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
77{
78}
79
80void EventKinematicsModule::getParticleMomentumLists(vector<string> particleLists)
81{
83
87
88 int nParticleLists = particleLists.size();
89 B2DEBUG(10, "Number of ParticleLists to calculate Event Kinematics variables: " << nParticleLists);
90
91 for (int i_pl = 0; i_pl != nParticleLists; ++i_pl) {
92 string particleListName = particleLists[i_pl];
93 B2DEBUG(10, "ParticleList: " << particleListName);
94 StoreObjPtr<ParticleList> plist(particleListName);
95 int m_part = plist->getListSize();
96 for (int i = 0; i < m_part; i++) {
97 const Particle* part = plist->getParticle(i);
98 if (part->getParticleSource() == Particle::EParticleSourceObject::c_MCParticle and !m_usingMC) {
99 B2FATAL("EventKinematics received MCParticles as an input, but usingMC flag is false");
100 }
101 if (part->getParticleSource() != Particle::EParticleSourceObject::c_MCParticle and m_usingMC) {
102 B2FATAL("EventKinematics received reconstructed Particles as an input, but usingMC flag is true");
103 }
104
105 ROOT::Math::PxPyPzEVector p_lab = part->get4Vector();
106 m_particleMomentumList.push_back(p_lab);
107
108 if ((part->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster or
109 part->getParticleSource() == Particle::EParticleSourceObject::c_MCParticle)
110 and (part->getPDGCode() == Const::photon.getPDGCode()))
111 m_photonsMomentumList.push_back(p_lab);
112
113 ROOT::Math::PxPyPzEVector p_cms = T.rotateLabToCms() * p_lab;
114 m_particleMomentumListCMS.push_back(p_cms);
115 }
116 }
117 return;
118}
119
120
122{
124 ROOT::Math::PxPyPzEVector beam = T.getBeamFourMomentum();
125 ROOT::Math::XYZVector p = beam.Vect();
126 int nParticles = m_particleMomentumList.size();
127 for (int i = 0; i < nParticles; ++i) {
128 p -= m_particleMomentumList.at(i).Vect();
129 }
130 return p;
131}
132
134{
135 ROOT::Math::XYZVector p(0., 0., 0.);
136 int nParticles = m_particleMomentumListCMS.size();
137 for (int i = 0; i < nParticles; ++i) {
138 p -= m_particleMomentumListCMS.at(i).Vect();
139 }
140 return p;
141}
142
144{
146 float ECMS = T.getCMSEnergy();
147 int nParticles = m_particleMomentumListCMS.size();
148 for (int i = 0; i < nParticles; ++i) {
149 ECMS -= m_particleMomentumListCMS.at(i).E();
150 }
151 return ECMS;
152}
153
155{
156 float visibleE = 0.0;
157 int nParticles = m_particleMomentumListCMS.size();
158 for (int i = 0; i < nParticles; ++i) {
159 visibleE += m_particleMomentumListCMS.at(i).E();
160 }
161 return visibleE;
162}
163
165{
166 float photonsEnergy = 0.0;
167 int nParticles = m_photonsMomentumList.size();
168 for (int i = 0; i < nParticles; ++i) {
169 photonsEnergy += m_photonsMomentumList.at(i).E();
170 }
171 return photonsEnergy;
172}
int getPDGCode() const
PDG code.
Definition: Const.h:473
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.
void getParticleMomentumLists(std::vector< std::string > particleLists)
Fill the lists of particles' momenta.
virtual void event() override
Define event parameters.
virtual void terminate() override
finish the execution
float getTotalPhotonsEnergy()
Calculate the energy for the photons in this event.
StoreObjPtr< EventKinematics > m_eventKinematics
event kinematics object pointer
virtual ~EventKinematicsModule()
free memory
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.
Class for collecting variables related to the global kinematics of the event.
Base class for Modules.
Definition: Module.h:72
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
@ 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.
ROOT::Math::PxPyPzEVector getBeamFourMomentum() const
Returns LAB four-momentum of e+e-, i.e.
double getCMSEnergy() const
Returns CMS energy of e+e- (aka.
const ROOT::Math::LorentzRotation rotateLabToCms() const
Returns Lorentz transformation from Lab to CMS.
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:95
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.