Skip to content

Commit cb4ffb5

Browse files
Merge branch 'master' into iss221
2 parents f96e407 + 9d6344c commit cb4ffb5

9 files changed

Lines changed: 708 additions & 393 deletions

File tree

recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.List;
1313
import java.util.Set;
1414

15+
import org.hps.conditions.beam.BeamEnergy.BeamEnergyCollection;
1516
import org.hps.recon.ecal.cluster.ClusterUtilities;
1617
import org.hps.recon.tracking.CoordinateTransformations;
1718
import org.hps.recon.tracking.TrackUtils;
@@ -48,12 +49,18 @@ public abstract class ReconParticleDriver extends Driver {
4849
public static final int MOLLER_BOT = 1;
4950

5051
// normalized cluster-track distance required for qualifying as a match:
51-
private double MAXNSIGMAPOSITIONMATCH = 30.0;
52+
private double MAXNSIGMAPOSITIONMATCH=15.0;
5253

5354
HPSEcal3 ecal;
5455

5556
protected boolean isMC = false;
5657
private boolean disablePID = false;
58+
59+
public void setUseCorrectedClusterPositionsForMatching(boolean val){
60+
useCorrectedClusterPositionsForMatching = val;
61+
}
62+
63+
boolean useCorrectedClusterPositionsForMatching = false;
5764

5865
// ==============================================================
5966
// ==== Class Variables =========================================
@@ -355,6 +362,10 @@ protected void detectorChanged(Detector detector) {
355362

356363
ecal = (HPSEcal3) detector.getSubdetector("Ecal");
357364
matcher.setBFieldMap(detector.getFieldMap());
365+
BeamEnergyCollection beamEnergyCollection =
366+
this.getConditionsManager().getCachedConditions(BeamEnergyCollection.class, "beam_energies").getCachedData();
367+
368+
matcher.setBeamEnergy(beamEnergyCollection.get(0).getBeamEnergy());
358369

359370
}
360371

@@ -433,7 +444,17 @@ protected List<ReconstructedParticle> makeReconstructedParticles(List<Cluster> c
433444
// try to find a matching cluster:
434445
Cluster matchedCluster = null;
435446
for (Cluster cluster : clusters) {
436-
447+
448+
//if the option to use corrected cluster positions is selected, then
449+
//create a copy of the current cluster, and apply corrections to it
450+
//before calculating nsigma. Default is don't use corrections.
451+
Cluster originalCluster = cluster;
452+
if(useCorrectedClusterPositionsForMatching){
453+
cluster = new BaseCluster(cluster);
454+
double ypos = TrackUtils.getTrackStateAtECal(particle.getTracks().get(0)).getReferencePoint()[2];
455+
ClusterUtilities.applyCorrections(ecal, cluster, ypos,isMC);
456+
}
457+
437458
// normalized distance between this cluster and track:
438459
final double thisNSigma = matcher.getNSigmaPosition(cluster, particle);
439460

@@ -447,7 +468,7 @@ protected List<ReconstructedParticle> makeReconstructedParticles(List<Cluster> c
447468

448469
// we found a new best cluster candidate for this track:
449470
smallestNSigma = thisNSigma;
450-
matchedCluster = cluster;
471+
matchedCluster = originalCluster;
451472

452473
// prefer using GBL tracks to correct (later) the clusters, for some consistency:
453474
if (track.getType() >= 32 || !clusterToTrack.containsKey(matchedCluster)) {
@@ -535,6 +556,14 @@ protected List<ReconstructedParticle> makeReconstructedParticles(List<Cluster> c
535556
}
536557
HepLorentzVector fourVector = new BasicHepLorentzVector(clusterEnergy, momentum);
537558
((BaseReconstructedParticle) particle).set4Vector(fourVector);
559+
560+
// recalculate track-cluster matching n_sigma using corrected cluster positions
561+
// if that option is selected
562+
if(!particle.getClusters().isEmpty() && useCorrectedClusterPositionsForMatching){
563+
double goodnessPID_corrected = matcher.getNSigmaPosition(particle.getClusters().get(0), particle);
564+
((BaseReconstructedParticle) particle).setGoodnessOfPid(goodnessPID_corrected);
565+
}
566+
538567
}
539568

540569
// Return the list of reconstructed particles.
@@ -711,4 +740,9 @@ protected void startOfData() {
711740
protected void endOfData() {
712741
// matcher.saveHistograms();
713742
}
743+
744+
745+
public void setSnapToEdge(boolean val){
746+
this.matcher.setSnapToEdge(val);
747+
}
714748
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.hps.recon.utils;
2+
3+
import java.util.List;
4+
5+
import org.lcsim.event.CalorimeterHit;
6+
import org.lcsim.event.Cluster;
7+
8+
import hep.physics.vec.BasicHep3Vector;
9+
import hep.physics.vec.Hep3Vector;
10+
11+
public class SnapToEdge {
12+
13+
public Hep3Vector snapToEdge(Hep3Vector tPos, Cluster c) {
14+
List<CalorimeterHit> hits = c.getCalorimeterHits();
15+
boolean upperEdgeCrystalsOnly = true;
16+
boolean lowerEdgeCrystalsOnly = true;
17+
for(CalorimeterHit hit : hits){
18+
int ix = hit.getIdentifierFieldValue("ix");
19+
int iy = hit.getIdentifierFieldValue("iy");
20+
21+
if(!(iy == -1 || (iy == -2 && ix >= -10 && ix <= -2) || iy == 5)){
22+
upperEdgeCrystalsOnly = false;
23+
}
24+
25+
if(!(iy == 1 || (iy == 2 && ix >= -10 && ix <= -2) || iy == -5)){
26+
lowerEdgeCrystalsOnly = false;
27+
}
28+
29+
30+
if(!upperEdgeCrystalsOnly && !lowerEdgeCrystalsOnly)
31+
break;
32+
}
33+
if(upperEdgeCrystalsOnly && tPos.y() >= c.getPosition()[1])
34+
return new BasicHep3Vector(tPos.x(), c.getPosition()[1], tPos.z());
35+
if(lowerEdgeCrystalsOnly && tPos.y() <= c.getPosition()[1])
36+
return new BasicHep3Vector(tPos.x(), c.getPosition()[1], tPos.z());
37+
else
38+
return tPos;
39+
}
40+
}

0 commit comments

Comments
 (0)