9 #include <generators/modules/TouschekTURTLEInputModule.h>
11 #include <framework/datastore/StoreArray.h>
13 #include <framework/gearbox/Gearbox.h>
14 #include <framework/gearbox/GearDir.h>
15 #include <framework/gearbox/Unit.h>
16 #include <framework/utilities/FileSystem.h>
18 #include <generators/touschek/TouschekReaderTURTLE.h>
37 setDescription(
"Reads the Touschek data from a TURTLE file and stores it into the MCParticle collection.");
41 addParam(
"FilenameHER", m_filenameHER,
"The filename of the HER TURTLE input file.");
42 addParam(
"FilenameLER", m_filenameLER,
"The filename of the LER TURTLE input file.");
43 addParam(
"ReadHER", m_readHER,
"Set to false to skip reading the HER data.",
true);
44 addParam(
"ReadLER", m_readLER,
"Set to false to skip reading the LER data.",
true);
45 addParam(
"zCoordinate", m_zPos,
46 "Indicates the z-coordinate of the TURTLE particles in the file. (default is 50cm, 400cm is also implemented.)", 50.0);
47 addParam(
"MaxParticles", m_maxParticles,
48 "The maximum number of particles per event that should be read. -1 means all of the particles are read.", -1);
51 m_herPipePartMatrix =
new TGeoHMatrix(
"TouschekPlaneHER");
52 m_lerPipePartMatrix =
new TGeoHMatrix(
"TouschekPlaneLER");
58 TouschekTURTLEInputModule::~TouschekTURTLEInputModule()
65 void TouschekTURTLEInputModule::initialize()
68 if (!Gearbox::getInstance().isOpen()) {
69 B2FATAL(
"The Touschek Turtle input module requires a valid Gearbox. Please make sure you have the Gearbox module added to your path.");
77 if ((m_readHER) && (!FileSystem::fileExists(m_filenameHER))) {
78 B2ERROR(
"Parameter <FilenameHER>: Could not open the file. The filename " << m_filenameHER <<
" does not exist !");
79 }
else m_readerHER->open(m_filenameHER);
81 if ((m_readLER) && (!FileSystem::fileExists(m_filenameLER))) {
82 B2ERROR(
"Parameter <FilenameLER>: Could not open the file. The filename " << m_filenameLER <<
" does not exist !");
83 }
else m_readerLER->open(m_filenameLER);
87 GearDir irDir = Gearbox::getInstance().getDetectorComponent(
"Cryostat");
88 double angleher = irDir.
getAngle(
"AngleHER");
89 double angleler = irDir.
getAngle(
"AngleLER");
90 m_herPipePartMatrix->RotateY(angleher / Unit::deg);
91 m_lerPipePartMatrix->RotateY(angleler / Unit::deg);
95 void TouschekTURTLEInputModule::event()
98 int readHERParticles = 0;
99 int readLERParticles = 0;
103 if (m_readHER) readHERParticles = m_readerHER->getParticles(m_maxParticles, mpg);
104 if (m_readLER) readLERParticles = m_readerLER->getParticles(m_maxParticles, mpg);
106 if ((readHERParticles > 0) || (readLERParticles > 0)) {
108 mpg.
generateList(
"", MCParticleGraph::c_setDecayInfo | MCParticleGraph::c_checkCyclic);
110 B2INFO(
"Read " << readHERParticles <<
" e- particles (HER).");
111 B2INFO(
"Read " << readLERParticles <<
" e+ particles (LER).");
113 }
catch (runtime_error& exc) {
GearDir is the basic class used for accessing the parameter store.
Class to build, validate and sort a particle decay chain.
void generateList(const std::string &name="", int options=c_setNothing)
Generates the MCParticle list and stores it in the StoreArray with the given name.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Class to read Touschek files and store their content in a MCParticle graph.
double getAngle(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard angle unit.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.