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>
29 #include <framework/dataobjects/EventT0.h>
30 #include <mdst/dataobjects/EventLevelTriggerTimeInfo.h>
33 #include <framework/database/DBObjPtr.h>
34 #include <mdst/dbobjects/BeamSpot.h>
36 #include <analysis/utility/PCmsLabTransform.h>
38 #include <framework/core/Environment.h>
39 #include <framework/logging/Logger.h>
49 bool isMC(
const Particle*)
54 bool eventType(
const Particle*)
56 StoreArray<MCParticle> mcparticles;
57 return (mcparticles.getEntries()) > 0 ? 0 : 1;
60 bool isContinuumEvent(
const Particle*)
62 return (isNotContinuumEvent(
nullptr) == 1 ? 0 : 1);
65 bool isChargedBEvent(
const Particle*)
67 StoreArray<MCParticle> mcParticles;
68 for (
const auto& mcp : mcParticles) {
69 int pdg_no = mcp.getPDG();
70 if (abs(pdg_no) == 521)
return 1.0;
75 double isUnmixedBEvent(
const Particle*)
77 StoreArray<MCParticle> mcParticles;
78 std::vector<int> bPDGs;
79 for (
const auto& mcp : mcParticles) {
80 int pdg_no = mcp.getPDG();
81 if (abs(pdg_no) == 511) bPDGs.push_back(pdg_no);
83 if (bPDGs.size() == 2) {
84 return bPDGs[0] * bPDGs[1] < 0;
86 return std::numeric_limits<float>::quiet_NaN();
89 bool isNotContinuumEvent(
const Particle*)
91 StoreArray<MCParticle> mcParticles;
92 for (
const MCParticle& mcp : mcParticles) {
93 int pdg_no = mcp.getPDG();
94 if (mcp.getMother() ==
nullptr &&
99 (pdg_no == 9000553) ||
100 (pdg_no == 9010553)))
106 int nMCParticles(
const Particle*)
108 StoreArray<MCParticle> mcps;
109 return mcps.getEntries();
112 int nPrimaryMCParticles(
const Particle*)
115 StoreArray<MCParticle> mcps;
116 for (
const auto& mcp : mcps)
117 if (mcp.isPrimaryParticle())
122 int nInitialPrimaryMCParticles(
const Particle*)
125 StoreArray<MCParticle> mcps;
126 for (
const auto& mcp : mcps)
127 if (mcp.isInitial() and mcp.isPrimaryParticle())
132 int nVirtualPrimaryMCParticles(
const Particle*)
135 StoreArray<MCParticle> mcps;
136 for (
const auto& mcp : mcps)
137 if (mcp.isVirtual() and mcp.isPrimaryParticle())
142 int nTracks(
const Particle*)
144 StoreArray<Track> tracks;
145 return tracks.getEntries();
148 int nChargeZeroTrackFits(
const Particle*)
150 StoreArray<TrackFitResult> tfrs;
152 for (
const auto& t : tfrs)
153 if (t.getChargeSign() == 0) out++;
157 double belleECLEnergy(
const Particle*)
159 StoreArray<ECLCluster> eclClusters;
161 for (
int i = 0; i < eclClusters.getEntries(); ++i) {
171 int nKLMClusters(
const Particle*)
173 StoreArray<KLMCluster> klmClusters;
174 return klmClusters.getEntries();
177 int expNum(
const Particle*)
179 StoreObjPtr<EventMetaData> evtMetaData;
180 int exp_no = evtMetaData->getExperiment();
184 int productionIdentifier(
const Particle*)
186 StoreObjPtr<EventMetaData> evtMetaData;
187 int eventProduction = evtMetaData->getProduction();
188 return eventProduction;
191 int evtNum(
const Particle*)
193 StoreObjPtr<EventMetaData> evtMetaData;
194 int evt_no = evtMetaData->getEvent();
198 int runNum(
const Particle*)
200 StoreObjPtr<EventMetaData> evtMetaData;
201 int run_no = evtMetaData->getRun();
206 double getCMSEnergy(
const Particle*)
209 return T.getCMSEnergy();
212 double getBeamPx(
const Particle*)
215 return (T.getBeamFourMomentum()).Px();
218 double getBeamPy(
const Particle*)
221 return (T.getBeamFourMomentum()).Py();
224 double getBeamPz(
const Particle*)
227 return (T.getBeamFourMomentum()).Pz();
230 double getBeamE(
const Particle*)
233 return (T.getBeamFourMomentum()).E();
236 double getGenIPX(
const Particle*)
240 StoreArray<MCParticle> mcps;
241 for (
const auto& mcp : mcps)
242 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
243 return mcp.getVertex().X();
244 return std::numeric_limits<double>::quiet_NaN();
247 double getGenIPY(
const Particle*)
249 StoreArray<MCParticle> mcps;
250 for (
const auto& mcp : mcps)
251 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
252 return mcp.getVertex().Y();
253 return std::numeric_limits<double>::quiet_NaN();
256 double getGenIPZ(
const Particle*)
258 StoreArray<MCParticle> mcps;
259 for (
const auto& mcp : mcps)
260 if (not mcp.isInitial() and not mcp.isVirtual() and mcp.isPrimaryParticle())
261 return mcp.getVertex().Z();
262 return std::numeric_limits<double>::quiet_NaN();
265 double getIPX(
const Particle*)
267 static DBObjPtr<BeamSpot> beamSpotDB;
268 return (beamSpotDB->getIPPosition()).X();
271 double getIPY(
const Particle*)
273 static DBObjPtr<BeamSpot> beamSpotDB;
274 return (beamSpotDB->getIPPosition()).Y();
277 double getIPZ(
const Particle*)
279 static DBObjPtr<BeamSpot> beamSpotDB;
280 return (beamSpotDB->getIPPosition()).Z();
283 double ipCovMatrixElement(
const Particle*,
const std::vector<double>& element)
285 int elementI = int(std::lround(element[0]));
286 int elementJ = int(std::lround(element[1]));
288 if (elementI < 0 || elementI > 3) {
289 B2WARNING(
"Requested IP covariance matrix element is out of boundaries [0 - 3]:" <<
LogVar(
"i", elementI));
290 return std::numeric_limits<float>::quiet_NaN();
292 if (elementJ < 0 || elementJ > 3) {
293 B2WARNING(
"Requested particle's momentumVertex covariance matrix element is out of boundaries [0 - 3]:" <<
LogVar(
"j", elementJ));
294 return std::numeric_limits<float>::quiet_NaN();
297 static DBObjPtr<BeamSpot> beamSpotDB;
298 return beamSpotDB->getCovVertex()(elementI, elementJ);
302 double missingMomentumOfEvent(
const Particle*)
304 StoreObjPtr<EventKinematics> evtShape;
306 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
307 return std::numeric_limits<float>::quiet_NaN();
309 double missing = evtShape->getMissingMomentum().R();
313 double missingMomentumOfEvent_Px(
const Particle*)
315 StoreObjPtr<EventKinematics> evtShape;
317 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
318 return std::numeric_limits<float>::quiet_NaN();
320 double missing = evtShape->getMissingMomentum().X();
324 double missingMomentumOfEvent_Py(
const Particle*)
326 StoreObjPtr<EventKinematics> evtShape;
328 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
329 return std::numeric_limits<float>::quiet_NaN();
331 double missing = evtShape->getMissingMomentum().Y();
335 double missingMomentumOfEvent_Pz(
const Particle*)
337 StoreObjPtr<EventKinematics> evtShape;
339 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
340 return std::numeric_limits<float>::quiet_NaN();
342 double missing = evtShape->getMissingMomentum().Z();
346 double missingMomentumOfEvent_theta(
const Particle*)
348 StoreObjPtr<EventKinematics> evtShape;
350 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
351 return std::numeric_limits<float>::quiet_NaN();
353 double missing = evtShape->getMissingMomentum().Theta();
357 double missingMomentumOfEventCMS(
const Particle*)
359 StoreObjPtr<EventKinematics> evtShape;
361 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
362 return std::numeric_limits<float>::quiet_NaN();
364 double missing = evtShape->getMissingMomentumCMS().R();
368 double genMissingMomentumOfEventCMS(
const Particle*)
370 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
372 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
373 return std::numeric_limits<float>::quiet_NaN();
375 double missing = evtShape->getMissingMomentumCMS().R();
379 double missingMomentumOfEventCMS_Px(
const Particle*)
381 StoreObjPtr<EventKinematics> evtShape;
383 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
384 return std::numeric_limits<float>::quiet_NaN();
386 double missing = evtShape->getMissingMomentumCMS().X();
390 double missingMomentumOfEventCMS_Py(
const Particle*)
392 StoreObjPtr<EventKinematics> evtShape;
394 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
395 return std::numeric_limits<float>::quiet_NaN();
397 double missing = evtShape->getMissingMomentumCMS().Y();
401 double missingMomentumOfEventCMS_Pz(
const Particle*)
403 StoreObjPtr<EventKinematics> evtShape;
405 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
406 return std::numeric_limits<float>::quiet_NaN();
408 double missing = evtShape->getMissingMomentumCMS().Z();
412 double missingMomentumOfEventCMS_theta(
const Particle*)
414 StoreObjPtr<EventKinematics> evtShape;
416 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
417 return std::numeric_limits<float>::quiet_NaN();
419 double theta = evtShape->getMissingMomentumCMS().Theta();
423 double missingEnergyOfEventCMS(
const Particle*)
425 StoreObjPtr<EventKinematics> evtShape;
427 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
428 return std::numeric_limits<float>::quiet_NaN();
430 double missing = evtShape->getMissingEnergyCMS();
434 double genMissingEnergyOfEventCMS(
const Particle*)
436 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
438 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
439 return std::numeric_limits<float>::quiet_NaN();
441 double missing = evtShape->getMissingEnergyCMS();
446 double missingMass2OfEvent(
const Particle*)
448 StoreObjPtr<EventKinematics> evtShape;
450 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
451 return std::numeric_limits<float>::quiet_NaN();
453 double missing = evtShape->getMissingMass2();
457 double genMissingMass2OfEvent(
const Particle*)
459 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
461 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
462 return std::numeric_limits<float>::quiet_NaN();
464 double missing = evtShape->getMissingMass2();
468 double visibleEnergyOfEventCMS(
const Particle*)
470 StoreObjPtr<EventKinematics> evtShape;
472 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
473 return std::numeric_limits<float>::quiet_NaN();
475 double visible = evtShape->getVisibleEnergyCMS();
479 double genVisibleEnergyOfEventCMS(
const Particle*)
481 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
483 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
484 return std::numeric_limits<float>::quiet_NaN();
486 double visible = evtShape->getVisibleEnergyCMS();
491 double totalPhotonsEnergyOfEvent(
const Particle*)
493 StoreObjPtr<EventKinematics> evtShape;
495 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule?");
496 return std::numeric_limits<float>::quiet_NaN();
498 double energyOfPhotons = evtShape->getTotalPhotonsEnergy();
499 return energyOfPhotons;
502 double genTotalPhotonsEnergyOfEvent(
const Particle*)
504 StoreObjPtr<EventKinematics> evtShape(
"EventKinematicsFromMC");
506 B2WARNING(
"Cannot find missing momentum information, did you forget to run EventKinematicsModule with usingMC parameter set to true?");
507 return std::numeric_limits<float>::quiet_NaN();
509 double energyOfPhotons = evtShape->getTotalPhotonsEnergy();
510 return energyOfPhotons;
513 double eventYearMonthDay(
const Particle*)
515 StoreObjPtr<EventMetaData> evtMetaData;
517 return std::numeric_limits<float>::quiet_NaN();
519 std::time_t rawtime = trunc(evtMetaData->getTime() / 1e9);
520 auto tt = std::gmtime(&rawtime);
521 int y = tt->tm_year + 1900;
522 int m = tt->tm_mon + 1;
524 return (y * 1e4) + (m * 1e2) + d;
527 double eventYear(
const Particle*)
529 StoreObjPtr<EventMetaData> evtMetaData;
531 return std::numeric_limits<float>::quiet_NaN();
533 std::time_t rawtime = trunc(evtMetaData->getTime() / 1e9);
534 auto tt = std::gmtime(&rawtime);
535 return tt->tm_year + 1900;
538 double eventTimeSeconds(
const Particle*)
540 StoreObjPtr<EventMetaData> evtMetaData;
543 return std::numeric_limits<float>::quiet_NaN();
545 double evtTime = trunc(evtMetaData->getTime() / 1e9);
550 double eventTimeSecondsFractionRemainder(
const Particle*)
552 StoreObjPtr<EventMetaData> evtMetaData;
555 return std::numeric_limits<float>::quiet_NaN();
557 double evtTime = trunc(evtMetaData->getTime() / 1e9);
559 double evtTimeFrac = (evtMetaData->getTime() - evtTime * 1e9) / 1e9;
564 double eventT0(
const Particle*)
566 StoreObjPtr<EventT0> evtT0;
569 B2WARNING(
"StoreObjPtr<EventT0> does not exist, are you running over cDST data?");
570 return std::numeric_limits<float>::quiet_NaN();
573 if (evtT0->hasEventT0()) {
574 return evtT0->getEventT0();
576 return std::numeric_limits<float>::quiet_NaN();
580 double timeSincePrevTriggerClockTicks(
const Particle*)
582 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
585 if (!TTDInfo.isValid()) {
586 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
587 return std::numeric_limits<float>::quiet_NaN();
591 if (TTDInfo->isValid()) {
592 return TTDInfo->getTimeSincePrevTrigger();
594 return std::numeric_limits<float>::quiet_NaN();
598 double timeSincePrevTriggerMicroSeconds(
const Particle*)
600 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
603 if (!TTDInfo.isValid()) {
604 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
605 return std::numeric_limits<float>::quiet_NaN();
609 if (TTDInfo->isValid()) {
610 return TTDInfo->getTimeSincePrevTriggerInMicroSeconds();
612 return std::numeric_limits<float>::quiet_NaN();
616 double triggeredBunchNumberTTD(
const Particle*)
618 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
621 if (!TTDInfo.isValid()) {
622 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
623 return std::numeric_limits<float>::quiet_NaN();
627 if (TTDInfo->isValid()) {
628 return TTDInfo->getBunchNumber();
630 return std::numeric_limits<float>::quiet_NaN();
634 double triggeredBunchNumber(
const Particle*)
636 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
639 if (!TTDInfo.isValid()) {
640 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
641 return std::numeric_limits<float>::quiet_NaN();
645 if (TTDInfo->isValid()) {
646 return TTDInfo->getTriggeredBunchNumberGlobal();
648 return std::numeric_limits<float>::quiet_NaN();
652 double hasRecentInjection(
const Particle*)
654 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
657 if (!TTDInfo.isValid()) {
658 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
659 return std::numeric_limits<float>::quiet_NaN();
663 if (TTDInfo->isValid()) {
664 return TTDInfo->hasInjection();
666 return std::numeric_limits<float>::quiet_NaN();
670 double timeSinceLastInjectionSignalClockTicks(
const Particle*)
672 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
675 if (!TTDInfo.isValid()) {
676 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
677 return std::numeric_limits<float>::quiet_NaN();
681 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
682 return TTDInfo->getTimeSinceLastInjection();
684 return std::numeric_limits<float>::quiet_NaN();
688 double timeSinceLastInjectionSignalMicroSeconds(
const Particle*)
690 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
693 if (!TTDInfo.isValid()) {
694 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
695 return std::numeric_limits<float>::quiet_NaN();
699 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
700 return TTDInfo->getTimeSinceLastInjectionInMicroSeconds();
702 return std::numeric_limits<float>::quiet_NaN();
706 double timeSinceLastInjectionClockTicks(
const Particle*)
708 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
711 if (!TTDInfo.isValid()) {
712 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
713 return std::numeric_limits<float>::quiet_NaN();
717 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
718 return TTDInfo->getTimeSinceInjectedBunch();
720 return std::numeric_limits<float>::quiet_NaN();
724 double timeSinceLastInjectionMicroSeconds(
const Particle*)
726 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
729 if (!TTDInfo.isValid()) {
730 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
731 return std::numeric_limits<float>::quiet_NaN();
735 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
736 return TTDInfo->getTimeSinceInjectedBunchInMicroSeconds();
738 return std::numeric_limits<float>::quiet_NaN();
742 double injectionInHER(
const Particle*)
744 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
747 if (!TTDInfo.isValid()) {
748 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
749 return std::numeric_limits<float>::quiet_NaN();
753 if (TTDInfo->isValid() && TTDInfo->hasInjection()) {
754 return TTDInfo->isHER();
756 return std::numeric_limits<float>::quiet_NaN();
760 double revolutionCounter2(
const Particle*)
762 StoreObjPtr<EventLevelTriggerTimeInfo> TTDInfo;
765 if (!TTDInfo.isValid()) {
766 B2WARNING(
"StoreObjPtr<EventLevelTriggerTimeInfo> does not exist, are you running over data reconstructed with release-05 or earlier?");
767 return std::numeric_limits<float>::quiet_NaN();
771 if (TTDInfo->isValid()) {
772 return TTDInfo->isRevo2();
774 return std::numeric_limits<float>::quiet_NaN();
779 VARIABLE_GROUP(
"Event");
781 REGISTER_VARIABLE(
"isMC", isMC,
782 "[Eventbased] Returns 1 if current basf2 process is running over simulated (Monte-Carlo) dataset and 0 in case of real experimental data.");
783 REGISTER_VARIABLE(
"isContinuumEvent", isContinuumEvent,
784 "[Eventbased] Returns 1.0 if event doesn't contain a :math:`\\Upsilon(4S)` particle on generator level, 0.0 otherwise.");
785 REGISTER_VARIABLE(
"isNotContinuumEvent", isNotContinuumEvent,
786 "[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.");
788 REGISTER_VARIABLE(
"isChargedBEvent", isChargedBEvent,
789 "[Eventbased] Returns 1.0 if event contains a charged B-meson on generator level.");
790 REGISTER_VARIABLE(
"isUnmixedBEvent", isUnmixedBEvent,
791 R
"DOC([Eventbased] Returns 1.0 if the event contains opposite flavor neutral B-mesons on generator level,
792 0.0 in case of same flavor B-mesons and NaN if the event has no generated neutral B.)DOC");
794 REGISTER_VARIABLE("nTracks", nTracks, R
"DOC(
795 [Eventbased] Returns the total number of tracks (unfiltered) in the event.
797 .. warning:: This variable is exceedingly background-dependent and should not really be used in any selections (other than perhaps for monitoring purposes).
798 .. seealso:: :b2:var:`nCleanedTracks` for a more useful variable for use in selections.
800 REGISTER_VARIABLE("nChargeZeroTrackFits", nChargeZeroTrackFits, R
"DOC(
801 [Eventbased] Returns number of track fits with zero charge.
804 Sometimes, track fits can have zero charge, if background or non IP originating tracks, for example, are fit from the IP.
805 These tracks are excluded from particle lists, but a large amount of charge zero
806 fits may indicate problems with whole event constraints
807 or abnominally high beam backgrounds and/or noisy events.
810 REGISTER_VARIABLE("belleECLEnergy", belleECLEnergy, R
"DOC(
811 [Eventbased][Legacy] Returns total energy in ECL in the event as used in Belle 1 analyses.
815 For Belle II use cases use either ``totalEnergyOfParticlesInList(gamma:all)``,
816 or (probably better) fill a photon list with some minimal cleanup cuts and use that instea
818 .. code-block:: python
820 from variables import variables as vm
821 fillParticleList("gamma:cleaned", "E > 0.05 and isFromECL==1", path=path)
822 fillParticleList("e+:cleaned", "clusterE > 0.05", path=path)
823 vm.addAlias("myNeutralECLEnergy", "totalEnergyOfParticlesInList(gamma:cleaned)")
824 vm.addAlias("myChargedECLEnergy", "totalEnergyOfParticlesInList(e+:cleaned)")
825 vm.addAlias("myECLEnergy", "formula(myNeutralECLEnergy+myChargedECLEnergy)")
827 REGISTER_VARIABLE("nKLMClusters", nKLMClusters,
828 "[Eventbased] Returns number of KLM clusters in the event.");
829 REGISTER_VARIABLE("nMCParticles", nMCParticles,
830 "[Eventbased] Returns number of MCParticles in the event.");
831 REGISTER_VARIABLE("nPrimaryMCParticles", nPrimaryMCParticles,
832 "[Eventbased] Returns number of primary MCParticles in the event.");
833 REGISTER_VARIABLE("nInitialPrimaryMCParticles", nInitialPrimaryMCParticles,
834 "[Eventbased] Returns number of initial primary MCParticles in the event.");
835 REGISTER_VARIABLE("nVirtualPrimaryMCParticles", nVirtualPrimaryMCParticles,
836 "[Eventbased] Returns number of virtual primary MCParticles in the event.");
838 REGISTER_VARIABLE("expNum", expNum, "[Eventbased] Returns the experiment number.");
839 REGISTER_VARIABLE("evtNum", evtNum, "[Eventbased] Returns the event number.");
840 REGISTER_VARIABLE("runNum", runNum, "[Eventbased] Returns the run number.");
841 REGISTER_VARIABLE("productionIdentifier", productionIdentifier, R"DOC(
842 [Eventbased] Production identifier.
843 Uniquely identifies an MC sample by the (grid-jargon) production ID.
844 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).
845 In such cases the event numbers are sequential *only within a production*, so experiment/run/event will restart with every new sample analysed.
847 .. tip:: Experiment/run/event/production is unique for all MC samples. Experiment/run/event is unique for data.
849 .. seealso:: `Where can I rely on uniqueness of the ['__experiment__', '__run__', '__event__', '__candidate__'] combination? <https://questions.belle2.org/question/9704>`__
852 REGISTER_VARIABLE("Ecms", getCMSEnergy,
"[Eventbased] Returns center-of-mass energy.",
"GeV");
853 REGISTER_VARIABLE(
"beamE", getBeamE,
"[Eventbased] Returns total beam energy in the laboratory frame.",
"GeV");
854 REGISTER_VARIABLE(
"beamPx", getBeamPx,
"[Eventbased] Returns x component of total beam momentum in the laboratory frame.",
"GeV/c");
855 REGISTER_VARIABLE(
"beamPy", getBeamPy,
"[Eventbased] Returns y component of total beam momentum in the laboratory frame.",
"GeV/c");
856 REGISTER_VARIABLE(
"beamPz", getBeamPz,
"[Eventbased] Returns z component of total beam momentum in the laboratory frame.",
"GeV/c");
857 REGISTER_VARIABLE(
"IPX", getIPX, R
"DOC(
858 [Eventbased] Returns x coordinate of the measured interaction point.
860 .. note:: For old data and uncalibrated MC files this will return 0.0.
862 .. note:: You might hear tracking and calibration people refer to this as the ``BeamSpot``.
864 REGISTER_VARIABLE("IPY", getIPY, "[Eventbased] Returns y coordinate of the measured interaction point.","cm");
865 REGISTER_VARIABLE("IPZ", getIPZ, "[Eventbased] Returns z coordinate of the measured interaction point.","cm");
866 REGISTER_VARIABLE("IPCov(i,j)", ipCovMatrixElement, "[Eventbased] Returns (i,j)-th element of the covariance matrix of the measured interaction point.",":math:`\\text{cm}^2`");
868 REGISTER_VARIABLE("genIPX", getGenIPX, R"DOC(
869 [Eventbased] Returns x coordinate of the interaction point used for the underlying **MC generation**.
870 Returns NaN for data.
872 .. note:: This is normally smeared from 0.0
874 REGISTER_VARIABLE("genIPY", getGenIPY, "[Eventbased] Returns y coordinate of the interaction point used for the underlying **MC generation**. Returns NaN for data.","cm");
875 REGISTER_VARIABLE("genIPZ", getGenIPZ, "[Eventbased] Returns z coordinate of the interaction point used for the underlying **MC generation**. Returns NaN for data.","cm");
877 REGISTER_VARIABLE("date", eventYearMonthDay, R"DOC(
878 [Eventbased] Returns the date when the event was recorded, a number of the form YYYYMMDD (in UTC).
880 .. seealso:: :b2:var:`year`, :b2:var:`eventTimeSeconds`, :b2:var:`eventTimeSecondsFractionRemainder`, provided for convenience.
882 REGISTER_VARIABLE("year", eventYear, R
"DOC(
883 [Eventbased] Returns the year when the event was recorded (in UTC).
886 For more precise event time, see :b2:var:`eventTimeSeconds` and :b2:var:`eventTimeSecondsFractionRemainder`.
888 REGISTER_VARIABLE("eventTimeSeconds", eventTimeSeconds,
889 "[Eventbased] Time of the event (truncated down) since 1970/1/1 (Unix epoch).",
"s");
890 REGISTER_VARIABLE(
"eventTimeSecondsFractionRemainder", eventTimeSecondsFractionRemainder, R
"DOC(
891 [Eventbased] Remainder of the event time.
894 Use eventTimeSeconds + eventTimeSecondsFractionRemainder to get the total event time in seconds.
897 REGISTER_VARIABLE("timeSincePrevTriggerClockTicks", timeSincePrevTriggerClockTicks,
898 "[Eventbased] Time since the previous trigger (127MHz=RF/4 clock).","clock ticks");
900 REGISTER_VARIABLE("timeSincePrevTriggerMicroSeconds", timeSincePrevTriggerMicroSeconds,
901 "[Eventbased] Time since the previous trigger.",":math:`\\mathrm{\\mu s}`");
903 REGISTER_VARIABLE("triggeredBunchNumberTTD", triggeredBunchNumberTTD, R"DOC(
904 [Eventbased] Number of triggered bunch ranging from 0-1279.
906 .. warning:: This is the bunch number as provided by the TTD, which does not necessarily correspond to the 'global' SKB bunch number.
907 .. 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.
910 REGISTER_VARIABLE("triggeredBunchNumber", triggeredBunchNumber, R
"DOC(
911 [Eventbased] Number of triggered bunch ranging from 0-1279.
913 .. 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
916 REGISTER_VARIABLE("hasRecentInjection", hasRecentInjection,
917 "[Eventbased] Returns 1 if an injection happened recently, 0 otherwise.");
919 REGISTER_VARIABLE(
"timeSinceLastInjectionSignalClockTicks", timeSinceLastInjectionSignalClockTicks, R
"DOC(
920 [Eventbased] Time since the last injection pre-kick signal (127MHz=RF/4 clock)
922 .. warning:: this returns the time without the delay until the injected bunch reaches the detector (which differs for HER/LER)
923 )DOC","clock ticks");
925 REGISTER_VARIABLE("timeSinceLastInjectionSignalMicroSeconds", timeSinceLastInjectionSignalMicroSeconds, R"DOC(
926 [Eventbased] Time since the last injection pre-kick signal
928 .. warning:: this returns the time without the delay until the injected bunch reaches the detector (which differs for HER/LER)
929 )DOC",":math:`\\mathrm{\\mu s}`");
931 REGISTER_VARIABLE("timeSinceLastInjectionClockTicks", timeSinceLastInjectionClockTicks,
932 "[Eventbased] Time since the last injected bunch passed by the detector.","clock ticks")
934 REGISTER_VARIABLE("timeSinceLastInjectionMicroSeconds", timeSinceLastInjectionMicroSeconds,
935 "[Eventbased] Time since the last injected bunch passed by the detector.",":math:`\\mathrm{\\mu s}`")
937 REGISTER_VARIABLE("injectionInHER", injectionInHER,
938 "[Eventbased] Returns 1 if injection was in HER, 0 otherwise.");
940 REGISTER_VARIABLE("revolutionCounter2", revolutionCounter2, R"DOC(
941 [Eventbased] The lowest bit of revolution counter, i.e. return 0 or 1
943 .. note:: related to PXD data acquisition; PXD needs ~2 revolutions to read out one frame
946 VARIABLE_GROUP("EventKinematics");
948 REGISTER_VARIABLE(
"missingMomentumOfEvent", missingMomentumOfEvent, R
"DOC(
949 [Eventbased] The magnitude of the missing momentum in laboratory frame.
951 .. warning:: You have to run the Event Kinematics builder module for this variable to be meaningful.
952 .. seealso:: `modularAnalysis.buildEventKinematics`.
954 REGISTER_VARIABLE("missingMomentumOfEvent_Px", missingMomentumOfEvent_Px, R"DOC(
955 [Eventbased] The x component of the missing momentum in laboratory frame.
957 REGISTER_VARIABLE("missingMomentumOfEvent_Py", missingMomentumOfEvent_Py, R"DOC(
958 [Eventbased] The y component of the missing momentum in laboratory frame.
960 REGISTER_VARIABLE("missingMomentumOfEvent_Pz", missingMomentumOfEvent_Pz, R"DOC(
961 [Eventbased] The z component of the missing momentum in laboratory frame.
963 REGISTER_VARIABLE("missingMomentumOfEvent_theta", missingMomentumOfEvent_theta, R"DOC(
964 [Eventbased] The theta angle of the missing momentum of the event in laboratory frame.
966 REGISTER_VARIABLE("missingMomentumOfEventCMS", missingMomentumOfEventCMS, R"DOC(
967 [Eventbased] The magnitude of the missing momentum in center-of-mass frame.
969 REGISTER_VARIABLE("genMissingMomentumOfEventCMS", genMissingMomentumOfEventCMS, R"DOC(
970 [Eventbased] The magnitude of the missing momentum in center-of-mass frame from generator
972 REGISTER_VARIABLE("missingMomentumOfEventCMS_Px", missingMomentumOfEventCMS_Px, R"DOC(
973 [Eventbased] The x component of the missing momentum in center-of-mass frame.
975 REGISTER_VARIABLE("missingMomentumOfEventCMS_Py", missingMomentumOfEventCMS_Py, R"DOC(
976 [Eventbased] The y component of the missing momentum in center-of-mass frame.
978 REGISTER_VARIABLE("missingMomentumOfEventCMS_Pz", missingMomentumOfEventCMS_Pz, R"DOC(
979 [Eventbased] The z component of the missing momentum in center-of-mass frame.
981 REGISTER_VARIABLE("missingMomentumOfEventCMS_theta", missingMomentumOfEventCMS_theta, R"DOC(
982 [Eventbased] The theta angle of the missing momentum in center-of-mass frame.
984 REGISTER_VARIABLE("missingEnergyOfEventCMS", missingEnergyOfEventCMS, R"DOC(
985 [Eventbased] The missing energy in center-of-mass frame.
987 REGISTER_VARIABLE("genMissingEnergyOfEventCMS", genMissingEnergyOfEventCMS, R"DOC(
988 [Eventbased] The missing energy in center-of-mass frame from generator.
990 REGISTER_VARIABLE("missingMass2OfEvent", missingMass2OfEvent, R"DOC(
991 [Eventbased] The missing mass squared.
992 )DOC",":math:`[\\text{GeV}/\\text{c}^2]^2`");
993 REGISTER_VARIABLE("genMissingMass2OfEvent", genMissingMass2OfEvent, R"DOC(
994 [Eventbased] The missing mass squared from generator
995 )DOC",":math:`[\\text{GeV}/\\text{c}^2]^2`");
996 REGISTER_VARIABLE("visibleEnergyOfEventCMS", visibleEnergyOfEventCMS, R"DOC(
997 [Eventbased] The visible energy in center-of-mass frame.
999 REGISTER_VARIABLE("genVisibleEnergyOfEventCMS", genVisibleEnergyOfEventCMS, R"DOC(
1000 [Eventbased] The visible energy in center-of-mass frame from generator.
1002 REGISTER_VARIABLE("totalPhotonsEnergyOfEvent", totalPhotonsEnergyOfEvent, R"DOC(
1003 [Eventbased] The energy in laboratory frame of all the photons.
1005 REGISTER_VARIABLE("genTotalPhotonsEnergyOfEvent", genTotalPhotonsEnergyOfEvent, R"DOC(
1006 [Eventbased] The energy in laboratory frame of all the photons. from generator.
1009 VARIABLE_GROUP("Event (cDST only)");
1010 REGISTER_VARIABLE("eventT0", eventT0, R"DOC(
1011 [Eventbased][Calibration] The Event t0, is the time of the event relative to the trigger time.
1014 The event time can be measured by several sub-detectors including the SVD, CDC, ECL, and TOP.
1015 This eventT0 variable is the final combined value of all the event time measurements.
1016 Currently, only the SVD 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.
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.