Commit in projects/lcsim/trunk/analysis/src/main/java/org/lcsim/analysis on MAIN | |||
CalorimeterOccupancyDriver.java | +87 | added 3069 |
new analysis Driver to calculate occupancies
--- projects/lcsim/trunk/analysis/src/main/java/org/lcsim/analysis/CalorimeterOccupancyDriver.java (rev 0) +++ projects/lcsim/trunk/analysis/src/main/java/org/lcsim/analysis/CalorimeterOccupancyDriver.java 2014-04-01 19:04:20 UTC (rev 3069) @@ -0,0 +1,87 @@
+package org.lcsim.analysis; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.lcsim.event.EventHeader; +import org.lcsim.event.SimCalorimeterHit; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +/** + * + * @author Norman A Graf + * + * @version $Id: + */ +public class CalorimeterOccupancyDriver extends Driver +{ + + private boolean _debug = true; + private String[] calNames = {"EcalBarrelHits", "EcalEndcapHits", "LumiCalHits"}; + 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>()); + } + } + + @Override + protected void process(EventHeader event) + { + // loop over all of the calorimeters + for (int i = 0; i < calNames.length; ++i) { + // fetch the SimCalorimeterHits + List<SimCalorimeterHit> hits = event.get(SimCalorimeterHit.class, calNames[i]); + log("There are " + hits.size() + " "+ calNames[i]); + // get the right Map to populate + Map<Long, Integer> map = cellCountMaps.get(calNames[i]); + // loop over all of the hits + for (SimCalorimeterHit hit : hits) { + long cellId = hit.getCellID(); + // and update the occupancy of this address + if (map.containsKey(cellId)) { +// System.out.println("id: "+cellId+" now has "+(map.get(cellId) + 1)+ " hits."); + map.put(cellId, map.get(cellId) + 1); + } else { + map.put(cellId, 1); + } + } + } + } + + @Override + protected void endOfData() + { + // quick analysis... + // loop over all of the calorimeters + for (int i = 0; i < calNames.length; ++i) { + // get the right Map to analyze + System.out.println(calNames[i]); + Map<Long, Integer> map = cellCountMaps.get(calNames[i]); + //get its keys + Set<Long> keys = map.keySet(); + // loop over all of the hits + for (Long key : keys) { + Integer hitCount = map.get(key); + // and fill the histogram + if(hitCount > 3) + { + System.out.println(calNames[i]+" id "+key+" has "+hitCount+" hits."); + } + aida.cloud1D(calNames[i]+ "occupancy rates").fill(hitCount); + } + } + } + + private void log(String s) + { + if (_debug) { + System.out.println(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