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

Track Record Generator. More...

#include <TrackRecordGenerator.h>

Inheritance diagram for TrackRecordGenerator:
Collaboration diagram for TrackRecordGenerator:

Public Member Functions

 TrackRecordGenerator (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~TrackRecordGenerator ()
virtual StatusCode callGenerator ()
 For calling the generator on each iteration of the event loop.
virtual StatusCode fillEvt (HepMC::GenEvent *evt)
 For filling the HepMC event object.
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
 Get filter decision:
virtual void setFilterPassed (bool state, const EventContext &ctx) const
 Set filter decision:
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 (const EventContext &ctx)
 Execute method.
StatusCode finalize ()
Gen-specific event loop methods: to be overloaded
virtual StatusCode genInitialize ()
 For initializing the generator, if required.
virtual StatusCode genuserInitialize ()
 For initialization of user code, if required. Called after genInitialize.
virtual StatusCode genFinalize ()
 For finalising the generator, if required.
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::GenEventevent_const (const EventContext &ctx) const
 Access the current signal event (const).
const McEventCollectionevents_const (const EventContext &ctx) const
 Access the current event's McEventCollection (const).

Protected Member Functions

virtual bool isReEntrant () const override final
 Legacy algorithms are not thread-safe.
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.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

int m_events
std::vector< int > m_pdgCode
std::vector< CLHEP::HepLorentzVector > m_fourPos
std::vector< CLHEP::HepLorentzVector > m_fourMom
CLHEP::Hep3Vector m_center
std::vector< HepMC::Polarizationm_polarization
double m_smearTR
 Amount by which to smear TR position.
double m_smearTRp
 Amount by which to smear TR momentum.
std::string m_recordName
 TrackRecord collection name.
bool m_stopParticles
 Stop particles before simulation.
float m_stopped_tminus
float m_stopped_tplus
 Bounds for random time.
bool m_add_cL
 For stopped particles, add c*L to the time.
std::shared_ptr< GenDatam_gendata {nullptr}
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
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.
std::shared_ptr< HepMC3::GenRunInfo > m_runinfo {}
 The run info for HepMC3.
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

Properties

SG::ReadHandleKey< McEventCollectionm_mcevents_const { this, "McEventKey", "GEN_EVENT", "StoreGate key of the MC event collection" }
 Const handle to the MC event collection.
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.

Detailed Description

Track Record Generator.

The class takes input simulation track records and uses them as generator records.

Author
Zach Marshall ZLMar.nosp@m.shal.nosp@m.l@lbl.nosp@m..gov

Definition at line 29 of file TrackRecordGenerator.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TrackRecordGenerator()

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

Definition at line 25 of file TrackRecordGenerator.cxx.

26 : GenModule(name,pSvcLocator)
27 , m_events(0)
28{
29 // Input collection name
30 declareProperty("TRCollection" , m_recordName = "CosmicRecord" );
31
32 // Smearing of the initial position for tracks
33 declareProperty("TRSmearing", m_smearTR=-1, "Smear the initial position of the track by up to this amount");
34 declareProperty("TRPSmearing", m_smearTRp=-1, "Smear the momentum of the track by up to this amount");
35 declareProperty("StopParticles", m_stopParticles=false, "Stop the particles and make them decay within 25 ns");
36 declareProperty("stopped_tminus", m_stopped_tminus =-25. );
37 declareProperty("stopped_tplus", m_stopped_tplus =25. );
38 declareProperty("Add_cL", m_add_cL=true, "For stopped particles, shift the time by c times the decay rho");
39 m_gendata = std::make_shared<GenData>();
40}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
GenModule(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenModule.cxx:14
bool m_stopParticles
Stop particles before simulation.
double m_smearTR
Amount by which to smear TR position.
float m_stopped_tplus
Bounds for random time.
std::string m_recordName
TrackRecord collection name.
double m_smearTRp
Amount by which to smear TR momentum.
std::shared_ptr< GenData > m_gendata
bool m_add_cL
For stopped particles, add c*L to the time.

◆ ~TrackRecordGenerator()

TrackRecordGenerator::~TrackRecordGenerator ( )
virtual

Definition at line 43 of file TrackRecordGenerator.cxx.

44{}

Member Function Documentation

◆ ATLAS_NOT_CONST_THREAD_SAFE() [1/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.

◆ ATLAS_NOT_CONST_THREAD_SAFE() [2/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 74 of file GenBase.h.

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

◆ callGenerator()

StatusCode TrackRecordGenerator::callGenerator ( )
virtual

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

Reimplemented from GenModule.

Definition at line 47 of file TrackRecordGenerator.cxx.

47 {
48
49 ++m_events;
50 ATH_MSG_DEBUG( "Event #" << m_events);
51
52 // clear up the vectors
53 m_fourPos.clear();
54 m_fourMom.clear();
55 m_polarization.clear();
56 m_pdgCode.clear();
57
58 const EventContext& ctx = Gaudi::Hive::currentContext();
59 CLHEP::HepRandomEngine* rndmEngine = this->getRandomEngine(name(), ctx);
60
61 const TrackRecordCollection* coll = nullptr;
62 CHECK( evtStore()->retrieve(coll,m_recordName) );
63
64 ATH_MSG_INFO("retrieved "<<coll->size()<<" TTR hits; will smear position by "<< (m_smearTR>0?m_smearTR:0.) <<" mm and momentum by "<< (m_smearTRp>0?m_smearTRp:0.) <<" radians");
65
66 for (const auto & iterTTR : *coll) {
67
68 const auto pmass = m_gendata->particleMass(std::abs(iterTTR.GetPDGCode()));
69 double mass = *pmass;
70 double en = std::sqrt(mass*mass+iterTTR.GetMomentum().mag2());
71
72 ATH_MSG_VERBOSE("Reading back TTR:\n pos is "<<iterTTR.GetPosition()
73 <<"\n mom is "<<iterTTR.GetMomentum()
74 <<"\n pdg is "<<iterTTR.GetPDGCode() );
75
76 CLHEP::HepLorentzVector particle4Position( iterTTR.GetPosition(), iterTTR.GetTime());
77
78 ATH_MSG_DEBUG( "Smearing position by up to " << m_smearTR << " mm and momentum by up to " << m_smearTRp << " radians" );
79 if (m_smearTR>0){
80 ATH_MSG_DEBUG( "Track record started at " << particle4Position );
81
82 // if Z is maximal, move in X and Y; otherwise move in Z and "phi"
83 if ( particle4Position.z() == 22031 || particle4Position.z() == -22031 ){ //FIXME Hardcoded limits!
84 particle4Position.setX( particle4Position.x() + CLHEP::RandFlat::shoot(rndmEngine, -m_smearTR, m_smearTR) );
85 particle4Position.setY( particle4Position.y() + CLHEP::RandFlat::shoot(rndmEngine, -m_smearTR, m_smearTR) );
86 } else {
87 particle4Position.setZ( particle4Position.z() + CLHEP::RandFlat::shoot(rndmEngine, -m_smearTR, m_smearTR) );
88 double R = std::sqrt( std::pow( particle4Position.x(),2 ) + std::pow(particle4Position.y(),2 ) );
89 double dPhi = std::atan2( m_smearTR, R );
90 dPhi = CLHEP::RandFlat::shoot( rndmEngine, -dPhi, dPhi );
91 double theta = std::atan2( particle4Position.x() , particle4Position.y() );
92 particle4Position.setX( R*std::sin( theta + dPhi ) );
93 particle4Position.setY( R*std::cos( theta + dPhi ) );
94 }
95 ATH_MSG_DEBUG( "Shifted track record to " << particle4Position );
96 }
97 CLHEP::HepLorentzVector particle4Momentum( iterTTR.GetMomentum(), en );
98 if (m_smearTRp>0){
99 ATH_MSG_DEBUG( "Track record momentum was " << particle4Momentum );
100
101 // Keep p - smear an angle, and then randomly spin that change in (0,2PI)
102 double dTheta = CLHEP::RandFlat::shoot(rndmEngine, 0, m_smearTRp);
103 double dPhi = CLHEP::RandFlat::shoot(rndmEngine, 0, 2*M_PI);
104
105 // Need a perpendicular vector...
106 CLHEP::HepLorentzVector perpendicularMomentum( 1 , 0 , 0 , 0);
107 if ( particle4Momentum.x() != 0 ){
108 if (particle4Momentum.y() == 0){
109 perpendicularMomentum.setX( 0 );
110 perpendicularMomentum.setY( 1 );
111 } else {
112 perpendicularMomentum.setX( particle4Momentum.y() );
113 perpendicularMomentum.setY( particle4Momentum.x() );
114 }
115 }
116
117 // Now scale it based on dTheta
118 double tempP = std::pow(particle4Momentum.x(),2)+std::pow(particle4Momentum.y(),2)+std::pow(particle4Momentum.z(),2);
119 if ( tempP==0 ) {
120 ATH_MSG_DEBUG("Our initial momentum had zero magnitude!!");
121 perpendicularMomentum.setX(0);
122 perpendicularMomentum.setY(0);
123 } else if ( std::tan(dTheta) == 0 ){
124 ATH_MSG_DEBUG("Randomly deciding to keep the vector's direction...");
125 perpendicularMomentum.setX(0);
126 perpendicularMomentum.setY(0);
127 } else {
128 double scale = ( tempP ) * std::sin(dTheta) / ( std::pow(perpendicularMomentum.x(),2)+std::pow(perpendicularMomentum.y(),2) );
129 perpendicularMomentum.setX( perpendicularMomentum.x() * scale );
130 perpendicularMomentum.setY( perpendicularMomentum.y() * scale );
131
132 // Rotate perpendicularMomentum by dPhi around particle4Momentum
133 perpendicularMomentum.rotate( dPhi , particle4Momentum.vect() );
134 }
135 particle4Momentum.setX( particle4Momentum.x() + perpendicularMomentum.x() );
136 particle4Momentum.setY( particle4Momentum.y() + perpendicularMomentum.y() );
137 particle4Momentum.setZ( particle4Momentum.z() + perpendicularMomentum.z() );
138
139 // Rescale (very small effect, but want to include it)
140 double scale2 = tempP==0? 1 : (pow(particle4Momentum.x(),2)+pow(particle4Momentum.y(),2)+pow(particle4Momentum.z(),2)) / tempP;
141 particle4Momentum.setX( particle4Momentum.x() * scale2 );
142 particle4Momentum.setY( particle4Momentum.y() * scale2 );
143 particle4Momentum.setZ( particle4Momentum.z() * scale2 );
144 ATH_MSG_DEBUG( "Rotated the vector by " << perpendicularMomentum );
145 ATH_MSG_DEBUG( "And resulting momentum is " << particle4Momentum );
146 }
147 if (m_stopParticles){
148 ATH_MSG_DEBUG( "Will stop the track record where it is and give it mass " << mass );
149 particle4Momentum.setX(0);
150 particle4Momentum.setY(0);
151 particle4Momentum.setZ(0);
152 particle4Momentum.setT(mass);
153
154 double settime=CLHEP::RandFlat::shoot(rndmEngine,m_stopped_tminus, m_stopped_tplus);
155 ATH_MSG_DEBUG( "Setting particle time to something uniform between "<<m_stopped_tminus<<" and "<<m_stopped_tplus<<" ns : " << settime );
156 if (m_add_cL){
157 settime += particle4Position.rho()/CLHEP::c_light;
158 }
159 particle4Position.setT(settime*CLHEP::c_light); // ct in mm
160 }
161
162 m_fourPos.push_back( particle4Position );
163 m_fourMom.push_back( particle4Momentum );
164
165 m_pdgCode.push_back(iterTTR.GetPDGCode());
166 HepMC::Polarization thePolarization(0.0,0.0);
167 m_polarization.push_back(thePolarization);
168
169 if (m_stopParticles){
170 ATH_MSG_DEBUG( "Only one per event!!" );
171 break;
172 }
173 } // Loop through the track record collection
174
175 return StatusCode::SUCCESS;
176}
#define M_PI
Scalar theta() const
theta method
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
#define scale2
AtlasHitsVector< TrackRecord > TrackRecordCollection
ServiceHandle< StoreGateSvc > & evtStore()
size_type size() const
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition GenModule.cxx:34
std::vector< CLHEP::HepLorentzVector > m_fourMom
std::vector< HepMC::Polarization > m_polarization
std::vector< CLHEP::HepLorentzVector > m_fourPos
std::vector< int > m_pdgCode
double R(const INavigable4Momentum *p1, const double v_eta, const double v_phi)
bool dPhi(const xAOD::TauJet &tau, const xAOD::CaloVertexedTopoCluster &cluster, float &out)
constexpr int pow(int x)
Definition conifer.h:27

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::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< Gaudi::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 EventContext & ctx) const
inlineinherited

Access the current signal event (const).

Definition at line 81 of file GenBase.h.

81 {
82 const McEventCollection* coll = events_const(ctx);
83 if (coll->empty())
84 ATH_MSG_ERROR("Const McEventCollection is empty during first event access");
85 return *(coll->begin());
86 }
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
bool empty() const noexcept
Returns true if the collection is empty.
const McEventCollection * events_const(const EventContext &ctx) const
Access the current event's McEventCollection (const).
Definition GenBase.h:95

◆ events_const()

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

Access the current event's McEventCollection (const).

Definition at line 95 of file GenBase.h.

95 {
96 SG::ReadHandle<McEventCollection> ret = SG::makeHandle(m_mcevents_const, ctx);
97 if (!ret.isValid())
98 ATH_MSG_ERROR("No McEventCollection found in StoreGate with key " << m_mcevents_const.key());
99 return ret.cptr();
100 }
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
Definition GenBase.h:119
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< Gaudi::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 ( const EventContext & ctx)
virtualinherited

Execute method.

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 //CLHEP::HepRandomEngine* rndmEngine = this->getRandomEngine("MyStream", ctx);
79
80 // Example 2 - seeded based on the m_randomSeed property (+ slot, run, streamName)
81 //CLHEP::HepRandomEngine* rndmEngine = this->getRandomEngine("MyStream", m_randomSeed.value(), ctx);
82
83 // Call the code that generates an event
84 CHECK(this->callGenerator());
85
86 // Create the MC event and send the GeneratorEvent stored in it to fillEvt
88 CHECK(this->fillEvt(evt));
90
91 // Add the event to the MC event collection
92 if (events()) {
93 // If this is an "afterburner" generator, replace the last event rather than add a new one
95 if (m_isAfterburner.value() || name() == "Tauola" || name() == "Photos") {
96 events()->pop_back();
97 }
98 // Add the event to the end of the collection
99 events()->push_back(evt);
100 ATH_MSG_DEBUG("MC event added to McEventCollection");
101
102 // remove the empty event in case of ParticleDecayer
103 if (name() == "ParticleDecayer") {
104 events()->pop_back();
105 }
106 }
107
108 // Call the incident service to notify that an event has been made
109 m_incidentSvc->fireIncident( Incident(name(), "McEventGenerated") );
110 return StatusCode::SUCCESS;
111}
ServiceHandle< IIncidentSvc > m_incidentSvc
Handle on the incident service.
Definition GenModule.h:99
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
void fillBarcodesAttribute(GenEvent *e)
Definition GenEvent.h:393
GenEvent * newGenEvent(const int signal_process_id, const int event_number)
Definition GenEvent.h:360
HepMC3::GenEvent GenEvent
Definition GenEvent.h:39

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::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 & AthCommonAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

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

Definition at line 89 of file AthCommonAlgorithm.cxx.

54{
55 // If we didn't find any symlinks to add, just return the collection
56 // from the base class. Otherwise, return the extended collection.
57 if (!m_extendedExtraObjects.empty()) {
59 }
61}
Common base class for algorithms.

◆ fillEvt()

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

For filling the HepMC event object.

Implements GenModule.

Definition at line 179 of file TrackRecordGenerator.cxx.

179 {
180
181 if ( m_fourMom.size() != m_fourPos.size() || m_fourMom.size() != m_polarization.size()) {
182 ATH_MSG_ERROR("Wrong different number of vertexes/momenta/polaritazions!");
183 return StatusCode::FAILURE;
184 }
185 for(std::size_t v = 0; v < m_fourMom.size(); ++v){
186 // Note: The vertex and particle are owned by the event, so the
187 // event is responsible for those pointers.
188
189 // Create the particle, and specify its polarization.
191
192 // Create the vertex, and add the particle to the vertex.
194 vertex->add_particle_out( particle );
195
196 // Add the vertex to the event.
197 event->add_vertex( std::move(vertex) );
198
199 // Add attributes
201 } // Loop over the particles
202
203 event->set_event_number(m_events); // Set the event number
204 if (event->weights().empty()){
205 event->weights().push_back(1.0);
206 }
207 return StatusCode::SUCCESS;
208}
#define y
#define x
#define z
void set_polarization(T &a, const Polarization &b)
HepMC3::FourVector FourVector
GenParticlePtr newGenParticlePtr(const HepMC3::FourVector &mom=HepMC3::FourVector::ZERO_VECTOR(), int pid=0, int status=0)
Definition GenParticle.h:21
HepMC3::GenParticlePtr GenParticlePtr
Definition GenParticle.h:19
GenVertexPtr newGenVertexPtr(const HepMC3::FourVector &pos=HepMC3::FourVector::ZERO_VECTOR(), const int i=0)
Definition GenVertex.h:25
HepMC3::GenVertexPtr GenVertexPtr
Definition GenVertex.h:23
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses

◆ filterPassed()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Get filter decision:

Definition at line 93 of file AthCommonAlgorithm.h.

93 {
94 return execState( ctx ).filterPassed();
95 }
virtual bool filterPassed(const EventContext &ctx) const
Get filter decision:

◆ 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()

virtual StatusCode GenModule::genFinalize ( )
inlinevirtualinherited

For finalising the generator, if required.

Reimplemented in BeamHaloGeneratorAlg, CosmicGenerator, Epos4, Epos, Herwig7, Hijing, MultiParticleGunPileup, MultiPy8Pileup, Pythia8_i, Pythia8B_i, Sherpa_i, and Starlight_i.

Definition at line 70 of file GenModule.h.

70{ return StatusCode::SUCCESS; }

◆ genInitialize()

virtual StatusCode GenModule::genInitialize ( )
inlinevirtualinherited

For initializing the generator, if required.

Reimplemented in BeamHaloGeneratorAlg, CosmicGenerator, Epos4, Epos, Herwig7, Hijing, MultiParticleGunPileup, MultiPy8Pileup, ParticleDecayer, Pythia8_i, Pythia8B_i, Sherpa_i, and Starlight_i.

Definition at line 62 of file GenModule.h.

62{ return StatusCode::SUCCESS; }

◆ 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:154
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:108
ServiceHandle< IAthRNGSvc > m_rndmSvc
Data members.
Definition GenModule.h:97

◆ 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.

◆ 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< Gaudi::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.

◆ isClonable()

virtual bool AthCommonAlgorithm< Gaudi::Algorithm >::isClonable ( ) const
inlineoverridevirtualinherited

Specify if the algorithm is clonable.

Only relevant for non-reentrant algorithms. Actual number of clones needs to be set via the "Cardinality" property.

Reimplemented in AFP_DigiTop, AlgB, AlgT, BCM_Digitization, CscDigitBuilder, CscDigitToCscRDO, G4AtlasAlg, G4RunAlg, HGTD_Digitization, HiveAlgBase, InDet::GNNSeedingTrackMaker, InDet::SCT_Clusterization, InDet::SiSPGNNTrackMaker, InDet::SiSPSeededTrackFinder, InDet::SiTrackerSpacePointFinder, ISF::SimKernelMT, ITk::StripDigitization, ITkPixelCablingAlg, ITkStripCablingAlg, LArHitEMapMaker, LArTTL1Maker, LUCID_DigiTop, LVL1::L1TopoSimulation, MergeCalibHits, MergeGenericMuonSimHitColl, MergeHijingPars, MergeMcEventCollection, MergeTrackRecordCollection, MergeTruthJets, MergeTruthParticles, MuonDigitizer, PileUpMTAlg, PixelDigitization, RoIBResultToxAOD, SCT_ByteStreamErrorsTestAlg, SCT_CablingCondAlgFromCoraCool, SCT_CablingCondAlgFromText, SCT_ConditionsParameterTestAlg, SCT_ConditionsSummaryTestAlg, SCT_ConfigurationConditionsTestAlg, SCT_Digitization, SCT_FlaggedConditionTestAlg, SCT_LinkMaskingTestAlg, SCT_MajorityConditionsTestAlg, SCT_ModuleVetoTestAlg, SCT_MonitorConditionsTestAlg, SCT_PrepDataToxAOD, SCT_RawDataToxAOD, SCT_ReadCalibChipDataTestAlg, SCT_ReadCalibDataTestAlg, SCT_RODVetoTestAlg, SCT_SensorsTestAlg, SCT_SiliconConditionsTestAlg, SCT_StripVetoTestAlg, SCT_TdaqEnabledTestAlg, SCT_TestCablingAlg, SCTEventFlagWriter, SCTRawDataProvider, SCTSiLorentzAngleTestAlg, SCTSiPropertiesTestAlg, SGInputLoader, Simulation::BeamEffectsAlg, TileHitVecToCnt, TileMuonFitter, TilePulseForTileMuonReceiver, TileRawChannelMaker, TRTDigitization, and ZDC_DigiTop.

Definition at line 68 of file AthCommonAlgorithm.h.

68 {
69 return true;
70 }

◆ isReEntrant()

virtual bool AthAlgorithm::isReEntrant ( ) const
inlinefinaloverrideprotectedvirtualinherited

Legacy algorithms are not thread-safe.

Definition at line 47 of file AthAlgorithm.h.

47{ return false; }

◆ msg()

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

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

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

Definition at line 30 of file AthCommonMsg.h.

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

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::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.

◆ 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< Gaudi::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< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Set filter decision:

Reimplemented in AthFilterAlgorithm.

Definition at line 99 of file AthCommonAlgorithm.h.

99 {
101 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const
Set filter decision:

◆ sysExecute()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Reimplemented in AthAnalysisAlgorithm.

Definition at line 80 of file AthCommonAlgorithm.cxx.

41{
42 return BaseAlg::sysExecute (ctx);
43}

◆ sysInitialize()

StatusCode AthCommonAlgorithm< Gaudi::Algorithm >::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< Gaudi::Algorithm > >.

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

Definition at line 60 of file AthCommonAlgorithm.cxx.

71 {
73
74 if (sc.isFailure()) {
75 return sc;
76 }
77
78 ServiceHandle<ICondSvc> cs("CondSvc",name());
79 for (auto h : outputHandles()) {
80 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
81 // do this inside the loop so we don't create the CondSvc until needed
82 if ( cs.retrieve().isFailure() ) {
83 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
85 }
86 if (cs->regHandle(this,*h).isFailure()) {
88 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
89 << " with CondSvc");
90 }
91 }
92 }
93 return sc;
94}
#define ATH_MSG_WARNING(x)
virtual StatusCode sysInitialize() override
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::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< Gaudi::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 }

