27#include "CLHEP/Vector/LorentzVector.h"
29#include "reportingUtils.h"
30#include "starlightconstants.h"
31#include "starlightparticlecodes.h"
39 static const std::string starlight_stream =
"STARLIGHT";
56 ATH_MSG_INFO(
"===> January 20 2011 STARLIGHT INTERFACE VERSION. \n" );
67 return StatusCode::FAILURE;
83 ATH_MSG_INFO(
"===> dumping starlight events to lhef format. \n" );
87 return StatusCode::SUCCESS;
97 const EventContext& ctx = Gaudi::Hive::currentContext();
109 const std::vector<starlightParticle>* particleCollection = std::visit(
110 [](
auto& evt) {
return evt->getParticles(); },
m_event
116 int numberofTracks = particleCollection->size();
117 int numberOfVertices = 1;
120 <<
" with " << numberOfVertices <<
" vertices "
121 <<
" and " << numberofTracks <<
" tracks" );
123 <<
" with " << numberofTracks <<
" tracks" );
126 std::vector<starlightParticle>::const_iterator part =
127 particleCollection->begin();
128 for (part = particleCollection->begin();
129 part != particleCollection->end(); ++part, ++ipart) {
131 << starlightParticleCodes::jetsetToGeant((*part).getCharge() * (*part).getPdgCode()) <<
" "
132 << (*part).GetPx() <<
" " << (*part).GetPy() <<
" "<< (*part).GetPz()
133 <<
" " <<
m_events <<
" " << ipart <<
" " << 0 <<
" "
134 << (*part).getCharge() * (*part).getPdgCode() );
139 return StatusCode::SUCCESS;
147 return StatusCode::SUCCESS;
161 evt->add_vertex( v1 );
164 const std::vector<starlightParticle>* particleCollection = std::visit(
165 [](
auto& evt) {
return evt->getParticles(); },
m_event
171 std::vector<starlightParticle>::const_iterator part =
172 particleCollection->begin();
176 for (part = particleCollection->begin();
177 part != particleCollection->end(); ++part, ++ipart)
179 int pid = (*part).getPdgCode();
180 int charge = (*part).getCharge();
182 int pidsign = pid/std::abs(pid);
185 if( chsign != pidsign && chsign != 0) pid = -pid;
187 double px = (*part).GetPx();
188 double py = (*part).GetPy();
189 double pz = (*part).GetPz();
190 double e = (*part).GetE();
192 if(std::abs(pid)==13) {
194 e = std::sqrt(px*px + py*py + pz*pz + mass*mass);
197 if(std::abs(pid)==22) {
198 e = std::sqrt(px*px + py*py + pz*pz);
232 double e = sqrt(px_tot*px_tot + py_tot*py_tot + pz_tot*pz_tot + mass*mass);
233 v1->add_particle_out(
240 return StatusCode::SUCCESS;
247 std::string lheFilename =
"events.lhe";
248 std::ofstream lheStream;
249 lheStream.open(lheFilename.c_str(), std::ofstream::trunc);
255 lheStream <<
"<LesHouchesEvents version=\"1.0\">\n";
256 lheStream <<
"<!--\n";
257 lheStream <<
"File generated using Starlight \n";
258 lheStream <<
"-->\n";
260 float beam_energy=0.;
264 else beam_energy = 2.51e+03;
266 lheStream <<
"<init>\n";
267 lheStream <<
" 13 -13 "<<beam_energy<<
" "<<beam_energy<<
" 0 0 0 0 3 1\n";
268 lheStream <<
" 1.000000e+00 0.000000e+00 1.000000e+00 9999\n";
269 lheStream <<
"</init>\n";
274 std::unique_ptr<upcEvent>,
275 std::unique_ptr<upcXEvent>> uevent;
278 lheStream <<
"<event>\n";
282 uevent = std::make_unique<upcEvent>(
m_starlight->produceUpcEvent());
284 uevent = std::make_unique<upcXEvent>(
m_starlight->produceEvent());
287 const std::vector<starlightParticle>* particleCollection = std::visit(
288 [](
auto& evt) {
return evt->getParticles(); }, uevent
292 CLHEP::HepLorentzVector photon_system(0);
294 std::vector<starlightParticle>::const_iterator part = particleCollection->begin();
295 for (part = particleCollection->begin(); part != particleCollection->end(); ++part, ++ipart)
297 CLHEP::HepLorentzVector particle_sl((*part).GetPx(), (*part).GetPy(), (*part).GetPz(), (*part).GetE());
298 photon_system += particle_sl;
299 ptscale += std::sqrt((*part).GetPx()*(*part).GetPx() + (*part).GetPy()*(*part).GetPy());
307 ptscale /=
static_cast<float> (ipart);
309 lheStream <<
" 4 9999 1.000000e+00 "<<ptscale<<
" 7.297e-03 2.569093e-01\n";
312 lheStream <<
" -11 -1 0 0 0 0 0.0000000000e+00 0.0000000000e+00 "
313 << photon_system.m()/2.*std::exp(photon_system.rapidity())<<
" "
314 <<photon_system.m()/2.*std::exp(photon_system.rapidity())
315 <<
" 0.0000000000e+00 0. 9.\n";
316 lheStream <<
" 11 -1 0 0 0 0 0.0000000000e+00 0.0000000000e+00 "
317 << -photon_system.m()/2.*std::exp(-photon_system.rapidity())<<
" "
318 <<photon_system.m()/2.*std::exp(-photon_system.rapidity())
319 <<
" 0.0000000000e+00 0. 9.\n";
323 lheStream <<
" 22 -1 0 0 0 0 0.0000000000e+00 0.0000000000e+00 "
324 << photon_system.m()/2.*std::exp(photon_system.rapidity())<<
" "
325 <<photon_system.m()/2.*std::exp(photon_system.rapidity())
326 <<
" 0.0000000000e+00 0. 9.\n";
327 lheStream <<
" 22 -1 0 0 0 0 0.0000000000e+00 0.0000000000e+00 "
328 << -photon_system.m()/2.*std::exp(-photon_system.rapidity())<<
" "
329 <<photon_system.m()/2.*std::exp(-photon_system.rapidity())
330 <<
" 0.0000000000e+00 0. 9.\n";
333 for (part = particleCollection->begin(); part != particleCollection->end(); ++part, ++ipart)
335 int pid = (*part).getPdgCode();
336 int charge = (*part).getCharge();
338 int pidsign = pid/std::abs(pid);
340 if( chsign != pidsign ) pid = -pid;
342 double px = (*part).GetPx();
343 double py = (*part).GetPy();
344 double pz = (*part).GetPz();
345 double e = (*part).GetE();
346 double mass = (*part).getMass();
351 lheStream << pid<<
" 1 1 2 0 0 "<<px<<
" "<<py<<
" "<<pz<<
" "<<e<<
" "<<mass<<
" 0. 9.\n";
354 lheStream <<
"</event>\n";
358 lheStream <<
"</LesHouchesEvents>";
374 "problems initializing input parameters. cannot initialize starlight.";
381 ATH_MSG_WARNING(
"problems initializing input parameters. cannot initialize starlight. " );
397 std::string myparam = mystring.
piece<std::string>(1);
398 if (myparam ==
"beam1Z")
402 else if (myparam ==
"beam1A")
406 else if (myparam ==
"beam2Z")
410 else if (myparam ==
"beam2A")
414 else if (myparam ==
"beam1Gamma")
418 else if (myparam ==
"beam2Gamma")
422 else if (myparam ==
"maxW")
426 else if (myparam ==
"minW")
430 else if (myparam ==
"nmbWBins")
434 else if (myparam ==
"maxRapidity")
438 else if (myparam ==
"nmbRapidityBins")
442 else if (myparam ==
"accCutPt")
446 else if (myparam ==
"minPt")
450 else if (myparam ==
"maxPt")
454 else if (myparam ==
"accCutEta")
458 else if (myparam ==
"minEta")
462 else if (myparam ==
"maxEta")
466 else if (myparam ==
"productionMode")
470 else if (myparam ==
"axionMass")
474 else if (myparam ==
"nmbEventsTot")
478 else if (myparam ==
"prodParticleId")
482 else if (myparam ==
"randomSeed")
486 else if (myparam ==
"outputFormat")
490 else if (myparam ==
"beamBreakupMode")
494 else if (myparam ==
"interferenceEnabled")
498 else if (myparam ==
"interferenceStrength")
502 else if (myparam ==
"coherentProduction")
506 else if (myparam ==
"incoherentFactor")
510 else if (myparam ==
"maxPtInterference")
514 else if (myparam ==
"nmbPtBinsInterference")
518 else if (myparam ==
"xsecMethod")
522 else if (myparam ==
"nThreads")
526 else if (myparam ==
"pythFullRec")
532 ATH_MSG_ERROR(
" ERROR in STARLIGHT INITIALIZATION PARAMETERS "
533 << myparam <<
" is an invalid parameter !" );
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
double charge(const T &p)
ATLAS-specific HepMC functions.
std::vector< std::string > CommandVector
std::pair< std::vector< unsigned int >, bool > res
GenModule(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
IntegerProperty m_randomSeed
Seed for random number engine.
double m_interferenceStrength
unsigned int m_nmbRapidityBins
int m_nmbPtBinsInterference
UnsignedIntegerProperty m_maxevents
virtual StatusCode fillEvt(HepMC::GenEvent *evt)
For filling the HepMC event object.
double m_incoherentFactor
BooleanProperty m_lheOutput
Starlight_i(const std::string &name, ISvcLocator *pSvcLocator)
StringArrayProperty m_InitializeVector
bool prepare_params_file()
std::unique_ptr< starlight > m_starlight
BooleanProperty m_doTauolappLheFormat
unsigned int m_nmbEventsTot
virtual StatusCode callGenerator()
For calling the generator on each iteration of the event loop.
inputParameters m_inputParameters
std::variant< std::unique_ptr< upcEvent >, std::unique_ptr< upcXEvent > > m_event
virtual StatusCode genFinalize()
For finalising the generator, if required.
std::shared_ptr< randomGenerator > m_randomGenerator
StringProperty m_configFileName
bool m_coherentProduction
BooleanProperty m_suppressVMdecay
virtual StatusCode genInitialize()
For initializing the generator, if required.
bool m_interferenceEnabled
double m_maxPtInterference
Utility object for parsing a string into tokens and returning them as a variety of types.
T piece(size_t num) const
Templated function to get the num'th token as any numeric type.
void calculateSeedsMC21(long *seeds, const std::string &algName, uint64_t ev, uint64_t run, uint64_t offset=0)
Set the random seed using a string (e.g.
HepMC3::FourVector FourVector
GenParticlePtr newGenParticlePtr(const HepMC3::FourVector &mom=HepMC3::FourVector::ZERO_VECTOR(), int pid=0, int status=0)
GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos=HepMC3::FourVector::ZERO_VECTOR(), const int i=0)
HepMC3::GenVertexPtr GenVertexPtr
HepMC3::GenEvent GenEvent
void GeVToMeV(HepMC::GenEvent *evt)