10 #include <analysis/modules/BremsCorrection/BelleBremRecoveryModule.h>
12 #include <framework/logging/Logger.h>
13 #include <framework/datastore/RelationArray.h>
16 #include <mdst/dataobjects/Track.h>
19 #include <analysis/DecayDescriptor/ParticleListName.h>
22 #include <analysis/variables/ECLVariables.h>
25 #include <TMatrixFSym.h>
52 Takes the charged particle from the given charged particle list (``inputListName``) and
53 copies it to the output list (``outputListName``). The 4-vector of the nearest (all) photon(s)
54 from ``gammaListName`` (considered as radiative) is added to the charged particle, if it is
55 found inside the cone around the charged particle with the given maximum angle (``angleThreshold``).
57 setPropertyFlags(c_ParallelProcessingCertified);
60 addParam(
"inputListName", m_inputListName,
61 "The initial charged particle list containing the charged particles to correct, should already exist.");
62 addParam(
"outputListName", m_outputListName,
"The output charged particle list containing the corrected charged particles.");
63 addParam(
"gammaListName", m_gammaListName,
"The gammas list containing possibly radiative gammas, should already exist.");
64 addParam(
"angleThreshold", m_angleThres,
65 "The maximum angle in radians between the charged particle and the (radiative) gamma to be accepted.", 0.05);
66 addParam(
"multiplePhotons", m_isMultiPho,
"If only the nearest photon to add then make it False otherwise true",
true);
67 addParam(
"writeOut", m_writeOut,
68 "Set to true if you want to write out the output list to a root file",
false);
72 void BelleBremRecoveryModule::initialize()
75 bool valid = m_decaydescriptor.init(m_outputListName);
77 B2ERROR(
"[BelleBremRecoveryModule] Invalid output ParticleList name: " << m_outputListName);
81 m_pdgCode = mother->getPDGCode();
82 m_outputAntiListName = ParticleListName::antiParticleListName(m_outputListName);
85 if (m_inputListName == m_outputListName) {
86 B2ERROR(
"[BelleBremRecoveryModule] Input and output particle list names are the same: " << m_inputListName);
87 }
else if (!m_decaydescriptor.init(m_inputListName)) {
88 B2ERROR(
"[BelleBremRecoveryModule] Invalid input particle list name: " << m_inputListName);
90 m_inputparticleList.isRequired(m_inputListName);
93 if (!m_decaydescriptorGamma.init(m_gammaListName)) {
94 B2ERROR(
"[BelleBremRecoveryModule] Invalid gamma particle list name: " << m_gammaListName);
96 m_gammaList.isRequired(m_gammaListName);
101 m_outputparticleList.registerInDataStore(m_outputListName, flags);
102 m_outputAntiparticleList.registerInDataStore(m_outputAntiListName, flags);
104 m_particles.registerRelationTo(m_pidlikelihoods);
108 void BelleBremRecoveryModule::event()
110 RelationArray particlesToMCParticles(m_particles, m_mcParticles);
113 m_outputparticleList.create();
114 m_outputparticleList->initialize(m_pdgCode, m_outputListName);
116 m_outputAntiparticleList.create();
117 m_outputAntiparticleList->initialize(-1 * m_pdgCode, m_outputAntiListName);
118 m_outputAntiparticleList->bindAntiParticleList(*(m_outputparticleList));
121 const unsigned int nLep = m_inputparticleList->getListSize();
122 const unsigned int nGam = m_gammaList->getListSize();
123 for (
unsigned i = 0; i < nLep; i++) {
124 const Particle* lepton = m_inputparticleList->getParticle(i);
125 TLorentzVector lepton4Vector = lepton->
get4Vector();
126 TLorentzVector new4Vec = lepton->
get4Vector();
127 std::vector<Particle*> selectedGammas;
128 double bremsGammaEnergySum = 0.0;
130 for (
unsigned j = 0; j < nGam; j++) {
131 Particle* gamma = m_gammaList->getParticle(j);
134 TVector3 pj = gamma->getMomentum();
135 double angle = (pi.Angle(pj));
138 if (m_angleThres > angle) {
139 gamma->writeExtraInfo(
"theta_e_gamma", angle);
140 selectedGammas.push_back(gamma);
144 std::sort(selectedGammas.begin(), selectedGammas.end(), [](
const Particle * photon1,
const Particle * photon2) {
145 return photon1->getExtraInfo(
"theta_e_gamma") < photon2->getExtraInfo(
"theta_e_gamma");
148 for (
auto const& fsrgamma : selectedGammas) {
149 new4Vec += fsrgamma->get4Vector();
150 bremsGammaEnergySum += Variable::eclClusterE(fsrgamma);
151 if (!m_isMultiPho)
break;
153 Particle correctedLepton(new4Vec, lepton->
getPDGCode(), Particle::EFlavorType::c_Flavored, Particle::c_Track,
159 TMatrixFSym corLepMatrix = lepErrorMatrix;
160 for (
auto const& fsrgamma : selectedGammas) {
161 const TMatrixFSym& fsrErrorMatrix = fsrgamma->getMomentumVertexErrorMatrix();
162 for (
int irow = 0; irow <= 3 ; irow++)
163 for (
int icol = irow; icol <= 3; icol++)
164 corLepMatrix(irow, icol) += fsrErrorMatrix(irow, icol);
166 B2DEBUG(19,
"[BelleBremRecoveryModule] Found a radiative gamma and added its 4-vector to the charge particle");
167 if (!m_isMultiPho)
break;
172 correctedLepton.
addExtraInfo(
"bremsCorrected",
float(selectedGammas.size() > 0));
173 correctedLepton.
addExtraInfo(
"bremsCorrectedPhotonEnergy", bremsGammaEnergySum);
175 Particle* newLepton = m_particles.appendNew(correctedLepton);
181 m_outputparticleList->addParticle(newLepton);
Brem recovery module (used in past belle analyses) This module add four vector of all the brem photon...
EStoreFlags
Flags describing behaviours of objects etc.
Represents a particle in the DecayDescriptor.
A Class to store the Monte Carlo particle information.
Class to collect log likelihoods from TOP, ARICH, dEdx, ECL and KLM aimed for output to mdst includes...
Class to store reconstructed particles.
const Track * getTrack() const
Returns the pointer to the Track object that was used to create this Particle (ParticleType == c_Trac...
void setPValue(float pValue)
Sets chi^2 probability of fit.
void setVertex(const TVector3 &vertex)
Sets position (decay vertex)
TVector3 getVertex() const
Returns vertex position (POCA for charged, IP for neutral FS particles)
float getPValue() const
Returns chi^2 probability of fit if done or -1.
TVector3 getMomentum() const
Returns momentum vector.
const PIDLikelihood * getPIDLikelihood() const
Returns the pointer to the PIDLikelihood object that is related to the Track, which was used to creat...
int getPDGCode(void) const
Returns PDG code.
void addExtraInfo(const std::string &name, float value)
Sets the user-defined data of given name to the given value.
TLorentzVector get4Vector() const
Returns Lorentz vector.
void setMomentumVertexErrorMatrix(const TMatrixFSym &errMatrix)
Sets 7x7 error matrix.
TMatrixFSym getMomentumVertexErrorMatrix() const
Returns 7x7 error matrix.
void appendDaughter(const Particle *daughter, const bool updateType=true)
Appends index of daughter to daughters index array.
Low-level class to create/modify relations between StoreArrays.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
int getArrayIndex() const
Returns this object's array index (in StoreArray), or -1 if not found.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.