ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Generators
EvgenProdTools
src
SimTimeEstimate.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#ifndef XAOD_ANALYSIS
6
#include "
EvgenProdTools/SimTimeEstimate.h
"
7
#include "
AtlasHepMC/GenEvent.h
"
8
#include "
TruthUtils/HepMCHelpers.h
"
9
10
SimTimeEstimate::SimTimeEstimate
(
const
std::string& name, ISvcLocator* pSvcLocator)
11
:
GenBase
(name, pSvcLocator)
12
{
13
}
14
15
StatusCode
SimTimeEstimate::execute
(
const
EventContext& ctx)
16
{
17
// Loop over all events in McEventCollection
19
for
(
const
auto
itr : *(
events_const
(ctx)))
20
{
21
m_eventEnergy
= 0.;
22
m_particleNumber
= 0.;
23
m_particleIDs
.clear();
24
m_particleEtas
.clear();
25
m_particleEnergies
.clear();
26
// Check particles
27
for
(
const
auto
& part: *itr)
28
{
29
// Only use stable particles
30
if
(!
MC::isStable
(part))
continue
;
31
// Only use particles that are interacting
32
if
(!(
MC::isSimInteracting
(part)))
continue
;
33
// Grab the momentum
34
const
HepMC::FourVector
pmom = part->momentum();
35
// Only count particles with finite eta
36
if
(pmom.perp()==0 || std::abs(pmom.eta())>
m_etaMax
)
continue
;
37
m_particleEtas
.push_back(pmom.eta());
38
// add ID of particle to list
39
m_particleIDs
.push_back(std::abs(part->pdg_id()));
40
// add energy per particle to get the distribution:
41
m_particleEnergies
.push_back(pmom.e());
42
43
// Skip muons and neutrinos. This should eventually be using a common
44
// "is MIP-like" function, but that's a bit tricky as for
45
// example sometimes a chargino is stable and sometimes
46
// it decays. This algorithm will always be a little tricky
47
// in those cases, but better to *overestimate* the sim time.
48
49
if
(std::find(
m_pidsToSkip
.begin(),
m_pidsToSkip
.end(), std::abs(part->pdg_id())) !=
m_pidsToSkip
.end())
continue
;
50
// Add in the total energy
51
m_total_Energy
+= pmom.e();
52
m_eventEnergy
+= pmom.e();
53
m_particleNumber
++;
54
}
// Loop over particles in the event
55
56
//Report characterisitics of each event
57
ATH_MSG_VERBOSE
(
"==> EVENT INFORMATION | event number: "
<<
m_total_Events
<<
"| event energy: "
<<
m_eventEnergy
);
// << " | m_particleNumber: " << m_particleNumber << " | m_particleIDs: " << m_particleIDs << " | etas: " << m_particleEtas << " | energies: " << m_particleEnergies);
58
}
// Loop over events in the event collection
59
// One more event done!
60
m_total_Events
++;
61
return
StatusCode::SUCCESS;
62
}
63
64
StatusCode
SimTimeEstimate::finalize
()
65
{
66
// Reporting in!
67
ATH_MSG_INFO
(
"==> RUN INFORMATION | Processed "
<<
m_total_Events
<<
" events and found "
<<
m_total_Energy
<<
" of energy to be processed."
);
68
69
return
StatusCode::SUCCESS;
70
}
71
72
#endif
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:28
GenEvent.h
HepMCHelpers.h
ATLAS-specific HepMC functions.
SimTimeEstimate.h
GenBase::GenBase
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition
GenBase.cxx:11
GenBase::events_const
const McEventCollection * events_const(const EventContext &ctx) const
Access the current event's McEventCollection (const).
Definition
GenBase.h:93
SimTimeEstimate::m_etaMax
Gaudi::Property< double > m_etaMax
Definition
SimTimeEstimate.h:27
SimTimeEstimate::m_pidsToSkip
const std::array< int, 4 > m_pidsToSkip
Definition
SimTimeEstimate.h:36
SimTimeEstimate::m_particleEnergies
std::vector< double > m_particleEnergies
list holds energy of each particle
Definition
SimTimeEstimate.h:33
SimTimeEstimate::m_eventEnergy
double m_eventEnergy
Amount of energy that I've seen in one event.
Definition
SimTimeEstimate.h:31
SimTimeEstimate::m_particleNumber
int m_particleNumber
Number of particles in one event.
Definition
SimTimeEstimate.h:35
SimTimeEstimate::m_total_Energy
double m_total_Energy
Amount of energy that I've seen.
Definition
SimTimeEstimate.h:30
SimTimeEstimate::finalize
virtual StatusCode finalize() override
Definition
SimTimeEstimate.cxx:64
SimTimeEstimate::SimTimeEstimate
SimTimeEstimate(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SimTimeEstimate.cxx:10
SimTimeEstimate::m_total_Events
int m_total_Events
Number of events that I've seen.
Definition
SimTimeEstimate.h:29
SimTimeEstimate::m_particleIDs
std::vector< int > m_particleIDs
list holds all the particle IDs for one event
Definition
SimTimeEstimate.h:34
SimTimeEstimate::m_particleEtas
std::vector< double > m_particleEtas
list holds eta of each particle
Definition
SimTimeEstimate.h:32
SimTimeEstimate::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
SimTimeEstimate.cxx:15
HepMC::FourVector
HepMC3::FourVector FourVector
Definition
SimpleVector.h:11
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition
HepMCHelpers.h:46
MC::isSimInteracting
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....
Definition
HepMCHelpers.h:61
Generated on
for ATLAS Offline Software by
1.17.0