ATLAS Offline Software
SimTimeEstimate.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 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  declareProperty( "EtaLimit", m_etaMax = 6.0 );
14  m_total_Events = 0;
15  m_total_Energy = 0.;
16  m_pidsToSkip = {12, 13, 14, 16};
17 }
18 
20 {
21  // Loop over all events in McEventCollection
23  for (const auto itr : *(events_const()))
24  {
25  m_eventEnergy = 0.;
26  m_particleNumber = 0.;
27  m_particleIDs.clear();
28  m_particleEtas.clear();
29  m_particleEnergies.clear();
30  // Check particles
31  for (const auto& part: *itr)
32  {
33  // Only use stable particles
34  if (!MC::isStable(part)) continue;
35  // Only use particles that are interacting
36  if (!(MC::isSimInteracting(part))) continue;
37  // Grab the momentum
38  const HepMC::FourVector pmom = part->momentum();
39  // Only count particles with finite eta
40  if (pmom.perp()==0 || std::abs(pmom.eta())>m_etaMax) continue;
41  m_particleEtas.push_back(pmom.eta());
42  // add ID of particle to list
43  m_particleIDs.push_back(std::abs(part->pdg_id()));
44  // add energy per particle to get the distribution:
45  m_particleEnergies.push_back(pmom.e());
46 
47  // Skip muons and neutrinos. This should eventually be using a common
48  // "is MIP-like" function, but that's a bit tricky as for
49  // example sometimes a chargino is stable and sometimes
50  // it decays. This algorithm will always be a little tricky
51  // in those cases, but better to *overestimate* the sim time.
52 
53  if(std::find(m_pidsToSkip.begin(), m_pidsToSkip.end(), std::abs(part->pdg_id())) != m_pidsToSkip.end()) continue;
54  // Add in the total energy
55  m_total_Energy += pmom.e();
56  m_eventEnergy += pmom.e();
57  m_particleNumber ++;
58  } // Loop over particles in the event
59 
60  //Report characterisitics of each event
61  ATH_MSG_INFO("==> 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);
62  } // Loop over events in the event collection
63  // One more event done!
65  return StatusCode::SUCCESS;
66 }
67 
69  {
70  // Reporting in!
71  ATH_MSG_INFO("==> RUN INFORMATION | Processed " << m_total_Events << " events and found " << m_total_Energy << " of energy to be processed.");
72 
73  return StatusCode::SUCCESS;
74 }
75 
76 #endif
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
SimTimeEstimate::m_particleNumber
int m_particleNumber
Number of particles in one event.
Definition: SimTimeEstimate.h:33
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:32
SimTimeEstimate::m_eventEnergy
double m_eventEnergy
Amount of energy that I've seen in one event.
Definition: SimTimeEstimate.h:29
SimTimeEstimate::m_particleEnergies
std::vector< double > m_particleEnergies
list holds energy of each particle
Definition: SimTimeEstimate.h:31
GenBase::events_const
const McEventCollection * events_const() const
Access the current event's McEventCollection (const)
Definition: GenBase.h:96
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
SimTimeEstimate::m_etaMax
double m_etaMax
Max eta that will be used for simulation.
Definition: SimTimeEstimate.h:26
SimTimeEstimate.h
SimTimeEstimate::m_particleEtas
std::vector< double > m_particleEtas
list holds eta of each particle
Definition: SimTimeEstimate.h:30
GenBase
Base class for common behaviour of MC truth algorithms.
Definition: GenBase.h:47
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SimTimeEstimate::execute
StatusCode execute()
Definition: SimTimeEstimate.cxx:19
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MC::isStable
bool isStable(const T &p)
Definition: HepMCHelpers.h:30
SimTimeEstimate::m_total_Energy
double m_total_Energy
Amount of energy that I've seen.
Definition: SimTimeEstimate.h:28
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:42
SimTimeEstimate::m_pidsToSkip
std::vector< int > m_pidsToSkip
Definition: SimTimeEstimate.h:34
SimTimeEstimate::finalize
StatusCode finalize()
Definition: SimTimeEstimate.cxx:68
HepMCHelpers.h
SimTimeEstimate::m_total_Events
int m_total_Events
Number of events that I've seen.
Definition: SimTimeEstimate.h:27