Index: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInfo.java
===================================================================
--- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInfo.java	(revision 1422)
+++ trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskInfo.java	(revision 1423)
@@ -19,6 +19,6 @@
 /**
  * <p>
- * yet more or less unused, this class will in the future provide extended information about a
- * specific task, such as statistics about task occurrences, etc.
+ * Provides extended information about a specific task, such as statistics about task occurrences,
+ * etc. It contains measures for different metrics determined for a task.
  * </p>
  * 
@@ -38,10 +38,74 @@
     /**
      * <p>
-     * returns the number of times a task occurred
+     * returns all available measures
      * </p>
      * 
      * @return as described
      */
-    public int getCount();
+    public IMeasure[] getMeasures();
+
+    /**
+     * <p>
+     * returns the value of the measure identified through the given metric
+     * </p>
+     *
+     * @param metric the metric for which the value is to be returned
+     * 
+     * @return as described
+     */
+    public int getMeasureValue(TaskMetric metric);
+
+    /**
+     * <p>
+     * returns the value of the measure identified through the given metric if the task is
+     * observed in the given context, i.e. parent task. The result is Integer.MIN_VALUE if there
+     * is no value for this measure in a context.
+     * </p>
+     *
+     * @param metric  the metric for which the value is to be returned
+     * @param context the context for which the measure value is to be returned
+     * 
+     * @return as described
+     */
+    public int getMeasureValue(TaskMetric metric, ITask context);
+
+    /**
+     * <p>
+     * represents a measure for a specific metric
+     * </p>
+     * 
+     * @author Patrick Harms
+     */
+    public interface IMeasure {
+        
+        /**
+         * <p>
+         * returns the metric of the measure
+         * </p>
+         * 
+         * @return as described
+         */
+        public TaskMetric getMetric();
+        
+        /**
+         * <p>
+         * returns the value of the measure
+         * </p>
+         * 
+         * @return as described
+         */
+        public int getValue();
+        
+        /**
+         * <p>
+         * returns the value of the measure if the task was observed in a specific context, i.e.
+         * parent task
+         * </p>
+         * 
+         * @return as described
+         */
+        public int getValue(ITask context);
+        
+    }
 
 }
Index: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskModel.java
===================================================================
--- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskModel.java	(revision 1422)
+++ trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/ITaskModel.java	(revision 1423)
@@ -22,5 +22,5 @@
  * <p>
  * This class represents a complete task model. A task model within AutoQUEST is usually generated
- * based on user session. Therefore, the task model consists of the user sessions, the models
+ * based on user sessions. Therefore, the task model consists of the user sessions, the models
  * of the identified tasks, as well as further information about the tasks (e.g. their
  * occurrence count) for statistical processing.
@@ -63,4 +63,14 @@
     /**
      * <p>
+     * returns a list of all metrics calculated by this model for the tasks and stored in the
+     * respective task infos
+     * </p>
+     *
+     * @return as described
+     */
+    public TaskMetric[] getAllMetrics();
+
+    /**
+     * <p>
      * creates a deep clone of the model including all tasks and user sessions.
      * </p>
@@ -69,3 +79,4 @@
      */
     public ITaskModel clone();
+
 }
