11 #include <generators/modules/TouschekTURTLEInputModule.h>
13 #include <framework/datastore/StoreArray.h>
15 #include <framework/gearbox/Gearbox.h>
16 #include <framework/gearbox/GearDir.h>
17 #include <framework/gearbox/Unit.h>
18 #include <framework/utilities/FileSystem.h>
20 #include <generators/touschek/TouschekReaderTURTLE.h>
39 setDescription(
"Reads the Touschek data from a TURTLE file and stores it into the MCParticle collection.");
43 addParam(
"FilenameHER", m_filenameHER,
"The filename of the HER TURTLE input file.");
44 addParam(
"FilenameLER", m_filenameLER,
"The filename of the LER TURTLE input file.");
45 addParam(
"ReadHER", m_readHER,
"Set to false to skip reading the HER data.",
true);
46 addParam(
"ReadLER", m_readLER,
"Set to false to skip reading the LER data.",
true);
47 addParam(
"zCoordinate", m_zPos,
48 "Indicates the z-coordinate of the TURTLE particles in the file. (default is 50cm, 400cm is also implemented.)", 50.0);
49 addParam(
"MaxParticles", m_maxParticles,
50 "The maximum number of particles per event that should be read. -1 means all of the particles are read.", -1);
53 m_herPipePartMatrix =
new TGeoHMatrix(
"TouschekPlaneHER");
54 m_lerPipePartMatrix =
new TGeoHMatrix(
"TouschekPlaneLER");
60 TouschekTURTLEInputModule::~TouschekTURTLEInputModule()
67 void TouschekTURTLEInputModule::initialize()
70 if (!Gearbox::getInstance().isOpen()) {
71 B2FATAL(
"The Touschek Turtle input module requires a valid Gearbox. Please make sure you have the Gearbox module added to your path.");
76 mcparticle.registerInDataStore();
79 if ((m_readHER) && (!FileSystem::fileExists(m_filenameHER))) {
80 B2ERROR(
"Parameter <FilenameHER>: Could not open the file. The filename " << m_filenameHER <<
" does not exist !");
81 }
else m_readerHER->open(m_filenameHER);
83 if ((m_readLER) && (!FileSystem::fileExists(m_filenameLER))) {
84 B2ERROR(
"Parameter <FilenameLER>: Could not open the file. The filename " << m_filenameLER <<
" does not exist !");
85 }
else m_readerLER->open(m_filenameLER);
89 GearDir irDir = Gearbox::getInstance().getDetectorComponent(
"Cryostat");
90 double angleher = irDir.
getAngle(
"AngleHER");
91 double angleler = irDir.
getAngle(
"AngleLER");
92 m_herPipePartMatrix->RotateY(angleher / Unit::deg);
93 m_lerPipePartMatrix->RotateY(angleler / Unit::deg);
97 void TouschekTURTLEInputModule::event()
100 int readHERParticles = 0;
101 int readLERParticles = 0;
105 if (m_readHER) readHERParticles = m_readerHER->getParticles(m_maxParticles, mpg);
106 if (m_readLER) readLERParticles = m_readerLER->getParticles(m_maxParticles, mpg);
108 if ((readHERParticles > 0) || (readLERParticles > 0)) {
110 mpg.
generateList(
"", MCParticleGraph::c_setDecayInfo | MCParticleGraph::c_checkCyclic);
112 B2INFO(
"Read " << readHERParticles <<
" e- particles (HER).");
113 B2INFO(
"Read " << readLERParticles <<
" e+ particles (LER).");
115 }
catch (runtime_error& exc) {