Belle II Software development
TwoBodyISRPhotonCorrectorModule.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/modules/TwoBodyISRPhotonCorrector/TwoBodyISRPhotonCorrectorModule.h>
10
11#include <analysis/dataobjects/Particle.h>
12
13#include <framework/datastore/StoreArray.h>
14#include <framework/logging/Logger.h>
15#include <framework/gearbox/Const.h>
16
17#include <analysis/DecayDescriptor/DecayDescriptor.h>
18#include <analysis/DecayDescriptor/DecayDescriptorParticle.h>
19#include <analysis/utility/PCmsLabTransform.h>
20#include <analysis/utility/ParticleCopy.h>
21#include <TDatabasePDG.h>
22
23using namespace Belle2;
24
25// Register module in the framework
26REG_MODULE(TwoBodyISRPhotonCorrector);
27
29{
30 //Set module properties
31 setDescription("This module corrects the energy and momentum of high energy ISR photons in single ISR events based on the beam energy, photon direction, and mass of the recoil particle. The corrected photons are stored in a new list, the original photon kinematics can be accessed via the originalParticle() metavariable.");
33 //Parameter definition
34 addParam("inputGammaList", m_inputGammaListName, "Name of photon list containing the ISR gammas to be corrected");
35 addParam("outputGammaList", m_outputGammaListName, "Name of photon list containing the corrected ISR gammas");
36 addParam("massiveParticlePDGCode", m_massiveParticlePDGCode,
37 "Name of the massive particle participating in the two body decay with the ISR gamma.");
38}
39
41{
43 DecayDescriptor inputDD, outputDD;
44
45 // Output list checks
46 bool outputValid = outputDD.init(m_outputGammaListName);
47 if (!outputValid)
48 B2ERROR("Invalid output ParticleList: " << m_outputGammaListName);
49 if (outputDD.getMother()->getPDGCode() != Const::photon.getPDGCode())
50 B2ERROR("TwoBodyISRPhotonCorrectorModule::event ParticleList " << m_outputGammaListName << " is not a gamma list");
51
52 // Input list checks
54 B2ERROR("TwoBodyISRPhotonCorrectorModule: cannot copy Particles from " << m_inputGammaListName <<
55 " to itself!");
56 } else if (!inputDD.init(m_inputGammaListName)) {
57 B2ERROR("Invalid input ParticleList name: " << m_inputGammaListName);
58 } else {
59 if (inputDD.getMother()->getPDGCode() != Const::photon.getPDGCode())
60 B2ERROR("TwoBodyISRPhotonCorrectorModule::event ParticleList " << m_inputGammaListName << " is not a gamma list");
61
63 }
64
66
67 TParticlePDG* massiveParticlePDG = TDatabasePDG::Instance()->GetParticle(m_massiveParticlePDGCode);
68 B2DEBUG(19, "TwoBodyISRPhotonCorrectorModule: PDG code " << m_massiveParticlePDGCode <<
69 " selected for massive particle participating in two body decay. Its mass is " <<
70 massiveParticlePDG->Mass() << " GeV/c^2.");
71
72}
73
75{
77
78 bool existingList = m_outputGammaList.isValid();
79 if (!existingList) {
80 // new particle list: create it
81 m_outputGammaList.create();
82 m_outputGammaList->initialize(Const::photon.getPDGCode(), m_outputGammaListName);
83 } else {
84 B2WARNING("TwoBodyISRPhotonCorrectorModule: Output ParticleList " << m_outputGammaListName << " already exists. Overwriting.");
85 m_outputGammaList->clear();
86 }
87
88 // Initialize the mass to which we are constraining and the beam momentum
89 const double massMassiveParticle = TDatabasePDG::Instance()->GetParticle(m_massiveParticlePDGCode)->Mass();
91 ROOT::Math::PxPyPzEVector P4beam = T.getBeamFourMomentum();
92
93 // Loop through the given gamma list
94 const unsigned int numParticles = inputGammaList->getListSize();
95 for (unsigned int i = 0; i < numParticles; i++) {
96 ROOT::Math::PxPyPzEVector P4corrected;
97
98 // Get gamma and it's 4 momentum
99 Particle* iParticle = inputGammaList->getParticle(i);
100 ROOT::Math::PxPyPzEVector P4gamma = iParticle->get4Vector();
101
102 // Calculate corrected energy for photon in list
103 ROOT::Math::XYZVector p3gamma_unit((P4gamma.Vect()).Unit());
104 ROOT::Math::XYZVector pbeam(P4beam.Vect());
105 double E_corrected = 0.5 * (P4beam.mag2() - massMassiveParticle * massMassiveParticle) /
106 (P4beam.E() - pbeam.Dot(p3gamma_unit));
107 P4corrected.SetPxPyPzE(p3gamma_unit.X()*E_corrected, p3gamma_unit.Y()*E_corrected,
108 p3gamma_unit.Z()*E_corrected, E_corrected);
109
110 // Set particle's new 4 momentum in a copy
111 Particle* correctedP = ParticleCopy::copyParticle(iParticle);
112 correctedP->setMomentumScalingFactor(1.0);
113 correctedP->set4Vector(P4corrected);
114
115 m_outputGammaList->addParticle(correctedP);
116 }
117
118 const unsigned int numCopy = m_outputGammaList->getListSize();
119 if (numCopy != numParticles)
120 B2FATAL("Size of the ParticleList " << m_inputGammaListName
121 << " has changed while copying the Particles! original size = "
122 << numParticles << " vs. new size = " << numCopy);
123
124}
125
126
int getPDGCode() const
PDG code.
Definition: Const.h:473
static const ParticleType photon
photon particle
Definition: Const.h:673
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
Definition: DataStore.h:71
int getPDGCode() const
Return PDG code.
The DecayDescriptor stores information about a decay tree or parts of a decay tree.
bool init(const std::string &str)
Initialise the DecayDescriptor from given string.
const DecayDescriptorParticle * getMother() const
return mother.
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.
Class to store reconstructed particles.
Definition: Particle.h:76
void setMomentumScalingFactor(double momentumScalingFactor)
Sets momentum scaling.
Definition: Particle.h:345
ROOT::Math::PxPyPzEVector get4Vector() const
Returns Lorentz vector.
Definition: Particle.h:567
void set4Vector(const ROOT::Math::PxPyPzEVector &p4)
Sets Lorentz vector.
Definition: Particle.h:282
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:95
virtual void initialize() override
Initialises the module.
virtual void event() override
Method called for each event.
std::string m_inputGammaListName
name of input particle list.
StoreObjPtr< ParticleList > m_outputGammaList
output particleList
std::string m_outputGammaListName
name of output particle list.
Int_t m_massiveParticlePDGCode
PDG code of particle constraining the gamma energy.
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
Particle * copyParticle(const Particle *original)
Function takes argument Particle and creates a copy of it and copies of all its (grand-)^n-daughters.
Definition: ParticleCopy.cc:17
Abstract base class for different kinds of events.