ATLAS Offline Software
Loading...
Searching...
No Matches
MultiParticleGunPileup Class Reference

#include <MultiParticleGunPileup.h>

Inheritance diagram for MultiParticleGunPileup:
Collaboration diagram for MultiParticleGunPileup:

Public Member Functions

 MultiParticleGunPileup (const std::string &name, ISvcLocator *pSvcLocator)
 ~MultiParticleGunPileup ()
virtual StatusCode genInitialize ()
 For initializing the generator, if required.
virtual StatusCode genFinalize ()
 For finalising the generator, if required.
virtual StatusCode callGenerator ()
 For calling the generator on each iteration of the event loop.
virtual StatusCode fillEvt (HepMC::GenEvent *event)
 For filling the HepMC event object.
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
Event loop algorithm methods: not to be overloaded
StatusCode initialize ()
StatusCode execute ()
StatusCode finalize ()
Gen-specific event loop methods: to be overloaded
virtual StatusCode genuserInitialize ()
 For initialization of user code, if required. Called after genInitialize.
Event collection accessors (const and non-const)
HepMC::GenEvent *event ATLAS_NOT_CONST_THREAD_SAFE ()
 Access the current signal event (first in the McEventCollection)
McEventCollection *events ATLAS_NOT_CONST_THREAD_SAFE ()
 Access the current event's McEventCollection.
const HepMC::GenEvent * event_const () const
 Access the current signal event (const)
const McEventCollectionevents_const () const
 Access the current event's McEventCollection (const)
const McEventCollectionevents_const (const EventContext &ctx) const
Particle data accessors
const ServiceHandle< IPartPropSvc > partPropSvc () const
 Access the particle property service.
const HepPDT::ParticleDataTable & particleTable () const
 Get a particle data table.
const HepPDT::ParticleDataTable & pdt () const
 Shorter alias to get a particle data table.
const HepPDT::ParticleData * particleData (int pid) const
 Access an element in the particle data table.

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

Properties
std::string m_mcEventKey {}
 StoreGate key for the MC event collection (defaults to GEN_EVENT)
