25#include "HepMC3/GenCrossSection.h"
28#include "CLHEP/Vector/LorentzVector.h"
30#include "reportingUtils.h"
31#include "starlightconstants.h"
32#include "starlightparticlecodes.h"
40 static const std::string starlight_stream =
"STARLIGHT";
57 ATH_MSG_INFO(
"===> January 20 2011 STARLIGHT INTERFACE VERSION. \n" );
68 return StatusCode::FAILURE;
84 ATH_MSG_INFO(
"===> dumping starlight events to lhef format. \n" );
88 return StatusCode::SUCCESS;
98 const EventContext& ctx = Gaudi::Hive::currentContext();
110 const std::vector<starlightParticle>* particleCollection = std::visit(
111 [](
auto& _evt) {
return _evt->getParticles(); },
m_event
117 int numberofTracks = particleCollection->size();
118 int numberOfVertices = 1;
121 <<
" with " << numberOfVertices <<
" vertices "
122 <<
" and " << numberofTracks <<
" tracks" );
124 <<
" with " << numberofTracks <<
" tracks" );
127 std::vector<starlightParticle>::const_iterator part =
128 particleCollection->begin();
129 for (part = particleCollection->begin();
130 part != particleCollection->end(); ++part, ++ipart) {
132 << starlightParticleCodes::jetsetToGeant((*part).getCharge() * (*part).getPdgCode()) <<
" "
133 << (*part).GetPx() <<
" " << (*part).GetPy() <<
" "<< (*part).GetPz()
134 <<
" " <<
m_events <<
" " << ipart <<
" " << 0 <<
" "
135 << (*part).getCharge() * (*part).getPdgCode() );
140 return StatusCode::SUCCESS;
148 return StatusCode::SUCCESS;
162 evt->add_vertex( v1 );
165 const std::vector<starlightParticle>* particleCollection = std::visit(
166 [](
auto& _evt) {
return _evt->getParticles(); },
m_event
172 std::vector<starlightParticle>::const_iterator part =
173 particleCollection->begin();
177 for (part = particleCollection->begin();
178 part != particleCollection->end(); ++part, ++ipart)
180 int pid = (*part).getPdgCode();
181 int charge = (*part).getCharge();
183 int pidsign = pid/std::abs(pid);
186 if( chsign != pidsign && chsign != 0) pid = -pid;
188 double px = (*part).GetPx();
189 double py = (*part).GetPy();
190 double pz = (*part).GetPz();
191 double e = (*part).GetE();
193 if(std::abs(pid)==13) {
195 e = std::sqrt(px*px + py*py + pz*pz + mass*mass);
198 if(std::abs(pid)==22) {
199 e = std::sqrt(px*px + py*py + pz*pz);
233 double e = sqrt(px_tot*px_tot + py_tot*py_tot + pz_tot*pz_tot + mass*mass);
234 v1->add_particle_out(
246 v1->add_particle_in(b1);
247 v1->add_particle_in(b2);
250 evt->set_units(HepMC3::Units::MEV, HepMC3::Units::MM);
252 return StatusCode::SUCCESS;
259 std::string lheFilename =
"events.lhe";
260 std::ofstream lheStream;
261 lheStream.open(lheFilename.c_str(), std::ofstream::trunc);
267 lheStream <<
"<LesHouchesEvents version=\"1.0\">\n";
268 lheStream <<
"<!--\n";
269 lheStream <<
"File generated using Starlight \n";
270 lheStream <<
"-->\n";
272 lheStream <<
"<init>\n";
274 lheStream <<
" 1.000000e+00 0.000000e+00 1.000000e+00 9999\n";
275 lheStream <<
"</init>\n";
280 std::unique_ptr<upcEvent>,
281 std::unique_ptr<upcXEvent>> uevent;
284 lheStream <<
"<event>\n";
288 uevent = std::make_unique<upcEvent>(
m_starlight->produceUpcEvent());
290 uevent = std::make_unique<upcXEvent>(
m_starlight->produceEvent());
293 const std::vector<starlightParticle>* particleCollection = std::visit(
294 [](
auto& _evt) {
return _evt->getParticles(); }, uevent
298 CLHEP::HepLorentzVector photon_system(0);
300 std::vector<starlightParticle>::const_iterator part = particleCollection->begin();
301 for (part = particleCollection->begin(); part != particleCollection->end(); ++part, ++ipart)
303 CLHEP::HepLorentzVector particle_sl((*part).GetPx(), (*part).GetPy(), (*part).GetPz(), (*part).GetE());
304 photon_system += particle_sl;
305 ptscale += std::sqrt((*part).GetPx()*(*part).GetPx() + (*part).GetPy()*(*part).GetPy());
313 ptscale /=
static_cast<float> (ipart);
315 lheStream <<
" 4 9999 1.000000e+00 "<<ptscale<<
" 7.297e-03 2.569093e-01\n";
318 lheStream <<
" -11 -1 0 0 0 0 0.0000000000e+00 0.0000000000e+00 "
319 << photon_system.m()/2.*std::exp(photon_system.rapidity())<<
" "
320 <<photon_system.m()/2.*std::exp(photon_system.rapidity())
321 <<
" 0.0000000000e+00 0. 9.\n";
322 lheStream <<
" 11 -1 0 0 0 0 0.0000000000e+00 0.0000000000e+00 "
323 << -photon_system.m()/2.*std::exp(-photon_system.rapidity())<<
" "
324 <<photon_system.m()/2.*std::exp(-photon_system.rapidity())
325 <<
" 0.0000000000e+00 0. 9.\n";
329 lheStream <<
" 22 -1 0 0 0 0 0.0000000000e+00 0.0000000000e+00 "
330 << photon_system.m()/2.*std::exp(photon_system.rapidity())<<
" "
331 <<photon_system.m()/2.*std::exp(photon_system.rapidity())
332 <<
" 0.0000000000e+00 0. 9.\n";
333 lheStream <<
" 22 -1 0 0 0 0 0.0000000000e+00 0.0000000000e+00 "
334 << -photon_system.m()/2.*std::exp(-photon_system.rapidity())<<
" "
335 <<photon_system.m()/2.*std::exp(-photon_system.rapidity())
336 <<
" 0.0000000000e+00 0. 9.\n";
339 for (part = particleCollection->begin(); part != particleCollection->end(); ++part, ++ipart)
341 int pid = (*part).getPdgCode();
342 int charge = (*part).getCharge();
344 int pidsign = pid/std::abs(pid);
346 if( chsign != pidsign ) pid = -pid;
348 double px = (*part).GetPx();
349 double py = (*part).GetPy();
350 double pz = (*part).GetPz();
351 double e = (*part).GetE();
352 double mass = (*part).getMass();
357 lheStream << pid<<
" 1 1 2 0 0 "<<px<<
" "<<py<<
" "<<pz<<
" "<<e<<
" "<<mass<<
" 0. 9.\n";
360 lheStream <<
"</event>\n";
364 lheStream <<
"</LesHouchesEvents>";
380 "problems initializing input parameters. cannot initialize starlight.";
387 ATH_MSG_WARNING(
"problems initializing input parameters. cannot initialize starlight. " );
403 std::string myparam = mystring.
piece<std::string>(1);
404 if (myparam ==
"beam1Z")
408 else if (myparam ==
"beam1A")
412 else if (myparam ==
"beam2Z")
416 else if (myparam ==
"beam2A")
420 else if (myparam ==
"beam1Gamma")
424 else if (myparam ==
"beam2Gamma")
428 else if (myparam ==
"maxW")
432 else if (myparam ==
"minW")
436 else if (myparam ==
"nmbWBins")
440 else if (myparam ==
"maxRapidity")
444 else if (myparam ==
"nmbRapidityBins")
448 else if (myparam ==
"accCutPt")
452 else if (myparam ==
"minPt")
456 else if (myparam ==
"maxPt")
460 else if (myparam ==
"accCutEta")
464 else if (myparam ==
"minEta")
468 else if (myparam ==
"maxEta")
472 else if (myparam ==
"productionMode")
476 else if (myparam ==
"axionMass")
480 else if (myparam ==
"nmbEventsTot")
484 else if (myparam ==
"prodParticleId")
488 else if (myparam ==
"randomSeed")
492 else if (myparam ==
"outputFormat")
496 else if (myparam ==
"beamBreakupMode")
500 else if (myparam ==
"interferenceEnabled")
504 else if (myparam ==
"interferenceStrength")
508 else if (myparam ==
"coherentProduction")
512 else if (myparam ==
"incoherentFactor")
516 else if (myparam ==
"maxPtInterference")
520 else if (myparam ==
"nmbPtBinsInterference")
524 else if (myparam ==
"xsecMethod")
528 else if (myparam ==
"nThreads")
532 else if (myparam ==
"pythFullRec")
538 ATH_MSG_ERROR(
" ERROR in STARLIGHT INITIALIZATION PARAMETERS "
539 << 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
DoubleProperty m_beam1_energy
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()
DoubleProperty m_beam2_energy
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)
HepMC3::GenParticlePtr GenParticlePtr
GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos=HepMC3::FourVector::ZERO_VECTOR(), const int i=0)
HepMC3::GenVertexPtr GenVertexPtr
HepMC3::GenEvent GenEvent