Commit in hps-java/src on MAIN | |||
main/java/org/lcsim/hps/evio/EventConstants.java | +25 | added 1.1 | |
/TestRunReconToEvio.java | +32 | -50 | 1.1 -> 1.2 |
test/java/org/lcsim/hps/evio/TestRunReconToEvio_Test.java | +6 | -3 | 1.2 -> 1.3 |
+63 | -53 |
move constants from EVIO converter to separate class
diff -N EventConstants.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EventConstants.java 29 Mar 2012 04:14:14 -0000 1.1 @@ -0,0 +1,25 @@
+package org.lcsim.hps.evio; + +public final class EventConstants { + + // These correspond to ROC (readout crate) IDs from the DAQ. + // TODO Double check that these match the actual values. + public static final int ECAL_TOP_BANK_TAG = 0x1; + public static final int ECAL_BOTTOM_BANK_TAG = 0x2; + public static final int SVT_BANK_TAG = 0x3; + + // These values are put into the number field of the banks. + // FIXME Bank numbers should actually be sequentially numbered and not hard-coded. + public static final int SVT_BANK_NUMBER = 1; + public static final int ECAL_BANK_NUMBER = 2; + + // The composite data format for pulse integral ecal data. + public static final String ECAL_PULSE_INTEGRAL_FORMAT = "c,i,l,N(c,N(s,i))"; + + // The tag for ECal pulse integral data. + public static final int ECAL_PULSE_INTEGRAL_BANK_TAG = 0xe103; + + // Offset applied to ecal channels, as we are temporarily using some negative values. + // This will eventually go away. + public static final int ECAL_CHANNEL_OFFSET = 23; +}
diff -u -r1.1 -r1.2 --- TestRunReconToEvio.java 29 Mar 2012 03:52:57 -0000 1.1 +++ TestRunReconToEvio.java 29 Mar 2012 04:14:14 -0000 1.2 @@ -1,12 +1,20 @@
package org.lcsim.hps.evio;
+import static org.lcsim.hps.evio.EventConstants.ECAL_BANK_NUMBER; +import static org.lcsim.hps.evio.EventConstants.ECAL_BOTTOM_BANK_TAG; +import static org.lcsim.hps.evio.EventConstants.ECAL_CHANNEL_OFFSET; +import static org.lcsim.hps.evio.EventConstants.ECAL_PULSE_INTEGRAL_FORMAT; +import static org.lcsim.hps.evio.EventConstants.ECAL_PULSE_INTEGRAL_BANK_TAG; +import static org.lcsim.hps.evio.EventConstants.ECAL_TOP_BANK_TAG; +import static org.lcsim.hps.evio.EventConstants.SVT_BANK_NUMBER; +import static org.lcsim.hps.evio.EventConstants.SVT_BANK_TAG; +
import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;
-import org.jlab.coda.jevio.BaseStructure;
import org.jlab.coda.jevio.CompositeData; import org.jlab.coda.jevio.DataType; import org.jlab.coda.jevio.EventBuilder;
@@ -16,52 +24,32 @@
import org.lcsim.event.EventHeader; import org.lcsim.event.EventHeader.LCMetaData; import org.lcsim.event.RawCalorimeterHit;
-import org.lcsim.event.RawTrackerHit;
import org.lcsim.geometry.IDDecoder; import org.lcsim.hps.recon.tracking.HPSSVTData; import org.lcsim.util.Driver; /**
- * - * See MCRawDataToEvio4Converter2. This version is for writing - * EVIO output that is the same as the format that will come - * off of the test run ET ring. (not done yet!)
+ * This class takes raw data generated from MC and converts + * it to EVIO. The goal is to make this look like data + * which will come off the actual ET ring during the + * test run.
* * @author Jeremy McCormick <[log in to unmask]> */ public class TestRunReconToEvio extends Driver {
- - // These correspond to ROC (readout crate) IDs from the DAQ system. - public static final int ecalTopBankTag = 0x1; - public static final int ecalBottomBankTag = 0x2; - public static final int trackerBankTag = 0x3; - - public static final int trackerBankNumber = 1; - public static final int ecalBankNumber = 2; - - final String ecalFormatString = "c,i,l,N(c,N(s,i))"; - final int ecalChannelOffset = 23; - final int ecalPulseIntegralTag = 0xe103; - - String evioOutputFile = "MCRawData.evio";
+
EventWriter writer; String rawCalorimeterHitCollectionName = "EcalDigitizedHits"; String svtCollectionName = "SVTData";
+ String evioOutputFile = "MCRawData.evio";
- EventBuilder builder = null; -
+ EventBuilder builder = null;
private int eventsWritten = 0;
- - boolean debug = false; -
+
public TestRunReconToEvio() {}
- - public void setDebug(boolean debug) { - this.debug = debug; - } -
+
public void setEvioOutputFile(String evioOutputFile) { this.evioOutputFile = evioOutputFile; }
@@ -133,12 +121,8 @@
if (svtDataList.size() > 0) { if (svtDataList.get(0) != null) { this.writeSVTData(svtDataList.get(0));
- } else { - System.out.println("No HPSSVTData in event!"); - }
+ }
}
- } else { - System.out.println("No lists with type HPSSVTData.class in event!");
} }
@@ -160,7 +144,7 @@
evioIntData[i+3] = sampleData[3]; i += 4; }
- EvioBank bank = new EvioBank(trackerBankTag, DataType.UINT32, trackerBankNumber);
+ EvioBank bank = new EvioBank(SVT_BANK_TAG, DataType.UINT32, SVT_BANK_NUMBER);
try { bank.appendIntData(evioIntData); } catch (EvioException e) {
@@ -185,7 +169,7 @@
hitMap.put(hit.getCellID(), hit); }
- // Make map of slot number to IDs.
+ // Make map of slot number to hit IDs.
Map<Integer,List<Long>> slotMap = new HashMap<Integer,List<Long>>(); for (Long id : hitMap.keySet()) { dec.setID(id);
@@ -198,18 +182,16 @@
slots.add(id); }
- EvioBank crateBank = new EvioBank(bankTag, DataType.BANK, ecalBankNumber);
+ // Make a new bank for this crate. + EvioBank crateBank = new EvioBank(bankTag, DataType.BANK, ECAL_BANK_NUMBER);
+ // Loop over the slots in the map.
for (int slot : slotMap.keySet()) {
- - //System.out.println("making evio data for slot " + slot); -
+
// New bank for this slot.
- EvioBank slotBank = new EvioBank(ecalPulseIntegralTag, DataType.COMPOSITE, slot); - - // "c,i,l,N(c,N(s,i)) - - // Create composite data for slot.
+ EvioBank slotBank = new EvioBank(ECAL_PULSE_INTEGRAL_BANK_TAG, DataType.COMPOSITE, slot); + + // Create composite data for this slot and its channels.
CompositeData.Data data = new CompositeData.Data(); data.addUchar((byte)slot); // slot # data.addUint(0); // trigger #
@@ -220,7 +202,7 @@
for (Long id : hitIDs) { dec.setID(id); int ix = dec.getValue("ix");
- int channel = ix + ecalChannelOffset;
+ int channel = ix + ECAL_CHANNEL_OFFSET;
data.addUchar((byte)channel); // channel # data.addN(1); // number of pulses RawCalorimeterHit hit = hitMap.get(id);
@@ -231,7 +213,7 @@
// Add CompositeData to bank. CompositeData cdata = null; try {
- cdata = new CompositeData(ecalFormatString, 1, data, ecalPulseIntegralTag, slot);
+ cdata = new CompositeData(ECAL_PULSE_INTEGRAL_FORMAT, 1, data, ECAL_PULSE_INTEGRAL_BANK_TAG, slot);
slotBank.appendCompositeData(cdata); } catch (EvioException e) {
@@ -274,8 +256,8 @@
} // Write the two collections for top and bottom hits to separate EVIO banks.
- writeRawCalorimeterHitCollection(topHits, meta, ecalTopBankTag, builder); - writeRawCalorimeterHitCollection(bottomHits, meta, ecalBottomBankTag, builder);
+ writeRawCalorimeterHitCollection(topHits, meta, ECAL_TOP_BANK_TAG, builder); + writeRawCalorimeterHitCollection(bottomHits, meta, ECAL_BOTTOM_BANK_TAG, builder);
} }
\ No newline at end of file
diff -u -r1.2 -r1.3 --- TestRunReconToEvio_Test.java 29 Mar 2012 03:55:39 -0000 1.2 +++ TestRunReconToEvio_Test.java 29 Mar 2012 04:14:14 -0000 1.3 @@ -1,5 +1,9 @@
package org.lcsim.hps.evio;
+import static org.lcsim.hps.evio.EventConstants.ECAL_BOTTOM_BANK_TAG; +import static org.lcsim.hps.evio.EventConstants.ECAL_TOP_BANK_TAG; +import static org.lcsim.hps.evio.EventConstants.SVT_BANK_TAG; +
import java.io.File; import java.io.IOException; import java.net.URL;
@@ -12,7 +16,6 @@
import org.jlab.coda.jevio.EvioEvent; import org.jlab.coda.jevio.EvioException; import org.jlab.coda.jevio.EvioReader;
-import org.lcsim.hps.evio.TestRunReconToEvio;
import org.lcsim.hps.recon.tracking.HPSTrackerSample; import org.lcsim.job.JobControlManager; import org.lcsim.util.cache.FileCache;
@@ -67,7 +70,7 @@
} else { System.out.println("subbank has " + topBank.getChildCount() + " children"); }
- if (header.getTag() == TestRunReconToEvio.trackerBankTag) {
+ if (header.getTag() == SVT_BANK_TAG) {
int[] intData = topBank.getIntData(); if (intData.length % 4 != 0) { throw new RuntimeException("Size of int array not divisible by 4!");
@@ -96,7 +99,7 @@
System.out.println(" sample[" + j + "]="+val); } }
- } else if (header.getTag() == TestRunReconToEvio.ecalTopBankTag || header.getTag() == TestRunReconToEvio.ecalBottomBankTag) {
+ } else if (header.getTag() == ECAL_TOP_BANK_TAG || header.getTag() == ECAL_BOTTOM_BANK_TAG) {
System.out.println("got ecal bank from event: " + Integer.toHexString(header.getTag())); if (topBank.getChildCount() > 0) { for (BaseStructure slotBank : topBank.getChildren()) {
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