BooleanProperty m_mkMcEvent {this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"}
 Flag to determine if a new MC event collection should be made if it doesn't exist.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

int nPileupEvents (CLHEP::HepRandomEngine *rndmEngine)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

int m_ncollevent
std::vector< int > m_pileupProfile
std::vector< float > m_multbcid
std::string m_filename
int m_ngen
int m_nbad
std::vector< HepMC::GenEvent * > m_evts
std::vector< double > m_pileupProfileIntegral
TFile * m_file
TH1D * m_htgPileupProfile
TH1D * m_htgPileupMu
TH1D * m_htgPileupEvents
ParticleSamplerm_partSampler
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Features for derived classes to use internally

ServiceHandle< IAthRNGSvcm_rndmSvc {this, "RndmSvc", "AthRNGSvc"}
 Data members.
ServiceHandle< IIncidentSvc > m_incidentSvc {this, "IncidentSvc", "IncidentSvc"}
 Handle on the incident service.
IntegerProperty m_randomSeed {this, "RandomSeed", 1234567, "Random seed for the built-in random engine"}
 Seed for random number engine.
BooleanProperty m_isAfterburner {this, "IsAfterburner", false, "Set true if generator modifies existing events rather than creating new ones"}
 Flag for normal vs. afterburner generators.
CLHEP::HepRandomEngine * getRandomEngine (const std::string &streamName, const EventContext &ctx) const
CLHEP::HepRandomEngine * getRandomEngine (const std::string &streamName, unsigned long int randomSeedOffset, const EventContext &ctx) const
CLHEP::HepRandomEngine * getRandomEngineDuringInitialize (const std::string &streamName, unsigned long int randomSeedOffset, unsigned int conditionsRun=1, unsigned int lbn=1) const

Utility event-mangling functions

Todo
Replace with HepMC units when available
ServiceHandle< IPartPropSvc > m_ppSvc {this, "PartPropSvc", "PartPropSvc"}
 Handle on the particle property service.
SG::ReadHandleKey< McEventCollectionm_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
 Const handle to the MC event collection.
void GeVToMeV (HepMC::GenEvent *evt)
 Scale event energies/momenta by x 1000.
void MeVToGeV (HepMC::GenEvent *evt)
 Scale event energies/momenta by x 1/1000.
void cmTomm (HepMC::GenEvent *evt)
 Scale event lengths by x 10.
void mmTocm (HepMC::GenEvent *evt)
 Scale event lengths by x 1/10.

Detailed Description

Definition at line 23 of file MultiParticleGunPileup.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MultiParticleGunPileup()

MultiParticleGunPileup::MultiParticleGunPileup ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 18 of file MultiParticleGunPileup.cxx.

18 :
19 GenModule( name, pSvcLocator ),
20 m_ngen(0),
21 m_nbad(0),
22 // m_evnumber(1),
23 m_file(NULL),
25 m_htgPileupMu(NULL),
27 m_partSampler(NULL)
28{
29 declareProperty("NCollPerEvent",m_ncollevent=20,"Collisons per event (-1 to use profile)");
30 declareProperty("PileupProfile",m_pileupProfile,"Pileup profile array");
31 declareProperty("MultBCID",m_multbcid,"Pileup multiplier per BCID array");
32 declareProperty("HistFile",m_filename="","Filename for histograms");
33}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
GenModule(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenModule.cxx:14
std::vector< float > m_multbcid
std::vector< int > m_pileupProfile

◆ ~MultiParticleGunPileup()

MultiParticleGunPileup::~MultiParticleGunPileup ( )

Definition at line 35 of file MultiParticleGunPileup.cxx.

35 {
36
37}

Member Function Documentation

◆ ATLAS_NOT_CONST_THREAD_SAFE() [1/2]

HepMC::GenEvent *event GenBase::ATLAS_NOT_CONST_THREAD_SAFE ( )
inlineinherited

Access the current signal event (first in the McEventCollection)

Note
This function will make a new McEventCollection if there is not already a valid one and MakeMcEvent=True.

Definition at line 76 of file GenBase.h.

76 {
77 if (events()->empty())
78 ATH_MSG_ERROR("McEventCollection is empty during first event access");
79 return *(events()->begin());
80 }
#define ATH_MSG_ERROR(x)
static const Attributes_t empty

◆ ATLAS_NOT_CONST_THREAD_SAFE() [2/2]

McEventCollection *events GenBase::ATLAS_NOT_CONST_THREAD_SAFE ( )
inherited

Access the current event's McEventCollection.

Note
This function will make a new McEventCollection if there is not already a valid one and MakeMcEvent=True.

◆ callGenerator()

StatusCode MultiParticleGunPileup::callGenerator ( )
virtual

For calling the generator on each iteration of the event loop.

Reimplemented from GenModule.

Definition at line 84 of file MultiParticleGunPileup.cxx.

84 {
85 // initialise random generators the first time - delayed after Pythia init
86 const EventContext& ctx = Gaudi::Hive::currentContext();
87 CLHEP::HepRandomEngine* rndmEngine = this->getRandomEngine("ParticleGun", ctx);
88
89 // decide how many events to generate
90
91 int muval = ( m_ncollevent > 0 ? m_ncollevent : nPileupEvents(rndmEngine) );
92 if (m_file) m_htgPileupMu->Fill(muval+0.1);
93 m_evts.clear();
94
95 // loop over all BCID - starting from 1 for in-time pileup
96 int bcid=1;
97 for (std::vector<float>::const_iterator bcitr=m_multbcid.begin();
98 bcitr!=m_multbcid.end();++bcitr,++bcid) {
99 // actual number of minbias in this BCID
100 // Poisson around instantaneous_mu * multiplier value
101 const int nevtraw=CLHEP::RandPoisson::shoot(muval);
102 if (m_file) m_htgPileupEvents->Fill(nevtraw+0.1);
103 const int nevt=(float)nevtraw*(*bcitr);
104
105 for (int ievt=0;ievt<nevt;++ievt) {
106 ATH_MSG_DEBUG("Request generation of event " << ievt << " of " << nevt
107 << " for BCID " << bcid);
108
109//--------------------------- CALL GUN HERE
110 HepMC::GenEvent* evt=new HepMC::GenEvent();
111 evt->weights().push_back(1.0);
112 //evt->set_event_number(ievt); //Maybe dangerous to do this since the first event gets stacked last
113 // Make and fill particles
114 std::vector<SampledParticle> particles = m_partSampler->shoot();
115 for (const auto& p : particles){
116 // Debug printout of particle properties
117 std::cout << ievt << " DEBUG0," << p.m_pid << ", " << p.m_mom.E()<< ", " << p.m_mom.Pt()<< ", " << p.m_mom.M() << std::endl;
118 std::cout << ievt << " DEBUG1 (px,py,pz,E) = (" << p.m_mom.Px()<< ", " << p.m_mom.Py()<< ", " << p.m_mom.Pz()<< ", " << p.m_mom.E() <<")" << std::endl;
119 std::cout << ievt << " DEBUG2 (eta,phi,pt,m) = ()" << p.m_mom.Eta()<< ", " << p.m_mom.Phi()<< ", " << p.m_mom.Pt()<< ", " << p.m_mom.M() <<")" << std::endl;
120 std::cout << ievt << " DEBUG3 (x,y,z,t) = ()" << p.m_pos.X()<< ", " << p.m_pos.Y()<< ", " << p.m_pos.Z()<< ", " << p.m_pos.T() << ")" << std::endl;
121 // Make particle-creation vertex
122 // TODO: do something cleverer than one vertex per particle?
123 HepMC::FourVector pos(p.m_pos.X(), p.m_pos.Y(), p.m_pos.Z(), p.m_pos.T());
125 evt->add_vertex(gv);
126 // Make particle with status == 1
127 HepMC::FourVector mom(p.m_mom.Px(), p.m_mom.Py(), p.m_mom.Pz(), p.m_mom.E());
129 gp->set_status(1);
130 gp->set_pdg_id(p.m_pid);
131 gp->set_momentum(mom);
132 if (p.m_mass)
133 gp->set_generated_mass(p.m_mass);
134 gv->add_particle_out(std::move(gp));
135 }
136//-----------------------------------------
137
138 // change the process ID to incorporate the BCID * 10000
140 HepMC::set_signal_process_id(evt,pid+10000*bcid);
141 ATH_MSG_DEBUG("Signal process ID " << pid << " set to " <<
142 HepMC::signal_process_id(evt) << " for BCID " << bcid);
144 m_evts.push_back(evt);
145 ++m_ngen;
146 }
147 }
148 ATH_MSG_DEBUG("callGenerator finished with " << m_evts.size() <<
149 " pileup events in buffer");
150 return StatusCode::SUCCESS;
151}
#define ATH_MSG_DEBUG(x)
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition GenModule.cxx:34
std::vector< HepMC::GenEvent * > m_evts
int nPileupEvents(CLHEP::HepRandomEngine *rndmEngine)
int signal_process_id(const GenEvent &e)
Definition GenEvent.h:637
HepMC::GenVertex * GenVertexPtr
Definition GenVertex.h:59
GenVertexPtr newGenVertexPtr(const HepMC::FourVector &pos=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), const int i=0)
Definition GenVertex.h:64
GenParticlePtr newGenParticlePtr(const HepMC::FourVector &mom=HepMC::FourVector(0.0, 0.0, 0.0, 0.0), int pid=0, int status=0)
Definition GenParticle.h:39
void set_signal_process_id(GenEvent *e, const int i)
Definition GenEvent.h:643
void fillBarcodesAttribute(GenEvent *)
Definition GenEvent.h:628
GenParticle * GenParticlePtr
Definition GenParticle.h:37
setEventNumber setTimeStamp bcid

◆ cmTomm()

void GenBase::cmTomm ( HepMC::GenEvent * evt)
protectedinherited

Scale event lengths by x 10.

Definition at line 78 of file GenBase.cxx.

78 {
79 for (HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); vtx != evt->vertices_end(); ++vtx) {
80 const HepMC::FourVector fv((*vtx)->position().x() * 10,
81 (*vtx)->position().y() * 10,
82 (*vtx)->position().z() * 10,
83 (*vtx)->position().t() * 10);
84 (*vtx)->set_position(fv);
85 }
86}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ event_const()

