Created
August 17, 2015 19:03
-
-
Save JeremyMcCormick/39c7278a4315f974b376 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.hps.record.scalers; | |
import java.util.ArrayList; | |
/** | |
* This is an EVIO event processor for creating a {@link ScalerData} object from scaler bank data. | |
* | |
* @author <a href="mailto:[email protected]">Jeremy McCormick</a> | |
*/ | |
public class ScalersEvioProcessor extends EvioEventProcessor { | |
private static final Logger LOGGER = LogUtil.create(ScalersEvioProcessor.class, new DefaultLogFormatter(), | |
Level.ALL); | |
//private boolean checkSyncBit = true; | |
private Set<ScalerData> scalerDataSet; | |
/** | |
* Currently cached ScalerData object which was created by the process method. | |
*/ | |
private ScalerData currentScalerData; | |
private boolean resetEveryEvent = true; | |
/** | |
* Get the current scaler data or null if there was none in the last event processed. | |
* | |
* @return the current scaler data or <code>null</code> if none exists | |
*/ | |
public List<ScalerData> getScalerData() { | |
return new ArrayList<ScalerData>(this.scalerDataSet); | |
} | |
/** | |
* This method will create a <code>ScalerData</code> object and cache it. The current object is first reset to | |
* <code>null</code> every time this method is called. | |
* | |
* @param evioEvent the EVIO event data | |
*/ | |
@Override | |
public void process(final EvioEvent evioEvent) { | |
if (resetEveryEvent) { | |
// Reset the cached data object. | |
this.currentScalerData = null; | |
} | |
// Proceed if sync bit checking is not enabled or sync bit is on. | |
//if (!checkSyncBit || EventTagBitMask.SYNC.isEventTag(evio)) { | |
for (final BaseStructure bank : evioEvent.getChildrenList()) { | |
// Does the crate tag match? | |
if (bank.getHeader().getTag() == EvioEventConstants.SCALERS_CRATE_TAG) { | |
if (bank.getChildrenList() != null) { | |
for (final BaseStructure subBank : bank.getChildrenList()) { | |
// Does the bank tag match? | |
if (subBank.getHeader().getTag() == EvioEventConstants.SCALERS_BANK_TAG) { | |
LOGGER.fine("found scaler data in bank " + subBank.getHeader().getTag() | |
+ " and EVIO event " + evioEvent.getEventNumber()); | |
// Scaler data exists in event so create object and stop processing. | |
this.currentScalerData = new ScalerData(subBank.getIntData(), EvioEventUtilities.getEventIdData(evioEvent)[0]); | |
this.scalerDataSet.add(this.currentScalerData); | |
} | |
} | |
} | |
} | |
} | |
//} | |
} | |
//public void setCheckSyncBit(final boolean checkSyncBit) { | |
// this.checkSyncBit = checkSyncBit; | |
//} | |
public void setResetEveryEvent(final boolean resetEveryEvent) { | |
this.resetEveryEvent = resetEveryEvent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment