16 "List of keys of RawRamp containers");
18 "Key of LArRampComplete or LArRampMC objects");
39 bool hasRawRampContainer=
false;
41 NTuple::Item<long> cellIndex;
42 NTuple::Item<long>
gain;
43 NTuple::Item<long> corrUndo;
44 NTuple::Array<float> SampleMax;
46 NTuple::Array<float> DAC;
47 NTuple::Array<float>
ADC;
48 NTuple::Array<long> NTriggers;
51 NTuple::Array<float> Sample0;
52 NTuple::Array<float> Sample1;
53 NTuple::Array<float> Sample2;
54 NTuple::Array<float> Sample3;
55 NTuple::Array<float> Sample4;
56 NTuple::Array<float> Sample5;
57 NTuple::Array<float> Sample6;
60 NTuple::Array<float> RMS0;
61 NTuple::Array<float> RMS1;
62 NTuple::Array<float> RMS2;
63 NTuple::Array<float> RMS3;
64 NTuple::Array<float> RMS4;
65 NTuple::Array<float> RMS5;
66 NTuple::Array<float> RMS6;
68 NTuple::Item<unsigned long> DACIndex;
69 NTuple::Array<float>
coeffs;
70 NTuple::Item<unsigned long> coeffIndex;
72 NTuple::Item<float> RampRMS;
79 if (
sc!=StatusCode::SUCCESS || !rawRampContainer) {
84 hasRawRampContainer =
true;
87 if (!hasRawRampContainer)
ATH_MSG_WARNING(
" No LArRawRampContainer found. Only fitted ramp in ntuple " );
108 if (!ramp && !hasRawRampContainer) {
109 ATH_MSG_ERROR(
"Have neither Raw Ramp nor Fitted Ramp. No Ntuple produced." );
110 return StatusCode::FAILURE;
113 sc=
m_nt->addItem(
"cellIndex",cellIndex,0,2000);
114 if (
sc!=StatusCode::SUCCESS) {
116 return StatusCode::FAILURE;
120 if (
sc!=StatusCode::SUCCESS) {
122 return StatusCode::FAILURE;
126 sc=
m_nt->addItem(
"corrUndo",corrUndo,0,1);
127 if (
sc!=StatusCode::SUCCESS) {
129 return StatusCode::FAILURE;
133 if (hasRawRampContainer)
135 sc=
m_nt->addItem(
"DACIndex",DACIndex,0,800);
136 if (
sc!=StatusCode::SUCCESS) {
138 return StatusCode::FAILURE;
141 sc=
m_nt->addItem(
"SampleMax",DACIndex,SampleMax);
142 if (
sc!=StatusCode::SUCCESS)
144 return StatusCode::FAILURE;
148 if (
sc!=StatusCode::SUCCESS)
150 return StatusCode::FAILURE;
153 if (
sc!=StatusCode::SUCCESS)
155 return StatusCode::FAILURE;
158 sc=
m_nt->addItem(
"DAC",DACIndex,DAC);
159 if (
sc!=StatusCode::SUCCESS)
161 return StatusCode::FAILURE;
164 sc=
m_nt->addItem(
"NTriggers",DACIndex,NTriggers);
165 if (
sc!=StatusCode::SUCCESS) {
167 return StatusCode::FAILURE;
171 sc=
m_nt->addItem(
"Sample0",DACIndex,Sample0);
172 if (
sc!=StatusCode::SUCCESS)
174 return StatusCode::FAILURE;
176 sc=
m_nt->addItem(
"Sample1",DACIndex,Sample1);
177 if (
sc!=StatusCode::SUCCESS)
179 return StatusCode::FAILURE;
181 sc=
m_nt->addItem(
"Sample2",DACIndex,Sample2);
182 if (
sc!=StatusCode::SUCCESS)
184 return StatusCode::FAILURE;
186 sc=
m_nt->addItem(
"Sample3",DACIndex,Sample3);
187 if (
sc!=StatusCode::SUCCESS)
189 return StatusCode::FAILURE;
191 sc=
m_nt->addItem(
"Sample4",DACIndex,Sample4);
192 if (
sc!=StatusCode::SUCCESS)
194 return StatusCode::FAILURE;
196 sc=
m_nt->addItem(
"Sample5",DACIndex,Sample5);
197 if (
sc!=StatusCode::SUCCESS)
199 return StatusCode::FAILURE;
201 sc=
m_nt->addItem(
"Sample6",DACIndex,Sample6);
202 if (
sc!=StatusCode::SUCCESS)
204 return StatusCode::FAILURE;
207 sc=
m_nt->addItem(
"RMS0",DACIndex,RMS0);
208 if (
sc!=StatusCode::SUCCESS)
210 return StatusCode::FAILURE;
212 sc=
m_nt->addItem(
"RMS1",DACIndex,RMS1);
213 if (
sc!=StatusCode::SUCCESS)
215 return StatusCode::FAILURE;
217 sc=
m_nt->addItem(
"RMS2",DACIndex,RMS2);
218 if (
sc!=StatusCode::SUCCESS)
220 return StatusCode::FAILURE;
222 sc=
m_nt->addItem(
"RMS3",DACIndex,RMS3);
223 if (
sc!=StatusCode::SUCCESS)
225 return StatusCode::FAILURE;
227 sc=
m_nt->addItem(
"RMS4",DACIndex,RMS4);
228 if (
sc!=StatusCode::SUCCESS)
230 return StatusCode::FAILURE;
232 sc=
m_nt->addItem(
"RMS5",DACIndex,RMS5);
233 if (
sc!=StatusCode::SUCCESS)
235 return StatusCode::FAILURE;
237 sc=
m_nt->addItem(
"RMS6",DACIndex,RMS6);
238 if (
sc!=StatusCode::SUCCESS)
240 return StatusCode::FAILURE;
246 sc=
m_nt->addItem(
"Xi",coeffIndex,0,7);
247 if (
sc!=StatusCode::SUCCESS)
249 return StatusCode::FAILURE;
253 if (
sc!=StatusCode::SUCCESS)
255 return StatusCode::FAILURE;
258 if (hasRawRampContainer) {
259 sc=
m_nt->addItem(
"RampRMS",RampRMS,-1000,1000);
260 if (
sc!=StatusCode::SUCCESS)
262 return StatusCode::FAILURE;
269 ATH_MSG_WARNING(
"Failed to dyn-cast to ILArRamp to LArRampComplete. Cannot apply corrections");
275 if (
sc.isFailure()) {
276 ATH_MSG_ERROR(
"Failed to apply corrections to LArRampComplete!" );
279 ATH_MSG_INFO(
"Applied corrections to LArRampComplete" );
300 return StatusCode::FAILURE;
303 unsigned cellCounter=0;
304 std::set<std::pair<HWIdentifier,unsigned> > cellDone;
305 if (hasRawRampContainer) {
311 if (
sc!=StatusCode::SUCCESS || !rawRampContainer) {
315 for (
const LArRawRamp* rawramp : *rawRampContainer) {
316 const std::vector<LArRawRamp::RAMPPOINT_t>& singleRamp=rawramp->theRamp();
318 for (DACIndex=0;DACIndex<singleRamp.size();DACIndex++) {
319 SampleMax[DACIndex] = singleRamp[DACIndex].iMaxSample;
320 TimeMax[DACIndex] = singleRamp[DACIndex].TimeMax;
321 ADC[DACIndex] = singleRamp[DACIndex].ADC;
322 NTriggers[DACIndex] = singleRamp[DACIndex].NTriggers;
323 DAC[DACIndex] = singleRamp[DACIndex].DAC;
327 if ( singleRamp[DACIndex].Samples.empty() || singleRamp[DACIndex].RMS.empty() ) {
331 Sample0[DACIndex]=singleRamp[DACIndex].Samples[0];
332 Sample1[DACIndex]=singleRamp[DACIndex].Samples[1];
333 Sample2[DACIndex]=singleRamp[DACIndex].Samples[2];
334 Sample3[DACIndex]=singleRamp[DACIndex].Samples[3];
335 Sample4[DACIndex]=singleRamp[DACIndex].Samples[4];
336 if(singleRamp[DACIndex].Samples.size()>5) Sample5[DACIndex]=singleRamp[DACIndex].Samples[5];
337 if(singleRamp[DACIndex].Samples.size()>6) Sample6[DACIndex]=singleRamp[DACIndex].Samples[6];
339 RMS0[DACIndex]=singleRamp[DACIndex].RMS[0];
340 RMS1[DACIndex]=singleRamp[DACIndex].RMS[1];
341 RMS2[DACIndex]=singleRamp[DACIndex].RMS[2];
342 RMS3[DACIndex]=singleRamp[DACIndex].RMS[3];
343 RMS4[DACIndex]=singleRamp[DACIndex].RMS[4];
344 if(singleRamp[DACIndex].
RMS.size()>5) RMS5[DACIndex]=singleRamp[DACIndex].RMS[5];
345 if(singleRamp[DACIndex].
RMS.size()>6) RMS6[DACIndex]=singleRamp[DACIndex].RMS[6];
355 if (ramp &&
cabling->isOnlineConnected(chid)) {
359 cellDone.insert(std::make_pair(chid,
igain));
364 if (rampcoeff.size()==0) {
366 " channel=" <<
static_cast<long>(
m_channel) <<
" gain=" <<
igain );
368 for (coeffIndex=0;coeffIndex<rampcoeff.size();coeffIndex++)
coeffs[coeffIndex]=rampcoeff[coeffIndex];
369 nDAC = singleRamp.size();
370 nCoeff = rampcoeff.size();
372 if (nDAC>1 && nCoeff>0) {
375 for (
unsigned iDAC=1;iDAC<nDAC;iDAC++) {
376 double fittedResult=0;
377 for (
unsigned icoeff=0;icoeff<nCoeff;icoeff++)
379 rampDev+=(fittedResult-DAC[iDAC])*(fittedResult-DAC[iDAC]);
381 RampRMS=1./(nDAC-1)*sqrt(rampDev);
387 if (
sc!=StatusCode::SUCCESS) {
389 return StatusCode::FAILURE;
406 if (
cabling->isOnlineConnected(chid)) {
408 if ( !cellDone.empty() && cellDone.contains(std::make_pair(chid,
gain)) )
continue;
411 if (rampcoeff.size()==0)
continue;
412 cellIndex = cellCounter;
414 for (coeffIndex=0;coeffIndex<rampcoeff.size();coeffIndex++)
coeffs[coeffIndex]=rampcoeff[coeffIndex];
418 if (
sc!=StatusCode::SUCCESS) {
420 return StatusCode::FAILURE;
439 for(;itUndo!=itUndo_e;itUndo++) {
443 const std::vector<float>& rampcoeff=itUndo->second.m_vRamp;
444 if (rampcoeff.empty())
447 cellIndex = cellCounter;
450 for (coeffIndex=0;coeffIndex<rampcoeff.size();coeffIndex++)
coeffs[coeffIndex]=rampcoeff[coeffIndex];
454 if (
sc!=StatusCode::SUCCESS) {
456 return StatusCode::FAILURE;
463 if (rampComplete_nc) {
465 ATH_MSG_INFO(
"Reverted corrections of LArRampComplete container");
469 return StatusCode::SUCCESS;