const HepMC::GenEvent * GenBase::event_const ( ) const
inlineinherited

Access the current signal event (const)

Definition at line 83 of file GenBase.h.

83 {
84 if (events_const()->empty())
85 ATH_MSG_ERROR("Const McEventCollection is empty during first event access");
86 return *(events_const()->begin());
87 }
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition GenBase.h:96

◆ events_const() [1/2]

const McEventCollection * GenBase::events_const ( ) const
inlineinherited

Access the current event's McEventCollection (const)

Definition at line 96 of file GenBase.h.

96 {
97 return events_const( getContext() );
98 }

◆ events_const() [2/2]

const McEventCollection * GenBase::events_const ( const EventContext & ctx) const
inlineinherited

Definition at line 99 of file GenBase.h.

99 {
100 SG::ReadHandle<McEventCollection> ret = SG::makeHandle(m_mcevents_const, ctx);
101 if (!ret.isValid())
102 ATH_MSG_ERROR("No McEventCollection found in StoreGate with key " << m_mcevents_const.key());
103 return ret.cptr();
104 }
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
Definition GenBase.h:163
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode GenModule::execute ( )
virtualinherited
Todo
Remove hard-coded alg name checking (already incomplete)

Reimplemented from GenBase.

Definition at line 70 of file GenModule.cxx.

70 {
71 // Examples of how to retrieve the random number engine for a given
72 // stream.
73 // NB getRandomEngine should only be called once per event for a
74 // given stream, as it causes the stream to be re-seeded each time
75 // it is called.
76
77 // Example 1 - seeded based on the current event number (+ slot, run, streamName)
78 //const EventContext& ctx = Gaudi::Hive::currentContext();
79 //CLHEP::HepRandomEngine* rndmEngine = this->getRandomEngine("MyStream", ctx);
80
81 // Example 2 - seeded based on the m_randomSeed property (+ slot, run, streamName)
82 //const EventContext& ctx = Gaudi::Hive::currentContext();
83 //CLHEP::HepRandomEngine* rndmEngine = this->getRandomEngine("MyStream", m_randomSeed.value(), ctx);
84
85 // Call the code that generates an event
86 CHECK(this->callGenerator());
87
88 // Create the MC event and send the GeneratorEvent stored in it to fillEvt
89 HepMC::GenEvent* evt = HepMC::newGenEvent(1,1);
90 CHECK(this->fillEvt(evt));
92
93 // Add the event to the MC event collection
94 if (events()) {
95 // If this is an "afterburner" generator, replace the last event rather than add a new one
97 if (m_isAfterburner.value() || name() == "Tauola" || name() == "Photos") {
98 events()->pop_back();
99 }
100 // Add the event to the end of the collection
101 events()->push_back(evt);
102 ATH_MSG_DEBUG("MC event added to McEventCollection");
103
104 // remove the empty event in case of ParticleDecayer
105 if (name() == "ParticleDecayer") {
106 events()->pop_back();
107 }
108 }
109
110 // Call the incident service to notify that an event has been made
111 m_incidentSvc->fireIncident( Incident(name(), "McEventGenerated") );
112 return StatusCode::SUCCESS;
113}
#define CHECK(...)
Evaluate an expression and check for errors.
ServiceHandle< IIncidentSvc > m_incidentSvc
Handle on the incident service.
Definition GenModule.h:101
virtual StatusCode callGenerator()
For calling the generator on each iteration of the event loop.
Definition GenModule.h:66
virtual StatusCode fillEvt(HepMC::GenEvent *evt)=0
For filling the HepMC event object.
BooleanProperty m_isAfterburner
Flag for normal vs. afterburner generators.
Definition GenModule.h:87
GenEvent * newGenEvent(const int a, const int b)
Definition GenEvent.h:626

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ fillEvt()

StatusCode MultiParticleGunPileup::fillEvt ( HepMC::GenEvent * evt)
virtual

For filling the HepMC event object.

Implements GenModule.

Definition at line 153 of file MultiParticleGunPileup.cxx.

153 {
154 int nbuf=m_evts.size();
155 if (nbuf>1) {
156 // send extra events into McEventCollection via backdoor
157 for (int i=1;i<nbuf;++i) {
158 events()->push_back(m_evts[i]);
159 }
160 }
161 // send first event back via usual method
162 // have to copy it to the passed in GenEvent
163 if (nbuf>0) {
164 *evt=*m_evts[0];
165 delete m_evts[0];
166 }
167 return StatusCode::SUCCESS;
168}

◆ finalize()

StatusCode GenModule::finalize ( )
inlineinherited

Definition at line 55 of file GenModule.h.

55{ return genFinalize(); }
virtual StatusCode genFinalize()
For finalising the generator, if required.
Definition GenModule.h:70

◆ genFinalize()

StatusCode MultiParticleGunPileup::genFinalize ( )
virtual

For finalising the generator, if required.

Reimplemented from GenModule.

Definition at line 170 of file MultiParticleGunPileup.cxx.

170 {
171 ATH_MSG_INFO("MultiParticleGunPileup finished with " << m_ngen << " good events and " << m_nbad << " failures" );
172
173 if (m_file) {
174 m_file->cd();
175 m_file->Write();
176 m_file->Close();
177 }
178
179 return StatusCode::SUCCESS;
180}
#define ATH_MSG_INFO(x)

◆ genInitialize()

StatusCode MultiParticleGunPileup::genInitialize ( )
virtual

For initializing the generator, if required.

Reimplemented from GenModule.

Definition at line 39 of file MultiParticleGunPileup.cxx.

39 {
40 ATH_MSG_INFO( "In MultiParticleGunPileup::genInitialize" );
41
42 // should be initialized after Pythia8_i::genInitialize() ???
43 // m_randomEngine = atRndmGenSvc().GetEngine( Pythia8_i::pythia_stream );
44
45 // if filename set, initialise histograms for mu/nevt profiles
46 if (m_filename!="") {
47 m_file = new TFile( m_filename.c_str(), "recreate" );
48 m_file->cd();
49 m_htgPileupProfile = new TH1D( "pileupProfile", "input pileupProfile", 100, 0., 100. );
50 m_htgPileupMu = new TH1D( "generatedMu", "generated pileup mu", 100, 0., 100. );
51 m_htgPileupEvents = new TH1D( "generatedEvents", "generated pileup events", 100, 0., 100. );
52 }
53
56 for ( std::vector< int >::iterator itr = m_pileupProfile.begin(); itr != m_pileupProfile.end(); ++itr ) {
57 m_pileupProfileIntegral.push_back( std::accumulate( m_pileupProfile.begin(), itr + 1, 0. ) );
58 if (m_file)
59 m_htgPileupProfile->SetBinContent( std::distance( m_pileupProfile.begin(), itr ) + 1, *itr );
60 }
61
62 if ( m_ncollevent > 0 ) {
63 ATH_MSG_INFO("Generate fixed number of " << m_ncollevent << " minbias collisions per bunch crossing");
64 }
65 else {
66 ATH_MSG_INFO("Generate varying minbias collisions per event according to given pileup profile");
67 }
68 m_evts.reserve( 50 );
69
70 ATH_MSG_INFO("Simulate " << m_multbcid.size() << " bunch crossings per event");
71 int ibc=1;
72 for (std::vector<float>::const_iterator itr=m_multbcid.begin();
73 itr!=m_multbcid.end();++itr,++ibc) {
74 ATH_MSG_INFO("Bunch crossing BCID " << ibc << " mu multiplier " << *itr);
75 }
76
77 //Initialize the ParticleGun generator
78 m_partSampler = new ParticleSampler(new CyclicSeqSampler("-11,11,"), new PtEtaMPhiSampler(10000.,10000.,-3,3),1);
79
80 // exit via the base class initialisation
81 return StatusCode::SUCCESS;
82}
std::vector< double > m_pileupProfileIntegral

◆ genuserInitialize()

virtual StatusCode GenModule::genuserInitialize ( )
inlinevirtualinherited

For initialization of user code, if required. Called after genInitialize.

Reimplemented in Pythia8B_i.

Definition at line 64 of file GenModule.h.

64{ return StatusCode::SUCCESS; }

◆ getRandomEngine() [1/2]

CLHEP::HepRandomEngine * GenModule::getRandomEngine ( const std::string & streamName,
const EventContext & ctx ) const
protectedinherited

Definition at line 34 of file GenModule.cxx.

36{
37 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName);
38 std::string rngName = name()+streamName;
39 rngWrapper->setSeed( rngName, ctx );
40 return rngWrapper->getEngine(ctx);
41}
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
ServiceHandle< IAthRNGSvc > m_rndmSvc
Data members.
Definition GenModule.h:99

◆ getRandomEngine() [2/2]

CLHEP::HepRandomEngine * GenModule::getRandomEngine ( const std::string & streamName,
unsigned long int randomSeedOffset,
const EventContext & ctx ) const
protectedinherited

Definition at line 44 of file GenModule.cxx.

46{
47 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, streamName);
48 rngWrapper->setSeed( streamName, ctx.slot(), randomSeedOffset, ctx.eventID().run_number() );
49 return rngWrapper->getEngine(ctx);
50}

◆ getRandomEngineDuringInitialize()

CLHEP::HepRandomEngine * GenModule::getRandomEngineDuringInitialize ( const std::string & streamName,
unsigned long int randomSeedOffset,
unsigned int conditionsRun = 1,
unsigned int lbn = 1 ) const
protectedinherited

Definition at line 53 of file GenModule.cxx.

54{
55 const size_t slot=0;
56 EventContext ctx;
57 ctx.setSlot( slot );
58 ctx.setEventID (EventIDBase (conditionsRun,
59 EventIDBase::UNDEFEVT, // event
60 EventIDBase::UNDEFNUM, // timestamp
61 EventIDBase::UNDEFNUM, // timestamp ns
62 lbn));
64 Atlas::ExtendedEventContext( evtStore()->hiveProxyDict(),
65 conditionsRun) );
66 return getRandomEngine(streamName, randomSeedOffset, ctx);
67}
void setExtendedEventContext(EventContext &ctx, ExtendedEventContext &&ectx)
Move an extended context into a context object.

◆ GeVToMeV()

void GenBase::GeVToMeV ( HepMC::GenEvent * evt)
protectedinherited

Scale event energies/momenta by x 1000.

Todo
Add HepMC units awareness and do it differently when HepMC provides this functionality directly (and reference-based FourVector accessors)

Definition at line 58 of file GenBase.cxx.

58 {
59 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
60 const HepMC::FourVector fv((*p)->momentum().px() * 1000,
61 (*p)->momentum().py() * 1000,
62 (*p)->momentum().pz() * 1000,
63 (*p)->momentum().e() * 1000);
64 (*p)->set_momentum(fv);
65 (*p)->set_generated_mass(1000 * (*p)->generated_mass());
66 }
67}

◆ initialize()

StatusCode GenModule::initialize ( )
virtualinherited

Reimplemented from GenBase.

Definition at line 21 of file GenModule.cxx.

21 {
22 // Base class initializations
24 // Get the random number service
25 CHECK(m_rndmSvc.retrieve());
26 // Get the incident service
27 CHECK(m_incidentSvc.retrieve());
30 return StatusCode::SUCCESS;
31}
virtual StatusCode initialize() override
Definition GenBase.cxx:17
virtual StatusCode genuserInitialize()
For initialization of user code, if required. Called after genInitialize.
Definition GenModule.h:64
virtual StatusCode genInitialize()
For initializing the generator, if required.
Definition GenModule.h:62

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ MeVToGeV()