Member Data Documentation

◆ m_add_cL

bool TrackRecordGenerator::m_add_cL
private

For stopped particles, add c*L to the time.

Definition at line 52 of file TrackRecordGenerator.h.

◆ m_center

CLHEP::Hep3Vector TrackRecordGenerator::m_center
private

Definition at line 43 of file TrackRecordGenerator.h.

◆ m_detStore

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

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_events

int TrackRecordGenerator::m_events
private

Definition at line 39 of file TrackRecordGenerator.h.

◆ m_evtStore

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

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 108 of file AthCommonAlgorithm.h.

◆ m_fourMom

std::vector<CLHEP::HepLorentzVector> TrackRecordGenerator::m_fourMom
private

Definition at line 42 of file TrackRecordGenerator.h.

◆ m_fourPos

std::vector<CLHEP::HepLorentzVector> TrackRecordGenerator::m_fourPos
private

Definition at line 41 of file TrackRecordGenerator.h.

◆ m_gendata

std::shared_ptr<GenData> TrackRecordGenerator::m_gendata {nullptr}
private

Definition at line 53 of file TrackRecordGenerator.h.

53{nullptr};

◆ m_incidentSvc

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

Handle on the incident service.

Definition at line 99 of file GenModule.h.

99{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 110 of file GenBase.h.

110{};

◆ 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 119 of file GenBase.h.

119{ 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 112 of file GenBase.h.

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

◆ m_pdgCode

std::vector<int> TrackRecordGenerator::m_pdgCode
private

Definition at line 40 of file TrackRecordGenerator.h.

◆ m_polarization

std::vector<HepMC::Polarization> TrackRecordGenerator::m_polarization
private

Definition at line 44 of file TrackRecordGenerator.h.

◆ 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_recordName

std::string TrackRecordGenerator::m_recordName
private

TrackRecord collection name.

Definition at line 49 of file TrackRecordGenerator.h.

◆ m_rndmSvc

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

Data members.

Definition at line 97 of file GenModule.h.

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

◆ m_runinfo

std::shared_ptr<HepMC3::GenRunInfo> GenModule::m_runinfo {}
protectedinherited

The run info for HepMC3.

Definition at line 90 of file GenModule.h.

90{};

◆ m_smearTR

double TrackRecordGenerator::m_smearTR
private

Amount by which to smear TR position.

Definition at line 47 of file TrackRecordGenerator.h.

◆ m_smearTRp

double TrackRecordGenerator::m_smearTRp
private

Amount by which to smear TR momentum.

Definition at line 48 of file TrackRecordGenerator.h.

◆ m_stopParticles

bool TrackRecordGenerator::m_stopParticles
private

Stop particles before simulation.

Definition at line 50 of file TrackRecordGenerator.h.

◆ m_stopped_tminus

float TrackRecordGenerator::m_stopped_tminus
private

Definition at line 51 of file TrackRecordGenerator.h.

◆ m_stopped_tplus

float TrackRecordGenerator::m_stopped_tplus
private

Bounds for random time.

Definition at line 51 of file TrackRecordGenerator.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.


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