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

#include <ParticleDecayer.h>

Inheritance diagram for ParticleDecayer:
Collaboration diagram for ParticleDecayer:

Public Member Functions

 ParticleDecayer (const std::string &name, ISvcLocator *pSvcLocator)
 ~ParticleDecayer ()=default
StatusCode genInitialize ()
 For initializing the generator, if required.
StatusCode fillEvt (HepMC::GenEvent *)
 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 genuserInitialize ()
 For initialization of user code, if required. Called after genInitialize.
virtual StatusCode callGenerator ()
 For calling the generator on each iteration of the event loop.
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).
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

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

double getParticleMass (int pdgID)
void addParticle (HepMC::GenVertexPtr, int pdg, HepMC::FourVector, int statusCode)
double rnd_ExpLifetime (CLHEP::HepRandomEngine *engine, double ct)
double rnd_DoubleRange (CLHEP::HepRandomEngine *engine, double a, double b)
double cosgen (CLHEP::HepRandomEngine *engine, int itype)
StatusCode DFTwoBodyDecay (CLHEP::HepRandomEngine *engine, HepMC::GenParticlePtr, int)
StatusCode setDecayPosition (CLHEP::HepRandomEngine *engine, HepMC::GenParticlePtr, HepMC::GenEvent *, bool doScalarDecay=false)
StatusCode changeMass (HepMC::GenParticlePtr, double)
StatusCode getDecayProducts (CLHEP::HepRandomEngine *engine, CLHEP::HepLorentzVector, double, std::vector< CLHEP::HepLorentzVector > &, int decayType=0)
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

std::string m_truthParticleContainerName
int m_LJType {}
int m_scalarPDGID {}
double m_scalarMass {}
double m_particleMass {}
int m_particleID {}
double m_particleLifeTime {}
int m_particlePDGID {}
int m_particlePolarization {}
bool m_oppositePolarization {}
double m_BRElectron {}
double m_BRMuon {}
double m_BRPion {}
bool m_doUniformDecay {}
bool m_doExponentialDecay {}
bool m_expDecayDoVariableLifetime {}
double m_expDecayFractionToKeep {}
bool m_expDecayDoTruncateLongDecays {}
bool m_decayOnlyStable {}
double m_barrelRadius
double m_endCapDistance
double m_thetaEndCapBarrel
HepPDT::ParticleDataTable * m_particleTable {}
CLHEP::HepLorentzVector m_boostLV
CLHEP::HepLorentzVector m_posLV
CLHEP::HepLorentzVector m_posLV1
CLHEP::HepLorentzVector m_posLV2
int m_eventCounter {}
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

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

Definition at line 26 of file ParticleDecayer.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

◆ ParticleDecayer()

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

Definition at line 223 of file ParticleDecayer.cxx.

