88 {
89
90
92
93 if (writeHandle.isValid()) {
95 "CondHandle "
96 << writeHandle.fullKey() << " is already valid.");
97 return StatusCode::SUCCESS;
98 }
99
100
101 const LArOnlineID_Base *larOnlineID = nullptr;
103 const LArOnline_SuperCellID *scidhelper;
105 larOnlineID = scidhelper;
106 } else {
107 const LArOnlineID *idhelper;
109 larOnlineID = idhelper;
110 }
111
112 const LArOnOffIdMapping *larOnOffIdMapping = nullptr;
113 SG::ReadCondHandle<LArOnOffIdMapping> larOnOffIdMappingHdl{
115 };
116 larOnOffIdMapping = *larOnOffIdMappingHdl;
117 if (larOnOffIdMapping == nullptr) {
118 ATH_MSG_ERROR(
"Failed to retrieve LArOnOffIdMapping object");
119 }
120
121
123
124
125
126 const ILArShape *larShape{ *ShapeHdl };
127 writeHandle.addDependency(ShapeHdl);
128
130 const ILArAutoCorr *larAutoCorr{ *AutoCorrHdl };
131 writeHandle.addDependency(AutoCorrHdl);
132
134 const LArADC2MeV *larADC2MeV = nullptr;
135 larADC2MeV = *ADC2MeVHdl;
136 if (larADC2MeV == nullptr) {
138 return StatusCode::FAILURE;
139 }
140 writeHandle.addDependency(ADC2MeVHdl);
141
142
143
144
145 const ILArNoise *larNoise = nullptr;
146 const ILArPedestal *larPedestal = nullptr;
147 const ILArfSampl *larfSampl = nullptr;
148 const ILArMinBias *larMinBias = nullptr;
149
153 larNoise = *NoiseHdl;
154 writeHandle.addDependency(NoiseHdl);
155 } else {
157 larPedestal = *PedestalHdl;
158 writeHandle.addDependency(PedestalHdl);
159 }
160
162 larfSampl = *fSamplHdl;
163 writeHandle.addDependency(fSamplHdl);
164
166 larMinBias = *MinBiasHdl;
167 writeHandle.addDependency(MinBiasHdl);
168 }
169
170 ATH_MSG_INFO(
"IOV found from intersection for AutoCorrTotal object: "
171 << writeHandle.getRange());
172
173
174
175
176 std::unique_ptr<LArAutoCorrTotal> larAutoCorrTotal =
177 std::make_unique<LArAutoCorrTotal>(larOnlineID, larOnOffIdMapping,
m_nGains);
178
180 int count2 = 0;
181 int count3 =0;
182
183 for (
const HWIdentifier chid : larOnlineID->
channel_range()) {
185 const IdentifierHash hid = larOnlineID->
channel_Hash(chid);
186
187
189 count2++;
190
193 const int nsamples_shape = static_cast<int>(Shape.size());
194
197
198 if (
AC.size() == 0) {
200 continue;
201 }
202
203 count3++;
204 int nsamples_AC_OFC =
AC.size() + 1;
205
208 }
209
210
211 unsigned int ihecshift = 0;
212 if (larOnlineID->
isHECchannel(chid) && nsamples_AC_OFC == 4 &&
214 ihecshift = 1;
215
216
217 }
218
219
220
221
222
223
224 float fSigma2 = 0.;
226 float SigmaNoise;
228 SigmaNoise = larNoise->
noise(chid, igain);
229 else {
230 float RMSpedestal = larPedestal->
pedestalRMS(chid, igain);
232 SigmaNoise = RMSpedestal;
233 else
234 SigmaNoise = 0.;
235 }
236 float fSampl = larfSampl->
FSAMPL(chid);
237 float MinBiasRMS = larMinBias->
minBiasRMS(chid);
238 if (fSampl != 0)
239 MinBiasRMS /= fSampl;
240 const auto polynom_adc2mev =
241 larADC2MeV->
ADC2MEV(hid, igain);
242 float Adc2MeV = 0.;
243 if (polynom_adc2mev.size() > 0) {
244 Adc2MeV = (polynom_adc2mev)[1];
245 }
246 if (SigmaNoise != 0 && Adc2MeV != 0)
247 fSigma2 =
pow(MinBiasRMS / (SigmaNoise * Adc2MeV), 2);
248
249 if (fSampl == 0 || SigmaNoise == 0 || Adc2MeV == 0) {
253 << "fSampl (" << fSampl << "), SigmaNoise ("
254 << SigmaNoise << ") or Adc2MeV (" << Adc2MeV
255 << ") null "
256 << "=> AutoCorrTotal = only AutoCorr elect. part ");
257 }
258 fSigma2 = 0.;
259 }
261 << ") fSampl (" << fSampl << ") "
262 << ") SigmaNoise (" << SigmaNoise << ") "
263 << ") Adc2MeV (" << Adc2MeV << ") "
264
265 );
266
267
268
269
270
271 }
272
273
274
275 int nsize_tot = (nsamples_AC_OFC - 1) * (nsamples_AC_OFC) / 2;
276
278 << ") fSigma2 (" << fSigma2 << ") "
279 << ") nsamples_AC_OFC ( " << nsamples_AC_OFC);
280 std::vector<float> vTerms;
281
282 vTerms.resize(2 * nsize_tot + nsamples_AC_OFC, 0.);
283
284
285 for (
int j1 = 0;
j1 < nsamples_AC_OFC - 1;
j1++) {
286 for (
int j2 = j1 + 1;
j2 < nsamples_AC_OFC;
j2++) {
287 int l = abs(j2 - j1) - 1;
289 j1 * nsamples_AC_OFC -
j1 * (
j1 + 1) / 2 + j2 - (j1 + 1);
291 }
292 }
293
295 << ") vTerms[1] (" << vTerms[1] << ") ");
296
297 for (
int j1 = 0;
j1 < nsamples_AC_OFC - 1; ++
j1) {
298 for (
int j2 = j1 + 1;
j2 < nsamples_AC_OFC;
j2++) {
300 j1 * nsamples_AC_OFC -
j1 * (
j1 + 1) / 2 + j2 - (j1 + 1);
301 float Rij = 0;
302 for (
int k = 0;
k < nsamples_shape; ++
k) {
303 if ((j2 - j1 + k) >= 0 && (j2 - j1 + k) < nsamples_shape) {
304 int ibunch = 0;
306 ibunch = 1;
307 Rij += Shape[
k] * Shape[
j2 -
j1 +
k] * ibunch;
308 }
309 }
310 vTerms[nsize_tot +
index] = fSigma2 * Rij;
311 }
312 }
314 << ") vTerms[mid] (" << vTerms[vTerms.size()/2] << ") ");
315
316
317 for (
int j1 = 0;
j1 < nsamples_AC_OFC;
j1++) {
318 float Rms2i = 0;
319 for (
int k = 0;
k < nsamples_shape; ++
k) {
320 int ibunch = 0;
322 ibunch = 1;
323 Rms2i +=
pow(Shape[k], 2) * ibunch;
324 }
325 vTerms[2 * nsize_tot +
j1] = fSigma2 * Rms2i;
326 }
328 << ") vTerms[last] (" << vTerms[vTerms.size()-1] << ") ");
329
330
331
332 larAutoCorrTotal->set(hid, igain, vTerms);
333
334 }
335
336 } else
339 std::vector<float>
empty(nsize_tot, 0.);
340 larAutoCorrTotal->set(hid, igain,
empty);
341 }
342 }
343
345 ATH_MSG_INFO(
"LArAutoCorrTotal Ncell * Ngain " << count3);
347
349
350 ATH_CHECK(writeHandle.record(std::move(larAutoCorrTotal)));
351
352
353 return StatusCode::SUCCESS;
354}
#define ATH_CHECK
Evaluate an expression and check for errors.
static const Attributes_t empty
constexpr int pow(int base, int exp) noexcept
const ServiceHandle< StoreGateSvc > & detStore() const
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
LArVectorProxy AutoCorrRef_t
virtual AutoCorrRef_t autoCorr(const HWIdentifier &CellID, int gain) const =0
virtual const float & minBiasRMS(const HWIdentifier &id) const =0
access to RMS of E in minimum bias events index by Identifier
virtual const float & noise(const HWIdentifier &id, int gain) const =0
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
LArVectorProxy ShapeRef_t
This class defines the interface for accessing Shape (Nsample variable, Dt = 25 ns fixed) @stereotype...
virtual ShapeRef_t Shape(const HWIdentifier &id, int gain, int tbin=0, int mode=0) const =0
virtual const float & FSAMPL(const HWIdentifier &id) const =0
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
bool isOnlineConnected(const HWIdentifier &sid) const
Test whether a HWIdentifier is connected of not (inline)
id_range channel_range() const
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
virtual bool isHECchannel(const HWIdentifier id) const =0
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
l
Printing final latex table to .tex output file.
retrieve(aClass, aKey=None)