Commit in hps-java/src/main/java/org/lcsim/hps/evio on MAIN | |||
ECalEvioReader.java | +122 | added 1.1 | |
LCSimTestRunEventBuilder.java | +91 | -84 | 1.5 -> 1.6 |
+213 | -84 |
broke out ECal portion of LCSim event builder
diff -N ECalEvioReader.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ECalEvioReader.java 5 Apr 2012 21:05:52 -0000 1.1 @@ -0,0 +1,122 @@
+/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package org.lcsim.hps.evio; + +import org.lcsim.event.base.BaseRawCalorimeterHit; +import org.jlab.coda.jevio.BaseStructureHeader; +import org.jlab.coda.jevio.BaseStructure; +import org.jlab.coda.jevio.EvioEvent; +import org.jlab.coda.jevio.CompositeData; +import java.util.ArrayList; +import java.util.List; +import org.jlab.coda.jevio.EvioException; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawCalorimeterHit; +import org.lcsim.hps.recon.ecal.HPSEcalDaqIDConverter; + +/** + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: ECalEvioReader.java,v 1.1 2012/04/05 21:05:52 meeg Exp $ + */ +public class ECalEvioReader { + // Names of subdetectors. + + // Debug flag. + private boolean debug = false; + private String rawCalorimeterHitCollectionName = "EcalReadoutHits"; + private String ecalName = "Ecal"; + private HPSEcalDaqIDConverter ecalIDConverter = null; + + public ECalEvioReader() { + } + + public void setEcalName(String ecalName) { + this.ecalName = ecalName; + } + + public void setRawCalorimeterHitCollectionName(String rawCalorimeterHitCollectionName) { + this.rawCalorimeterHitCollectionName = rawCalorimeterHitCollectionName; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public void makeRawCalorimeterHits(EvioEvent event, EventHeader lcsimEvent) { + if (ecalIDConverter == null) { + ecalIDConverter = new HPSEcalDaqIDConverter(); + ecalIDConverter.fillDaqCellMap(lcsimEvent.getDetector().getSubdetector(ecalName)); + } + List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); + for (BaseStructure bank : event.getChildren()) { + BaseStructureHeader header = bank.getHeader(); + int bankTag = header.getTag(); + if (bankTag == MCRawDataToEvio4Converter.ecalBottomBankTag || bankTag == MCRawDataToEvio4Converter.ecalTopBankTag) { + if (bank.getChildCount() > 0) { + if (debug) { + System.out.println("ECal bank tag: " + header.getTag() + "; childCount: " + bank.getChildCount()); + } + for (BaseStructure slotBank : bank.getChildren()) { + CompositeData cdata = null; + try { + cdata = slotBank.getCompositeData(); + } catch (EvioException e) { + throw new RuntimeException(e); + } + List<RawCalorimeterHit> bankHits = makeRawCalorimeterHits(cdata, bankTag); + hits.addAll(bankHits); + } + } + } + } + String readoutName = lcsimEvent.getDetector().getSubdetector(ecalName).getReadout().getName(); + lcsimEvent.put(rawCalorimeterHitCollectionName, hits, RawCalorimeterHit.class, 0, readoutName); + } + + private List<RawCalorimeterHit> makeRawCalorimeterHits(CompositeData cdata, int bankTag) { + List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); + if (debug) { + int n = cdata.getNValues().size(); + for (int i = 0; i < n; i++) { + System.out.println("cdata.N[" + i + "]=" + cdata.getNValues().get(i)); + } + int ni = cdata.getItems().size(); + for (int i = 0; i < ni; i++) { + System.out.println("cdata.type[" + i + "]=" + cdata.getTypes().get(i)); + } + } + + int crate = bankTag; + short slot = cdata.getByte(); + int trigger = cdata.getInt(); + long timestamp = cdata.getLong(); + int nchannels = cdata.getNValue(); + if (debug) { + System.out.println("slot#=" + slot + "; trigger=" + trigger + "; timestamp=" + timestamp + "; nchannels=" + nchannels); + } + for (int j = 0; j < nchannels; j++) { + short channel = cdata.getByte(); + int npulses = cdata.getNValue(); + if (debug) { + System.out.println(" channel=" + channel + "; npulses=" + npulses); + } + long daqID = HPSEcalDaqIDConverter.getDaqID(crate, slot, channel); + Long id = ecalIDConverter.daqToPhysicalID(daqID); +// System.out.printf("crate = %d, slot = %d, channel = %d\n", crate, slot, channel); +// System.out.printf("physicalID %d, daqID %d\n", id, daqID); + + for (int k = 0; k < npulses; k++) { + short pulseTime = cdata.getShort(); + int pulseIntegral = cdata.getInt(); + if (debug) { + System.out.println(" pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral); + } + hits.add(new BaseRawCalorimeterHit(id, pulseIntegral, pulseTime)); + } + } + return hits; + } +}
diff -u -r1.5 -r1.6 --- LCSimTestRunEventBuilder.java 5 Apr 2012 19:05:23 -0000 1.5 +++ LCSimTestRunEventBuilder.java 5 Apr 2012 21:05:52 -0000 1.6 @@ -27,7 +27,7 @@
* Build LCSim events from EVIO data. * @author Sho Uemura <[log in to unmask]> * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: LCSimTestRunEventBuilder.java,v 1.5 2012/04/05 19:05:23 meeg Exp $
+ * @version $Id: LCSimTestRunEventBuilder.java,v 1.6 2012/04/05 21:05:52 meeg Exp $
*/ public class LCSimTestRunEventBuilder implements LCSimEventBuilder {
@@ -42,7 +42,7 @@
private Detector detector; // Debug flag. private boolean debug = false;
- private HPSEcalDaqIDConverter ecalIDConverter;
+ ECalEvioReader ecalReader = null;
public LCSimTestRunEventBuilder() { }
@@ -67,6 +67,7 @@
public void setDebug(boolean debug) { this.debug = debug;
+ ecalReader = null;
} public String getRawTrackerHitCollectionName() {
@@ -83,6 +84,7 @@
public void setRawCalorimeterHitCollectionName(String rawCalorimeterHitCollectionName) { this.rawCalorimeterHitCollectionName = rawCalorimeterHitCollectionName;
+ ecalReader = null;
} public String getTrackerName() {
@@ -103,6 +105,7 @@
public void setCalorimeterName(String calorimeterName) { this.calorimeterName = calorimeterName;
+ ecalReader = null;
} public String getCalorimeterReadoutName() {
@@ -115,18 +118,21 @@
public EventHeader makeLCSimEvent(EvioEvent evioEvent) {
+ // Create a new LCSimEvent. + EventHeader lcsimEvent = new BaseLCSimEvent(0, evioEvent.getHeader().getNumber(), detector.getDetectorName()); + + if (ecalReader == null) { + ecalReader = new ECalEvioReader(); + ecalReader.setEcalName(calorimeterName); + ecalReader.setRawCalorimeterHitCollectionName(rawCalorimeterHitCollectionName); + ecalReader.setDebug(debug); + } +
// Make RawTrackerHit collection. //List<RawTrackerHit> rawTrackerHits = makeRawTrackerHits(evioEvent); // Make RawCalorimeterHit collection, combining top and bottom section of ECal into one list.
- List<RawCalorimeterHit> rawCalorimeterHits = makeRawCalorimeterHits(evioEvent); - - // Create a new LCSimEvent. - EventHeader lcsimEvent = new BaseLCSimEvent(0, evioEvent.getHeader().getNumber(), detector.getDetectorName()); - - // Add the hit collections. - //lcsimEvent.put(rawTrackerHitCollectionName, rawTrackerHits, RawTrackerHit.class, (1 << LCIOConstants.TRAWBIT_ID1), getTrackerReadoutName()); - lcsimEvent.put(rawCalorimeterHitCollectionName, rawCalorimeterHits, RawCalorimeterHit.class, 0, getCalorimeterReadoutName());
+ ecalReader.makeRawCalorimeterHits(evioEvent, lcsimEvent);
return lcsimEvent; }
@@ -258,78 +264,79 @@
return sensor; } */
- private List<RawCalorimeterHit> makeRawCalorimeterHits(EvioEvent event) { - List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); - for (BaseStructure bank : event.getChildren()) { - BaseStructureHeader header = bank.getHeader(); - int bankTag = header.getTag(); - if (bankTag == MCRawDataToEvio4Converter.ecalBottomBankTag || bankTag == MCRawDataToEvio4Converter.ecalTopBankTag) { - if (bank.getChildCount() > 0) { - if (debug) { - System.out.println("ECal bank tag: " + header.getTag() + "; childCount: " + bank.getChildCount()); - } - for (BaseStructure slotBank : bank.getChildren()) { - CompositeData cdata = null; - try { - cdata = slotBank.getCompositeData(); - } catch (EvioException e) { - throw new RuntimeException(e); - } - List<RawCalorimeterHit> bankHits = makeRawCalorimeterHits(cdata, bankTag); - hits.addAll(bankHits); - } - } - } - } - return hits; - } - - private List<RawCalorimeterHit> makeRawCalorimeterHits(CompositeData cdata, int bankTag) { - List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); - if (ecalIDConverter == null) { - ecalIDConverter = new HPSEcalDaqIDConverter(); - ecalIDConverter.fillDaqCellMap(detector.getSubdetector(calorimeterName)); - } - - if (debug) { - int n = cdata.getNValues().size(); - for (int i = 0; i < n; i++) { - System.out.println("cdata.N[" + i + "]=" + cdata.getNValues().get(i)); - } - int ni = cdata.getItems().size(); - for (int i = 0; i < ni; i++) { - System.out.println("cdata.type[" + i + "]=" + cdata.getTypes().get(i)); - } - } - - int crate = bankTag; - short slot = cdata.getByte(); - int trigger = cdata.getInt(); - long timestamp = cdata.getLong(); - int nchannels = cdata.getNValue(); - if (debug) { - System.out.println("slot#=" + slot + "; trigger=" + trigger + "; timestamp=" + timestamp + "; nchannels=" + nchannels); - } - for (int j = 0; j < nchannels; j++) { - short channel = cdata.getByte(); - int npulses = cdata.getNValue(); - if (debug) { - System.out.println(" channel=" + channel + "; npulses=" + npulses); - } - long daqID = HPSEcalDaqIDConverter.getDaqID(crate, slot, channel); - Long id = ecalIDConverter.daqToPhysicalID(daqID); -// System.out.printf("crate = %d, slot = %d, channel = %d\n", crate, slot, channel); -// System.out.printf("physicalID %d, daqID %d\n", id, daqID); - - for (int k = 0; k < npulses; k++) { - short pulseTime = cdata.getShort(); - int pulseIntegral = cdata.getInt(); - if (debug) { - System.out.println(" pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral); - } - hits.add(new BaseRawCalorimeterHit(id, pulseIntegral, pulseTime)); - } - } - return hits; - }
+// private void makeRawCalorimeterHits(EvioEvent event, EventHeader lcsimEvent) { +// List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); +// for (BaseStructure bank : event.getChildren()) { +// BaseStructureHeader header = bank.getHeader(); +// int bankTag = header.getTag(); +// if (bankTag == MCRawDataToEvio4Converter.ecalBottomBankTag || bankTag == MCRawDataToEvio4Converter.ecalTopBankTag) { +// if (bank.getChildCount() > 0) { +// if (debug) { +// System.out.println("ECal bank tag: " + header.getTag() + "; childCount: " + bank.getChildCount()); +// } +// for (BaseStructure slotBank : bank.getChildren()) { +// CompositeData cdata = null; +// try { +// cdata = slotBank.getCompositeData(); +// } catch (EvioException e) { +// throw new RuntimeException(e); +// } +// List<RawCalorimeterHit> bankHits = makeRawCalorimeterHits(cdata, bankTag); +// hits.addAll(bankHits); +// } +// } +// } +// } +// +// lcsimEvent.put(rawCalorimeterHitCollectionName, hits, RawCalorimeterHit.class, 0, getCalorimeterReadoutName()); +// } +// +// private List<RawCalorimeterHit> makeRawCalorimeterHits(CompositeData cdata, int bankTag) { +// List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); +// if (ecalIDConverter == null) { +// ecalIDConverter = new HPSEcalDaqIDConverter(); +// ecalIDConverter.fillDaqCellMap(detector.getSubdetector(calorimeterName)); +// } +// +// if (debug) { +// int n = cdata.getNValues().size(); +// for (int i = 0; i < n; i++) { +// System.out.println("cdata.N[" + i + "]=" + cdata.getNValues().get(i)); +// } +// int ni = cdata.getItems().size(); +// for (int i = 0; i < ni; i++) { +// System.out.println("cdata.type[" + i + "]=" + cdata.getTypes().get(i)); +// } +// } +// +// int crate = bankTag; +// short slot = cdata.getByte(); +// int trigger = cdata.getInt(); +// long timestamp = cdata.getLong(); +// int nchannels = cdata.getNValue(); +// if (debug) { +// System.out.println("slot#=" + slot + "; trigger=" + trigger + "; timestamp=" + timestamp + "; nchannels=" + nchannels); +// } +// for (int j = 0; j < nchannels; j++) { +// short channel = cdata.getByte(); +// int npulses = cdata.getNValue(); +// if (debug) { +// System.out.println(" channel=" + channel + "; npulses=" + npulses); +// } +// long daqID = HPSEcalDaqIDConverter.getDaqID(crate, slot, channel); +// Long id = ecalIDConverter.daqToPhysicalID(daqID); +//// System.out.printf("crate = %d, slot = %d, channel = %d\n", crate, slot, channel); +//// System.out.printf("physicalID %d, daqID %d\n", id, daqID); +// +// for (int k = 0; k < npulses; k++) { +// short pulseTime = cdata.getShort(); +// int pulseIntegral = cdata.getInt(); +// if (debug) { +// System.out.println(" pulseTime=" + pulseTime + "; pulseIntegral=" + pulseIntegral); +// } +// hits.add(new BaseRawCalorimeterHit(id, pulseIntegral, pulseTime)); +// } +// } +// return hits; +// }
}
\ No newline at end of file
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