12 #include <analysis/modules/BremsCorrection/BelleBremRecoveryModule.h>
14 #include <framework/logging/Logger.h>
15 #include <framework/datastore/RelationArray.h>
16 #include <framework/datastore/StoreArray.h>
19 #include <analysis/dataobjects/Particle.h>
20 #include <mdst/dataobjects/MCParticle.h>
21 #include <mdst/dataobjects/PIDLikelihood.h>
22 #include <mdst/dataobjects/Track.h>
25 #include <analysis/DecayDescriptor/ParticleListName.h>
28 #include <analysis/variables/ECLVariables.h>
31 #include <TMatrixFSym.h>
58 Takes the charged particle from the given charged particle list(``inputListName``) and
59 copies them to the output list(``outputListName``) and adds the 4-vector of nearest(all) photon(s)
60 from ``gammaListName`` (considered as radiative) to the charged particle, if the given
61 criteria for maximum angle(``angleThreshold``) and minimum energy(``minimumEnergy``) are fulfilled.
63 setPropertyFlags(c_ParallelProcessingCertified);
66 addParam(
"inputListName", m_inputListName,
67 "The initial charged particle list containing the charged particles to correct, should already exist.");
68 addParam(
"outputListName", m_outputListName,
"The output charged particle list containing the corrected charged particles.");
69 addParam(
"gammaListName", m_gammaListName,
"The gammas list containing possibly radiative gammas, should already exist.");
70 addParam(
"angleThreshold", m_angleThres,
71 "The maximum angle in radians between the charged particle and the (radiative) gamma to be accepted.", 0.05);
72 addParam(
"minimumEnergy", m_minimumEnergy,
"The minimum energy in GeV of the (radiative) gamma to be accepted.", 0.05);
73 addParam(
"multiplePhotons", m_isMultiPho,
"If only the nearest photon to add then make it False otherwise true",
true);
74 addParam(
"writeOut", m_writeOut,
75 "Set to false if you want to add only the nearest photon, otherwise all eligible photons will be added",
false);
79 void BelleBremRecoveryModule::initialize()
82 bool valid = m_decaydescriptor.init(m_outputListName);
84 B2ERROR(
"[BelleBremRecoveryModule] Invalid output ParticleList name: " << m_outputListName);
88 m_pdgCode = mother->getPDGCode();
89 m_outputAntiListName = ParticleListName::antiParticleListName(m_outputListName);
92 if (m_inputListName == m_outputListName) {
93 B2ERROR(
"[BelleBremRecoveryModule] Input and output particle list names are the same: " << m_inputListName);
94 }
else if (!m_decaydescriptor.init(m_inputListName)) {
95 B2ERROR(
"[BelleBremRecoveryModule] Invalid input particle list name: " << m_inputListName);
97 m_inputparticleList.isRequired(m_inputListName);
100 if (!m_decaydescriptorGamma.init(m_gammaListName)) {
101 B2ERROR(
"[BelleBremRecoveryModule] Invalid gamma particle list name: " << m_gammaListName);
103 m_gammaList.isRequired(m_gammaListName);
108 m_outputparticleList.registerInDataStore(m_outputListName, flags);
109 m_outputAntiparticleList.registerInDataStore(m_outputAntiListName, flags);
113 particles.registerRelationTo(pidlikelihoods);
117 void BelleBremRecoveryModule::event()
122 RelationArray particlesToMCParticles(particles, mcParticles);
125 m_outputparticleList.create();
126 m_outputparticleList->initialize(m_pdgCode, m_outputListName);
128 m_outputAntiparticleList.create();
129 m_outputAntiparticleList->initialize(-1 * m_pdgCode, m_outputAntiListName);
130 m_outputAntiparticleList->bindAntiParticleList(*(m_outputparticleList));
133 const unsigned int nLep = m_inputparticleList->getListSize();
134 const unsigned int nGam = m_gammaList->getListSize();
135 for (
unsigned i = 0; i < nLep; i++) {
136 const Particle* lepton = m_inputparticleList->getParticle(i);
137 TLorentzVector lepton4Vector = lepton->
get4Vector();
138 TLorentzVector new4Vec = lepton->
get4Vector();
139 std::vector<Particle*> selectedGammas;
140 double bremsGammaEnergySum = 0.0;
142 for (
unsigned j = 0; j < nGam; j++) {
143 Particle* gamma = m_gammaList->getParticle(j);
145 if (gamma->getEnergy() < m_minimumEnergy)
continue;
148 TVector3 pj = gamma->getMomentum();
149 double angle = (pi.Angle(pj));
152 if (m_angleThres > angle) {
153 gamma->writeExtraInfo(
"theta_e_gamma", angle);
154 selectedGammas.push_back(gamma);
158 std::sort(selectedGammas.begin(), selectedGammas.end(), [](
const Particle * photon1,
const Particle * photon2) {
159 return photon1->getExtraInfo(
"theta_e_gamma") < photon2->getExtraInfo(
"theta_e_gamma");
162 for (
auto const& fsrgamma : selectedGammas) {
163 new4Vec += fsrgamma->get4Vector();
164 bremsGammaEnergySum += Variable::eclClusterE(fsrgamma);
165 if (!m_isMultiPho)
break;
167 Particle correctedLepton(new4Vec, lepton->
getPDGCode(), Particle::EFlavorType::c_Flavored, Particle::c_Track,
173 TMatrixFSym corLepMatrix = lepErrorMatrix;
174 for (
auto const& fsrgamma : selectedGammas) {
175 const TMatrixFSym& fsrErrorMatrix = fsrgamma->getMomentumVertexErrorMatrix();
176 for (
int irow = 0; irow <= 3 ; irow++)
177 for (
int icol = irow; icol <= 3; icol++)
178 corLepMatrix(irow, icol) += fsrErrorMatrix(irow, icol);
180 B2DEBUG(19,
"[BelleBremRecoveryModule] Found a radiative gamma and added its 4-vector to the charge particle");
181 if (!m_isMultiPho)
break;
186 correctedLepton.
addExtraInfo(
"bremsCorrected",
float(selectedGammas.size() > 0));
187 correctedLepton.
addExtraInfo(
"bremsCorrectedPhotonEnergy", bremsGammaEnergySum);
189 Particle* newLepton = particles.appendNew(correctedLepton);
195 m_outputparticleList->addParticle(newLepton);