28#include "CoralBase/Blob.h"
42 ISvcLocator* pSvcLocator ) :
69 return StatusCode::SUCCESS;
75 const std::string& outputName,
const unsigned nGain,
const bool withFCAL) {
78 unsigned nCopiedEMPS=0;
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>();
90 float* pblob=
static_cast<float*
>(blob.startingAddress());
94 if (!withFCAL &&
m_onlineID->isFCALchannel(chid)) {
98 value=input->get(chid,gain).m_data;
102 value=input->get(chid,1).m_data;
113 unsigned coolChan=gain;
116 if (nGain==1) coolChan=1;
118 coll->add(coolChan,*attrList);
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)" );
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 );
137 ATH_MSG_INFO(
"LArCompleteToFlat::pedestalFlat, starting");
139 unsigned nChannels=0;
140 unsigned nCopiedEMPS=0;
142 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
143 spec->extend(
"Pedestal",
"blob");
144 spec->extend(
"PedestalRMS",
"blob");
145 spec->extend<
unsigned>(
"version");
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>();
157 float* pblobPed=
static_cast<float*
>(blobPed.startingAddress());
158 float* pblobRMS=
static_cast<float*
>(blobRMS.startingAddress());
162 float ped=input->pedestal(chid,gain);
163 float pedRMS=input->pedestalRMS(chid,gain);
174 ped=input->pedestal(chid,1);
175 pedRMS=input->pedestalRMS(chid,1);
183 collPed->add(gain,*attrList);
184 ATH_MSG_INFO(
"Number of channels filled with default Pedestal (1000) and PedestalRMS (1) "<< nDefault <<
" (including disconnected)" );
187 StatusCode
sc=
detStore()->record(collPed,outputName);
188 if (
sc.isFailure()) {
189 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection for pedestal with key " << outputName );
192 ATH_MSG_INFO(
"Converted Pedestal to inline storage. Total number of channels=" << nChannels );
194 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
203 unsigned nChannels=0;
204 unsigned nCopiedEMPS=0;
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");
215 const unsigned nGain =
m_isSC ? 1 : 3;
216 for (
unsigned gain=0;gain<nGain;++gain) {
220 for (
unsigned hs=0;hs<
m_hashMax && nSamples==0;++hs) {
223 if ( input->nTimeBins(chid,gain) > 23 ){
225 ofca = input->OFC_a(chid,gain,phase);
228 nSamples=ofca.size();
231 ATH_MSG_ERROR(
"All input OFCs for gain " << gain <<
" have 0 samples!" );
235 ATH_MSG_INFO(
"Gain " << gain <<
": Found " << nSamples <<
" OFC samples in input data" );
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>();
243 (*attrList)[
"nSamples"].setValue(nSamples);
245 ofcaBlob.resize(
m_hashMax*
sizeof(
float)*nSamples);
246 ofcbBlob.resize(
m_hashMax*
sizeof(
float)*nSamples);
248 float* pOfca=
static_cast<float*
>(ofcaBlob.startingAddress());
249 float* pOfcb=
static_cast<float*
>(ofcbBlob.startingAddress());
250 float* pTimeOffset=
static_cast<float*
>(toBlob.startingAddress());
255 float timeOffset=input->timeOffset(chid,gain);
257 ofca= input->OFC_a(chid,1,phase);
258 ofcb= input->OFC_b(chid,1,phase);
259 timeOffset=input->timeOffset(chid,1);
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.)) {
266 pOfca[hs*nSamples+i]=1.0;
268 pOfca[hs*nSamples+i]=ofca[i];
273 std::stringstream message;
274 message <<
"Number of samples don't match. Expect " << nSamples <<
", got " << ofca.size() <<
".";
276 for (
unsigned i=0;i<nSamples;++i) {
277 pOfca[hs*nSamples+i]=1.0;
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.)) {
285 pOfcb[hs*nSamples+i]=1.0;
287 pOfcb[hs*nSamples+i]=ofcb[i];
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]);
301 std::stringstream message;
302 message <<
"Number of samples don't match. Expect " << nSamples <<
", got " << ofcb.size() <<
".";
304 for (
unsigned i=0;i<nSamples;++i) {
305 pOfcb[hs*nSamples+i]=1.0;
308 pTimeOffset[hs]=timeOffset;
312 collOFC->add(gain,*attrList);
315 StatusCode
sc=
detStore()->record(collOFC,outputName);
316 if (
sc.isFailure()) {
317 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection OFC with key " << outputName );
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)" );
324 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
333 unsigned nChannels=0;
334 unsigned nCopiedEMPS=0;
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");
345 const unsigned nGain =
m_isSC ? 1 : 3;
346 for (
unsigned gain=0;gain<nGain;++gain) {
349 for (
unsigned hs=0;hs<
m_hashMax && nSamples==0;++hs) {
352 nSamples=shape.size();
355 ATH_MSG_ERROR(
"All input Shapes for gain " << gain <<
" have 0 samples!" );
359 ATH_MSG_INFO(
"Gain " << gain <<
": Found " << nSamples <<
" shape samples in input data" );
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>();
367 (*attrList)[
"nSamples"].setValue(nSamples);
369 shapeBlob.resize(
m_hashMax*
sizeof(
float)*nSamples);
370 shapeDerBlob.resize(
m_hashMax*
sizeof(
float)*nSamples);
372 float* pShape=
static_cast<float*
>(shapeBlob.startingAddress());
373 float* pShapeDer=
static_cast<float*
>(shapeDerBlob.startingAddress());
374 float* pTimeOffset=
static_cast<float*
>(toBlob.startingAddress());
380 float timeOffset=input->timeOffset(chid,gain);
382 shape=input->Shape(chid,1);
383 shapeDer=input->ShapeDer(chid,1);
384 timeOffset=input->timeOffset(chid,1);
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;
393 pShape[hs*nSamples+i]=shape[i];
398 std::stringstream message;
399 message <<
"Number of samples don't match. Expect " << nSamples <<
", got " << shape.size() <<
".";
401 for (
unsigned i=0;i<nSamples;++i) {
402 pShape[hs*nSamples+i]=0.0;
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;
413 pShapeDer[hs*nSamples+i]=shapeDer[i];
418 std::stringstream message;
419 message <<
"Number of samples don't match. Expect " << nSamples <<
", got " << shapeDer.size() <<
".";
421 for (
unsigned i=0;i<nSamples;++i) {
422 pShapeDer[hs*nSamples+i]=0.0;
425 pTimeOffset[hs]=timeOffset;
429 coll->add(gain,*attrList);
432 StatusCode
sc=
detStore()->record(coll,outputName);
433 if (
sc.isFailure()) {
434 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection Shape with key " << outputName );
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)" );
441 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
452 unsigned nChannels=0;
453 unsigned nCopiedEMPS=0;
456 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
457 spec->extend(
"RampVec",
"blob");
458 spec->extend<
unsigned>(
"nPoints");
459 spec->extend<
unsigned>(
"version");
462 std::vector<float> defaultRamp={0.0,1.0};
477 const unsigned nGain =
m_isSC ? 1 : 3;
478 for (
unsigned gain=0;gain<nGain;++gain) {
481 for (
unsigned hs=0;hs<
m_hashMax && nPoints==0;++hs) {
487 ATH_MSG_ERROR(
"All input Ramps for gain " << gain <<
" have 0 points!" );
491 defaultRamp.resize(nPoints,0.0);
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());
502 std::vector<float> rampVec(input->ADC2DAC(chid,gain).asVector());
503 if(rampVec.size()>=2 && rampVec[1]>500) {
507 if (rampVec.empty() && gain==2 &&
m_fakeEMBPSLowGain && cabling->isOnlineConnected(chid) ) {
508 rampVec=input->ADC2DAC(chid,1).asVector();
509 if(rampVec.empty()) {
524 if (rampVec.size()>=nPoints) {
525 for (
size_t i=0;i<nPoints;++i) {
526 pblobRamp[nPoints*hs+i]=rampVec[i];
530 std::stringstream message;
531 message <<
"Polynom degree doesn't match. Expect " << nPoints <<
", got " << rampVec.size() <<
".";
533 for (
size_t i=0;i<nPoints;++i) {
534 pblobRamp[nPoints*hs+i]=defaultRamp[i];
540 coll->add(gain,*attrList);
543 StatusCode
sc=
detStore()->record(coll,outputName);
544 if (
sc.isFailure()) {
545 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection for ramp with key " << outputName );
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)" );
552 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain (applied factor 10)" << nCopiedEMPS );
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>();
568 float* pblob=
static_cast<float*
>(blob.startingAddress());
571 pblob[hs]=input->DAC2UA(chid);
573 coll->add(1,*attrList);
575 StatusCode
sc=
detStore()->record(coll,outputName);
576 if (
sc.isFailure()) {
577 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection with key" << 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>();
593 float* pblob=
static_cast<float*
>(blob.startingAddress());
596 pblob[hs]=input->UA2MEV(chid);
598 coll->add(1,*attrList);
600 StatusCode
sc=
detStore()->record(coll,outputName);
601 if (
sc.isFailure()) {
602 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection with key" << outputName );
610 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
611 spec->extend(
"tQThr",
"blob");
612 spec->extend(
"samplesThr",
"blob");
613 spec->extend(
"trigSumThr",
"blob");
615 spec->extend(
"Name",
"string");
617 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
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>();
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());
634 ptQThr[hs] = input->tQThr(chid);
635 pSamplesThr[hs] = input->samplesThr(chid);
636 pTrigThr[hs] = input->trigSumThr(chid);
638 ATH_MSG_INFO(
"hwid: "<<chid.
getString()<<
" "<<hs<<
" | "<<ptQThr[hs]<<
" : "<<pSamplesThr[hs]<<
" | "<<pTrigThr[hs] );
643 StatusCode
sc=
detStore()->record(coll,outputName);
644 if (
sc.isFailure()) {
645 ATH_MSG_ERROR(
"Failed to record AthenaAttributeList DSPThresholds with key " << outputName );
655 std::string flatName =
"/LAR/ElecCalibFlat";
660 sc =
detStore()->retrieve(ll,
"LArOnline_SuperCellID");
661 if (
sc.isFailure()) {
663 return StatusCode::FAILURE;
672 if (
sc.isFailure()) {
674 return StatusCode::FAILURE;
688 if (
sc.isFailure()) {
696 uA2MeVFlat(uA2MeVComplete, flatName+
"/uA2MeV");
704 if (
sc.isFailure()) {
712 DAC2uAFlat(DAC2uAComplete, flatName+
"/DAC2uA");
719 if (
sc.isFailure()) {
727 const int nGain =
m_isSC ? 1 : 3;
729 singleFloatFlat(
"MphysOverMcal", MphysOverMcalComplete, flatName+
"/MphysOverMcal",nGain,
false);
737 if (
sc.isFailure()) {
745 singleFloatFlat(
"HVScaleCorr", HVScaleCorrComplete, flatName+
"/HVScaleCorr",1);
752 if (
sc.isFailure()) {
785 if (
sc.isFailure()) {
796 weightsComplete=*wHdl;
797 if(!weightsComplete) {
801 ofcFlat(ofcComplete,flatName+
"/OFC",weightsComplete);
807 if (
sc.isFailure()) {
809 ATH_MSG_ERROR(
"Failed to get LArOFCComplete object (cali)" );
815 ofcFlat(ofcComplete,flatName+
"/OFCCali");
823 if (
sc.isFailure()) {
831 shapeFlat(shapeComplete,flatName+
"/Shape");
855 if (
sc.isFailure()) {
863 rampFlat(rampComplete,flatName+
"/Ramp");
871 if (
sc.isFailure()) {
873 ATH_MSG_ERROR(
"Failed to get LArDSPThresholdsComplete object" );
896 return StatusCode::SUCCESS;
918 if (cabling->isOnlineConnected(chid)) {
920 ATH_MSG_ERROR(
"No valid " << objName <<
" found for channel " <<
m_onlineID->channel_name(chid) <<
", gain " << gain <<
". ");
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(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.
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.
LArVectorProxy ShapeRef_t
This class defines the interface for accessing Shape (Nsample variable, Dt = 25 ns fixed) @stereotype...
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)
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
Helper for the Liquid Argon Calorimeter cell identifiers.
This class implements the ILArPedestal interface.
This class implements the ILArShape interface.