Index: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/TaskMetric.java
===================================================================
--- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/TaskMetric.java	(revision 1423)
+++ trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeifc/TaskMetric.java	(revision 1423)
@@ -0,0 +1,138 @@
+//   Copyright 2012 Georg-August-Universität Göttingen, Germany
+//
+//   Licensed under the Apache License, Version 2.0 (the "License");
+//   you may not use this file except in compliance with the License.
+//   You may obtain a copy of the License at
+//
+//       http://www.apache.org/licenses/LICENSE-2.0
+//
+//   Unless required by applicable law or agreed to in writing, software
+//   distributed under the License is distributed on an "AS IS" BASIS,
+//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//   See the License for the specific language governing permissions and
+//   limitations under the License.
+
+package de.ugoe.cs.autoquest.tasktrees.treeifc;
+
+import java.text.DecimalFormat;
+
+/**
+ * <p>
+ * represents different metrics available or calculatable for tasks. Measure for the metrics
+ * are calculated by a task model and added to the task infos of a specific task.
+ * </p>
+ * 
+ * @author Patrick Harms
+ */
+public enum TaskMetric {
+
+    COUNT("count", "number of all occurrences of the task in the model"),
+    DEPTH("depth",
+          "the maximum depth of the task, i.e., the number of children levels including the " +
+          "level of the task itself"),
+    EVENT_COVERAGE("covered events", "number of all event task instances covered by the task"),
+    EVENT_COVERAGE_RATIO("event coverage ratio",
+                         "the ratio of events covered by this task in relation to all events " +
+                         "covered by all tasks in their instances in per mille", 0.1, "%");
+    
+    /**
+     * <p>
+     * the name of the metric
+     * </p>
+     */
+    private String name;
+    
+    /**
+     * <p>
+     * a human readable description of the metric
+     * </p>
+     */
+    private String description;
+
+    /**
+     * <p>
+     * a scale applied for the metric when formatting the value
+     * </p>
+     */
+    private double formatScale;
+    
+    /**
+     * <p>
+     * the unit of the metric used when formatting the value
+     * </p>
+     */
+    private String formatUnit;
+    
+    /**
+     * <p>
+     * initializes the metric with a name and a description
+     * </p>
+     */
+    private TaskMetric(String name, String description) {
+        this.name = name;
+        this.description = description;
+        this.formatScale = 1.0;
+        this.formatUnit = null;
+    }
+
+    /**
+     * <p>
+     * initializes the metric with a name and a description, as well as with a scale and a unit for
+     * formatting it.
+     * </p>
+     */
+    private TaskMetric(String name, String description, double formatScale, String formatUnit) {
+        this.name = name;
+        this.description = description;
+        this.formatScale = formatScale;
+        this.formatUnit = formatUnit;
+    }
+
+    /**
+     * <p>
+     * returns the name of the metric
+     * </p>
+     * 
+     * @return the name of the metric
+     */
+    public String getName() {
+        return name;
+    }
+
+    /**
+     * <p>
+     * returns the human readable description of the metric
+     * </p>
+     * 
+     * @return the human readable description of the metric
+     */
+    public String getDescription() {
+        return description;
+    }
+    
+    /**
+     * <p>
+     * formats the provided value of a measure of the metric using the internal format scale and
+     * unit.
+     * </p>
+     * 
+     * @return the formatted value depending on the scale and unit of the metric
+     */
+    public String formatValue(int value) {
+        String formattedValue;
+        
+        if (formatScale != 1.0) {
+            double effectiveValue = formatScale * value;
+            formattedValue = new DecimalFormat( "#,##0.0;(#)").format(effectiveValue);
+        }
+        else {
+            formattedValue = Integer.toString(value);
+        }
+        
+        if (formatUnit != null) {
+            formattedValue += formatUnit;
+        }
+        
+        return formattedValue;
+    }
+}
Index: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInfo.java
===================================================================
--- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInfo.java	(revision 1422)
+++ trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskInfo.java	(revision 1423)
@@ -15,6 +15,10 @@
 package de.ugoe.cs.autoquest.tasktrees.treeimpl;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+
 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.TaskMetric;
 
 /**
@@ -41,11 +45,11 @@
      */
     private ITask task;
