15 using namespace findNode;
19 namespace SColdQcdCorrelatorAnalysis {
23 bool SCorrelatorJetTree::IsGoodParticle(HepMC::GenParticle* par,
const bool ignoreCharge) {
27 cout <<
"SCorrelatorJetTree::IsGoodParticle(HepMC::GenParticle*) Checking if MC particle is good..." << endl;
31 const bool isJetCharged = (m_jetType != 1);
32 const bool doChargeCheck = (isJetCharged && !ignoreCharge);
38 parID = par -> pdg_id();
40 isGoodCharge = (parChrg != 0.);
45 const double parEta = par ->
momentum().eta();
46 const double parPx = par ->
momentum().px();
47 const double parPy = par ->
momentum().py();
48 const double parPt = sqrt((parPx * parPx) + (parPy * parPy));
49 const bool isInPtRange = ((parPt > m_parPtRange[0]) && (parPt < m_parPtRange[1]));
50 const bool isInEtaRange = ((parEta > m_parEtaRange[0]) && (parEta < m_parEtaRange[1]));
51 const bool isGoodPar = (isGoodCharge && isInPtRange && isInEtaRange);
62 cout <<
"SCorrelatorJetTree::IsGoodTrack(SvtxTrack*) Checking if track is good..." << endl;
66 const double trkPt = track -> get_pt();
67 const double trkEta = track -> get_eta();
68 const double trkQual = track -> get_quality();
76 const double trkDcaXY = trkDca.first;
77 const double trkDcaZ = trkDca.second;
82 double ptEvalXY = (trkPt > m_dcaPtFitMaxXY) ? m_dcaPtFitMaxXY : trkPt;
83 double ptEvalZ = (trkPt > m_dcaPtFitMaxZ) ? m_dcaPtFitMaxZ : trkPt;
86 bool isInDcaRangeXY =
false;
87 bool isInDcaRangeZ =
false;
88 if (m_doDcaSigmaCut) {
89 isInDcaRangeXY = (abs(trkDcaXY) < (m_nSigCutXY * (m_fSigDcaXY -> Eval(ptEvalXY))));
90 isInDcaRangeZ = (abs(trkDcaZ) < (m_nSigCutZ * (m_fSigDcaZ -> Eval(ptEvalZ))));
92 isInDcaRangeXY = ((trkDcaXY > m_trkDcaRangeXY[0]) && (trkDcaXY < m_trkDcaRangeXY[1]));
93 isInDcaRangeZ = ((trkDcaZ > m_trkDcaRangeZ[0]) && (trkDcaZ < m_trkDcaRangeZ[1]));
98 bool isInVtxRange =
true;
101 isInVtxRange = IsGoodVertex(trkVtx);
106 if (m_useOnlyPrimVtx) {
108 if (!isFromPrimVtx) {
109 isInVtxRange =
false;
115 bool isGoodPhi =
true;
116 if (m_maskTpcSectors) {
117 isGoodPhi = IsGoodTrackPhi(track);
122 const bool isInPtRange = ((trkPt > m_trkPtRange[0]) && (trkPt < m_trkPtRange[1]));
123 const bool isInEtaRange = ((trkEta > m_trkEtaRange[0]) && (trkEta < m_trkEtaRange[1]));
124 const bool isInQualRange = ((trkQual > m_trkQualRange[0]) && (trkQual < m_trkQualRange[1]));
125 const bool isInNMvtxRange = ((trkNMvtx > m_trkNMvtxRange[0]) && (trkNMvtx <= m_trkNMvtxRange[1]));
126 const bool isInNInttRange = ((trkNIntt > m_trkNInttRange[0]) && (trkNIntt <= m_trkNInttRange[1]));
127 const bool isInNTpcRange = ((trkNTpc > m_trkNTpcRange[0]) && (trkNTpc <= m_trkNTpcRange[1]));
128 const bool isInDeltaPtRange = ((trkDeltaPt > m_trkDeltaPtRange[0]) && (trkDeltaPt < m_trkDeltaPtRange[1]));
129 const bool isInNumRange = (isInNMvtxRange && isInNInttRange && isInNTpcRange);
130 const bool isInDcaRange = (isInDcaRangeXY && isInDcaRangeZ);
131 const bool isGoodTrack = (isSeedGood && isGoodPhi && isInPtRange && isInEtaRange && isInQualRange && isInNumRange && isInDcaRange && isInDeltaPtRange && isInVtxRange);
142 cout <<
"SCorrelatorJetTree::IsGoodFlow(ParticleFlowElement*) Checking if particle flow element is good..." << endl;
146 const double pfEta = flow -> get_eta();
147 const bool isInEtaRange = ((pfEta > m_flowEtaRange[0]) && (pfEta < m_flowEtaRange[1]));
148 const bool isGoodFlow = isInEtaRange;
155 bool SCorrelatorJetTree::IsGoodECal(CLHEP::Hep3Vector& hepVecECal) {
159 cout <<
"SCorrelatorJetTree::IsGoodECal(CLHEP::Hep3Vector&) Checking if ECal cluster is good..." << endl;
162 const double clustPt = hepVecECal.perp();
163 const double clustEta = hepVecECal.pseudoRapidity();
164 const bool isInPtRange = ((clustPt > m_ecalPtRange[0]) && (clustPt < m_ecalPtRange[1]));
165 const bool isInEtaRange = ((clustEta > m_ecalEtaRange[0]) && (clustEta < m_ecalEtaRange[1]));
166 const bool isGoodClust = (isInPtRange && isInEtaRange);
173 bool SCorrelatorJetTree::IsGoodHCal(CLHEP::Hep3Vector& hepVecHCal) {
177 cout <<
"SCorrelatorJetTree::IsGoodHCal(CLHEP::Hep3Vector&) Checking if HCal cluster is good..." << endl;
181 const double clustPt = hepVecHCal.perp();
182 const double clustEta = hepVecHCal.pseudoRapidity();
183 const bool isInPtRange = ((clustPt > m_hcalPtRange[0]) && (clustPt < m_hcalPtRange[1]));
184 const bool isInEtaRange = ((clustEta > m_hcalEtaRange[0]) && (clustEta < m_hcalEtaRange[1]));
185 const bool isGoodClust = (isInPtRange && isInEtaRange);
196 cout <<
"SCorrelatorJetTree::IsGoodSeedTrack(SvtxTrack*) Checking if track seed is good..." << endl;
200 TrackSeed* trkSiSeed = track -> get_silicon_seed();
201 TrackSeed* trkTpcSeed = track -> get_tpc_seed();
204 bool isSeedGood = (trkSiSeed && trkTpcSeed);
205 if (!m_requireSiSeeds) {
206 isSeedGood = (trkSiSeed || trkTpcSeed);
214 bool SCorrelatorJetTree::IsGoodTrackPhi(
SvtxTrack* track,
const float phiMaskSize) {
218 cout <<
"SCorrelatorJetTree::IsGoodTrackPhi(SvtxTrack*) Checking if track phi is good..." << endl;
225 const array<float, NTpcSector> phiSectorBoundaries = {
241 const double halfMaskSize = phiMaskSize / 2.;
242 const double trkPhi = track -> get_phi();
245 bool isGoodPhi =
true;
246 for (
const float boundary : phiSectorBoundaries) {
247 if ((trkPhi > (boundary - halfMaskSize)) && (trkPhi < (boundary + halfMaskSize))) {
262 cout <<
"SCorrelatorJetTree::IsParton(HepMC::GenParticle*) Checking if particle is a parton..." << endl;
266 const int pid = par -> pdg_id();
270 const bool isStatusGood = ((status == 23) || (status == 24));
271 const bool isLightQuark = ((pid == 1) || (pid == 2));
272 const bool isStrangeQuark = ((pid == 3) || (pid == 4));
273 const bool isHeavyQuark = ((pid == 5) || (pid == 6));
274 const bool isGluon = (pid == 21);
275 const bool isParton = (isLightQuark || isStrangeQuark || isHeavyQuark || isGluon);
276 const bool isOutgoingParton = (isStatusGood && isParton);
277 return isOutgoingParton;
287 cout <<
"SCorrelatorJetTree::IsFromPrimaryVtx(SvtxTrack*, PHCompositeNode*) Checking if track is from primary vertex..." << endl;
291 const int vtxID = (int) track -> get_vertex_id();
295 const int primVtxID = primVtx -> get_id();
298 const bool isFromPrimVtx = (vtxID == primVtxID);
299 return isFromPrimVtx;
309 cout <<
"SCorrelatorJetTree::GetTrackDcaPair(SvtxTrack*, PHCompositeNode*) Getting track dca values..." << endl;
318 return make_pair(dcaAndErr.first.first, dcaAndErr.second.first);
328 cout <<
"SCorrelatorJetTree::GetTrackVertex(SvtxTrack*, PHCompositeNode*) Getting track vertex..." << endl;
332 const int vtxID = (int) track -> get_vertex_id();
336 CLHEP::Hep3Vector hepVecVtx = CLHEP::Hep3Vector(vtx -> get_x(), vtx -> get_y(), vtx -> get_z());
347 cout <<
"SCorrelatorJetTree::GetTrackDeltaPt(SvtxTrack*) Getting track delta pt..." << endl;
351 const float trkCovXX = track -> get_error(3, 3);
352 const float trkCovXY = track -> get_error(3, 4);
353 const float trkCovYY = track -> get_error(4, 4);
356 const float trkPx = track -> get_px();
357 const float trkPy = track -> get_py();
358 const float trkPt = track -> get_pt();
361 const float numer = (trkCovXX * trkPx * trkPx) + 2 * (trkCovXY * trkPx * trkPy) + (trkCovYY * trkPy * trkPy);
362 const float denom = (trkPx * trkPx) + (trkPy * trkPy);
363 const float ptDelta2 = numer / denom;
364 const float ptDelta = sqrt(ptDelta2) / trkPt;
375 cout <<
"SCorrelatorJetTree::GetParticleCharge(int) Grabbing MC particle charge..." << endl;
501 cerr <<
"SCorrelatorJetTree::GetParticleCharge(int) WARNING: trying to determine charge of unknown particle (PID = " << pid <<
")..." << endl;
520 cout <<
"SCorrelatorJetTree::GetNumLayer(SvtxTrack*, uint8_t) Grabbing number of track clusters..." << endl;
524 const bool isSubsysWrong = (subsys > 2);
525 if (isSubsysWrong && m_doDebug && (
Verbosity() > 3)) {
526 cerr <<
"SCorrelatorJetTree::GetNumLayer(SvtxTrack*, uint8_t) PANIC: trying to determine no. of clusters for an unknown subsystem (subsys = " << subsys <<
")! Aborting!" << endl;
532 if (!isSeedGood && m_doDebug && (
Verbosity() > 3)) {
533 cerr <<
"SCorrelatorJetTree::GetNumLayer(SvtxTrack*, uint8_t) PANIC: track seed(s) is (are) no good! Aborting!" << endl;
538 TrackSeed* trkSiSeed = track -> get_silicon_seed();
539 TrackSeed* trkTpcSeed = track -> get_tpc_seed();
542 const bool hasBothSeeds = (trkSiSeed && trkTpcSeed);
543 const bool hasOnlyTpcSeed = (!trkSiSeed && trkTpcSeed);
548 if (hasBothSeeds) seed = trkSiSeed;
549 if (hasOnlyTpcSeed) seed = trkTpcSeed;
552 if (hasBothSeeds) seed = trkSiSeed;
553 if (hasOnlyTpcSeed) seed = trkTpcSeed;
559 if (!seed && m_doDebug && (
Verbosity() > 3)) {
560 cerr <<
"SCorrelatorJetTree::GetNumLayer(SvtxTrack*, uint8_t) PANIC: couldn't set seed! Aborting!" << endl;
565 const int minInttLayer = CONST::NMvtxLayer;
566 const int minTpcLayer = CONST::NMvtxLayer + CONST::NInttLayer;
571 for (
int iMvtxLayer = 0; iMvtxLayer < CONST::NMvtxLayer; iMvtxLayer++) {
572 isMvtxLayerHit[iMvtxLayer] =
false;
576 for (
int iInttLayer = 0; iInttLayer < CONST::NInttLayer; iInttLayer++) {
577 isInttLayerHit[iInttLayer] =
false;
581 for (
int iTpcLayer = 0; iTpcLayer < CONST::NTpcLayer; iTpcLayer++) {
582 isTpcLayerHit[iTpcLayer] =
false;
588 unsigned int layer = 0;
589 unsigned int mvtxLayer = 0;
590 unsigned int inttLayer = 0;
591 unsigned int tpcLayer = 0;
592 for (
auto itClustKey = (seed -> begin_cluster_keys()); itClustKey != (seed -> end_cluster_keys()); ++itClustKey) {
600 if (layer < CONST::NMvtxLayer) {
602 isMvtxLayerHit[mvtxLayer] =
true;
606 if ((layer >= minInttLayer) && (layer < minTpcLayer)) {
607 inttLayer = layer - minInttLayer;
608 isInttLayerHit[inttLayer] =
true;
612 if (layer >= minTpcLayer) {
613 tpcLayer = layer - minTpcLayer;
614 isTpcLayerHit[tpcLayer] =
true;
624 for (
int iMvtxLayer = 0; iMvtxLayer < CONST::NMvtxLayer; iMvtxLayer++) {
625 if (isMvtxLayerHit[iMvtxLayer]) ++nLayer;
629 for (
int iInttLayer = 0; iInttLayer < CONST::NInttLayer; iInttLayer++) {
630 if (isInttLayerHit[iInttLayer]) ++nLayer;
634 for (
int iTpcLayer = 0; iTpcLayer < CONST::NTpcLayer; iTpcLayer++) {
635 if (isTpcLayerHit[iTpcLayer]) ++nLayer;
648 const bool isSubsysWrong = (subsys > 2);
649 if (isSubsysWrong && m_doDebug && (
Verbosity() > 3)) {
650 cerr <<
"SCorrelatorJetTree::GetNumLClust(SvtxTrack*, uint8_t) PANIC: trying to determine no. of clusters for an unknown subsystem (subsys = " << subsys <<
")! Aborting!" << endl;
656 if (!isSeedGood && m_doDebug && (
Verbosity() > 3)) {
657 cerr <<
"SCorrelatorJetTree::GetNumLayer(SvtxTrack*, uint8_t) PANIC: track seed(s) is (are) no good! Aborting!" << endl;
662 TrackSeed* trkSiSeed = track -> get_silicon_seed();
663 TrackSeed* trkTpcSeed = track -> get_tpc_seed();
666 const bool hasBothSeeds = (trkSiSeed && trkTpcSeed);
667 const bool hasOnlyTpcSeed = (!trkSiSeed && trkTpcSeed);
672 if (hasBothSeeds) seed = trkSiSeed;
673 if (hasOnlyTpcSeed) seed = trkTpcSeed;
676 if (hasBothSeeds) seed = trkSiSeed;
677 if (hasOnlyTpcSeed) seed = trkTpcSeed;
683 if (!seed && m_doDebug && (
Verbosity() > 3)) {
684 cerr <<
"SCorrelatorJetTree::GetNumClust(SvtxTrack*, uint8_t) PANIC: couldn't set seed! Aborting!" << endl;
689 const int minInttLayer = CONST::NMvtxLayer;
690 const int minTpcLayer = CONST::NMvtxLayer + CONST::NInttLayer;
693 unsigned int layer = 0;
694 unsigned int nCluster = 0;
695 for (
auto itClustKey = (seed -> begin_cluster_keys()); itClustKey != (seed -> end_cluster_keys()); ++itClustKey) {
703 if (layer < CONST::NMvtxLayer) {
708 if ((layer >= minInttLayer) && (layer < minTpcLayer)) {
713 if (layer >= minTpcLayer) {
729 cout <<
"SCorrelatorJetTree::GetMatchID(SvtxTrack*) Grabbing barcode of matching particle..." << endl;
733 PHG4Particle *bestMatch = m_trackEval -> max_truth_particle_by_nclusters(track);
738 matchID = bestMatch -> get_barcode();