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