223 :
224 GenModule(name, pSvcLocator),
225 m_truthParticleContainerName("GEN_EVENT"),
227{
228 declareProperty("McEventCollection", m_truthParticleContainerName);
229 declareProperty("LJType", m_LJType = 1); //1 = one dark photon per LeptonJet, 2 = two dark photons per LeptonJet
230 declareProperty("ScalarPDGID", m_scalarPDGID); //new PDG ID of the scalar
231 declareProperty("ScalarMass", m_scalarMass); //new mass of the scalar in MeV
232 declareProperty("ParticleID", m_particleID = 999); //PDG ID of the geantino
233 declareProperty("ParticleMass", m_particleMass = 400); //new mass of the dark photon in MeV (default 400 MeV)
234 declareProperty("ParticleLifeTime", m_particleLifeTime = 0); //ctau of the dark photon in mm (default prompt)
235 declareProperty("ParticlePolarization", m_particlePolarization = 0); //polarization of the dark photon (default 0 : isotropic decay, -1 : transverse, 1 : longitudinal)
236 declareProperty("OppositePolarization", m_oppositePolarization = false);//In case of LJType == 2 and opposite polarization for the two dark photons in the event
237 declareProperty("ParticlePDGID", m_particlePDGID = 700022); //new PDG ID of the dark photon (default 700022)
238 declareProperty("DecayOnlyStable", m_decayOnlyStable = false);
239 declareProperty("DecayBRElectrons", m_BRElectron = 1.); //BR of dark photon decay to electrons
240 declareProperty("DecayBRMuons", m_BRMuon = 0.); //BR of dark photon decay to muons
241 declareProperty("DecayBRPions", m_BRPion = 0.); //BR of dark photon decay to pions
242
243 //Choose between the different types of displaced decays
244 declareProperty("DoUniformDecay", m_doUniformDecay = false);
245 declareProperty("DoExponentialDecay", m_doExponentialDecay = true );
246 declareProperty("ExpDecayDoVariableLifetime", m_expDecayDoVariableLifetime = false );
247 declareProperty("ExpDecayPercentageToKeep", m_expDecayFractionToKeep = 0.8 );
248 declareProperty("ExpDecayDoTruncateLongDecays", m_expDecayDoTruncateLongDecays = false );
249
250 //Dimensions within which to decay in case of non-prompt events
251 declareProperty("BarrelRadius", m_barrelRadius = 10.e3 ); // outer limit for decay radius
252 declareProperty("EndCapDistance", m_endCapDistance = 15.e3 ); // outer limit along z for decays in endcap
253 declareProperty("ThetaEndCapBarrel", m_thetaEndCapBarrel = 0.439067982); // theta if where to switch between barrel and endcap (default: eta = 1.5)
254}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
GenModule(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenModule.cxx:14
bool m_expDecayDoVariableLifetime
std::string m_truthParticleContainerName
double m_expDecayFractionToKeep
bool m_expDecayDoTruncateLongDecays

◆ ~ParticleDecayer()

ParticleDecayer::~ParticleDecayer ( )
default

Member Function Documentation

◆ addParticle()

void ParticleDecayer::addParticle ( HepMC::GenVertexPtr prod_vtx,
int pdg,
HepMC::FourVector momentum,
int statusCode )
private

Definition at line 452 of file ParticleDecayer.cxx.

452 {
453
454 double mass = 0.;
455 if( pdg == m_particlePDGID)
456 {
458 }else
459 {
460 mass = getParticleMass(pdg);
461 }
462 double energy=std::sqrt(std::pow(momentum.x(),2)+std::pow(momentum.y(),2)+std::pow(momentum.z(),2)+mass*mass);
464 pdg, statusCode);
465
466 prod_vtx->add_particle_out(std::move(aParticle));
467}
double getParticleMass(int pdgID)
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

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

◆ callGenerator()

virtual StatusCode GenModule::callGenerator ( )
inlinevirtualinherited

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

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

Definition at line 66 of file GenModule.h.

66{ return StatusCode::SUCCESS; }

◆ changeMass()

StatusCode ParticleDecayer::changeMass ( HepMC::GenParticlePtr genpart,
double newMass )
private

Definition at line 94 of file ParticleDecayer.cxx.

95{
96 double e = genpart->momentum().e();
97 double theta = genpart->momentum().theta();
98 double phi = genpart->momentum().phi();
99 //Sanity check
100 double p2 = e*e - newMass*newMass;
101 if ( p2 < 0 ) {
102 ATH_MSG_FATAL("ParticleDecayer::fillEvt: -- you have generated a tachyon!");
103 return StatusCode::FAILURE;
104 }
105 //At this point, we have e, theta, and phi. Put them together to get the four-momentum.
106 double p = std::sqrt(p2);
107 double px = p*std::sin(theta)*std::cos(phi);
108 double py = p*std::sin(theta)*std::sin(phi);
109 double pz = p*std::cos(theta);
110 //Fill the four-momentum
111 const CLHEP::HepLorentzVector updatedLV(px,py,pz,e);
112 genpart->set_momentum(HepMC::FourVector(updatedLV.x(),updatedLV.y(),updatedLV.z(),updatedLV.e()));
113 genpart->set_generated_mass(newMass);
114 return StatusCode::SUCCESS;
115}
Scalar phi() const
phi method
Scalar theta() const
theta method
#define ATH_MSG_FATAL(x)
tuple genpart
Check that the actual generators, tune, and main PDF are consistent with the JO name.

◆ cosgen()

double ParticleDecayer::cosgen ( CLHEP::HepRandomEngine * engine,
int itype )
private

Definition at line 47 of file ParticleDecayer.cxx.

47 {
48 double x,fx,hit;
49 x=0;
50
51 if(itype==0){ // flat
52 x=rnd_DoubleRange(engine,-1.,1.);
53 return x;
54 }
55
56 if(itype==1){ // f(cost)=1.5*cost^2
57 hit=1.5;
58 fx=0;
59 while(hit>fx){
60 x=rnd_DoubleRange(engine,-1.,1.);
61 hit=rnd_DoubleRange(engine,0.,1.5);
62 fx=1.5*x*x;
63 }
64 return x;
65 }
66
67 if(itype==2){ // f(cost)=0.375(1+cost^2)
68 hit=0.75;
69 fx=0;
70 while(hit>fx){
71 x=rnd_DoubleRange(engine,-1.,1.);
72 hit=rnd_DoubleRange(engine,0.,0.75);
73 fx=0.375*(1+x*x);
74 }
75 return x;
76 }
77
78 if(itype==3){ // f(cost)=0.75(1-cost^2)
79 hit=1.5;
80 fx=0;
81 while(hit>fx){
82 x=rnd_DoubleRange(engine,-1.,1.);
83 hit=rnd_DoubleRange(engine,0.,1.5);
84 fx=0.75*(1-x*x);
85 }
86 return x;
87 }
88
89 return x;
90
91}
#define x
double rnd_DoubleRange(CLHEP::HepRandomEngine *engine, double a, double b)

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

