9 #include <beast/analysis/modules/ReprocessorModule.h>
11 #include <mdst/dataobjects/MCParticle.h>
12 #include <framework/logging/Logger.h>
15 #include <boost/foreach.hpp>
35 setDescription(
"Reprocessor module");
37 addParam(
"input_TPC_PDG", m_input_TPC_PDG,
"Set the PDG particle to re-launch");
38 addParam(
"input_TPC_Ntimes", m_input_TPC_Ntimes,
"Re-launch the PDG particle N times");
39 addParam(
"input_HE3_PDG", m_input_HE3_PDG,
"Set the PDG particle to re-launch");
40 addParam(
"input_HE3_Ntimes", m_input_HE3_Ntimes,
"Re-launch the PDG particle N times");
43 ReprocessorModule::~ReprocessorModule()
47 void ReprocessorModule::initialize()
49 B2INFO(
"Reprocessor: Initializing");
51 m_mcParticle.registerInDataStore();
53 m_evtMetaData.registerInDataStore();
55 MetaHits.isRequired();
56 mc_he3_parts.isOptional();
57 mc_tpc_parts.isOptional();
60 void ReprocessorModule::beginRun()
64 void ReprocessorModule::event()
67 if (mc_he3_parts.getEntries() == 0 && mc_tpc_parts.getEntries() == 0 && m_input_TPC_Ntimes != 0 && m_input_HE3_Ntimes != 0) {
70 if (mc_he3_parts.getEntries() == 0 && m_input_HE3_Ntimes != 0) {
73 if (mc_tpc_parts.getEntries() == 0 && m_input_TPC_Ntimes != 0) {
79 for (
const auto& MetaHit : MetaHits) {
80 rate = MetaHit.getrate();
83 if (m_input_HE3_Ntimes != 0 && m_input_TPC_Ntimes == 0) rate /= (double)m_input_HE3_Ntimes;
84 if (m_input_TPC_Ntimes != 0 && m_input_HE3_Ntimes == 0) rate /= (double)m_input_TPC_Ntimes;
94 if (m_input_TPC_Ntimes != 0) {
95 for (
const auto& mcpart : mc_tpc_parts) {
96 const int PDG = mcpart.getPDG();
97 const double energy = mcpart.getEnergy();
98 TVector3 Momentum = mcpart.getMomentum();
99 TVector3 ProductionVertex = mcpart.getProductionVertex();
100 if (m_input_TPC_PDG == PDG) {
101 for (
int i = 0; i < m_input_TPC_Ntimes; i ++) {
104 particle->setStatus(MCParticle::c_PrimaryParticle);
105 particle->setPDG(PDG);
106 particle->setMassFromPDG();
107 particle->setMomentum(Momentum);
108 particle->setProductionVertex(ProductionVertex);
109 particle->setProductionTime(0.0);
110 particle->setEnergy(energy);
111 particle->setValidVertex(
true);
117 if (m_input_HE3_Ntimes != 0) {
118 for (
const auto& mcpart : mc_he3_parts) {
119 const int PDG = mcpart.getPDG();
120 const double energy = mcpart.getEnergy();
121 TVector3 Momentum = mcpart.getMomentum();
122 TVector3 ProductionVertex = mcpart.getProductionVertex();
123 if (m_input_HE3_PDG == PDG) {
124 for (
int i = 0; i < m_input_HE3_Ntimes; i ++) {
127 particle->setStatus(MCParticle::c_PrimaryParticle);
128 particle->setPDG(PDG);
129 particle->setMassFromPDG();
130 particle->setMomentum(Momentum);
131 particle->setProductionVertex(ProductionVertex);
132 particle->setProductionTime(0.0);
133 particle->setEnergy(energy);
134 particle->setValidVertex(
true);
140 evtMetaData->setGeneratedWeight(rate);
145 void ReprocessorModule::endRun()
149 void ReprocessorModule::terminate()
A Class to store the Monte Carlo particle information.
bool create(bool replace=false)
Create a default object in the data store.
T * appendNew()
Construct a new T object at the end of the array.
void clear() override
Delete all entries in this array.
Type-safe access to single objects in the data store.
bool isValid() const
Check whether the object was created.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.