Author: [log in to unmask] Date: Thu Aug 20 12:46:08 2015 New Revision: 3379 Log: Remove scaler parameters from event header. HPSJAVA-577 Removed: java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParameters.java java/trunk/record-util/src/main/java/org/hps/record/scalers/ScalerParametersIndex.java Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java java/trunk/integration-tests/src/test/java/org/hps/test/it/EvioToLcioTest.java Modified: java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java ============================================================================= --- java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java (original) +++ java/trunk/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java Thu Aug 20 12:46:08 2015 @@ -14,7 +14,6 @@ import org.hps.record.epics.EpicsEvioProcessor; import org.hps.record.evio.EvioEventUtilities; import org.hps.record.scalers.ScalerData; -import org.hps.record.scalers.ScalerParameters; import org.hps.record.scalers.ScalersEvioProcessor; import org.jlab.coda.jevio.EvioEvent; import org.lcsim.conditions.ConditionsEvent; @@ -23,15 +22,13 @@ import org.lcsim.util.log.LogUtil; /** - * This is the {@link org.hps.record.LCSimEventBuilder} implementation for the - * Engineering Run and the Commissioning Run for converting EVIO to LCIO events. + * This is the {@link org.hps.record.LCSimEventBuilder} implementation for the Engineering Run and the Commissioning Run + * for converting EVIO to LCIO events. * <p> - * It has several modifications from the Test Run builder including different - * values for certain bank tags. + * It has several modifications from the Test Run builder including different values for certain bank tags. * <p> - * Additionally, this builder will write DAQ config information, EPICS control - * data, and scalar bank data into the output LCSim events if these banks are - * present in the EVIO data. + * Additionally, this builder will write DAQ config information, EPICS control data, and scalar bank data into the + * output LCSim events if these banks are present in the EVIO data. * * @author Sho Uemura, SLAC * @author Jeremy McCormick, SLAC @@ -50,30 +47,24 @@ private final EpicsEvioProcessor epicsProcessor = new EpicsEvioProcessor(); /** - * Scaler parameters for lcsim event parameters. - */ - private ScalerParameters scalerParameters = new ScalerParameters(); - - /** * EVIO processor for extracting scaler data. */ private final ScalersEvioProcessor scalerProcessor = new ScalersEvioProcessor(); /** + * Writes event flags describing the SVT state. + */ + private final SvtEventFlagger svtEventFlagger; + + /** * Reads trigger config. */ private TriggerConfigEvioReader triggerConfigReader = null; /** - * Writes event flags describing the SVT state. - */ - private final SvtEventFlagger svtEventFlagger; - - /** * Class constructor. */ public LCSimEngRunEventBuilder() { - // FIXME: Is this the best place for doing all this stuff??? ecalReader.setTopBankTag(0x25); ecalReader.setBotBankTag(0x27); ecalReader.setRfBankTag(0x2e); @@ -81,13 +72,19 @@ sspCrateBankTag = 0x2E; // A.C. modification after Sergey's confirmation sspBankTag = 0xe10c; intBanks = new ArrayList<IntBankDefinition>(); - intBanks.add(new IntBankDefinition(SSPData.class, new int[]{sspCrateBankTag, sspBankTag})); - intBanks.add(new IntBankDefinition(TIData.class, new int[]{sspCrateBankTag, 0xe10a})); - intBanks.add(new IntBankDefinition(HeadBankData.class, new int[]{sspCrateBankTag, 0xe10f})); - intBanks.add(new IntBankDefinition(TDCData.class, new int[]{0x3a, 0xe107})); + intBanks.add(new IntBankDefinition(SSPData.class, new int[] {sspCrateBankTag, sspBankTag})); + intBanks.add(new IntBankDefinition(TIData.class, new int[] {sspCrateBankTag, 0xe10a})); + intBanks.add(new IntBankDefinition(HeadBankData.class, new int[] {sspCrateBankTag, 0xe10f})); + intBanks.add(new IntBankDefinition(TDCData.class, new int[] {0x3a, 0xe107})); // ecalReader = new ECalEvioReader(0x25, 0x27); triggerConfigReader = new TriggerConfigEvioReader(); svtEventFlagger = new SvtEventFlagger(); + } + + @Override + public void conditionsChanged(final ConditionsEvent conditionsEvent) { + super.conditionsChanged(conditionsEvent); + svtEventFlagger.initialize(); } /** @@ -148,9 +145,6 @@ // Write scalers into the event, if they exist in the EVIO data. this.writeScalerData(evioEvent, lcsimEvent); - // Write out current ScalerParameters to event header. - this.scalerParameters.write(lcsimEvent); - this.svtEventFlagger.writeFlags(lcsimEvent); return lcsimEvent; @@ -180,7 +174,7 @@ private void writeEpicsData(final EventHeader lcsimEvent) { // Get EpicsData from processor that was already activated (usually it is null). - EpicsData epicsData = epicsProcessor.getEpicsData(); + final EpicsData epicsData = epicsProcessor.getEpicsData(); // Was new EpicsData created? if (epicsData != null) { @@ -189,9 +183,6 @@ // Write to the collection in the lcsim event. epicsData.write(lcsimEvent); - // Update the ScalerParameters. - scalerParameters.readEpicsData(epicsData); - // Reset the processor. epicsProcessor.reset(); } @@ -209,7 +200,7 @@ scalerProcessor.process(evioEvent); // Get ScalerData from the processor. - ScalerData scalerData = scalerProcessor.getScalerData(); + final ScalerData scalerData = scalerProcessor.getCurrentScalerData(); // Was new ScalerData created? if (scalerData != null) { @@ -218,16 +209,7 @@ + evioEvent.getEventNumber()); // Write the current scalar data to the event. - scalerProcessor.getScalerData().write(lcsimEvent); - - // Update current ScalerParameters. - scalerParameters.readScalerData(scalerData); - } - } - - @Override - public void conditionsChanged(ConditionsEvent conditionsEvent) { - super.conditionsChanged(conditionsEvent); - svtEventFlagger.initialize(); + scalerProcessor.getCurrentScalerData().write(lcsimEvent); + } } } Modified: java/trunk/integration-tests/src/test/java/org/hps/test/it/EvioToLcioTest.java ============================================================================= --- java/trunk/integration-tests/src/test/java/org/hps/test/it/EvioToLcioTest.java (original) +++ java/trunk/integration-tests/src/test/java/org/hps/test/it/EvioToLcioTest.java Thu Aug 20 12:46:08 2015 @@ -1,15 +1,16 @@ package org.hps.test.it; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import junit.framework.TestCase; import org.hps.evio.EvioToLcio; +import org.hps.record.epics.Epics2sVariables; import org.hps.record.epics.EpicsData; import org.hps.record.scalers.ScalerData; -import org.hps.record.scalers.ScalerParameters; -import org.hps.record.scalers.ScalerParametersIndex; import org.hps.test.util.TestOutputFile; import org.lcsim.event.EventHeader; import org.lcsim.event.GenericObject; @@ -78,31 +79,38 @@ nEmpty = 0; } ++nEmpty; - //System.out.println(name + " is empty in event " + event.getEventNumber()); + // System.out.println(name + " is empty in event " + event.getEventNumber()); emptyCollections.put(name, nEmpty); } } - - /** - * Check scaler parameters from event. - * - * @param event the lcsim event - */ - private void checkScalerParameters(final EventHeader event) { - - // If this is missing an exception will be thrown. - ScalerParameters scalerParameters = ScalerParameters.read(event); - - // Spot check scaler parameters from event after scaler data occurs in the data stream. - if (event.getEventNumber() == 25000) { - System.out.println(); - System.out.println("scaler parameters for event " + event.getEventNumber() + " ..."); - System.out.println(scalerParameters); - - // Check scaler values against answer key. - for (ScalerParametersIndex index : ScalerParametersIndex.values()) { - assertEquals("Wrong " + index.name() + " value.", scalerParameters.getValue(index), SCALER_VALUES[index.ordinal()]); + + private void checkCollections(final EventHeader event) { + for (int i = 0; i < COLLECTION_NAMES.length; i++) { + this.checkCollection(event, COLLECTION_TYPES[i], COLLECTION_NAMES[i]); + } + } + + private void checkEpicsData(final EventHeader event) { + final EpicsData epicsData = EpicsData.read(event); + if (epicsData != null) { + if (epicsData.getEpicsHeader() == null) { + throw new RuntimeException("The EpicsData header is null."); } + for (final String variableName : Epics2sVariables.getVariables().keySet()) { + if (!EXCLUDED_EPICS_VARIABLES.contains(variableName)) { + if (!epicsData.getKeys().contains(variableName)) { + throw new RuntimeException("EpicsData is missing key: " + variableName); + } + } + } + ++epicsDataCount; + } + } + + private void checkScalarData(final EventHeader event) { + final ScalerData scalerData = ScalerData.read(event); + if (scalerData != null) { + ++scalerDataCount; } } @@ -114,77 +122,69 @@ @Override public void process(final EventHeader event) { - // Find EPICS data. - final EpicsData epicsData = EpicsData.read(event); - if (epicsData != null) { - ++epicsDataCount; - } + // Find and check EPICS data. + this.checkEpicsData(event); // Find scaler data. - final ScalerData scalerData = ScalerData.read(event); - if (scalerData != null) { - ++scalerDataCount; - } + this.checkScalarData(event); // Check for presence of required collections and that they are non-empty. - for (int i = 0; i < COLLECTION_NAMES.length; i++) { - this.checkCollection(event, COLLECTION_TYPES[i], COLLECTION_NAMES[i]); - } - - // Check scaler parameters from event. - checkScalerParameters(event); - + this.checkCollections(event); + ++processedCount; } } /** + * The number of empty collections that are allowed. + */ + private static int[] ALLOWED_EMPTY = new int[] {45, 0, 0, 0}; + + /** * Names of collections to check. */ private static String[] COLLECTION_NAMES = new String[] {"EcalReadoutHits", "FADCGenericHits", "SVTRawTrackerHits", - "TriggerBank"}; + "TriggerBank"}; /** * Classes of collections. */ private static Class<?>[] COLLECTION_TYPES = new Class<?>[] {RawTrackerHit.class, GenericObject.class, RawTrackerHit.class, GenericObject.class}; - - /** - * The number of empty collections that are allowed. - */ - private static int[] ALLOWED_EMPTY = new int[] {45, 0, 0, 0}; - - /** - * Expected scaler values after first occurrence of scaler collection in the data. - */ - private static float[] SCALER_VALUES = { - 205.47786f, - 206.38852f, - -1.726095f, - -0.622837f, - 179.9981f - }; - + /** * The number of EPICS collections that should be found. */ private static int EPICS_DATA_COUNT = 7; - + + /** + * List of EPICS variables that are not expected to be present in this data. + */ + private static List<String> EXCLUDED_EPICS_VARIABLES = new ArrayList<String>(); + + /** + * The default input file (large file at SLAC so the pom.xml file excludes this test on non-SLAC hosts). + */ + private static final String INPUT_FILE = "/nfs/slac/g/hps3/data/engrun/evio/hps_005772.evio.0"; + + /** + * The number of events that should be processed. + */ + private static int PROCESSED_COUNT = 251823; + /** * The number of scaler data collections that should be found. */ private static int SCALER_DATA_COUNT = 3; - - /** - * The number of events that should be processed. - */ - private static int PROCESSED_COUNT = 251823; - - /** - * The default input file (large file at SLAC so the pom.xml file excludes this test on non-SLAC hosts). - */ - private static final String INPUT_FILE = "/nfs/slac/g/hps3/data/engrun/evio/hps_005772.evio.0"; + + /** + * Expected scaler values after first occurrence of scaler collection in the data. + */ + private static float[] SCALER_VALUES = {205.47786f, 206.38852f, -1.726095f, -0.622837f, 179.9981f}; + + static { + EXCLUDED_EPICS_VARIABLES.add("VCG2C21 2C21"); + } /** * Run the test. @@ -204,7 +204,7 @@ System.out.println("Done running EvioToLcio!"); // Read in the LCIO file and run the CheckDriver on it. - System.out.println("Checking LCIO output ..."); + System.out.println("Checking LCIO output ..."); final LCSimLoop loop = new LCSimLoop(); loop.setLCIORecordSource(outputFile); final CheckDriver checkDriver = new CheckDriver(); @@ -212,9 +212,9 @@ loop.loop(-1); // Check for correct number of events processed by loop. - System.out.println("Loop processed " + loop.getTotalCountableConsumed() + " events."); + System.out.println("Loop processed " + loop.getTotalCountableConsumed() + " events."); assertEquals("Loop processed wrong number of events.", PROCESSED_COUNT, loop.getTotalCountableConsumed()); - + // Check that the Driver saw the correct number of events. System.out.println("CheckDriver processed " + checkDriver.processedCount + " events."); assertEquals("Driver saw wrong number of events.", PROCESSED_COUNT, checkDriver.processedCount);