◆ DFTwoBodyDecay()

StatusCode ParticleDecayer::DFTwoBodyDecay ( CLHEP::HepRandomEngine * engine,
HepMC::GenParticlePtr genpart,
int Polarization )
private

Definition at line 482 of file ParticleDecayer.cxx.

482 {
483
484
485 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- allow the two-body decay of the dark photon...");
486
487 //create heplorentzvector from genpart's fourMomentum, as it is more useful
488 CLHEP::HepLorentzVector boostDF( genpart->momentum().px(), genpart->momentum().py(), genpart->momentum().pz(), genpart->momentum().e() );
489
490 //Given branching fractions, pick decay mode
491 int ModeOfDecay;
492 double unif = rnd_DoubleRange(engine, 0.,1.);
493 if (unif<=m_BRElectron) {
494 ModeOfDecay = 11;
495 } else if (unif<=(m_BRElectron+m_BRMuon) && unif>m_BRElectron) {
496 ModeOfDecay = 13;
497 } else {
498 ModeOfDecay = 211;
499 }
500 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- decayMode = " << ModeOfDecay);
501
502 //Now that we have a decay mode. get the associated particle mass
503 double decayPartMass = getParticleMass(ModeOfDecay);
504
505 //Choose how to decay
506 //angular distribution handling, see pag.6 of http://arxiv.org/pdf/hep-ph/0605296v2.pdf
507 int type = 0; //isotropic by default
508 if(Polarization==0) {
509 type = 0; //isotropic
510 } else if(Polarization==-1 && (ModeOfDecay==11 || ModeOfDecay==13)) {
511 type = 2; //transverse polarization of the dark photon + fermions
512 } else if(Polarization==1 && (ModeOfDecay==11 || ModeOfDecay==13)) {
513 type = 3; //longitudinal polarization of the dark photon + fermions
514 } else if(Polarization==-1 && ModeOfDecay==211) {
515 type = 3; //transverse polarization of the dark photon + scalars
516 } else if(Polarization==1 && ModeOfDecay==211) {
517 type = 1; //longitudinal polarization of the dark photon + scalars
518 } else {
519 ATH_MSG_FATAL("ParticleDecayer::fillEvt: -- wrong polarization value... please check!");
520 return StatusCode::FAILURE;
521 }
522
523 //Now we are ready to decay the dark photon
524 std::vector<CLHEP::HepLorentzVector> daughterLVs;
525 CHECK( getDecayProducts( engine, boostDF, decayPartMass, daughterLVs, type) );
526
527 //Add the daughters to the pool file
528 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- Add the daughters to the pool file");
529 auto end_vtx = genpart->end_vertex();
530 auto v0=daughterLVs.at(0).vect();
531 addParticle(end_vtx, ModeOfDecay, HepMC::FourVector(v0.x(),v0.y(),v0.z(),0.0), 1);
532 auto v1=daughterLVs.at(1).vect();
533 addParticle(std::move(end_vtx), -ModeOfDecay, HepMC::FourVector(v1.x(),v1.y(),v1.z(),0.0), 1);
534
535 return StatusCode::SUCCESS;
536}
#define ATH_MSG_DEBUG(x)
#define CHECK(...)
Evaluate an expression and check for errors.
StatusCode getDecayProducts(CLHEP::HepRandomEngine *engine, CLHEP::HepLorentzVector, double, std::vector< CLHEP::HepLorentzVector > &, int decayType=0)
void addParticle(HepMC::GenVertexPtr, int pdg, HepMC::FourVector, int statusCode)

◆ event_const()

const HepMC::GenEvent * GenBase::event_const ( const EventContext & ctx) const
inlineinherited

Access the current signal event (const).

Definition at line 83 of file GenBase.h.

83 {
84 const McEventCollection* coll = events_const(ctx);
85 if (coll->empty())
86 ATH_MSG_ERROR("Const McEventCollection is empty during first event access");
87 return *(coll->begin());
88 }
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:97

◆ events_const()

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

