From 6d2748132d625eac0dd42b052fd8fa18b814b0d5 Mon Sep 17 00:00:00 2001 From: Pierfrancesco Butti Date: Fri, 3 May 2024 07:28:52 -0700 Subject: [PATCH 1/4] Fix filling plot --- .../org/hps/recon/tracking/gbl/GBLOutputDriver.java | 2 +- .../recon/tracking/gbl/SimpleGBLTrajAliDriver.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java b/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java index 55a0ae329..40aff032a 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java @@ -396,7 +396,7 @@ private void doEoPPlots(Track track, Cluster cluster) { aidaGBL.histogram2D(eopFolder+"EoP_vs_phi_"+charge+"_"+vol).fill(phi,eop); aidaGBL.histogram2D(eopFolder+"EoP_vs_tanLambda").fill(tanL,eop); - aidaGBL.histogram2D(eopFolder+"EoP_vs_phi").fill(tanL,eop); + aidaGBL.histogram2D(eopFolder+"EoP_vs_phi").fill(phi,eop); aidaGBL.histogram3D(eopFolder+"EoP_vs_tanLambda_phi").fill(tanL, phi, eop); diff --git a/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java b/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java index 1e84d2330..eff8d11d5 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java @@ -130,6 +130,7 @@ public class SimpleGBLTrajAliDriver extends Driver { private List Alignabledes = new ArrayList(); private List sensors = new ArrayList(); private boolean debugAlignmentDs = false; + private boolean debug_ = false; private boolean compositeAlign = false; private boolean constrainedFit = false; private boolean constrainedBSFit = false; @@ -248,6 +249,9 @@ public void setDebugAlignmentDs (boolean val) { debugAlignmentDs = val; } + public void setDebug(boolean val) { + debug_ = val; + } public void setEnableAlignmentCuts (boolean val) { enableAlignmentCuts = val; @@ -500,10 +504,11 @@ protected void process(EventHeader event) { if (inputCollectionName.contains("Kalman") || inputCollectionName.contains("KF")) { TrackType = 1; - //System.out.println("PF:: DEBUG :: Found Kalman Tracks in the event"); - } + } - //System.out.println("DEBUG::Tom::Deduced a track type of "+TrackType); + if (debug_) { + System.out.println("DEBUG::Tom::Deduced a track type of "+TrackType); + } //If using Seed Tracker, get the hits from the event if (TrackType == 0) { From 0c9b707a1c2f7191b1f6c1023c5ee81a604e1003 Mon Sep 17 00:00:00 2001 From: Pierfrancesco Butti Date: Mon, 6 May 2024 01:15:01 -0700 Subject: [PATCH 2/4] Fix filling EoPvsPhi plot --- .../java/org/hps/recon/tracking/gbl/GBLOutputDriver.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java b/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java index 40aff032a..7f2700e8c 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java @@ -295,9 +295,10 @@ public void process(EventHeader event) { if (Math.abs(trackState.getPhi()) > maxPhi) continue; - - //System.out.println("Track passed tanLambda"); - + + //System.out.println("Track passed tanLambda"); + + GenericObject gblKink = GBLKinkData.getKinkData(event, trk); //if (gblKink == null) { @@ -416,7 +417,7 @@ private void doEoPPlots(Track track, Cluster cluster) { aidaGBL.histogram2D(eopFolder+"EoP_vs_phi_"+charge+"_"+vol+"_fid").fill(phi,eop); aidaGBL.histogram2D(eopFolder+"EoP_vs_tanLambda_fid").fill(tanL,eop); - aidaGBL.histogram2D(eopFolder+"EoP_vs_phi_fid").fill(tanL,eop); + aidaGBL.histogram2D(eopFolder+"EoP_vs_phi_fid").fill(phi,eop); aidaGBL.histogram3D(eopFolder+"EoP_vs_tanLambda_phi_fid").fill(tanL, phi, eop); From ddbf7cb54f3a250e57436839f2664c57589a398f Mon Sep 17 00:00:00 2001 From: Pierfrancesco Butti Date: Thu, 9 May 2024 12:39:26 -0700 Subject: [PATCH 3/4] Fixes to GBL fitter and monitoring --- .../recon/tracking/gbl/GBLOutputDriver.java | 116 +++++++++++++++--- .../tracking/gbl/SimpleGBLTrajAliDriver.java | 12 +- 2 files changed, 107 insertions(+), 21 deletions(-) diff --git a/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java b/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java index 3fb09e6c6..6c71b1c64 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java @@ -58,6 +58,7 @@ public class GBLOutputDriver extends Driver { private String trackCollectionName = "GBLTracks"; private String inputCollectionName = "FinalStateParticles_KF"; private String trackResidualsRelColName = "TrackResidualsGBLRelations"; + private String trackRelationsColName = "GBLToKFRelations"; private String dataRelationCollection = GBLKinkData.DATA_RELATION_COLLECTION; private List sensors = new ArrayList(); private double bfield; @@ -97,7 +98,11 @@ public class GBLOutputDriver extends Driver { private boolean useParticles = true; - + + + public void setDebug(boolean val) { + debug = val; + } public void setUseParticles(boolean val) { useParticles = val; @@ -218,6 +223,27 @@ public void process(EventHeader event) { // Create a mapping of matched Tracks to corresponding Clusters. HashMap TrackClusterPairs = new HashMap(); + + int TrackType = 0; + if (!useParticles) { + if (debug) + System.out.println("PF:: DEBUG :: NOT Using particles" + trackCollectionName); + if (trackCollectionName.contains("Kalman") || trackCollectionName.contains("KF")) { + TrackType = 1; + } + } + else { + if (debug) + System.out.println("PF:: DEBUG :: Using particles" + inputCollectionName); + if (inputCollectionName.contains("Kalman") || inputCollectionName.contains("KF")) { + + TrackType = 1 ; + } + + } + if (debug) + System.out.println("PF:: DEBUG :: Track Type=" + TrackType); + if (!useParticles) tracks = event.get(Track.class,trackCollectionName); @@ -228,9 +254,37 @@ public void process(EventHeader event) { continue; Track track = particle.getTracks().get(0); Cluster cluster = particle.getClusters().get(0); - tracks.add(track); - TrackClusterPairs.put(track,cluster); - } + + // If track is a Kalman Track, get the GBL refitted track from the relations + if (TrackType==1) { + RelationalTable trackRelationsTable = null; + if (event.hasCollection(LCRelation.class, trackRelationsColName)) { + trackRelationsTable = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED); + List trackRelation = event.get(LCRelation.class, trackRelationsColName); + for (LCRelation relation : trackRelation) { + if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + trackRelationsTable.add(relation.getFrom(), relation.getTo()); + } + } + } // has the table + + Track gblTrack = (Track) trackRelationsTable.from(track); + + if (gblTrack == null) { + if (debug) + System.out.println("ERROR RETRIEVING GBLTRACK!"); + return; + } + tracks.add(gblTrack); + TrackClusterPairs.put(gblTrack,cluster); + }// it's a kalman track + else { + if (debug) + System.out.println("Particle not made with a kalman track. Adding track directly"); + tracks.add(track); + TrackClusterPairs.put(track,cluster); + } + } } @@ -241,15 +295,8 @@ public void process(EventHeader event) { } System.out.println(); */ - - int TrackType = 0; - 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); + + //System.out.println("Running on "+trackCollectionName); //RelationalTable trackMatchTable = null; //trackMatchTable = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED); @@ -435,6 +482,25 @@ private void doEoPPlots(Track track, Cluster cluster) { phi, eop); + + + // Cluster positions + + double clusterX = cluster.getPosition()[0]; + double clusterY = cluster.getPosition()[1]; + + aidaGBL.histogram1D(eopFolder+"Xcluster_"+vol+"_fid").fill(clusterX); + aidaGBL.histogram1D(eopFolder+"Ycluster_"+vol+"_fid").fill(clusterY); + + + + // + + // As function of incident angle at ECAL, inclusive and in bin of momentum. + + + + } @@ -581,7 +647,9 @@ private void doBasicGBLtrack(Track trk, Map sensorHits) // FillGBLTrackPlot(trkpFolder+"p_MissingLastLayer",isTop,charge,trackp); - FillGBLTrackPlot(trkpFolder+"Chi2",isTop,charge,trk.getChi2()); + + FillGBLTrackPlot(trkpFolder+"Chi2",isTop,charge,trk.getChi2()); + FillGBLTrackPlot(trkpFolder+"Chi2oNDF",isTop,charge,trk.getChi2() / trk.getNDF()); FillGBLTrackPlot(trkpFolder+"Chi2_vs_p",isTop,charge,trackp,trk.getChi2()); // deduce multiplication factor for ST-started GBL tracks @@ -596,7 +664,7 @@ private void doBasicGBLtrack(Track trk, Map sensorHits) Hep3Vector beamspot = CoordinateTransformations.transformVectorToDetector(TrackUtils.extrapolateHelixToXPlane(trackState, 0)); if (debug) - System.out.printf("beamspot %s transformed %s \n", beamspot.toString()); + System.out.printf("beamspot %s transformed \n", beamspot.toString()); FillGBLTrackPlot(trkpFolder+"trk_extr_or_x",isTop,charge,beamspot.x()); FillGBLTrackPlot(trkpFolder+"trk_extr_or_y",isTop,charge,beamspot.y()); @@ -771,15 +839,20 @@ private void doGBLresiduals(Track trk, Map sensorHits, trackResidualsTable.add(relation.getFrom(), relation.getTo()); } } + if (debug) + System.out.println("Loaded track Residuals Table"); } else { - //System.out.println("null TrackResidualsGBL Data Relations."); + if (debug) { + System.out.println("null TrackResidualsGBL Data Relations."); + } //Failed finding TrackResidualsGBL return; } GenericObject trackRes = (GenericObject) trackResidualsTable.from(trk); if (trackRes == null) { - //System.out.println("null TrackResidualsGBL Data."); + if (debug) + System.out.println("null TrackResidualsGBL Data."); return; } @@ -945,6 +1018,9 @@ private void setupEoPPlots() { aidaGBL.histogram1D(eopFolder+"Ecluster"+vol,200,0,6); aidaGBL.histogram1D(eopFolder+"EoP"+vol,200,0,2); + + aidaGBL.histogram1D(eopFolder+"Xcluster_"+vol+"_fid",200,-100,100); + aidaGBL.histogram1D(eopFolder+"Ycluster_"+vol+"_fid",200,-100,100); double lmin = 0.; double lmax = 0.08; @@ -967,6 +1043,11 @@ private void setupEoPPlots() { aidaGBL.histogram2D(eopFolder+"EoP_vs_trackP"+charge+vol+"_fid",200,0,6,200,0,2); aidaGBL.histogram2D(eopFolder+"EoP_vs_tanLambda"+charge+vol+"_fid",200,0.01,0.08,200,0,2); aidaGBL.histogram2D(eopFolder+"EoP_vs_phi"+charge+vol+"_fid",200,-0.2,0.2,200,0,2); + + + + + } } @@ -1121,6 +1202,7 @@ private void setupPlots() { aidaGBL.histogram1D(trkpFolder+"p_slot"+vol+charge,nbins_p,0.,pmax); aidaGBL.histogram1D(trkpFolder+"Chi2"+vol+charge,nbins_t*2,0,200); + aidaGBL.histogram1D(trkpFolder+"Chi2oNDF"+vol+charge,nbins_t*2,0,200); aidaGBL.histogram1D(trkpFolder+"nHits"+vol+charge,15,0,15); aidaGBL.histogram1D(trkpFolder+"trk_extr_or_x"+vol+charge,nbins_t,-3,3); aidaGBL.histogram1D(trkpFolder+"trk_extr_or_y"+vol+charge,nbins_t,-3,3); diff --git a/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java b/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java index 2b2695e1e..bf1a780bb 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java @@ -626,7 +626,7 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track)) //Cluster cuts //FEE Clusters cuts - + /* if (clusterEnergyCutMin > 0 ) { if (clusters.size() != 1 ) continue; @@ -634,7 +634,7 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track)) if (clusters.get(0).getEnergy() < clusterEnergyCutMin ) continue; } - + */ } @@ -970,7 +970,10 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track)) //System.out.println("Refitted track chi2 " + gblTrk.getChi2()); + //Store the track and the relation refittedTracks.add(gblTrk); + trackRelations.add(new BaseLCRelation(gblTrk,track)); + kinkDataCollection.add(newTrack.getSecond()); kinkDataRelations.add(new BaseLCRelation(newTrack.getSecond(), gblTrk)); } @@ -997,15 +1000,16 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track)) // Put the tracks back into the event and exit int flag = 1 << LCIOConstants.TRBIT_HITS; event.put(outputCollectionName, refittedTracks, Track.class, flag); - + event.put(trackRelationCollectionName, trackRelations, LCRelation.class,0); if (computeGBLResiduals) { event.put(trackResidualsColName, trackResidualsCollection, TrackResidualsData.class, 0); event.put(trackResidualsRelColName, trackResidualsRelations, LCRelation.class, 0); - } + event.put(GBLKinkData.DATA_COLLECTION, kinkDataCollection, GBLKinkData.class, 0); event.put(GBLKinkData.DATA_RELATION_COLLECTION, kinkDataRelations, LCRelation.class, 0); + } } } From 2d6d0b968d16ed37d6a1c12ee9211d34a9d6793e Mon Sep 17 00:00:00 2001 From: Pierfrancesco Butti Date: Wed, 15 May 2024 02:14:05 -0700 Subject: [PATCH 4/4] Added ECAL Cluster residuals to alignment monitoring --- .../recon/tracking/gbl/GBLOutputDriver.java | 90 +++++++++++++++++-- .../tracking/gbl/SimpleGBLTrajAliDriver.java | 70 +++++++++------ 2 files changed, 124 insertions(+), 36 deletions(-) diff --git a/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java b/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java index 6c71b1c64..60e72ff85 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java @@ -482,17 +482,57 @@ private void doEoPPlots(Track track, Cluster cluster) { phi, eop); - + // Cluster positions double clusterX = cluster.getPosition()[0]; double clusterY = cluster.getPosition()[1]; + TrackState ts_ecal = TrackUtils.getTrackStateAtECal(track); + + if(ts_ecal == null){ + return; + } + + double[] ts_ecalPos = ts_ecal.getReferencePoint(); + double trkX = ts_ecalPos[1]; + double trkY = ts_ecalPos[2]; aidaGBL.histogram1D(eopFolder+"Xcluster_"+vol+"_fid").fill(clusterX); aidaGBL.histogram1D(eopFolder+"Ycluster_"+vol+"_fid").fill(clusterY); + + aidaGBL.histogram1D(eopFolder+"trk_clu_resX_"+vol+"_fid").fill(trkX-clusterX); + aidaGBL.histogram1D(eopFolder+"trk_clu_resY_"+vol+"_fid").fill(trkY-clusterY); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vsX_"+vol+"_fid").fill(trkX,trkX-clusterX); + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vsY_"+vol+"_fid").fill(trkY,trkX-clusterX); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vsX_"+vol+"_fid").fill(trkX,trkY-clusterY); + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vsY_"+vol+"_fid").fill(trkY,trkY-clusterY); + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vstrkP_"+vol+"_fid").fill(trackp,trkY-clusterY); + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vstrkP_"+vol+"_fid").fill(trackp,trkX-clusterX); + aidaGBL.histogram2D(eopFolder+"trkY_vs_tanL_"+vol+"_fid").fill(tanL,trkY); + + + aidaGBL.histogram1D(eopFolder+"Xcluster_"+charge+"_"+vol+"_fid").fill(clusterX); + aidaGBL.histogram1D(eopFolder+"Ycluster_"+charge+"_"+vol+"_fid").fill(clusterY); + + aidaGBL.histogram1D(eopFolder+"trk_clu_resX_"+charge+"_"+vol+"_fid").fill(trkX-clusterX); + aidaGBL.histogram1D(eopFolder+"trk_clu_resY_"+charge+"_"+vol+"_fid").fill(trkY-clusterY); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vsX_"+charge+"_"+vol+"_fid").fill(trkX,trkX-clusterX); + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vsY_"+charge+"_"+vol+"_fid").fill(trkY,trkX-clusterX); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vsX_"+charge+"_"+vol+"_fid").fill(trkX,trkY-clusterY); + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vsY_"+charge+"_"+vol+"_fid").fill(trkY,trkY-clusterY); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vstrkP_"+charge+"_"+vol+"_fid").fill(trackp,trkY-clusterY); + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vstrkP_"+charge+"_"+vol+"_fid").fill(trackp,trkX-clusterX); + + aidaGBL.histogram2D(eopFolder+"trkY_vs_tanL_"+charge+"_"+vol+"_fid").fill(tanL,trkY); + // @@ -1019,10 +1059,7 @@ private void setupEoPPlots() { aidaGBL.histogram1D(eopFolder+"Ecluster"+vol,200,0,6); aidaGBL.histogram1D(eopFolder+"EoP"+vol,200,0,2); - aidaGBL.histogram1D(eopFolder+"Xcluster_"+vol+"_fid",200,-100,100); - aidaGBL.histogram1D(eopFolder+"Ycluster_"+vol+"_fid",200,-100,100); - - double lmin = 0.; + double lmin = 0.; double lmax = 0.08; if (vol == "_bot") { lmin = -0.08; @@ -1038,15 +1075,54 @@ private void setupEoPPlots() { aidaGBL.histogram1D(eopFolder+"Ecluster"+vol+"_fid",200,0,5); aidaGBL.histogram1D(eopFolder+"EoP"+vol+"_fid",200,0,2); aidaGBL.histogram2D(eopFolder+"EoP_vs_trackP"+vol+"_fid",200,0,6,200,0,2); + + + double cxrange = 20; + double cyrange = 20; + double ecalX = 400; + + aidaGBL.histogram1D(eopFolder+"Xcluster"+vol+"_fid",200,-ecalX,ecalX); + aidaGBL.histogram1D(eopFolder+"Ycluster"+vol+"_fid",200,-ecalX,ecalX); + aidaGBL.histogram1D(eopFolder+"trk_clu_resX"+vol+"_fid",200,-cxrange,cxrange); + aidaGBL.histogram1D(eopFolder+"trk_clu_resY"+vol+"_fid",200,-cyrange,cyrange); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vsX"+vol+"_fid",200,-ecalX,ecalX,200,-cxrange,cxrange); + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vsY"+vol+"_fid",200,-ecalX,ecalX,200,-cxrange,cxrange); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vsX"+vol+"_fid",200,-ecalX,ecalX,200,-cyrange,cyrange); + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vsY"+vol+"_fid",200,-ecalX,ecalX,200,-cyrange,cyrange); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vstrkP"+vol+"_fid",100,0.,5,200,-cyrange,cyrange); + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vstrkP"+vol+"_fid",100,0.,5,200,-cyrange,cyrange); + + aidaGBL.histogram2D(eopFolder+"trkY_vs_tanL"+vol+"_fid",200,-0.2,0.2,200,-100,100); + for (String charge : charges) { aidaGBL.histogram2D(eopFolder+"EoP_vs_trackP"+charge+vol+"_fid",200,0,6,200,0,2); aidaGBL.histogram2D(eopFolder+"EoP_vs_tanLambda"+charge+vol+"_fid",200,0.01,0.08,200,0,2); aidaGBL.histogram2D(eopFolder+"EoP_vs_phi"+charge+vol+"_fid",200,-0.2,0.2,200,0,2); + + + aidaGBL.histogram1D(eopFolder+"Xcluster"+charge+vol+"_fid",200,-ecalX,ecalX); + aidaGBL.histogram1D(eopFolder+"Ycluster"+charge+vol+"_fid",200,-ecalX,ecalX); + aidaGBL.histogram1D(eopFolder+"trk_clu_resX"+charge+vol+"_fid",200,-cxrange,cxrange); + aidaGBL.histogram1D(eopFolder+"trk_clu_resY"+charge+vol+"_fid",200,-cyrange,cyrange); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vsX"+charge+vol+"_fid",200,-ecalX,ecalX,200,-cxrange,cxrange); + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vsY"+charge+vol+"_fid",200,-ecalX,ecalX,200,-cxrange,cxrange); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vsX"+charge+vol+"_fid",200,-ecalX,ecalX,200,-cyrange,cyrange); + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vsY"+charge+vol+"_fid",200,-ecalX,ecalX,200,-cyrange,cyrange); + + aidaGBL.histogram2D(eopFolder+"trk_clu_resY_vstrkP"+charge+vol+"_fid",100,0.,5,200,-cyrange,cyrange); + aidaGBL.histogram2D(eopFolder+"trk_clu_resX_vstrkP"+charge+vol+"_fid",100,0.,5,200,-cyrange,cyrange); + + aidaGBL.histogram2D(eopFolder+"trkY_vs_tanL"+charge+vol+"_fid",200,-0.2,0.2,200,-100,100); + - } } @@ -1202,7 +1278,7 @@ private void setupPlots() { aidaGBL.histogram1D(trkpFolder+"p_slot"+vol+charge,nbins_p,0.,pmax); aidaGBL.histogram1D(trkpFolder+"Chi2"+vol+charge,nbins_t*2,0,200); - aidaGBL.histogram1D(trkpFolder+"Chi2oNDF"+vol+charge,nbins_t*2,0,200); + aidaGBL.histogram1D(trkpFolder+"Chi2oNDF"+vol+charge,nbins_t*2,0,50); aidaGBL.histogram1D(trkpFolder+"nHits"+vol+charge,15,0,15); aidaGBL.histogram1D(trkpFolder+"trk_extr_or_x"+vol+charge,nbins_t,-3,3); aidaGBL.histogram1D(trkpFolder+"trk_extr_or_y"+vol+charge,nbins_t,-3,3); diff --git a/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java b/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java index bf1a780bb..05f014e85 100644 --- a/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java +++ b/tracking/src/main/java/org/hps/recon/tracking/gbl/SimpleGBLTrajAliDriver.java @@ -51,6 +51,7 @@ import org.lcsim.event.RelationalTable; import org.lcsim.event.Track; import org.lcsim.event.base.BaseTrack; +import org.lcsim.event.base.BaseTrackState; //Fiducial cuts on the calorimeter cluster import org.hps.record.triggerbank.TriggerModule; @@ -100,8 +101,7 @@ public class SimpleGBLTrajAliDriver extends Driver { private AIDA aidaGBL; String derFolder = "/gbl_derivatives/"; - String eopFolder = "/EoP/"; - + private String inputCollectionName = "MatchedTracks"; private String outputCollectionName = "GBLTracks"; private String trackRelationCollectionName = "MatchedToGBLTrackRelations"; @@ -444,19 +444,21 @@ protected void detectorChanged(Detector detector) { //Alignment Manager - Get the composite structures. IDetectorElement detectorElement = detector.getDetectorElement(); Alignabledes = detectorElement.findDescendants(AlignableDetectorElement.class); - - for (AlignableDetectorElement ade : Alignabledes) { - if (ade.getName().contains("alignable")) { - System.out.printf("Alignable Detector Elements informations: %s \n", ade.getName()); - //System.out.printf(((AlignableDetectorElement)ade).getlocalToGlobal().toString()+"\n"); - if (ade.getParent() != null) { - System.out.printf("The parent is: %s\n", ade.getParent().getName()); - } - else { - System.out.printf("No parent. \n"); - } - } - } + + if (debug_) { + for (AlignableDetectorElement ade : Alignabledes) { + if (ade.getName().contains("alignable")) { + System.out.printf("Alignable Detector Elements informations: %s \n", ade.getName()); + //System.out.printf(((AlignableDetectorElement)ade).getlocalToGlobal().toString()+"\n"); + if (ade.getParent() != null) { + System.out.printf("The parent is: %s\n", ade.getParent().getName()); + } + else { + System.out.printf("No parent. \n"); + } + } + } + } // Get the sensors subcomponents // This should be only HpsSiSensors sensors = detectorElement.findDescendants(SiSensor.class); @@ -464,7 +466,8 @@ protected void detectorChanged(Detector detector) { if (!doCOMAlignment) { //Assign the mothers to the sensors - //TODO FIX this part. For the moment the mother of the sensors are chosen by string parsing. + //TODO FIX this part. For the moment the mother of the sensors are chosen by string parsing. + MakeAlignmentTree("alignable_fullmodule"); //Dump the constrain file @@ -478,6 +481,7 @@ protected void detectorChanged(Detector detector) { @Override protected void process(EventHeader event) { + int runNumber = event.getRunNumber(); //Track collection @@ -871,11 +875,18 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track)) Collection hth = track.getTrackerHits(); List allHthList = TrackUtils.sortHits(hth); Pair newTrack = MakeGblTracks.makeCorrectedTrack(fitTraj, TrackUtils.getHTF(track), allHthList, 0, bfield); - - // Track refit failed + // Track refit failed if (newTrack == null) continue; + + + // Extrapolate to the ECAL and make a new trackState there. + + Track gblTrk = newTrack.getFirst(); + BaseTrackState ts_ecal = new BaseTrackState(); + ts_ecal = TrackUtils.getTrackExtrapAtEcalRK(gblTrk, bFieldMap, runNumber); + gblTrk.getTrackStates().add(ts_ecal); //To make sure that the track fit converged if (writeMilleBinary) { @@ -888,7 +899,7 @@ else if (trackSide == 1 && !TrackUtils.isHoleTrack(track)) - Track gblTrk = newTrack.getFirst(); + //System.out.println("DEBUG::Tom::Correct GBL track has "+gblTrk.getTrackerHits().size()+" hits"); @@ -1327,16 +1338,17 @@ private void MakeAlignmentTree(String regEx) { }//loop on sensors - - for (SiSensor sensor : sensors) { - if (((HpsSiSensor)sensor).getAdeMother() != null) - System.out.printf("DEBUG::PF::MakeAlignmentTree sensor %s has mother %s \n", sensor.getName(), ((HpsSiSensor)sensor).getAdeMother().getName()); - } - - for (AlignableDetectorElement ade : Alignabledes) { - System.out.printf("DEBUG::PF::MakeAlignmentTree ade %s has children \n %s \n", ade.getName(), ade.getChildren().toString()); - - } + if (debug_) { + for (SiSensor sensor : sensors) { + if (((HpsSiSensor)sensor).getAdeMother() != null) + System.out.printf("DEBUG::PF::MakeAlignmentTree sensor %s has mother %s \n", sensor.getName(), ((HpsSiSensor)sensor).getAdeMother().getName()); + } + + for (AlignableDetectorElement ade : Alignabledes) { + System.out.printf("DEBUG::PF::MakeAlignmentTree ade %s has children \n %s \n", ade.getName(), ade.getChildren().toString()); + + } + } } //Matching by name