Skip to content

Commit

Permalink
FTCal: added time walk module and configuration panel
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaelladevita committed Apr 18, 2019
1 parent f280b7e commit e1cbd09
Show file tree
Hide file tree
Showing 13 changed files with 909 additions and 234 deletions.
33 changes: 17 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
ftHodoCalibNovice/target/classes/org/clas/fthodo/*.class
*/.DS_Store
*.txt
.DS_Store
*.class
*.jar
ftCalCalib/target/maven-archiver/pom.properties
ftCalCalib/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
ftCalCalib/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
ftCalLedAndCosmics/target/maven-archiver/pom.properties
ftCalLedAndCosmics/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
ftCalLedAndCosmics/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
ftHodoCalib/target/maven-archiver/pom.properties
ftHodoCalib/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
*.lst
*.cnf
*.tiff
*.properties
*.txt
.DS_Store
*.class
*.jar
ftCalCalib/target/maven-archiver/pom.properties
ftCalCalib/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
ftCalCalib/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
ftCalLedAndCosmics/target/maven-archiver/pom.properties
ftCalLedAndCosmics/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
ftCalLedAndCosmics/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
ftHodoCalib/target/maven-archiver/pom.properties
ftHodoCalib/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
*.lst
*.cnf
*.tiff
*.properties
ftHodoCalib/nbactions.xml
ftHodoCalibNovice/nbactions.xml
ftHodoCalibNovice/pom.xml
ftHodoCalibNovice/target/
/ftCalCalib/target/
9 changes: 6 additions & 3 deletions ftCalCalib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<dependency>
<groupId>org.jlab.coat</groupId>
<artifactId>coat-libs</artifactId>
<version>5.1-SNAPSHOT</version>
<version>5.9.0-SNAPSHOT</version>
<type>jar</type>
</dependency>

Expand Down Expand Up @@ -51,6 +51,9 @@
</executions>
</plugin>
</plugins>
</build>

</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
44 changes: 19 additions & 25 deletions ftCalCalib/src/main/java/org/clas/modules/FTElasticCalibration.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.clas.view.DetectorShape2D;
import org.clas.viewer.FTAdjustFit;
import org.clas.viewer.FTCalibrationModule;
import org.clas.viewer.FTDetector;
import org.jlab.clas.physics.Particle;
import org.jlab.detector.calib.utils.CalibrationConstants;
import org.jlab.detector.calib.utils.ConstantsManager;
import org.jlab.groot.base.ColorPalette;
import org.jlab.groot.data.H1F;
import org.jlab.groot.group.DataGroup;
Expand All @@ -24,6 +26,7 @@
import org.jlab.groot.fitter.DataFitter;
import org.jlab.groot.data.GraphErrors;
import org.jlab.utils.groups.IndexedTable;
import org.jlab.clas.pdg.PhysicsConstants;