Access the current event's McEventCollection (const).

Definition at line 97 of file GenBase.h.

97 {
98 SG::ReadHandle<McEventCollection> ret = SG::makeHandle(m_mcevents_const, ctx);
99 if (!ret.isValid())
100 ATH_MSG_ERROR("No McEventCollection found in StoreGate with key " << m_mcevents_const.key());
101 return ret.cptr();
102 }
SG::ReadHandleKey< McEventCollection > m_mcevents_const
Const handle to the MC event collection.
Definition GenBase.h:145
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 ParticleDecayer::fillEvt ( HepMC::GenEvent * evt)
virtual

For filling the HepMC event object.

*** Now allow the two-body decay of the particle

*** Now allow the two-body decay of the scalar

Implements GenModule.

Definition at line 291 of file ParticleDecayer.cxx.

291 {
292
293 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- EventCounter: " << m_eventCounter);
294
295 const EventContext& ctx = Gaudi::Hive::currentContext();
296 CLHEP::HepRandomEngine* engine = this->getRandomEngine("ParticleDecayer", ctx);
297
298 StatusCode status = StatusCode::SUCCESS;
299
300 // Extract the event from the TES
301 McEventCollection* mcEvtColl = nullptr;
303 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- Found an McEventCollection for ParticleDecayer");
304 } else {
305 ATH_MSG_FATAL("TES is empty!!!!");
306 status = StatusCode::FAILURE;
307 return status;
308 }
309
310 event = mcEvtColl->back();
311
312 if (event == NULL) {
313 ATH_MSG_FATAL("ParticleDecayer::fillEvt: -- McEvent was not successfully created");
314 status = StatusCode::FAILURE;
315 return status;
316 }
317
318 for ( auto genpart : *event) {
319
320 const bool hasRightPDG = (genpart->pdg_id() == m_particleID);
321 const bool isStable = (genpart->status() == 1);
322 const bool hasEndVtx = (genpart->end_vertex() != nullptr);
323
324 if (!hasRightPDG) {
325 continue;
326 }
327
328 if (m_decayOnlyStable) {
329 if (!isStable || hasEndVtx) {
330 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- skip particle with PDG ID = "
331 << genpart->pdg_id()
332 << " status = " << genpart->status()
333 << " end_vertex = " << (hasEndVtx ? "yes" : "no"));
334 continue;
335 }
336 }
337
339 // only one dark photon per LeptonJet //
341 if (m_LJType == 1) {
342 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- only one dark photon per LeptonJet");
343 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- found MC particle with PDG ID = " << genpart->pdg_id());
344 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- assign the new mass of the dark photon, m = " << m_particleMass);
345
346 //Change the mass of the parent particle ( set by user input + command )
347 //Changes the magnitude of the spatial part of the 4-momentum such that the new 4-momentum has the desired inv mass
348 CHECK( changeMass( genpart, m_particleMass ) );
349
350 //Add decay position to the event
351 CHECK( setDecayPosition( engine, genpart, event ) );
352
353 //assign the new PDG_ID of the particle
354 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- set the new PDG ID = " << m_particlePDGID);
355 genpart->set_pdg_id(m_particlePDGID);
356
357 //set the new status (decayed) of the particle
358 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- set the new status = 2");
359 genpart->set_status(2);
360
361 //set the new momentum of the particle
362 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- set the new momentum");
363
365 CHECK( DFTwoBodyDecay( engine, std::move(genpart), m_particlePolarization ) );
366
367 }else if (m_LJType == 2) {
369 // two dark photons per LeptonJet //
371
372 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- two dark photons per LeptonJet");
373 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- found MC particle with PDG ID = " << genpart->pdg_id());
374 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- assign the new mass of the dark scalar, m = " << m_scalarMass);
375
376 //Get the mass of the parent particle ( set by user input + command )
377 //Change the mass of the parent particle ( set by user input + command )
378 //Changes the magnitude of the spatial part of the 4-momentum such that the new 4-momentum has the desired inv mass
379 CHECK( changeMass( genpart, m_scalarMass ) );
380
381 //set the new PDG_ID of the scalar
382 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- set the new PDG ID = " << m_scalarPDGID);
383 genpart->set_pdg_id(m_scalarPDGID);
384
385 //set the new status (decayed) of the scalar
386 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- set the new status = 2");
387 genpart->set_status(2);
388
389 //set the decay vertex position of the scalar
390 //Create a HepMC vertex at the decay position of the scalar
391 CHECK( setDecayPosition( engine, genpart, event, true ) );
392
394 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- allow the two-body decay of the dark scalar to dark photons...");
395 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- dark photon has PDG ID = " << m_particlePDGID);
396
397 std::vector<CLHEP::HepLorentzVector> darkPhotonLVs;
398 CHECK( getDecayProducts( engine, CLHEP::HepLorentzVector( genpart->momentum().px(), genpart->momentum().py(), genpart->momentum().pz(), genpart->momentum().e() ),
400 darkPhotonLVs) );
401
402 //add dark photon 1
403 auto v0=darkPhotonLVs.at(0).vect();
404 addParticle( genpart->end_vertex(), m_particlePDGID, HepMC::FourVector(v0.x(),v0.y(),v0.z(),0.0) , 2);
405 //add dark photon 2
406 auto v1=darkPhotonLVs.at(1).vect();
407 addParticle( genpart->end_vertex(), m_particlePDGID, HepMC::FourVector(v1.x(),v1.y(),v1.z(),0.0), 2);
408
409 //lifetime handling of the dark photons
410 int polarizationSwitch = 1;
411 const std::vector<HepMC::GenParticlePtr>& particlesOut = genpart->end_vertex()->particles_out();
412 std::vector<HepMC::GenParticlePtr>::const_iterator pItBegin = particlesOut.begin();
413 std::vector<HepMC::GenParticlePtr>::const_iterator pItEnd = particlesOut.end();
414 for ( auto pIt=pItBegin ; pIt != pItEnd; ++pIt )
415 {
416
417 //Add decay position to the event
418 CHECK( setDecayPosition( engine, *pIt, event ) );
419 //And perform two-body decay
420 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- Now allow the two-body decay of the dark photons");
421 CHECK( DFTwoBodyDecay( engine, *pIt, polarizationSwitch*m_particlePolarization ) );
423 {
424 polarizationSwitch = -polarizationSwitch;
425 }
426 }
427
428 }else
429 {
430 ATH_MSG_FATAL("LJType set to " << m_LJType );
431 ATH_MSG_FATAL("LJType must be 1 or 2" );
432 return StatusCode::FAILURE;
433 }
434 }
435
436 //set the event number
437 event->set_event_number(m_eventCounter);
438
439 //Add a unit entry to the event weight vector if it's currently empty
440 if (event->weights().empty()) {
441 event->weights().push_back(1.);
442 }
443
444 //increment the event counter
446
447 return status;
448}
ServiceHandle< StoreGateSvc > & evtStore()
const T * back() const
Access the last element in the collection as an rvalue.
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition GenModule.cxx:34
StatusCode changeMass(HepMC::GenParticlePtr, double)
StatusCode DFTwoBodyDecay(CLHEP::HepRandomEngine *engine, HepMC::GenParticlePtr, int)
StatusCode setDecayPosition(CLHEP::HepRandomEngine *engine, HepMC::GenParticlePtr, HepMC::GenEvent *, bool doScalarDecay=false)
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:116
::StatusCode StatusCode
StatusCode definition for legacy code.
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
status
Definition merge.py:16

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

