ATLAS Offline Software
LArG4FastSimSvc.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 // include header file
7 
8 // athena includes
9 #include "GaudiKernel/ServiceHandle.h"
10 
11 // CLHEP includes
12 #include "CLHEP/Units/SystemOfUnits.h"
13 #include "CLHEP/Units/PhysicalConstants.h"
14 
15 #include "AtlasHepMC/IO_GenEvent.h"
16 #include "AtlasHepMC/GenEvent.h"
17 
18 // default constructor
19 LArG4FastSimSvc::LArG4FastSimSvc(const std::string& name, ISvcLocator* sl)
20  : base_class(name,sl),
21  m_generated_starting_points_file(),
22  m_generate_starting_points(false),
23  m_starting_points_file(),
24  m_detector_tag(0)
25 {
26  declareProperty("EFlagToShowerLib", m_e_FlagShowerLib = true, "Switch for e+/- frozen showers");
27  declareProperty("EMinEneShowerLib", m_e_MinEneShowerLib = 0.0*CLHEP::GeV, "Minimum energy for e+/- frozen showers");
28  declareProperty("EMaxEneShowerLib", m_e_MaxEneShowerLib = 1.0*CLHEP::GeV, "Maximum energy for e+/- frozen showers");
29 
30  declareProperty("GFlagToShowerLib", m_g_FlagShowerLib = true, "Switch for photon frozen showers");
31  declareProperty("GMinEneShowerLib", m_g_MinEneShowerLib = 0.*CLHEP::GeV, "Minimum energy for photon frozen showers");
32  declareProperty("GMaxEneShowerLib", m_g_MaxEneShowerLib = 0.010*CLHEP::GeV, "Maximum energy for photon frozen showers");
33 
34  declareProperty("NeutFlagToShowerLib", m_Neut_FlagShowerLib = true, "Switch for neutron frozen showers");
35  declareProperty("NeutMinEneShowerLib", m_Neut_MinEneShowerLib = 0.0*CLHEP::GeV, "Minimum energy for neutron frozen showers");
36  declareProperty("NeutMaxEneShowerLib", m_Neut_MaxEneShowerLib = 0.1*CLHEP::GeV, "Maximum energy for neutron frozen showers");
37 
38  declareProperty("PionFlagToShowerLib", m_Pion_FlagShowerLib = true, "Switch for neutron frozen showers");
39  declareProperty("PionMinEneShowerLib", m_Pion_MinEneShowerLib = 0.0*CLHEP::GeV, "Minimum energy for neutron frozen showers");
40  declareProperty("PionMaxEneShowerLib", m_Pion_MaxEneShowerLib = 2.0*CLHEP::GeV, "Maximum energy for neutron frozen showers");
41 
42  declareProperty("ContainLow", m_containLow = true, "Switch for containment at low eta");
43  declareProperty("ContainHigh", m_containHigh = true, "Switch for containment at high eta");
44  declareProperty("ContainCrack", m_containCrack = true, "Switch for containment in the crack region");
45 
46  declareProperty("GeneratedStartingPointsFile", m_generated_starting_points_file = "", "Name of file for generated SPs. Do not touch until you want to produce a new library");
47  declareProperty("GeneratedStartingPointsRatio", m_generated_starting_points_ratio = 0.02, "Ratio of SPs that goes to output");
48 
49  /* BE SURE THIS ONE IS THE SAME AS IN LArG4ShowerLibSvc!!! */
50  enum DETECTOR {EMB=100000,EMEC=200000,FCAL1=300000,FCAL2=400000,FCAL3=500000,HECLOC=600000,HEC=700000};
51 
52  m_detmap["EMB"]=EMB;
53  m_detmap["EMEC"]=EMEC;
54  m_detmap["FCAL1"]=FCAL1;
55  m_detmap["FCAL2"]=FCAL2;
56  m_detmap["FCAL3"]=FCAL3;
57  m_detmap["HECLOC"]=HECLOC;
58  m_detmap["HEC"]=HEC;
59 
60 }
61 
62 
63 // default destructor
65 {
66 }
67 
68 // initialization
70 {
71  msg(MSG::INFO) << "Initializing" << endmsg;
72 
73  if (name().find("EMB") != std::string::npos) {
74  m_detector_tag_str = "EMB";
75  } else if (name().find("EMEC") != std::string::npos) {
76  m_detector_tag_str = "EMEC";
77  } else if (name().find("FCAL2") != std::string::npos) {
78  m_detector_tag_str = "FCAL2";
79  } else if (name().find("FCAL") != std::string::npos) {
80  m_detector_tag_str = "FCAL1";
81  } else if (name().find("HEC") != std::string::npos) {
82  m_detector_tag_str = "HEC";
83  } else if (name().find("DeadMaterial") != std::string::npos) {
84  m_detector_tag_str = "DM";
85  } else {
86  m_detector_tag_str = "UNKNOWN";
87  }
88  m_detector_tag = 0;
89  if (m_detmap.find(m_detector_tag_str) != m_detmap.end()){
91  }
93 
95  m_starting_points_file = new HepMC::IO_GenEvent(m_generated_starting_points_file.value().c_str(),std::ios::out);
96  }
97  // list all properties
98  this->print();
99 
100  return StatusCode::SUCCESS;
101 }
102 
103 
105 {
106  msg(MSG::INFO) << "Finalizing fast simulation service. " << endmsg;
107 
109  delete m_starting_points_file;
110  }
111  return StatusCode::SUCCESS;
112 }
113 
114 
116 {
117  msg(MSG::INFO) << "List of Frozen Shower options:" << endmsg;
118  msg(MSG::INFO) << "Detector tag is " << m_detector_tag_str << endmsg;
120  msg(MSG::INFO) << "Starting points will be saved to " << m_generated_starting_points_file.value() << endmsg;
121  }
122 
123  if (this->m_e_FlagShowerLib) {
124  msg(MSG::INFO) << "Electrons energy range [MeV] for Frozen Showers ["
125  << this->m_e_MinEneShowerLib << " -- " << this->m_e_MaxEneShowerLib << "]" << endmsg;
126  } else {
127  msg(MSG::INFO) << "Electrons wont be parameterized" << endmsg;
128  }
129 
130  if (this->m_g_FlagShowerLib) {
131  msg(MSG::INFO) << "Photons energy range [MeV] for Frozen Showers ["
132  << this->m_g_MinEneShowerLib << " -- " << this->m_g_MaxEneShowerLib << "]" << endmsg;
133  } else {
134  msg(MSG::INFO) << "Photons wont be parameterized" << endmsg;
135  }
136 
137  if (this->m_Neut_FlagShowerLib) {
138  msg(MSG::INFO) << "Neutrons energy range [MeV] for Frozen Showers ["
139  << this->m_Neut_MinEneShowerLib << " -- " << this->m_Neut_MaxEneShowerLib << "]" << endmsg;
140  } else {
141  msg(MSG::INFO) << "Neutrons wont be parameterized" << endmsg;
142  }
143 
144  // the containment checks
145  msg(MSG::INFO) << "Containment check at low eta: " << (this->m_containLow ? "YES" : "NO") << endmsg;
146  msg(MSG::INFO) << "Containment check at crack eta: " << (this->m_containCrack ? "YES" : "NO") << endmsg;
147  msg(MSG::INFO) << "Containment check at high eta: " << (this->m_containHigh ? "YES" : "NO") << endmsg;
148 }
149 
150 bool LArG4FastSimSvc::generateFSStartingPoint( const HepMC::GenEvent * ge )
151 {
153  return false;
154  m_starting_points_file->write_event(ge);
155  return true;
156 }
LArG4FastSimSvc::m_containLow
bool m_containLow
switch for containment check at low eta
Definition: LArG4FastSimSvc.h:92
LArG4FastSimSvc::m_detector_tag_str
std::string m_detector_tag_str
Definition: LArG4FastSimSvc.h:101
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
LArSamples::HEC
@ HEC
Definition: CaloId.h:26
GenEvent.h
LArG4FastSimSvc::m_e_MinEneShowerLib
double m_e_MinEneShowerLib
lower energy limit for electron frozen showers
Definition: LArG4FastSimSvc.h:77
LArG4FastSimSvc::m_generated_starting_points_file
StringProperty m_generated_starting_points_file
switch for shower starting point record
Definition: LArG4FastSimSvc.h:96
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
LArG4FastSimSvc::m_detector_tag
int m_detector_tag
name for the detector tag for the ShowerLibSvc
Definition: LArG4FastSimSvc.h:100
IO_GenEvent.h
LArG4FastSimSvc::m_Neut_MinEneShowerLib
double m_Neut_MinEneShowerLib
lower energy limit for neutron frozen showers
Definition: LArG4FastSimSvc.h:85
LArG4FastSimSvc::print
void print() const
dump object content
Definition: LArG4FastSimSvc.cxx:115
LArG4FastSimSvc::initialize
virtual StatusCode initialize()
Definition: LArG4FastSimSvc.cxx:69
LArG4FastSimSvc::m_detmap
std::map< std::string, int > m_detmap
Definition: LArG4FastSimSvc.h:102
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
CaloCell_ID_FCS::FCAL1
@ FCAL1
Definition: FastCaloSim_CaloCell_ID.h:41
LArG4FastSimSvc::m_containHigh
bool m_containHigh
switch for containment check at high eta
Definition: LArG4FastSimSvc.h:93
LArG4FastSimSvc::m_starting_points_file
HepMC::IO_GenEvent * m_starting_points_file
Definition: LArG4FastSimSvc.h:99
LArG4FastSimSvc::finalize
virtual StatusCode finalize()
Definition: LArG4FastSimSvc.cxx:104
LArG4FastSimSvc::m_containCrack
bool m_containCrack
switch for containment check in crack region
Definition: LArG4FastSimSvc.h:94
LArSamples::EMEC
@ EMEC
Definition: CaloId.h:25
LArG4FastSimSvc::m_Pion_MinEneShowerLib
double m_Pion_MinEneShowerLib
lower energy limit for pion frozen showers
Definition: LArG4FastSimSvc.h:89
LArSamples::EMB
@ EMB
Definition: CaloId.h:25
LArG4FastSimSvc::LArG4FastSimSvc
LArG4FastSimSvc(const std::string &name, ISvcLocator *sl)
Standard Constructor.
Definition: LArG4FastSimSvc.cxx:19
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArG4FastSimSvc::generateFSStartingPoint
virtual bool generateFSStartingPoint(const HepMC::GenEvent *ge)
Definition: LArG4FastSimSvc.cxx:150
LArG4FastSimSvc::m_g_MaxEneShowerLib
double m_g_MaxEneShowerLib
lower energy limit for photon frozen showers
Definition: LArG4FastSimSvc.h:81
LArG4FastSimSvc::m_Pion_MaxEneShowerLib
double m_Pion_MaxEneShowerLib
upper energy limit for pion frozen showers
Definition: LArG4FastSimSvc.h:90
LArG4FastSimSvc::m_generated_starting_points_ratio
float m_generated_starting_points_ratio
switch for shower starting point record
Definition: LArG4FastSimSvc.h:97
LArG4FastSimSvc::m_Neut_FlagShowerLib
bool m_Neut_FlagShowerLib
switch for neutron frozen showers
Definition: LArG4FastSimSvc.h:84
LArG4FastSimSvc.h
LArG4FastSimSvc::~LArG4FastSimSvc
virtual ~LArG4FastSimSvc()
Standard Destructor.
Definition: LArG4FastSimSvc.cxx:64
LArG4FastSimSvc::m_Pion_FlagShowerLib
bool m_Pion_FlagShowerLib
switch for pion frozen showers
Definition: LArG4FastSimSvc.h:88
LArG4FastSimSvc::m_generate_starting_points
bool m_generate_starting_points
Definition: LArG4FastSimSvc.h:98
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
LArG4FastSimSvc::m_g_FlagShowerLib
bool m_g_FlagShowerLib
switch for photon frozen showers
Definition: LArG4FastSimSvc.h:80
LArG4FastSimSvc::m_e_FlagShowerLib
bool m_e_FlagShowerLib
switch for electron frozen showers
Definition: LArG4FastSimSvc.h:76
LArG4FastSimSvc::m_g_MinEneShowerLib
double m_g_MinEneShowerLib
upper energy limit for photon frozen showers
Definition: LArG4FastSimSvc.h:82
CaloCell_ID_FCS::FCAL2
@ FCAL2
Definition: FastCaloSim_CaloCell_ID.h:42
LArG4FastSimSvc::m_Neut_MaxEneShowerLib
double m_Neut_MaxEneShowerLib
upper energy limit for neutron frozen showers
Definition: LArG4FastSimSvc.h:86
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
LArG4FastSimSvc::m_e_MaxEneShowerLib
double m_e_MaxEneShowerLib
upper energy limit for electron frozen showers
Definition: LArG4FastSimSvc.h:78