9#include <generators/modules/trepsinput/TrepsInputModule.h>
10#include <framework/geometry/B2Vector3.h>
13#include <boost/filesystem.hpp>
33 setDescription(
"Input from TREPS generator (No-tag), Input from TREPS generator for ee->ee hadrons");
37 "parameter file for TREPS input", std::string(
"treps_par.dat"));
39 "file name for differential cross section table input. If UseDiscreteAndSortedW is true, the file is used",
40 std::string(
"pipidcs.dat"));
42 "file name for W-List table input. If UseDiscreteAndSortedW is false (default), the file is used", std::string(
"wlist_table.dat"));
44 "if true, use WListTable for discrete and sorted W. if false (default), use DifferentialCrossSection",
false);
47 "Maximal :math:`Q^2 = -q^2`, where q is the difference between the initial "
48 "and final electron or positron momenta. Negative means no cut.",
51 "Maximal :math:`|\\cos(\\theta)|`, where :math:`\\theta` is the final-state particle "
52 "polar angle.", 1.01);
54 "Whether to apply cut on :math:`|cos(theta)|` for charged particles only.",
57 "Minimal transverse momentum of the final-state particles.", 0.0);
58 addParam(
"ApplyTransverseMomentumCutCharged",
60 "Whether to apply cut on the minimal transverse momentum for "
61 "charged particles only.",
true);
80 B2INFO(
"Initialized the TREPS generator!");
82 B2FATAL(
"TrepsInputModule::event(): BeamParameters have changed within "
83 "a job, this is not supported for TREPS!");
89 ROOT::Math::XYZVector vertex = initial.
getVertex();
133 p.setPDG(part[i].part_prop.icode);
134 p.set4Vector(ROOT::Math::PxPyPzEVector(part[i].p.Px(), part[i].p.Py(), part[i].p.Pz(), part[i].p.E()));
135 p.setMass(part[i].part_prop.pmass);
137 p.setProductionVertex(vertex);
138 p.setValidVertex(
true);
146 p1.setProductionVertex(vertex);
147 p1.setValidVertex(
true);
154 p2.setProductionVertex(vertex);
155 p2.setValidVertex(
true);
170 B2FATAL(
"Cross Section Table is empty !!!");
175 auto it_upper =
m_generator.diffCrossSectionOfW.lower_bound(W);
176 auto it_lower = it_upper;
179 return (it_upper->second - it_lower->second) / (it_upper->first - it_lower->first) * (W - it_lower->first) + it_lower->second;
186 double crossSectionForMC = gRandom->Uniform(0.0,
m_generator.totalCrossSectionForMC);
188 auto it_upper =
m_generator.WOfCrossSectionForMC.lower_bound(crossSectionForMC);
189 auto it_lower = it_upper;
192 double diffCrossSectionAtUpper =
m_generator.diffCrossSectionOfW.at(it_upper->second);
193 double diffCrossSectionAtLower =
m_generator.diffCrossSectionOfW.at(it_lower->second);
194 double limit = (diffCrossSectionAtUpper > diffCrossSectionAtLower) ? diffCrossSectionAtUpper * 1.01 : diffCrossSectionAtLower *
198 double W = (crossSectionForMC - it_lower->first) / limit + it_lower->second ;
199 if (W <
m_generator.diffCrossSectionOfW.begin()->first or W >
m_generator.diffCrossSectionOfW.rbegin()->first)
200 B2FATAL(
"W has to be in [" <<
m_generator.diffCrossSectionOfW.begin()->first <<
", "
202 <<
"] !!! W = " << W <<
", crossSectionForMC = " << crossSectionForMC);
204 double trial = gRandom->Uniform(0.0, limit);
207 if (trial < crossSection)
246 B2INFO(
"Discrete W-list is used !!!");
This class contains the nominal beam parameters and the parameters used for smearing of the primary v...
The base module for generator modules, which sets the generator information as EventExtraInfo.
const BeamParameters & getBeamParameters() const
Return reference to nominal beam parameters.
This class contains the initial state for the given event.
const ROOT::Math::PxPyPzEVector & getHER() const
Get 4vector of the high energy beam.
const ROOT::Math::PxPyPzEVector & getLER() const
Get 4vector of the low energy beam.
const ROOT::Math::XYZVector & getVertex() const
Get the position of the collision.
double getMass() const
Get the invariant mass of the collision (= energy in CMS)
Class to represent Particle data in graph.
@ c_setDecayInfo
Set decay time and vertex.
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
@ c_Initial
bit 5: Particle is initial such as e+ or e- and not going to Geant4
@ c_PrimaryParticle
bit 0: Particle is primary particle.
@ c_StableInGenerator
bit 1: Particle is stable, i.e., not decaying in the generator.
void setMass(float mass)
Set particle mass.
void addStatus(unsigned short int bitmask)
Add bitmask to current status.
void setEnergy(float energy)
Set energy.
void setPDG(int pdg)
Set PDG code of the particle.
void setMomentum(const ROOT::Math::XYZVector &momentum)
Set particle momentum.
void setDescription(const std::string &description)
Sets the description of the module.
const std::string & getName() const
Return name under which the object is saved in the DataStore.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
B2Vector3< double > B2Vector3D
typedef for common usage with double
void initialize()
function to be executed on initialize()
MCInitialParticles & generate()
Generate a new event.
double sqrt(double a)
sqrt for double
void clear()
Reset particles and decay information to make the class reusable.
GraphParticle & addParticle()
Add new particle to the graph.
Abstract base class for different kinds of events.