10#include <analysis/variables/EventVariables.h>
13#include <analysis/VariableManager/Manager.h>
16#include <framework/datastore/StoreArray.h>
17#include <framework/datastore/StoreObjPtr.h>
18#include <framework/dataobjects/EventMetaData.h>
21#include <analysis/dataobjects/Particle.h>
22#include <analysis/dataobjects/EventKinematics.h>
24#include <mdst/dataobjects/MCParticle.h>
25#include <mdst/dataobjects/Track.h>
26#include <mdst/dataobjects/ECLCluster.h>
27#include <mdst/dataobjects/KLMCluster.h>
28#include <mdst/dataobjects/V0.h>
30#include <framework/dataobjects/EventT0.h>
31#include <mdst/dataobjects/EventLevelTriggerTimeInfo.h>
34#include <framework/database/DBObjPtr.h>
35#include <mdst/dbobjects/BeamSpot.h>
37#include <analysis/utility/PCmsLabTransform.h>
39#include <framework/core/Environment.h>
40#include <framework/logging/Logger.h>
51 bool isMC(
const Particle*)
56 bool isContinuumEvent(
const Particle*)
58 return (isNotContinuumEvent(
nullptr) == 1 ? 0 : 1);
61 bool isChargedBEvent(
const Particle*)
63 StoreArray<MCParticle> mcParticles;
64 for (
const auto& mcp : mcParticles) {
65 int pdg_no = mcp.getPDG();
66 if (abs(pdg_no) == 521)
return 1.0;
71 double isUnmixedBEvent(
const Particle*)
73 StoreArray<MCParticle> mcParticles;
74 std::vector<int> bPDGs;
75 for (
const auto& mcp : mcParticles) {
76 int pdg_no = mcp.getPDG();
77 if (abs(pdg_no) == 511) bPDGs.push_back(pdg_no);
79 if (bPDGs.size() == 2) {
80 return bPDGs[0] * bPDGs[1] < 0;
85 bool isNotContinuumEvent(
const Particle*)
87 StoreArray<MCParticle> mcParticles;
88 for (
const MCParticle& mcp : mcParticles) {
89 int pdg_no = mcp.getPDG();
90 if (mcp.getMother() ==
nullptr &&
95 (pdg_no == 9000553) ||
102 int nMCParticles(
const Particle*)
104 StoreArray<MCParticle> mcps;
105 return mcps.getEntries();
108 int nPrimaryMCParticles(
const Particle*)
111 StoreArray<MCParticle> mcps;
112 for (
const auto& mcp : mcps)
113 if (mcp.isPrimaryParticle())
118 int nInitialPrimaryMCParticles(
const Particle*)
121 StoreArray<MCParticle> mcps;
122 for (
const auto& mcp : mcps)
123 if (mcp.isInitial() and mcp.isPrimaryParticle())
128 int nVirtualPrimaryMCParticles(
const Particle*)
131 StoreArray<MCParticle> mcps;
132 for (
const auto& mcp : mcps)
133 if (mcp.isVirtual() and mcp.isPrimaryParticle())
138 int nTracks(
const Particle*)
140 StoreArray<Track> tracks;
141 return tracks.getEntries();
144 int nV0s(
const Particle*)
147 return v0s.getEntries();
150 int nValidV0s(
const Particle*)
155 for (
int i = 0; i < v0s.getEntries(); i++) {
156 const V0* v0 = v0s[i];
157 if (v0->getTrackFitResults().first->getChargeSign() == v0->getTrackFitResults().second->getChargeSign())
165 int nNeutralECLClusters(
const Particle*,
const std::vector<double>& hypothesis)
167 if (hypothesis.size() != 1)
168 B2FATAL(
"Number of arguments of nNeutralECLClusters must be 1.");
170 int hypothesis_int = std::lround(hypothesis[0]);
171 if (hypothesis_int < 1 or hypothesis_int > 2) {
172 B2WARNING(
"nNeutralECLClusters:: Hypothesis must be 1 (nPhotons) or 2 (NeutralHadron)");
176 StoreArray<ECLCluster> eclClusters;
178 for (
int i = 0; i < eclClusters.getEntries(); i++) {
179 auto cluster = eclClusters[i];
180 if (!cluster->isNeutral())
190 int nChargeZeroTrackFits(
const Particle*)
192 StoreArray<TrackFitResult> tfrs;
194 for (
const auto& t : tfrs)
195 if (t.getChargeSign() == 0) out++;
199 double belleECLEnergy(
const Particle*)
201 StoreArray<ECLCluster> eclClusters;
203 for (
int i = 0; i < eclClusters.getEntries(); ++i) {
213 int nKLMClusters(
const Particle*)
215 StoreArray<KLMCluster> klmClusters;
216 return klmClusters.getEntries();
219 int expNum(
const Particle*)
221 StoreObjPtr<EventMetaData> evtMetaData;
222 int exp_no = evtMetaData->getExperiment();
226 int productionIdentifier(
const Particle*)
228 StoreObjPtr<EventMetaData> evtMetaData;
229 int eventProduction = evtMetaData->getProduction();
230 return eventProduction;
233 int evtNum(
const Particle*)
235 StoreObjPtr<EventMetaData> evtMetaData;
236 int evt_no = evtMetaData->getEvent();
240 int runNum(
const Particle*)
242 StoreObjPtr<EventMetaData> evtMetaData;
243 int run_no = evtMetaData->getRun();
248 double getCMSEnergy(
const Particle*)
251 return T.getCMSEnergy();
254 double getBeamPx(
const Particle*)
257 return (T.getBeamFourMomentum()).Px();
260 double getBeamPy(
const Particle*)
263 return (T.getBeamFourMomentum()).Py();
266 double getBeamPz(
const Particle*)
269 return (T.getBeamFourMomentum()).Pz();
272 double getBeamE(
const Particle*)
275 return (T.getBeamFourMomentum()).E();
279 static ROOT::Math::PxPyPzEVector getTotalMcFinalStateMomentum()
281 StoreArray<MCParticle> mcps;
282 ROOT::Math::PxPyPzEVector sum;
283 for (
const auto& mcp : mcps) {
285 if (mcp.isPrimaryParticle() and not(mcp.isInitial() or mcp.isVirtual())) {
286 const MCParticle* mother = mcp.getMother();
288 if (not mother or not(mother->isPrimaryParticle() and not(mother->isInitial() or mother->isVirtual())))
289 sum += mcp.get4Vector();
297 static ROOT::Math::PxPyPzEVector getMcBeamMomentum(
int charge)
299 StoreArray<MCParticle> mcps;
300 for (
const auto& mcp : mcps) {
301 if (mcp.isInitial() && mcp.getPDG() == -charge * 11) {
302 return mcp.get4Vector();
311 static ROOT::Math::PxPyPzEVector getBeamMomentum(
int charge)
314 double EbeamCM = T.getCMSEnergy() / 2;
317 ROOT::Math::PxPyPzEVector pCM(0, 0, -charge * pBeamCM, EbeamCM);
319 return T.cmsToLab(pCM);
323 double getMcPxHER(
const Particle*) {
return getMcBeamMomentum(-1).Px();}
324 double getMcPyHER(
const Particle*) {
return getMcBeamMomentum(-1).Py();}
325 double getMcPzHER(
const Particle*) {
return getMcBeamMomentum(-1).Pz();}
327 double getMcPxLER(
const Particle*) {
return getMcBeamMomentum(+1).Px();}
328 double getMcPyLER(
const Particle*) {
return getMcBeamMomentum(+1).Py();}
329 double getMcPzLER(
const Particle*) {
return getMcBeamMomentum(+1).Pz();}
332 double getPxHER(
const Particle*) {
return getBeamMomentum(-1).Px();}
333 double getPyHER(
const Particle*) {
return getBeamMomentum(-1).Py();}
334 double getPzHER(
const Particle*) {
return getBeamMomentum(-1).Pz();}
336 double getPxLER(
const Particle*) {
return getBeamMomentum(+1).Px();}
337 double getPyLER(
const Particle*) {
return getBeamMomentum(+1).Py();}
338 double getPzLER(
const Particle*) {
return getBeamMomentum(+1).Pz();}
341 double getCMSEnergyMC(
const Particle*)
343 StoreArray<MCParticle> mcps;
346 }
else return getTotalMcFinalStateMomentum().M();
349 double getTotalEnergyMC(
const Particle*)
351 StoreArray<MCParticle> mcps;
354 }
else return getTotalMcFinalStateMomentum().E();
357 double getGenIPX(
const Particle*)
361 StoreArray<MCParticle> mcps;
362 for (
const auto& mcp : mcps)
363 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
364 return mcp.getVertex().X();
368 double getGenIPY(
const Particle*)
370 StoreArray<MCParticle> mcps;
371 for (
const auto& mcp : mcps)
372 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
373 return mcp.getVertex().Y();
377 double getGenIPZ(
const Particle*)
379 StoreArray<MCParticle> mcps;
380 for (
const auto& mcp : mcps)
381 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
382 return mcp.getVertex().Z();
386 double getIPX(
const Particle*)
388 static DBObjPtr<BeamSpot> beamSpotDB;
389 if (!beamSpotDB.isValid())
391 return (beamSpotDB->getIPPosition()).X();
394 double getIPY(
const Particle*)
396 static DBObjPtr<BeamSpot> beamSpotDB;
397 if (!beamSpotDB.isValid())
399 return (beamSpotDB->getIPPosition()).Y();
402 double getIPZ(
const Particle*)
404 static DBObjPtr<BeamSpot> beamSpotDB;
405 if (!beamSpotDB.isValid())
407 return (beamSpotDB->getIPPosition()).Z();
410 double ipCovMatrixElement(
const Particle*,
const std::vector<double>& element)
412 int elementI = std::lround(element[0]);
413 int elementJ = std::lround(element[1]);
415 bool isOutOfRange =
false;
416 if (elementI < 0 || elementI > 2) {
417 B2WARNING(
"Requested IP covariance matrix element is out of boundaries [0 - 2]:" << LogVar(
"i", elementI));
420 if (elementJ < 0 || elementJ > 2) {
421 B2WARNING(
"Requested IP covariance matrix element is out of boundaries [0 - 2]:" << LogVar(
"j", elementJ));
427 static DBObjPtr<BeamSpot> beamSpotDB;
428 if (!beamSpotDB.isValid())
430 return beamSpotDB->getCovVertex()(elementI, elementJ);
434 double missingMomentumOfEvent(
const Particle*)
436 StoreObjPtr<EventKinematics> evtShape;
438 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
441 double missing = evtShape->getMissingMomentum().R();
445 double missingMomentumOfEvent_Px(
const Particle*)
447 StoreObjPtr<EventKinematics> evtShape;
449 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
452 double missing = evtShape->getMissingMomentum().X();
456 double missingMomentumOfEvent_Py(
const Particle*)
458 StoreObjPtr<EventKinematics> evtShape;
460 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
463 double missing = evtShape->getMissingMomentum().Y();
467 double missingMomentumOfEvent_Pz(
const Particle*)
469 StoreObjPtr<EventKinematics> evtShape;
471 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
474 double missing = evtShape->getMissingMomentum().Z();
478 double missingMomentumOfEvent_theta(
const Particle*)
480 StoreObjPtr<EventKinematics> evtShape;
482 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
485 double missing = evtShape->getMissingMomentum().Theta();
489 double missingMomentumOfEventCMS(
const Particle*)
491 StoreObjPtr<EventKinematics> evtShape;
493 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
496 double missing = evtShape->getMissingMomentumCMS().R();
500 double genMissingMomentumOfEventCMS(
const Particle*)
502 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
504 B2WARNING(
"Cannot find missing momentum information from MC, did you forget to use the buildEventKinematicsFromMC method?");
507 double missing = evtShape->getMissingMomentumCMS().R();
511 double missingMomentumOfEventCMS_Px(
const Particle*)
513 StoreObjPtr<EventKinematics> evtShape;
515 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
518 double missing = evtShape->getMissingMomentumCMS().X();
522 double missingMomentumOfEventCMS_Py(
const Particle*)
524 StoreObjPtr<EventKinematics> evtShape;
526 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
529 double missing = evtShape->getMissingMomentumCMS().Y();
533 double missingMomentumOfEventCMS_Pz(
const Particle*)
535 StoreObjPtr<EventKinematics> evtShape;
537 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
540 double missing = evtShape->getMissingMomentumCMS().Z();
544 double missingMomentumOfEventCMS_theta(
const Particle*)
546 StoreObjPtr<EventKinematics> evtShape;
548 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
551 double theta = evtShape->getMissingMomentumCMS().Theta();
555 double missingEnergyOfEventCMS(
const Particle*)
557 StoreObjPtr<EventKinematics> evtShape;
559 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
562 double missing = evtShape->getMissingEnergyCMS();
566 double genMissingEnergyOfEventCMS(
const Particle*)
568 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
570 B2WARNING(
"Cannot find missing momentum information from MC, did you forget to use the buildEventKinematicsFromMC method?");
573 double missing = evtShape->getMissingEnergyCMS();
578 double missingMass2OfEvent(
const Particle*)
580 StoreObjPtr<EventKinematics> evtShape;
582 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
585 double missing = evtShape->getMissingMass2();
589 double genMissingMass2OfEvent(
const Particle*)
591 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
593 B2WARNING(
"Cannot find missing momentum information from MC, did you forget to use the buildEventKinematicsFromMC method?");
596 double missing = evtShape->getMissingMass2();
600 double visibleEnergyOfEventCMS(
const Particle*)
602 StoreObjPtr<EventKinematics> evtShape;
604 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
607 double visible = evtShape->getVisibleEnergyCMS();
611 double genVisibleEnergyOfEventCMS(
const Particle*)
613 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
615 B2WARNING(
"Cannot find missing momentum information from MC, did you forget to use the buildEventKinematicsFromMC method?");
618 double visible = evtShape->getVisibleEnergyCMS();
623 double totalPhotonsEnergyOfEvent(
const Particle*)
625 StoreObjPtr<EventKinematics> evtShape;
627 B2WARNING(
"Cannot find missing momentum information, did you forget to use the buildEventKinematics method?");
630 double energyOfPhotons = evtShape->getTotalPhotonsEnergy();
631 return energyOfPhotons;
634 double genTotalPhotonsEnergyOfEvent(
const Particle*)
636 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
638 B2WARNING(
"Cannot find missing momentum information from MC, did you forget to use the buildEventKinematicsFromMC method?");
641 double energyOfPhotons = evtShape->getTotalPhotonsEnergy();
642 return energyOfPhotons;
645 double eventYearMonthDay(
const Particle*)
647 StoreObjPtr<EventMetaData> evtMetaData;
651 std::time_t rawtime = trunc(evtMetaData->getTime() / 1e9);
652 const auto* tt = std::gmtime(&rawtime);
653 int y = tt->tm_year + 1900;
654 int m = tt->tm_mon + 1;
656 return (y * 1e4) + (m * 1e2) + d;
659 double eventYear(
const Particle*)
661 StoreObjPtr<EventMetaData> evtMetaData;
665 std::time_t rawtime = trunc(evtMetaData->getTime() / 1e9);
666 const auto* tt = std::gmtime(&rawtime);
667 return tt->tm_year + 1900;
670 double eventTimeSeconds(
const Particle*)
672 StoreObjPtr<EventMetaData> evtMetaData;
677 double evtTime = trunc(evtMetaData->getTime() / 1e9);
682 double eventTimeSecondsFractionRemainder(
const Particle*)
684 StoreObjPtr<EventMetaData> evtMetaData;
689 double evtTime = trunc(evtMetaData->getTime() / 1e9);
691 double evtTimeFrac = (evtMetaData->getTime() - evtTime * 1e9) / 1e9;
696 double eventT0(
const Particle*)
698 StoreObjPtr<EventT0> evtT0;
701 B2WARNING(
"StoreObjPtr<EventT0> does not exist, are you running over cDST data?");
705 if (evtT0->hasEventT0()) {
706 return evtT0->getEventT0();
712 double timeSincePrevTriggerClockTicks(
const Particle*)
714 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
717 if (!TTDInfo.isValid()) {
718 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
723 if (TTDInfo->isValid()) {
724 return TTDInfo->getTimeSincePrevTrigger();
730 double timeSincePrevTriggerMicroSeconds(
const Particle*)
732 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
735 if (!TTDInfo.isValid()) {
736 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
741 if (TTDInfo->isValid()) {
742 return TTDInfo->getTimeSincePrevTriggerInMicroSeconds();
748 double triggeredBunchNumberTTD(
const Particle*)
750 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
753 if (!TTDInfo.isValid()) {
754 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
759 if (TTDInfo->isValid()) {
760 return TTDInfo->getBunchNumber();
766 double triggeredBunchNumber(
const Particle*)
768 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
771 if (!TTDInfo.isValid()) {
772 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
777 if (TTDInfo->isValid()) {
778 return TTDInfo->getTriggeredBunchNumberGlobal();
784 double hasRecentInjection(
const Particle*)
786 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
789 if (!TTDInfo.isValid()) {
790 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
795 if (TTDInfo->isValid()) {
796 return TTDInfo->hasInjection();
802 double timeSinceLastInjectionSignalClockTicks(
const Particle*)
804 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
807 if (!TTDInfo.isValid()) {
808 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
813 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
814 return TTDInfo->getTimeSinceLastInjection();
820 double timeSinceLastInjectionSignalMicroSeconds(
const Particle*)
822 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
825 if (!TTDInfo.isValid()) {
826 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
831 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
832 return TTDInfo->getTimeSinceLastInjectionInMicroSeconds();
838 double timeSinceLastInjectionClockTicks(
const Particle*)
840 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
843 if (!TTDInfo.isValid()) {
844 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
849 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
850 return TTDInfo->getTimeSinceInjectedBunch();
856 double timeSinceLastInjectionMicroSeconds(
const Particle*)
858 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
861 if (!TTDInfo.isValid()) {
862 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
867 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
868 return TTDInfo->getTimeSinceInjectedBunchInMicroSeconds();
874 double injectionInHER(
const Particle*)
876 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
879 if (!TTDInfo.isValid()) {
880 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
885 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
886 return TTDInfo->isHER();
892 double revolutionCounter2(
const Particle*)
894 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
897 if (!TTDInfo.isValid()) {
898 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
903 if (TTDInfo->isValid()) {
904 return TTDInfo->isRevo2();
910 bool eventT0CalculatedWithSVDInfo(
const Particle*)
912 StoreObjPtr<EventLevelTriggerTimeInfo> triggerTimeInfo;
913 if (!triggerTimeInfo.isValid()) {
916 return triggerTimeInfo->hasEventT0SourceFromSVD();
919 bool eventT0CalculatedWithCDCInfo(
const Particle*)
921 StoreObjPtr<EventLevelTriggerTimeInfo> triggerTimeInfo;
922 if (!triggerTimeInfo.isValid()) {
925 return triggerTimeInfo->hasEventT0SourceFromCDC();
928 bool eventT0CalculatedWithECLInfo(
const Particle*)
930 StoreObjPtr<EventLevelTriggerTimeInfo> triggerTimeInfo;
931 if (!triggerTimeInfo.isValid()) {
934 return triggerTimeInfo->hasEventT0SourceFromECL();
938 VARIABLE_GROUP(
"Event");
940 REGISTER_VARIABLE(
"isMC", isMC,
941 "[Eventbased] Returns 1 if current basf2 process is running over simulated (Monte-Carlo) dataset and 0 in case of real experimental data.");
942 REGISTER_VARIABLE(
"isContinuumEvent", isContinuumEvent,
943 "[Eventbased] Returns 1.0 if event doesn't contain a :math:`\\Upsilon(4S)` particle on generator level, 0.0 otherwise.");
944 REGISTER_VARIABLE(
"isNotContinuumEvent", isNotContinuumEvent,
945 "[Eventbased] Returns 1.0 if event does contain an :math:`\\Upsilon(4S)` particle on generator level and therefore is not a continuum event, 0.0 otherwise.");
947 REGISTER_VARIABLE(
"isChargedBEvent", isChargedBEvent,
948 "[Eventbased] Returns 1.0 if event contains a charged B-meson on generator level.");
949 REGISTER_VARIABLE(
"isUnmixedBEvent", isUnmixedBEvent,
950 R
"DOC([Eventbased] Returns 1.0 if the event contains opposite flavor neutral B-mesons on generator level,
9510.0 in case of same flavor B-mesons and NaN if the event has no generated neutral B.)DOC");
953 REGISTER_VARIABLE("nTracks", nTracks, R
"DOC(
954[Eventbased] Returns the total number of tracks (unfiltered) in the event.
956.. warning:: This variable is exceedingly background-dependent and should not really be used in any selections (other than perhaps for monitoring purposes).
957.. seealso:: :b2:var:`nCleanedTracks` for a more useful variable for use in selections.
959 REGISTER_VARIABLE("nChargeZeroTrackFits", nChargeZeroTrackFits, R
"DOC(
960[Eventbased] Returns number of track fits with zero charge.
963 Sometimes, track fits can have zero charge, if background or non IP originating tracks, for example, are fit from the IP.
964 These tracks are excluded from particle lists, but a large amount of charge zero
965 fits may indicate problems with whole event constraints
966 or abnominally high beam backgrounds and/or noisy events.
969 REGISTER_VARIABLE("belleECLEnergy", belleECLEnergy, R
"DOC(
970[Eventbased][Legacy] Returns total energy in ECL in the event as used in Belle 1 analyses.
973 For Belle II use cases use either ``totalEnergyOfParticlesInList(gamma:all)``,
974 or (probably better) fill a photon list with some minimal cleanup cuts and use that instead:
976 .. code-block:: python
978 from variables import variables as vm
979 fillParticleList("gamma:cleaned", "E > 0.05 and isFromECL==1", path=path)
980 fillParticleList("e+:cleaned", "clusterE > 0.05", path=path)
981 vm.addAlias("myNeutralECLEnergy", "totalEnergyOfParticlesInList(gamma:cleaned)")
982 vm.addAlias("myChargedECLEnergy", "totalEnergyOfParticlesInList(e+:cleaned)")
983 vm.addAlias("myECLEnergy", "formula(myNeutralECLEnergy+myChargedECLEnergy)")
986 REGISTER_VARIABLE("nKLMClusters", nKLMClusters,
987 "[Eventbased] Returns number of KLM clusters in the event.");
988 REGISTER_VARIABLE("nNeutralECLClusters(hypothesis)", nNeutralECLClusters,
989 "[Eventbased] Returns number of neutral ECL clusters with a given hypothesis, 1:nPhotons, 2:NeutralHadron.");
990 REGISTER_VARIABLE("nV0s", nV0s,
991 "[Eventbased] Returns number of V0s in the event.");
992 REGISTER_VARIABLE("nValidV0s", nValidV0s,
993 "[Eventbased] Returns number of V0s consisting of pair of tracks with opposite charges.");
994 REGISTER_VARIABLE("nMCParticles", nMCParticles,
995 "[Eventbased] Returns number of MCParticles in the event.");
996 REGISTER_VARIABLE("nPrimaryMCParticles", nPrimaryMCParticles,
997 "[Eventbased] Returns number of primary MCParticles in the event.");
998 REGISTER_VARIABLE("nInitialPrimaryMCParticles", nInitialPrimaryMCParticles,
999 "[Eventbased] Returns number of initial primary MCParticles in the event.");
1000 REGISTER_VARIABLE("nVirtualPrimaryMCParticles", nVirtualPrimaryMCParticles,
1001 "[Eventbased] Returns number of virtual primary MCParticles in the event.");
1003 REGISTER_VARIABLE("expNum", expNum, "[Eventbased] Returns the experiment number.");
1004 REGISTER_VARIABLE("evtNum", evtNum, "[Eventbased] Returns the event number.");
1005 REGISTER_VARIABLE("runNum", runNum, "[Eventbased] Returns the run number.");
1006 REGISTER_VARIABLE("productionIdentifier", productionIdentifier, R"DOC(
1007[Eventbased] Production identifier.
1008Uniquely identifies an MC sample by the (grid-jargon) production ID.
1009This is useful when analysing large MC samples split between more than one production or combining different MC samples (e.g. combining all continuum samples).
1010In such cases the event numbers are sequential *only within a production*, so experiment/run/event will restart with every new sample analysed.
1012.. tip:: Experiment/run/event/production is unique for all MC samples. Experiment/run/event is unique for data.
1014.. seealso:: `Where can I rely on uniqueness of the ['__experiment__', '__run__', '__event__', '__candidate__'] combination? <https://questions.belle2.org/question/9704>`__
1017 REGISTER_VARIABLE("Ecms", getCMSEnergy,
"[Eventbased] Returns center-of-mass energy.\n\n",
"GeV");
1018 REGISTER_VARIABLE(
"beamE", getBeamE,
"[Eventbased] Returns total beam energy in the laboratory frame.\n\n",
"GeV");
1019 REGISTER_VARIABLE(
"beamPx", getBeamPx,
"[Eventbased] Returns x component of total beam momentum in the laboratory frame.\n\n",
"GeV/c");
1020 REGISTER_VARIABLE(
"beamPy", getBeamPy,
"[Eventbased] Returns y component of total beam momentum in the laboratory frame.\n\n",
"GeV/c");
1021 REGISTER_VARIABLE(
"beamPz", getBeamPz,
"[Eventbased] Returns z component of total beam momentum in the laboratory frame.\n\n",
"GeV/c");
1022 REGISTER_VARIABLE(
"EcmsMC", getCMSEnergyMC,
"[Eventbased] Truth value of sqrt(s)\n\n",
"GeV");
1023 REGISTER_VARIABLE(
"totalEnergyMC", getTotalEnergyMC,
"[Eventbased] Truth value of sum of energies of all the generated particles\n\n",
"GeV");
1026 REGISTER_VARIABLE(
"PxHER", getPxHER,
"[Eventbased] Returns x component of the electron beam momentum in the laboratory frame.\n\n",
"GeV/c");
1027 REGISTER_VARIABLE(
"PyHER", getPyHER,
"[Eventbased] Returns y component of the electron beam momentum in the laboratory frame.\n\n",
"GeV/c");
1028 REGISTER_VARIABLE(
"PzHER", getPzHER,
"[Eventbased] Returns z component of the electron beam momentum in the laboratory frame.\n\n",
"GeV/c");
1029 REGISTER_VARIABLE(
"PxLER", getPxLER,
"[Eventbased] Returns x component of the positron beam momentum in the laboratory frame.\n\n",
"GeV/c");
1030 REGISTER_VARIABLE(
"PyLER", getPyLER,
"[Eventbased] Returns y component of the positron beam momentum in the laboratory frame.\n\n",
"GeV/c");
1031 REGISTER_VARIABLE(
"PzLER", getPzLER,
"[Eventbased] Returns z component of the positron beam momentum in the laboratory frame.\n\n",
"GeV/c");
1033 REGISTER_VARIABLE(
"mcPxHER", getMcPxHER,
"[Eventbased] Returns truth value of the x component of the incoming electron momentum in the laboratory frame.\n\n",
"GeV/c");
1034 REGISTER_VARIABLE(
"mcPyHER", getMcPyHER,
"[Eventbased] Returns truth value of the y component of the incoming electron momentum in the laboratory frame.\n\n",
"GeV/c");
1035 REGISTER_VARIABLE(
"mcPzHER", getMcPzHER,
"[Eventbased] Returns truth value of the z component of the incoming electron momentum in the laboratory frame.\n\n",
"GeV/c");
1036 REGISTER_VARIABLE(
"mcPxLER", getMcPxLER,
"[Eventbased] Returns truth value of the x component of the incoming positron momentum in the laboratory frame.\n\n",
"GeV/c");
1037 REGISTER_VARIABLE(
"mcPyLER", getMcPyLER,
"[Eventbased] Returns truth value of the y component of the incoming positron momentum in the laboratory frame.\n\n",
"GeV/c");
1038 REGISTER_VARIABLE(
"mcPzLER", getMcPzLER,
"[Eventbased] Returns truth value of the z component of the incoming positron momentum in the laboratory frame.\n\n",
"GeV/c");
1042 REGISTER_VARIABLE(
"IPX", getIPX, R
"DOC(
1043[Eventbased] Returns x coordinate of the measured interaction point.
1045.. note:: For old data and uncalibrated MC files this will return 0.0.
1047.. note:: You might hear tracking and calibration people refer to this as the ``BeamSpot``.
1050 REGISTER_VARIABLE("IPY", getIPY, "[Eventbased] Returns y coordinate of the measured interaction point.\n\n","cm");
1051 REGISTER_VARIABLE("IPZ", getIPZ, "[Eventbased] Returns z coordinate of the measured interaction point.\n\n","cm");
1052 REGISTER_VARIABLE("IPCov(i,j)", ipCovMatrixElement, "[Eventbased] Returns (i,j)-th element of the covariance matrix of the measured interaction point.\n\n",":math:`\\text{cm}^2`");
1054 REGISTER_VARIABLE("genIPX", getGenIPX, R"DOC(
1055[Eventbased] Returns x coordinate of the interaction point used for the underlying **MC generation**.
1056Returns NaN for data.
1058.. note:: This is normally smeared from 0.0
1061 REGISTER_VARIABLE("genIPY", getGenIPY, "[Eventbased] Returns y coordinate of the interaction point used for the underlying **MC generation**. Returns NaN for data.\n\n","cm");
1062 REGISTER_VARIABLE("genIPZ", getGenIPZ, "[Eventbased] Returns z coordinate of the interaction point used for the underlying **MC generation**. Returns NaN for data.\n\n","cm");
1064 REGISTER_VARIABLE("date", eventYearMonthDay, R"DOC(
1065[Eventbased] Returns the date when the event was recorded, a number of the form YYYYMMDD (in UTC).
1067.. seealso:: :b2:var:`year`, :b2:var:`eventTimeSeconds`, :b2:var:`eventTimeSecondsFractionRemainder`, provided for convenience.
1069 REGISTER_VARIABLE("year", eventYear, R
"DOC(
1070[Eventbased] Returns the year when the event was recorded (in UTC).
1073 For more precise event time, see :b2:var:`eventTimeSeconds` and :b2:var:`eventTimeSecondsFractionRemainder`.
1075 REGISTER_VARIABLE("eventTimeSeconds", eventTimeSeconds,
1076 "[Eventbased] Time of the event (truncated down) since 1970/1/1 (Unix epoch).\n\n",
"s");
1077 REGISTER_VARIABLE(
"eventTimeSecondsFractionRemainder", eventTimeSecondsFractionRemainder, R
"DOC(
1078[Eventbased] Remainder of the event time.
1080.. tip:: Use eventTimeSeconds + eventTimeSecondsFractionRemainder to get the total event time in seconds.
1084 REGISTER_VARIABLE("timeSincePrevTriggerClockTicks", timeSincePrevTriggerClockTicks,
1085 "[Eventbased] Time since the previous trigger (127MHz=RF/4 clock).\n\n","clock ticks");
1087 REGISTER_VARIABLE("timeSincePrevTriggerMicroSeconds", timeSincePrevTriggerMicroSeconds,
1088 "[Eventbased] Time since the previous trigger.\n\n",":math:`\\mathrm{\\mu s}`");
1090 REGISTER_VARIABLE("triggeredBunchNumberTTD", triggeredBunchNumberTTD, R"DOC(
1091[Eventbased] Number of triggered bunch ranging from 0-1279.
1093.. warning:: This is the bunch number as provided by the TTD, which does not necessarily correspond to the 'global' SKB bunch number.
1094.. note:: There are a maximum of 5120 buckets, which could each carry one bunch of e+/e-, but we only have 1280 clock ticks (=5120/4) to identify the bunches.
1097 REGISTER_VARIABLE("triggeredBunchNumber", triggeredBunchNumber, R
"DOC(
1098[Eventbased] Number of triggered bunch ranging from 0-1279.
1100.. note:: There are a maximum of 5120 buckets, which could each carry one bunch of e+/e-, but we only have 1280 clock ticks (=5120/4) to identify the bunches
1103 REGISTER_VARIABLE("hasRecentInjection", hasRecentInjection,
1104 "[Eventbased] Returns 1 if an injection happened recently, 0 otherwise.");
1106 REGISTER_VARIABLE(
"timeSinceLastInjectionSignalClockTicks", timeSinceLastInjectionSignalClockTicks, R
"DOC(
1107[Eventbased] Time since the last injection pre-kick signal (127MHz=RF/4 clock)
1109.. warning:: this returns the time without the delay until the injected bunch reaches the detector (which differs for HER/LER)
1111)DOC","clock ticks");
1113 REGISTER_VARIABLE("timeSinceLastInjectionSignalMicroSeconds", timeSinceLastInjectionSignalMicroSeconds, R"DOC(
1114[Eventbased] Time since the last injection pre-kick signal
1116.. warning:: this returns the time without the delay until the injected bunch reaches the detector (which differs for HER/LER)
1118)DOC",":math:`\\mathrm{\\mu s}`");
1120 REGISTER_VARIABLE("timeSinceLastInjectionClockTicks", timeSinceLastInjectionClockTicks,
1121 "[Eventbased] Time since the last injected bunch passed by the detector.\n\n","clock ticks")
1123 REGISTER_VARIABLE("timeSinceLastInjectionMicroSeconds", timeSinceLastInjectionMicroSeconds,
1124 "[Eventbased] Time since the last injected bunch passed by the detector.\n\n",":math:`\\mathrm{\\mu s}`")
1126 REGISTER_VARIABLE("injectionInHER", injectionInHER,
1127 "[Eventbased] Returns 1 if injection was in HER, 0 otherwise.");
1129 REGISTER_VARIABLE("revolutionCounter2", revolutionCounter2, R"DOC(
1130[Eventbased] The lowest bit of revolution counter, i.e. return 0 or 1
1132.. note:: related to PXD data acquisition; PXD needs ~2 revolutions to read out one frame
1135 VARIABLE_GROUP("EventKinematics");
1137 REGISTER_VARIABLE(
"missingMomentumOfEvent", missingMomentumOfEvent, R
"DOC(
1138[Eventbased] The magnitude of the missing momentum in laboratory frame.
1140.. warning:: You have to run the Event Kinematics builder module for this variable to be meaningful.
1141.. seealso:: `modularAnalysis.buildEventKinematics`.
1144 REGISTER_VARIABLE("missingMomentumOfEvent_Px", missingMomentumOfEvent_Px, R"DOC(
1145[Eventbased] The x component of the missing momentum in laboratory frame.
1148 REGISTER_VARIABLE("missingMomentumOfEvent_Py", missingMomentumOfEvent_Py, R"DOC(
1149[Eventbased] The y component of the missing momentum in laboratory frame.
1152 REGISTER_VARIABLE("missingMomentumOfEvent_Pz", missingMomentumOfEvent_Pz, R"DOC(
1153[Eventbased] The z component of the missing momentum in laboratory frame.
1156 REGISTER_VARIABLE("missingMomentumOfEvent_theta", missingMomentumOfEvent_theta, R"DOC(
1157[Eventbased] The theta angle of the missing momentum of the event in laboratory frame.
1160 REGISTER_VARIABLE("missingMomentumOfEventCMS", missingMomentumOfEventCMS, R"DOC(
1161[Eventbased] The magnitude of the missing momentum in center-of-mass frame.
1164 REGISTER_VARIABLE("genMissingMomentumOfEventCMS", genMissingMomentumOfEventCMS, R"DOC(
1165[Eventbased] The magnitude of the missing momentum in center-of-mass frame from generator
1168 REGISTER_VARIABLE("missingMomentumOfEventCMS_Px", missingMomentumOfEventCMS_Px, R"DOC(
1169[Eventbased] The x component of the missing momentum in center-of-mass frame.
1172 REGISTER_VARIABLE("missingMomentumOfEventCMS_Py", missingMomentumOfEventCMS_Py, R"DOC(
1173[Eventbased] The y component of the missing momentum in center-of-mass frame.
1176 REGISTER_VARIABLE("missingMomentumOfEventCMS_Pz", missingMomentumOfEventCMS_Pz, R"DOC(
1177[Eventbased] The z component of the missing momentum in center-of-mass frame.
1180 REGISTER_VARIABLE("missingMomentumOfEventCMS_theta", missingMomentumOfEventCMS_theta, R"DOC(
1181[Eventbased] The theta angle of the missing momentum in center-of-mass frame.
1184 REGISTER_VARIABLE("missingEnergyOfEventCMS", missingEnergyOfEventCMS, R"DOC(
1185[Eventbased] The missing energy in center-of-mass frame.
1188 REGISTER_VARIABLE("genMissingEnergyOfEventCMS", genMissingEnergyOfEventCMS, R"DOC(
1189[Eventbased] The missing energy in center-of-mass frame from generator.
1192 REGISTER_VARIABLE("missingMass2OfEvent", missingMass2OfEvent, R"DOC(
1193[Eventbased] The missing mass squared.
1195)DOC",":math:`[\\text{GeV}/\\text{c}^2]^2`");
1196 REGISTER_VARIABLE("genMissingMass2OfEvent", genMissingMass2OfEvent, R"DOC(
1197[Eventbased] The missing mass squared from generator
1199)DOC",":math:`[\\text{GeV}/\\text{c}^2]^2`");
1200 REGISTER_VARIABLE("visibleEnergyOfEventCMS", visibleEnergyOfEventCMS, R"DOC(
1201[Eventbased] The visible energy in center-of-mass frame.
1204 REGISTER_VARIABLE("genVisibleEnergyOfEventCMS", genVisibleEnergyOfEventCMS, R"DOC(
1205[Eventbased] The visible energy in center-of-mass frame from generator.
1208 REGISTER_VARIABLE("totalPhotonsEnergyOfEvent", totalPhotonsEnergyOfEvent, R"DOC(
1209[Eventbased] The energy in laboratory frame of all the photons.
1212 REGISTER_VARIABLE("genTotalPhotonsEnergyOfEvent", genTotalPhotonsEnergyOfEvent, R"DOC(
1213[Eventbased] The energy in laboratory frame of all the photons. from generator.
1216 REGISTER_VARIABLE("eventT0CalculatedWithSVDInfo", eventT0CalculatedWithSVDInfo, R"DOC(
1217[Eventbased] It returns true if the SVD subdetector contributed in the calculation of the EventT0.
1218Please note that other subdetectors may also have contributed, so store the variables for these as well.
1220 REGISTER_VARIABLE("eventT0CalculatedWithCDCInfo", eventT0CalculatedWithCDCInfo, R
"DOC(
1221[Eventbased] It returns true if the CDC subdetector contributed in the calculation of the EventT0.
1222Please note that other subdetectors may also have contributed, so store the variables for these as well.
1224 REGISTER_VARIABLE("eventT0CalculatedWithECLInfo", eventT0CalculatedWithECLInfo, R
"DOC(
1225[Eventbased] It returns true if the ECL subdetector contributed in the calculation of the EventT0.
1226Please note that other subdetectors may also have contributed, so store the variables for these as well.
1229 VARIABLE_GROUP("Event (cDST only)");
1230 REGISTER_VARIABLE(
"eventT0", eventT0, R
"DOC(
1231[Eventbased][Calibration] The Event t0, is the time of the event relative to the trigger time.
1234 The event time can be measured by several sub-detectors including the SVD, CDC, ECL, and TOP.
1235 This eventT0 variable is the final combined value of all the event time measurements.
1236 Currently, only the SVD and ECL are used in this combination.
static const double electronMass
electron mass
static const double doubleNaN
quiet_NaN
@ c_nPhotons
CR is split into n photons (N1)
@ c_neutralHadron
CR is reconstructed as a neutral hadron (N2)
bool isMC() const
Do we have generated, not real data?
static Environment & Instance()
Static method to get a reference to the Environment instance.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.