ATLAS Offline Software
Loading...
Searching...
No Matches
LArCompleteToFlat.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
12
17
20
22
25
28#include "CoralBase/Blob.h"
29
32
34
36// Public methods:
38
39// Constructors
41LArCompleteToFlat::LArCompleteToFlat( const std::string& name,
42 ISvcLocator* pSvcLocator ) :
43 ::AthReentrantAlgorithm( name, pSvcLocator )
44{
45 declareProperty("OFCInput",m_OFCInput);//="LArOFC");
46 declareProperty("OFCCaliInput",m_OFCCaliInput);//="LArOFC");
47 declareProperty("ShapeInput",m_ShapeInput);//="LArShape");
48 declareProperty("DSPThresholdsInput",m_DSPThresholdsInput);//="LArDSPThresholds");
49 declareProperty("NameOfSet",m_nameOfSet); // for DSPThreshold
50
51 declareProperty("ForceStop",m_forceStop=true);
52
53 declareProperty("FakeEMBPSLowGain",m_fakeEMBPSLowGain=false);
54
55
56}
57
58// Destructor
61
62// Athena Algorithm's Hooks
65{
66 ATH_CHECK( m_cablingKey.initialize() );
67 ATH_CHECK( m_cablingKeySC.initialize(m_isSC) );
68 ATH_CHECK( m_weightsKeySC.initialize(m_isSC && !m_weightsKeySC.empty()) );
69 return StatusCode::SUCCESS;
70}
71
72
73
75 const std::string& outputName, const unsigned nGain,const bool withFCAL) {
76
77 unsigned nChannels=0;
78 unsigned nCopiedEMPS=0;
79 unsigned nDefault=0;
80
81 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
82 spec->extend(blobName, "blob");
83 spec->extend<unsigned>("version");
85 for (unsigned gain=0;gain<nGain;++gain) {
86 coral::AttributeList* attrList = new coral::AttributeList(*spec);
87 (*attrList)["version"].setValue(0U);
88 coral::Blob& blob=(*attrList)[blobName].data<coral::Blob>();
89 blob.resize(m_hashMax*sizeof(float));
90 float* pblob=static_cast<float*>(blob.startingAddress());
91 for (unsigned hs=0;hs<m_hashMax;++hs) {
92 const HWIdentifier chid=m_onlineID->channel_Id(hs);
93 float value;
94 if (!withFCAL && m_onlineID->isFCALchannel(chid)) {
95 value=1.0; //Fill fcal channels with 1.0. for MPhysOverMcal
96 }
97 else
98 value=input->get(chid,gain).m_data;
99
100 if (value<0 && gain==2 && m_fakeEMBPSLowGain) {
101 //Fill medium gain for EMB PS low gain
102 value=input->get(chid,1).m_data;
103 ++nCopiedEMPS;
104 }
105 if (value < 0) {
106 errIfConnected(chid,gain,blobName);
107 value=1.0; //Default vaue is 1.0, since these are multiplicative constants
108 ++nDefault;
109 }
110 pblob[hs]=value;
111 ++nChannels;
112 }
113 unsigned coolChan=gain;
114 //Special case: Store single-gain constant in channel 1
115 //To avoid AttrList vs AttrListCollection confusion in Athena DB infrastructure
116 if (nGain==1) coolChan=1;
117
118 coll->add(coolChan,*attrList);
119 //delete attrList;//???
120 }
121
122 ATH_MSG_INFO( "Converted " << blobName << " to inline storage. Total number of channels=" << nChannels );
123 ATH_MSG_INFO( "Number of channels filled with default value (1.0) " << nDefault << " (including disconnected)" );
124 if (nCopiedEMPS)
125 ATH_MSG_INFO( "\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
126 StatusCode sc=detStore()->record(coll,outputName);
127 if (sc.isFailure()) {
128 ATH_MSG_ERROR( "Failed to record CondAttrListCollection with key" << outputName );
129 return nullptr;
130 }
131 return coll;
132}
133
134
135
136CondAttrListCollection* LArCompleteToFlat::pedestalFlat(const ILArPedestal* input, const std::string& outputName) {
137 ATH_MSG_INFO("LArCompleteToFlat::pedestalFlat, starting");
138
139 unsigned nChannels=0;
140 unsigned nCopiedEMPS=0;
141
142 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
143 spec->extend("Pedestal", "blob");
144 spec->extend("PedestalRMS", "blob");
145 spec->extend<unsigned>("version");
146
148
149 const unsigned nGain = m_isSC ? 1 : 3;
150 for (unsigned gain=0;gain<nGain;++gain) {
151 coral::AttributeList* attrList = new coral::AttributeList(*spec);
152 (*attrList)["version"].setValue(0U);
153 coral::Blob& blobPed=(*attrList)["Pedestal"].data<coral::Blob>();
154 coral::Blob& blobRMS=(*attrList)["PedestalRMS"].data<coral::Blob>();
155 blobPed.resize(m_hashMax*sizeof(float));
156 blobRMS.resize(m_hashMax*sizeof(float));
157 float* pblobPed=static_cast<float*>(blobPed.startingAddress());
158 float* pblobRMS=static_cast<float*>(blobRMS.startingAddress());
159 int nDefault=0;
160 for (unsigned hs=0;hs<m_hashMax;++hs) {
161 const HWIdentifier chid=m_onlineID->channel_Id(hs);
162 float ped=input->pedestal(chid,gain);
163 float pedRMS=input->pedestalRMS(chid,gain);
164 if (gain==0){
165 if (ped<0){
166 ped = 1000;
167 pedRMS = 1;
168 ++nDefault;
169 }
170
171
172 }
173 if (ped<0 && gain==2 && m_fakeEMBPSLowGain) {
174 ped=input->pedestal(chid,1);
175 pedRMS=input->pedestalRMS(chid,1);
176 ++nCopiedEMPS;
177 }
178
179 pblobPed[hs]=ped;
180 pblobRMS[hs]=pedRMS;
181 ++nChannels;
182 }//end loop over hash ids
183 collPed->add(gain,*attrList);
184 ATH_MSG_INFO( "Number of channels filled with default Pedestal (1000) and PedestalRMS (1) "<< nDefault << " (including disconnected)" );
185 }//end loop over gains
186
187 StatusCode sc=detStore()->record(collPed,outputName);//"/LAR/ElecCalibFlat/Pedestal");
188 if (sc.isFailure()) {
189 ATH_MSG_ERROR( "Failed to record CondAttrListCollection for pedestal with key " << outputName );
190 return nullptr;
191 }
192 ATH_MSG_INFO( "Converted Pedestal to inline storage. Total number of channels=" << nChannels );
193 if (nCopiedEMPS)
194 ATH_MSG_INFO( "\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
195
196 return collPed;
197}
198
199
200CondAttrListCollection* LArCompleteToFlat::ofcFlat(const ILArOFC* input, const std::string& outputName, const LArfSamplSC* weights) {
201
202 ATH_MSG_INFO("LArCompleteToFlat::ofcFlat, starting");
203 unsigned nChannels=0;
204 unsigned nCopiedEMPS=0;
205 unsigned nDefault=0;
206
207 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
208 spec->extend("OFCa", "blob");
209 spec->extend("OFCb", "blob");
210 spec->extend("TimeOffset","blob");
211 spec->extend<unsigned>("nSamples");
212 spec->extend<unsigned>("version");
214 int phase = 0;
215 const unsigned nGain = m_isSC ? 1 : 3;
216 for (unsigned gain=0;gain<nGain;++gain) {
217
218 //Auto-detect the number of samples (at least in theory, could be different for each gain)
219 unsigned nSamples=0;
220 for (unsigned hs=0;hs<m_hashMax && nSamples==0;++hs) {
221 const HWIdentifier chid=m_onlineID->channel_Id(hs);
222 LArOFCFlat::OFCRef_t ofca= input->OFC_a(chid,gain);
223 if ( input->nTimeBins(chid,gain) > 23 ){
224 phase = 23;
225 ofca = input->OFC_a(chid,gain,phase);
226 }
227
228 nSamples=ofca.size();
229 }
230 if (nSamples==0) {
231 ATH_MSG_ERROR( "All input OFCs for gain " << gain << " have 0 samples!" );
232 continue;//jump to the next gain
233 }
234
235 ATH_MSG_INFO( "Gain " << gain <<": Found " << nSamples << " OFC samples in input data" );
236
237 coral::AttributeList* attrList = new coral::AttributeList(*spec);
238 (*attrList)["version"].setValue(0U);
239 coral::Blob& ofcaBlob=(*attrList)["OFCa"].data<coral::Blob>();
240 coral::Blob& ofcbBlob=(*attrList)["OFCb"].data<coral::Blob>();
241 coral::Blob& toBlob=(*attrList)["TimeOffset"].data<coral::Blob>();
242
243 (*attrList)["nSamples"].setValue(nSamples);
244
245 ofcaBlob.resize(m_hashMax*sizeof(float)*nSamples);
246 ofcbBlob.resize(m_hashMax*sizeof(float)*nSamples);
247 toBlob.resize(m_hashMax*sizeof(float));
248 float* pOfca=static_cast<float*>(ofcaBlob.startingAddress());
249 float* pOfcb=static_cast<float*>(ofcbBlob.startingAddress());
250 float* pTimeOffset=static_cast<float*>(toBlob.startingAddress());
251 for (unsigned hs=0;hs<m_hashMax;++hs) {
252 const HWIdentifier chid=m_onlineID->channel_Id(hs);
253 LArOFCFlat::OFCRef_t ofca= input->OFC_a(chid,gain,phase);
254 LArOFCFlat::OFCRef_t ofcb= input->OFC_b(chid,gain,phase);
255 float timeOffset=input->timeOffset(chid,gain);
256 if (ofca.size()==0 && gain==2 && m_fakeEMBPSLowGain) {
257 ofca= input->OFC_a(chid,1,phase);
258 ofcb= input->OFC_b(chid,1,phase);
259 timeOffset=input->timeOffset(chid,1);
260 ++nCopiedEMPS;
261 }
262
263 if (ofca.size()==nSamples) {
264 for (unsigned i=0;i<nSamples;++i) {
265 if(std::isnan(ofca[i]) || std::isinf(ofca[i]) || (m_isSC && fabs(ofca[i])> 10.)) { // protection
266 pOfca[hs*nSamples+i]=1.0;
267 } else {
268 pOfca[hs*nSamples+i]=ofca[i];
269 }
270 }
271 }
272 else {
273 std::stringstream message;
274 message <<"Number of samples don't match. Expect " << nSamples << ", got " << ofca.size() << ".";
275 errIfConnected(chid,gain,"OFCa", message.str().c_str());
276 for (unsigned i=0;i<nSamples;++i) {
277 pOfca[hs*nSamples+i]=1.0;
278 }
279 ++nDefault;
280 }
281
282 if (ofcb.size()==nSamples) {
283 for (unsigned i=0;i<nSamples;++i) {
284 if(std::isnan(ofcb[i]) || std::isinf(ofcb[i]) || (m_isSC && fabs(ofcb[i])> 100.)) { // protection
285 pOfcb[hs*nSamples+i]=1.0;
286 } else {
287 pOfcb[hs*nSamples+i]=ofcb[i];
288 }
289 // FIXME: it should be replaced by proper conditions per channel
290 // HERE - multiplying HEC OFCb by 1.5 for SCs
291 // https://its.cern.ch/jira/browse/ATLLARONL-1784
292 //if (m_isSC && m_onlineID->isHECchannel(chid)){
293 // pOfcb[hs*nSamples+i]=ofcb[i]*1.5;
294 // ATH_MSG_WARNING("NOTE: this OFC for channel "<<chid<<" was multiplied by 1.5. This should be a HEC SC("<<m_onlineID->channel_name(chid)<<"). Was "<<ofcb[i]<<" now "<<pOfcb[hs*nSamples+i]);
295 //}
296 if (m_isSC && weights) pOfcb[hs*nSamples+i] *= weights->FSAMPL(chid);
297 if (weights && weights->FSAMPL(chid) != 1.) ATH_MSG_WARNING("NOTE: this OFC for channel "<<chid<<" was multiplied by "<<weights->FSAMPL(chid)<<" This should be a SC("<<m_onlineID->channel_name(chid)<<"). Was "<<ofcb[i]<<" now "<<pOfcb[hs*nSamples+i]);
298 }
299 }
300 else {
301 std::stringstream message;
302 message <<"Number of samples don't match. Expect " << nSamples << ", got " << ofcb.size() << ".";
303 errIfConnected(chid,gain,"OFCb", message.str().c_str());
304 for (unsigned i=0;i<nSamples;++i) {
305 pOfcb[hs*nSamples+i]=1.0;
306 }
307 }
308 pTimeOffset[hs]=timeOffset;
309 ++nChannels;
310
311 }//end loop over hash ids
312 collOFC->add(gain,*attrList);
313 }//end loop over gains
314
315 StatusCode sc=detStore()->record(collOFC,outputName);//"/LAR/ElecCalibFlat/OFC");
316 if (sc.isFailure()) {
317 ATH_MSG_ERROR( "Failed to record CondAttrListCollection OFC with key " << outputName );
318 return nullptr;
319 }
320
321 ATH_MSG_INFO( "Converted OFCs to inline storage. Total number of channels=" << nChannels );
322 ATH_MSG_INFO( "Number of channels filled with default OFCs {1,1,1,1} " << nDefault << " (including disconnected)" );
323 if (nCopiedEMPS)
324 ATH_MSG_INFO( "\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
325 return collOFC;
326}
327
328
329CondAttrListCollection* LArCompleteToFlat::shapeFlat(const LArShapeComplete* input, const std::string& outputName) {
330
331 ATH_MSG_INFO("LArCompleteToFlat::shapeFlat, starting");
332
333 unsigned nChannels=0;
334 unsigned nCopiedEMPS=0;
335 unsigned nDefault=0;
336
337 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
338 spec->extend("Shape", "blob");
339 spec->extend("ShapeDer", "blob");
340 spec->extend("TimeOffset","blob");
341 spec->extend<unsigned>("nSamples");
342 spec->extend<unsigned>("version");
344
345 const unsigned nGain = m_isSC ? 1 : 3;
346 for (unsigned gain=0;gain<nGain;++gain) {
347
348 unsigned nSamples=0;
349 for (unsigned hs=0;hs<m_hashMax && nSamples==0;++hs) {
350 const HWIdentifier chid=m_onlineID->channel_Id(hs);
351 ILArShape::ShapeRef_t shape= input->Shape(chid,gain);
352 nSamples=shape.size();
353 }
354 if (nSamples==0) {
355 ATH_MSG_ERROR( "All input Shapes for gain " << gain << " have 0 samples!" );
356 continue;//jump to the next gain
357 }
358
359 ATH_MSG_INFO( "Gain " << gain <<": Found " << nSamples << " shape samples in input data" );
360
361 coral::AttributeList* attrList = new coral::AttributeList(*spec);
362 (*attrList)["version"].setValue(0U);
363 coral::Blob& shapeBlob=(*attrList)["Shape"].data<coral::Blob>();
364 coral::Blob& shapeDerBlob=(*attrList)["ShapeDer"].data<coral::Blob>();
365 coral::Blob& toBlob=(*attrList)["TimeOffset"].data<coral::Blob>();
366
367 (*attrList)["nSamples"].setValue(nSamples);
368
369 shapeBlob.resize(m_hashMax*sizeof(float)*nSamples);
370 shapeDerBlob.resize(m_hashMax*sizeof(float)*nSamples);
371 toBlob.resize(m_hashMax*sizeof(float));
372 float* pShape=static_cast<float*>(shapeBlob.startingAddress());
373 float* pShapeDer=static_cast<float*>(shapeDerBlob.startingAddress());
374 float* pTimeOffset=static_cast<float*>(toBlob.startingAddress());
375 for (unsigned hs=0;hs<m_hashMax;++hs) {
376 const HWIdentifier chid=m_onlineID->channel_Id(hs);
377
378 ILArShape::ShapeRef_t shape= input->Shape(chid,gain);
379 ILArShape::ShapeRef_t shapeDer= input->ShapeDer(chid,gain);
380 float timeOffset=input->timeOffset(chid,gain);
381 if (shape.size()==0 && gain==2 && m_fakeEMBPSLowGain) {
382 shape=input->Shape(chid,1);
383 shapeDer=input->ShapeDer(chid,1);
384 timeOffset=input->timeOffset(chid,1);
385 ++nCopiedEMPS;
386 }
387
388 if (shape.size()==nSamples) {
389 for (unsigned i=0;i<nSamples;++i) {
390 if(std::isnan(shape[i]) || std::isinf(shape[i])) {
391 pShape[hs*nSamples+i]=0.0;
392 } else {
393 pShape[hs*nSamples+i]=shape[i];
394 }
395 }
396 }
397 else {
398 std::stringstream message;
399 message <<"Number of samples don't match. Expect " << nSamples << ", got " << shape.size() << ".";
400 errIfConnected(chid,gain,"Shape", message.str().c_str());
401 for (unsigned i=0;i<nSamples;++i) {
402 pShape[hs*nSamples+i]=0.0;
403 }
404 ++nDefault;
405 }
406
407
408 if (shapeDer.size()==nSamples) {
409 for (unsigned i=0;i<nSamples;++i) {
410 if(std::isnan(shapeDer[i]) || std::isinf(shapeDer[i])) {
411 pShapeDer[hs*nSamples+i]=0.0;
412 } else {
413 pShapeDer[hs*nSamples+i]=shapeDer[i];
414 }
415 }
416 }
417 else {
418 std::stringstream message;
419 message <<"Number of samples don't match. Expect " << nSamples << ", got " << shapeDer.size() << ".";
420 errIfConnected(chid,gain,"ShapeDer", message.str().c_str());
421 for (unsigned i=0;i<nSamples;++i) {
422 pShapeDer[hs*nSamples+i]=0.0;
423 }
424 }
425 pTimeOffset[hs]=timeOffset;
426 ++nChannels;
427
428 }//end loop over hash ids
429 coll->add(gain,*attrList);
430 }//end loop over gains
431
432 StatusCode sc=detStore()->record(coll,outputName);//"/LAR/ElecCalibFlat/SHAPE");
433 if (sc.isFailure()) {
434 ATH_MSG_ERROR( "Failed to record CondAttrListCollection Shape with key " << outputName );
435 return nullptr;
436 }
437
438 ATH_MSG_INFO( "Converted Shapes to inline storage. Total number of channels=" << nChannels );
439 ATH_MSG_INFO( "Number of channels filled with default shape {0,0,0,0} " << nDefault << " (including disconnected)" );
440 if (nCopiedEMPS)
441 ATH_MSG_INFO( "\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
442
443 return coll;
444}
445
446
447
448CondAttrListCollection* LArCompleteToFlat::rampFlat(const ILArRamp* input, const std::string& outputName) {
449
450 ATH_MSG_INFO("LArCompleteToFlat::rampFlat, starting");
451
452 unsigned nChannels=0;
453 unsigned nCopiedEMPS=0;
454 unsigned nDefault=0;
455
456 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
457 spec->extend("RampVec", "blob");
458 spec->extend<unsigned>("nPoints");
459 spec->extend<unsigned>("version");
461
462 std::vector<float> defaultRamp={0.0,1.0};
463
464 const LArOnOffIdMapping* cabling(nullptr);
465 if(m_isSC){
467 cabling=*cablingHdl;
468 }else{
470 cabling=*cablingHdl;
471 }
472 if(!cabling) {
473 ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() );
474 return coll;
475 }
476
477 const unsigned nGain = m_isSC ? 1 : 3;
478 for (unsigned gain=0;gain<nGain;++gain) {
479
480 unsigned nPoints=0;
481 for (unsigned hs=0;hs<m_hashMax && nPoints==0;++hs) {
482 const HWIdentifier chid=m_onlineID->channel_Id(hs);
483 const ILArRamp::RampRef_t ramp= input->ADC2DAC(chid,gain);
484 nPoints=ramp.size();
485 }
486 if (nPoints==0) {
487 ATH_MSG_ERROR( "All input Ramps for gain " << gain << " have 0 points!" );
488 continue;//jump to the next gain
489 }
490
491 defaultRamp.resize(nPoints,0.0); //fill remaining points if needed
492 ATH_MSG_INFO( "Gain " << gain << ": Found a ramp polynom of degree " << nPoints << " in input data" );
493 coral::AttributeList* attrList = new coral::AttributeList(*spec);
494 (*attrList)["version"].setValue(0U);
495 coral::Blob& blobRamp=(*attrList)["RampVec"].data<coral::Blob>();
496 (*attrList)["nPoints"].setValue(nPoints);
497 blobRamp.resize(m_hashMax*sizeof(float)*nPoints);
498 float* pblobRamp=static_cast<float*>(blobRamp.startingAddress());
499
500 for (unsigned hs=0;hs<m_hashMax;++hs) {
501 const HWIdentifier chid=m_onlineID->channel_Id(hs);
502 std::vector<float> rampVec(input->ADC2DAC(chid,gain).asVector());
503 if(rampVec.size()>=2 && rampVec[1]>500) {
504 ATH_MSG_WARNING("Protection against crazy ramp values, set 500");
505 rampVec[1]=500.;
506 }
507 if (rampVec.empty() && gain==2 && m_fakeEMBPSLowGain && cabling->isOnlineConnected(chid) ) {
508 rampVec=input->ADC2DAC(chid,1).asVector();
509 if(rampVec.empty()) {
510 ATH_MSG_WARNING("Filling EMBPS ramp with default values 0,10");
511 rampVec.resize(2);
512 rampVec[0]=0.;
513 rampVec[1]=10.;
514 } else {
515 rampVec[1]*=10.0;
516 if(rampVec[1]>500) {
517 ATH_MSG_WARNING("Protection against crazy ramp values, set 500");
518 rampVec[1]=500.;
519 }
520 }
521 ++nCopiedEMPS;
522 }
523
524 if (rampVec.size()>=nPoints) {
525 for (size_t i=0;i<nPoints;++i) {
526 pblobRamp[nPoints*hs+i]=rampVec[i];
527 }
528 }
529 else {
530 std::stringstream message;
531 message <<"Polynom degree doesn't match. Expect " << nPoints << ", got " << rampVec.size() << ".";
532 errIfConnected(chid,gain,"Ramp", message.str().c_str());
533 for (size_t i=0;i<nPoints;++i) {
534 pblobRamp[nPoints*hs+i]=defaultRamp[i];
535 }
536 ++nDefault;
537 }
538 ++nChannels;
539 }//end loop over hash ids
540 coll->add(gain,*attrList);
541 }//end loop over gains
542
543 StatusCode sc=detStore()->record(coll,outputName);//"/LAR/ElecCalibFlat/Ramp");
544 if (sc.isFailure()) {
545 ATH_MSG_ERROR( "Failed to record CondAttrListCollection for ramp with key " << outputName );
546 return nullptr;
547 }
548
549 ATH_MSG_INFO( "Converted Ramps to inline storage. Total number of channels " << nChannels );
550 ATH_MSG_INFO( "Number of channels filled with default ramp {0,1} " << nDefault << " (including disconnected)" );
551 if (nCopiedEMPS)
552 ATH_MSG_INFO( "\t Number of low gain EMBPS channels copied from medium gain (applied factor 10)" << nCopiedEMPS );
553
554
555 return coll;
556}
557
558
559CondAttrListCollection* LArCompleteToFlat::DAC2uAFlat(const ILArDAC2uA* input, const std::string& outputName) {
560 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
561 spec->extend("DAC2uA", "blob");
562 spec->extend<unsigned>("version");
564 coral::AttributeList* attrList = new coral::AttributeList(*spec);
565 (*attrList)["version"].setValue(0U);
566 coral::Blob& blob=(*attrList)["DAC2uA"].data<coral::Blob>();
567 blob.resize(m_hashMax*sizeof(float));
568 float* pblob=static_cast<float*>(blob.startingAddress());
569 for (unsigned hs=0;hs<m_hashMax;++hs) {
570 const HWIdentifier chid=m_onlineID->channel_Id(hs);
571 pblob[hs]=input->DAC2UA(chid);
572 }
573 coll->add(1,*attrList);
574 //delete attrList;//???
575 StatusCode sc=detStore()->record(coll,outputName);
576 if (sc.isFailure()) {
577 ATH_MSG_ERROR( "Failed to record CondAttrListCollection with key" << outputName );
578 return nullptr;
579 }
580 return coll;
581}
582
583
584CondAttrListCollection* LArCompleteToFlat::uA2MeVFlat(const ILAruA2MeV* input, const std::string& outputName) {
585 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
586 spec->extend("uA2MeV", "blob");
587 spec->extend<unsigned>("version");
589 coral::AttributeList* attrList = new coral::AttributeList(*spec);
590 (*attrList)["version"].setValue(0U);
591 coral::Blob& blob=(*attrList)["uA2MeV"].data<coral::Blob>();
592 blob.resize(m_hashMax*sizeof(float));
593 float* pblob=static_cast<float*>(blob.startingAddress());
594 for (unsigned hs=0;hs<m_hashMax;++hs) {
595 const HWIdentifier chid=m_onlineID->channel_Id(hs);
596 pblob[hs]=input->UA2MEV(chid);
597 }
598 coll->add(1,*attrList);
599 //delete attrList;//???
600 StatusCode sc=detStore()->record(coll,outputName);
601 if (sc.isFailure()) {
602 ATH_MSG_ERROR( "Failed to record CondAttrListCollection with key" << outputName );
603 return nullptr;
604 }
605 return coll;
606}
607
609
610 coral::AttributeListSpecification* spec = new coral::AttributeListSpecification();
611 spec->extend("tQThr", "blob");
612 spec->extend("samplesThr", "blob");
613 spec->extend("trigSumThr","blob");
614 //spec->extend<unsigned>("version");
615 spec->extend("Name","string");
616
617 coral::AttributeList* attrList = new coral::AttributeList(*spec);
618 //(*attrList)["version"].setValue(0U);
619 (*attrList)["Name"].setValue(m_nameOfSet);
620 coral::Blob& QBlob=(*attrList)["tQThr"].data<coral::Blob>();
621 coral::Blob& SamplesBlob=(*attrList)["samplesThr"].data<coral::Blob>();
622 coral::Blob& TrigBlob=(*attrList)["trigSumThr"].data<coral::Blob>();
623
624 QBlob.resize(m_hashMax*sizeof(float));
625 SamplesBlob.resize(m_hashMax*sizeof(float));
626 TrigBlob.resize(m_hashMax*sizeof(float));
627 float* ptQThr=static_cast<float*>(QBlob.startingAddress());
628 float* pSamplesThr=static_cast<float*>(SamplesBlob.startingAddress());
629 float* pTrigThr=static_cast<float*>(TrigBlob.startingAddress());
630
631 for (unsigned hs=0;hs<m_hashMax;++hs) {
632 const HWIdentifier chid=m_onlineID->channel_Id(hs);
633
634 ptQThr[hs] = input->tQThr(chid);
635 pSamplesThr[hs] = input->samplesThr(chid);
636 pTrigThr[hs] = input->trigSumThr(chid);
637
638 ATH_MSG_INFO( "hwid: "<<chid.getString()<<" "<<hs<<" | "<<ptQThr[hs]<<" : "<<pSamplesThr[hs]<<" | "<<pTrigThr[hs] );
639 }//end loop over hash ids
640
641 AthenaAttributeList* coll=new AthenaAttributeList(*attrList);
642
643 StatusCode sc=detStore()->record(coll,outputName);
644 if (sc.isFailure()) {
645 ATH_MSG_ERROR( "Failed to record AthenaAttributeList DSPThresholds with key " << outputName );
646 return nullptr;
647 }
648
649 return coll;
650}
651
652
653
655 std::string flatName = "/LAR/ElecCalibFlat";
656 StatusCode sc;
657 if(m_isSC){
658 flatName += "SC";
659 const LArOnline_SuperCellID* ll = nullptr;
660 sc = detStore()->retrieve(ll, "LArOnline_SuperCellID");
661 if (sc.isFailure()) {
662 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
663 return StatusCode::FAILURE;
664 }
665 else {
666 m_onlineID = static_cast<const LArOnlineID_Base*>(ll);
667 ATH_MSG_DEBUG("Found the LArOnlineID helper");
668 }
669 }else{
670 const LArOnlineID* ll = nullptr;
671 sc = detStore()->retrieve(ll, "LArOnlineID");
672 if (sc.isFailure()) {
673 ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
674 return StatusCode::FAILURE;
675 }
676 else {
677 m_onlineID = static_cast<const LArOnlineID_Base*>(ll);
678 ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
679 }
680
681 }
682
683 m_hashMax=m_onlineID->channelHashMax();
684
685 if (!m_uA2MeVInput.empty()) {
686 const ILAruA2MeV* uA2MeVComplete = nullptr;
687 sc=detStore()->retrieve(uA2MeVComplete,m_uA2MeVInput);
688 if (sc.isFailure()) {
689 if(m_forceStop) {
690 ATH_MSG_ERROR( "Failed to get LAruA2MeV with key " << m_uA2MeVInput );
691 return sc;
692 } else {
693 ATH_MSG_WARNING( "Will not process LAruA2MeV" );
694 }
695 } else {
696 uA2MeVFlat(uA2MeVComplete, flatName+"/uA2MeV");
697 }
698 }//end if have m_uA2MeV
699
700
701 if (!m_DAC2uAInput.empty()) {
702 const ILArDAC2uA* DAC2uAComplete = nullptr;
703 sc=detStore()->retrieve(DAC2uAComplete,m_DAC2uAInput);
704 if (sc.isFailure()) {
705 if(m_forceStop) {
706 ATH_MSG_ERROR( "Failed to get LArDAC2uA with key " << m_DAC2uAInput );
707 return sc;
708 } else {
709 ATH_MSG_WARNING( "Will not process LArDAC2uA" );
710 }
711 } else {
712 DAC2uAFlat(DAC2uAComplete, flatName+"/DAC2uA");
713 }
714 }//end if have m_DAC2uAInput
715
716 if (!m_MphysOverMcalInput.empty()) {
717 const LArMphysOverMcalComplete* MphysOverMcalComplete = nullptr;
718 sc=detStore()->retrieve(MphysOverMcalComplete,m_MphysOverMcalInput);
719 if (sc.isFailure()) {
720 if(m_forceStop) {
721 ATH_MSG_ERROR( "Failed to get LArMphysOverMcal with key " << m_MphysOverMcalInput );
722 return sc;
723 } else {
724 ATH_MSG_WARNING( "Will not process LArMphysOverMcal" );
725 }
726 } else {
727 const int nGain = m_isSC ? 1 : 3;
728 //const bool wfcal = m_isSC ? true : false;
729 singleFloatFlat("MphysOverMcal", MphysOverMcalComplete, flatName+"/MphysOverMcal",nGain,false); //No MphysOverMCal for FCAL
730 }
731 }//end if have m_MphysOverMcalInput
732
733
734 if (!m_HVScaleCorrInput.empty()) {
735 const LArHVScaleCorrComplete* HVScaleCorrComplete = nullptr;
736 sc=detStore()->retrieve(HVScaleCorrComplete,m_HVScaleCorrInput);
737 if (sc.isFailure()) {
738 if(m_forceStop) {
739 ATH_MSG_ERROR( "Failed to get LArHVScaleCorr with key " << m_HVScaleCorrInput );
740 return sc;
741 } else {
742 ATH_MSG_WARNING( "Will not process LArHVScaleCorr" );
743 }
744 } else {
745 singleFloatFlat("HVScaleCorr", HVScaleCorrComplete, flatName+"/HVScaleCorr",1);
746 }
747 }//end if have m_HVScaleCorrInput
748
749 if (!m_PedestalInput.empty()) {
750 const LArPedestalComplete* pedComplete = nullptr;
751 sc=detStore()->retrieve(pedComplete,m_PedestalInput);
752 if (sc.isFailure()) {
753 if(m_forceStop) {
754 ATH_MSG_ERROR( "Failed to get LArPedestal" );
755 return sc;
756 } else {
757 ATH_MSG_WARNING( "Will not process LArPedestal" );
758 }
759 } else {
760 pedestalFlat(pedComplete,flatName+"/Pedestal");
761
762 /*
763 CondAttrListCollection* coll=pedestalFlat(pedComplete,"/LAR/ElecCalibFlat/Pedestal");
764 LArPedestalFlat* pf=new LArPedestalFlat(coll);
765
766 sc=detStore()->record(pf,"PedestalFlat");
767 if (sc.isFailure()) {
768 ATH_MSG_ERROR( "Failed to record LArPedestalFlat" );
769 }
770
771 ILArPedestal* iped=pf;
772 sc=detStore()->symLink(pf,iped);
773 if (sc.isFailure()) {
774 ATH_MSG_ERROR( "Failed to symlink LArPedestalFlat" );
775 }
776 }
777 */
778 }
779 }//end if have m_pedestalInput
780
781 //OFC:
782 if (!m_OFCInput.empty()) {
783 const LArOFCComplete* ofcComplete = nullptr;
784 sc=detStore()->retrieve(ofcComplete,m_OFCInput);
785 if (sc.isFailure()) {
786 if(m_forceStop) {
787 ATH_MSG_ERROR( "Failed to get LArOFCComplete object" );
788 return sc;
789 } else {
790 ATH_MSG_WARNING( "Will not process LArOFCComplete" );
791 }
792 } else {
793 const LArfSamplSC* weightsComplete(nullptr);
794 if(m_isSC && !m_weightsKeySC.empty()) {
796 weightsComplete=*wHdl;
797 if(!weightsComplete) {
798 ATH_MSG_WARNING("Do not have OFCb weights !!!! Not applying");
799 }
800 }
801 ofcFlat(ofcComplete,flatName+"/OFC",weightsComplete);
802 }
803 }//end have m_OFCInput
804 if (!m_OFCCaliInput.empty()) {
805 const LArOFCComplete* ofcComplete = nullptr;
806 sc=detStore()->retrieve(ofcComplete,m_OFCCaliInput);
807 if (sc.isFailure()) {
808 if(m_forceStop) {
809 ATH_MSG_ERROR( "Failed to get LArOFCComplete object (cali)" );
810 return sc;
811 } else {
812 ATH_MSG_WARNING( "Will not process LArOFCComplete (cali)" );
813 }
814 } else {
815 ofcFlat(ofcComplete,flatName+"/OFCCali");
816
817 }
818 }//end have m_OFCInput
819 //Shape:
820 if (!m_ShapeInput.empty()) {
821 const LArShapeComplete* shapeComplete = nullptr;
822 sc=detStore()->retrieve(shapeComplete,m_ShapeInput);
823 if (sc.isFailure()) {
824 if(m_forceStop) {
825 ATH_MSG_ERROR( "Failed to get LArShapeComplete object" );
826 return sc;
827 } else {
828 ATH_MSG_WARNING( "Will not process LArShapeComplete" );
829 }
830 } else {
831 shapeFlat(shapeComplete,flatName+"/Shape");
832 /*
833 CondAttrListCollection* coll=shapeFlat(shapeComplete,"/LAR/ElecCalibFlat/Shape");
834
835 LArShapeFlat* sf=new LArShapeFlat(coll);
836
837 sc=detStore()->record(sf,"ShapeFlat");
838 if (sc.isFailure()) {
839 ATH_MSG_ERROR( "Failed to record LArShapeFlat" );
840 }
841
842 ILArShape* ishape=sf;
843 sc=detStore()->symLink(sf,ishape);
844 if (sc.isFailure()) {
845 ATH_MSG_ERROR( "Failed to symlink LArShapeFlat" );
846 }
847 */
848 }
849 }//end if have m_shapeInput
850
851 //Ramp
852 if (!m_RampInput.empty()) {
853 const LArRampComplete* rampComplete = nullptr;
854 sc=detStore()->retrieve(rampComplete,m_RampInput);
855 if (sc.isFailure()) {
856 if(m_forceStop) {
857 ATH_MSG_ERROR( "Failed to get LArRampComplete object" );
858 return sc;
859 } else {
860 ATH_MSG_WARNING( "Will not process LArRampComplete" );
861 }
862 } else {
863 rampFlat(rampComplete,flatName+"/Ramp");
864 }
865 }
866
867 if(!m_DSPThresholdsInput.empty()) {
868 //DSPThresh:
869 const LArDSPThresholdsComplete* DSPTComplete = nullptr;
870 sc=detStore()->retrieve(DSPTComplete,m_DSPThresholdsInput);
871 if (sc.isFailure()) {
872 if(m_forceStop) {
873 ATH_MSG_ERROR( "Failed to get LArDSPThresholdsComplete object" );
874 return sc;
875 } else {
876 ATH_MSG_WARNING( "Will not process LArDSPThresholdsComplete" );
877 }
878 }
879 DSPThresholdsFlat(DSPTComplete,"/LAR/Configuration/DSPThresholdFlat/Templates");
880 /*
881 AthenaAttributeList *cl=DSPThresholdsFlat(DSPTComplete,"/LAR/Configuration/DSPThresholdFlat/Templates");
882
883 LArDSPThresholdsFlat* df;
884 if(cl) {
885 df=new LArDSPThresholdsFlat(cl);
886
887 sc=detStore()->record(df,"DSPThresholdsFlat");
888 if (sc.isFailure()) {
889 ATH_MSG_ERROR( "Failed to record LArDSPThresholdsFlat" );
890 }
891 }
892 */
893 } //end if have m__DSPThresholdsInput
894
895
896 return StatusCode::SUCCESS;
897}
898
899
900
901
902
903void LArCompleteToFlat::errIfConnected(const HWIdentifier chid, const int gain, const char* objName, const char* message) const{
904
905 const LArOnOffIdMapping* cabling(nullptr);
906 if(m_isSC){
908 cabling=*cablingHdl;
909 }else{
911 cabling=*cablingHdl;
912 }
913 if(!cabling) {
914 ATH_MSG_ERROR( "Do not have cabling mapping from key " << m_cablingKey.key() );
915 return;
916 }
917
918 if (cabling->isOnlineConnected(chid)) {
919 if (gain!=2 || !m_onlineID->isEMBPS(chid)) { //No LG Presampler calibration
920 ATH_MSG_ERROR( "No valid " << objName << " found for channel " << m_onlineID->channel_name(chid) << ", gain " << gain << ". ");
921 if (message) ATH_MSG_ERROR( message );
922 ATH_MSG_ERROR( " Filling with default value." );
923 }
924 }
925 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Defines a common ERRORCODE enum for LAr-Calibration objects.
A LArRawConditionsContainer holding thresholds used by the DSP.
static Double_t sc
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
An algorithm that can be simultaneously executed in multiple threads.
An AttributeList represents a logical row of attributes in a metadata table.
This class is a collection of AttributeLists where each one is associated with a channel number.
LArVectorProxy RampRef_t
This class defines the interface for accessing Ramp @stereotype Interface.
Definition ILArRamp.h:31
LArVectorProxy ShapeRef_t
This class defines the interface for accessing Shape (Nsample variable, Dt = 25 ns fixed) @stereotype...
Definition ILArShape.h:26
std::string getString() const
Provide a string form of the identifier - hexadecimal.
CondAttrListCollection * rampFlat(const ILArRamp *input, const std::string &outputName)
std::string m_OFCCaliInput
StringProperty m_DAC2uAInput
CondAttrListCollection * ofcFlat(const ILArOFC *input, const std::string &outputName, const LArfSamplSC *weights=nullptr)
const LArOnlineID_Base * m_onlineID
virtual ~LArCompleteToFlat()
Destructor:
StringProperty m_uA2MeVInput
InputSGKeys.
StringProperty m_MphysOverMcalInput
virtual StatusCode stop() override
virtual StatusCode initialize() override
AthenaAttributeList * DSPThresholdsFlat(const LArDSPThresholdsComplete *input, const std::string &outputName)
CondAttrListCollection * singleFloatFlat(const char *blobName, const LArConditionsContainer< LArSingleFloatP > *input, const std::string &outputName, const unsigned nGain, const bool withFCAL=true)
BooleanProperty m_isSC
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
void errIfConnected(const HWIdentifier chid, const int gain, const char *objName, const char *message=0) const
StringProperty m_RampInput
StringProperty m_PedestalInput
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
std::string m_DSPThresholdsInput
CondAttrListCollection * uA2MeVFlat(const ILAruA2MeV *input, const std::string &outputName)
SG::ReadCondHandleKey< LArfSamplSC > m_weightsKeySC
LArCompleteToFlat()=delete
Default constructor:
CondAttrListCollection * pedestalFlat(const ILArPedestal *input, const std::string &outputName)
StringProperty m_HVScaleCorrInput
CondAttrListCollection * shapeFlat(const LArShapeComplete *input, const std::string &outputName)
CondAttrListCollection * DAC2uAFlat(const ILArDAC2uA *input, const std::string &outputName)
This class implements the ILArHVScaleCorr interface.
This class implements the ILArMphysOverMcal interface.
This class implements the ILArOFC interface.
ILArOFC::OFCRef_t OFCRef_t
Definition LArOFCFlat.h:24
Helper for the Liquid Argon Calorimeter cell identifiers.
This class implements the ILArPedestal interface.
This class implements the ILArShape interface.