Commit in projects/lcsim/trunk/analysis/src/main/java/org/lcsim/analysis on MAIN | |||
CalorimeterOccupancyDriver.java | +22 | -13 | 3103 -> 3104 |
added set method for collections to analyze.
--- projects/lcsim/trunk/analysis/src/main/java/org/lcsim/analysis/CalorimeterOccupancyDriver.java 2014-04-24 01:34:56 UTC (rev 3103) +++ projects/lcsim/trunk/analysis/src/main/java/org/lcsim/analysis/CalorimeterOccupancyDriver.java 2014-04-25 18:02:04 UTC (rev 3104) @@ -1,6 +1,8 @@
package org.lcsim.analysis;
+import java.util.Arrays;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List; import java.util.Map; import java.util.Set;
@@ -19,27 +21,29 @@
{ private boolean _debug = true;
- private String[] calNames = {"EcalBarrelHits", "EcalEndcapHits", "LumiCalHits"};
+ private Set<String> collections = new HashSet<String>();
private Map<String, Map<Long, Integer>> cellCountMaps = new HashMap<String, Map<Long, Integer>>(); private AIDA aida = AIDA.defaultInstance(); public CalorimeterOccupancyDriver() {
- for (int i = 0; i < calNames.length; ++i) { - cellCountMaps.put(calNames[i], new HashMap<Long, Integer>());
+ System.out.println("processing: "); + for (String collectionName : collections) { + System.out.println(collectionName); + cellCountMaps.put(collectionName, new HashMap<Long, Integer>());
} } @Override protected void process(EventHeader event) {
- // loop over all of the calorimeters - for (int i = 0; i < calNames.length; ++i) {
+ // loop over all of the collections + for (String collectionName : collections) {
// fetch the SimCalorimeterHits
- List<SimCalorimeterHit> hits = event.get(SimCalorimeterHit.class, calNames[i]); - log("There are " + hits.size() + " "+ calNames[i]);
+ List<SimCalorimeterHit> hits = event.get(SimCalorimeterHit.class, collectionName); + log("There are " + hits.size() + " "+ collectionName);
// get the right Map to populate
- Map<Long, Integer> map = cellCountMaps.get(calNames[i]);
+ Map<Long, Integer> map = cellCountMaps.get(collectionName);
// loop over all of the hits for (SimCalorimeterHit hit : hits) { long cellId = hit.getCellID();
@@ -59,10 +63,10 @@
{ // quick analysis... // loop over all of the calorimeters
- for (int i = 0; i < calNames.length; ++i) {
+ for (String collectionName : collections) {
// get the right Map to analyze
- System.out.println(calNames[i]); - Map<Long, Integer> map = cellCountMaps.get(calNames[i]);
+ System.out.println(collectionName); + Map<Long, Integer> map = cellCountMaps.get(collectionName);
//get its keys Set<Long> keys = map.keySet(); // loop over all of the hits
@@ -71,12 +75,17 @@
// and fill the histogram if(hitCount > 3) {
- System.out.println(calNames[i]+" id "+key+" has "+hitCount+" hits.");
+ System.out.println(collectionName+" id "+key+" has "+hitCount+" hits.");
}
- aida.histogram1D(calNames[i]+ "occupancy rates", 50, 0., 50.).fill(hitCount);
+ aida.histogram1D(collectionName+ "occupancy rates", 50, 0., 50.).fill(hitCount);
} } }
+ + public void setCollectionNames(String[] collectionNames) + { + collections.addAll(Arrays.asList(collectionNames)); + }
private void log(String s) {
Use REPLY-ALL to reply to list
To unsubscribe from the LCDET-SVN list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCDET-SVN&A=1