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 #520 from JeffersonLab/bugfix-6.5.6
Browse files Browse the repository at this point in the history
Gated beam charge bugfix
  • Loading branch information
baltzell authored Apr 25, 2020
2 parents 72578b8 + 128e90b commit f24b1aa
Show file tree
Hide file tree
Showing 38 changed files with 227 additions and 117 deletions.
7 changes: 7 additions & 0 deletions bin/rebuild-scalers
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

source `dirname $0`/env.sh

MALLOC_ARENA_MAX=1; export MALLOC_ARENA_MAX

java -Xmx768m -Xms768m -cp "$CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/services/*:$CLAS12DIR/lib/utils/*" org.jlab.analysis.postprocess.RebuildScalers $*
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.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
<packaging>jar</packaging>

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

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

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-physics</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package org.jlab.analysis.postprocess;

import java.sql.Time;
import java.util.Arrays;
import java.util.Date;
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.jnp.hipo4.data.Bank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.io.HipoReader;
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
import org.jlab.utils.groups.IndexedTable;
import org.jlab.utils.options.OptionParser;
import org.jlab.utils.system.ClasUtilsFile;

/**
* Rebuild RUN::scaler from RAW::scaler
*
* @author baltzell
*/
public class RebuildScalers {

static final String CCDB_FCUP_TABLE="/runcontrol/fcup";

public static void main(String[] args) {

OptionParser parser = new OptionParser("rebuildscaler");
parser.addRequired("-o","output.hipo");
parser.parse(args);
List<String> inputList = parser.getInputList();
if(inputList.isEmpty()==true){
parser.printUsage();
System.err.println("\n >>>> error : no input file is specified....\n");
System.exit(1);
}

HipoWriterSorted writer = new HipoWriterSorted();
writer.getSchemaFactory().initFromDirectory(ClasUtilsFile.getResourceDir("COATJAVA", "etc/bankdefs/hipo4"));
writer.setCompressionType(1);
writer.open(parser.getOption("-o").stringValue());

Event event = new Event();
Bank rawScalerBank = new Bank(writer.getSchemaFactory().getSchema("RAW::scaler"));
Bank runScalerBank = new Bank(writer.getSchemaFactory().getSchema("RUN::scaler"));
Bank runConfigBank = new Bank(writer.getSchemaFactory().getSchema("RUN::config"));

ConstantsManager conman = new ConstantsManager();
conman.init(Arrays.asList(new String[]{CCDB_FCUP_TABLE}));

for (String filename : inputList) {

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

RCDBConstants rcdb = null;
IndexedTable ccdb = null;

while (reader.hasNext()) {

// read the event and necessary banks:
reader.nextEvent(event);
event.read(runConfigBank);
event.read(runScalerBank);
event.read(rawScalerBank);

// this is the bank we're here to rebuild:
event.remove(runScalerBank.getSchema());

// get CCDB/RCDB constants:
if (runConfigBank.getInt("run",0) >= 100) {
ccdb = conman.getConstants(runConfigBank.getInt("run",0),CCDB_FCUP_TABLE);
rcdb = conman.getRcdbConstants(runConfigBank.getInt("run",0));
}

// now rebuild the RUN::scaler bank:
if (rcdb!=null && ccdb !=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);
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());
event.write(runScalerBank);
}

writer.addEvent(event, event.getEventTag());
}
reader.close();
}
writer.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public static void main(String[] args) {
else {
goodCharge++;
if (doBeamCharge) {
recEventBank.putFloat("beamCharge",0,ds.getBeamCharge());
recEventBank.putFloat("beamCharge",0,ds.getBeamChargeGated());
recEventBank.putDouble("liveTime",0,ds.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.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
<packaging>jar</packaging>

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

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

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

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static DaqScalers create(Bank rawScalerBank,IndexedTable fcupTable,double

if (dsc2.getClock() > 0) {

float live = dsc2.getGatedSlm() / dsc2.getSlm();
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;
Expand Down
10 changes: 5 additions & 5 deletions common-tools/clas-eventmerger/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>clas-eventmerger</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
<packaging>jar</packaging>

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

<build>
Expand All @@ -29,19 +29,19 @@
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
4 changes: 2 additions & 2 deletions common-tools/clas-geometry/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-geometry</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
<packaging>jar</packaging>

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

<build>
Expand Down
6 changes: 3 additions & 3 deletions common-tools/clas-io/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-io</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
<packaging>jar</packaging>

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

<build>
Expand Down Expand Up @@ -75,7 +75,7 @@
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
8 changes: 4 additions & 4 deletions common-tools/clas-jcsg/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-jcsg</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
<packaging>jar</packaging>

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

<build>
Expand Down Expand Up @@ -40,12 +40,12 @@
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>java3d</groupId>
Expand Down
4 changes: 2 additions & 2 deletions common-tools/clas-math/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-math</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
<packaging>jar</packaging>

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

<build>
Expand Down
4 changes: 2 additions & 2 deletions common-tools/clas-physics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.jlab.clas</groupId>
<artifactId>clas-physics</artifactId>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
Expand All @@ -23,7 +23,7 @@
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>6.5.3-SNAPSHOT</version>
<version>6.5.6-SNAPSHOT</version>
</parent>

</project>
Loading

0 comments on commit f24b1aa

Please sign in to comment.