43 {
44
45
47
48 if (writeHandle.isValid()) {
50 "CondHandle "
51 << writeHandle.fullKey() << " is already valid.");
52 return StatusCode::SUCCESS;
53 }
54
55
56 const LArOnlineID_Base *larOnlineID = nullptr;
58 const LArOnline_SuperCellID *scidhelper;
60 larOnlineID = scidhelper;
61 } else {
62 const LArOnlineID *idhelper;
64 larOnlineID = idhelper;
65 }
66
67 const LArOnOffIdMapping *larOnOffIdMapping = nullptr;
68 SG::ReadCondHandle<LArOnOffIdMapping> larOnOffIdMappingHdl{
70 };
71 larOnOffIdMapping = *larOnOffIdMappingHdl;
72 if (larOnOffIdMapping == nullptr) {
74 }
75
76
78
79
80
81 const ILArShape *larShape{ *ShapeHdl };
82 writeHandle.addDependency(ShapeHdl);
83
85 const ILArAutoCorr *larAutoCorr{ *AutoCorrHdl };
86 writeHandle.addDependency(AutoCorrHdl);
87
89 const LArADC2MeV *larADC2MeV = nullptr;
90 larADC2MeV = *ADC2MeVHdl;
91 if (larADC2MeV == nullptr) {
93 return StatusCode::FAILURE;
94 }
95 writeHandle.addDependency(ADC2MeVHdl);
96
97
98
99
100 const ILArNoise *larNoise = nullptr;
101 const ILArPedestal *larPedestal = nullptr;
102 const ILArfSampl *larfSampl = nullptr;
103 const ILArMinBias *larMinBias = nullptr;
104
108 larNoise = *NoiseHdl;
109 writeHandle.addDependency(NoiseHdl);
110 } else {
112 larPedestal = *PedestalHdl;
113 writeHandle.addDependency(PedestalHdl);
114 }
115
117 larfSampl = *fSamplHdl;
118 writeHandle.addDependency(fSamplHdl);
119
121 larMinBias = *MinBiasHdl;
122 writeHandle.addDependency(MinBiasHdl);
123 }
124
125 ATH_MSG_INFO(
"IOV found from intersection for AutoCorrTotal object: "
126 << writeHandle.getRange());
127
128
129
130
131 std::unique_ptr<LArAutoCorrTotal> larAutoCorrTotal =
132 std::make_unique<LArAutoCorrTotal>(larOnlineID, larOnOffIdMapping,
m_nGains);
133
135 int count2 = 0;
136 int count3 =0;
137
138 for (
const HWIdentifier chid : larOnlineID->
channel_range()) {
140 const IdentifierHash hid = larOnlineID->
channel_Hash(chid);
141
142
144 count2++;
145
148 const int nsamples_shape = static_cast<int>(Shape.size());
149
152
153 if (
AC.size() == 0) {
155 continue;
156 }
157
158 count3++;
159 int nsamples_AC_OFC =
AC.size() + 1;
160
163 }
164
165
166 unsigned int ihecshift = 0;
167 if (larOnlineID->
isHECchannel(chid) && nsamples_AC_OFC == 4 &&
169 ihecshift = 1;
170
171
172 }
173
174
175
176
177
178
179 float fSigma2 = 0.;
181 float SigmaNoise;
183 SigmaNoise = larNoise->
noise(chid, igain);
184 else {
185 float RMSpedestal = larPedestal->
pedestalRMS(chid, igain);
187 SigmaNoise = RMSpedestal;
188 else
189 SigmaNoise = 0.;
190 }
191 float fSampl = larfSampl->
FSAMPL(chid);
192 float MinBiasRMS = larMinBias->
minBiasRMS(chid);
193 if (fSampl != 0)
194 MinBiasRMS /= fSampl;
195 const auto polynom_adc2mev =
196 larADC2MeV->
ADC2MEV(hid, igain);
197 float Adc2MeV = 0.;
198 if (polynom_adc2mev.size() > 0) {
199 Adc2MeV = (polynom_adc2mev)[1];
200 }
201 if (SigmaNoise != 0 && Adc2MeV != 0)
202 fSigma2 =
pow(MinBiasRMS / (SigmaNoise * Adc2MeV), 2);
203
204 if (fSampl == 0 || SigmaNoise == 0 || Adc2MeV == 0) {
208 << "fSampl (" << fSampl << "), SigmaNoise ("
209 << SigmaNoise << ") or Adc2MeV (" << Adc2MeV
210 << ") null "
211 << "=> AutoCorrTotal = only AutoCorr elect. part ");
212 }
213 fSigma2 = 0.;
214 }
216 << ") fSampl (" << fSampl << ") "
217 << ") SigmaNoise (" << SigmaNoise << ") "
218 << ") Adc2MeV (" << Adc2MeV << ") "
219
220 );
221
222
223
224
225
226 }
227
228
229
230 int nsize_tot = (nsamples_AC_OFC - 1) * (nsamples_AC_OFC) / 2;
231
233 << ") fSigma2 (" << fSigma2 << ") "
234 << ") nsamples_AC_OFC ( " << nsamples_AC_OFC);
235 std::vector<float> vTerms;
236
237 vTerms.resize(2 * nsize_tot + nsamples_AC_OFC, 0.);
238
239
240 for (
int j1 = 0;
j1 < nsamples_AC_OFC - 1;
j1++) {
241 for (
int j2 = j1 + 1;
j2 < nsamples_AC_OFC;
j2++) {
242 int l = abs(j2 - j1) - 1;
244 j1 * nsamples_AC_OFC -
j1 * (
j1 + 1) / 2 + j2 - (j1 + 1);
246 }
247 }
248
250 << ") vTerms[1] (" << vTerms[1] << ") ");
251
252 for (
int j1 = 0;
j1 < nsamples_AC_OFC - 1; ++
j1) {
253 for (
int j2 = j1 + 1;
j2 < nsamples_AC_OFC;
j2++) {
255 j1 * nsamples_AC_OFC -
j1 * (
j1 + 1) / 2 + j2 - (j1 + 1);
256 float Rij = 0;
257 for (
int k = 0;
k < nsamples_shape; ++
k) {
258 if ((j2 - j1 + k) >= 0 && (j2 - j1 + k) < nsamples_shape) {
259 int ibunch = 0;
261 ibunch = 1;
262 Rij += Shape[
k] * Shape[
j2 -
j1 +
k] * ibunch;
263 }
264 }
265 vTerms[nsize_tot +
index] = fSigma2 * Rij;
266 }
267 }
269 << ") vTerms[mid] (" << vTerms[vTerms.size()/2] << ") ");
270
271
272 for (
int j1 = 0;
j1 < nsamples_AC_OFC;
j1++) {
273 float Rms2i = 0;
274 for (
int k = 0;
k < nsamples_shape; ++
k) {
275 int ibunch = 0;
277 ibunch = 1;
278 Rms2i +=
pow(Shape[k], 2) * ibunch;
279 }
280 vTerms[2 * nsize_tot +
j1] = fSigma2 * Rms2i;
281 }
283 << ") vTerms[last] (" << vTerms[vTerms.size()-1] << ") ");
284
285
286
287 larAutoCorrTotal->set(hid, igain, vTerms);
288
289 }
290
291 } else
294 std::vector<float>
empty(nsize_tot, 0.);
295 larAutoCorrTotal->set(hid, igain,
empty);
296 }
297 }
298
300 ATH_MSG_INFO(
"LArAutoCorrTotal Ncell * Ngain " << count3);
302
304
305 ATH_CHECK(writeHandle.record(std::move(larAutoCorrTotal)));
306
307
308 return StatusCode::SUCCESS;
309}
#define ATH_CHECK
Evaluate an expression and check for errors.
static const Attributes_t empty
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
SG::WriteCondHandleKey< LArAutoCorrTotal > m_LArAutoCorrTotalObjKey
Gaudi::Property< unsigned > m_nGains
SG::ReadCondHandleKey< LArOnOffIdMapping > m_LArOnOffIdMappingObjKey
SG::ReadCondHandleKey< ILArShape > m_LArShapeObjKey
SG::ReadCondHandleKey< ILArPedestal > m_LArPedestalObjKey
SG::ReadCondHandleKey< ILArMinBias > m_LArMinBiasObjKey
SG::ReadCondHandleKey< ILArAutoCorr > m_LArAutoCorrObjKey
Gaudi::Property< bool > m_isMC
Gaudi::Property< int > m_deltaBunch
SG::ReadCondHandleKey< LArADC2MeV > m_LArADC2MeVObjKey
SG::ReadCondHandleKey< ILArNoise > m_LArNoiseObjKey
SG::ReadCondHandleKey< ILArfSampl > m_LArfSamplObjKey
Gaudi::Property< unsigned int > m_firstSample
Gaudi::Property< bool > m_isSuperCell
Gaudi::Property< bool > m_NoPile
Gaudi::Property< int > m_Nsamples
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.