10#include <analysis/variables/MCTruthVariables.h>
13#include <analysis/VariableManager/Manager.h>
15#include <analysis/dataobjects/Particle.h>
16#include <analysis/dataobjects/TauPairDecay.h>
17#include <analysis/utility/MCMatching.h>
18#include <analysis/utility/ReferenceFrame.h>
19#include <analysis/utility/ValueIndexPairSorting.h>
21#include <mdst/dataobjects/MCParticle.h>
22#include <mdst/dataobjects/ECLCluster.h>
23#include <mdst/dataobjects/Track.h>
26#include <framework/datastore/StoreArray.h>
27#include <framework/datastore/StoreObjPtr.h>
28#include <framework/dataobjects/EventMetaData.h>
29#include <framework/gearbox/Const.h>
30#include <framework/logging/Logger.h>
31#include <framework/database/DBObjPtr.h>
32#include <framework/dbobjects/BeamParameters.h>
43 double isSignal(
const Particle* part)
52 double isSignalAcceptWrongFSPs(
const Particle* part)
59 status &= (~MCMatching::c_MisID);
60 status &= (~MCMatching::c_AddedWrongParticle);
65 double isPrimarySignal(
const Particle* part)
67 return (isSignal(part) > 0.5 and particleMCPrimaryParticle(part) > 0.5);
70 double isMisidentified(
const Particle* part)
78 double isWrongCharge(
const Particle* part)
82 return (part->getCharge() != mcp->getCharge());
85 double isCloneTrack(
const Particle* particle)
91 const auto mcpww = particle->getRelatedToWithWeight<MCParticle>();
93 return (mcpww.second < 0);
96 double isOrHasCloneTrack(
const Particle* particle)
99 std::queue<const Particle*> qq;
101 while (!qq.empty()) {
102 const auto d = qq.front();
104 if (isCloneTrack(d) == 1.0)
return 1.0;
105 size_t nDau = d->getNDaughters();
106 for (
size_t iDau = 0; iDau < nDau; ++iDau)
107 qq.push(d->getDaughter(iDau));
112 double genNthMotherPDG(
const Particle* part,
const std::vector<double>& args)
115 if (!mcparticle)
return 0.0;
117 unsigned int nLevels = args.empty() ? 0 : args[0];
119 const MCParticle* curMCParticle = mcparticle;
120 for (
unsigned int i = 0; i <= nLevels; ++i) {
121 const MCParticle* curMCMother = curMCParticle->getMother();
122 if (!curMCMother)
return 0.0;
123 curMCParticle = curMCMother;
125 return curMCParticle->getPDG();
128 double genNthMotherIndex(
const Particle* part,
const std::vector<double>& args)
131 if (!mcparticle)
return 0.0;
133 unsigned int nLevels = args.empty() ? 0 : args[0];
135 const MCParticle* curMCParticle = mcparticle;
136 for (
unsigned int i = 0; i <= nLevels; ++i) {
137 const MCParticle* curMCMother = curMCParticle->getMother();
138 if (!curMCMother)
return 0.0;
139 curMCParticle = curMCMother;
144 double genQ2PmPd(
const Particle* part,
const std::vector<double>& daughter_indices)
149 auto daughters = mcparticle->getDaughters();
151 ROOT::Math::PxPyPzEVector p4Daughters;
152 for (
auto& double_daughter : daughter_indices) {
153 unsigned long daughter = std::lround(double_daughter);
156 p4Daughters += daughters[daughter]->get4Vector();
158 auto p4Mother = mcparticle->get4Vector();
159 return (p4Mother - p4Daughters).mag2();
162 double genMotherPDG(
const Particle* part)
164 return genNthMotherPDG(part, {});
167 double genMotherP(
const Particle* part)
172 const MCParticle* mcmother = mcparticle->getMother();
175 return mcmother->getMomentum().R();
178 double genMotherIndex(
const Particle* part)
180 return genNthMotherIndex(part, {});
183 double genParticleIndex(
const Particle* part)
187 return mcparticle->getArrayIndex();
190 double isSignalAcceptMissingNeutrino(
const Particle* part)
197 status &= (~MCMatching::c_MissNeutrino);
202 double isSignalAcceptMissingMassive(
const Particle* part)
209 status &= (~MCMatching::c_MissMassiveParticle);
210 status &= (~MCMatching::c_MissKlong);
215 double isSignalAcceptMissingGamma(
const Particle* part)
222 status &= (~MCMatching::c_MissGamma);
227 double isSignalAcceptMissing(
const Particle* part)
234 status &= (~MCMatching::c_MissGamma);
235 status &= (~MCMatching::c_MissMassiveParticle);
236 status &= (~MCMatching::c_MissKlong);
237 status &= (~MCMatching::c_MissNeutrino);
242 double isSignalAcceptBremsPhotons(
const Particle* part)
249 status &= (~MCMatching::c_AddedRecoBremsPhoton);
254 double particleMCMatchPDGCode(
const Particle* part)
258 return mcparticle->getPDG();
261 double particleMCErrors(
const Particle* part)
266 double particleNumberOfMCMatch(
const Particle* particle)
268 RelationVector<MCParticle> mcRelations = particle->getRelationsTo<MCParticle>();
269 return (mcRelations.size());
272 double particleMCMatchWeight(
const Particle* particle)
274 auto relWithWeight = particle->getRelatedToWithWeight<MCParticle>();
276 return relWithWeight.second;
279 double particleMCMatchDecayTime(
const Particle* part)
283 return mcparticle->getDecayTime();
286 double particleMCMatchLifeTime(
const Particle* part)
290 return mcparticle->getLifetime();
293 double particleMCMatchPX(
const Particle* part)
299 ROOT::Math::PxPyPzEVector mcpP4 = mcparticle->get4Vector();
300 return frame.getMomentum(mcpP4).Px();
303 double particleMCMatchPY(
const Particle* part)
309 ROOT::Math::PxPyPzEVector mcpP4 = mcparticle->get4Vector();
310 return frame.getMomentum(mcpP4).Py();
313 double particleMCMatchPZ(
const Particle* part)
319 ROOT::Math::PxPyPzEVector mcpP4 = mcparticle->get4Vector();
320 return frame.getMomentum(mcpP4).Pz();
323 double particleMCMatchPT(
const Particle* part)
329 ROOT::Math::PxPyPzEVector mcpP4 = mcparticle->get4Vector();
330 return frame.getMomentum(mcpP4).Pt();
333 double particleMCMatchE(
const Particle* part)
339 ROOT::Math::PxPyPzEVector mcpP4 = mcparticle->get4Vector();
340 return frame.getMomentum(mcpP4).E();
343 double particleMCMatchP(
const Particle* part)
349 ROOT::Math::PxPyPzEVector mcpP4 = mcparticle->get4Vector();
350 return frame.getMomentum(mcpP4).P();
353 double particleMCMatchTheta(
const Particle* part)
359 ROOT::Math::PxPyPzEVector mcpP4 = mcparticle->get4Vector();
360 return frame.getMomentum(mcpP4).Theta();
363 double particleMCMatchPhi(
const Particle* part)
369 ROOT::Math::PxPyPzEVector mcpP4 = mcparticle->get4Vector();
370 return frame.getMomentum(mcpP4).Phi();
373 double mcParticleNDaughters(
const Particle* part)
378 return mcparticle->getNDaughters();
381 double particleMCRecoilMass(
const Particle* part)
383 StoreArray<MCParticle> mcparticles;
386 ROOT::Math::PxPyPzEVector pInitial = mcparticles[0]->get4Vector();
387 ROOT::Math::PxPyPzEVector pDaughters;
388 const std::vector<Particle*> daughters = part->getDaughters();
389 for (
auto daughter : daughters) {
390 const MCParticle* mcD = daughter->getMCParticle();
393 pDaughters += mcD->get4Vector();
395 return (pInitial - pDaughters).M();
398 ROOT::Math::PxPyPzEVector MCInvisibleP4(
const MCParticle* mcparticle)
400 ROOT::Math::PxPyPzEVector ResultP4;
401 int pdg = abs(mcparticle->getPDG());
402 bool isNeutrino = (pdg == 12 or pdg == 14 or pdg == 16);
404 if (mcparticle->getNDaughters() > 0) {
405 const std::vector<MCParticle*> daughters = mcparticle->getDaughters();
406 for (
auto daughter : daughters)
407 ResultP4 += MCInvisibleP4(daughter);
408 }
else if (isNeutrino)
409 ResultP4 += mcparticle->get4Vector();
414 double particleMCCosThetaBetweenParticleAndNominalB(
const Particle* part)
416 int particlePDG = abs(part->getPDGCode());
417 if (particlePDG != 511 and particlePDG != 521)
418 B2FATAL(
"The variable mcCosThetaBetweenParticleAndNominalB is only meant to be used on B mesons!");
421 double e_Beam = T.getCMSEnergy() / 2.0;
422 double m_B = part->getPDGMass();
425 const double mY4S = 10.5794;
428 if (e_Beam * e_Beam - m_B * m_B < 0) {
431 double p_B = std::sqrt(e_Beam * e_Beam - m_B * m_B);
437 int mcParticlePDG = abs(mcB->getPDG());
438 if (mcParticlePDG != 511 and mcParticlePDG != 521)
441 ROOT::Math::PxPyPzEVector p = T.rotateLabToCms() * (mcB->get4Vector() - MCInvisibleP4(mcB));
446 double theta_BY = (2 * e_Beam * e_d - m_B * m_B - m_d * m_d)
451 double mcParticleSecondaryPhysicsProcess(
const Particle* p)
453 const MCParticle* mcp = p->getMCParticle();
455 return mcp->getSecondaryPhysicsProcess();
458 double mcParticleStatus(
const Particle* p)
460 const MCParticle* mcp = p->getMCParticle();
462 return mcp->getStatus();
465 double particleMCPrimaryParticle(
const Particle* p)
467 const MCParticle* mcp = p->getMCParticle();
471 return mcp->hasStatus(bitmask);
474 double particleMCVirtualParticle(
const Particle* p)
476 const MCParticle* mcp = p->getMCParticle();
480 return mcp->hasStatus(bitmask);
483 double particleMCInitialParticle(
const Particle* p)
485 const MCParticle* mcp = p->getMCParticle();
489 return mcp->hasStatus(bitmask);
492 double particleMCISRParticle(
const Particle* p)
494 const MCParticle* mcp = p->getMCParticle();
498 return mcp->hasStatus(bitmask);
501 double particleMCFSRParticle(
const Particle* p)
503 const MCParticle* mcp = p->getMCParticle();
507 return mcp->hasStatus(bitmask);
510 double particleMCPhotosParticle(
const Particle* p)
512 const MCParticle* mcp = p->getMCParticle();
516 return mcp->hasStatus(bitmask);
519 double generatorEventWeight(
const Particle*)
521 StoreObjPtr<EventMetaData> evtMetaData;
523 return evtMetaData->getGeneratedWeight();
526 int tauPlusMcMode(
const Particle*)
528 StoreObjPtr<TauPairDecay> tauDecay;
530 B2WARNING(
"Cannot find tau decay ID, did you forget to run TauDecayMarkerModule?");
533 return tauDecay->getTauPlusIdMode();
536 int tauMinusMcMode(
const Particle*)
538 StoreObjPtr<TauPairDecay> tauDecay;
540 B2WARNING(
"Cannot find tau decay ID, did you forget to run TauDecayMarkerModule?");
543 return tauDecay->getTauMinusIdMode();
546 int tauPlusMcProng(
const Particle*)
548 StoreObjPtr<TauPairDecay> tauDecay;
550 B2WARNING(
"Cannot find tau prong, did you forget to run TauDecayMarkerModule?");
553 return tauDecay->getTauPlusMcProng();
556 int tauMinusMcProng(
const Particle*)
558 StoreObjPtr<TauPairDecay> tauDecay;
560 B2WARNING(
"Cannot find tau prong, did you forget to run TauDecayMarkerModule?");
563 return tauDecay->getTauMinusMcProng();
566 double tauPlusEgstar(
const Particle*)
568 StoreObjPtr<TauPairDecay> tauDecay;
570 B2WARNING(
"Cannot find tau prong, did you forget to run TauDecayMarkerModule?");
573 return tauDecay->getTauPlusEgstar();
576 double tauMinusEgstar(
const Particle*)
578 StoreObjPtr<TauPairDecay> tauDecay;
580 B2WARNING(
"Cannot find tau prong, did you forget to run TauDecayMarkerModule?");
583 return tauDecay->getTauMinusEgstar();
586 double isReconstructible(
const Particle* p)
588 if (p->getParticleSource() == Particle::EParticleSourceObject::c_Composite)
590 const MCParticle* mcp = p->getMCParticle();
595 return (abs(mcp->getCharge()) > 0) ? seenInSVD(p) : seenInECL(p);
598 double isTrackFound(
const Particle* p)
600 if (p->getParticleSource() != Particle::EParticleSourceObject::c_MCParticle)
602 const MCParticle* tmp_mcP = p->getMCParticle();
605 Track* tmp_track = tmp_mcP->getRelated<Track>();
607 const TrackFitResult* tmp_tfr = tmp_track->getTrackFitResultWithClosestMass(Const::ChargedStable(abs(tmp_mcP->getPDG())));
608 if (tmp_tfr->getChargeSign()*tmp_mcP->getCharge() > 0)
616 double seenInPXD(
const Particle* p)
618 if (p->getParticleSource() == Particle::EParticleSourceObject::c_Composite)
620 const MCParticle* mcp = p->getMCParticle();
622 return mcp->hasSeenInDetector(Const::PXD);
625 double seenInSVD(
const Particle* p)
627 if (p->getParticleSource() == Particle::EParticleSourceObject::c_Composite)
629 const MCParticle* mcp = p->getMCParticle();
631 return mcp->hasSeenInDetector(Const::SVD);
634 double seenInCDC(
const Particle* p)
636 if (p->getParticleSource() == Particle::EParticleSourceObject::c_Composite)
638 const MCParticle* mcp = p->getMCParticle();
640 return mcp->hasSeenInDetector(Const::CDC);
643 double seenInTOP(
const Particle* p)
645 if (p->getParticleSource() == Particle::EParticleSourceObject::c_Composite)
647 const MCParticle* mcp = p->getMCParticle();
649 return mcp->hasSeenInDetector(Const::TOP);
652 double seenInECL(
const Particle* p)
654 if (p->getParticleSource() == Particle::EParticleSourceObject::c_Composite)
656 const MCParticle* mcp = p->getMCParticle();
658 return mcp->hasSeenInDetector(Const::ECL);
661 double seenInARICH(
const Particle* p)
663 if (p->getParticleSource() == Particle::EParticleSourceObject::c_Composite)
665 const MCParticle* mcp = p->getMCParticle();
667 return mcp->hasSeenInDetector(Const::ARICH);
670 double seenInKLM(
const Particle* p)
672 if (p->getParticleSource() == Particle::EParticleSourceObject::c_Composite)
674 const MCParticle* mcp = p->getMCParticle();
676 return mcp->hasSeenInDetector(Const::KLM);
679 int genNStepsToDaughter(
const Particle* p,
const std::vector<double>& arguments)
681 if (arguments.size() != 1)
682 B2FATAL(
"Wrong number of arguments for genNStepsToDaughter");
684 const MCParticle* mcp = p->getMCParticle();
686 B2WARNING(
"No MCParticle is associated to the particle");
690 int nChildren = p->getNDaughters();
691 if (arguments[0] >= nChildren) {
695 const Particle* daugP = p->getDaughter(arguments[0]);
700 B2WARNING(
"No MCParticle is associated to the i-th daughter");
704 if (nChildren == 1)
return 1;
706 std::vector<int> genMothers;
708 auto match = std::find(genMothers.begin(), genMothers.end(), mcp->getIndex());
709 return match - genMothers.begin();
712 int genNMissingDaughter(
const Particle* p,
const std::vector<double>& arguments)
714 if (arguments.size() < 1)
715 B2FATAL(
"Wrong number of arguments for genNMissingDaughter");
717 const std::vector<int> PDGcodes(arguments.begin(), arguments.end());
719 const MCParticle* mcp = p->getMCParticle();
721 B2WARNING(
"No MCParticle is associated to the particle");
728 double getHEREnergy(
const Particle*)
730 static DBObjPtr<BeamParameters> beamParamsDB;
731 return (beamParamsDB->getHER()).E();
734 double getLEREnergy(
const Particle*)
736 static DBObjPtr<BeamParameters> beamParamsDB;
737 return (beamParamsDB->getLER()).E();
740 double getCrossingAngleX(
const Particle*)
743 static DBObjPtr<BeamParameters> beamParamsDB;
744 B2Vector3D herVec = beamParamsDB->getHER().Vect();
745 B2Vector3D lerVec = beamParamsDB->getLER().Vect();
752 return herVec.Angle(-lerVec);
755 double getCrossingAngleY(
const Particle*)
758 static DBObjPtr<BeamParameters> beamParamsDB;
759 B2Vector3D herVec = beamParamsDB->getHER().Vect();
760 B2Vector3D lerVec = beamParamsDB->getLER().Vect();
767 return herVec.Angle(-lerVec);
771 double particleClusterMatchWeight(
const Particle* particle)
779 const MCParticle* matchedToParticle = particle->getMCParticle();
781 int matchedToIndex = matchedToParticle->getArrayIndex();
783 const ECLCluster* cluster = particle->getECLCluster();
786 const auto mcps = cluster->getRelationsTo<MCParticle>();
787 for (
unsigned int i = 0; i < mcps.size(); ++i)
788 if (mcps[i]->getArrayIndex() == matchedToIndex)
789 return mcps.weight(i);
794 double particleClusterBestMCMatchWeight(
const Particle* particle)
806 const ECLCluster* cluster = particle->getECLCluster();
812 auto mcps = cluster->getRelationsTo<MCParticle>();
815 std::vector<double> weights;
816 for (
unsigned int i = 0; i < mcps.size(); ++i)
817 weights.emplace_back(mcps.weight(i));
820 std::sort(weights.begin(), weights.end());
821 std::reverse(weights.begin(), weights.end());
825 double particleClusterBestMCPDGCode(
const Particle* particle)
835 const ECLCluster* cluster = particle->getECLCluster();
838 auto mcps = cluster->getRelationsTo<MCParticle>();
841 std::vector<std::pair<double, int>> weightsAndIndices;
842 for (
unsigned int i = 0; i < mcps.size(); ++i)
843 weightsAndIndices.emplace_back(mcps.weight(i), i);
846 std::sort(weightsAndIndices.begin(), weightsAndIndices.end(),
847 ValueIndexPairSorting::higherPair<
decltype(weightsAndIndices)::value_type>);
849 return mcps.object(weightsAndIndices[0].second)->getPDG();
852 double particleClusterTotalMCMatchWeight(
const Particle* particle)
854 const ECLCluster* cluster = particle->getECLCluster();
857 auto mcps = cluster->getRelationsTo<MCParticle>();
860 double weightsum = 0;
861 for (
unsigned int i = 0; i < mcps.size(); ++i)
862 weightsum += mcps.weight(i);
868 void getKlongWeightMap(
const Particle* particle, std::map<int, double>& mapMCParticleIndxAndWeight)
870 const ECLCluster* cluster = particle->getECLCluster();
871 auto mcps = cluster->getRelationsTo<MCParticle>();
873 for (
unsigned int i = 0; i < mcps.size(); ++i) {
874 double weight = mcps.weight(i);
875 const MCParticle* mcp = mcps[i];
878 if (mcp->getPDG() == 130) {
879 int index = mcp->getArrayIndex();
880 if (mapMCParticleIndxAndWeight.find(index) != mapMCParticleIndxAndWeight.end()) {
881 mapMCParticleIndxAndWeight.at(index) = mapMCParticleIndxAndWeight.at(index) + weight;
883 mapMCParticleIndxAndWeight.insert({index, weight});
887 mcp = mcp->getMother();
893 double particleClusterTotalMCMatchWeightForKlong(
const Particle* particle)
895 const ECLCluster* cluster = particle->getECLCluster();
898 auto mcps = cluster->getRelationsTo<MCParticle>();
901 std::map<int, double> mapMCParticleIndxAndWeight;
902 getKlongWeightMap(particle, mapMCParticleIndxAndWeight);
904 double totalWeight = 0;
905 for (
const auto& map : mapMCParticleIndxAndWeight) {
906 totalWeight += map.second;
912 double particleClusterTotalMCMatchWeightForBestKlong(
const Particle* particle)
914 const ECLCluster* cluster = particle->getECLCluster();
917 auto mcps = cluster->getRelationsTo<MCParticle>();
920 std::map<int, double> mapMCParticleIndxAndWeight;
921 getKlongWeightMap(particle, mapMCParticleIndxAndWeight);
923 if (mapMCParticleIndxAndWeight.size() == 0)
926 auto maxMap = std::max_element(mapMCParticleIndxAndWeight.begin(), mapMCParticleIndxAndWeight.end(),
927 [](
const auto & x,
const auto & y) { return x.second < y.second; }
930 return maxMap->second;
933 double isBBCrossfeed(
const Particle* particle)
935 if (particle ==
nullptr)
938 int pdg = particle->getPDGCode();
939 if (abs(pdg) != 511 && abs(pdg) != 521 && abs(pdg) != 531)
942 std::vector<const Particle*> daughters = particle->getFinalStateDaughters();
943 int nDaughters = daughters.size();
946 std::vector<int> mother_ids;
948 for (
int j = 0; j < nDaughters; ++j) {
949 const MCParticle* curMCParticle = daughters[j]->
getMCParticle();
950 while (curMCParticle !=
nullptr) {
951 pdg = curMCParticle->getPDG();
952 if (abs(pdg) == 511 || abs(pdg) == 521 || abs(pdg) == 531) {
953 mother_ids.emplace_back(curMCParticle->getArrayIndex());
956 const MCParticle* curMCMother = curMCParticle->getMother();
957 curMCParticle = curMCMother;
959 if (curMCParticle ==
nullptr) {
964 std::set<int> distinctIDs = std::set(mother_ids.begin(), mother_ids.end());
965 if (distinctIDs.size() == 1)
971 int ancestorBIndex(
const Particle* particle)
973 const MCParticle* mcpart = particle->getMCParticle();
976 int pdg = std::abs(mcpart->getPDG());
978 if ((pdg == 521) || (pdg == 511))
979 return mcpart->getArrayIndex();
981 mcpart = mcpart->getMother();
987 VARIABLE_GROUP(
"MC matching and MC truth");
988 REGISTER_VARIABLE(
"isSignal", isSignal,
989 "1.0 if Particle is correctly reconstructed (SIGNAL), 0.0 if not, and NaN if no related MCParticle could be found. \n"
990 "It behaves according to DecayStringGrammar.");
991 REGISTER_VARIABLE(
"isSignalAcceptWrongFSPs", isSignalAcceptWrongFSPs,
992 "1.0 if Particle is almost correctly reconstructed (SIGNAL), 0.0 if not, and NaN if no related MCParticle could be found.\n"
993 "Misidentification of charged FSP is allowed.");
994 REGISTER_VARIABLE(
"isPrimarySignal", isPrimarySignal,
995 "1.0 if Particle is correctly reconstructed (SIGNAL) and primary, 0.0 if not, and NaN if no related MCParticle could be found");
996 REGISTER_VARIABLE(
"isSignalAcceptBremsPhotons", isSignalAcceptBremsPhotons,
997 "1.0 if Particle is correctly reconstructed (SIGNAL), 0.0 if not, and NaN if no related MCParticle could be found.\n"
998 "Particles with gamma daughters attached through the bremsstrahlung recovery modules are allowed.");
999 REGISTER_VARIABLE(
"genMotherPDG", genMotherPDG,
1000 "Check the PDG code of a particles MC mother particle");
1001 REGISTER_VARIABLE(
"genMotherPDG(i)", genNthMotherPDG,
1002 "Check the PDG code of a particles n-th MC mother particle by providing an argument. 0 is first mother, 1 is grandmother etc. :noindex:");
1004 REGISTER_VARIABLE(
"genQ2PmPd(i,j,...)", genQ2PmPd, R
"DOC(
1005 Returns the generated four momentum transfer squared :math:`q^2` calculated as :math:`q^2 = (p_m - p_{d_i} - p_{d_j} - ...)^2`.
1007 Here :math:`p_m` is the four momentum of the given (mother) particle,
1008 and :math:`p_{d_{i,j,...}}` are the daughter particles with indices given as arguments .
1009 The ordering of daughters is as defined in the DECAY.DEC file used in the generation, with the numbering starting at :math:`N=0`.
1011 Returns NaN if no related MCParticle could be found.
1012 Returns NaN if any of the given indices is larger than the number of daughters of the given particle.
1014 )DOC", ":math:`[\\text{GeV}/\\text{c}]^2`");
1016 REGISTER_VARIABLE(
"genMotherID", genMotherIndex,
1017 "Check the array index of a particles generated mother");
1018 REGISTER_VARIABLE(
"genMotherID(i)", genNthMotherIndex,
1019 "Check the array index of a particle n-th MC mother particle by providing an argument. 0 is first mother, 1 is grandmother etc. :noindex:");
1023 REGISTER_VARIABLE(
"isBBCrossfeed", isBBCrossfeed,
1024 "Returns 1 for crossfeed in reconstruction of given B meson, 0 for no crossfeed and NaN for no true B meson or failed truthmatching.");
1025 REGISTER_VARIABLE(
"ancestorBIndex", ancestorBIndex,
1026 "Returns array index of B ancestor, or -1 if no B or no MC-matching is found.");
1027 REGISTER_VARIABLE(
"genMotherP", genMotherP,
1028 "Generated momentum of a particles MC mother particle\n\n",
"GeV/c");
1029 REGISTER_VARIABLE(
"genParticleID", genParticleIndex,
1030 "Check the array index of a particle's related MCParticle");
1031 REGISTER_VARIABLE(
"isSignalAcceptMissingNeutrino",
1032 isSignalAcceptMissingNeutrino,
1033 "Same as isSignal, but also accept missing neutrino");
1034 REGISTER_VARIABLE(
"isSignalAcceptMissingMassive",
1035 isSignalAcceptMissingMassive,
1036 "Same as isSignal, but also accept missing massive particle");
1037 REGISTER_VARIABLE(
"isSignalAcceptMissingGamma",
1038 isSignalAcceptMissingGamma,
1039 "Same as isSignal, but also accept missing gamma, such as B -> K* gamma, pi0 -> gamma gamma");
1040 REGISTER_VARIABLE(
"isSignalAcceptMissing",
1041 isSignalAcceptMissing,
1042 "Same as isSignal, but also accept missing particle");
1043 REGISTER_VARIABLE(
"isMisidentified", isMisidentified,
1044 "Return 1 if the particle is misidentified: at least one of the final state particles has the wrong PDG code assignment (including wrong charge), 0 if PDG code is fine, and NaN if no related MCParticle could be found.");
1045 REGISTER_VARIABLE(
"isWrongCharge", isWrongCharge,
1046 "Return 1 if the charge of the particle is wrongly assigned, 0 if it's the correct charge, and NaN if no related MCParticle could be found.");
1047 REGISTER_VARIABLE(
"isCloneTrack", isCloneTrack,
1048 "Return 1 if the charged final state particle comes from a cloned track, 0 if not a clone. Returns NAN if neutral, composite, or MCParticle not found (like for data or if not MCMatched)");
1049 REGISTER_VARIABLE(
"isOrHasCloneTrack", isOrHasCloneTrack,
1050 "Return 1 if the particle is a clone track or has a clone track as a daughter, 0 otherwise.");
1051 REGISTER_VARIABLE(
"mcPDG", particleMCMatchPDGCode,
1052 "The PDG code of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).");
1053 REGISTER_VARIABLE(
"mcErrors", particleMCErrors,
1054 "The bit pattern indicating the quality of MC match (see MCMatching::MCErrorFlags)");
1055 REGISTER_VARIABLE(
"mcMatchWeight", particleMCMatchWeight,
1056 "The weight of the Particle -> MCParticle relation (only for the first Relation = largest weight).");
1057 REGISTER_VARIABLE(
"nMCMatches", particleNumberOfMCMatch,
1058 "The number of relations of this Particle to MCParticle.");
1059 REGISTER_VARIABLE(
"mcDecayTime", particleMCMatchDecayTime,
1060 "The decay time of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1062 REGISTER_VARIABLE(
"mcLifeTime", particleMCMatchLifeTime,
1063 "The life time of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1065 REGISTER_VARIABLE(
"mcPX", particleMCMatchPX,
1066 "The px of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1068 REGISTER_VARIABLE(
"mcPY", particleMCMatchPY,
1069 "The py of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1071 REGISTER_VARIABLE(
"mcPZ", particleMCMatchPZ,
1072 "The pz of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1074 REGISTER_VARIABLE(
"mcPT", particleMCMatchPT,
1075 "The pt of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1077 REGISTER_VARIABLE(
"mcE", particleMCMatchE,
1078 "The energy of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1080 REGISTER_VARIABLE(
"mcP", particleMCMatchP,
1081 "The total momentum of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1083 REGISTER_VARIABLE(
"mcPhi", particleMCMatchPhi,
1084 "The phi of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1086 REGISTER_VARIABLE(
"mcTheta", particleMCMatchTheta,
1087 "The theta of matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).\n\n",
1089 REGISTER_VARIABLE(
"nMCDaughters", mcParticleNDaughters,
1090 "The number of daughters of the matched MCParticle, NaN if no match. Requires running matchMCTruth() on the reconstructed particles, or a particle list filled with generator particles (MCParticle objects).");
1091 REGISTER_VARIABLE(
"mcRecoilMass", particleMCRecoilMass,
1092 "The mass recoiling against the particles attached as particle's daughters calculated using MC truth values.\n\n",
1093 "GeV/:math:`\\text{c}^2`");
1094 REGISTER_VARIABLE(
"mcCosThetaBetweenParticleAndNominalB",
1095 particleMCCosThetaBetweenParticleAndNominalB,
1096 "Cosine of the angle in CMS between momentum the particle and a nominal B particle. In this calculation, the momenta of all descendant neutrinos are subtracted from the B momentum.");
1099 REGISTER_VARIABLE(
"mcSecPhysProc", mcParticleSecondaryPhysicsProcess,
1101Returns the secondary physics process flag, which is set by Geant4 on secondary particles. It indicates the type of process that produced the particle.
1103Returns NaN if the particle is not matched to a MCParticle.
1105Returns -1 in case of unknown process.
1107Returns 0 if the particle is primary, i.e. produced by the event generator and not Geant4. Particles produced by Geant4 (i.e. secondary particles) include those produced in interaction with detector material, Bremsstrahlung, and the decay products of long-lived particles (e.g. muons, pions, K_S0, K_L0, Lambdas, ...).
1109List of possible values (taken from the Geant4 source of
1110`G4DecayProcessType <https://github.com/Geant4/geant4/blob/v10.6.3/source/processes/decay/include/G4DecayProcessType.hh>`_,
1111`G4HadronicProcessType <https://github.com/Geant4/geant4/blob/v10.6.3/source/processes/hadronic/management/include/G4HadronicProcessType.hh>`_,
1112`G4TransportationProcessType <https://github.com/Geant4/geant4/blob/v10.6.3/source/processes/transportation/include/G4TransportationProcessType.hh>`_ and
1113`G4EmProcessSubType <https://github.com/Geant4/geant4/blob/v10.6.3/source/processes/electromagnetic/utils/include/G4EmProcessSubType.hh>`_)
1115* 1 Coulomb scattering
1118* 4 Pair production by charged
1120* 6 Annihilation to mu mu
1121* 7 Annihilation to hadrons
1123* 9 Electron general process
1124* 10 Multiple scattering
1126* 12 Photo-electric effect
1127* 13 Compton scattering
1128* 14 Gamma conversion
1129* 15 Gamma conversion to mu mu
1130* 16 Gamma general process
1133* 23 Synchrotron radiation
1134* 24 Transition radiation
1136* 92 Coupled transportation
1138* 121 Hadron inelastic
1140* 132 Mu atomic capture
1144* 161 Charge exchange
1146* 202 Decay with spin
1147* 203 Decay (pion make spin)
1148* 210 Radioactive decay
1153.. note:: This is what `modularAnalysis.printMCParticles` shows as ``creation process`` when ``showStatus`` is set to ``True``.
1155 REGISTER_VARIABLE("mcParticleStatus", mcParticleStatus,
1156 "Returns status bits of related MCParticle or NaN if MCParticle relation is not set.");
1157 REGISTER_VARIABLE(
"mcPrimary", particleMCPrimaryParticle,
1158 "Returns 1 if Particle is related to primary MCParticle, 0 if Particle is related to non - primary MCParticle, "
1159 "NaN if Particle is not related to MCParticle.");
1160 REGISTER_VARIABLE(
"mcVirtual", particleMCVirtualParticle,
1161 "Returns 1 if Particle is related to virtual MCParticle, 0 if Particle is related to non - virtual MCParticle, "
1162 "NaN if Particle is not related to MCParticle.")
1163 REGISTER_VARIABLE("mcInitial", particleMCInitialParticle,
1164 "Returns 1 if Particle is related to initial MCParticle, 0 if Particle is related to non - initial MCParticle, "
1165 "NaN if Particle is not related to MCParticle.")
1166 REGISTER_VARIABLE("mcISR", particleMCISRParticle,
1167 "Returns 1 if Particle is related to ISR MCParticle, 0 if Particle is related to non - ISR MCParticle, "
1168 "NaN if Particle is not related to MCParticle.")
1169 REGISTER_VARIABLE("mcFSR", particleMCFSRParticle,
1170 "Returns 1 if Particle is related to FSR MCParticle, 0 if Particle is related to non - FSR MCParticle ,"
1171 "NaN if Particle is not related to MCParticle.")
1172 REGISTER_VARIABLE("mcPhotos", particleMCPhotosParticle,
1173 "Returns 1 if Particle is related to Photos MCParticle, 0 if Particle is related to non - Photos MCParticle, "
1174 "NaN if Particle is not related to MCParticle.")
1175 REGISTER_VARIABLE("generatorEventWeight", generatorEventWeight,
1176 "[Eventbased] Returns the event weight produced by the event generator")
1178 REGISTER_VARIABLE("genNStepsToDaughter(i)", genNStepsToDaughter,
1179 "Returns number of steps to i-th daughter from the particle at generator level. "
1180 "NaN if no MCParticle is associated to the particle or i-th daughter. "
1181 "NaN if i-th daughter does not exist.");
1182 REGISTER_VARIABLE("genNMissingDaughter(PDG)", genNMissingDaughter,
1183 "Returns the number of missing daughters having assigned PDG codes. "
1184 "NaN if no MCParticle is associated to the particle.");
1185 REGISTER_VARIABLE("Eher", getHEREnergy,
R"DOC(
1186[Eventbased] The nominal HER energy used by the generator.
1188.. warning:: This variable does not make sense for data.
1191 REGISTER_VARIABLE("Eler", getLEREnergy,
R"DOC(
1192[Eventbased] The nominal LER energy used by the generator.
1194.. warning:: This variable does not make sense for data.
1197 REGISTER_VARIABLE("XAngle", getCrossingAngleX,
R"DOC(
1198[Eventbased] The nominal beam crossing angle in the x-z plane from generator level beam kinematics.
1200.. warning:: This variable does not make sense for data.
1203 REGISTER_VARIABLE("YAngle", getCrossingAngleY,
R"DOC(
1204[Eventbased] The nominal beam crossing angle in the y-z plane from generator level beam kinematics.
1206.. warning:: This variable does not make sense for data.
1210 VARIABLE_GROUP("Generated tau decay information");
1211 REGISTER_VARIABLE("tauPlusMCMode", tauPlusMcMode,
1212 "[Eventbased] Decay ID for the positive tau lepton in a tau pair generated event.");
1213 REGISTER_VARIABLE("tauMinusMCMode", tauMinusMcMode,
1214 "[Eventbased] Decay ID for the negative tau lepton in a tau pair generated event.");
1215 REGISTER_VARIABLE("tauPlusMCProng", tauPlusMcProng,
1216 "[Eventbased] Prong for the positive tau lepton in a tau pair generated event.");
1217 REGISTER_VARIABLE("tauMinusMCProng", tauMinusMcProng,
1218 "[Eventbased] Prong for the negative tau lepton in a tau pair generated event.");
1219 REGISTER_VARIABLE("tauPlusEgstar", tauPlusEgstar,
1220 "[Eventbased] Energy of radiated gamma from positive tau lepton in a tau pair generated event.");
1221 REGISTER_VARIABLE("tauMinusEgstar", tauMinusEgstar,
1222 "[Eventbased] Energy of radiated gamma from negative tau lepton in a tau pair generated event.");
1224 VARIABLE_GROUP("MC particle seen in subdetectors");
1225 REGISTER_VARIABLE("isReconstructible", isReconstructible,
1226 "Checks charged particles were seen in the SVD and neutrals in the ECL, returns 1.0 if so, 0.0 if not, NaN for composite particles or if no related MCParticle could be found. Useful for generator studies, not for reconstructed particles.");
1227 REGISTER_VARIABLE("seenInPXD", seenInPXD,
1228 "Returns 1.0 if the MC particle was seen in the PXD, 0.0 if not, NaN for composite particles or if no related MCParticle could be found. Useful for generator studies, not for reconstructed particles.");
1229 REGISTER_VARIABLE("isTrackFound", isTrackFound,
1230 "works on charged stable particle list created from MCParticles, returns NaN if not ; returns 1.0 if there is a reconstructed track related to the charged stable MCParticle with the correct charge, return -1.0 if the reconstructed track has the wrong charge, return 0.0 when no reconstructed track is found.");
1231 REGISTER_VARIABLE("seenInSVD", seenInSVD,
1232 "Returns 1.0 if the MC particle was seen in the SVD, 0.0 if not, NaN for composite particles or if no related MCParticle could be found. Useful for generator studies, not for reconstructed particles.");
1233 REGISTER_VARIABLE("seenInCDC", seenInCDC,
1234 "Returns 1.0 if the MC particle was seen in the CDC, 0.0 if not, NaN for composite particles or if no related MCParticle could be found. Useful for generator studies, not for reconstructed particles.");
1235 REGISTER_VARIABLE("seenInTOP", seenInTOP,
1236 "Returns 1.0 if the MC particle was seen in the TOP, 0.0 if not, NaN for composite particles or if no related MCParticle could be found. Useful for generator studies, not for reconstructed particles.");
1237 REGISTER_VARIABLE("seenInECL", seenInECL,
1238 "Returns 1.0 if the MC particle was seen in the ECL, 0.0 if not, NaN for composite particles or if no related MCParticle could be found. Useful for generator studies, not for reconstructed particles.");
1239 REGISTER_VARIABLE("seenInARICH", seenInARICH,
1240 "Returns 1.0 if the MC particle was seen in the ARICH, 0.0 if not, NaN for composite particles or if no related MCParticle could be found. Useful for generator studies, not for reconstructed particles.");
1241 REGISTER_VARIABLE("seenInKLM", seenInKLM,
1242 "Returns 1.0 if the MC particle was seen in the KLM, 0.0 if not, NaN for composite particles or if no related MCParticle could be found. Useful for generator studies, not for reconstructed particles.");
1244 VARIABLE_GROUP("MC Matching for ECLClusters");
1245 REGISTER_VARIABLE("clusterMCMatchWeight", particleClusterMatchWeight,
1246 "Returns the weight of the ECLCluster -> MCParticle relation for the MCParticle matched to the particle. "
1247 "Returns NaN if: no cluster is related to the particle, the particle is not MC matched, or if there are no mcmatches for the cluster. "
1248 "Returns -1 if the cluster *was* matched to particles, but not the match of the particle provided.");
1249 REGISTER_VARIABLE("clusterBestMCMatchWeight", particleClusterBestMCMatchWeight,
1250 "Returns the weight of the ECLCluster -> MCParticle relation for the relation with the largest weight.");
1251 REGISTER_VARIABLE("clusterBestMCPDG", particleClusterBestMCPDGCode,
1252 "Returns the PDG code of the MCParticle for the ECLCluster -> MCParticle relation with the largest weight.");
1253 REGISTER_VARIABLE("clusterTotalMCMatchWeight", particleClusterTotalMCMatchWeight,
1254 "Returns the sum of all weights of the ECLCluster -> MCParticles relations.");
1256 REGISTER_VARIABLE("clusterTotalMCMatchWeightForKlong", particleClusterTotalMCMatchWeightForKlong,
1257 "Returns the sum of all weights of the ECLCluster -> MCParticles relations when MCParticle is a Klong or daughter of a Klong");
1258 REGISTER_VARIABLE("clusterTotalMCMatchWeightForBestKlong", particleClusterTotalMCMatchWeightForBestKlong,
1259 "Returns the sum of all weights of the ECLCluster -> MCParticles relations when MCParticle is the same Klong or daughter of the Klong. If multiple MC Klongs are related to the ECLCluster, returns the sum of weights for the best matched Klong.");
void SetX(DataType x)
set X/1st-coordinate
void SetY(DataType y)
set Y/2nd-coordinate
static const ParticleSet chargedStableSet
set of charged stable particles
static const double doubleNaN
quiet_NaN
@ c_IsFSRPhoton
bit 7: Particle is from finial state radiation
@ c_Initial
bit 5: Particle is initial such as e+ or e- and not going to Geant4
@ c_IsPHOTOSPhoton
bit 8: Particle is an radiative photon from PHOTOS
@ c_PrimaryParticle
bit 0: Particle is primary particle.
@ c_IsVirtual
bit 4: Particle is virtual and not going to Geant4.
@ c_IsISRPhoton
bit 6: Particle is from initial state radiation
const MCParticle * getMCParticle() const
Returns the pointer to the MCParticle object that was used to create this Particle (ParticleType == c...
static const ReferenceFrame & GetCurrent()
Get current rest frame.
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Abstract base class for different kinds of events.
static int countMissingParticle(const Belle2::Particle *particle, const Belle2::MCParticle *mcParticle, const std::vector< int > &daughterPDG)
Count the number of missing daughters of the 'particle'.
@ c_Correct
This Particle and all its daughters are perfectly reconstructed.
@ c_MisID
One of the charged final state particles is mis-identified, i.e.
static int getMCErrors(const Belle2::Particle *particle, const Belle2::MCParticle *mcParticle=nullptr)
Returns quality indicator of the match as a bit pattern where the individual bits indicate the the ty...
static void fillGenMothers(const Belle2::MCParticle *mcP, std::vector< int > &genMCPMothers)
Fills vector with array (1-based) indices of all generator ancestors of given MCParticle.