void GenBase::MeVToGeV ( HepMC::GenEvent * evt)
protectedinherited

Scale event energies/momenta by x 1/1000.

Definition at line 68 of file GenBase.cxx.

68 {
69 for (HepMC::GenEvent::particle_iterator p = evt->particles_begin(); p != evt->particles_end(); ++p) {
70 const HepMC::FourVector fv((*p)->momentum().px() / 1000,
71 (*p)->momentum().py() / 1000,
72 (*p)->momentum().pz() / 1000,
73 (*p)->momentum().e() / 1000);
74 (*p)->set_momentum(fv);
75 (*p)->set_generated_mass((*p)->generated_mass() / 1000);
76 }
77}

◆ mmTocm()

void GenBase::mmTocm ( HepMC::GenEvent * evt)
protectedinherited

Scale event lengths by x 1/10.

Definition at line 87 of file GenBase.cxx.

87 {
88 for (HepMC::GenEvent::vertex_iterator vtx = evt->vertices_begin(); vtx != evt->vertices_end(); ++vtx) {
89 const HepMC::FourVector fv((*vtx)->position().x() / 10,
90 (*vtx)->position().y() / 10,
91 (*vtx)->position().z() / 10,
92 (*vtx)->position().t() / 10);
93 (*vtx)->set_position(fv);
94 }
95}

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ nPileupEvents()

int MultiParticleGunPileup::nPileupEvents ( CLHEP::HepRandomEngine * rndmEngine)
private

Definition at line 183 of file MultiParticleGunPileup.cxx.

183 {
184 // return the instantaneous mu value according to the profile
185 double threshold = rndmEngine->flat() * m_pileupProfileIntegral.back();
186 std::vector< double >::iterator itr = std::lower_bound( m_pileupProfileIntegral.begin(), m_pileupProfileIntegral.end(), threshold );
187 return std::distance( m_pileupProfileIntegral.begin(), itr );
188}

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ particleData()

const HepPDT::ParticleData * GenBase::particleData ( int pid) const
inlineinherited

Access an element in the particle data table.

Definition at line 126 of file GenBase.h.

126 {
127 return pdt().particle(HepPDT::ParticleID(std::abs(pid)));
128 }
const HepPDT::ParticleDataTable & pdt() const
Shorter alias to get a particle data table.
Definition GenBase.h:123

◆ particleTable()

const HepPDT::ParticleDataTable & GenBase::particleTable ( ) const
inlineinherited

Get a particle data table.

Definition at line 118 of file GenBase.h.

118 {
119 return *(m_ppSvc->PDT());
120 }
ServiceHandle< IPartPropSvc > m_ppSvc
Handle on the particle property service.
Definition GenBase.h:160

◆ partPropSvc()

const ServiceHandle< IPartPropSvc > GenBase::partPropSvc ( ) const
inlineinherited

Access the particle property service.

Definition at line 113 of file GenBase.h.

113 {
114 return m_ppSvc;
115 }

◆ pdt()

const HepPDT::ParticleDataTable & GenBase::pdt ( ) const
inlineinherited

Shorter alias to get a particle data table.

Definition at line 123 of file GenBase.h.

123{ return particleTable(); }
const HepPDT::ParticleDataTable & particleTable() const
Get a particle data table.
Definition GenBase.h:118

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_WARNING(x)
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evts

std::vector< HepMC::GenEvent * > MultiParticleGunPileup::m_evts
private

Definition at line 47 of file MultiParticleGunPileup.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_file

TFile* MultiParticleGunPileup::m_file
private

Definition at line 51 of file MultiParticleGunPileup.h.

◆ m_filename

std::string MultiParticleGunPileup::m_filename
private

Definition at line 41 of file MultiParticleGunPileup.h.

◆ m_htgPileupEvents

