ATLAS Offline Software
LArG4FastSimSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 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  : AthService(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 
115 // query interface
116 StatusCode LArG4FastSimSvc::queryInterface(const InterfaceID& riid, void** ppvInterface)
117 {
118  if ( IID_ILArG4FastSimSvc == riid ) {
119  *ppvInterface = (ILArG4FastSimSvc*)this;
120  }
121  else {
122  // Interface is not directly available: try out a base class
123  return AthService::queryInterface(riid, ppvInterface);
124  }
125  addRef();
126  return StatusCode::SUCCESS;
127 }
128 
129 
131 {
132  msg(MSG::INFO) << "List of Frozen Shower options:" << endmsg;
133  msg(MSG::INFO) << "Detector tag is " << m_detector_tag_str << endmsg;
135  msg(MSG::INFO) << "Starting points will be saved to " << m_generated_starting_points_file.value() << endmsg;
136  }
137 
138  if (this->m_e_FlagShowerLib) {
139  msg(MSG::INFO) << "Electrons energy range [MeV] for Frozen Showers ["
140  << this->m_e_MinEneShowerLib << " -- " << this->m_e_MaxEneShowerLib << "]" << endmsg;
141  } else {
142  msg(MSG::INFO) << "Electrons wont be parameterized" << endmsg;
143  }
144 
145  if (this->m_g_FlagShowerLib) {
146  msg(MSG::INFO) << "Photons energy range [MeV] for Frozen Showers ["
147  << this->m_g_MinEneShowerLib << " -- " << this->m_g_MaxEneShowerLib << "]" << endmsg;
148  } else {
149  msg(MSG::INFO) << "Photons wont be parameterized" << endmsg;
150  }
151 
152  if (this->m_Neut_FlagShowerLib) {
153  msg(MSG::INFO) << "Neutrons energy range [MeV] for Frozen Showers ["
154  << this->m_Neut_MinEneShowerLib << " -- " << this->m_Neut_MaxEneShowerLib << "]" << endmsg;
155  } else {
156  msg(MSG::INFO) << "Neutrons wont be parameterized" << endmsg;
157  }
158 
159  // the containment checks
160  msg(MSG::INFO) << "Containment check at low eta: " << (this->m_containLow ? "YES" : "NO") << endmsg;
161  msg(MSG::INFO) << "Containment check at crack eta: " << (this->m_containCrack ? "YES" : "NO") << endmsg;
162  msg(MSG::INFO) << "Containment check at high eta: " << (this->m_containHigh ? "YES" : "NO") << endmsg;
163 }
164 
165 bool LArG4FastSimSvc::generateFSStartingPoint( const HepMC::GenEvent * ge )
166 {
168  return false;
169  m_starting_points_file->write_event(ge);
170  return true;
171 }
LArG4FastSimSvc::m_containLow
bool m_containLow
switch for containment check at low eta
Definition: LArG4FastSimSvc.h:98
LArG4FastSimSvc::m_detector_tag_str
std::string m_detector_tag_str
Definition: LArG4FastSimSvc.h:107
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:83
LArG4FastSimSvc::m_generated_starting_points_file
StringProperty m_generated_starting_points_file
switch for shower starting point record
Definition: LArG4FastSimSvc.h:102
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:106
IO_GenEvent.h
LArG4FastSimSvc::m_Neut_MinEneShowerLib
double m_Neut_MinEneShowerLib
lower energy limit for neutron frozen showers
Definition: LArG4FastSimSvc.h:91
LArG4FastSimSvc::print
void print() const
dump object content
Definition: LArG4FastSimSvc.cxx:130
LArG4FastSimSvc::initialize
virtual StatusCode initialize()
Definition: LArG4FastSimSvc.cxx:69
LArG4FastSimSvc::m_detmap
std::map< std::string, int > m_detmap
Definition: LArG4FastSimSvc.h:108
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:99
LArG4FastSimSvc::m_starting_points_file
HepMC::IO_GenEvent * m_starting_points_file
Definition: LArG4FastSimSvc.h:105
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:100
LArSamples::EMEC
@ EMEC
Definition: CaloId.h:25
ILArG4FastSimSvc
Definition: ILArG4FastSimSvc.h:15
LArG4FastSimSvc::m_Pion_MinEneShowerLib
double m_Pion_MinEneShowerLib
lower energy limit for pion frozen showers
Definition: LArG4FastSimSvc.h:95
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
AthService
Definition: AthService.h:32
LArG4FastSimSvc::generateFSStartingPoint
virtual bool generateFSStartingPoint(const HepMC::GenEvent *ge)
Definition: LArG4FastSimSvc.cxx:165
LArG4FastSimSvc::m_g_MaxEneShowerLib
double m_g_MaxEneShowerLib
lower energy limit for photon frozen showers
Definition: LArG4FastSimSvc.h:87
LArG4FastSimSvc::m_Pion_MaxEneShowerLib
double m_Pion_MaxEneShowerLib
upper energy limit for pion frozen showers
Definition: LArG4FastSimSvc.h:96
LArG4FastSimSvc::m_generated_starting_points_ratio
float m_generated_starting_points_ratio
switch for shower starting point record
Definition: LArG4FastSimSvc.h:103
LArG4FastSimSvc::m_Neut_FlagShowerLib
bool m_Neut_FlagShowerLib
switch for neutron frozen showers
Definition: LArG4FastSimSvc.h:90
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:94
LArG4FastSimSvc::m_generate_starting_points
bool m_generate_starting_points
Definition: LArG4FastSimSvc.h:104
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArG4FastSimSvc::m_g_FlagShowerLib
bool m_g_FlagShowerLib
switch for photon frozen showers
Definition: LArG4FastSimSvc.h:86
LArG4FastSimSvc::queryInterface
StatusCode queryInterface(const InterfaceID &riid, void **ppvIF)
Query interface.
Definition: LArG4FastSimSvc.cxx:116
LArG4FastSimSvc::m_e_FlagShowerLib
bool m_e_FlagShowerLib
switch for electron frozen showers
Definition: LArG4FastSimSvc.h:82
LArG4FastSimSvc::m_g_MinEneShowerLib
double m_g_MinEneShowerLib
upper energy limit for photon frozen showers
Definition: LArG4FastSimSvc.h:88
AthCommonMsg< Service >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
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:92
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
LArG4FastSimSvc::m_e_MaxEneShowerLib
double m_e_MaxEneShowerLib
upper energy limit for electron frozen showers
Definition: LArG4FastSimSvc.h:84