/**
*
Expand All @@ -32,24 +35,14 @@
public class FTElasticCalibration extends FTCalibrationModule {

// analysis realted info
double ebeam=10604;//2217;//6424;//
double mass=938.27;
double nsPerSample=4;
double LSB = 0.4884;
double clusterEnergyThr = 500;// Vertical selection
int clusterSizeThr = 3;// Vertical selection
double emips = 15.3; //MeV
double charge2e = 6.005; //pC
double seed = 6980;//1370*ebeam/2217;
double ebeam=2217;//10604;//6424;//
double seed = 1370;//6980;//1370*ebeam/;

IndexedTable charge2energy = null;
// double crystal_length = 200;//mm
// double shower_depth = 65;
// double light_speed = 150; //cm/ns
// double c = 29.97; //cm/ns


public FTElasticCalibration(FTDetector d, String name) {
super(d, name, "seed:seed_error:factor:factor_err:charge2energy:",3);
public FTElasticCalibration(FTDetector d, String name, ConstantsManager ccdb, Map<String,CalibrationConstants> gConstants) {
super(d, name, "seed:seed_error:factor:factor_err:charge2energy:",3, ccdb, gConstants);
this.initRange(0., ebeam*1.1);
}

Expand Down Expand Up @@ -168,27 +161,28 @@ public void processEvent(DataEvent event) {
DataBank hitFTCAL = event.getBank("FTCAL::hits");
DataBank adcFTCAL = event.getBank("FTCAL::adc");
for (int loop = 0; loop < clusterFTCAL.rows(); loop++) {
int key = getDetector().getComponent(clusterFTCAL.getFloat("x", loop), clusterFTCAL.getFloat("y", loop));
int key = getDetector().getComponent(clusterFTCAL.getFloat("x", loop)/10., clusterFTCAL.getFloat("y", loop)/10.);
int id = clusterFTCAL.getShort("id", loop);
int size = clusterFTCAL.getShort("size", loop);
double x = clusterFTCAL.getFloat("x", loop);
double y = clusterFTCAL.getFloat("y", loop);
double z = clusterFTCAL.getFloat("z", loop);
double energy = 2e3 * clusterFTCAL.getFloat("energy", loop);
double energyR = 2e3 * clusterFTCAL.getFloat("recEnergy", loop);
double energy = 1e3 *clusterFTCAL.getFloat("energy", loop);
double energyR = 1e3 * clusterFTCAL.getFloat("recEnergy", loop);
double path = Math.sqrt(x*x+y*y+z*z);
double theta = Math.atan(Math.sqrt(x*x+y*y)/path);
double pela = mass*ebeam/(2*ebeam*Math.pow(Math.sin(theta/2), 2)+mass);
double pela = PhysicsConstants.massProton()*1000*ebeam/(2*ebeam*Math.pow(Math.sin(theta/2), 2)+PhysicsConstants.massProton()*1000);
double energySeed=0;
double energyCalib=0;
for(int k=0; k<adcFTCAL.rows(); k++) {
int component = adcFTCAL.getInt("component",k);
double energyK = (double) adcFTCAL.getInt("ADC",k);
double c2e = (LSB*nsPerSample/50)*emips/charge2e;
if(this.getConstantsManager()!=null) c2e = 2*charge2energy.getDoubleValue("fadc_to_charge", 1,1,component)
double c2e = (this.getConstants().LSB*this.getConstants().nsPerSample/50)*this.getConstants().eMips/this.getConstants().chargeMips;
if(this.getConstantsManager()!=null) c2e = 1*charge2energy.getDoubleValue("fadc_to_charge", 1,1,component)
*charge2energy.getDoubleValue("mips_energy", 1,1,component)
/charge2energy.getDoubleValue("mips_charge", 1,1,component);
if(key == component && energyK>energySeed) energySeed = energyK*c2e;
// System.out.println(key + " " + energyK + " " + c2e + " " + energySeed + " " + energy);
}
if(this.getPreviousCalibrationTable().hasEntry(1,1,key)) {
for(int k=0; k<hitFTCAL.rows(); k++) {
Expand All @@ -198,8 +192,8 @@ public void processEvent(DataEvent event) {
double energyK = (double) adcFTCAL.getInt("ADC",hitID);
if(this.getPreviousCalibrationTable().hasEntry(1,1,key)) {
double calib = this.getPreviousCalibrationTable().getDoubleValue("charge2energy", 1, 1, component);
double conv = (LSB*nsPerSample/50)*emips;
if(this.getConstantsManager()!=null) conv = 2*charge2energy.getDoubleValue("fadc_to_charge", 1,1,component)
double conv = (this.getConstants().LSB*this.getConstants().nsPerSample/50)*this.getConstants().eMips;
if(this.getConstantsManager()!=null) conv = 1*charge2energy.getDoubleValue("fadc_to_charge", 1,1,component)
*charge2energy.getDoubleValue("mips_energy", 1,1,component);
if(clusterID == id) {
energyCalib += energyK*conv/calib;
Expand All @@ -213,7 +207,7 @@ public void processEvent(DataEvent event) {
recParticle.setProperty("energySeed",energySeed);
recParticle.setProperty("energyCalib",energyCalib);
recParticle.setProperty("elastic",pela);
if(energyR>this.clusterEnergyThr && size>this.clusterSizeThr) ftParticles.add(recParticle);
if(energyR>this.getConstants().clusterThr && size>this.getConstants().clusterSize) ftParticles.add(recParticle);
// System.out.println(energyR + " " + size + " " + pela + " " + ftParticles.size());
}
if(ftParticles.size()>0) {
Expand Down Expand Up @@ -314,7 +308,7 @@ public void updateTable() {
double seedE_err = 0;
double factorE = 0;
double factorE_err = 0;
double c2e = charge2e;
double c2e = this.getConstants().chargeMips;
if(this.getConstantsManager()!=null) c2e = charge2energy.getDoubleValue("mips_charge", 1,1,key);

if(hseed.getEntries()>1000 && fseed.getParameter(1)>500) {
Expand Down
29 changes: 7 additions & 22 deletions ftCalCalib/src/main/java/org/clas/modules/FTEnergyCalibration.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,31 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.clas.view.DetectorShape2D;
import org.clas.viewer.FTCalibrationModule;
import org.clas.viewer.FTDetector;
import org.jlab.clas.pdg.PhysicsConstants;
import org.jlab.clas.physics.Particle;
import org.jlab.detector.calib.utils.CalibrationConstants;
import org.jlab.detector.calib.utils.ConstantsManager;
import org.jlab.groot.base.ColorPalette;
import org.jlab.groot.data.H1F;
import org.jlab.groot.group.DataGroup;
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
import org.jlab.groot.math.F1D;
import org.jlab.groot.data.H2F;
import org.jlab.clas.pdg.PhysicsConstants;

/**
*
* @author devita
*/
public class FTEnergyCalibration extends FTCalibrationModule {

// analysis realted info
double nsPerSample=4;
double LSB = 0.4884;
double clusterEnergyThr = 300.0;// Vertical selection
int clusterSizeThr = 3;// Vertical selection
// double singleChThr = 0.00;// Single channel selection MeV
// double signalThr =0.0;
// double simSignalThr=0.00;// Threshold used for simulated events in MeV
// double startTime = 124.25;//ns
// double ftcalDistance =1898; //mm
// double timeshift =0;// ns
// double crystal_size = 15.3;//mm
double charge2e = 15.3/6.005; //MeV
// double crystal_length = 200;//mm
// double shower_depth = 65;
// double light_speed = 150; //cm/ns
// double c = 29.97; //cm/ns

public FTEnergyCalibration(FTDetector d, String name) {
super(d, name, "offset:offset_error:resolution",3);
public FTEnergyCalibration(FTDetector d, String name, ConstantsManager ccdb, Map<String,CalibrationConstants> gConstants) {
super(d, name, "offset:offset_error:resolution",3, ccdb, gConstants);
}

@Override
Expand Down Expand Up @@ -146,13 +131,13 @@ public void processEvent(DataEvent event) {
double path = Math.sqrt(x*x+y*y+z*z);
double energySeed=0;
for(int k=0; k<adcFTCAL.rows(); k++) {
double energyK = ((double) adcFTCAL.getInt("ADC", k))*(LSB*nsPerSample/50)*charge2e;
double energyK = ((double) adcFTCAL.getInt("ADC", k))*(this.getConstants().LSB*this.getConstants().nsPerSample/50)*this.getConstants().eMips/this.getConstants().chargeMips;
if(key == adcFTCAL.getInt("component", k) && energyK>energySeed) energySeed = energyK;
}
Particle recParticle = new Particle(22, energy*x/path, energy*y/path, energy*z/path, 0,0,0);
recParticle.setProperty("key",(double) key);
recParticle.setProperty("energySeed",energySeed);
if(energyR>this.clusterEnergyThr && size>this.clusterSizeThr && charge==0) ftParticles.add(recParticle);
if(energyR>this.getConstants().clusterThr && size>this.getConstants().clusterSize && charge==0) ftParticles.add(recParticle);
}
if(ftParticles.size()>=2) {
for (int i1 = 0; i1 < ftParticles.size(); i1++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.clas.view.DetectorShape2D;
import org.clas.viewer.FTCalibrationModule;
import org.clas.viewer.FTDetector;
import org.jlab.clas.physics.Particle;
import org.jlab.detector.calib.utils.CalibrationConstants;
import org.jlab.detector.calib.utils.ConstantsManager;
import org.jlab.geom.prim.Vector3D;
import org.jlab.groot.base.ColorPalette;
import org.jlab.groot.data.H1F;
import org.jlab.groot.data.H2F;
import org.jlab.groot.group.DataGroup;
import org.jlab.io.base.DataBank;
import org.jlab.io.base.DataEvent;
import org.jlab.io.base.DataEventType;
import org.jlab.utils.groups.IndexedList;
import org.jlab.groot.math.F1D;
import org.jlab.groot.fitter.DataFitter;
import org.jlab.groot.data.GraphErrors;
import org.jlab.clas.pdg.PhysicsConstants;

/**
*
Expand All @@ -34,11 +35,11 @@
public class FTEnergyCorrection extends FTCalibrationModule {

private int minNumberOfEvents =100;
public double theta[] = new double[500];
public double phi[] = new double[500];
public double theta[] = new double[500];
public double phi[] = new double[500];

public FTEnergyCorrection(FTDetector d, String name) {
super(d, name, "c0:c1:c2:c3:c4",7);
public FTEnergyCorrection(FTDetector d, String name, ConstantsManager ccdb, Map<String,CalibrationConstants> gConstants) {
super(d, name, "c0:c1:c2:c3:c4",7, ccdb, gConstants);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import java.awt.Color;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.clas.view.DetectorShape2D;
import org.clas.viewer.FTCalibrationModule;
import org.clas.viewer.FTDetector;
import org.jlab.detector.calib.utils.CalibrationConstants;
import org.jlab.detector.calib.utils.ConstantsManager;
import org.jlab.groot.base.ColorPalette;
import org.jlab.groot.data.H1F;
import org.jlab.groot.group.DataGroup;
Expand All @@ -20,32 +22,17 @@
import org.jlab.groot.math.F1D;
import org.jlab.groot.fitter.DataFitter;
import org.jlab.groot.data.GraphErrors;
import org.jlab.clas.pdg.PhysicsConstants;

/**
*
* @author devita
*/
public class FTPedestalCalibration extends FTCalibrationModule {

// analysis realted info
double nsPerSample=4;
double LSB = 0.4884;
double clusterThr = 50.0;// Vertical selection
double singleChThr = 0.00;// Single channel selection MeV
double signalThr =0.0;
double adcThrs=0.00;// Threshold used for simulated events in MeV
double startTime = 124.25;//ns
double ftcalDistance =1898; //mm
double timeshift =0;// ns
double crystal_size = 15.3;//mm
double charge2e = 15.3/6.005; //MeV
double crystal_length = 200;//mm
double shower_depth = 65;
double light_speed = 150; //cm/ns
double c = 29.97; //cm/ns

public FTPedestalCalibration(FTDetector d, String name) {
super(d, name, "pedestal:pedestal_error:pedestal_sigma",3);

public FTPedestalCalibration(FTDetector d, String name, ConstantsManager ccdb, Map<String,CalibrationConstants> gConstants) {
super(d, name, "pedestal:pedestal_error:pedestal_sigma",3, ccdb, gConstants);
this.getCalibrationTable().addConstraint(3, 140, 260);
this.getCalibrationTable().addConstraint(5, 0, 1);
}
Expand All @@ -56,12 +43,12 @@ public void resetEventListener() {
H1F hpsum = new H1F("hpsum", 200, 100.0, 300.0);
hpsum.setTitleX("Pedestal (channel)");
hpsum.setTitleY("Counts");
hpsum.setTitle("Global Time Offset");
hpsum.setTitle("Pedestal Distribution");
hpsum.setFillColor(3);
H1F hpsum_calib = new H1F("hpsum_calib", 200, 100.0, 300.0);
hpsum_calib.setTitleX("Pedestal (channel)");
hpsum_calib.setTitleY("counts");
hpsum_calib.setTitle("Global Time Offset");
hpsum_calib.setTitle("Pedestal Distribution");
hpsum_calib.setFillColor(44);
GraphErrors gpedestals = new GraphErrors("gpedestals");
gpedestals.setTitle("Pedestals"); // title
Expand Down Expand Up @@ -123,12 +110,16 @@ public int getNEvents(int isec, int ilay, int icomp) {
return this.getDataGroup().getItem(1, 1, icomp).getH1F("hped_" + icomp).getEntries();
}

public double getPedestal(int isec, int ilay, int icomp) {
return this.getCalibrationTable().getDoubleValue("pedestal", isec, ilay, icomp);
}

public void processEvent(DataEvent event) {
// loop over FTCAL reconstructed cluster
this.startTime = -100000;
double startTime = -100000;
if(event.hasBank("REC::Event")) {
DataBank recEvent = event.getBank("REC::Event");
this.startTime = recEvent.getFloat("STTime", 0);
startTime = recEvent.getFloat("STTime", 0);
// System.out.println(this.startTime);
}
if (event.hasBank("FTCAL::adc")) {
Expand All @@ -137,7 +128,7 @@ public void processEvent(DataEvent event) {
int key = adcFTCAL.getInt("component", loop);
int adc = adcFTCAL.getInt("ADC", loop);
double ped = adcFTCAL.getShort("ped", loop);
if(adc>adcThrs) {
if(adc>0) {
this.getDataGroup().getItem(1,1,key).getH1F("hpsum").fill(ped);
this.getDataGroup().getItem(1,1,key).getH1F("hped_wide_"+key).fill(ped);
this.getDataGroup().getItem(1,1,key).getH1F("hped_"+key).fill(ped);
Expand Down Expand Up @@ -201,9 +192,9 @@ public Color getColor(DetectorShape2D dsd) {
ColorPalette palette = new ColorPalette();
Color col = new Color(100, 100, 100);
if (this.getDetector().hasComponent(key)) {
int nent = this.getNEvents(sector, layer, key);
if (nent > 0) {
col = palette.getColor3D(nent, this.getnProcessed(), true);
double ped = this.getPedestal(sector, layer, key);
if (ped > 0) {
col = palette.getColor3D(ped, 500, false);
}
}
// col = new Color(100, 0, 0);
Expand Down
Loading

0 comments on commit e1cbd09

Please sign in to comment.