Commit in hps-java/src/main on MAIN | |||
resources/org/lcsim/hps/steering/DataQuality.lcsim | +18 | added 1.1 | |
java/org/lcsim/hps/util/CollectionSizeDriver.java | +73 | added 1.1 | |
+91 |
first pass at standard data quality reports
diff -N DataQuality.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ DataQuality.lcsim 22 Feb 2013 01:32:22 -0000 1.1 @@ -0,0 +1,18 @@
+<!-- + Quick summary of file contents, to be run after readout simulation or reconstruction. + @author Sho Uemura <[log in to unmask]> + @version $Id: DataQuality.lcsim,v 1.1 2013/02/22 01:32:22 meeg Exp $ +--> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <control> + <printInputFiles>true</printInputFiles> + <printDriversDetailed>true</printDriversDetailed> + </control> + <execute> + <driver name="CollectionSizeDriver"/> + </execute> + <drivers> + <driver name="CollectionSizeDriver" type="org.lcsim.hps.util.CollectionSizeDriver"/> + </drivers> +</lcsim>
diff -N CollectionSizeDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ CollectionSizeDriver.java 22 Feb 2013 01:32:22 -0000 1.1 @@ -0,0 +1,73 @@
+package org.lcsim.hps.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.lcsim.event.EventHeader; +import org.lcsim.util.Driver; + +/** + * Prints a summary of collections seen in the file, and their average sizes. + * @author Sho Uemura <[log in to unmask]> + * @version $Id: CollectionSizeDriver.java,v 1.1 2013/02/22 01:32:22 meeg Exp $ + */ +public class CollectionSizeDriver extends Driver { + + int eventCount = 0; + private Map<String, CollectionStats> collections = new HashMap<String, CollectionStats>(); + + @Override + public void process(EventHeader event) { + List<List<Object>> listOfLists = event.get(Object.class); + for (List<Object> list : listOfLists) { + String name = event.getMetaData(list).getName(); + Class type = event.getMetaData(list).getType(); + + CollectionStats stats = collections.get(name); + if (stats == null) { + stats = new CollectionStats(name, type); + collections.put(name, stats); + } + + stats.addCount(list.size()); + } + + eventCount++; + } + + @Override + public void endOfData() { + List<String> names = new ArrayList<String>(collections.keySet()); + java.util.Collections.sort(names); + for (String name:names){ + collections.get(name).printStats(eventCount); + } + } + + private class CollectionStats { + + String name; + Class type; + double eventsWithCollection = 0; + double totalCount = 0; + + public CollectionStats(String name, Class type) { + this.name = name; + this.type = type; + } + + public void addCount(int count) { + eventsWithCollection++; + totalCount += count; + } + + public void printStats(int eventCount) { + double fractionWithCollection = eventsWithCollection / eventCount; + double averageCollectionSize = totalCount / eventsWithCollection; + + System.out.format("%s (%s): %f of events had this collection, with an average of %f elements\n", name, type.getSimpleName(), fractionWithCollection, averageCollectionSize); + + } + } +}
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1