Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
7 #include "AtlasHepMC/GenEvent.h"
9 
10 SimTimeEstimate::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.;
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!
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
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
SimTimeEstimate::m_particleNumber
int m_particleNumber
Number of particles in one event.
Definition: SimTimeEstimate.h:35
GenEvent.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
SimTimeEstimate::m_particleIDs
std::vector< int > m_particleIDs
list holds all the particle IDs for one event
Definition: SimTimeEstimate.h:34
SimTimeEstimate::m_eventEnergy
double m_eventEnergy
Amount of energy that I've seen in one event.
Definition: SimTimeEstimate.h:31
SimTimeEstimate::m_particleEnergies
std::vector< double > m_particleEnergies
list holds energy of each particle
Definition: SimTimeEstimate.h:33
GenBase::events_const
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition: GenBase.h:96
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SimTimeEstimate.h
SimTimeEstimate::m_particleEtas
std::vector< double > m_particleEtas
list holds eta of each particle
Definition: SimTimeEstimate.h:32
GenBase
Base class for common behaviour of MC truth algorithms.
Definition: GenBase.h:47
SimTimeEstimate::m_pidsToSkip
const std::array< int, 4 > m_pidsToSkip
Definition: SimTimeEstimate.h:36
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MC::isStable
bool isStable(const T &p)
Identify if the particle is stable, i.e. has not decayed.
Definition: HepMCHelpers.h:45
SimTimeEstimate::m_etaMax
Gaudi::Property< double > m_etaMax
Definition: SimTimeEstimate.h:27
SimTimeEstimate::m_total_Energy
double m_total_Energy
Amount of energy that I've seen.
Definition: SimTimeEstimate.h:30
SimTimeEstimate::execute
virtual StatusCode execute() override
Definition: SimTimeEstimate.cxx:15
SimTimeEstimate::SimTimeEstimate
SimTimeEstimate(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SimTimeEstimate.cxx:10
MC::isSimInteracting
bool isSimInteracting(const T &p)
Identify if the particle could interact with the detector during the simulation, e....
Definition: HepMCHelpers.h:60
HepMCHelpers.h
SimTimeEstimate::m_total_Events
int m_total_Events
Number of events that I've seen.
Definition: SimTimeEstimate.h:29
SimTimeEstimate::finalize
virtual StatusCode finalize() override
Definition: SimTimeEstimate.cxx:64