StatusCode ParticleDecayer::genInitialize ( )
virtual

For initializing the generator, if required.

Reimplemented from GenModule.

Definition at line 258 of file ParticleDecayer.cxx.

259{
260 // Check here if the tool has been configured correctly
262 {
263 ATH_MSG_FATAL("Cannot configure exponential and uniform decay at the same time.");
264 return StatusCode::FAILURE;
265 }
266
267 double TOTBR = m_BRElectron + m_BRMuon + m_BRPion;
268 if (TOTBR>1.0000001) {
269 ATH_MSG_FATAL("ParticleDecayer::genInitialize: -- Branching Ratio sum is larger than 1!! Please check the values in your jobOption.");
270 ATH_MSG_FATAL("ParticleDecayer::genInitialize: -- Branching Ratio Electrons " << m_BRElectron);
271 ATH_MSG_FATAL("ParticleDecayer::genInitialize: -- Branching Ratio Muons " << m_BRMuon);
272 ATH_MSG_FATAL("ParticleDecayer::genInitialize: -- Branching Ratio Pions " << m_BRPion);
273 ATH_MSG_FATAL("ParticleDecayer::genInitialize: -- Total Branching Ratio " << TOTBR);
274 return StatusCode::FAILURE;
275 }
276
277 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- daughters randomly produced: " << m_BRElectron << "% e, " << m_BRMuon << "% mu, " << m_BRPion << "% pi");
278
279 if( m_LJType != 1 && m_LJType != 2 )
280 {
281 ATH_MSG_FATAL("LJType is set to " << m_LJType);
282 ATH_MSG_FATAL("LJType has to be set to either 1 or 2");
283 return StatusCode::FAILURE;
284 }
285
286
287 return StatusCode::SUCCESS;
288}

