10 #include <analysis/variables/EventVariables.h>
12 #include <analysis/VariableManager/Manager.h>
15 #include <framework/datastore/StoreArray.h>
16 #include <framework/datastore/StoreObjPtr.h>
17 #include <framework/dataobjects/EventMetaData.h>
20 #include <analysis/dataobjects/Particle.h>
21 #include <analysis/dataobjects/EventKinematics.h>
23 #include <mdst/dataobjects/MCParticle.h>
24 #include <mdst/dataobjects/Track.h>
25 #include <mdst/dataobjects/ECLCluster.h>
26 #include <mdst/dataobjects/KLMCluster.h>
28 #include <framework/dataobjects/EventT0.h>
29 #include <mdst/dataobjects/EventLevelTriggerTimeInfo.h>
32 #include <framework/database/DBObjPtr.h>
33 #include <mdst/dbobjects/BeamSpot.h>
35 #include <analysis/utility/PCmsLabTransform.h>
37 #include <framework/core/Environment.h>
38 #include <framework/logging/Logger.h>
40 #include <TLorentzVector.h>
51 double isMC(
const Particle*)
56 double eventType(
const Particle*)
58 StoreArray<MCParticle> mcparticles;
59 return (mcparticles.getEntries()) > 0 ? 0 : 1;
62 double isContinuumEvent(
const Particle*)
64 return (isNotContinuumEvent(
nullptr) == 1.0 ? 0.0 : 1.0);
67 double isChargedBEvent(
const Particle*)
69 StoreArray<MCParticle> mcParticles;
70 for (
const auto& mcp : mcParticles) {
71 int pdg_no = mcp.getPDG();
72 if (abs(pdg_no) == 521)
return 1.0;
77 double isUnmixedBEvent(
const Particle*)
79 StoreArray<MCParticle> mcParticles;
80 std::vector<int> bPDGs;
81 for (
const auto& mcp : mcParticles) {
82 int pdg_no = mcp.getPDG();
83 if (abs(pdg_no) == 511) bPDGs.push_back(pdg_no);
85 if (bPDGs.size() == 2) {
86 return bPDGs[0] * bPDGs[1] < 0;
88 return std::numeric_limits<float>::quiet_NaN();
92 double isNotContinuumEvent(
const Particle*)
94 StoreArray<MCParticle> mcParticles;
95 for (
const MCParticle& mcp : mcParticles) {
96 int pdg_no = mcp.getPDG();
97 if (mcp.getMother() ==
nullptr &&
100 (pdg_no == 200553) ||
101 (pdg_no == 300553) ||
102 (pdg_no == 9000553) ||
103 (pdg_no == 9010553)))
109 double nMCParticles(
const Particle*)
111 StoreArray<MCParticle> mcps;
112 return mcps.getEntries();
115 double nTracks(
const Particle*)
117 StoreArray<Track> tracks;
118 return tracks.getEntries();
121 double nChargeZeroTrackFits(
const Particle*)
123 StoreArray<TrackFitResult> tfrs;
125 for (
const auto& t : tfrs)
126 if (t.getChargeSign() == 0) out++;
130 double belleECLEnergy(
const Particle*)
132 StoreArray<ECLCluster> eclClusters;
134 for (
int i = 0; i < eclClusters.getEntries(); ++i) {
144 double nKLMClusters(
const Particle*)
146 StoreArray<KLMCluster> klmClusters;
147 return klmClusters.getEntries();
150 double expNum(
const Particle*)
152 StoreObjPtr<EventMetaData> evtMetaData;
153 int exp_no = evtMetaData->getExperiment();
157 double productionIdentifier(
const Particle*)
159 StoreObjPtr<EventMetaData> evtMetaData;
160 int eventProduction = evtMetaData->getProduction();
161 return eventProduction;
164 double evtNum(
const Particle*)
166 StoreObjPtr<EventMetaData> evtMetaData;
167 int evt_no = evtMetaData->getEvent();
171 double runNum(
const Particle*)
173 StoreObjPtr<EventMetaData> evtMetaData;
174 int run_no = evtMetaData->getRun();
179 double getCMSEnergy(
const Particle*)
182 return T.getCMSEnergy();
185 double getBeamPx(
const Particle*)
188 return (T.getBeamFourMomentum()).Px();
191 double getBeamPy(
const Particle*)
194 return (T.getBeamFourMomentum()).Py();
197 double getBeamPz(
const Particle*)
200 return (T.getBeamFourMomentum()).Pz();
203 double getBeamE(
const Particle*)
206 return (T.getBeamFourMomentum()).E();
209 double getGenIPX(
const Particle*)
213 StoreArray<MCParticle> mcps;
214 for (
const auto& mcp : mcps)
215 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
216 return mcp.getVertex().X();
217 return std::numeric_limits<double>::quiet_NaN();
220 double getGenIPY(
const Particle*)
222 StoreArray<MCParticle> mcps;
223 for (
const auto& mcp : mcps)
224 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
225 return mcp.getVertex().Y();
226 return std::numeric_limits<double>::quiet_NaN();
229 double getGenIPZ(
const Particle*)
231 StoreArray<MCParticle> mcps;
232 for (
const auto& mcp : mcps)
233 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
234 return mcp.getVertex().Z();
235 return std::numeric_limits<double>::quiet_NaN();
238 double getIPX(
const Particle*)
240 static DBObjPtr<BeamSpot> beamSpotDB;
241 return (beamSpotDB->getIPPosition()).X();
244 double getIPY(
const Particle*)
246 static DBObjPtr<BeamSpot> beamSpotDB;
247 return (beamSpotDB->getIPPosition()).Y();
250 double getIPZ(
const Particle*)
252 static DBObjPtr<BeamSpot> beamSpotDB;
253 return (beamSpotDB->getIPPosition()).Z();
256 double ipCovMatrixElement(
const Particle*,
const std::vector<double>& element)
258 int elementI = int(std::lround(element[0]));
259 int elementJ = int(std::lround(element[1]));
261 if (elementI < 0 || elementI > 3) {
262 B2WARNING(
"Requested IP covariance matrix element is out of boundaries [0 - 3]: i = " << elementI);
263 return std::numeric_limits<float>::quiet_NaN();
265 if (elementJ < 0 || elementJ > 3) {
266 B2WARNING(
"Requested particle's momentumVertex covariance matrix element is out of boundaries [0 - 3]: j = " << elementJ);
267 return std::numeric_limits<float>::quiet_NaN();
270 static DBObjPtr<BeamSpot> beamSpotDB;
271 return beamSpotDB->getCovVertex()(elementI, elementJ);
275 double missingMomentumOfEvent(
const Particle*)
277 StoreObjPtr<EventKinematics> evtShape;
279 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
280 return std::numeric_limits<float>::quiet_NaN();
282 double missing = evtShape->getMissingMomentum().Mag();
286 double missingMomentumOfEvent_Px(
const Particle*)
288 StoreObjPtr<EventKinematics> evtShape;
290 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
291 return std::numeric_limits<float>::quiet_NaN();
293 double missing = evtShape->getMissingMomentum().Px();
297 double missingMomentumOfEvent_Py(
const Particle*)
299 StoreObjPtr<EventKinematics> evtShape;
301 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
302 return std::numeric_limits<float>::quiet_NaN();
304 double missing = evtShape->getMissingMomentum().Py();
308 double missingMomentumOfEvent_Pz(
const Particle*)
310 StoreObjPtr<EventKinematics> evtShape;
312 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
313 return std::numeric_limits<float>::quiet_NaN();
315 double missing = evtShape->getMissingMomentum().Pz();
319 double missingMomentumOfEvent_theta(
const Particle*)
321 StoreObjPtr<EventKinematics> evtShape;
323 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
324 return std::numeric_limits<float>::quiet_NaN();
326 double missing = evtShape->getMissingMomentum().Theta();
330 double missingMomentumOfEventCMS(
const Particle*)
332 StoreObjPtr<EventKinematics> evtShape;
334 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
335 return std::numeric_limits<float>::quiet_NaN();
337 double missing = evtShape->getMissingMomentumCMS().Mag();
341 double genMissingMomentumOfEventCMS(
const Particle*)
343 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
345 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
346 return std::numeric_limits<float>::quiet_NaN();
348 double missing = evtShape->getMissingMomentumCMS().Mag();
352 double missingMomentumOfEventCMS_Px(
const Particle*)
354 StoreObjPtr<EventKinematics> evtShape;
356 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
357 return std::numeric_limits<float>::quiet_NaN();
359 double missing = evtShape->getMissingMomentumCMS().Px();
363 double missingMomentumOfEventCMS_Py(
const Particle*)
365 StoreObjPtr<EventKinematics> evtShape;
367 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
368 return std::numeric_limits<float>::quiet_NaN();
370 double missing = evtShape->getMissingMomentumCMS().Py();
374 double missingMomentumOfEventCMS_Pz(
const Particle*)
376 StoreObjPtr<EventKinematics> evtShape;
378 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
379 return std::numeric_limits<float>::quiet_NaN();
381 double missing = evtShape->getMissingMomentumCMS().Pz();
385 double missingMomentumOfEventCMS_theta(
const Particle*)
387 StoreObjPtr<EventKinematics> evtShape;
389 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
390 return std::numeric_limits<float>::quiet_NaN();
392 double theta = evtShape->getMissingMomentumCMS().Theta();
396 double missingEnergyOfEventCMS(
const Particle*)
398 StoreObjPtr<EventKinematics> evtShape;
400 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
401 return std::numeric_limits<float>::quiet_NaN();
403 double missing = evtShape->getMissingEnergyCMS();
407 double genMissingEnergyOfEventCMS(
const Particle*)
409 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
411 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
412 return std::numeric_limits<float>::quiet_NaN();
414 double missing = evtShape->getMissingEnergyCMS();
419 double missingMass2OfEvent(
const Particle*)
421 StoreObjPtr<EventKinematics> evtShape;
423 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
424 return std::numeric_limits<float>::quiet_NaN();
426 double missing = evtShape->getMissingMass2();
430 double genMissingMass2OfEvent(
const Particle*)
432 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
434 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
435 return std::numeric_limits<float>::quiet_NaN();
437 double missing = evtShape->getMissingMass2();
441 double visibleEnergyOfEventCMS(
const Particle*)
443 StoreObjPtr<EventKinematics> evtShape;
445 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
446 return std::numeric_limits<float>::quiet_NaN();
448 double visible = evtShape->getVisibleEnergyCMS();
452 double genVisibleEnergyOfEventCMS(
const Particle*)
454 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
456 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
457 return std::numeric_limits<float>::quiet_NaN();
459 double visible = evtShape->getVisibleEnergyCMS();
464 double totalPhotonsEnergyOfEvent(
const Particle*)
466 StoreObjPtr<EventKinematics> evtShape;
468 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
469 return std::numeric_limits<float>::quiet_NaN();
471 double energyOfPhotons = evtShape->getTotalPhotonsEnergy();
472 return energyOfPhotons;
475 double genTotalPhotonsEnergyOfEvent(
const Particle*)
477 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
479 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
480 return std::numeric_limits<float>::quiet_NaN();
482 double energyOfPhotons = evtShape->getTotalPhotonsEnergy();
483 return energyOfPhotons;
487 double eventYearMonthDay(
const Particle*)
489 StoreObjPtr<EventMetaData> evtMetaData;
491 return std::numeric_limits<float>::quiet_NaN();
493 std::time_t rawtime = trunc(evtMetaData->getTime() / 1e9);
494 auto tt = std::gmtime(&rawtime);
495 int y = tt->tm_year + 1900;
496 int m = tt->tm_mon + 1;
498 return (y * 1e4) + (m * 1e2) + d;
501 double eventYear(
const Particle*)
503 StoreObjPtr<EventMetaData> evtMetaData;
505 return std::numeric_limits<float>::quiet_NaN();
507 std::time_t rawtime = trunc(evtMetaData->getTime() / 1e9);
508 auto tt = std::gmtime(&rawtime);
509 return tt->tm_year + 1900;
512 double eventTimeSeconds(
const Particle*)
514 StoreObjPtr<EventMetaData> evtMetaData;
517 return std::numeric_limits<float>::quiet_NaN();
519 double evtTime = trunc(evtMetaData->getTime() / 1e9);
524 double eventTimeSecondsFractionRemainder(
const Particle*)
526 StoreObjPtr<EventMetaData> evtMetaData;
529 return std::numeric_limits<float>::quiet_NaN();
531 double evtTime = trunc(evtMetaData->getTime() / 1e9);
533 double evtTimeFrac = (evtMetaData->getTime() - evtTime * 1e9) / 1e9;
538 double eventT0(
const Particle*)
540 StoreObjPtr<EventT0> evtT0;
543 B2WARNING(
"StoreObjPtr<EventT0> does not exist, are you running over cDST data?");
544 return std::numeric_limits<float>::quiet_NaN();
547 if (evtT0->hasEventT0()) {
548 return evtT0->getEventT0();
550 return std::numeric_limits<float>::quiet_NaN();
554 double timeSincePrevTriggerClockTicks(
const Particle*)
556 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
559 if (!TTDInfo.isValid()) {
560 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
561 return std::numeric_limits<float>::quiet_NaN();
565 if (TTDInfo->isValid()) {
566 return TTDInfo->getTimeSincePrevTrigger();
568 return std::numeric_limits<float>::quiet_NaN();
572 double timeSincePrevTriggerMicroSeconds(
const Particle*)
574 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
577 if (!TTDInfo.isValid()) {
578 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
579 return std::numeric_limits<float>::quiet_NaN();
583 if (TTDInfo->isValid()) {
584 return TTDInfo->getTimeSincePrevTriggerInMicroSeconds();
586 return std::numeric_limits<float>::quiet_NaN();
590 double triggeredBunchNumberTTD(
const Particle*)
592 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
595 if (!TTDInfo.isValid()) {
596 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
597 return std::numeric_limits<float>::quiet_NaN();
601 if (TTDInfo->isValid()) {
602 return TTDInfo->getBunchNumber();
604 return std::numeric_limits<float>::quiet_NaN();
608 double triggeredBunchNumber(
const Particle*)
610 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
613 if (!TTDInfo.isValid()) {
614 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
615 return std::numeric_limits<float>::quiet_NaN();
619 if (TTDInfo->isValid()) {
620 return TTDInfo->getTriggeredBunchNumberGlobal();
622 return std::numeric_limits<float>::quiet_NaN();
626 double hasRecentInjection(
const Particle*)
628 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
631 if (!TTDInfo.isValid()) {
632 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
633 return std::numeric_limits<float>::quiet_NaN();
637 if (TTDInfo->isValid()) {
638 return TTDInfo->hasInjection();
640 return std::numeric_limits<float>::quiet_NaN();
644 double timeSinceLastInjectionSignalClockTicks(
const Particle*)
646 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
649 if (!TTDInfo.isValid()) {
650 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
651 return std::numeric_limits<float>::quiet_NaN();
655 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
656 return TTDInfo->getTimeSinceLastInjection();
658 return std::numeric_limits<float>::quiet_NaN();
662 double timeSinceLastInjectionSignalMicroSeconds(
const Particle*)
664 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
667 if (!TTDInfo.isValid()) {
668 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
669 return std::numeric_limits<float>::quiet_NaN();
673 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
674 return TTDInfo->getTimeSinceLastInjectionInMicroSeconds();
676 return std::numeric_limits<float>::quiet_NaN();
680 double timeSinceLastInjectionClockTicks(
const Particle*)
682 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
685 if (!TTDInfo.isValid()) {
686 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
687 return std::numeric_limits<float>::quiet_NaN();
691 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
692 return TTDInfo->getTimeSinceInjectedBunch();
694 return std::numeric_limits<float>::quiet_NaN();
698 double timeSinceLastInjectionMicroSeconds(
const Particle*)
700 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
703 if (!TTDInfo.isValid()) {
704 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
705 return std::numeric_limits<float>::quiet_NaN();
709 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
710 return TTDInfo->getTimeSinceInjectedBunchInMicroSeconds();
712 return std::numeric_limits<float>::quiet_NaN();
716 double injectionInHER(
const Particle*)
718 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
721 if (!TTDInfo.isValid()) {
722 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
723 return std::numeric_limits<float>::quiet_NaN();
727 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
728 return TTDInfo->isHER();
730 return std::numeric_limits<float>::quiet_NaN();
734 double revolutionCounter2(
const Particle*)
736 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
739 if (!TTDInfo.isValid()) {
740 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
741 return std::numeric_limits<float>::quiet_NaN();
745 if (TTDInfo->isValid()) {
746 return TTDInfo->isRevo2();
748 return std::numeric_limits<float>::quiet_NaN();
753 VARIABLE_GROUP(
"Event");
755 REGISTER_VARIABLE(
"isMC", isMC,
756 "[Eventbased] Returns 1 if current basf2 process is running over simulated (Monte-Carlo) dataset and 0 in case of real experimental data.");
757 REGISTER_VARIABLE(
"EventType", eventType,
"[Eventbased] EventType (0 MC, 1 Data)");
759 Use `isMC` instead of this variable but keep in mind that the meaning of the outcome is reversed.)DOC");
760 REGISTER_VARIABLE("isContinuumEvent", isContinuumEvent,
761 "[Eventbased] Returns 1.0 if event doesn't contain a :math:`\\Upsilon(4S)` particle on generator level, 0.0 otherwise.");
762 REGISTER_VARIABLE(
"isNotContinuumEvent", isNotContinuumEvent,
763 "[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.");
765 REGISTER_VARIABLE(
"isChargedBEvent", isChargedBEvent,
766 "[Eventbased] Returns 1.0 if event contains a charged B-meson on generator level.");
767 REGISTER_VARIABLE(
"isUnmixedBEvent", isUnmixedBEvent,
768 R
"DOC([Eventbased] Returns 1.0 if the event contains opposite flavor neutral B-mesons on generator level,
769 0.0 in case of same flavor B-mesons and NaN if the event has no generated neutral B.)DOC");
771 REGISTER_VARIABLE("nTracks", nTracks, R
"DOC(
772 [Eventbased] Returns the total number of tracks (unfiltered) in the event.
774 .. warning:: This variable is exceedingly background-dependent and should not really be used in any selections (other than perhaps for monitoring purposes).
775 .. seealso:: :b2:var:`nCleanedTracks` for a more useful variable for use in selections.
777 REGISTER_VARIABLE("nChargeZeroTrackFits", nChargeZeroTrackFits, R
"DOC(
778 [Eventbased] Returns number of track fits with zero charge.
781 Sometimes, track fits can have zero charge, if background or non IP originating tracks, for example, are fit from the IP.
782 These tracks are excluded from particle lists, but a large amount of charge zero
783 fits may indicate problems with whole event constraints
784 or abnominally high beam backgrounds and/or noisy events.
787 REGISTER_VARIABLE("belleECLEnergy", belleECLEnergy, R
"DOC(
788 [Eventbased][Legacy] Returns total energy in ECL in the event as used in Belle 1 analyses.
792 For Belle II use cases use either ``totalEnergyOfParticlesInList(gamma:all)``,
793 or (probably better) fill a photon list with some minimal cleanup cuts and use that instea
795 .. code-block:: python
797 from variables import variables as vm
798 fillParticleList("gamma:cleaned", "E > 0.05 and isFromECL==1", path=path)
799 fillParticleList("e+:cleaned", "clusterE > 0.05", path=path)
800 vm.addAlias("myNeutralECLEnergy", "totalEnergyOfParticlesInList(gamma:cleaned)")
801 vm.addAlias("myChargedECLEnergy", "totalEnergyOfParticlesInList(e+:cleaned)")
802 vm.addAlias("myECLEnergy", "formula(myNeutralECLEnergy+myChargedECLEnergy)")
804 REGISTER_VARIABLE("nKLMClusters", nKLMClusters,
805 "[Eventbased] Returns number of KLM clusters in the event.");
806 REGISTER_VARIABLE(
"nMCParticles", nMCParticles,
807 "[Eventbased] Returns number of MCParticles in the event.");
809 REGISTER_VARIABLE(
"expNum", expNum,
"[Eventbased] Returns the experiment number.");
810 REGISTER_VARIABLE(
"evtNum", evtNum,
"[Eventbased] Returns the event number.");
811 REGISTER_VARIABLE(
"runNum", runNum,
"[Eventbased] Returns the run number.");
812 REGISTER_VARIABLE(
"productionIdentifier", productionIdentifier, R
"DOC(
813 [Eventbased] Production identifier.
814 Uniquely identifies an MC sample by the (grid-jargon) production ID.
815 This is useful when analysing large MC samples split between more than one production or combining different MC samples (e.g. combining all continuum samples).
816 In such cases the event numbers are sequential *only within a production*, so experiment/run/event will restart with every new sample analysed.
818 .. tip:: Experiment/run/event/production is unique for all MC samples. Experiment/run/event is unique for data.
820 .. seealso:: `Where can I rely on uniqueness of the ['__experiment__', '__run__', '__event__', '__candidate__'] combination? <https://questions.belle2.org/question/9704>`__
823 REGISTER_VARIABLE("Ecms", getCMSEnergy,
"[Eventbased] Returns center-of-mass energy.");
824 REGISTER_VARIABLE(
"beamE", getBeamE,
"[Eventbased] Returns total beam energy in the laboratory frame.");
825 REGISTER_VARIABLE(
"beamPx", getBeamPx,
"[Eventbased] Returns x component of total beam momentum in the laboratory frame.");
826 REGISTER_VARIABLE(
"beamPy", getBeamPy,
"[Eventbased] Returns y component of total beam momentum in the laboratory frame.");
827 REGISTER_VARIABLE(
"beamPz", getBeamPz,
"[Eventbased] Returns z component of total beam momentum in the laboratory frame.");
829 REGISTER_VARIABLE(
"IPX", getIPX, R
"DOC(
830 [Eventbased] Returns x coordinate of the measured interaction point.
832 .. note:: For old data and uncalibrated MC files this will return 0.0.
834 .. note:: You might hear tracking and calibration people refer to this as the ``BeamSpot``.
836 REGISTER_VARIABLE("IPY", getIPY,
"[Eventbased] Returns y coordinate of the measured interaction point.");
837 REGISTER_VARIABLE(
"IPZ", getIPZ,
"[Eventbased] Returns z coordinate of the measured interaction point.");
838 REGISTER_VARIABLE(
"IPCov(i,j)", ipCovMatrixElement,
"[Eventbased] Returns (i,j)-th element of the covariance matrix of the measured interaction point.");
840 REGISTER_VARIABLE(
"genIPX", getGenIPX, R
"DOC(
841 [Eventbased] Returns x coordinate of the interaction point used for the underlying **MC generation**.
842 Returns NaN for data.
844 .. note:: This is normally smeared from 0.0
846 REGISTER_VARIABLE("genIPY", getGenIPY,
"[Eventbased] Returns y coordinate of the interaction point used for the underlying **MC generation**. Returns NaN for data.");
847 REGISTER_VARIABLE(
"genIPZ", getGenIPZ,
"[Eventbased] Returns z coordinate of the interaction point used for the underlying **MC generation**. Returns NaN for data.");
849 REGISTER_VARIABLE(
"date", eventYearMonthDay, R
"DOC(
850 [Eventbased] Returns the date when the event was recorded, a number of the form YYYYMMDD (in UTC).
852 .. seealso:: :b2:var:`year`, :b2:var:`eventTimeSeconds`, :b2:var:`eventTimeSecondsFractionRemainder`, provided for convenience.
854 REGISTER_VARIABLE("year", eventYear, R
"DOC(
855 [Eventbased] Returns the year when the event was recorded (in UTC).
858 For more precise event time, see :b2:var:`eventTimeSeconds` and :b2:var:`eventTimeSecondsFractionRemainder`.
860 REGISTER_VARIABLE("eventTimeSeconds", eventTimeSeconds,
861 "[Eventbased] Time of the event in seconds (truncated down) since 1970/1/1 (Unix epoch).");
862 REGISTER_VARIABLE(
"eventTimeSecondsFractionRemainder", eventTimeSecondsFractionRemainder, R
"DOC(
863 [Eventbased] Remainder of the event time in fractions of a second.
866 Use eventTimeSeconds + eventTimeSecondsFractionRemainder to get the total event time in seconds.
869 REGISTER_VARIABLE("timeSincePrevTriggerClockTicks", timeSincePrevTriggerClockTicks,
870 "[Eventbased] Time since the previous trigger in clock ticks (127MHz=RF/4 clock).");
872 REGISTER_VARIABLE(
"timeSincePrevTriggerMicroSeconds", timeSincePrevTriggerMicroSeconds,
873 "[Eventbased] Time since the previous trigger in micro seconds.");
875 REGISTER_VARIABLE(
"triggeredBunchNumberTTD", triggeredBunchNumberTTD, R
"DOC(
876 [Eventbased] Number of triggered bunch ranging from 0-1279.
878 .. warning:: This is the bunch number as provided by the TTD, which does not necessarily correspond to the 'global' SKB bunch number.
879 .. 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.
882 REGISTER_VARIABLE("triggeredBunchNumber", triggeredBunchNumber, R
"DOC(
883 [Eventbased] Number of triggered bunch ranging from 0-1279.
885 .. 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
888 REGISTER_VARIABLE("hasRecentInjection", hasRecentInjection,
889 "[Eventbased] Returns 1 if an injection happened recently, 0 otherwise.");
891 REGISTER_VARIABLE(
"timeSinceLastInjectionSignalClockTicks", timeSinceLastInjectionSignalClockTicks, R
"DOC(
892 [Eventbased] Time since the last injection pre-kick signal in clock ticks (127MHz=RF/4 clock)
894 .. warning:: this returns the time without the delay until the injected bunch reaches the detector (which differs for HER/LER)
897 REGISTER_VARIABLE("timeSinceLastInjectionSignalMicroSeconds", timeSinceLastInjectionSignalMicroSeconds, R
"DOC(
898 [Eventbased] Time since the last injection pre-kick signal in micro seconds
900 .. warning:: this returns the time without the delay until the injected bunch reaches the detector (which differs for HER/LER)
903 REGISTER_VARIABLE("timeSinceLastInjectionClockTicks", timeSinceLastInjectionClockTicks,
904 "[Eventbased] Time since the last injected bunch passed by the detector in micro seconds.")
906 REGISTER_VARIABLE("timeSinceLastInjectionMicroSeconds", timeSinceLastInjectionMicroSeconds,
907 "[Eventbased] Time since the last injected bunch passed by the detector in micro seconds.")
909 REGISTER_VARIABLE("injectionInHER", injectionInHER,
910 "[Eventbased] Returns 1 if injection was in HER, 0 otherwise.");
912 REGISTER_VARIABLE("revolutionCounter2", revolutionCounter2, R"DOC(
913 [Eventbased] The lowest bit of revolution counter, i.e. return 0 or 1
915 .. note:: related to PXD data acquisition; PXD needs ~2 revolutions to read out one frame
918 VARIABLE_GROUP("EventKinematics");
920 REGISTER_VARIABLE("missingMomentumOfEvent", missingMomentumOfEvent, R"DOC(
921 [Eventbased] The magnitude of the missing momentum in laboratory frame.
923 .. warning:: You have to run the Event Kinematics builder module for this variable to be meaningful.
924 .. seealso:: `modularAnalysis.buildEventKinematics`.
926 REGISTER_VARIABLE("missingMomentumOfEvent_Px", missingMomentumOfEvent_Px, R"DOC(
927 [Eventbased] The x component of the missing momentum in laboratory frame.
929 REGISTER_VARIABLE("missingMomentumOfEvent_Py", missingMomentumOfEvent_Py, R"DOC(
930 [Eventbased] The y component of the missing momentum in laboratory frame.
932 REGISTER_VARIABLE("missingMomentumOfEvent_Pz", missingMomentumOfEvent_Pz, R"DOC(
933 [Eventbased] The z component of the missing momentum in laboratory frame.
935 REGISTER_VARIABLE("missingMomentumOfEvent_theta", missingMomentumOfEvent_theta, R"DOC(
936 [Eventbased] The theta angle of the missing momentum of the event in laboratory frame.
938 REGISTER_VARIABLE("missingMomentumOfEventCMS", missingMomentumOfEventCMS, R"DOC(
939 [Eventbased] The magnitude of the missing momentum in center-of-mass frame.
941 REGISTER_VARIABLE("genMissingMomentumOfEventCMS", genMissingMomentumOfEventCMS, R"DOC(
942 [Eventbased] The magnitude of the missing momentum in center-of-mass frame from generator
944 REGISTER_VARIABLE("missingMomentumOfEventCMS_Px", missingMomentumOfEventCMS_Px, R"DOC(
945 [Eventbased] The x component of the missing momentum in center-of-mass frame.
947 REGISTER_VARIABLE("missingMomentumOfEventCMS_Py", missingMomentumOfEventCMS_Py, R"DOC(
948 [Eventbased] The y component of the missing momentum in center-of-mass frame.
950 REGISTER_VARIABLE("missingMomentumOfEventCMS_Pz", missingMomentumOfEventCMS_Pz, R"DOC(
951 [Eventbased] The z component of the missing momentum in center-of-mass frame.
953 REGISTER_VARIABLE("missingMomentumOfEventCMS_theta", missingMomentumOfEventCMS_theta, R"DOC(
954 [Eventbased] The theta angle of the missing momentum in center-of-mass frame.
956 REGISTER_VARIABLE("missingEnergyOfEventCMS", missingEnergyOfEventCMS, R"DOC(
957 [Eventbased] The missing energy in center-of-mass frame.
959 REGISTER_VARIABLE("genMissingEnergyOfEventCMS", genMissingEnergyOfEventCMS, R"DOC(
960 [Eventbased] The missing energy in center-of-mass frame from generator.
962 REGISTER_VARIABLE("missingMass2OfEvent", missingMass2OfEvent, R"DOC(
963 [Eventbased] The missing mass squared.
965 REGISTER_VARIABLE("genMissingMass2OfEvent", genMissingMass2OfEvent, R"DOC(
966 [Eventbased] The missing mass squared from generator
968 REGISTER_VARIABLE("visibleEnergyOfEventCMS", visibleEnergyOfEventCMS, R"DOC(
969 [Eventbased] The visible energy in center-of-mass frame.
971 REGISTER_VARIABLE("genVisibleEnergyOfEventCMS", genVisibleEnergyOfEventCMS, R"DOC(
972 [Eventbased] The visible energy in center-of-mass frame from generator.
974 REGISTER_VARIABLE("totalPhotonsEnergyOfEvent", totalPhotonsEnergyOfEvent, R"DOC(
975 [Eventbased] The energy in laboratory frame of all the photons.
977 REGISTER_VARIABLE("genTotalPhotonsEnergyOfEvent", genTotalPhotonsEnergyOfEvent, R"DOC(
978 [Eventbased] The energy in laboratory frame of all the photons. from generator.
981 VARIABLE_GROUP("Event (cDST only)");
982 REGISTER_VARIABLE("eventT0", eventT0, R"DOC(
983 [Eventbased][Calibration] The Event t0, measured in ns, is the time of the event relative to the trigger time.
986 The event time can be measured by several sub-detectors including the CDC, ECL, and TOP.
987 This Event t0 variable is the final combined value of all the event time measurements.
988 Currently only the CDC and ECL are used in this combination.
@ c_nPhotons
CR is split into n photons (N1)
bool isMC() const
Do we have generated, not real data?
static Environment & Instance()
Static method to get a reference to the Environment instance.
#define MAKE_DEPRECATED(name, make_fatal, version, description)
Registers a variable as deprecated.
Abstract base class for different kinds of events.