Skip to content
This repository has been archived by the owner on May 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #599 from JeffersonLab/development
Browse files Browse the repository at this point in the history
Go to master for new production release
  • Loading branch information
raffaelladevita authored Oct 6, 2020
2 parents b3da11a + df16fd2 commit 57f2cd0
Show file tree
Hide file tree
Showing 85 changed files with 2,013 additions and 1,319 deletions.
1 change: 1 addition & 0 deletions build-coatjava.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions common-tools/clas-analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-analysis</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</parent>

<build>
Expand All @@ -30,31 +30,31 @@
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-physics</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {

Expand All @@ -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);
Expand All @@ -44,54 +48,64 @@ 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) {

HipoReader reader = new HipoReader();
reader.open(filename);

RCDBConstants rcdb = null;
IndexedTable ccdb = null;
IndexedTable ccdb_fcup = null;
IndexedTable ccdb_slm = null;

while (reader.hasNext()) {

// read the event and necessary banks:
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<s1 ? s2+60*60*24-s1 : s2-s1;

// modify RUN::scaler and put it back in the event:
DaqScalers ds = DaqScalers.create(rawScalerBank, ccdb, seconds);
runScalerBank.putFloat("fcupgated",0,ds.getBeamChargeGated());
runScalerBank.putFloat("fcup",0,ds.getBeamCharge());
runScalerBank.putFloat("livetime",0,ds.getLivetime());
Date uet = new Date(runConfigBank.getInt("unixtime",0)*1000L);

DaqScalers ds = DaqScalers.create(rawScalerBank, ccdb_fcup, ccdb_slm, rst, uet);
runScalerBank = ds.createRunBank(writer.getSchemaFactory());
helScalerBank = ds.createHelicityBank(writer.getSchemaFactory());

// the scaler banks always are slightly after the helicity changes, so
// assign the previous (delay-corrected) helicity state to this scaler reading:
helScalerBank.putByte("helicity",0,helSeq.search(event,-1).value());
if (helSeq.getHalfWavePlate(event))
helScalerBank.putByte("helicityRaw",0,(byte)(-1*helSeq.search(event,-1).value()));
else
helScalerBank.putByte("helicityRaw",0,helSeq.search(event,-1).value());

// put modified HEL/RUN::scaler back in the event:
event.write(runScalerBank);
event.write(helScalerBank);
}

writer.addEvent(event, event.getEventTag());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import org.jlab.utils.system.ClasUtilsFile;

import org.jlab.detector.decode.DaqScalers;
import org.jlab.detector.decode.DaqScalersSequence;
import org.jlab.detector.scalers.DaqScalers;
import org.jlab.detector.scalers.DaqScalersSequence;

import org.jlab.detector.helicity.HelicityBit;
import org.jlab.detector.helicity.HelicitySequenceManager;
Expand Down Expand Up @@ -40,6 +40,7 @@ public static void main(String[] args) {
OptionParser parser = new OptionParser("postprocess");
parser.addOption("-q","0","do beam charge and livetime (0/1=false/true)");
parser.addOption("-d","0","do delayed helicity (0/1=false/true)");
parser.addOption("-f","0","do global offline helicity flip (0/1=false/true)");
parser.addRequired("-o","output.hipo");
parser.parse(args);

Expand All @@ -57,13 +58,14 @@ public static void main(String[] args) {
// helicity / beamcharge options:
final boolean doHelicity = parser.getOption("-d").intValue() != 0;
final boolean doBeamCharge = parser.getOption("-q").intValue() != 0;
final boolean doHelicityFlip = parser.getOption("-f").intValue() != 0;
if (!doHelicity && !doBeamCharge) {
parser.printUsage();
System.err.println("\n >>>>> 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();
Expand All @@ -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;
Expand All @@ -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());
}
Expand All @@ -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());
}
}

Expand Down
10 changes: 5 additions & 5 deletions common-tools/clas-detector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</parent>

<build>
Expand All @@ -30,7 +30,7 @@
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</dependency>

<dependency>
Expand All @@ -42,13 +42,13 @@
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>6.5.9-SNAPSHOT</version>
<version>6.5.11-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Loading

0 comments on commit 57f2cd0

Please sign in to comment.