8#include <hlt/softwaretrigger/calculations/FilterCalculator.h>
9#include <hlt/softwaretrigger/calculations/utilities.h>
11#include <Math/Vector3D.h>
12#include <Math/Vector4D.h>
13#include <Math/VectorUtil.h>
15#include <mdst/dataobjects/TrackFitResult.h>
16#include <mdst/dataobjects/HitPatternCDC.h>
18#include <analysis/dataobjects/Particle.h>
19#include <analysis/VertexFitting/KFit/VertexFitKFit.h>
21#include <framework/logging/Logger.h>
28using namespace SoftwareTrigger;
45 ROOT::Math::PxPyPzEVector
p4CMS;
47 ROOT::Math::PxPyPzEVector
p4Lab;
59 ROOT::Math::PxPyPzEVector
p4CMS;
61 ROOT::Math::PxPyPzEVector
p4Lab;
69const double flatBoundaries[10] = {0., 19., 22., 25., 30., 35., 45., 60., 90., 180.};
87 calculationResult[
"nTrkLoose"] = 0;
88 calculationResult[
"nTrkTight"] = 0;
89 calculationResult[
"ee2leg"] = 0;
90 calculationResult[
"nEmedium"] = 0;
91 calculationResult[
"nElow"] = 0;
92 calculationResult[
"nEhigh"] = 0;
93 calculationResult[
"nE180Lab"] = 0;
94 calculationResult[
"nE300Lab"] = 0;
95 calculationResult[
"nE500Lab"] = 0;
96 calculationResult[
"nE2000CMS"] = 0;
97 calculationResult[
"nE4000CMS"] = 0;
98 calculationResult[
"nE250Lab"] = 0;
99 calculationResult[
"nMaxEPhotonAcc"] = 0;
100 calculationResult[
"dphiCmsClust"] = NAN;
102 calculationResult[
"netChargeLoose"] = 0;
103 calculationResult[
"maximumPCMS"] = NAN;
104 calculationResult[
"maximumPLab"] = NAN;
105 calculationResult[
"eexx"] = 0;
106 calculationResult[
"ee1leg1trk"] = 0;
107 calculationResult[
"nEhighLowAng"] = 0;
108 calculationResult[
"nEsingleClust"] = 0;
109 calculationResult[
"nEsinglePhotonBarrel"] = 0;
110 calculationResult[
"nEsinglePhotonExtendedBarrel"] = 0;
111 calculationResult[
"nEsinglePhotonEndcap"] = 0;
112 calculationResult[
"nEsingleElectronBarrel"] = 0;
113 calculationResult[
"nEsingleElectronExtendedBarrel"] = 0;
114 calculationResult[
"nReducedEsinglePhotonReducedBarrel"] = 0;
115 calculationResult[
"nVetoClust"] = 0;
116 calculationResult[
"chrgClust2GeV"] = 0;
117 calculationResult[
"neutClust045GeVAcc"] = 0;
118 calculationResult[
"neutClust045GeVBarrel"] = 0;
119 calculationResult[
"singleTagLowMass"] = 0;
120 calculationResult[
"singleTagHighMass"] = 0;
121 calculationResult[
"n2GeVNeutBarrel"] = 0;
122 calculationResult[
"n2GeVNeutEndcap"] = 0;
123 calculationResult[
"n2GeVChrg"] = 0;
124 calculationResult[
"n2GeVPhotonBarrel"] = 0;
125 calculationResult[
"n2GeVPhotonEndcap"] = 0;
126 calculationResult[
"ee1leg"] = 0;
127 calculationResult[
"ee1leg1clst"] = 0;
128 calculationResult[
"ee1leg1e"] = 0;
129 calculationResult[
"ee2clst"] = 0;
130 calculationResult[
"gg2clst"] = 0;
131 calculationResult[
"eeee"] = 0;
132 calculationResult[
"eemm"] = 0;
133 calculationResult[
"eexxSelect"] = 0;
134 calculationResult[
"radBhabha"] = 0;
135 calculationResult[
"eeBrem"] = 0;
136 calculationResult[
"isrRadBhabha"] = 0;
137 calculationResult[
"muonPairECL"] = 0;
138 calculationResult[
"ggHighPt"] = 0;
139 calculationResult[
"selectee1leg1trk"] = 0;
140 calculationResult[
"selectee1leg1clst"] = 0;
141 calculationResult[
"selectee"] = 0;
142 calculationResult[
"ggBarrelVL"] = 0;
143 calculationResult[
"ggBarrelLoose"] = 0;
144 calculationResult[
"ggBarrelTight"] = 0;
145 calculationResult[
"ggEndcapVL"] = 0;
146 calculationResult[
"ggEndcapLoose"] = 0;
147 calculationResult[
"ggEndcapTight"] = 0;
148 calculationResult[
"muonPairV"] = 0;
149 calculationResult[
"selectmumu"] = 0;
150 calculationResult[
"singleMuon"] = 0;
151 calculationResult[
"cosmic"] = 0;
152 calculationResult[
"displacedVertex"] = 0;
153 calculationResult[
"eeFlat0"] = 0;
154 calculationResult[
"eeFlat1"] = 0;
155 calculationResult[
"eeFlat2"] = 0;
156 calculationResult[
"eeFlat3"] = 0;
157 calculationResult[
"eeFlat4"] = 0;
158 calculationResult[
"eeFlat5"] = 0;
159 calculationResult[
"eeFlat6"] = 0;
160 calculationResult[
"eeFlat7"] = 0;
161 calculationResult[
"eeFlat8"] = 0;
162 calculationResult[
"eeOneClust"] = 0;
165 calculationResult[
"nTrkLooseB"] = 0;
166 calculationResult[
"nTrkTightB"] = 0;
167 calculationResult[
"maximumPCMSB"] = NAN;
168 calculationResult[
"netChargeLooseB"] = 0;
169 calculationResult[
"muonPairVB"] = 0;
170 calculationResult[
"eeBremB"] = 0;
171 calculationResult[
"singleTagLowMassB"] = 0;
172 calculationResult[
"singleTagHighMassB"] = 0;
173 calculationResult[
"radBhabhaB"] = 0;
176 calculationResult[
"nTrackC"] = 0;
177 calculationResult[
"maximumPCMSC"] = NAN;
178 calculationResult[
"pCmsNegC"] = NAN;
179 calculationResult[
"clusterENegC"] = NAN;
180 calculationResult[
"pCmsPosC"] = NAN;
181 calculationResult[
"clusterEPosC"] = NAN;
182 calculationResult[
"dPhiCmsC"] = NAN;
193 }
catch (
const std::exception&) {
199 }
catch (
const std::exception&) {
205 }
catch (
const std::exception&) {
211 }
catch (
const std::exception&) {
217 }
catch (
const std::exception&) {
220 calculationResult[
"bha3d"] = bha3d;
221 calculationResult[
"bhapur"] = bhapurPsnm;
222 calculationResult[
"bhapur_lml1"] = lml1 and bhapurFtdl;
223 calculationResult[
"l1_bit_f"] = l1_bit_f;
225 calculationResult[
"l1_trigger_random"] = 1;
226 calculationResult[
"l1_trigger_delayed_bhabha"] = 0;
227 calculationResult[
"l1_trigger_poisson"] = 0;
228 calculationResult[
"bha3d"] = 0;
229 calculationResult[
"bhapur"] = 0;
230 calculationResult[
"bhapur_lml1"] = 0;
231 calculationResult[
"l1_bit_f"] = 0;
235 calculationResult[
"l1_trg_NN_info"] = 0;
236 if (
m_bitsNN.isValid() and
m_bitsNN.getEntries() > 0) {calculationResult[
"l1_trg_NN_info"] = 1;}
238 calculationResult[
"true"] = 1;
239 calculationResult[
"false"] = 0;
244 const ROOT::Math::XYZVector clustervertex = cUtil.
GetIPPosition();
246 ROOT::Math::PxPyPzEVector p4ofCOM;
247 p4ofCOM.SetPxPyPzE(0, 0, 0, boostrotate.
getCMSEnergy());
250 std::map<short, std::optional<MaximumPtTrack>> maximumPtTracks = {
255 std::map<short, std::optional<MaximumPtTrack>> maximumPtTracksWithoutZCut = {
260 std::map<short, std::optional<MaximumPtTrack>> maximumPCmsTracksC = {
268 if (not trackFitResult) {
275 if (charge == 0) {
continue;}
276 const double z0 = trackFitResult->
getZ0();
277 const ROOT::Math::PxPyPzEVector& momentumLab = trackFitResult->
get4Momentum();
278 const ROOT::Math::PxPyPzEVector momentumCMS = boostrotate.
rotateLabToCms() * momentumLab;
279 const double pCMS = momentumCMS.P();
280 const double pLab = momentumLab.P();
281 const double trackTime = track.getTrackTime();
284 double clusterELab = 0.;
285 for (
auto& cluster : track.getRelationsTo<
ECLCluster>()) {
290 const double clusterECMS = clusterELab * pCMS / pLab;
295 bool goodTrackCTime =
true;
296 if (std::abs(trackTime) > 15.) {goodTrackCTime =
false;}
297 if (std::abs(z0) < 1. and goodTrackCTime and pCMS > 0.2) {
298 calculationResult[
"nTrackC"] += 1;
299 if (std::isnan(calculationResult[
"maximumPCMSC"]) or pCMS > calculationResult[
"maximumPCMSC"]) {
300 calculationResult[
"maximumPCMSC"] = pCMS;
305 const auto& currentMaximumC = maximumPCmsTracksC.at(charge);
306 if (not currentMaximumC or pCMS > currentMaximumC->pCMS) {
309 newMaximum.
track = &track;
310 newMaximum.
pCMS = pCMS;
311 newMaximum.
pLab = pLab;
312 newMaximum.
p4CMS = momentumCMS;
313 newMaximum.
p4Lab = momentumLab;
316 maximumPCmsTracksC[charge] = newMaximum;
328 calculationResult[
"nTrkTight"] += 1;
334 const auto& currentMaximum = maximumPtTracksWithoutZCut.at(charge);
335 if (not currentMaximum or pT > currentMaximum->pT) {
338 newMaximum.
track = &track;
339 newMaximum.
pCMS = pCMS;
340 newMaximum.
pLab = pLab;
341 newMaximum.
p4CMS = momentumCMS;
342 newMaximum.
p4Lab = momentumLab;
345 maximumPtTracksWithoutZCut[charge] = newMaximum;
352 calculationResult[
"nTrkLoose"] += 1;
353 calculationResult[
"netChargeLoose"] += charge;
355 if (std::isnan(calculationResult[
"maximumPCMS"]) or pCMS > calculationResult[
"maximumPCMS"]) {
356 calculationResult[
"maximumPCMS"] = pCMS;
359 if (std::isnan(calculationResult[
"maximumPLab"]) or pLab > calculationResult[
"maximumPLab"]) {
360 calculationResult[
"maximumPLab"] = pLab;
365 const auto& currentMaximumLoose = maximumPtTracks.at(charge);
366 if (not currentMaximumLoose or pTLoose > currentMaximumLoose->pT) {
368 newMaximum.
pT = pTLoose;
369 newMaximum.
track = &track;
370 newMaximum.
pCMS = pCMS;
371 newMaximum.
pLab = momentumLab.P();
372 newMaximum.
p4CMS = momentumCMS;
373 newMaximum.
p4Lab = momentumLab;
376 maximumPtTracks[charge] = newMaximum;
383 if (std::abs(z0) < 1.) {calculationResult[
"nTrkTightB"] += 1;}
384 if (std::abs(z0) < 5.) {
385 calculationResult[
"nTrkLooseB"] += 1;
386 calculationResult[
"netChargeLooseB"] += charge;
387 if (std::isnan(calculationResult[
"maximumPCMSB"]) or pCMS > calculationResult[
"maximumPCMSB"]) {
388 calculationResult[
"maximumPCMSB"] = pCMS;
399 for (
short charge : { -1, 1}) {
400 auto& maximumPcmsTrackC = maximumPCmsTracksC.at(charge);
401 if (not maximumPcmsTrackC) {
407 calculationResult[
"pCmsNegC"] = maximumPcmsTrackC->pCMS;
408 calculationResult[
"clusterENegC"] = maximumPcmsTrackC->clusterEnergySumLab;
410 calculationResult[
"pCmsPosC"] = maximumPcmsTrackC->pCMS;
411 calculationResult[
"clusterEPosC"] = maximumPcmsTrackC->clusterEnergySumLab;
416 if (maximumPCmsTracksC.at(-1) and maximumPCmsTracksC.at(1)) {
420 calculationResult[
"dPhiCmsC"] = std::abs(ROOT::Math::VectorUtil::DeltaPhi(negativeTrack.
p4CMS,
421 positiveTrack.
p4CMS)) * TMath::RadToDeg();
427 std::vector<SelectedECLCluster> selectedClusters;
430 const double time = cluster.getTime();
432 std::abs(time) > 200 or
437 const double dt99 = cluster.getDeltaTime99();
444 selectedCluster.
cluster = &cluster;
448 selectedCluster.
isTrack = cluster.isTrack();
450 selectedClusters.push_back(selectedCluster);
453 calculationResult[
"nElow"] += 1;
456 calculationResult[
"nEmedium"] += 1;
459 calculationResult[
"nEhigh"] += 1;
463 calculationResult[
"nVetoClust"] += 1;
468 const double thetaLab = selectedCluster.
p4Lab.Theta() * TMath::RadToDeg();
469 const double zmva = cluster.getZernikeMVA();
470 const bool photon = zmva > 0.5 and not selectedCluster.
isTrack;
471 const bool electron = zmva > 0.5 and selectedCluster.
isTrack;
475 calculationResult[
"chrgClust2GeV"] += 1;
478 const bool isInAcceptance = 17. < thetaLab and thetaLab < 150.;
479 if (isInAcceptance) {calculationResult[
"neutClust045GeVAcc"] += 1;}
480 const bool isInBarrel = 30. < thetaLab and thetaLab < 130.;
481 if (isInBarrel) {calculationResult[
"neutClust045GeVBarrel"] += 1;}
486 const bool notInHighBackgroundEndcapRegion = 18.5 < thetaLab and thetaLab < 139.3;
488 calculationResult[
"nE180Lab"] += 1;
492 calculationResult[
"nE300Lab"] += 1;
496 calculationResult[
"nE500Lab"] += 1;
499 if (selectedCluster.
energyCMS >
m_Ehigh and notInHighBackgroundEndcapRegion) {
500 calculationResult[
"nE2000CMS"] += 1;
505 calculationResult[
"nE250Lab"] += 1;
508 calculationResult[
"nE4000CMS"] += 1;
513 calculationResult[
"nEsingleClust"] += 1;
515 const bool barrelRegion = thetaLab > 45 and thetaLab < 115;
516 const bool extendedBarrelRegion = thetaLab > 30 and thetaLab < 130;
517 const bool endcapRegion = (thetaLab > 22 and thetaLab < 45) or (thetaLab > 115 and thetaLab < 145);
519 if (photon and barrelRegion) {
520 calculationResult[
"nEsinglePhotonBarrel"] += 1;
523 if (photon and extendedBarrelRegion) {
524 calculationResult[
"nEsinglePhotonExtendedBarrel"] += 1;
527 if (electron and barrelRegion) {
528 calculationResult[
"nEsingleElectronBarrel"] += 1;
531 if (electron and extendedBarrelRegion) {
532 calculationResult[
"nEsingleElectronExtendedBarrel"] += 1;
535 if (photon and endcapRegion) {
536 calculationResult[
"nEsinglePhotonEndcap"] += 1;
541 const bool reducedBarrelRegion = thetaLab > 44 and thetaLab < 98;
543 if (photon and reducedBarrelRegion) {
544 calculationResult[
"nReducedEsinglePhotonReducedBarrel"] += 1;
550 const bool barrelRegion = thetaLab > 32 and thetaLab < 130;
551 const bool endcapRegion = (thetaLab > 22 and thetaLab < 32) or (thetaLab > 130 and thetaLab < 145);
552 const bool lowAngleRegion = thetaLab < 22 or thetaLab > 145;
554 if (not selectedCluster.
isTrack and barrelRegion) {
555 calculationResult[
"n2GeVNeutBarrel"] += 1;
557 if (not selectedCluster.
isTrack and endcapRegion) {
558 calculationResult[
"n2GeVNeutEndcap"] += 1;
560 if (selectedCluster.
isTrack and not lowAngleRegion) {
561 calculationResult[
"n2GeVChrg"] += 1;
563 if (lowAngleRegion) {
564 calculationResult[
"nEhighLowAng"] += 1;
566 if (photon and barrelRegion) {
567 calculationResult[
"n2GeVPhotonBarrel"] += 1;
569 if (photon and endcapRegion) {
570 calculationResult[
"n2GeVPhotonEndcap"] += 1;
576 std::sort(selectedClusters.begin(), selectedClusters.end(), [](
const auto & lhs,
const auto & rhs) {
577 return lhs.energyCMS > rhs.energyCMS;
581 for (
short charge : { -1, 1}) {
582 auto& maximumPtTrack = maximumPtTracks.at(charge);
583 if (not maximumPtTrack) {
588 if (maximumPtTrack->clusterEnergySumCMS > 4.5) {
589 calculationResult[
"ee1leg"] = 1;
593 if (maximumPtTrack->pCMS > 3 and maximumPtTrack->clusterEnergySumLab > 0. and maximumPtTrack->clusterEnergySumLab < 1.) {
594 calculationResult[
"singleMuon"] = 1;
599 if (maximumPtTracks.at(-1) and maximumPtTracks.at(1)) {
603 double dphi = std::abs(negativeTrack.
p4CMS.Phi() - positiveTrack.
p4CMS.Phi()) * TMath::RadToDeg();
610 const double negativeP = negativeTrack.
pCMS;
613 const double positiveP = positiveTrack.
pCMS;
616 const double thetaSum = (negativeTrack.
p4CMS.Theta() + positiveTrack.
p4CMS.Theta()) * TMath::RadToDeg();
617 const double dthetaSum = std::abs(thetaSum - 180);
618 const auto back2back = dphi > 175 and dthetaSum < 15;
619 if (back2back and negativeClusterSum > 3 and positiveClusterSum > 3 and
620 (negativeClusterSum > 4.5 or positiveClusterSum > 4.5)) {
621 calculationResult[
"ee2leg"] = 1;
625 if (back2back and ((negativeClusterSum > 4.5 and positiveP > 3) or (positiveClusterSum > 4.5 and negativeP > 3))) {
626 calculationResult[
"ee1leg1trk"] = 1;
631 if ((negativeClusterSum > 4.5 and positiveClusterSum > 0.8 * positiveP) or
632 (positiveClusterSum > 4.5 and negativeClusterSum > 0.8 * negativeP)) {
633 calculationResult[
"ee1leg1e"] = 1;
637 const ROOT::Math::PxPyPzEVector p4Miss = p4ofCOM - negativeTrack.
p4CMS - positiveTrack.
p4CMS;
638 const double pmissTheta = p4Miss.Theta() * TMath::RadToDeg();
639 const double pmissp = p4Miss.P();
643 const bool electronEP = positiveClusterSum > 0.8 * positiveP or negativeClusterSum > 0.8 * negativeP;
644 const bool notMuonPair = negativeClusterSumLab > 1 or positiveClusterSumLab > 1;
645 const double highp = std::max(negativeP, positiveP);
646 const double lowp = std::min(negativeP, positiveP);
647 const bool lowEdep = negativeClusterSumLab < 0.5 and positiveClusterSumLab < 0.5;
650 if (calculationResult[
"maximumPCMS"] < 2 and dphi > 160 and (pmissTheta < 25. or pmissTheta > 155.)) {
651 calculationResult[
"eexxSelect"] = 1;
653 calculationResult[
"eeee"] = 1;
655 calculationResult[
"eemm"] = 1;
660 if ((pmissTheta < 20. or pmissTheta > 160.) and
661 ((calculationResult[
"maximumPCMS"] < 1.2 and dphi > 150.) or
662 (calculationResult[
"maximumPCMS"] < 2. and 175. < dphi))) {
663 calculationResult[
"eexx"] = 1;
667 if (negativeP > 1. and pmissTheta > 10. and pmissTheta < 170. and positiveP > 1. and dphi < 170. and pmissp > 1. and electronEP) {
668 if (calculationResult[
"nTrkLoose"] == 2 and calculationResult[
"nTrkTight"] >= 1) {
669 calculationResult[
"radBhabha"] = 1;
671 if (calculationResult[
"nTrkLooseB"] == 2 and calculationResult[
"nTrkTightB"] >= 1) {
672 calculationResult[
"radBhabhaB"] = 1;
677 if (negativeP > 2. and positiveP > 2. and 2 == calculationResult[
"nTrkLoose"] and
678 calculationResult[
"nTrkTight"] >= 1 and dphi > 175. and
679 (pmissTheta < 5. or pmissTheta > 175.) and electronEP) {
680 calculationResult[
"isrRadBhabha"] = 1;
684 if (highp > 4.5 and notMuonPair and pmissp > 1. and (relMissAngle0 < 5. or relMissAngle1 < 5.)) {
685 if (calculationResult[
"nTrkLoose"] == 2) { calculationResult[
"eeBrem"] = 1;}
686 if (calculationResult[
"nTrkLooseB"] >= 1) { calculationResult[
"eeBremB"] = 1;}
690 if (highp > 4.5 and lowEdep and thetaSum > 175. and thetaSum < 185. and dphi > 175.) {
691 if (calculationResult[
"nTrkLoose"] == 2) {calculationResult[
"muonPairV"] = 1;}
692 if (calculationResult[
"nTrkLooseB"] == 2) {calculationResult[
"muonPairVB"] = 1;}
696 if (highp > 3. and lowp > 2.5 and dphi > 165. and
697 ((negativeClusterSumLab > 0. and negativeClusterSumLab < 1.) or
698 (positiveClusterSumLab > 0. and positiveClusterSumLab < 1.))) {
699 calculationResult[
"selectmumu"] = 1;
704 if (selectedClusters.size() >= 2) {
708 double dphi = std::abs(firstCluster.
p4CMS.Phi() - secondCluster.
p4CMS.Phi()) * TMath::RadToDeg();
712 double thetaSum = (firstCluster.
p4CMS.Theta() + secondCluster.
p4CMS.Theta()) * TMath::RadToDeg();
713 double dthetaSum = std::abs(thetaSum - 180);
716 calculationResult[
"dphiCmsClust"] = dphi;
717 for (
int ic = 0; ic < 2; ic++) {
718 const double thetaLab = selectedClusters[ic].p4Lab.Theta() * TMath::RadToDeg();
719 const bool isInAcceptance = 17. < thetaLab and thetaLab < 150.;
720 const ECLCluster* cluster = selectedClusters[ic].cluster;
721 const double zmva = cluster->getZernikeMVA();
722 const bool photon = zmva > 0.5 and not selectedClusters[ic].isTrack;
723 if (isInAcceptance and photon) {calculationResult[
"nMaxEPhotonAcc"] += 1;}
726 const double firstEnergy = firstCluster.
p4CMS.E();
727 const double secondEnergy = secondCluster.
p4CMS.E();
729 const bool highEnergetic = firstEnergy > 3 and secondEnergy > 3 and (firstEnergy > 4.5 or secondEnergy > 4.5);
731 if (dphi > 160 and dphi < 178 and dthetaSum < 15 and highEnergetic) {
732 calculationResult[
"ee2clst"] = 1;
735 if (dphi > 178 and dthetaSum < 15 and highEnergetic) {
736 calculationResult[
"gg2clst"] = 1;
739 if ((calculationResult[
"ee2clst"] == 1 or calculationResult[
"gg2clst"] == 1) and
740 calculationResult[
"ee1leg"] == 1) {
741 calculationResult[
"ee1leg1clst"] = 1;
744 const double Elab0 = firstCluster.
p4Lab.E();
745 const double Elab1 = secondCluster.
p4Lab.E();
748 if (firstEnergy > 2 and secondEnergy > 2) {
749 const double thetaLab0 = firstCluster.
p4Lab.Theta() * TMath::RadToDeg();
750 const double thetaLab1 = secondCluster.
p4Lab.Theta() * TMath::RadToDeg();
752 const bool barrel0 = 32. < thetaLab0 and thetaLab0 < 130.;
753 const bool barrel1 = 32. < thetaLab1 and thetaLab1 < 130.;
754 const bool oneClustersAbove4 = firstEnergy > 4 or secondEnergy > 4;
755 const bool oneIsNeutral = not firstCluster.
isTrack or not secondCluster.
isTrack;
756 const bool bothAreNeutral = not firstCluster.
isTrack and not secondCluster.
isTrack;
757 const bool oneIsBarrel = barrel0 or barrel1;
758 const bool dphiCutExtraLoose = dphi > 175;
759 const bool dphiCutLoose = dphi > 177;
760 const bool dphiCutTight = dphi > 177.5;
762 if (dphiCutExtraLoose and oneIsNeutral and oneIsBarrel) {
763 calculationResult[
"ggBarrelVL"] = 1;
765 if (oneClustersAbove4 and dphiCutLoose and oneIsNeutral and oneIsBarrel) {
766 calculationResult[
"ggBarrelLoose"] = 1;
768 if (oneClustersAbove4 and dphiCutTight and bothAreNeutral and oneIsBarrel) {
769 calculationResult[
"ggBarrelTight"] = 1;
771 if (dphiCutExtraLoose and oneIsNeutral and not oneIsBarrel) {
772 calculationResult[
"ggEndcapVL"] = 1;
774 if (oneClustersAbove4 and dphiCutLoose and oneIsNeutral and not oneIsBarrel) {
775 calculationResult[
"ggEndcapLoose"] = 1;
777 if (oneClustersAbove4 and dphiCutTight and bothAreNeutral and not oneIsBarrel) {
778 calculationResult[
"ggEndcapTight"] = 1;
782 const double minEnergy = std::min(Elab0, Elab1);
783 const double maxEnergy = std::max(Elab0, Elab1);
784 if (dphi > 155 and thetaSum > 165 and thetaSum < 195 and minEnergy > 0.15 and minEnergy < 0.5 and
785 maxEnergy > 0.15 and maxEnergy < 0.5) {
786 calculationResult[
"muonPairECL"] = 1;
790 const double thetaLab0 = firstCluster.
p4Lab.Theta() * TMath::RadToDeg();
791 const double thetaLab1 = secondCluster.
p4Lab.Theta() * TMath::RadToDeg();
792 const bool inHieRegion0 = thetaLab0 > 26. and thetaLab0 < 130.;
793 const bool inHieRegion1 = thetaLab1 > 26. and thetaLab1 < 130.;
794 const bool firstIsNeutral = not firstCluster.
isTrack;
795 const bool secondIsNeutral = not secondCluster.
isTrack;
797 if (secondEnergy > 0.3 and inHieRegion0 and inHieRegion1 and firstIsNeutral and secondIsNeutral) {
798 const ROOT::Math::PxPyPzEVector ggP4CMS = firstCluster.
p4CMS + secondCluster.
p4CMS;
799 if (ggP4CMS.pt() > 1.) {calculationResult[
"ggHighPt"] = 1;}
806 double thetaFlatten = 0;
809 for (
short charge : { -1, 1}) {
810 const auto& maximumPtTrack = maximumPtTracks.at(charge);
811 if (not maximumPtTrack) {
815 if (maximumPtTrack->clusterEnergySumCMS > 1.5) {
817 double tempFlatten = 0.;
819 double tempInvMass = (maximumPtTrack->p4Lab + cluster.p4Lab).M();
820 if (tempInvMass > invMass) {
821 invMass = tempInvMass;
823 tempFlatten = cluster.p4Lab.Theta() * TMath::RadToDeg();
828 tempFlatten = maximumPtTrack->p4Lab.Theta() * TMath::RadToDeg();
830 if (invMass > 5.29) {
831 calculationResult[
"selectee1leg1clst"] = 1;
832 thetaFlatten = tempFlatten;
838 if (maximumPtTracks.at(-1) and maximumPtTracks.at(1)) {
841 const double invMass = (negativeTrack.
p4Lab + positiveTrack.
p4Lab).M();
843 calculationResult[
"selectee1leg1trk"] = 1;
846 thetaFlatten = negativeTrack.
p4Lab.Theta() * TMath::RadToDeg();
851 if ((invMass > 9.) and (missNegClust or missPosClust)) {
852 calculationResult[
"eeOneClust"] = 1;
856 if (calculationResult[
"selectee1leg1trk"] == 1 or calculationResult[
"selectee1leg1clst"] == 1) {
857 for (
int iflat = 0; iflat < 9; iflat++) {
858 const std::string& eeFlatName =
"eeFlat" + std::to_string(iflat);
859 calculationResult[eeFlatName] =
860 thetaFlatten >= flatBoundaries[iflat] and thetaFlatten < flatBoundaries[iflat + 1];
861 if (calculationResult[eeFlatName]) {
862 calculationResult[
"selectee"] = 1;
868 if (calculationResult[
"nTrkLoose"] == 1 and calculationResult[
"maximumPCMS"] > 0.8 and selectedClusters.size() >= 2) {
870 decltype(selectedClusters) selectedSingleTagClusters(selectedClusters.size());
871 auto lastItem = std::copy_if(selectedClusters.begin(), selectedClusters.end(), selectedSingleTagClusters.begin(),
873 const bool isNeutralCluster = not cluster.isTrack;
874 const bool hasEnoughEnergy = cluster.energyLab > 0.1;
875 const double clusterThetaLab = cluster.p4Lab.Theta() * TMath::RadToDeg();
876 const bool isInAcceptance = 17 < clusterThetaLab and clusterThetaLab < 150.;
877 return isNeutralCluster and hasEnoughEnergy and isInAcceptance;
879 selectedSingleTagClusters.resize(std::distance(selectedSingleTagClusters.begin(), lastItem));
881 if (selectedSingleTagClusters.size() >= 2) {
883 const auto& track = maximumPtTracks.at(-1) ? *maximumPtTracks.at(-1) : *maximumPtTracks.at(1);
885 const auto& firstCluster = selectedSingleTagClusters[0];
886 const auto& secondCluster = selectedSingleTagClusters[1];
888 const ROOT::Math::PxPyPzEVector trackP4CMS = track.p4CMS;
889 const ROOT::Math::PxPyPzEVector pi0P4CMS = firstCluster.p4CMS + secondCluster.p4CMS;
891 const bool passPi0ECMS = pi0P4CMS.E() > 1. and pi0P4CMS.E() < 0.525 * p4ofCOM.M();
892 const double thetaSumCMS = (pi0P4CMS.Theta() + trackP4CMS.Theta()) * TMath::RadToDeg();
893 const bool passThetaSum = thetaSumCMS < 170. or thetaSumCMS > 190.;
895 double dphiCMS = std::abs(trackP4CMS.Phi() - pi0P4CMS.Phi()) * TMath::RadToDeg();
897 dphiCMS = 360 - dphiCMS;
899 const bool passdPhi = dphiCMS > 160.;
901 if (passPi0ECMS and passThetaSum and passdPhi and pi0P4CMS.M() < 0.7) {
902 calculationResult[
"singleTagLowMass"] = 1;
903 }
else if (passPi0ECMS and passThetaSum and passdPhi and pi0P4CMS.M() > 0.7) {
904 calculationResult[
"singleTagHighMass"] = 1;
910 if (calculationResult[
"nTrkLooseB"] == 1 and calculationResult[
"maximumPCMSB"] > 0.8 and selectedClusters.size() >= 2) {
912 decltype(selectedClusters) selectedSingleTagClusters(selectedClusters.size());
913 auto lastItem = std::copy_if(selectedClusters.begin(), selectedClusters.end(), selectedSingleTagClusters.begin(),
915 const bool isNeutralCluster = not cluster.isTrack;
916 const bool hasEnoughEnergy = cluster.energyLab > 0.1;
917 const double clusterThetaLab = cluster.p4Lab.Theta() * TMath::RadToDeg();
918 const bool isInAcceptance = 17 < clusterThetaLab and clusterThetaLab < 150.;
919 return isNeutralCluster and hasEnoughEnergy and isInAcceptance;
921 selectedSingleTagClusters.resize(std::distance(selectedSingleTagClusters.begin(), lastItem));
923 if (selectedSingleTagClusters.size() >= 2) {
925 const auto& track = maximumPtTracks.at(-1) ? *maximumPtTracks.at(-1) : *maximumPtTracks.at(1);
927 const auto& firstCluster = selectedSingleTagClusters[0];
928 const auto& secondCluster = selectedSingleTagClusters[1];
930 const ROOT::Math::PxPyPzEVector trackP4CMS = track.p4CMS;
931 const ROOT::Math::PxPyPzEVector pi0P4CMS = firstCluster.p4CMS + secondCluster.p4CMS;
933 const bool passPi0ECMS = pi0P4CMS.E() > 1. and pi0P4CMS.E() < 0.525 * p4ofCOM.M();
934 const double thetaSumCMS = (pi0P4CMS.Theta() + trackP4CMS.Theta()) * TMath::RadToDeg();
935 const bool passThetaSum = thetaSumCMS < 170. or thetaSumCMS > 190.;
937 double dphiCMS = std::abs(trackP4CMS.Phi() - pi0P4CMS.Phi()) * TMath::RadToDeg();
939 dphiCMS = 360 - dphiCMS;
941 const bool passdPhi = dphiCMS > 160.;
943 if (passPi0ECMS and passThetaSum and passdPhi and pi0P4CMS.M() < 0.7) {
944 calculationResult[
"singleTagLowMassB"] = 1;
945 }
else if (passPi0ECMS and passThetaSum and passdPhi and pi0P4CMS.M() > 0.7) {
946 calculationResult[
"singleTagHighMassB"] = 1;
954 const auto negTrack = maximumPtTracksWithoutZCut.at(-1);
955 const auto posTrack = maximumPtTracksWithoutZCut.at(1);
957 if (negTrack and posTrack) {
959 const double maxNegpT = negTrack->pT;
960 const double maxPospT = posTrack->pT;
961 const double maxClusterENeg = negTrack->clusterEnergySumLab;
962 const double maxClusterEPos = posTrack->clusterEnergySumLab;
964 const ROOT::Math::PxPyPzEVector& momentumLabNeg(negTrack->p4Lab);
965 const ROOT::Math::PxPyPzEVector& momentumLabPos(posTrack->p4Lab);
967 const double& z0Neg = negTrack->track->getTrackFitResultWithClosestMass(
Const::pion)->getZ0();
968 const double& d0Neg = negTrack->track->getTrackFitResultWithClosestMass(
Const::pion)->getD0();
969 const double& z0Pos = posTrack->track->getTrackFitResultWithClosestMass(
Const::pion)->getZ0();
970 const double& d0Pos = posTrack->track->getTrackFitResultWithClosestMass(
Const::pion)->getD0();
977 double dphiLab = std::abs(momentumLabNeg.Phi() - momentumLabPos.Phi()) * TMath::RadToDeg();
979 dphiLab = 360 - dphiLab;
982 const double thetaSumLab = (momentumLabNeg.Theta() + momentumLabPos.Theta()) * TMath::RadToDeg();
984 constexpr double phiBackToBackTolerance = 2.;
985 constexpr double thetaBackToBackTolerance = 2.;
986 if ((180 - dphiLab) < phiBackToBackTolerance and std::abs(180 - thetaSumLab) < thetaBackToBackTolerance) {
987 calculationResult[
"cosmic"] = 1;
995 if (maximumPtTracksWithoutZCut.at(-1) and maximumPtTracksWithoutZCut.at(1)) {
998 const auto nTrack = maximumPtTracksWithoutZCut.at(-1)->track;
1001 const auto pTrack = maximumPtTracksWithoutZCut.at(1)->track;
1011 const double chisq = vertexFit->
getCHIsq();
1012 const int ndf = vertexFit->
getNDF();
1013 const double vertexProb = TMath::Prob(chisq, ndf);
1014 const auto vertexLocation = vertexFit->
getVertex();
1015 const double vertexXY = vertexLocation.perp();
1016 const double vertexTheta = vertexLocation.theta() * TMath::RadToDeg();
1022 const ROOT::Math::PxPyPzEVector& momentumLabNeg(maximumPtTracksWithoutZCut.at(-1)->p4Lab);
1023 const ROOT::Math::PxPyPzEVector& momentumLabPos(maximumPtTracksWithoutZCut.at(1)->p4Lab);
1024 const double thetaSumLab = (momentumLabNeg.Theta() + momentumLabPos.Theta()) * TMath::RadToDeg();
1025 double dPhiLab = std::abs(momentumLabNeg.Phi() - momentumLabPos.Phi()) * TMath::RadToDeg();
1026 if (dPhiLab > 180) {
1027 dPhiLab = 360 - dPhiLab;
1029 const double backToBackTolerance = 10.;
1030 const bool backToBackLab = std::abs(thetaSumLab - 180.) < backToBackTolerance and std::abs(dPhiLab - 180.) < backToBackTolerance;
1033 const double minProbChiVertex = 0.005;
1034 const double minXYVertex = 3.;
1035 const double maxXYVertex = 60.;
1036 const double minThetaVertex = 30.;
1037 const double maxThetaVertex = 120.;
1038 if (vertexProb > minProbChiVertex and vertexXY > minXYVertex and vertexXY < maxXYVertex and vertexTheta > minThetaVertex
1039 and vertexTheta < maxThetaVertex
1040 and not backToBackLab) {calculationResult[
"displacedVertex"] = 1;}
DataType Angle(const B2Vector3< DataType > &q) const
The angle w.r.t.
Class to provide momentum-related information from ECLClusters.
const ROOT::Math::PxPyPzEVector Get4MomentumFromCluster(const ECLCluster *cluster, ECLCluster::EHypothesisBit hypo)
Returns four momentum vector.
const ROOT::Math::XYZVector GetIPPosition()
Returns default IP position from beam parameters.
static const ChargedStable pion
charged pion particle
@ c_nPhotons
CR is split into n photons (N1)
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
Class to store reconstructed particles.
double m_EminLab
which lab energy defines nE180Lab
double m_reducedEsinglePhoton
which CMS energy defines nReducedEsingle clusters
StoreObjPtr< TRGSummary > m_l1Trigger
Store Object with the trigger result.
double m_E0min
which CMS energy defines nEmedium
void requireStoreArrays() override
Require the particle list. We do not need more here.
void doCalculation(SoftwareTriggerObject &calculationResult) override
Actually write out the variables into the map.
double m_goodMagneticRegionZ0
maximum z0 for well understood magnetic field (cm)
double m_cosmicMinPt
which LAB pt defines a cosmic
double m_EsinglePhoton
which CMS energy defines nEsingleClust
double m_E2min
which CMS energy defines nElow
double m_tightTrkZ0
which Z0 defines a tight track
StoreArray< Track > m_tracks
Store Array of the tracks to be used.
double m_EminLab3Cluster
which lab energy defines nE500Lab
double m_Ehigh
which CMS energy defines nEhigh
StoreArray< ECLCluster > m_eclClusters
Store Array of the ecl clusters to be used.
double m_EminLab4Cluster
which lab energy defines nE300Lab
StoreArray< CDCTriggerUnpacker::NNBitStream > m_bitsNN
Store Object with the trigger NN bits.
FilterCalculator()
Set the default names for the store object particle lists.
double m_cosmicMaxClusterEnergy
which LAB cluster energy vetoes a cosmic candidate
double m_goodMagneticRegionD0
minimum d0 for well understood magnetic field, if z0 is large (cm)
double m_looseTrkZ0
which Z0 defines a loose track
@ TTYP_DPHY
delayed physics events for background
@ TTYP_POIS
poisson random trigger
@ TTYP_RAND
random trigger events
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
ROOT::Math::PxPyPzEVector get4Momentum() const
Getter for the 4Momentum at the closest approach of the track in the r/phi projection.
double getTransverseMomentum() const
Getter for the absolute value of the transverse momentum at the perigee.
double getZ0() const
Getter for z0.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
Class that bundles various TrackFitResults.
virtual int getNDF(void) const
Get an NDF of the fit.
enum KFitError::ECode addParticle(const Particle *particle)
Add a particle to the fitter.
VertexFitKFit is a derived class from KFitBase to perform vertex-constraint kinematical fit.
double getCHIsq(void) const override
Get a chi-square of the fit.
enum KFitError::ECode doFit(void)
Perform a vertex-constraint fit.
const HepPoint3D getVertex(const int flag=KFitConst::kAfterFit) const
Get a vertex position.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Abstract base class for different kinds of events.
Temporary data structure holding the track(s) with the maximum pT.
double pLab
the momentum magnitude in lab system
double pT
the pT of the track
ROOT::Math::PxPyPzEVector p4CMS
the 4 momentum in CMS system
double clusterEnergySumLab
the sum of related cluster energies in lab system
ROOT::Math::PxPyPzEVector p4Lab
the 4 momentum in lab system
double clusterEnergySumCMS
the sum of related cluster energies in CMS system
double pCMS
the momentum magnitude in CMS system
const Track * track
the track
Temporary data structure holding the ECL clusters used for this analysis.
double energyLab
the energy in Lab system
double clusterTime
the time of the cluster
ROOT::Math::PxPyPzEVector p4CMS
the 4 momentum in CMS system
ROOT::Math::PxPyPzEVector p4Lab
the 4 momentum in lab system
const ECLCluster * cluster
The ECL cluster.
bool isTrack
is this ECL cluster likely from a track (or a photon) = is it charged?
double energyCMS
the energy in CMS system