ATLAS Offline Software
Loading...
Searching...
No Matches
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
9
10SimTimeEstimate::SimTimeEstimate(const std::string& name, ISvcLocator* pSvcLocator)
11 : GenBase(name, pSvcLocator)
12{
13}
14
16{
17 // Loop over all events in McEventCollection
19 for (const auto itr : *(events_const()))
20 {
21 m_eventEnergy = 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();
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!
61 return StatusCode::SUCCESS;
62}
63
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
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
ATLAS-specific HepMC functions.
GenBase(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Definition GenBase.cxx:11
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition GenBase.h:96
Gaudi::Property< double > m_etaMax
const std::array< int, 4 > m_pidsToSkip
std::vector< double > m_particleEnergies
list holds energy of each particle
double m_eventEnergy
Amount of energy that I've seen in one event.
virtual StatusCode execute() override
int m_particleNumber
Number of particles in one event.
double m_total_Energy
Amount of energy that I've seen.
virtual StatusCode finalize() override
SimTimeEstimate(const std::string &name, ISvcLocator *pSvcLocator)
int m_total_Events
Number of events that I've seen.
std::vector< int > m_particleIDs
list holds all the particle IDs for one event
std::vector< double > m_particleEtas
list holds eta of each particle
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....