◆ 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; }

◆ getDecayProducts()

StatusCode ParticleDecayer::getDecayProducts ( CLHEP::HepRandomEngine * engine,
CLHEP::HepLorentzVector parentLV,
double decayPartMass,
std::vector< CLHEP::HepLorentzVector > & daughterLVs,
int decayType = 0 )
private

Definition at line 539 of file ParticleDecayer.cxx.

543{
544 double parentMass = parentLV.m();
545 CLHEP::Hep3Vector boostVec = parentLV.boostVector();
546
547 if( decayPartMass > parentMass/2.)
548 {
549 ATH_MSG_FATAL("Decay particle has more than half the mass of parent.");
550 return StatusCode::FAILURE;
551 }
552 //Get the angles in the rest frame
553 double phi_rf = rnd_DoubleRange(engine, -M_PI, M_PI);
554 double ct_rf = cosgen(engine, decayType);
555 double theta_rf = std::acos(ct_rf);
556
557 //construct p1 particle momentum in rest-frame (_rf)
558 double p1_rf = std::sqrt(parentMass*parentMass/4. - decayPartMass*decayPartMass);
559 double px_rf = p1_rf*std::cos(phi_rf)*std::sin(theta_rf);
560 double py_rf = p1_rf*std::sin(phi_rf)*std::sin(theta_rf);
561 double pz_rf = p1_rf*ct_rf;
562 CLHEP::HepLorentzVector hlv1( px_rf, py_rf, pz_rf, parentMass/2.);
563 CLHEP::HepLorentzVector hlv2( -px_rf, -py_rf, -pz_rf, parentMass/2.);
564
565 //Transform from the rotated frame to the (x,y,z) frame.
566 hlv1.rotateUz((parentLV.vect()).unit());
567 hlv2.rotateUz((parentLV.vect()).unit());
568
569 //Now boost back to the lab-frame
570 hlv1.boost(boostVec);
571 hlv2.boost(boostVec);
572
573 daughterLVs.push_back(hlv1);
574 daughterLVs.push_back(hlv2);
575
576 return StatusCode::SUCCESS;
577}
#define M_PI
double cosgen(CLHEP::HepRandomEngine *engine, int itype)

◆ getParticleMass()

double ParticleDecayer::getParticleMass ( int pdgID)
private

Definition at line 471 of file ParticleDecayer.cxx.

471 {
472 SmartIF<IPartPropSvc> partPropSvc(Gaudi::svcLocator()->service("PartPropSvc"));
473 if (!partPropSvc) throw GaudiException("PartPropSvc error", "I_ParticleDecayer", StatusCode::FAILURE);
475
476 const HepPDT::ParticleData* particle = m_particleTable->particle(HepPDT::ParticleID(std::abs(pid)));
477 return particle->mass().value();
478}
const ServiceHandle< IPartPropSvc > partPropSvc() const
Access the particle property service.
Definition GenBase.h:111
HepPDT::ParticleDataTable * m_particleTable
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses

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

◆ particleData()

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

Access an element in the particle data table.

Definition at line 124 of file GenBase.h.

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

◆ particleTable()

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

Get a particle data table.

Definition at line 116 of file GenBase.h.

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

◆ partPropSvc()

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

Access the particle property service.

Definition at line 111 of file GenBase.h.

111 {
112 return m_ppSvc;
113 }

◆ pdt()

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

Shorter alias to get a particle data table.

Definition at line 121 of file GenBase.h.

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

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

◆ rnd_DoubleRange()

double ParticleDecayer::rnd_DoubleRange ( CLHEP::HepRandomEngine * engine,
double a,
double b )
private

Definition at line 39 of file ParticleDecayer.cxx.

39 {
40 double r = engine->flat(); //< Return random num in [0,1]
41 return a + r*(b-a);
42}
static Double_t a
int r
Definition globals.cxx:22

◆ rnd_ExpLifetime()

double ParticleDecayer::rnd_ExpLifetime ( CLHEP::HepRandomEngine * engine,
double ct )
private

Definition at line 32 of file ParticleDecayer.cxx.

32 {
33 double r = engine->flat(); //< Return random num in [0,1]
34 return ((-ct)*std::log(1.-r));
35}

◆ setDecayPosition()

StatusCode ParticleDecayer::setDecayPosition ( CLHEP::HepRandomEngine * engine,
HepMC::GenParticlePtr genpart,
HepMC::GenEvent * event,
bool doScalarDecay = false )
private

