Belle II Software development
EventKinematicsModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <analysis/utility/PCmsLabTransform.h>
10
11#include <analysis/modules/EventKinematics/EventKinematicsModule.h>
12
13#include <analysis/dataobjects/ParticleList.h>
14#include <analysis/dataobjects/Particle.h>
15
16#include <framework/logging/Logger.h>
17#include <framework/gearbox/Const.h>
18
19using namespace std;
20using namespace Belle2;
21
22//-----------------------------------------------------------------
23// Register the Module
24//-----------------------------------------------------------------
26
27//-----------------------------------------------------------------
28// Implementation
29//-----------------------------------------------------------------
30
32{
33 // Set module properties
34 setDescription("Module to compute global event kinematic attributes like missing momentum and energy.");
36
37 // Parameter definitions
38 addParam("particleLists", m_particleLists, "List of the ParticleLists", vector<string>());
39 addParam("usingMC", m_usingMC, "is built using generated particles", false);
40
41}
42
44
46{
47 auto arrayName = (!m_usingMC) ? "EventKinematics" : "EventKinematicsFromMC";
48 m_eventKinematics.registerInDataStore(arrayName);
49
50}
51
53{
56
57 ROOT::Math::XYZVector missingMomentum = EventKinematicsModule::getMissingMomentum();
58 m_eventKinematics->addMissingMomentum(missingMomentum);
59
60 ROOT::Math::XYZVector missingMomentumCMS = EventKinematicsModule::getMissingMomentumCMS();
61 m_eventKinematics->addMissingMomentumCMS(missingMomentumCMS);
62
63 float missingEnergyCMS = EventKinematicsModule::getMissingEnergyCMS();
64 m_eventKinematics->addMissingEnergyCMS(missingEnergyCMS);
65
66 float missingMass2 = missingEnergyCMS * missingEnergyCMS - missingMomentumCMS.R() * missingMomentumCMS.R();
67 m_eventKinematics->addMissingMass2(missingMass2);
68
69 float visibleEnergyCMS = EventKinematicsModule::getVisibleEnergyCMS();
70 m_eventKinematics->addVisibleEnergyCMS(visibleEnergyCMS);
71
72 float totalPhotonsEnergy = EventKinematicsModule::getTotalPhotonsEnergy();
73 m_eventKinematics->addTotalPhotonsEnergy(totalPhotonsEnergy);
74}
75
76void EventKinematicsModule::getParticleMomentumLists(const std::vector<std::string>& particleLists)
77{
79
83
84 int nParticleLists = particleLists.size();
85 B2DEBUG(10, "Number of ParticleLists to calculate Event Kinematics variables: " << nParticleLists);
86
87 for (int i_pl = 0; i_pl != nParticleLists; ++i_pl) {
88 string particleListName = particleLists[i_pl];
89 B2DEBUG(10, "ParticleList: " << particleListName);
90 StoreObjPtr<ParticleList> plist(particleListName);
91 int m_part = plist->getListSize();
92 for (int i = 0; i < m_part; i++) {
93 const Particle* part = plist->getParticle(i);
94 if (part->getParticleSource() == Particle::EParticleSourceObject::c_MCParticle and !m_usingMC) {
95 B2FATAL("EventKinematics received MCParticles as an input, but usingMC flag is false");
96 }
97 if (part->getParticleSource() != Particle::EParticleSourceObject::c_MCParticle and m_usingMC) {
98 B2FATAL("EventKinematics received reconstructed Particles as an input, but usingMC flag is true");
99 }
100
101 ROOT::Math::PxPyPzEVector p_lab = part->get4Vector();
102 m_particleMomentumList.push_back(p_lab);
103
104 if ((part->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster or
105 part->getParticleSource() == Particle::EParticleSourceObject::c_MCParticle)
106 and (part->getPDGCode() == Const::photon.getPDGCode()))
107 m_photonsMomentumList.push_back(p_lab);
108
109 ROOT::Math::PxPyPzEVector p_cms = T.rotateLabToCms() * p_lab;
110 m_particleMomentumListCMS.push_back(p_cms);
111 }
112 }
113 return;
114}
115
116
118{
120 ROOT::Math::PxPyPzEVector beam = T.getBeamFourMomentum();
121 ROOT::Math::XYZVector p = beam.Vect();
122 int nParticles = m_particleMomentumList.size();
123 for (int i = 0; i < nParticles; ++i) {
124 p -= m_particleMomentumList.at(i).Vect();
125 }
126 return p;
127}
128
130{
131 ROOT::Math::XYZVector p(0., 0., 0.);
132 int nParticles = m_particleMomentumListCMS.size();
133 for (int i = 0; i < nParticles; ++i) {
134 p -= m_particleMomentumListCMS.at(i).Vect();
135 }
136 return p;
137}
138
140{
142 float ECMS = T.getCMSEnergy();
143 int nParticles = m_particleMomentumListCMS.size();
144 for (int i = 0; i < nParticles; ++i) {
145 ECMS -= m_particleMomentumListCMS.at(i).E();
146 }
147 return ECMS;
148}
149
151{
152 float visibleE = 0.0;
153 int nParticles = m_particleMomentumListCMS.size();
154 for (int i = 0; i < nParticles; ++i) {
155 visibleE += m_particleMomentumListCMS.at(i).E();
156 }
157 return visibleE;
158}
159
161{
162 float photonsEnergy = 0.0;
163 int nParticles = m_photonsMomentumList.size();
164 for (int i = 0; i < nParticles; ++i) {
165 photonsEnergy += m_photonsMomentumList.at(i).E();
166 }
167 return photonsEnergy;
168}
static const ParticleType photon
photon particle
Definition Const.h:673
ROOT::Math::XYZVector getMissingMomentum()
Calculate the missing momentum in the lab system for this event.
float getMissingEnergyCMS()
Calculate the missing energy in the CMS for this event.
EventKinematicsModule()
Constructor: Sets the description, the properties and the parameters of the module.
float getVisibleEnergyCMS()
Calculate the visible energy in the CMS for this event.
std::vector< ROOT::Math::PxPyPzEVector > m_particleMomentumListCMS
A vector of the particles' 4-momenta in the CMS.
virtual void initialize() override
Define the physical parameters.
virtual void event() override
Define event parameters.
float getTotalPhotonsEnergy()
Calculate the energy for the photons in this event.
StoreObjPtr< EventKinematics > m_eventKinematics
event kinematics object pointer
void getParticleMomentumLists(const std::vector< std::string > &particleLists)
Fill the lists of particles' momenta.
std::vector< std::string > m_particleLists
Name of the ParticleList.
std::vector< ROOT::Math::PxPyPzEVector > m_photonsMomentumList
A vector of the photons' 4-momenta in the lab.
std::vector< ROOT::Math::PxPyPzEVector > m_particleMomentumList
A vector of the particles' 4-momenta in lab.
ROOT::Math::XYZVector getMissingMomentumCMS()
Calculate the missing momentum in the CMS for this event.
virtual ~EventKinematicsModule() override
free memory
Class for collecting variables related to the global kinematics of the event.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
Module()
Constructor.
Definition Module.cc:30
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
Class to hold Lorentz transformations from/to CMS and boost vector.
double getCMSEnergy() const
Returns CMS energy of e+e- (aka.
Class to store reconstructed particles.
Definition Particle.h:76
int getPDGCode(void) const
Returns PDG code.
Definition Particle.h:465
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Definition Particle.h:567
EParticleSourceObject getParticleSource() const
Returns particle source as defined with enum EParticleSourceObject.
Definition Particle.h:489
Type-safe access to single objects in the data store.
Definition StoreObjPtr.h:96
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.