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

Commit

Permalink
Extend Time2Distance array size to accomodate larger values of tmax.
Browse files Browse the repository at this point in the history
Add fields residual sum and times sum to TB segment bank.
  • Loading branch information
zieglerv committed Aug 3, 2017
1 parent 5d68dc4 commit 08c6a1e
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,7 @@ public class CalibrationConstantsLoader {
public CalibrationConstantsLoader() {
// TODO Auto-generated constructor stub
}
/* public static final int[] cableid =
{0,0,1,7, 13,19,25,31,37,0,0,0,0,43,49,55,61,67,73,79,
0,0,2,8, 14,20,26,32,38,0,0,0,0,44,50,56,62,68,74,80,
0,0,3,9, 15,21,27,33,39,0,0,0,0,45,51,57,63,69,75,81,
0,0,4,10,16,22,28,34,40,0,0,0,0,46,52,58,64,70,76,82,
0,0,5,11,17,23,29,35,41,0,0,0,0,47,53,59,65,71,77,83,
0,0,6,12,18,24,30,36,42,0,0,0,0,48,54,60,66,72,78,84};*/
/*
// T2D
public static final double[][] deltanm = new double[6][6];
public static final double[][] v0 = new double[6][6]; // staturated drift velocity in cm/ns
public static final double[][] delt_bfield_coefficient = new double[6][6]; //coefficient of the bfield part of the increase in time
public static final double[] dmaxsuperlayer = {0.77665,0.81285,1.25065,1.32446,1.72947,1.80991};
public static final double[][] tmaxsuperlayer = new double[6][6];
public static final double deltatime_bfield_par1[][] = new double[6][6];
public static final double deltatime_bfield_par2[][] = new double[6][6];
public static final double deltatime_bfield_par3[][] = new double[6][6];
public static final double deltatime_bfield_par4[][] = new double[6][6];
public static final double distbeta[][] = new double[6][6];
//RMS
// Instantiating the constants arrays
public static final double[][] PAR1 = new double[6][6];
public static final double[][] PAR2 = new double[6][6];
public static final double[][] PAR3 = new double[6][6];
public static final double[][] PAR4 = new double[6][6];
public static final double[][] SCAL = new double[6][6];
public static final int[][][][] STATUS = new int[6][6][6][112];
//T0s
public static final double[][][][] T0 = new double[6][6][7][6]; //nSec*nSL*nSlots*nCables
public static final double[][][][] T0Err = new double[6][6][7][6]; //nSec*nSL*nSlots*nCables
*/

//Map of Cable ID (1, .., 6) in terms of Layer number (1, ..., 6) and localWire# (1, ..., 16)
public static final int[][] CableID = { //[nLayer][nLocWire] => nLocWire=16, 7 groups of 16 wires in each layer
{1, 1, 1, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 6, 6, 6}, //Layer 1
Expand Down Expand Up @@ -193,7 +158,7 @@ public static final synchronized void Load(int runNb, String var) {
}

public static final synchronized void LoadDevel(int runNb, String var, String var2) {

System.out.println(" LOADING DEVEL for Run "+runNb+" var "+var+" var2 "+var2);
double[][] DELTANM = new double[6][6];
double[][] V0 = new double[6][6]; // staturated drift velocity in cm/ns
double[][] DELT_BFIELD_COEFFICIENT = new double[6][6]; //coefficient of the bfield part of the increase in time
Expand Down Expand Up @@ -229,7 +194,7 @@ public static final synchronized void LoadDevel(int runNb, String var, String va
dbprovider.loadTable("/geometry/dc/superlayer");
//disconncect from database. Important to do this after loading tables.
dbprovider.disconnect();

dbprovider_Test.disconnect();
//dbprovider.show();
// Getting DMAX
for (int i = 0; i < dbprovider.length("/geometry/dc/superlayer/superlayer"); i++) {
Expand Down Expand Up @@ -260,6 +225,7 @@ public static final synchronized void LoadDevel(int runNb, String var, String va
}

// 2) T2D

for (int i = 0; i < dbprovider_Test.length("/calibration/dc/time_to_distance/tvsx_devel_v2/Sector"); i++) {

int iSec = dbprovider_Test.getInteger("/calibration/dc/time_to_distance/tvsx_devel_v2/Sector", i);
Expand Down Expand Up @@ -287,8 +253,8 @@ public static final synchronized void LoadDevel(int runNb, String var, String va

DISTBETA[iSec - 1][iSly - 1] = idistbeta;

System.out.println(" T2D Constants : "+ " deltanm " + DELTANM[iSec - 1][iSly - 1] + " v0 " + V0[iSec - 1][iSly - 1] + " delt_bfield_coefficient " + DELT_BFIELD_COEFFICIENT[iSec - 1][iSly - 1]
+ " b1 " + DELTATIME_BFIELD_PAR1[iSec - 1][iSly - 1] + " b2 " + DELTATIME_BFIELD_PAR2[iSec - 1][iSly - 1] + " b3 " + DELTATIME_BFIELD_PAR3[iSec - 1][iSly - 1] + " b4 " + DELTATIME_BFIELD_PAR4[iSec - 1][iSly - 1]);
System.out.println("T2D Constants: Sector"+iSec+" Superlayer "+ iSly+" tmax "+TMAXSUPERLAYER[iSec - 1][iSly - 1]+" deltanm " + DELTANM[iSec - 1][iSly - 1] + " v0 " + V0[iSec - 1][iSly - 1] + " delt_bfield_coefficient " + DELT_BFIELD_COEFFICIENT[iSec - 1][iSly - 1]
+ " b1 " + DELTATIME_BFIELD_PAR1[iSec - 1][iSly - 1] + " b2 " + DELTATIME_BFIELD_PAR2[iSec - 1][iSly - 1] + " b3 " + DELTATIME_BFIELD_PAR3[iSec - 1][iSly - 1] + " b4 " + DELTATIME_BFIELD_PAR4[iSec - 1][iSly - 1] +" run "+runNb);
}
// T0-subtraction
for (int i = 0; i < dbprovider_Test.length("/calibration/dc/time_corrections/T0Corrections/Sector"); i++) {
Expand All @@ -302,7 +268,7 @@ public static final synchronized void LoadDevel(int runNb, String var, String va

T0[iSec - 1][iSly - 1][iSlot - 1][iCab - 1] = t0;
T0ERR[iSec - 1][iSly - 1][iSlot - 1][iCab - 1] = t0Error;
System.out.println(" DC CALIBRATION CONSTANTS TO; Cable id = "+iCab+" T0 = "+t0);
// System.out.println(" DC CALIBRATION CONSTANTS TO; Cable id = "+iCab+" T0 = "+t0 + " for variation "+var2+" Run = "+runNb);
}
CCDBConstants.setDELTANM(DELTANM);
CCDBConstants.setV0(V0);
Expand All @@ -325,6 +291,6 @@ public static final synchronized void LoadDevel(int runNb, String var, String va
}

public static final void main(String arg[]) {
CalibrationConstantsLoader.LoadDevel(790, "default", "dc_test1");
CalibrationConstantsLoader.LoadDevel(1142, "default", "dc_test2");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ public DataBank fillTBSegmentsBank(DataEvent event, List<Segment> seglist) {
bank.setFloat("fitSlopeErr", i, (float) cls.get_clusterLineFitSlopeErr());
bank.setFloat("fitInterc", i, (float) cls.get_clusterLineFitIntercept());
bank.setFloat("fitIntercErr", i, (float) cls.get_clusterLineFitInterceptErr());

bank.setFloat("resiSum", i, (float) seglist.get(i).get_ResiSum());
bank.setFloat("timeSum", i, (float) seglist.get(i).get_TimeSum());
bank.setFloat("SegEndPoint1X", i, (float) seglist.get(i).get_SegmentEndPoints()[0]);
bank.setFloat("SegEndPoint1Z", i, (float) seglist.get(i).get_SegmentEndPoints()[1]);
bank.setFloat("SegEndPoint2X", i, (float) seglist.get(i).get_SegmentEndPoints()[2]);
Expand All @@ -486,7 +487,7 @@ public DataBank fillTBSegmentsBank(DataEvent event, List<Segment> seglist) {
bank.setShort(hitStrg, i, (short) hitIdxArray[j]);
}
}

return bank;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public double get_PosErr(double B) {
if (this._TrkgStatus != -1) {
if (this.get_TimeToDistance() == 0) // if the time-to-dist is not set ... set it
{
set_TimeToDistance(B, 0);
set_TimeToDistance(1.0, B);
}

err = Constants.CELLRESOL; // default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ public void set_fittedCluster(FittedCluster _fittedCluster) {
this._fittedCluster = _fittedCluster;
}

private int _Sector; // sector[1...6]
private int _Superlayer; // superlayer [1,...6]
private int _Id; // cluster Id
private int _Sector; // sector[1...6]
private int _Superlayer; // superlayer [1,...6]
private int _Id; // cluster Id
private double _ResiSum; // sum of residuals for hits in segment

/**
*
Expand Down Expand Up @@ -131,6 +132,39 @@ public int get_RegionSlayer() {
return (this._Superlayer + 1) % 2 + 1;
}

/**
*
* @return sum of residuals for all hits in segment
*/
public double get_ResiSum() {
return _ResiSum;
}

/**
*
* @param _ResiSum sum of residuals for all hits in segment
*/
public void set_ResiSum(double _ResiSum) {
this._ResiSum = _ResiSum;
}

/**
*
* @return sum of the corrected (T0-subtracted) times of all hits in segment
*/
public double get_TimeSum() {
return _TimeSum;
}

/**
*
* @param _TimeSum sum of the corrected (T0-subtracted) times of all hits in segment
*/
public void set_TimeSum(double _TimeSum) {
this._TimeSum = _TimeSum;
}
private double _TimeSum; // sum of times for hits in segment

/**
*
* @param otherseg matching cluster in other superlayer in a region
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.jlab.rec.dc.Constants;
import org.jlab.rec.dc.GeometryLoader;
import org.jlab.rec.dc.cluster.FittedCluster;
import org.jlab.rec.dc.hit.FittedHit;
import org.jlab.rec.dc.trajectory.SegmentTrajectory;

/**
Expand Down Expand Up @@ -129,10 +130,21 @@ public List<Segment> get_Segments(List<FittedCluster> allClusters, DataEvent eve
seg.set_Trajectory(trj);
}
}

double sumRes=0;
double sumTime=0;

for(FittedHit h : seg) {
sumRes+=h.get_TimeResidual();
sumTime+=h.get_Time();
}
seg.set_ResiSum(sumRes);
seg.set_TimeSum(sumTime);

segList.add(seg);
}

// this.setAssociatedID(segList);
// this.setAssociatedID(segList);
return segList;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public TableLoader() {
// TODO Auto-generated constructor stub
}

public static double[][][][][] DISTFROMTIME = new double[6][6][6][6][850]; // sector slyr alpha Bfield time bins
//public static double[][][][][] DISTFROMTIME = new double[6][6][6][6][850]; // sector slyr alpha Bfield time bins
public static double[][][][][] DISTFROMTIME = new double[6][6][6][6][1200]; // sector slyr alpha Bfield time bins
static boolean T2DLOADED = false;
static int minBinIdxB = 0;
static int maxBinIdxB = 5;
Expand Down Expand Up @@ -73,7 +74,7 @@ public static synchronized void Fill() {

if(tbin>maxBinIdxT[s][r][ibfield][icosalpha]) {
maxBinIdxT[s][r][ibfield][icosalpha] = tbin;
}
} //System.out.println("tbin "+tbin+" tmax "+tmax+ "s "+s+" sl "+r );
if(DISTFROMTIME[s][r][ibfield][icosalpha][tbin]==0) {
// firstbin = bin;
// bincount = 0;
Expand Down Expand Up @@ -122,22 +123,22 @@ public static synchronized void Fill() {
*/
public static synchronized double calc_Time(double x, double dmax, double tmax, double alpha, double bfield, int s, int r) {

// Assume a functional form (time=x/v0+a*(x/dmax)**n+b*(x/dmax)**m)
// for time as a function of x for theta = 30 deg.
// first, calculate n
double n = ( 1.+ (CCDBConstants.getDELTANM()[s][r]-1.)*Math.pow(FracDmaxAtMinVel, CCDBConstants.getDELTANM()[s][r]) )/( 1.- Math.pow(FracDmaxAtMinVel, CCDBConstants.getDELTANM()[s][r]));
//now, calculate m
double m = n + CCDBConstants.getDELTANM()[s][r];
// determine b from the requirement that the time = tmax at dist=dmax
double b = (tmax - dmax/CCDBConstants.getV0()[s][r])/(1.- m/n);
// determine a from the requirement that the derivative at
// d=dmax equal the derivative at d=0
double a = -b*m/n;
double cos30minusalpha=Math.cos(Math.toRadians(30.-alpha));
double xhat = x/dmax;
double dmaxalpha = dmax*cos30minusalpha;
double xhatalpha = x/dmaxalpha;
// Assume a functional form (time=x/v0+a*(x/dmax)**n+b*(x/dmax)**m)
// for time as a function of x for theta = 30 deg.
// first, calculate n
double n = ( 1.+ (CCDBConstants.getDELTANM()[s][r]-1.)*Math.pow(FracDmaxAtMinVel, CCDBConstants.getDELTANM()[s][r]) )/( 1.- Math.pow(FracDmaxAtMinVel, CCDBConstants.getDELTANM()[s][r]));
//now, calculate m
double m = n + CCDBConstants.getDELTANM()[s][r];
// determine b from the requirement that the time = tmax at dist=dmax
double b = (tmax - dmax/CCDBConstants.getV0()[s][r])/(1.- m/n);
// determine a from the requirement that the derivative at
// d=dmax equal the derivative at d=0
double a = -b*m/n;

double cos30minusalpha=Math.cos(Math.toRadians(30.-alpha));
double xhat = x/dmax;
double dmaxalpha = dmax*cos30minusalpha;
double xhatalpha = x/dmaxalpha;

// now calculate the dist to time function for theta = 'alpha' deg.
// Assume a functional form with the SAME POWERS N and M and
Expand All @@ -156,21 +157,21 @@ public static synchronized double calc_Time(double x, double dmax, double tmax,
// a track with local angle alpha (for local angle = alpha)
double deltatime_bfield = CCDBConstants.getDELT_BFIELD_COEFFICIENT()[s][r]*Math.pow(bfield,2)*tmax*(CCDBConstants.getDELTATIME_BFIELD_PAR1()[s][r]*xhatalpha+CCDBConstants.getDELTATIME_BFIELD_PAR2()[s][r]*Math.pow(xhatalpha, 2)+
CCDBConstants.getDELTATIME_BFIELD_PAR3()[s][r]*Math.pow(xhatalpha, 3)+CCDBConstants.getDELTATIME_BFIELD_PAR4()[s][r]*Math.pow(xhatalpha, 4));

// System.out.println("dB "+deltatime_bfield+" raw time "+time);
//calculate the time at alpha deg. and at a non-zero bfield
time += deltatime_bfield;


return time;
}

public static void main(String args[]) {
CalibrationConstantsLoader.Load(10, "default");
TableLoader tbl = new TableLoader();
TableLoader.Fill();
//public static void main(String args[]) {
// CalibrationConstantsLoader.Load(10, "default");
// TableLoader tbl = new TableLoader();
// TableLoader.Fill();
//System.out.println(maxBinIdxT[1][0][0]+" "+maxBinIdxT[1][0][5]+" "+DISTFROMTIME[1][0][0][maxBinIdxT[1][0][0]]+ " "+DISTFROMTIME[1][0][5][maxBinIdxT[1][0][5]]);
//System.out.println(tbl.interpolateOnGrid(2.5, Math.toRadians(0.000000), 1000) );
//579: B 2.5 alpha 0 d 1.3419999999999992 alpha 1 1.3474999999999997

}
//}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jlab.rec.dc.track;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.apache.commons.math3.util.FastMath;
Expand Down Expand Up @@ -57,8 +56,8 @@ public List<Track> getTrackCands(CrossList crossList) {
TrajectoryFinder trjFind = new TrajectoryFinder();

Trajectory traj = trjFind.findTrajectory(crossesInTrk);
if(traj == null)
continue;
if(traj == null)
continue;

if(crossesInTrk.size()==3) {

Expand Down
22 changes: 12 additions & 10 deletions reconstruction/dc/src/main/java/org/jlab/service/dc/DCHBEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ public void setRunConditionsParameters(DataEvent event) {
boolean T2DCalc = false;

if(Run!=newRun) {
if(newRun>751 && newRun<912) {
//if(newRun>751 && newRun<912) {
if(newRun>99) {
T2DCalc = true;
Constants.setT0(true);
Constants.setUseMiniStagger(true);
Expand Down Expand Up @@ -268,8 +269,9 @@ public static void main(String[] args) throws FileNotFoundException, EvioExcepti
//String inputFile = "/Users/ziegler/Workdir/Distribution/coatjava-4a.0.0/old/RaffaNew.hipo";
//String inputFile = args[0];
//String outputFile = args[1];
//String inputFile="/Users/ziegler/Workdir/Files/Data/DecodedData/DC/big.806.pass4.2trackstdc.hipo";
String inputFile = "/Users/ziegler/Workdir/Files/GEMC/GEMCoutputFiles_hipo/sidis_0100_12.hipo";
String inputFile="/Users/ziegler/Workdir//Files/GEMC/TestDCOnlyE3.hipo";
//String inputFile="/Users/ziegler/Workdir/Files/test/electron_fd_t0.8torus.hipo";
// String inputFile = "/Users/ziegler/Workdir/Files/Data/DecodedData/DC/big.806.pass4.2trackstdc.hipo";
//System.err.println(" \n[PROCESSING FILE] : " + inputFile);

DCHBEngine en = new DCHBEngine();
Expand All @@ -285,8 +287,8 @@ public static void main(String[] args) throws FileNotFoundException, EvioExcepti
HipoDataSync writer = new HipoDataSync();
//Writer
//String outputFile="/Users/ziegler/Workdir/Distribution/DCTest_797D.hipo";
//String outputFile="/Users/ziegler/Workdir/Files/GEMC/DC/KPP2trksRecDd.hipo";
String outputFile = "/Users/ziegler/Workdir/Files/GEMC/GEMCoutputFiles_hipo/sidis_0100_12_rec_slow2.hipo";
// String outputFile="/Users/ziegler/Workdir/Files/test/electron_fd_rcF3.hipo";
String outputFile = "/Users/ziegler/Workdir//Files/GEMC/TestDCOnlyE2.rec3.hipo";
writer.open(outputFile);

long t1 = 0;
Expand All @@ -303,14 +305,14 @@ public static void main(String[] args) throws FileNotFoundException, EvioExcepti

// Processing TB
en2.processDataEvent(event);
//System.out.println(" EVENT "+counter);
if (counter > 9) {
break;
}
System.out.println(" EVENT "+counter);
// if (counter > 13) {
// break;
//}
//event.show();
//if(counter%100==0)
System.out.println("*************************************************************run " + counter + " events");
if(event.hasBank("HitBasedTrkg::HBTracks")) {
if(event.hasBank("TimeBasedTrkg::TBTracks")) {
// event.show();
writer.writeEvent(event);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,13 @@ public void setRunConditionsParameters(DataEvent event) {
// Load the constants
//-------------------
int newRun = bank.getInt("run", 0);
if(newRun ==0)
return;

boolean T2DCalc = false;

if(Run!=newRun) {
if(newRun>751 && newRun<912) {
if(newRun>99) {
T2DCalc = true;
Constants.setT0(true);
Constants.setUseMiniStagger(true);
Expand Down Expand Up @@ -261,7 +264,7 @@ public void setRunConditionsParameters(DataEvent event) {
public static void main(String[] args) throws FileNotFoundException, EvioException{

//String inputFile = "/Users/ziegler/Workdir/Distribution/coatjava-4a.0.0/clas_000767_000.hipo";
String inputFile = "/Users/ziegler/Workdir/Distribution/coatjava-4a.0.0/clas12_000797_a00000.hipo";
String inputFile = "/Users/ziegler/Workdir/Files/Data/clas12_001142_a00000.hipo";
//String inputFile = "/Users/ziegler/Workdir/Distribution/coatjava-4a.0.0/e2to6hipo.hipo";
// String inputFile="/Users/ziegler/Downloads/out.hipo";
//String inputFile = "/Users/ziegler/Workdir/Distribution/coatjava-4a.0.0/Run758.hipo";
Expand Down
Loading

0 comments on commit 08c6a1e

Please sign in to comment.