diff --git a/build-coatjava.sh b/build-coatjava.sh index bf11ae5644..e4620bc385 100755 --- a/build-coatjava.sh +++ b/build-coatjava.sh @@ -73,6 +73,7 @@ mkdir -p coatjava/lib/services ### clean up any cache copies ### rm -rf ~/.m2/repository/org/hep/hipo rm -rf ~/.m2/repository/org/jlab +cd common-tools/coat-lib; $mvn clean; cd - unset CLAS12DIR if [ $runUnitTests == "yes" ]; then diff --git a/common-tools/clas-analysis/pom.xml b/common-tools/clas-analysis/pom.xml index 891947c69b..c8f8dc149f 100644 --- a/common-tools/clas-analysis/pom.xml +++ b/common-tools/clas-analysis/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-analysis - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT @@ -30,31 +30,31 @@ org.jlab.clas clas-utils - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT org.jlab.clas clas-physics - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT org.jlab.clas clas-io - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT org.jlab.clas clas-geometry - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT org.jlab.clas clas-detector - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT diff --git a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/FilterFcup.java b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/FilterFcup.java index 7bca1c4486..b651a793fd 100644 --- a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/FilterFcup.java +++ b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/FilterFcup.java @@ -1,7 +1,7 @@ package org.jlab.analysis.eventmerger; import java.util.LinkedHashMap; import java.util.Map; -import org.jlab.detector.decode.DaqScalersSequence; +import org.jlab.detector.scalers.DaqScalersSequence; import org.jlab.jnp.hipo4.data.*; import org.jlab.jnp.hipo4.io.HipoReader; import org.jlab.jnp.utils.data.TextHistogram; diff --git a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/FilterTrigger.java b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/FilterTrigger.java index c9119f80ae..7b1f18a33f 100644 --- a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/FilterTrigger.java +++ b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/FilterTrigger.java @@ -1,5 +1,5 @@ package org.jlab.analysis.eventmerger; -import org.jlab.detector.decode.DaqScalersSequence; +import org.jlab.detector.scalers.DaqScalersSequence; import org.jlab.jnp.hipo4.data.*; import org.jlab.jnp.hipo4.io.HipoReader; import org.jlab.jnp.utils.data.*; diff --git a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/RandomTriggerFilter.java b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/RandomTriggerFilter.java index 0e6f82751c..688112bf1d 100644 --- a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/RandomTriggerFilter.java +++ b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/eventmerger/RandomTriggerFilter.java @@ -1,6 +1,6 @@ package org.jlab.analysis.eventmerger; import java.util.List; -import org.jlab.detector.decode.DaqScalersSequence; +import org.jlab.detector.scalers.DaqScalersSequence; import org.jlab.jnp.hipo4.data.*; import org.jlab.jnp.hipo4.io.HipoReader; import org.jlab.jnp.hipo4.io.HipoWriterSorted; diff --git a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/RebuildScalers.java b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/RebuildScalers.java index b4e4133439..4f77df1fe2 100644 --- a/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/RebuildScalers.java +++ b/common-tools/clas-analysis/src/main/java/org/jlab/analysis/postprocess/RebuildScalers.java @@ -6,7 +6,8 @@ import java.util.List; import org.jlab.detector.calib.utils.ConstantsManager; import org.jlab.detector.calib.utils.RCDBConstants; -import org.jlab.detector.decode.DaqScalers; +import org.jlab.detector.scalers.DaqScalers; +import org.jlab.detector.helicity.HelicitySequenceManager; import org.jlab.jnp.hipo4.data.Bank; import org.jlab.jnp.hipo4.data.Event; import org.jlab.jnp.hipo4.io.HipoReader; @@ -23,6 +24,7 @@ public class RebuildScalers { static final String CCDB_FCUP_TABLE="/runcontrol/fcup"; + static final String CCDB_SLM_TABLE="/runcontrol/slm"; public static void main(String[] args) { @@ -36,6 +38,8 @@ public static void main(String[] args) { System.exit(1); } + HelicitySequenceManager helSeq = new HelicitySequenceManager(8,inputList); + HipoWriterSorted writer = new HipoWriterSorted(); writer.getSchemaFactory().initFromDirectory(ClasUtilsFile.getResourceDir("COATJAVA", "etc/bankdefs/hipo4")); writer.setCompressionType(1); @@ -44,10 +48,11 @@ public static void main(String[] args) { Event event = new Event(); Bank rawScalerBank = new Bank(writer.getSchemaFactory().getSchema("RAW::scaler")); Bank runScalerBank = new Bank(writer.getSchemaFactory().getSchema("RUN::scaler")); + Bank helScalerBank = new Bank(writer.getSchemaFactory().getSchema("HEL::scaler")); Bank runConfigBank = new Bank(writer.getSchemaFactory().getSchema("RUN::config")); ConstantsManager conman = new ConstantsManager(); - conman.init(Arrays.asList(new String[]{CCDB_FCUP_TABLE})); + conman.init(Arrays.asList(new String[]{CCDB_FCUP_TABLE,CCDB_SLM_TABLE})); for (String filename : inputList) { @@ -55,7 +60,8 @@ public static void main(String[] args) { reader.open(filename); RCDBConstants rcdb = null; - IndexedTable ccdb = null; + IndexedTable ccdb_fcup = null; + IndexedTable ccdb_slm = null; while (reader.hasNext()) { @@ -63,35 +69,43 @@ public static void main(String[] args) { reader.nextEvent(event); event.read(runConfigBank); event.read(runScalerBank); + event.read(helScalerBank); event.read(rawScalerBank); // this is the bank we're here to rebuild: event.remove(runScalerBank.getSchema()); + event.remove(helScalerBank.getSchema()); // get CCDB/RCDB constants: if (runConfigBank.getInt("run",0) >= 100) { - ccdb = conman.getConstants(runConfigBank.getInt("run",0),CCDB_FCUP_TABLE); + ccdb_fcup = conman.getConstants(runConfigBank.getInt("run",0),CCDB_FCUP_TABLE); + ccdb_slm = conman.getConstants(runConfigBank.getInt("run",0),CCDB_SLM_TABLE); rcdb = conman.getRcdbConstants(runConfigBank.getInt("run",0)); } // now rebuild the RUN::scaler bank: - if (rcdb!=null && ccdb !=null && rawScalerBank.getRows()>0) { + if (rcdb!=null && ccdb_fcup !=null && rawScalerBank.getRows()>0) { - // Run duration in seconds. Nasty but works, until RCDB (uses java.sql.Time) - // is changed to support full date and not just HH:MM:SS. Meanwhile just - // requires that runs last less than 24 hours. - Date uet = new Date(runConfigBank.getInt("unixtime",0)*1000L); + // Inputs for calculation run duration in seconds, since for + // some run periods the DSC2 clock rolls over during a run. Time rst = rcdb.getTime("run_start_time"); - final double s1 = rst.getSeconds()+60*rst.getMinutes()+60*60*rst.getHours(); - final double s2 = uet.getSeconds()+60*uet.getMinutes()+60*60*uet.getHours(); - final double seconds = s2>>>> error : at least one of -q/-d must be specified\n"); System.exit(1); } - HelicitySequenceManager helSeq = new HelicitySequenceManager(8,inputList); + HelicitySequenceManager helSeq = new HelicitySequenceManager(8,inputList,doHelicityFlip); DaqScalersSequence chargeSeq = DaqScalersSequence.readSequence(inputList); HipoWriterSorted writer = new HipoWriterSorted(); @@ -75,9 +77,9 @@ public static void main(String[] args) { // we're going to modify this bank: Bank recEventBank = new Bank(writer.getSchemaFactory().getSchema("REC::Event")); - - // FIXME: we shouldn't need this bank, but just the event: - Bank runConfigBank = new Bank(writer.getSchemaFactory().getSchema("RUN::config")); + + // we're going to modify this bank if doHelicityFlip is set: + Bank helFlipBank = new Bank(writer.getSchemaFactory().getSchema("HEL::flip")); long badCharge = 0; long goodCharge = 0; @@ -93,19 +95,26 @@ public static void main(String[] args) { reader.nextEvent(event); event.read(recEventBank); + event.read(helFlipBank); + event.remove(recEventBank.getSchema()); - // FIXME: we shouldn't need this bank, but just the event: - event.read(runConfigBank); - final long timestamp = runConfigBank.getLong("timestamp", 0); + if (doHelicityFlip && helFlipBank.getRows()>0) { + event.remove(helFlipBank.getSchema()); + helFlipBank.setByte("helicity", 0, (byte)-helFlipBank.getByte("helicity",0)); + helFlipBank.setByte("helicityRaw", 0, (byte)-helFlipBank.getByte("helicityRaw",0)); + event.write(helFlipBank); + } // do the lookups: HelicityBit hb = helSeq.search(event); - DaqScalers ds = chargeSeq.get(timestamp); + DaqScalers ds = chargeSeq.get(event); - // write heliicty to REC::Event: + // count helicity good/bad; if (Math.abs(hb.value())==1) goodHelicity++; else badHelicity++; + + // write heliicty to REC::Event: if (doHelicity) { recEventBank.putByte("helicity",0,hb.value()); } @@ -115,8 +124,8 @@ public static void main(String[] args) { else { goodCharge++; if (doBeamCharge) { - recEventBank.putFloat("beamCharge",0,ds.getBeamChargeGated()); - recEventBank.putDouble("liveTime",0,ds.getLivetime()); + recEventBank.putFloat("beamCharge",0, (float) ds.dsc2.getBeamChargeGated()); + recEventBank.putDouble("liveTime",0,ds.dsc2.getLivetime()); } } diff --git a/common-tools/clas-detector/pom.xml b/common-tools/clas-detector/pom.xml index b72eee8158..16bb8e226d 100644 --- a/common-tools/clas-detector/pom.xml +++ b/common-tools/clas-detector/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-detector - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT @@ -30,7 +30,7 @@ org.jlab.clas clas-utils - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT @@ -42,13 +42,13 @@ org.jlab.clas clas-io - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT org.jlab.clas clas-geometry - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java index d6a8bac187..563f5bccc4 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/CLASDecoder4.java @@ -5,6 +5,7 @@ */ package org.jlab.detector.decode; +import org.jlab.detector.scalers.DaqScalers; import java.util.ArrayList; import java.util.List; @@ -564,7 +565,7 @@ public Bank createEpicsBank(){ * * FIXME: refactor this out more cleanly */ - public Bank createReconScalerBank(Event event){ + public Bank[] createReconScalerBanks(Event event){ // abort if run number corresponds to simulation: if (this.detectorDecoder.getRunNumber() < 1000) return null; @@ -581,9 +582,11 @@ public Bank createReconScalerBank(Event event){ event.read(rawScalerBank); if (configBank.getRows()<1 || rawScalerBank.getRows()<1) return null; - // retrieve fcup calibrations from CCDB: + // retrieve fcup/slm calibrations from slm: IndexedTable fcupTable = this.detectorDecoder.scalerManager. getConstants(this.detectorDecoder.getRunNumber(),"/runcontrol/fcup"); + IndexedTable slmTable = this.detectorDecoder.scalerManager. + getConstants(this.detectorDecoder.getRunNumber(),"/runcontrol/slm"); // get unix event time (in seconds), and convert to Java's date (via milliseconds): Date uet=new Date(configBank.getInt("unixtime",0)*1000L); @@ -598,26 +601,7 @@ public Bank createReconScalerBank(Event event){ // abort if no RCDB access (e.g. offsite) return null; } - - // seconds since 00:00:00, on their given day: - final double s1 = rst.getSeconds()+60*rst.getMinutes()+60*60*rst.getHours(); - final double s2 = uet.getSeconds()+60*uet.getMinutes()+60*60*uet.getHours(); - - // Run duration in seconds. Nasty but works, until RCDB (uses java.sql.Time) - // is changed to support full date and not just HH:MM:SS. Meanwhile just - // requires that runs last less than 24 hours. - final double seconds = s20) scalerEvent.write(rawScaler); if(rawRunConf.getRows()>0) scalerEvent.write(rawRunConf); - Bank recScaler = decoder.createReconScalerBank(decodedEvent); - if (recScaler != null) { - decodedEvent.write(recScaler); - scalerEvent.write(recScaler); + Bank[] scalers = decoder.createReconScalerBanks(decodedEvent); + if (scalers != null) { + for (Bank b : scalers) { + decodedEvent.write(b); + scalerEvent.write(b); + } } if (epics!=null) { diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java deleted file mode 100644 index 6656cf9c47..0000000000 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalers.java +++ /dev/null @@ -1,278 +0,0 @@ -package org.jlab.detector.decode; - -import org.jlab.jnp.hipo4.data.Bank; -import org.jlab.utils.groups.IndexedTable; - -/** - * - * Read the occasional scaler bank, extract beam charge, livetime, etc. - * - * We have at least two relevant scaler hardware boards, STRUCK and DSC2, both - * readout on helicity flips and with DAQ-busy gating, both decoded into RAW::scaler. - * This class reads RAW::scaler and converts to more user-friendly information. - * - * STRUCK. Latching on helicity states, zeroed upon readout, with both helicity - * settle (normally 500 us) and non-settle counts, useful for "instantaneous" - * livetime, beam charge asymmetry, beam trip studies, ... - * - * DSC2. Integrating since beginning of run, useful for beam charge normalization. - * - * @see logbook entry - * and common-tools/clas-detector/doc - * - * The EPICS equation for converting Faraday Cup raw scaler S to beam current I: - * I [nA] = (S [Hz] - offset ) / slope * attenuation; - * - * offset/slope/attenuation are read from CCDB - * - * Accounting for the offset in accumulated beam charge requires knowledge of - * time duration. Currently, the (32 bit) DSC2 clock is zeroed at run start - * but at 1 Mhz rolls over every 35 seconds, and the (48 bit) 250 MHz TI timestamp - * can also rollover within a run since only zeroed upon reboot. Instead we allow - * run duration to be passed in, e.g. using run start time from RCDB and event - * unix time from RUN::config. - * - * FIXME: Use CCDB for GATEINVERTED, CLOCK_FREQ, CRATE/SLOT/CHAN - * - * @author baltzell - */ -public class DaqScalers { - - private float beamCharge=0; - private float beamChargeGated=0; - private float livetime=0; - private long timestamp = 0; - public Dsc2RawReading dsc2=null; - public StruckRawReading struck=null; - public void setTimestamp(long timestamp) { this.timestamp=timestamp; } - private void setBeamCharge(float q) { this.beamCharge=q; } - private void setBeamChargeGated(float q) { this.beamChargeGated=q; } - private void setLivetime(float l) { this.livetime=l; } - public float getBeamCharge() { return beamCharge; } - public float getBeamChargeGated() { return beamChargeGated; } - public float getLivetime() { return livetime; } - public long getTimestamp() { return timestamp; } - public void show() { System.out.println("BCG=%.3f LT=%.3f"); } - - /** - * @param runScalerBank HIPO RUN::scaler bank - */ - public static DaqScalers create(Bank runScalerBank) { - DaqScalers ds=new DaqScalers(); - for (int ii=0; ii 0) { - - float live = (float)dsc2.getGatedSlm() / dsc2.getSlm(); - float q = (float)(dsc2.getFcup() - fcup_offset * seconds ); - float qg = (float)(dsc2.getGatedFcup() - fcup_offset * seconds * live); - q *= fcup_atten / fcup_slope; - qg *= fcup_atten / fcup_slope; - float l = -1; - if (struck.getClock()>0) { - l = (float)struck.getGatedClock() / struck.getClock(); - } - DaqScalers ds=new DaqScalers(); - ds.setBeamCharge(q); - ds.setBeamChargeGated(qg); - ds.setLivetime(l); - ds.dsc2=dsc2; - ds.struck=struck; - return ds; - } - return null; - } - - /** - * Same as create(Bank,IndexedTable,double), except relies on DSC2's clock. - * - * @param rawScalerBank HIPO RAW::scaler bank - * @param fcupTable /runcontrol/fcup IndexedTable from CCDB - */ - public static DaqScalers create(Bank rawScalerBank,IndexedTable fcupTable) { - Dsc2RawReading dsc2 = new Dsc2RawReading(rawScalerBank); - return create(rawScalerBank,fcupTable,dsc2.getGatedClockTime()); - } - - private static class RawReading { - - protected static final String RAWBANKNAME="RAW::scaler"; - protected static final int CRATE=64; - - protected double clockFreq=1; // Hz - protected long fcup=-1; // counts - protected long clock=-1; // counts - protected long slm=-1; // counts - protected long gatedFcup=-1; // counts - protected long gatedClock=-1; // counts - protected long gatedSlm=-1; // counts - - public long getClock() { return this.clock; } - public long getFcup() { return this.fcup; } - public long getSlm() { return this.slm; } - public long getGatedClock() { return this.gatedClock; } - public long getGatedFcup() { return this.gatedFcup; } - public long getGatedSlm() { return this.gatedSlm; } - public double getClockTime() { return this.clock / this.clockFreq; } - public double getGatedClockTime() { return this.gatedClock / this.clockFreq; } - } - - public static class StruckRawReading extends RawReading { - - private static final boolean GATEINVERTED=false; - - private final byte UDF=0; - private final byte POSITIVE=1; - private final byte NEGATIVE=-1; - private byte helicity=UDF; - private byte quartet=UDF; - public byte getHelicity() { return this.helicity; } - public byte getQuartet() { return this.quartet; } - - private static final int SLOT_GATED=0; - private static final int SLOT_UNGATED=1; - - // these are the non-settle periods: - private static final int CHAN_FCUP=0; - private static final int CHAN_SLM=1; - private static final int CHAN_CLOCK=2; - - // these are the settle periods (currently ignored): - private static final int CHAN_FCUP_SETTLE=32; - private static final int CHAN_SLM_SETTLE=33; - private static final int CHAN_CLOCK_SETTLE=34; - - public StruckRawReading(Bank bank) { - - // the STRUCK's clock is 1 MHz - this.clockFreq = 1e6; - - // this will get the last entries (most recent) in the bank - for (int k=0; k 0 ? POSITIVE : NEGATIVE; - this.quartet = bank.getByte("quartet",k) > 0 ? POSITIVE : NEGATIVE; - this.gatedFcup = bank.getLong("value",k); - break; - case CHAN_SLM: - this.gatedSlm = bank.getLong("value",k); - break; - case CHAN_CLOCK: - this.gatedClock = bank.getLong("value",k); - break; - default: - break; - } - } - else if (bank.getInt("slot",k)==SLOT_UNGATED) { - switch (bank.getInt("channel",k)) { - case CHAN_FCUP: - this.fcup = bank.getLong("value",k); - break; - case CHAN_SLM: - this.slm = bank.getLong("value",k); - break; - case CHAN_CLOCK: - this.clock = bank.getLong("value",k); - break; - default: - break; - } - } - } - if (GATEINVERTED) { - gatedSlm = slm - gatedSlm; - gatedFcup = fcup - gatedFcup; - gatedClock = clock - gatedClock; - } - } - } - - public static class Dsc2RawReading extends RawReading{ - - private static final boolean GATEINVERTED=true; - - // DSC has TRG and TDC thresholds, we use only TDC here: - private static final int SLOT=64; - private static final int CHAN_FCUP_GATED=16; - private static final int CHAN_SLM_GATED=17; - private static final int CHAN_CLOCK_GATED=18; - private static final int CHAN_FCUP=48; - private static final int CHAN_SLM=49; - private static final int CHAN_CLOCK=50; - - public Dsc2RawReading(Bank bank) { - - // the DSC2's clock is (currently) 1 MHz - // FIXME: use CCDB - this.clockFreq=1e6; - - // this will get the last entries (most recent) in the bank - for (int k=0; k seqMap=new HashMap<>(); Bank rcfgBank=null; + public HelicitySequenceManager(int delay,List filenames,boolean flip) { + this.flip=flip; + this.delay=delay; + initialize(filenames); + } + public HelicitySequenceManager(int delay,List filenames) { this.delay=delay; initialize(filenames); } + /** + * @param delay number of states delayed + * @param reader HipoReader to initialize from + */ private HelicitySequenceManager(int delay,HipoReader reader) { this.delay=delay; initialize(reader); } + + private HelicitySequenceManager(int delay,HipoReader reader,boolean flip) { + this.flip=flip; + this.delay=delay; + initialize(reader); + } public void setVerbosity(int verbosity) { this.verbosity=verbosity; @@ -51,37 +68,73 @@ private boolean addState(int runno,HelicityState state) { System.exit(1); } } - return seqMap.get(runno).addState(state); + return seqMap.get(runno).addState(this.flip?state.invert():state); } + /** + * @param runno run number + * @return sequence for given run number + */ public HelicitySequence getSequence(int runno) { if (seqMap.containsKey(runno)) return seqMap.get(runno); return null; } + /** + * @param runno run number + * @param timestamp TI timestamp + * @return helicity for given run number and timestamp + */ public HelicityBit search(int runno, long timestamp) { - if (seqMap.containsKey(runno)) return seqMap.get(runno).search(timestamp); + return this.search(runno,timestamp,0); + } + + /** + * @param runno run number + * @param timestamp TI timestamp + * @param offset number of states offset + * @return helicity for given run number and timestamp plus offset + */ + public HelicityBit search(int runno, long timestamp,int offset) { + if (seqMap.containsKey(runno)) return seqMap.get(runno).search(timestamp,offset); return HelicityBit.UDF; } + + /** + * @param event HIPO event + * @return helicity for given event + */ + public HelicityBit search(Event event) { + return this.search(event,0); + } + + /** + * @param event HIPO event + * @param offset number of states offset + * @return helicity for given event plus offset + */ + public HelicityBit search(Event event,int offset) { + event.read(this.rcfgBank); + if (rcfgBank.getRows()<1) return HelicityBit.UDF; + return this.search(rcfgBank.getInt("run",0),rcfgBank.getLong("timestamp",0),offset); + } + public HelicityBit predictGenerated(int runno, long timestamp) { if (seqMap.containsKey(runno)) return seqMap.get(runno).predictGenerated(timestamp); return HelicityBit.UDF; } + public HelicityBit searchGenerated(int runno, long timestamp) { if (seqMap.containsKey(runno)) return seqMap.get(runno).searchGenerated(timestamp); return HelicityBit.UDF; } - - public HelicityBit search(Event event) { - event.read(this.rcfgBank); - if (rcfgBank.getRows()<1) return HelicityBit.UDF; - return this.search(rcfgBank.getInt("run",0),rcfgBank.getLong("timestamp",0)); - } + public HelicityBit predictGenerated(Event event) { event.read(this.rcfgBank); if (rcfgBank.getRows()<1) return HelicityBit.UDF; return this.predictGenerated(rcfgBank.getInt("run",0),rcfgBank.getLong("timestamp",0)); } + public HelicityBit searchGenerated(Event event) { event.read(this.rcfgBank); if (rcfgBank.getRows()<1) return HelicityBit.UDF; @@ -122,10 +175,6 @@ private void initialize(HipoReader reader) { } } - /** - * Initialize from a list of file names: - * @param filenames - */ private void initialize(List filenames) { for (String filename : filenames) { HipoReader reader = new HipoReader(); diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityState.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityState.java index bb43be0711..2a94129c04 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityState.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/helicity/HelicityState.java @@ -114,6 +114,10 @@ public static HelicityState createFromFadcBank(Bank adcBank) { if (state.helicityRaw==HelicityBit.UDF) state.hwStatus |= Mask.HELICITY; if (state.pairSync==HelicityBit.UDF) state.hwStatus |= Mask.SYNC; if (state.patternSync==HelicityBit.UDF) state.hwStatus |= Mask.PATTERN; + + // Fix the overall sign-convention error in the offline helicity: + state.invert(); + state.fixMissingReadouts(); return state; } @@ -252,4 +256,14 @@ public void setHalfWavePlate(byte hwp) { public HelicityBit getPairSync() { return this.pairSync; } public HelicityBit getPatternSync() { return this.patternSync; } + /** + * Inverts the helicity/helicityRaw components of this state + * @return this state after inversion + */ + public HelicityState invert() { + this.helicity = HelicityBit.getFlipped(this.helicity); + this.helicityRaw = HelicityBit.getFlipped(this.helicityRaw); + return this; + } + } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScaler.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScaler.java new file mode 100644 index 0000000000..111a740bb2 --- /dev/null +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScaler.java @@ -0,0 +1,90 @@ +package org.jlab.detector.scalers; + +import org.jlab.utils.groups.IndexedTable; + +public class DaqScaler { + + protected static final String RAWBANKNAME="RAW::scaler"; + protected static final int CRATE=64; + + protected double clockFreq=1; // Hz + protected long fcup=-1; // counts + protected long clock=-1; // counts + protected long slm=-1; // counts + protected long gatedFcup=-1; // counts + protected long gatedClock=-1; // counts + protected long gatedSlm=-1; // counts + + public final long getClock() { return this.clock; } + public final long getFcup() { return this.fcup; } + public final long getSlm() { return this.slm; } + public final long getGatedClock() { return this.gatedClock; } + public final long getGatedFcup() { return this.gatedFcup; } + public final long getGatedSlm() { return this.gatedSlm; } + public final double getClockSeconds() { return (double)this.clock / this.clockFreq; } + public final double getGatedClockSeconds() { return (double)this.gatedClock / this.clockFreq; } + public final double getLivetimeClock() { return (double)this.gatedClock / this.clock; } + public final double getLivetimeFcup() {return (double)this.gatedFcup / this.fcup; } + public final double getLivetimeSLM() {return (double)this.gatedSlm / this.slm; } + + protected double beamCharge=0; + protected double beamChargeGated=0; + protected double beamChargeSLM=0; + protected double beamChargeGatedSLM=0; + protected double livetime=0; + protected void setBeamCharge(double q) { this.beamCharge=q; } + protected void setBeamChargeGated(double q) { this.beamChargeGated=q; } + protected void setBeamChargeSLM(double q) { this.beamChargeSLM=q; } + protected void setBeamChargeGatedSLM(double q) { this.beamChargeGatedSLM=q; } + protected void setLivetime(double l) { this.livetime=l; } + public double getBeamCharge() { return beamCharge; } + public double getBeamChargeGated() { return beamChargeGated; } + public double getLivetime() { return livetime; } + public double getBeamChargeSLM() { return beamChargeSLM; } + public double getBeamChargeGatedSLM() { return beamChargeGatedSLM; } + + /** + * Manually choose dwell and live-dwell times, e.g. if clock rolls over. + * @param fcupTable + * @param slmTable + * @param seconds + * @param liveSeconds + */ + protected void calibrate(IndexedTable fcupTable,IndexedTable slmTable,double seconds,double liveSeconds) { + + if (this.clock > 0) { + final double fcup_slope = fcupTable.getDoubleValue("slope",0,0,0); // Hz/nA + final double fcup_offset = fcupTable.getDoubleValue("offset",0,0,0); // Hz + final double fcup_atten = fcupTable.getDoubleValue("atten",0,0,0); // attenuation + final double slm_slope = slmTable.getDoubleValue("slope",0,0,0); // Hz/nA + final double slm_offset = slmTable.getDoubleValue("offset",0,0,0); // Hz + final double slm_atten = slmTable.getDoubleValue("atten",0,0,0); // attenuation + + double q = (double)this.slm - slm_offset * seconds; + double qg = (double)this.gatedSlm - slm_offset * liveSeconds; + this.beamChargeSLM = q * slm_atten / slm_slope; + this.beamChargeGatedSLM = qg * slm_atten / slm_slope; + this.livetime = (double)this.gatedClock / this.clock; + + if (fcup_atten<1e-8 || fcup_slope<1e-8) { + this.beamCharge = this.beamChargeSLM; + this.beamChargeGated = this.beamChargeGatedSLM; + } + else { + q = (double)this.fcup - fcup_offset * seconds; + qg = (double)this.gatedFcup - fcup_offset * liveSeconds; + this.beamCharge = q * fcup_atten / fcup_slope; + this.beamChargeGated = qg * fcup_atten / fcup_slope; + } + } + } + + /** + * Use the scaler's own clock to get dwell and live-dwell times + * @param fcupTable + * @param slmTable + */ + protected final void calibrate(IndexedTable fcupTable,IndexedTable slmTable) { + this.calibrate(fcupTable,slmTable,this.getClockSeconds(),this.getGatedClockSeconds()); + } +} diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalers.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalers.java new file mode 100644 index 0000000000..ae1837e34a --- /dev/null +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalers.java @@ -0,0 +1,194 @@ +package org.jlab.detector.scalers; + +import java.util.Date; +import org.jlab.jnp.hipo4.data.Bank; +import org.jlab.jnp.hipo4.data.SchemaFactory; +import org.jlab.utils.groups.IndexedTable; + +/** + * + * Read the occasional scaler bank, extract beam charge, livetime, etc. + * + * We have at least two relevant scaler hardware boards, STRUCK and DSC2, both + * readout on helicity flips and with DAQ-busy gating, both decoded into RAW::scaler. + * This class reads RAW::scaler and converts to more user-friendly information. + * + * STRUCK. Latching on helicity states, zeroed upon readout, with both helicity + * settle (normally 500 us) and non-settle counts, useful for "instantaneous" + * livetime, beam charge asymmetry, beam trip studies, ... + * + * DSC2. Integrating since beginning of run, useful for beam charge normalization. + * + * @see logbook entry + * and common-tools/clas-detector/doc + * + * The EPICS equation for converting Faraday Cup raw scaler S to beam current I: + * I [nA] = (S [Hz] - offset ) / slope * attenuation; + * + * offset/slope/attenuation are read from CCDB + * + * Accounting for the offset in accumulated beam charge requires knowledge of + * time duration. Currently, the (32 bit) DSC2 clock is zeroed at run start + * but at 1 Mhz rolls over every 35 seconds, and the (48 bit) 250 MHz TI timestamp + * can also rollover within a run since only zeroed upon reboot. Instead we allow + * run duration to be passed in, e.g. using run start time from RCDB and event + * unix time from RUN::config. + * + * FIXME: Use CCDB for GATEINVERTED, CLOCK_FREQ, CRATE/SLOT/CHAN + * + * @author baltzell + */ +public class DaqScalers { + + public Dsc2Scaler dsc2=null; + public StruckScaler struck=null; + + private long timestamp=0; + public void setTimestamp(long timestamp) { this.timestamp=timestamp; } + public long getTimestamp(){ return this.timestamp; } + + /** + * Get seconds between two dates assuming the differ by not more than 24 hours. + * + * The 24 hour requirement is because the java RCDB library currently provides + * times as java.sql.Time, which only supports HH:MM:SS and not full date. + * + * Necessitated because run-integrating DSC2's clock frequency in some run + * periods was too large and rolls over during run. And that was the only + * clock that is reset at beginning of the run. + * + * Since DAQ runs are never 24 hours, this works. + * + * @param rst run start time + * @param uet unix event time + * @return + */ + public static double getSeconds(Date rst,Date uet) { + // seconds since 00:00:00, on their given day: + final double s1 = rst.getSeconds()+60*rst.getMinutes()+60*60*rst.getHours(); + final double s2 = uet.getSeconds()+60*uet.getMinutes()+60*60*uet.getHours(); + return s20 || struck.getClock()>0) { + DaqScalers ds=new DaqScalers(); + ds.dsc2=dsc2; + ds.struck=struck; + return ds; + } + return null; + } + + /** + * @param rawScalerBank HIPO RAW::scaler bank + * @param fcupTable /runcontrol/fcup from CCDB + * @param slmTable /runcontrol/slm from CCDB + * @param rst run start time + * @param uet unix event time + * @return + */ + public static DaqScalers create(Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable,Date rst, Date uet) { + return DaqScalers.create(rawScalerBank,fcupTable,slmTable,DaqScalers.getSeconds(rst, uet)); + } + + /** + * Same as create(Bank,IndexedTable,double), except relies on DSC2's clock. + * + * @param rawScalerBank HIPO RAW::scaler bank + * @param fcupTable /runcontrol/fcup from CCDB + * @param slmTable /runcontrol/slm from CCDB + * @return + */ + public static DaqScalers create(Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable) { + Dsc2Scaler dsc2 = new Dsc2Scaler(rawScalerBank,fcupTable,slmTable); + return DaqScalers.create(rawScalerBank,fcupTable,slmTable,dsc2.getGatedClockSeconds()); + } + + /** + * @param schema bank schema + * @return RUN::scaler banks + */ + public Bank createRunBank(SchemaFactory schema) { + Bank bank = new Bank(schema.getSchema("RUN::scaler"),1); + bank.putFloat("fcup",0,(float)this.dsc2.getBeamCharge()); + bank.putFloat("fcupgated",0,(float)this.dsc2.getBeamChargeGated()); + bank.putFloat("livetime",0,(float)this.struck.getLivetimeClock()); + return bank; + } + + /** + * @param schema bank schema + * @return HEL::scaler banks + */ + public Bank createHelicityBank(SchemaFactory schema) { + Bank bank = new Bank(schema.getSchema("HEL::scaler"),1); + bank.putFloat("fcup",0,(float)this.struck.getBeamCharge()); + bank.putFloat("fcupgated",0,(float)this.struck.getBeamChargeGated()); + bank.putFloat("slm",0,(float)this.struck.getBeamChargeSLM()); + bank.putFloat("slmgated",0,(float)this.struck.getBeamChargeGatedSLM()); + bank.putFloat("clock",0,(float)this.struck.getClock()); + bank.putFloat("clockgated",0,(float)this.struck.getGatedClock()); + return bank; + } + + /** + * @param rawScalerBank RAW::scaler bank + * @param schema bank schema + * @param fcupTable /runcontrol/fcup CCDB table + * @param slmTable /runcontrol/slm CCDB table + * @return [RUN::scaler,HEL::scaler] banks + */ + public static Bank[] createBanks(SchemaFactory schema,Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable) { + DaqScalers ds = DaqScalers.create(rawScalerBank,fcupTable,slmTable); + if (ds==null) return null; + Bank ret[] = {ds.createRunBank(schema),ds.createHelicityBank(schema)}; + return ret; + } + + /** + * @param rawScalerBank RAW::scaler bank + * @param schema bank schema + * @param fcupTable /runcontrol/fcup CCDB table + * @param slmTable /runcontrol/slm CCDB table + * @param seconds duration between run start and current event + * @return [RUN::scaler,HEL::scaler] banks + */ + public static Bank[] createBanks(SchemaFactory schema,Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable,double seconds) { + DaqScalers ds = DaqScalers.create(rawScalerBank,fcupTable,slmTable,seconds); + if (ds==null) return null; + Bank ret[] = {ds.createRunBank(schema),ds.createHelicityBank(schema)}; + return ret; + } + + public static Bank[] createBanks(SchemaFactory schema,Bank rawScalerBank,IndexedTable fcupTable,IndexedTable slmTable,Date rst,Date uet) { + return DaqScalers.createBanks(schema,rawScalerBank,fcupTable,slmTable,DaqScalers.getSeconds(rst,uet)); + } + +} + diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalersSequence.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalersSequence.java similarity index 82% rename from common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalersSequence.java rename to common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalersSequence.java index 7de896b1ff..7513efba34 100644 --- a/common-tools/clas-detector/src/main/java/org/jlab/detector/decode/DaqScalersSequence.java +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/DaqScalersSequence.java @@ -1,4 +1,4 @@ -package org.jlab.detector.decode; +package org.jlab.detector.scalers; import java.util.List; import java.util.ArrayList; @@ -10,6 +10,7 @@ import org.jlab.jnp.hipo4.data.Event; import org.jlab.jnp.hipo4.data.Bank; import org.jlab.jnp.hipo4.data.SchemaFactory; +import org.jlab.detector.scalers.DaqScalers; /** * For easy access to most recent scaler readout for any given event. @@ -24,6 +25,8 @@ public class DaqScalersSequence implements Comparator { public static final double TI_CLOCK_FREQ = 250e6; // Hz protected final List scalers=new ArrayList<>(); + + private Bank rcfgBank=null; public class Interval { private DaqScalers previous = null; @@ -38,15 +41,15 @@ protected Interval(DaqScalersSequence seq, long t1, long t2) { } public double getBeamChargeGated() { if (previous!=null && next!=null) { - return this.next.getBeamChargeGated() - -this.previous.getBeamChargeGated(); + return this.next.dsc2.getBeamChargeGated() + -this.previous.dsc2.getBeamChargeGated(); } return 0; } public double getBeamCharge() { if (previous!=null && next!=null) { - return this.next.getBeamCharge() - -this.previous.getBeamCharge(); + return this.next.dsc2.getBeamCharge() + -this.previous.dsc2.getBeamCharge(); } return 0; } @@ -115,6 +118,15 @@ public DaqScalers get(long timestamp) { return null; } + /** + * @param event + * @return the most recent DaqScalers for the given event + */ + public DaqScalers get(Event event) { + event.read(this.rcfgBank); + return this.get(this.rcfgBank.getLong("timestamp", 0)); + } + /** * @param timestamp TI timestamp (i.e. RUN::config.timestamp) * @return smallest interval of scaler readings around that timestamp @@ -122,14 +134,37 @@ public DaqScalers get(long timestamp) { public Interval getInterval(long timestamp) { return this.getInterval(timestamp,timestamp); } + + /** + * @param event + * @return smallest interval of scaler readings around that event + */ + public Interval getInterval(Event event) { + event.read(this.rcfgBank); + return this.getInterval(this.rcfgBank.getLong("timestamp", 0)); + } + /** * @param t1 first TI timestamp (i.e. RUN::config.timestamp) * @param t2 second TI timestamp - * @return an interval of scaler readings around those timestamps + * @return smallest interval of scaler readings around those timestamps */ public Interval getInterval(long t1,long t2) { return new Interval(this,t1,t2); } + + /** + * @param event1 first event + * @param event2 second event + * @return smallest interval of scaler readings around those events + */ + public Interval getInterval(Event event1, Event event2) { + event1.read(this.rcfgBank); + final long t1 = this.rcfgBank.getLong("timestamp",0); + event2.read(this.rcfgBank); + final long t2 = this.rcfgBank.getLong("timestamp",0); + return this.getInterval(t1,t2); + } /** * This reads tag=1 events for RUN::scaler banks, and initializes and returns @@ -148,6 +183,10 @@ public static DaqScalersSequence readSequence(List filenames) { HipoReader reader = new HipoReader(); reader.setTags(1); reader.open(filename); + + if (seq.rcfgBank==null) { + seq.rcfgBank = new Bank(reader.getSchemaFactory().getSchema("RUN::config")); + } SchemaFactory schema = reader.getSchemaFactory(); @@ -226,7 +265,7 @@ public static void main(String[] args) { else { good++; // do something useful with beam charge here: - System.out.println(timestamp+" "+ds.getBeamCharge()+" "+ds.getBeamChargeGated()); + System.out.println(timestamp+" "+ds.dsc2.getBeamCharge()+" "+ds.dsc2.getBeamChargeGated()); } } diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/Dsc2Scaler.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/Dsc2Scaler.java new file mode 100644 index 0000000000..4c46c5f20b --- /dev/null +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/Dsc2Scaler.java @@ -0,0 +1,88 @@ +package org.jlab.detector.scalers; + +import org.jlab.jnp.hipo4.data.Bank; +import org.jlab.utils.groups.IndexedTable; + +public class Dsc2Scaler extends DaqScaler{ + + private static final boolean GATEINVERTED=true; + + // DSC has TRG and TDC thresholds, we use only TDC here: + private static final int SLOT=64; + private static final int CHAN_FCUP_GATED=16; + private static final int CHAN_SLM_GATED=17; + private static final int CHAN_CLOCK_GATED=18; + private static final int CHAN_FCUP=48; + private static final int CHAN_SLM=49; + private static final int CHAN_CLOCK=50; + + public Dsc2Scaler() {} + + public Dsc2Scaler(Bank bank,IndexedTable fcupTable,IndexedTable slmTable,double seconds) { + + // the DSC2's clock is (currently) 1 MHz + // FIXME: use CCDB + this.clockFreq=1e6; + + // this will get the last entries (most recent) in the bank + for (int k=0; k0) { + super.calibrate(fcupTable,slmTable,seconds,seconds*((double)this.gatedSlm)/this.slm); + } + } +} \ No newline at end of file diff --git a/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/StruckScaler.java b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/StruckScaler.java new file mode 100644 index 0000000000..96644ccd36 --- /dev/null +++ b/common-tools/clas-detector/src/main/java/org/jlab/detector/scalers/StruckScaler.java @@ -0,0 +1,84 @@ +package org.jlab.detector.scalers; + +import org.jlab.jnp.hipo4.data.Bank; +import org.jlab.utils.groups.IndexedTable; + +public class StruckScaler extends DaqScaler { + + private static final boolean GATEINVERTED=false; + + private final byte UDF=0; + private final byte POSITIVE=1; + private final byte NEGATIVE=-1; + private byte helicity=UDF; + private byte quartet=UDF; + public byte getHelicity() { return this.helicity; } + public byte getQuartet() { return this.quartet; } + + private static final int SLOT_GATED=0; + private static final int SLOT_UNGATED=1; + + // these are the non-settle periods: + private static final int CHAN_FCUP=0; + private static final int CHAN_SLM=1; + private static final int CHAN_CLOCK=2; + + // these are the settle periods (currently ignored): + private static final int CHAN_FCUP_SETTLE=32; + private static final int CHAN_SLM_SETTLE=33; + private static final int CHAN_CLOCK_SETTLE=34; + + public StruckScaler() {} + + public StruckScaler(Bank bank,IndexedTable fcupTable, IndexedTable slmTable) { + + // the STRUCK's clock is 1 MHz + this.clockFreq = 1e6; + + // this will get the last entries (most recent) in the bank + for (int k=0; k 0 ? POSITIVE : NEGATIVE; + this.quartet = bank.getByte("quartet",k) > 0 ? POSITIVE : NEGATIVE; + this.gatedFcup = bank.getLong("value",k); + break; + case CHAN_SLM: + this.gatedSlm = bank.getLong("value",k); + break; + case CHAN_CLOCK: + this.gatedClock = bank.getLong("value",k); + break; + default: + break; + } + } + else if (bank.getInt("slot",k)==SLOT_UNGATED) { + switch (bank.getInt("channel",k)) { + case CHAN_FCUP: + this.fcup = bank.getLong("value",k); + break; + case CHAN_SLM: + this.slm = bank.getLong("value",k); + break; + case CHAN_CLOCK: + this.clock = bank.getLong("value",k); + break; + default: + break; + } + } + } + if (GATEINVERTED) { + gatedSlm = slm - gatedSlm; + gatedFcup = fcup - gatedFcup; + gatedClock = clock - gatedClock; + } + + this.calibrate(fcupTable,slmTable); + } +} \ No newline at end of file diff --git a/common-tools/clas-geometry/pom.xml b/common-tools/clas-geometry/pom.xml index b3df39a866..cafc6a1782 100644 --- a/common-tools/clas-geometry/pom.xml +++ b/common-tools/clas-geometry/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-geometry - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT diff --git a/common-tools/clas-io/pom.xml b/common-tools/clas-io/pom.xml index e616cb5e30..244f4481de 100644 --- a/common-tools/clas-io/pom.xml +++ b/common-tools/clas-io/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-io - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT @@ -75,7 +75,7 @@ org.jlab.clas clas-utils - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT diff --git a/common-tools/clas-io/src/main/java/org/jlab/io/utils/Bos2HipoEventBank.java b/common-tools/clas-io/src/main/java/org/jlab/io/utils/Bos2HipoEventBank.java index 2477c45174..2df2c40fec 100644 --- a/common-tools/clas-io/src/main/java/org/jlab/io/utils/Bos2HipoEventBank.java +++ b/common-tools/clas-io/src/main/java/org/jlab/io/utils/Bos2HipoEventBank.java @@ -49,12 +49,21 @@ public void initHipoBank(DataEvent hipoEvent){ if(this.bosDataBanks.containsKey("HEVT")==true){ DataBank bankHEVT = hipoEvent.createBank("HEADER::info", 1); + bankHEVT.setInt("estatus", 0, this.bosDataBanks.get("HEVT").getInt("ESTATUS")[0]); bankHEVT.setInt("nrun", 0, this.bosDataBanks.get("HEVT").getInt("NRUN")[0]); bankHEVT.setInt("nevt", 0, this.bosDataBanks.get("HEVT").getInt("NEVENT")[0]); + bankHEVT.setInt("type", 0, this.bosDataBanks.get("HEVT").getInt("TYPE")[0]); + bankHEVT.setInt("npgp", 0, this.bosDataBanks.get("HEVT").getInt("NPGP")[0]); + bankHEVT.setInt("trgprs", 0, this.bosDataBanks.get("HEVT").getInt("TRGPRS")[0]); + bankHEVT.setFloat("tg", 0, this.bosDataBanks.get("HEVT").getFloat("TG")[0]); bankHEVT.setFloat("stt" , 0, this.bosDataBanks.get("HEVT").getFloat("STT")[0]); bankHEVT.setFloat("fc" , 0, this.bosDataBanks.get("HEVT").getFloat("FC")[0]); bankHEVT.setFloat("fcg" , 0, this.bosDataBanks.get("HEVT").getFloat("FCG")[0]); - + bankHEVT.setFloat("rf1", 0, this.bosDataBanks.get("HEVT").getFloat("RF1")[0]); + bankHEVT.setFloat("rf2", 0, this.bosDataBanks.get("HEVT").getFloat("RF2")[0]); + bankHEVT.setFloat("con1", 0, this.bosDataBanks.get("HEVT").getFloat("CON1")[0]); + bankHEVT.setFloat("con2", 0, this.bosDataBanks.get("HEVT").getFloat("CON2")[0]); + bankHEVT.setFloat("con3", 0, this.bosDataBanks.get("HEVT").getFloat("CON3")[0]); int evtclass = this.bosDataBanks.get("HEVT").getInt("TRGPRS")[0]; byte ihelicity = 0; if(evtclass<0) ihelicity = 1; @@ -88,8 +97,10 @@ public void initHipoBank(DataEvent hipoEvent){ hipoEVNTp.setByte("lcstat", loop, (byte) bEVNT.getInt("LCstat")[loop]); hipoEVNTp.setByte("scstat", loop, (byte) bEVNT.getInt("SCstat")[loop]); hipoEVNTp.setByte("ccstat", loop, (byte) bEVNT.getInt("CCstat")[loop]); + hipoEVNTp.setByte("ststat", loop, (byte) bEVNT.getInt("STstat")[loop]); hipoEVNTp.setInt("pid",loop, bEVNT.getInt("ID")[loop]); + hipoEVNTp.setFloat("beta", loop, bEVNT.getFloat("Betta")[loop]); hipoEVNTp.setFloat("mass", loop,bEVNT.getFloat("Mass")[loop]); hipoEVNTp.setFloat("px", loop,bEVNT.getFloat("Pmom")[loop]*bEVNT.getFloat("Cx")[loop]); hipoEVNTp.setFloat("py", loop,bEVNT.getFloat("Pmom")[loop]*bEVNT.getFloat("cy")[loop]); @@ -112,7 +123,17 @@ public void initHipoBank(DataEvent hipoEvent){ } this.hipoDataBanks.put("TGPB", hipoTGPBp); } - + if(this.bosDataBanks.containsKey("TGBI")==true){ + BosDataBank tgbi = (BosDataBank) this.bosDataBanks.get("TGBI"); + DataBank hipoTGBIp = hipoEvent.createBank("HEADER::tgbi",tgbi.rows()); + hipoTGBIp.setInt("latch1", 0, tgbi.getInt("latch1")[0]); + hipoTGBIp.setInt("helicity_scaler", 0, tgbi.getInt("helicity_scaler")[0]); + hipoTGBIp.setInt("interrupt_time", 0, tgbi.getInt("interrupt_time")[0]); + hipoTGBIp.setInt("latch2", 0, tgbi.getInt("latch2")[0]); + hipoTGBIp.setInt("level3", 0, tgbi.getInt("level3")[0]); + + this.hipoDataBanks.put("TGBI", hipoTGBIp); + } if(this.bosDataBanks.containsKey("TAGR")==true){ BosDataBank tagr = (BosDataBank) this.bosDataBanks.get("TAGR"); DataBank hipoTAGRp = hipoEvent.createBank("TAGGER::tagr",tagr.rows()); @@ -151,6 +172,7 @@ public void initHipoBank(DataEvent hipoEvent){ hipoDCPB.setFloat("z_v", loop, bDCPB.getFloat("Z_v")[loop]); hipoDCPB.setFloat("r_v", loop, bDCPB.getFloat("R_v")[loop]); hipoDCPB.setFloat("chi2", loop, bDCPB.getFloat("Chi2")[loop]); + hipoDCPB.setInt("status", loop, bDCPB.getInt("Status")[loop]); } this.hipoDataBanks.put("DCPB", hipoDCPB); } @@ -176,6 +198,10 @@ public void initHipoBank(DataEvent hipoEvent){ hipoICPB.setFloat("tc", loop, bICPB.getFloat("Time")[loop]); hipoICPB.setFloat("xc", loop, bICPB.getFloat("X")[loop]); hipoICPB.setFloat("yc", loop, bICPB.getFloat("Y")[loop]); + hipoICPB.setFloat("m2_hit", loop, bICPB.getFloat("M2_hit")[loop]); + hipoICPB.setFloat("m3_hit", loop, bICPB.getFloat("M3_hit")[loop]); + hipoICPB.setInt("status", loop, bICPB.getInt("Status")[loop]); + hipoICPB.setFloat("zc", loop, bICPB.getFloat("Z")[loop]); } this.hipoDataBanks.put("ICPB", hipoICPB); } @@ -199,7 +225,13 @@ public void initHipoBank(DataEvent hipoEvent){ hipoECPB.setFloat("x", loop, bECPB.getFloat("X") [loop]); hipoECPB.setFloat("y", loop, bECPB.getFloat("Y") [loop]); hipoECPB.setFloat("z", loop, bECPB.getFloat("Z") [loop]); + hipoECPB.setFloat("m2_hit", loop, bECPB.getFloat("M2_hit")[loop]); + hipoECPB.setFloat("m3_hit", loop, bECPB.getFloat("M3_hit")[loop]); + hipoECPB.setFloat("m4_hit", loop, bECPB.getFloat("M4_hit")[loop]); hipoECPB.setFloat("chi2", loop, bECPB.getFloat("Chi2EC") [loop]); + hipoECPB.setInt("innstr", loop, bECPB.getInt("InnStr")[loop]); + hipoECPB.setInt("outstr", loop, bECPB.getInt("OutStr")[loop]); + hipoECPB.setInt("status", loop, bECPB.getInt("Status")[loop]); } this.hipoDataBanks.put("ECPB", hipoECPB); //banklist.add(hipoECPB); @@ -212,7 +244,9 @@ public void initHipoBank(DataEvent hipoEvent){ for(int loop = 0; loop < rows; loop++){ int scht = bLCPB.getInt("ScHt")[loop]; int sector = (int) scht/100; + int lchit_id = scht - sector; hipoLCPB.setByte("sector", loop, (byte) sector); + hipoLCPB.setByte("hit_id", loop, (byte) lchit_id); hipoLCPB.setFloat("etot", loop, bLCPB.getFloat("Etot")[loop]); hipoLCPB.setFloat("ein" , loop, bLCPB.getFloat("Ein")[loop]); hipoLCPB.setFloat("time", loop, bLCPB.getFloat("Time") [loop]); @@ -221,6 +255,7 @@ public void initHipoBank(DataEvent hipoEvent){ hipoLCPB.setFloat("y", loop, bLCPB.getFloat("Y") [loop]); hipoLCPB.setFloat("z", loop, bLCPB.getFloat("Z") [loop]); hipoLCPB.setFloat("chi2", loop, bLCPB.getFloat("Chi2LC") [loop]); + hipoLCPB.setInt("status", loop, bLCPB.getInt("Status") [loop]); } this.hipoDataBanks.put("LCPB", hipoLCPB); //banklist.add(hipoECPB); @@ -232,15 +267,18 @@ public void initHipoBank(DataEvent hipoEvent){ for(int loop = 0; loop < rows; loop++){ int sector = bSCPB.getInt("ScPdHt")[loop]/10000; int paddle = bSCPB.getInt("ScPdHt")[loop]/100 - sector*100; + int hit_id = bSCPB.getInt("ScPdHt")[loop] - sector - paddle; //System.err.println(" " + bSCPB.getInt("ScPdHt")[loop] + // " sector = " + sector + " " + paddle); //int paddle = bSCPB.getInt("ScPdHt")[loop]/10000; hipoSCPB.setByte("sector", loop, (byte) sector); hipoSCPB.setByte("paddle", loop, (byte) paddle); + hipoSCPB.setByte("hit_id", loop, (byte) hit_id); hipoSCPB.setFloat("edep", loop, bSCPB.getFloat("Edep") [loop]); hipoSCPB.setFloat("time", loop, bSCPB.getFloat("Time") [loop]); hipoSCPB.setFloat("path", loop, bSCPB.getFloat("Path") [loop]); hipoSCPB.setFloat("chi2", loop, bSCPB.getFloat("Chi2SC") [loop]); + hipoSCPB.setInt("status", loop, bSCPB.getInt("Status") [loop]); } this.hipoDataBanks.put("SCPB", hipoSCPB); } @@ -251,9 +289,12 @@ public void initHipoBank(DataEvent hipoEvent){ DataBank hipoCCPB = hipoEvent.createBank("DETECTOR::ccpb", rows); for(int loop = 0; loop < rows; loop++){ int sector = bCCPB.getInt("ScSgHt")[loop]/100; + int cluster = bCCPB.getInt("ScSgHt")[loop] - sector*100; //int paddle = bSCPB.getInt("ScPdHt")[loop]/10000; hipoCCPB.setByte("sector", loop, (byte) sector); + hipoCCPB.setInt("clusterid", loop, cluster); hipoCCPB.setFloat("nphe", loop, bCCPB.getFloat("Nphe") [loop]); + hipoCCPB.setInt("status", loop, bCCPB.getInt("Status") [loop]); hipoCCPB.setFloat("time", loop, bCCPB.getFloat("Time") [loop]); hipoCCPB.setFloat("path", loop, bCCPB.getFloat("Path") [loop]); hipoCCPB.setFloat("chi2", loop, bCCPB.getFloat("Chi2CC") [loop]); diff --git a/common-tools/clas-jcsg/pom.xml b/common-tools/clas-jcsg/pom.xml index c17fb5bc75..83b33109f4 100644 --- a/common-tools/clas-jcsg/pom.xml +++ b/common-tools/clas-jcsg/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-jcsg - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT @@ -40,12 +40,12 @@ org.jlab.clas clas-geometry - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT org.jlab.clas clas-detector - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT java3d diff --git a/common-tools/clas-math/pom.xml b/common-tools/clas-math/pom.xml index 472cc44d73..62fd5f13d2 100644 --- a/common-tools/clas-math/pom.xml +++ b/common-tools/clas-math/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-math - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT diff --git a/common-tools/clas-physics/pom.xml b/common-tools/clas-physics/pom.xml index ba7b522b27..f4f3e68473 100644 --- a/common-tools/clas-physics/pom.xml +++ b/common-tools/clas-physics/pom.xml @@ -4,7 +4,7 @@ org.jlab.clas clas-physics - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT jar @@ -23,7 +23,7 @@ org.jlab.clas clas12rec ../../parent/pom.xml - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT diff --git a/common-tools/clas-reco/pom.xml b/common-tools/clas-reco/pom.xml index 5603622df9..49d442dde8 100644 --- a/common-tools/clas-reco/pom.xml +++ b/common-tools/clas-reco/pom.xml @@ -3,14 +3,14 @@ 4.0.0 org.jlab.clas clas-reco - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT jar org.jlab.clas clas12rec ../../parent/pom.xml - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT @@ -67,7 +67,7 @@ org.jlab.clas clas-math - 6.5.9-SNAPSHOT + 6.5.11-SNAPSHOT