Commit in hps-java/src/main/java/org/lcsim/hps/recon/ecal on MAIN | |||
HPSEcalConverterAtoDDriver.java | +93 | added 1.1 |
add driver to convert CalorimeterHits directly to RawCalorimeterHits
diff -N HPSEcalConverterAtoDDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSEcalConverterAtoDDriver.java 20 Mar 2012 23:26:00 -0000 1.1 @@ -0,0 +1,93 @@
+/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.List; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawCalorimeterHit; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.Subdetector; +import org.lcsim.util.Driver; +import org.lcsim.util.lcio.LCIOConstants; + +/** + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: HPSEcalConverterAtoDDriver.java,v 1.1 2012/03/20 23:26:00 meeg Exp $ + */ +public class HPSEcalConverterAtoDDriver extends Driver { + + HPSEcalConverter converter = null; + Subdetector ecal; + String rawCollectionName = "EcalDigitizedHits"; + String ecalName; + String ecalReadoutName = "EcalHits"; + String ecalCollectionName; + int flags; + + public HPSEcalConverterAtoDDriver() { + flags = 0; + flags += 1 << LCIOConstants.CHBIT_LONG; //store position + flags += 1 << LCIOConstants.RCHBIT_ID1; //store cell ID + converter = new HPSEcalConverter(null); + } + + public void setPedestal(double pedestal) { + converter.setPedestal(pedestal); + } + + public void setScale(double scale) { + converter.setScale(scale); + } + + public void setEcalCollectionName(String ecalCollectionName) { + this.ecalCollectionName = ecalCollectionName; + } + + public void setEcalName(String ecalName) { + this.ecalName = ecalName; + } + + public void setRawCollectionName(String rawCollectionName) { + this.rawCollectionName = rawCollectionName; + } + + @Override + public void startOfData() { + if (ecalCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + + if (ecalName == null) { + throw new RuntimeException("The parameter ecalName was not set!"); + } + } + + @Override + public void detectorChanged(Detector detector) { + // Get the Subdetector. + ecal = (Subdetector) detector.getSubdetector(ecalName); + converter.setIDDecoder(ecal.getIDDecoder()); + } + + @Override + public void process(EventHeader event) { + // Get the list of ECal hits. + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); + if (hits == null) { + throw new RuntimeException("Event is missing ECal hits collection!"); + } + + ArrayList<RawCalorimeterHit> newHits = new ArrayList<RawCalorimeterHit>(); + + for (CalorimeterHit hit : hits) { + newHits.add(converter.HitAtoD(hit)); + } + + event.put(rawCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName); + } +}
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