TH1D * MultiParticleGunPileup::m_htgPileupEvents
private

Definition at line 52 of file MultiParticleGunPileup.h.

◆ m_htgPileupMu

TH1D * MultiParticleGunPileup::m_htgPileupMu
private

Definition at line 52 of file MultiParticleGunPileup.h.

◆ m_htgPileupProfile

TH1D* MultiParticleGunPileup::m_htgPileupProfile
private

Definition at line 52 of file MultiParticleGunPileup.h.

◆ m_incidentSvc

ServiceHandle<IIncidentSvc> GenModule::m_incidentSvc {this, "IncidentSvc", "IncidentSvc"}
privateinherited

Handle on the incident service.

Definition at line 101 of file GenModule.h.

101{this, "IncidentSvc", "IncidentSvc"};

◆ m_isAfterburner

BooleanProperty GenModule::m_isAfterburner {this, "IsAfterburner", false, "Set true if generator modifies existing events rather than creating new ones"}
protectedinherited

Flag for normal vs. afterburner generators.

Definition at line 87 of file GenModule.h.

87{this, "IsAfterburner", false, "Set true if generator modifies existing events rather than creating new ones"};

◆ m_mcEventKey

std::string GenBase::m_mcEventKey {}
protectedinherited

StoreGate key for the MC event collection (defaults to GEN_EVENT)

Definition at line 137 of file GenBase.h.

137{};

◆ m_mcevents_const

SG::ReadHandleKey<McEventCollection> GenBase::m_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
privateinherited

Const handle to the MC event collection.

Definition at line 163 of file GenBase.h.

163{ this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" };

◆ m_mkMcEvent

BooleanProperty GenBase::m_mkMcEvent {this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"}
protectedinherited

Flag to determine if a new MC event collection should be made if it doesn't exist.

Definition at line 139 of file GenBase.h.

139{this, "MakeMcEvent", false, "Create a new MC event collection if it doesn't exist"};

◆ m_multbcid

std::vector< float > MultiParticleGunPileup::m_multbcid
private

Definition at line 40 of file MultiParticleGunPileup.h.

◆ m_nbad

int MultiParticleGunPileup::m_nbad
private

Definition at line 44 of file MultiParticleGunPileup.h.

◆ m_ncollevent

int MultiParticleGunPileup::m_ncollevent
private

Definition at line 38 of file MultiParticleGunPileup.h.

◆ m_ngen

int MultiParticleGunPileup::m_ngen
private

Definition at line 43 of file MultiParticleGunPileup.h.

◆ m_partSampler

ParticleSampler* MultiParticleGunPileup::m_partSampler
private

Definition at line 54 of file MultiParticleGunPileup.h.

◆ m_pileupProfile

std::vector< int > MultiParticleGunPileup::m_pileupProfile
private

Definition at line 39 of file MultiParticleGunPileup.h.

◆ m_pileupProfileIntegral

std::vector< double > MultiParticleGunPileup::m_pileupProfileIntegral
private

Definition at line 49 of file MultiParticleGunPileup.h.

◆ m_ppSvc

ServiceHandle<IPartPropSvc> GenBase::m_ppSvc {this, "PartPropSvc", "PartPropSvc"}
privateinherited

Handle on the particle property service.

Definition at line 160 of file GenBase.h.

160{this, "PartPropSvc", "PartPropSvc"};

◆ m_randomSeed

IntegerProperty GenModule::m_randomSeed {this, "RandomSeed", 1234567, "Random seed for the built-in random engine"}
protectedinherited

Seed for random number engine.

Definition at line 84 of file GenModule.h.

84{this, "RandomSeed", 1234567, "Random seed for the built-in random engine"}; // FIXME make this into an unsigned long int?

◆ m_rndmSvc

ServiceHandle<IAthRNGSvc> GenModule::m_rndmSvc {this, "RndmSvc", "AthRNGSvc"}
privateinherited

Data members.

Definition at line 99 of file GenModule.h.

99{this, "RndmSvc", "AthRNGSvc"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: