Skip to content

Commit

Permalink
Merge pull request #1032 from JeffersonLab/alignment_branch
Browse files Browse the repository at this point in the history
Alignment branch
  • Loading branch information
pbutti authored May 3, 2024
2 parents fb068ff + 09ef3c5 commit 45b104f
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,18 @@ protected void detectorChanged(Detector detector) {

bFieldMap = detector.getFieldMap();

if (trackCollectionName.contains("Kalman") || trackCollectionName.contains("KF")) {

kinkFolder = "/kf_kinks/";
epullFolder = "/kf_err_pulls/";
trkpFolder = "/kf_trk_params/";
trkpDetailFolder = "/kf_trk_detail/";
resFolder = "/kf_res/";
hitFolder = "/kf_hit/";
}



setupPlots();
setupEoPPlots();
}
Expand Down Expand Up @@ -234,8 +246,9 @@ public void process(EventHeader event) {
if (trackCollectionName.contains("Kalman") || trackCollectionName.contains("KF")) {
TrackType = 1;
//System.out.println("PF:: DEBUG :: Found Kalman Tracks in the event");
}

}

//System.out.println("Running on "+trackCollectionName);

//RelationalTable trackMatchTable = null;
Expand Down Expand Up @@ -264,10 +277,10 @@ public void process(EventHeader event) {

//Remove tracks with less than 10 hits
if ((TrackType == 0 && trk.getTrackerHits().size() < nHits)
|| (TrackType == 1 && trk.getTrackerHits().size() < 2*nHits)) {
System.out.println("WARNING:: "+trk.getClass().getSimpleName()
+" got to GBLOutputDriver with "+trk.getTrackerHits().size()+" hits"
+" which is below the cut that should have been already applied.");
|| (TrackType == 1 && trk.getTrackerHits().size() < 2*nHits)) {
//System.out.println("WARNING:: "+trk.getClass().getSimpleName()
// +" got to GBLOutputDriver with "+trk.getTrackerHits().size()+" hits"
// +" which is below the cut that should have been already applied.");
continue;
}

Expand Down Expand Up @@ -998,6 +1011,26 @@ private void setupPlots() {
aidaGBL.profile1D(resFolder+"uresidual_GBL_mod_p",mod_2dplot_bins,-0.5,mod_2dplot_bins-0.5);


//Hits vs channel
int nch = 400;
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL1b",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL2b",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL3b",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL4b",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL5b",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL6b",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL7b",nch,0,nch,nch,0,nch);

aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL1t",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL2t",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL3t",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL4t",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL5t",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL6t",nch,0,nch,nch,0,nch);
aidaGBL.histogram2D(resFolder+"Axial_vs_Stereo_channel_moduleL7t",nch,0,nch,nch,0,nch);



for (SiSensor sensor : sensors) {

HpsSiSensor sens = (HpsSiSensor) sensor.getGeometry().getDetectorElement();
Expand All @@ -1018,6 +1051,8 @@ private void setupPlots() {
aidaGBL.histogram2D(resFolder+"uresidual_GBL_vs_v_pred_" + sensor.getName(),300,-60.0,60.0,100,-0.1,0.1);
aidaGBL.histogram2D(resFolder+"uresidual_GBL_vs_dT_hit_" + sensor.getName(),100,-10.0,10.0,100,-0.1,0.1);
aidaGBL.histogram2D(resFolder+"uresidual_GBL_vs_dTs_hit_" + sensor.getName(),100,-5.0,5.0,100,-0.1,0.1);


aidaGBL.histogram1D(epullFolder+"breserror_GBL_" + sensor.getName(), nbins, 0.0, 0.1);
aidaGBL.histogram1D(epullFolder+"ureserror_GBL_" + sensor.getName(), nbins, 0.0, 0.2);
aidaGBL.histogram1D(epullFolder+"bres_pull_GBL_" + sensor.getName(), nbins, -5, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,14 @@ public static Pair<Track, GBLKinkData> makeCorrectedTrack(FittedGblTrajectory fi
}

// Set state at IP
Pair<double[], SymmetricMatrix> correctedHelixParams = fittedGblTrajectory.getCorrectedPerigeeParameters(helicalTrackFit, FittedGblTrajectory.GBLPOINT.IP, bfield);

Pair<double[], SymmetricMatrix> correctedHelixParams = null;

// Bail on track if fails.
try {
correctedHelixParams = fittedGblTrajectory.getCorrectedPerigeeParameters(helicalTrackFit, FittedGblTrajectory.GBLPOINT.IP, bfield);
} catch (Exception e) {
}

if (correctedHelixParams == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public class SimpleGBLTrajAliDriver extends Driver {
private boolean constrainedFit = false;
private boolean constrainedBSFit = false;
private boolean constrainedD0Fit = false;
private double targetd0 = 0.2;
private boolean constrainedZ0Fit = false;
private boolean constrainedTanLFit = false;
private boolean constrainedPhi0Fit = false;
Expand All @@ -143,6 +144,8 @@ public class SimpleGBLTrajAliDriver extends Driver {
private double bsZ = -7.5;
private double bsX = 0.0;
private double bsY = 0.0;
private double sigmabsX = 0.05;
private double sigmabsY = 0.01;
private int trackSide = -1;
private boolean doCOMAlignment = false;
private double momC = 4.55;
Expand Down Expand Up @@ -214,6 +217,10 @@ public void setCompositeAlign (boolean val) {
public void setConstrainedFit (boolean val) {
constrainedFit = val;
}

public void setTargetd0 (double val) {
targetd0 = val;
}

public void setConstrainedPhi0Fit (boolean val) {
constrainedPhi0Fit = val;
Expand All @@ -235,6 +242,12 @@ public void setBsX(double val) {
public void setBsY(double val) {
bsY = val;
}
public void setSigmaBsX(double val) {
sigmabsX = val;
}
public void setSigmaBsY(double val) {
sigmabsY = val;
}

public void setSeedPrecision(double val) {
seed_precision = val;
Expand Down Expand Up @@ -472,6 +485,10 @@ protected void process(EventHeader event) {
if (useParticles && !event.hasCollection(ReconstructedParticle.class, inputCollectionName)) {
return;
}


// Cluster Collection
List<Cluster> clusters = event.get(Cluster.class, "EcalClustersCorr");

setupSensors(event);
List<Track> tracks = new ArrayList<Track>();
Expand Down Expand Up @@ -526,7 +543,8 @@ protected void process(EventHeader event) {

TrackClusterPairs = GetClustersFromParticles(particles);
}



//Loop over the tracks
for (Track track : tracks) {

Expand All @@ -551,6 +569,7 @@ protected void process(EventHeader event) {
//Get the track parameters
double[] trk_prms = track.getTrackParameters();
double tanLambda = trk_prms[BaseTrack.TANLAMBDA];
double phi = trk_prms[BaseTrack.PHI];

//Momentum cut: 3.8 - 5.2
Hep3Vector momentum = new BasicHep3Vector(track.getTrackStates().get(0).getMomentum());
Expand All @@ -569,6 +588,14 @@ protected void process(EventHeader event) {
if (Math.abs(tanLambda) < minTanL || Math.abs(tanLambda) > maxTanL) {
continue;
}


if (phi < minPhi) {
continue;
}

if (phi > maxPhi)
continue;

//Align with tracks with at least 6 hits
if ((tanLambda > 0 && track.getTrackerHits().size() < actualHitCut)
Expand All @@ -590,6 +617,19 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track))
continue;
}
//System.out.println("DEBUG::Tom::Pass with " + track.getTrackerHits().size() + " hits");

//Cluster cuts

//FEE Clusters cuts

if (clusterEnergyCutMin > 0 ) {
if (clusters.size() != 1 )
continue;

if (clusters.get(0).getEnergy() < clusterEnergyCutMin )
continue;
}

}


Expand Down Expand Up @@ -692,7 +732,6 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track))
double [] trk_prms = track.getTrackParameters();
//Bias the track
double d0 = trk_prms[BaseTrack.D0];
double targetd0 = 0.;
//double d0bias = targetd0 - d0;

double d0bias = 0.;
Expand Down Expand Up @@ -816,14 +855,6 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track))
continue;
}

if (writeMilleBinary) {
/*
System.out.println("DEBUG::Tom::Writing track with "
+ points_on_traj.size() + " hits to mille binary.");
*/
trajForMPII.milleOut(mille);
}

if (correctTrack) {

//Form the FittedGblTrajectory for the unconstrained fit
Expand All @@ -835,6 +866,23 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track))
Collection<TrackerHit> hth = track.getTrackerHits();
List<TrackerHit> allHthList = TrackUtils.sortHits(hth);
Pair<Track, GBLKinkData> newTrack = MakeGblTracks.makeCorrectedTrack(fitTraj, TrackUtils.getHTF(track), allHthList, 0, bfield);


// Track refit failed
if (newTrack == null)
continue;

//To make sure that the track fit converged
if (writeMilleBinary) {
/*
System.out.println("DEBUG::Tom::Writing track with "
+ points_on_traj.size() + " hits to mille binary.");
*/
trajForMPII.milleOut(mille);
}



Track gblTrk = newTrack.getFirst();

//System.out.println("DEBUG::Tom::Correct GBL track has "+gblTrk.getTrackerHits().size()+" hits");
Expand Down Expand Up @@ -1522,10 +1570,10 @@ GBLBeamSpotPoint FormBSPoint(HelicalTrackFit htf, double bsZ, double bsX, double
vdir[2] = 0.;


//Hard coded uncertainties
//Uncertainties
double[] bserror = new double[2];
bserror[0]=0.02;
bserror[1]=0.2;
bserror[0]=sigmabsY;
bserror[1]=sigmabsX;
return GblUtils.gblMakeBsPoint(htf, center, udir, vdir, bserror);
}

Expand Down

0 comments on commit 45b104f

Please sign in to comment.