Definition at line 118 of file ParticleDecayer.cxx.

119{
120 HepMC::GenVertexPtr vtxp = genpart->production_vertex();
121 if(!vtxp) {
122 ATH_MSG_FATAL("ParticleDecayer::fillEvt: -- no production vertex position found!");
123 return StatusCode::FAILURE;
124 }
125 if ( doScalarDecay ) // scalar decay is prompt. decay vtx == scalar production vertex
126 {
128 end_vtx->set_position(vtxp->position());
129 end_vtx->add_particle_in(std::move(genpart));
130 event->add_vertex(std::move(end_vtx));
131 return StatusCode::SUCCESS;
132 }
133
134 //lifetime handling
135 double gamma = genpart->momentum().e()/genpart->momentum().m();
136 double ctau = 0.;
137 double theta = genpart->momentum().theta();
138
139 // Make sure theta is between 0 and pi
140 while( theta > M_PI )
141 {
142 theta -= M_PI;
143 }
144 while( theta < 0 )
145 {
146 theta += M_PI;
147 }
148
150 {
151 if(m_expDecayDoVariableLifetime) // Variable proper lifetime distribution, such that fixed fraction of events decays within detector, independent of boost
152 {
153 double distanceToEdge = -999.;
154 if ( theta < m_thetaEndCapBarrel || theta > ( M_PI - m_thetaEndCapBarrel) ) // Particle escapes through endcap
155 {
156 distanceToEdge = std::abs(m_endCapDistance/std::cos(theta));
157 }
158 else // Particle escapes through barrel
159 {
160 distanceToEdge = m_barrelRadius/std::sin(theta);
161 }
162 if ( gamma < 1. )
163 {
164 ATH_MSG_FATAL("Gamma factor cannot be smaller than 1" );
165 return StatusCode::FAILURE;
166 }
167 double Limit = distanceToEdge / gamma; // ctau is enhanced by factor gamma in lab frame
168 double lambda = -1.*Limit/std::log(1. - m_expDecayFractionToKeep);
169 ctau = rnd_ExpLifetime(engine,lambda);
171 {
172 while ( ctau > Limit ) // If decay is outside detector, let's sample again (Produces a truncated exponential)
173 {
174 ctau = rnd_ExpLifetime(engine, lambda);
175 }
176 }
177 }
178 else if( m_particleLifeTime > 0 ) // Fixed proper lifetime distribution. Note that if m_particleLifeTime <= 0. ctau remains 0
179 {
180 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- set lifetime of the dark photon according to ctau = " << m_particleLifeTime);
182 }
183 }else if (m_doUniformDecay)
184 {
185 double decayRadius = -999.;
186 if ( theta < m_thetaEndCapBarrel || theta > ( M_PI - m_thetaEndCapBarrel) ) // Particle escapes through endcap
187 {
188 double outerLength = std::abs(m_endCapDistance/std::cos(theta));
189 double outerRadius = outerLength*std::sin(theta);
190 decayRadius = rnd_DoubleRange(engine,0., std::min(outerRadius, std::abs(m_barrelRadius)) );
191 }else // Particle escapes through barrel
192 {
193 decayRadius = rnd_DoubleRange(engine,0., std::abs(m_barrelRadius));
194 }
195
196 double decayLength = decayRadius/std::sin(theta);
197 ctau = decayLength/gamma;
198 }else
199 {
200 ATH_MSG_FATAL("have to pick uniform or exponential decay distance");
201 return StatusCode::FAILURE;
202 }
203
204 double ctg = gamma * ctau;
205 double px = genpart->momentum().px();
206 double py = genpart->momentum().py();
207 double pz = genpart->momentum().pz();
208 double p = std::sqrt(px*px + py*py + pz*pz);
209
210 const CLHEP::HepLorentzVector posLV(((ctg*px/p)+(vtxp->position().x())), ((ctg*py/p)+(vtxp->position().y())), ((ctg*pz/p)+(vtxp->position().z())), ((ctg)+(vtxp->position().t())));
211
212 //set the decay vertex position of the particle
213 //Create a HepMC vertex at the decay position of the particle
214 ATH_MSG_DEBUG("ParticleDecayer::fillEvt: -- set the decay vertex");
216 end_vtx->set_position(HepMC::FourVector(posLV.x(),posLV.y(),posLV.z(),posLV.t()));
217 end_vtx->add_particle_in(std::move(genpart));
218 event->add_vertex(std::move(end_vtx));
219 return StatusCode::SUCCESS;
220}
double rnd_ExpLifetime(CLHEP::HepRandomEngine *engine, double ct)
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

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

double ParticleDecayer::m_barrelRadius
private

