ATLAS Offline Software
LUCID_DigiSettings.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "CLHEP/Units/PhysicalConstants.h"
7 #include "CLHEP/Units/SystemOfUnits.h"
8 #include "GaudiKernel/Algorithm.h"
9 #include "GaudiKernel/MsgStream.h"
10 #include <iostream>
11 #include <utility>
12 
13 
15  m_msgSvc(nullptr),
16  m_parValueNotSetByUserDouble(10.0e39),
17  m_parValueNotSetByUserInt (32767) {
18 
20 }
21 
23 
24  m_msgSvc = msgSvc;
25 
26  MsgStream log(m_msgSvc, "LUCID_DigiSettings::initialize");
27 
28  log << MSG::INFO << "Initializing" << endmsg;
29 
31 }
32 
34 
35  MsgStream log(m_msgSvc, "LUCID_DigiSettings::SetDefaultValues");
36 
37  DefNewParameterInt ("Number of LUCID tubes" , "numTubes" , &m_numTubes , 1, 100);
38  DefNewParameterInt ("QDC channels per photo-electron", "qdcChannelsPerPE" , &m_qdcChannelsPerPE , 1 , 100);
39  DefNewParameterDouble("QDC FED NoiseFactor" , "qdcFedNoiseFactor", &m_qdcFedNoiseFactor, 1., 50.);
40  DefNewParameterDouble("TDC PMT NoiseFactor" , "tdcPmtNoiseFactor", &m_tdcPmtNoiseFactor, 1., 50.);
41  DefNewParameterDouble("TDC FED NoiseFactor" , "tdcFedNoiseFactor", &m_tdcFedNoiseFactor, 1., 50.);
42 
43  m_numTubes = 40;
44  m_qdcChannelsPerPE = 10;
45  m_qdcFedNoiseFactor = 3.0;
46  m_tdcPmtNoiseFactor = 2.8;
47  m_tdcFedNoiseFactor = 0.8;
48 }
49 
51 
54 
55  for (; doubleMapIt != m_doubleMap.end(); ++doubleMapIt) alg->declareProperty(std::string("Overwrite_") + doubleMapIt->first, doubleMapIt->second.overwriteVal);
56  for (; intMapIt != m_intMap.end() ; ++intMapIt ) alg->declareProperty(std::string("Overwrite_") + intMapIt->first , intMapIt->second.overwriteVal);
57 }
58 
60 
61  MsgStream log(m_msgSvc, "LUCID_DigiSettings");
62 
63  log << MSG::INFO << " OverwriteDigiParValues " << endmsg;
64 
67 
68  if (doubleMapIt->second.overwriteVal != m_parValueNotSetByUserDouble) {
69 
70  for (; doubleMapIt != m_doubleMap.end(); ++doubleMapIt) {
71 
72  if (doubleMapIt->second.overwriteVal > doubleMapIt->second.low &&
73  doubleMapIt->second.overwriteVal < doubleMapIt->second.high) {
74 
75  *(doubleMapIt->second.par) = doubleMapIt->second.overwriteVal;
76 
77  log << MSG::INFO << " Overwriting: "
78  << doubleMapIt->second.parDescription << " to : "
79  << doubleMapIt->second.overwriteVal << endmsg;
80  }
81  }
82  }
83 
84  if (intMapIt->second.overwriteVal != m_parValueNotSetByUserInt) {
85 
86  for (; intMapIt != m_intMap.end(); ++intMapIt) {
87 
88  if (intMapIt->second.overwriteVal > intMapIt->second.low &&
89  intMapIt->second.overwriteVal < intMapIt->second.high) {
90 
91  *(intMapIt->second.par) = intMapIt->second.overwriteVal;
92 
93  log << MSG::INFO << " Overwriting: "
94  << intMapIt->second.parDescription << " to : "
95  << intMapIt->second.overwriteVal << endmsg;
96  }
97  }
98  }
99 }
100 
102 
103  MsgStream log(m_msgSvc, "LUCID_DigiSettings::Print");
104 
105  std::map <std::string, parDouble>::const_iterator doubleMapIt = m_doubleMap.begin();
106  std::map <std::string, parInt>::const_iterator intMapIt = m_intMap.begin();
107 
108  log << MSG::INFO << "===================== Doubles ======================" << endmsg;
109 
110  for (; doubleMapIt != m_doubleMap.end(); ++doubleMapIt)
111  log << MSG::INFO << doubleMapIt->second.parDescription << ": " << *(doubleMapIt->second.par) <<endmsg;
112 
113  log << MSG::INFO << "===================== Integers ======================" << endmsg;
114 
115  for (; intMapIt != m_intMap.end(); ++intMapIt)
116  log << MSG::INFO << intMapIt->second.parDescription << ": " << *(intMapIt->second.par) << endmsg;
117 
118  log << MSG::INFO << "=====================================================" << endmsg;
119 }
120 
121 void LUCID_DigiSettings::SetDigiParDouble(const std::string& parname, double parval) {
122 
123  if (!m_doubleMap.count(parname))
124  if (!m_intMap.count(parname)) {
125  MsgStream log(m_msgSvc, "LUCID_DigiSettings::SetDigiParDouble");
126  log << MSG::FATAL << " LUCID_DigiSettings: parameter does not exist: " << parname << endmsg;
127  std::abort();
128  }
129 
130  m_doubleMap[parname].par = &parval;
131 }
132 
133 void LUCID_DigiSettings::SetDigiParInt(const std::string& parname, int parval) {
134 
135  if (!m_doubleMap.count(parname))
136  if (!m_intMap.count(parname)) {
137  MsgStream log(m_msgSvc, "LUCID_DigiSettings::SetDigiParInt");
138  log << MSG::FATAL << " LUCID_DigiSettings: parameter does not exist: " << parname << endmsg;
139  std::abort();
140  }
141 
142  m_intMap[parname].par = &parval;
143 }
144 
145 double LUCID_DigiSettings::GetDigiParDouble(const std::string& parname) {
146 
147  if (!m_doubleMap.count(parname))
148  if (!m_intMap.count(parname)) {
149  MsgStream log(m_msgSvc, "LUCID_DigiSettings::GetDigiParDouble");
150  log << MSG::FATAL << " LUCID_DigiSettings: parameter does not exist: " << parname << endmsg;
151  std::abort();
152  }
153 
154  return *m_doubleMap[parname].par;
155 }
156 
158 
159  if (!m_doubleMap.count(parname))
160  if (!m_intMap.count(parname)) {
161  MsgStream log(m_msgSvc, "LUCID_DigiSettings::GetDigiParInt");
162  log << MSG::FATAL << " LUCID_DigiSettings: parameter does not exist: " << parname << endmsg;
163  std::abort();
164  }
165 
166  return *m_intMap[parname].par;
167 }
168 
169 void LUCID_DigiSettings::DefNewParameterDouble(std::string parDescription,
170  const std::string& parname,
171  double* par,
172  double low,
173  double high) {
174 
175  if (low > high) {
176  MsgStream log(m_msgSvc, "LUCID_DigiSettings::DefNewParameterDouble");
177  log << MSG::FATAL << " Swap the boundaries on the range " << parname << endmsg;
178  std::abort();
179  }
180  if (m_doubleMap.count(parname)) {
181  MsgStream log(m_msgSvc, "LUCID_DigiSettings::DefNewParameterDouble");
182  log << MSG::FATAL << " More than one parameter with that name " << parname << endmsg;
183  std::abort();
184  }
185  if (m_intMap.count (parname)) {
186  MsgStream log(m_msgSvc, "LUCID_DigiSettings::DefNewParameterDouble");
187  log << MSG::FATAL << " More than one parameter with that name " << parname << endmsg;
188  std::abort();
189  }
190 
191  parDouble parD;
192 
193  parD.parDescription = std::move(parDescription);
194  parD.par = par;
195  parD.low = low;
196  parD.high = high;
198 
199  m_doubleMap[parname] = parD;
200 }
201 
202 void LUCID_DigiSettings::DefNewParameterInt(std::string parDescription,
203  const std::string& parname,
204  int* par,
205  int low,
206  int high) {
207 
208  if (low > high) {
209  MsgStream log(m_msgSvc, "LUCID_DigiSettings::DefNewParameterInt");
210  log << MSG::FATAL << " Swap the boundaries on the range " << parname << endmsg;
211  std::abort();
212  }
213  if (m_doubleMap.count(parname)) {
214  MsgStream log(m_msgSvc, "LUCID_DigiSettings::DefNewParameterInt");
215  log << MSG::FATAL << " More than one parameter with that name " << parname << endmsg;
216  std::abort();
217  }
218  if (m_intMap.count (parname)) {
219  MsgStream log(m_msgSvc, "LUCID_DigiSettings::DefNewParameterInt");
220  log << MSG::FATAL << " More than one parameter with that name " << parname << endmsg;
221  std::abort();
222  }
223 
224  parInt parI;
225 
226  parI.parDescription = std::move(parDescription);
227  parI.par = par;
228  parI.low = low;
229  parI.high = high;
231 
232  m_intMap[parname] = parI;
233 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
LUCID_DigiSettings::OverwriteDigiParValues
void OverwriteDigiParValues()
Definition: LUCID_DigiSettings.cxx:59
LUCID_DigiSettings::DefNewParameterInt
void DefNewParameterInt(std::string, const std::string &, int *, int, int)
Definition: LUCID_DigiSettings.cxx:202
LUCID_DigiSettings::Initialize
void Initialize(IMessageSvc *msgSvc)
Definition: LUCID_DigiSettings.cxx:22
SGout2dot.alg
alg
Definition: SGout2dot.py:243
LUCID_DigiSettings::GetDigiParInt
int GetDigiParInt(const std::string &)
Definition: LUCID_DigiSettings.cxx:157
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
LUCID_DigiSettings::m_tdcPmtNoiseFactor
double m_tdcPmtNoiseFactor
Definition: LUCID_DigiSettings.h:46
LUCID_DigiSettings::parInt::low
int low
Definition: LUCID_DigiSettings.h:68
python.CreateTierZeroArgdict.parname
parname
Definition: CreateTierZeroArgdict.py:194
LUCID_DigiSettings::SetDefaultValues
void SetDefaultValues()
Definition: LUCID_DigiSettings.cxx:33
LUCID_DigiSettings::DefNewParameterDouble
void DefNewParameterDouble(std::string, const std::string &, double *, double, double)
Definition: LUCID_DigiSettings.cxx:169
LUCID_DigiSettings::parDouble::par
double * par
Definition: LUCID_DigiSettings.h:58
LUCID_DigiSettings::parDouble::high
double high
Definition: LUCID_DigiSettings.h:60
LUCID_DigiSettings::m_msgSvc
IMessageSvc * m_msgSvc
Definition: LUCID_DigiSettings.h:41
LUCID_DigiSettings::m_parValueNotSetByUserDouble
double m_parValueNotSetByUserDouble
Definition: LUCID_DigiSettings.h:49
LUCID_DigiSettings::LUCID_DigiSettings
LUCID_DigiSettings()
Definition: LUCID_DigiSettings.cxx:14
LUCID_DigiSettings::parDouble::overwriteVal
double overwriteVal
Definition: LUCID_DigiSettings.h:61
LUCID_DigiSettings::SetDigiParInt
void SetDigiParInt(const std::string &, int)
Definition: LUCID_DigiSettings.cxx:133
LUCID_DigiSettings::m_parValueNotSetByUserInt
int m_parValueNotSetByUserInt
Definition: LUCID_DigiSettings.h:50
LUCID_DigiSettings::parInt::parDescription
std::string parDescription
Definition: LUCID_DigiSettings.h:66
LUCID_DigiSettings::parDouble
Definition: LUCID_DigiSettings.h:55
LUCID_DigiSettings::m_qdcFedNoiseFactor
double m_qdcFedNoiseFactor
Definition: LUCID_DigiSettings.h:45
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
LUCID_DigiSettings::m_numTubes
int m_numTubes
Definition: LUCID_DigiSettings.h:43
LUCID_DigiSettings.h
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
LUCID_DigiSettings::parInt::overwriteVal
int overwriteVal
Definition: LUCID_DigiSettings.h:70
LUCID_DigiSettings::Print
void Print() const
Definition: LUCID_DigiSettings.cxx:101
LUCID_DigiSettings::m_doubleMap
std::map< std::string, parDouble > m_doubleMap
Definition: LUCID_DigiSettings.h:73
LUCID_DigiSettings::SetDigiParDouble
void SetDigiParDouble(const std::string &, double)
Definition: LUCID_DigiSettings.cxx:121
LUCID_DigiSettings::parInt
Definition: LUCID_DigiSettings.h:64
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
LUCID_DigiSettings::parInt::par
int * par
Definition: LUCID_DigiSettings.h:67
LUCID_DigiSettings::parDouble::parDescription
std::string parDescription
Definition: LUCID_DigiSettings.h:57
LUCID_DigiSettings::m_tdcFedNoiseFactor
double m_tdcFedNoiseFactor
Definition: LUCID_DigiSettings.h:47
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
LUCID_DigiSettings::m_qdcChannelsPerPE
int m_qdcChannelsPerPE
Definition: LUCID_DigiSettings.h:44
LUCID_DigiSettings::parDouble::low
double low
Definition: LUCID_DigiSettings.h:59
LUCID_DigiSettings::parInt::high
int high
Definition: LUCID_DigiSettings.h:69
LUCID_DigiSettings::GetDigiParDouble
double GetDigiParDouble(const std::string &)
Definition: LUCID_DigiSettings.cxx:145
LUCID_DigiSettings::OverwriteDigiParProperties
void OverwriteDigiParProperties(Gaudi::Algorithm *)
Definition: LUCID_DigiSettings.cxx:50
LUCID_DigiSettings::m_intMap
std::map< std::string, parInt > m_intMap
Definition: LUCID_DigiSettings.h:74