-
-    /**
-     * <p>
-     * the number of occurrences of this task
-     * </p>
-     */
-    private int count;
+    
+    /**
+     * <p>
+     * all available measures for the task
+     * </p>
+     */
+    private ArrayList<Measure> measures = new ArrayList<Measure>();
 
     /**
@@ -69,9 +73,38 @@
 
     /* (non-Javadoc)
-     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo#getCount()
-     */
-    @Override
-    public int getCount() {
-        return count;
+     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo#getMeasures()
+     */
+    @Override
+    public IMeasure[] getMeasures() {
+        measures.trimToSize();
+        return measures.toArray(new IMeasure[measures.size()]);
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo#getMeasureValue(java.lang.String)
+     */
+    @Override
+    public int getMeasureValue(TaskMetric metric) {
+        Measure measure = getMeasure(metric);
+        
+        if (measure == null) {
+            throw new IllegalArgumentException("unknown metric " + metric);
+        }
+        
+        return measure.getValue();
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo#getMeasureValue(java.lang.String, de.ugoe.cs.autoquest.tasktrees.treeifc.ITask)
+     */
+    @Override
+    public int getMeasureValue(TaskMetric metric, ITask context) {
+        Measure measure = getMeasure(metric);
+        
+        if (measure == null) {
+            throw new IllegalArgumentException("unknown metric " + metric);
+        }
+        
+        return measure.getValue(context);
     }
 
@@ -86,9 +119,192 @@
     /**
      * <p>
-     * used to increase the counter of occurrences of this task by one
-     * </p>
-     */
-    void increaseCount() {
-        count++;
-    }
+     * must be called to indicate that a new new measures for the provided metric are about to
+     * be calculated and added.
+     * </p>
+     *
+     * @param metric the metric for which measures are about to be provided
+     */
+    void addMeasure(TaskMetric metric) {
+        Measure measure = getMeasure(metric);
+        
+        if (measure != null) {
+            throw new IllegalArgumentException("measure for metric " + metric + " already exists.");
+        }
+        
+        measure = new Measure(metric);
+        measures.add(measure);
+    }
+
+    /**
+     * <p>
+     * sets a specific value for a measure of a specific metric in the provided context of the task
+     * </p>
+     * 
+     * @param metric  the metric to which the value belongs
+     * @param context the context of the task in which the measure was recorded
+     * @param value   the value of the measure
+     */
+    void setCount(TaskMetric metric, ITask context, int value) {
+        Measure measure = getMeasure(metric);
+        
+        if (measure == null) {
+            throw new IllegalArgumentException("unknown metric. Please create a measure " +
+                                               "for the metric before using it.");
+        }
+        
+        measure.set(context, value);
+    }
+
+    /**
+     * <p>
+     * increases a specific value for a measure of a specific metric in the provided context of the
+     * task
+     * </p>
+     * 
+     * @param metric    the metric to which the value belongs
+     * @param context   the context of the task in which the measure was recorded
+     * @param increment the increment to be added to the value of the measure
+     */
+    void increaseCount(TaskMetric metric, ITask context, int increment) {
+        Measure measure = getMeasure(metric);
+        
+        if (measure == null) {
+            throw new IllegalArgumentException("unknown metric. Please create a measure " +
+                                               "for the metric before using it.");
+        }
+        
+        measure.increase(context, increment);
+    }
+
+    /**
+     * <p>
+     * convenience method to internally determine the measure for a specific metric
+     * </p>
+     */
+    private Measure getMeasure(TaskMetric metric) {
+        for (Measure candidate : measures) {
+            if (candidate.getMetric().equals(metric)) {
+                return candidate;
+            }
+        }
+        
+        return null;
+    }
+
+    /**
+     * <p>
+     * implementation for the measure interface of the task info interface. Does nothing fancy
+     * except implementing the interface
+     * </p>
+     * 
+     * @author Patrick Harms
+     */
+    private static class Measure implements IMeasure {
+
+        /**
+         * <p>
+         * the metric to which the measure belongs
+         * </p>
+         */
+        private TaskMetric metric;
+        
+        /**
+         * <p>
+         * the observed values for the difference contexts of the task
+         * </p>
+         */
+        private HashMap<ITask, Integer> values;
+        
+        /**
+         * <p>
+         * the context free value of the measure independent of the task context
+         * </p>
+         */
+        private int contextFreeValue = 0;
+        
+        /**
+         * <p>
+         * initializes the measure with a specific metric
+         * </p>
+         */
+        private Measure(TaskMetric metric) {
+            super();
+            this.metric = metric;
+        }
+
+        /* (non-Javadoc)
+         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo.IMeasure#getMetric()
+         */
+        @Override
+        public TaskMetric getMetric() {
+            return metric;
+        }
+
+        /* (non-Javadoc)
+         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo.IMeasure#getValue()
+         */
+        @Override
+        public int getValue() {
+            return contextFreeValue;
+        }
+
+        /* (non-Javadoc)
+         * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo.IMeasure#getValue(de.ugoe.cs.autoquest.tasktrees.treeifc.ITask)
+         */
+        @Override
+        public int getValue(ITask context) {
+            if ((context != null) && (values != null)) {
+                Integer currentValue = values.get(context);
+                
+                if (currentValue != null) {
+                    return currentValue;
+                }
+            }
+            
+            return Integer.MIN_VALUE;
+        }
+
+        /**
+         * <p>
+         * sets the value of the measure context free as well as specific to the provided context
+         * </p>
+         */
+        private void set(ITask context, int value) {
+            contextFreeValue = value;
+            
+            if (context != null) {
+                if (values == null) {
+                    values = new HashMap<ITask, Integer>();
+                }
+                
+                values.put(context, value);
+            }
+        }
+
+        /**
+         * <p>
+         * increases the value of the measure context free as well as specific to the provided
+         * context according to the provided increment
+         * </p>
+         */
+        private void increase(ITask context, int increment) {
+            contextFreeValue += increment;
+            
+            if (context != null) {
+                if (values == null) {
+                    values = new HashMap<ITask, Integer>();
+                }
+                
+                Integer currentValue = values.get(context);
+                
+                if (currentValue == null) {
+                    currentValue = 0;
+                }
+                
+                values.put(context, currentValue + increment);
+            }
+        }
+
+    }
+
 }
Index: trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java
===================================================================
--- trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java	(revision 1422)
+++ trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/treeimpl/TaskModel.java	(revision 1423)
@@ -21,4 +21,14 @@
 import java.util.Map;
 
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTaskInstance;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IIterationInstance;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptional;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IOptionalInstance;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelection;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.ISelectionInstance;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;
@@ -27,9 +37,11 @@
 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInfo;
 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession;
+import de.ugoe.cs.autoquest.tasktrees.treeifc.TaskMetric;
 
 /**
  * <p>
  * this is the default implementation of the interface {@link ITaskModel}. It
- * does not do anything fancy except implementing the interface.
+ * does not do anything fancy except implementing the interface. It also calculates on
+ * initialisations the measures for diverse metrics of the task belonging to the model
  * </p>
  * 
@@ -44,4 +56,15 @@
      */
     private static final long serialVersionUID = 1L;
+    
+    /**
+     * <p>
+     * all metrics calculated by this type of task model
+     * </p>
+     */
+    private static final TaskMetric[] taskMetrics = new TaskMetric[]
+        { TaskMetric.COUNT,
+          TaskMetric.DEPTH,
+          TaskMetric.EVENT_COVERAGE,
+          TaskMetric.EVENT_COVERAGE_RATIO };
 
     /**
@@ -54,10 +77,9 @@
     /**
      * <p>
-     * the tasks contained in the user session belonging to the model as well as statistical infos
-     * about them
-     * </p>
-     */
-    private Map<ITask, TaskInfo> taskMap = new HashMap<ITask, TaskInfo>();
-
+     * index for effectively accessing the model and calculating statistics about it
+     * </p>
+     */
+    private transient TaskModelIndex index = null;
+    
     /**
      * <p>
@@ -73,10 +95,4 @@
         
         this.userSessions = userSessions;
-        
-        for (IUserSession session : this.userSessions) {
-            for (ITaskInstance taskInstance : session) {
-                addTasksToMap(taskInstance);
-            }
-        }
     }
 
@@ -87,4 +103,5 @@
     @Override
     public List<IUserSession> getUserSessions() {
+        ensureInitialized();
         return Collections.unmodifiableList(userSessions);
     }
@@ -96,5 +113,6 @@
     @Override
     public Collection<ITask> getTasks() {
-        return Collections.unmodifiableCollection(taskMap.keySet());
+        ensureInitialized();
+        return Collections.unmodifiableCollection(index.taskMap.keySet());
     }
 
@@ -105,6 +123,16 @@
     @Override
     public ITaskInfo getTaskInfo(ITask task) {
-        return taskMap.get(task);
-    }
+        ensureInitialized();
+        return index.taskMap.get(task);
+    }
+
+    /* (non-Javadoc)
+     * @see de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel#getAllMetrics()
+     */
+    @Override
+    public TaskMetric[] getAllMetrics() {
+        return taskMetrics;
+    }
+
 
     /* (non-Javadoc)
@@ -116,48 +144,228 @@
     }
 
-
-    /**
-     * <p>
-     * internal convenience method to recursively add the tasks of a task instance and its
-     * children to the task model
-     * </p>
-     *
-     * @param taskInstance the task instance of which the tasks shall be added
-     */
-    private void addTasksToMap(ITaskInstance taskInstance) {
-        addTaskToMap(taskInstance.getTask());
-        
-        if (taskInstance instanceof ITaskInstanceList) {
-            for (ITaskInstance child : (ITaskInstanceList) taskInstance) {
-                addTasksToMap(child);
-            }
-        }
-    }
-
-    
-    /**
-     * <p>
-     * internal convenience method to build the task model during initialization
-     * </p>
-     */
-    private void addTaskToMap(ITask task) {
-        TaskInfo taskInfo = taskMap.get(task);
-
-        if (taskInfo == null) {
-            taskInfo = new TaskInfo(task);
-            taskMap.put(task, taskInfo);
-        }
-
-        taskInfo.increaseCount();
-
-        /*if (task instanceof IStructuringTemporalRelationship) {
-            for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) {
-                addTaskToMap(child);
-            }
-        }
-        else if (task instanceof IMarkingTemporalRelationship) {
-            addTaskToMap(((IMarkingTemporalRelationship) task).getMarkedTask());
+    /**
+     * <p>
+     * internal convenience method that initializes the internal index and calculates all measures
+     * for metrics available for the tasks
+     * </p>
+     */
+    private synchronized void ensureInitialized() {
+        if (index == null) {
+            index = new TaskModelIndex();
+            
+            for (IUserSession session : this.userSessions) {
+                for (ITaskInstance taskInstance : session) {
+                    index.handleTaskInstance(taskInstance, null);
+                }
+            }
+            
+            // count all events covered
+            int allEventsCovered = 0;
+            Collection<ITask> tasks = getTasks();
+            for (ITask task : tasks) {
+                if (task instanceof IEventTask) {
+                    allEventsCovered += task.getInstances().size();
+                }
+            }
+            
+            // add some further measures
+            for (ITask task : tasks) {
+                TaskInfo info = index.taskMap.get(task);
+                info.addMeasure(TaskMetric.EVENT_COVERAGE_RATIO);
+                
+                int coveredEvents = info.getMeasureValue(TaskMetric.EVENT_COVERAGE);
+                
+                if (allEventsCovered > 0) {
+                    info.setCount(TaskMetric.EVENT_COVERAGE_RATIO, null,
+                                  ((coveredEvents * 1000) / allEventsCovered));
+                }
+            }
+            
+            //index.dumpToCSV(System.out);
+            /*try {
+                OutputStream stream = new FileOutputStream(new File("tasks.csv"));
+                index.dumpToCSV(new PrintStream(stream));
+                stream.close();
+            }
+            catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }*/
+        }
+        
+    }
+
+    /**
+     * <p>
+     * the index of task infos used internally. The index is created once and while that filled
+     * with task infos for each observed task containing all measures for metrics belonging
+     * to the tasks. 
+     * </p>
+     * 
+     * @author Patrick Harms
+     */
+    private static class TaskModelIndex {
+
+        /**
+         * <p>
+         * the tasks contained in the user session belonging to the model as well as statistical
+         * infos about them
+         * </p>
+         */
+        private Map<ITask, TaskInfo> taskMap = new HashMap<ITask, TaskInfo>();
+
+        /**
+         * <p>
+         * called on initialization to fill the index with infos about the given task instance
+         * as well as to calculate the appropriate metrics
+         * </p>
+         */
+        private int[] handleTaskInstance(ITaskInstance taskInstance, ITask context) {
+            int eventTaskInstancesCovered = 0;
+            int depth = 0;
+            
+            if (taskInstance instanceof ITaskInstanceList) {
+                for (ITaskInstance child : (ITaskInstanceList) taskInstance) {
+                    int[] measures = handleTaskInstance(child, taskInstance.getTask());
+                    eventTaskInstancesCovered += measures[0];
+                    depth = Math.max(depth, measures[1]);
+                }
+                
+                if ((((ITaskInstanceList) taskInstance).size() == 0) &&
+                    (taskInstance instanceof IIterationInstance))
+                {
+                    // ensure also empty task infos for unselected variants
+                    ensureTaskInfo(((IIteration) taskInstance.getTask()).getMarkedTask(), context);
+                }
+            }
+            else if (taskInstance instanceof ISelectionInstance) {
+                ITaskInstance child = ((ISelectionInstance) taskInstance).getChild();
+                int[] measures = handleTaskInstance(child, taskInstance.getTask());
+                eventTaskInstancesCovered += measures[0];
+                depth = Math.max(depth, measures[1]);
+                
+                // ensure also empty task infos for unselected variants
+                for (ITask otherChildTask : ((ISelection) taskInstance.getTask()).getChildren()) {
+                    ensureTaskInfo(otherChildTask, context);
+                }
+            }
+            else if (taskInstance instanceof IOptionalInstance) {
+                ITaskInstance child = ((IOptionalInstance) taskInstance).getChild();
+                if (child != null) {
+                    int[] measures = handleTaskInstance(child, taskInstance.getTask());
+                    eventTaskInstancesCovered += measures[0];
+                    depth = Math.max(depth, measures[1]);
+                }
+                else {
+                    // ensure also empty task infos for unselected variants
+                    ensureTaskInfo(((IOptional) taskInstance.getTask()).getMarkedTask(), context);
+                }
+            }
+            else if (taskInstance instanceof IEventTaskInstance) {
+                eventTaskInstancesCovered = 1;
+            }
+            
+            depth++;
+            
+            ensureTaskInfo(taskInstance.getTask(), context, eventTaskInstancesCovered, depth);
+            
+            return new int[] { eventTaskInstancesCovered, depth };
+        }
+        
+        /**
+         * <p>
+         * internal convenience method to build the task model during initialization
+         * </p>
+         */
+        private void ensureTaskInfo(ITask task, ITask context) {
+            ensureTaskInfo(task, context, 0, 0);
+            
+            if (task instanceof IStructuringTemporalRelationship) {
+                for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) {
+                    ensureTaskInfo(child, task);
+                }
+            }
+            else if (task instanceof IMarkingTemporalRelationship) {
+                ensureTaskInfo(((IMarkingTemporalRelationship) task).getMarkedTask(), task);
+            }
+        
+        }
+        
+        /**
+         * <p>
+         * internal convenience method to build the task model during initialization. Adds a new
+         * task info object to the map for the provided task and fills it with measures. If there
+         * are already some task infos for the task, the contained measures are updated according
+         * to the parameters.
+         * </p>
+         */
+        private void ensureTaskInfo(ITask task,
+                                    ITask context,
+                                    int   eventTaskInstancesCovered,
+                                    int   depth)
+        {
+            TaskInfo taskInfo = taskMap.get(task);
+
+            if (taskInfo == null) {
+                taskInfo = new TaskInfo(task);
+                taskInfo.addMeasure(TaskMetric.COUNT);
+                taskInfo.addMeasure(TaskMetric.EVENT_COVERAGE);
+                taskInfo.addMeasure(TaskMetric.DEPTH);
+                taskMap.put(task, taskInfo);
+                
+                taskInfo.setCount(TaskMetric.DEPTH, null, getDepth(task));
+            }
+
+            taskInfo.increaseCount(TaskMetric.COUNT, context, 1);
+            taskInfo.increaseCount(TaskMetric.EVENT_COVERAGE, context, eventTaskInstancesCovered);
+
+            taskInfo.setCount(TaskMetric.DEPTH, context, depth);
+        }
+
+        /**
+         * <p>
+         * internal convenience method to calculate the maximum depth of a task
+         * </p>
+         */
+        private int getDepth(ITask task) {
+            if (task instanceof IMarkingTemporalRelationship) {
+                return getDepth(((IMarkingTemporalRelationship) task).getMarkedTask()) + 1;
+            }
+            else if (task instanceof IStructuringTemporalRelationship) {
+                int maxDepth = 0;
+                
+                for (ITask child : ((IStructuringTemporalRelationship) task).getChildren()) {
+                    maxDepth = Math.max(maxDepth, getDepth(child));
+                }
+                
+                return maxDepth + 1;
+            }
+            else {
+                // event tasks
+                return 1;
+            }
+        }
+
+        /**
+         *
+         */
+        /*private void dumpToCSV(PrintStream out) {
+            out.println("taskid;depth;count;eventcoverage;eventcoverageratio");
+            
+            for (Map.Entry<ITask, TaskInfo> entry : taskMap.entrySet()) {
+                out.print(entry.getKey().getId());
+                out.print(';');
+                out.print(entry.getValue().getMeasureValue(TaskMetric.DEPTH));
+                out.print(';');
+                out.print(entry.getValue().getMeasureValue(TaskMetric.COUNT));
+                out.print(';');
+                out.print(entry.getValue().getMeasureValue(TaskMetric.EVENT_COVERAGE));
+                out.print(';');
+                out.print(entry.getValue().getMeasureValue(TaskMetric.EVENT_COVERAGE_RATIO));
+                out.println();
+            }
         }*/
-    }
+
+    }
+
 
 }