Definition at line 74 of file ParticleDecayer.h.

◆ m_boostLV

CLHEP::HepLorentzVector ParticleDecayer::m_boostLV
private

Definition at line 93 of file ParticleDecayer.h.

◆ m_BRElectron

double ParticleDecayer::m_BRElectron {}
private

Definition at line 61 of file ParticleDecayer.h.

61{};

◆ m_BRMuon

double ParticleDecayer::m_BRMuon {}
private

Definition at line 63 of file ParticleDecayer.h.

63{};

◆ m_BRPion

double ParticleDecayer::m_BRPion {}
private

Definition at line 65 of file ParticleDecayer.h.

65{};

◆ m_decayOnlyStable

bool ParticleDecayer::m_decayOnlyStable {}
private

Definition at line 72 of file ParticleDecayer.h.

72{};

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

bool ParticleDecayer::m_doExponentialDecay {}
private

Definition at line 68 of file ParticleDecayer.h.

68{};

◆ m_doUniformDecay

bool ParticleDecayer::m_doUniformDecay {}
private

Definition at line 67 of file ParticleDecayer.h.

67{};

◆ m_endCapDistance

double ParticleDecayer::m_endCapDistance
private

Definition at line 75 of file ParticleDecayer.h.

◆ m_eventCounter

int ParticleDecayer::m_eventCounter {}
private

Definition at line 101 of file ParticleDecayer.h.

101{};

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

bool ParticleDecayer::m_expDecayDoTruncateLongDecays {}
private

Definition at line 71 of file ParticleDecayer.h.

71{};

◆ m_expDecayDoVariableLifetime

bool ParticleDecayer::m_expDecayDoVariableLifetime {}
private

Definition at line 69 of file ParticleDecayer.h.

69{};

◆ m_expDecayFractionToKeep

double ParticleDecayer::m_expDecayFractionToKeep {}
private

Definition at line 70 of file ParticleDecayer.h.

70{};

◆ 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_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_LJType

int ParticleDecayer::m_LJType {}
private

Definition at line 42 of file ParticleDecayer.h.

42{};

◆ m_mcEventKey

std::string GenBase::m_mcEventKey {}
protectedinherited

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

Definition at line 134 of file GenBase.h.

134{};

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

145{ 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 136 of file GenBase.h.

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

◆ m_oppositePolarization

bool ParticleDecayer::m_oppositePolarization {}
private

Definition at line 58 of file ParticleDecayer.h.

58{};

◆ m_particleID

int ParticleDecayer::m_particleID {}
private

Definition at line 50 of file ParticleDecayer.h.

50{};

◆ m_particleLifeTime

double ParticleDecayer::m_particleLifeTime {}
private

Definition at line 52 of file ParticleDecayer.h.

52{};

◆ m_particleMass

double ParticleDecayer::m_particleMass {}
private

Definition at line 48 of file ParticleDecayer.h.

48{};

◆ m_particlePDGID

int ParticleDecayer::m_particlePDGID {}
private

Definition at line 54 of file ParticleDecayer.h.

54{};

◆ m_particlePolarization

int ParticleDecayer::m_particlePolarization {}
private

Definition at line 56 of file ParticleDecayer.h.

56{};

◆ m_particleTable

HepPDT::ParticleDataTable* ParticleDecayer::m_particleTable {}
private

Definition at line 78 of file ParticleDecayer.h.

78{};

◆ m_posLV

CLHEP::HepLorentzVector ParticleDecayer::m_posLV
private

Definition at line 95 of file ParticleDecayer.h.

◆ m_posLV1

CLHEP::HepLorentzVector ParticleDecayer::m_posLV1
private

Definition at line 97 of file ParticleDecayer.h.

◆ m_posLV2

CLHEP::HepLorentzVector ParticleDecayer::m_posLV2
private

Definition at line 99 of file ParticleDecayer.h.

◆ m_ppSvc

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

Handle on the particle property service.

Definition at line 142 of file GenBase.h.

142{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 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_scalarMass

double ParticleDecayer::m_scalarMass {}
private

Definition at line 46 of file ParticleDecayer.h.

46{};

◆ m_scalarPDGID

int ParticleDecayer::m_scalarPDGID {}
private

Definition at line 44 of file ParticleDecayer.h.

44{};

◆ m_thetaEndCapBarrel

double ParticleDecayer::m_thetaEndCapBarrel
private

Definition at line 76 of file ParticleDecayer.h.

◆ m_truthParticleContainerName

std::string ParticleDecayer::m_truthParticleContainerName
private

Definition at line 40 of file ParticleDecayer.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: