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
19#include <iostream>
20
21using namespace std;
22using namespace Belle2;
23
24//-----------------------------------------------------------------
25// Register the Module
26//-----------------------------------------------------------------
28
29//-----------------------------------------------------------------
30// Implementation
31//-----------------------------------------------------------------
32
34{
35 // Set module properties
36 setDescription("Module to compute global event kinematic attributes like missing momentum and energy.");
37
38 // Parameter definitions
39 addParam("particleLists", m_particleLists, "List of the ParticleLists", vector<string>());
40 addParam("usingMC", m_usingMC, "is built using generated particles", false);
41
42}
43
45
47{
48 auto arrayName = (!m_usingMC) ? "EventKinematics" : "EventKinematicsFromMC";
49 m_eventKinematics.registerInDataStore(arrayName);
50
51}
52
54{
57
58 ROOT::Math::XYZVector missingMomentum = EventKinematicsModule::getMissingMomentum();
59 m_eventKinematics->addMissingMomentum(missingMomentum);
60
61 ROOT::Math::XYZVector missingMomentumCMS = EventKinematicsModule::getMissingMomentumCMS();
62 m_eventKinematics->addMissingMomentumCMS(missingMomentumCMS);
63
64 float missingEnergyCMS = EventKinematicsModule::getMissingEnergyCMS();
65 m_eventKinematics->addMissingEnergyCMS(missingEnergyCMS);
66
67 float missingMass2 = missingEnergyCMS * missingEnergyCMS - missingMomentumCMS.R() * missingMomentumCMS.R();
68 m_eventKinematics->addMissingMass2(missingMass2);
69
70 float visibleEnergyCMS = EventKinematicsModule::getVisibleEnergyCMS();
71 m_eventKinematics->addVisibleEnergyCMS(visibleEnergyCMS);
72
73 float totalPhotonsEnergy = EventKinematicsModule::getTotalPhotonsEnergy();
74 m_eventKinematics->addTotalPhotonsEnergy(totalPhotonsEnergy);
75}
76
78{
79}
80
81void EventKinematicsModule::getParticleMomentumLists(vector<string> particleLists)
82{
84
88
89 int nParticleLists = particleLists.size();
90 B2DEBUG(10, "Number of ParticleLists to calculate Event Kinematics variables: " << nParticleLists);
91
92 for (int i_pl = 0; i_pl != nParticleLists; ++i_pl) {
93 string particleListName = particleLists[i_pl];
94 B2DEBUG(10, "ParticleList: " << particleListName);
95 StoreObjPtr<ParticleList> plist(particleListName);
96 int m_part = plist->getListSize();
97 for (int i = 0; i < m_part; i++) {
98 const Particle* part = plist->getParticle(i);
99 if (part->getParticleSource() == Particle::EParticleSourceObject::c_MCParticle and !m_usingMC) {
100 B2FATAL("EventKinematics received MCParticles as an input, but usingMC flag is false");
101 }
102 if (part->getParticleSource() != Particle::EParticleSourceObject::c_MCParticle and m_usingMC) {
103 B2FATAL("EventKinematics received reconstructed Particles as an input, but usingMC flag is true");
104 }
105
106 ROOT::Math::PxPyPzEVector p_lab = part->get4Vector();
107 m_particleMomentumList.push_back(p_lab);
108
109 if ((part->getParticleSource() == Particle::EParticleSourceObject::c_ECLCluster or
110 part->getParticleSource() == Particle::EParticleSourceObject::c_MCParticle)
111 and (part->getPDGCode() == Const::photon.getPDGCode()))
112 m_photonsMomentumList.push_back(p_lab);
113
114 ROOT::Math::PxPyPzEVector p_cms = T.rotateLabToCms() * p_lab;
115 m_particleMomentumListCMS.push_back(p_cms);
116 }
117 }
118 return;
119}
120
121
123{
125 ROOT::Math::PxPyPzEVector beam = T.getBeamFourMomentum();
126 ROOT::Math::XYZVector p = beam.Vect();
127 int nParticles = m_particleMomentumList.size();
128 for (int i = 0; i < nParticles; ++i) {
129 p -= m_particleMomentumList.at(i).Vect();
130 }
131 return p;
132}
133
135{
136 ROOT::Math::XYZVector p(0., 0., 0.);
137 int nParticles = m_particleMomentumListCMS.size();
138 for (int i = 0; i < nParticles; ++i) {
139 p -= m_particleMomentumListCMS.at(i).Vect();
140 }
141 return p;
142}
143
145{
147 float ECMS = T.getCMSEnergy();
148 int nParticles = m_particleMomentumListCMS.size();
149 for (int i = 0; i < nParticles; ++i) {
150 ECMS -= m_particleMomentumListCMS.at(i).E();
151 }
152 return ECMS;
153}
154
156{
157 float visibleE = 0.0;
158 int nParticles = m_particleMomentumListCMS.size();
159 for (int i = 0; i < nParticles; ++i) {
160 visibleE += m_particleMomentumListCMS.at(i).E();
161 }
162 return visibleE;
163}
164
166{
167 float photonsEnergy = 0.0;
168 int nParticles = m_photonsMomentumList.size();
169 for (int i = 0; i < nParticles; ++i) {
170 photonsEnergy += m_photonsMomentumList.at(i).E();
171 }
172 return photonsEnergy;
173}
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
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:75
int getPDGCode(void) const
Returns PDG code.
Definition: Particle.h:454
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Definition: Particle.h:547
EParticleSourceObject getParticleSource() const
Returns particle source as defined with enum EParticleSourceObject.
Definition: Particle.h:478
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:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.