28#include "CoralBase/Blob.h"
42 ISvcLocator* pSvcLocator ) :
80 return StatusCode::SUCCESS;
86 const std::string& outputName,
const unsigned nGain,
const bool withFCAL) {
89 unsigned nCopiedEMPS=0;
92 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
93 spec->extend(blobName,
"blob");
94 spec->extend<
unsigned>(
"version");
96 for (
unsigned gain=0;gain<nGain;++gain) {
97 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
98 (*attrList)[
"version"].setValue(0U);
99 coral::Blob& blob=(*attrList)[blobName].data<coral::Blob>();
101 float* pblob=
static_cast<float*
>(blob.startingAddress());
105 if (!withFCAL &&
m_onlineID->isFCALchannel(chid)) {
109 value=input->get(chid,gain).m_data;
113 value=input->get(chid,1).m_data;
124 unsigned coolChan=gain;
127 if (nGain==1) coolChan=1;
129 coll->add(coolChan,*attrList);
133 ATH_MSG_INFO(
"Converted " << blobName <<
" to inline storage. Total number of channels=" << nChannels );
134 ATH_MSG_INFO(
"Number of channels filled with default value (1.0) " << nDefault <<
" (including disconnected)" );
136 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
137 StatusCode
sc=
detStore()->record(coll,outputName);
138 if (
sc.isFailure()) {
139 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection with key" << outputName );
148 ATH_MSG_INFO(
"LArCompleteToFlat::pedestalFlat, starting");
150 unsigned nChannels=0;
151 unsigned nCopiedEMPS=0;
153 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
154 spec->extend(
"Pedestal",
"blob");
155 spec->extend(
"PedestalRMS",
"blob");
156 spec->extend<
unsigned>(
"version");
160 const unsigned nGain =
m_isSC ? 1 : 3;
161 for (
unsigned gain=0;gain<nGain;++gain) {
162 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
163 (*attrList)[
"version"].setValue(0U);
164 coral::Blob& blobPed=(*attrList)[
"Pedestal"].data<coral::Blob>();
165 coral::Blob& blobRMS=(*attrList)[
"PedestalRMS"].data<coral::Blob>();
168 float* pblobPed=
static_cast<float*
>(blobPed.startingAddress());
169 float* pblobRMS=
static_cast<float*
>(blobRMS.startingAddress());
173 float ped=input->pedestal(chid,gain);
174 float pedRMS=input->pedestalRMS(chid,gain);
185 ped=input->pedestal(chid,1);
186 pedRMS=input->pedestalRMS(chid,1);
194 collPed->add(gain,*attrList);
195 ATH_MSG_INFO(
"Number of channels filled with default Pedestal (1000) and PedestalRMS (1) "<< nDefault <<
" (including disconnected)" );
198 StatusCode
sc=
detStore()->record(collPed,outputName);
199 if (
sc.isFailure()) {
200 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection for pedestal with key " << outputName );
203 ATH_MSG_INFO(
"Converted Pedestal to inline storage. Total number of channels=" << nChannels );
205 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
214 unsigned nChannels=0;
215 unsigned nCopiedEMPS=0;
218 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
219 spec->extend(
"OFCa",
"blob");
220 spec->extend(
"OFCb",
"blob");
221 spec->extend(
"TimeOffset",
"blob");
222 spec->extend<
unsigned>(
"nSamples");
223 spec->extend<
unsigned>(
"version");
226 const unsigned nGain =
m_isSC ? 1 : 3;
227 for (
unsigned gain=0;gain<nGain;++gain) {
231 for (
unsigned hs=0;hs<
m_hashMax && nSamples==0;++hs) {
234 if ( input->nTimeBins(chid,gain) > 23 ){
236 ofca = input->OFC_a(chid,gain,phase);
239 nSamples=ofca.size();
242 ATH_MSG_ERROR(
"All input OFCs for gain " << gain <<
" have 0 samples!" );
246 ATH_MSG_INFO(
"Gain " << gain <<
": Found " << nSamples <<
" OFC samples in input data" );
248 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
249 (*attrList)[
"version"].setValue(0U);
250 coral::Blob& ofcaBlob=(*attrList)[
"OFCa"].data<coral::Blob>();
251 coral::Blob& ofcbBlob=(*attrList)[
"OFCb"].data<coral::Blob>();
252 coral::Blob& toBlob=(*attrList)[
"TimeOffset"].data<coral::Blob>();
254 (*attrList)[
"nSamples"].setValue(nSamples);
256 ofcaBlob.resize(
m_hashMax*
sizeof(
float)*nSamples);
257 ofcbBlob.resize(
m_hashMax*
sizeof(
float)*nSamples);
259 float* pOfca=
static_cast<float*
>(ofcaBlob.startingAddress());
260 float* pOfcb=
static_cast<float*
>(ofcbBlob.startingAddress());
261 float* pTimeOffset=
static_cast<float*
>(toBlob.startingAddress());
266 float timeOffset=input->timeOffset(chid,gain);
268 ofca= input->OFC_a(chid,1,phase);
269 ofcb= input->OFC_b(chid,1,phase);
270 timeOffset=input->timeOffset(chid,1);
274 if (ofca.size()==nSamples) {
275 for (
unsigned i=0;i<nSamples;++i) {
276 if(std::isnan(ofca[i]) || std::isinf(ofca[i]) || (
m_isSC && fabs(ofca[i])> 10.)) {
277 pOfca[hs*nSamples+i]=1.0;
279 pOfca[hs*nSamples+i]=ofca[i];
284 std::stringstream message;
285 message <<
"Number of samples don't match. Expect " << nSamples <<
", got " << ofca.size() <<
".";
287 for (
unsigned i=0;i<nSamples;++i) {
288 pOfca[hs*nSamples+i]=1.0;
293 if (ofcb.size()==nSamples) {
294 for (
unsigned i=0;i<nSamples;++i) {
295 if(std::isnan(ofcb[i]) || std::isinf(ofcb[i]) || (
m_isSC && fabs(ofcb[i])> 100.)) {
296 pOfcb[hs*nSamples+i]=1.0;
298 pOfcb[hs*nSamples+i]=ofcb[i];
308 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]);
312 std::stringstream message;
313 message <<
"Number of samples don't match. Expect " << nSamples <<
", got " << ofcb.size() <<
".";
315 for (
unsigned i=0;i<nSamples;++i) {
316 pOfcb[hs*nSamples+i]=1.0;
319 pTimeOffset[hs]=timeOffset;
323 collOFC->add(gain,*attrList);
326 StatusCode
sc=
detStore()->record(collOFC,outputName);
327 if (
sc.isFailure()) {
328 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection OFC with key " << outputName );
332 ATH_MSG_INFO(
"Converted OFCs to inline storage. Total number of channels=" << nChannels );
333 ATH_MSG_INFO(
"Number of channels filled with default OFCs {1,1,1,1} " << nDefault <<
" (including disconnected)" );
335 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
344 unsigned nChannels=0;
345 unsigned nCopiedEMPS=0;
348 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
349 spec->extend(
"Shape",
"blob");
350 spec->extend(
"ShapeDer",
"blob");
351 spec->extend(
"TimeOffset",
"blob");
352 spec->extend<
unsigned>(
"nSamples");
353 spec->extend<
unsigned>(
"version");
356 const unsigned nGain =
m_isSC ? 1 : 3;
357 for (
unsigned gain=0;gain<nGain;++gain) {
360 for (
unsigned hs=0;hs<
m_hashMax && nSamples==0;++hs) {
363 nSamples=shape.size();
366 ATH_MSG_ERROR(
"All input Shapes for gain " << gain <<
" have 0 samples!" );
370 ATH_MSG_INFO(
"Gain " << gain <<
": Found " << nSamples <<
" shape samples in input data" );
372 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
373 (*attrList)[
"version"].setValue(0U);
374 coral::Blob& shapeBlob=(*attrList)[
"Shape"].data<coral::Blob>();
375 coral::Blob& shapeDerBlob=(*attrList)[
"ShapeDer"].data<coral::Blob>();
376 coral::Blob& toBlob=(*attrList)[
"TimeOffset"].data<coral::Blob>();
378 (*attrList)[
"nSamples"].setValue(nSamples);
380 shapeBlob.resize(
m_hashMax*
sizeof(
float)*nSamples);
381 shapeDerBlob.resize(
m_hashMax*
sizeof(
float)*nSamples);
383 float* pShape=
static_cast<float*
>(shapeBlob.startingAddress());
384 float* pShapeDer=
static_cast<float*
>(shapeDerBlob.startingAddress());
385 float* pTimeOffset=
static_cast<float*
>(toBlob.startingAddress());
391 float timeOffset=input->timeOffset(chid,gain);
393 shape=input->Shape(chid,1);
394 shapeDer=input->ShapeDer(chid,1);
395 timeOffset=input->timeOffset(chid,1);
399 if (shape.size()==nSamples) {
400 for (
unsigned i=0;i<nSamples;++i) {
401 if(std::isnan(shape[i]) || std::isinf(shape[i])) {
402 pShape[hs*nSamples+i]=0.0;
404 pShape[hs*nSamples+i]=shape[i];
409 std::stringstream message;
410 message <<
"Number of samples don't match. Expect " << nSamples <<
", got " << shape.size() <<
".";
412 for (
unsigned i=0;i<nSamples;++i) {
413 pShape[hs*nSamples+i]=0.0;
419 if (shapeDer.size()==nSamples) {
420 for (
unsigned i=0;i<nSamples;++i) {
421 if(std::isnan(shapeDer[i]) || std::isinf(shapeDer[i])) {
422 pShapeDer[hs*nSamples+i]=0.0;
424 pShapeDer[hs*nSamples+i]=shapeDer[i];
429 std::stringstream message;
430 message <<
"Number of samples don't match. Expect " << nSamples <<
", got " << shapeDer.size() <<
".";
432 for (
unsigned i=0;i<nSamples;++i) {
433 pShapeDer[hs*nSamples+i]=0.0;
436 pTimeOffset[hs]=timeOffset;
440 coll->add(gain,*attrList);
443 StatusCode
sc=
detStore()->record(coll,outputName);
444 if (
sc.isFailure()) {
445 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection Shape with key " << outputName );
449 ATH_MSG_INFO(
"Converted Shapes to inline storage. Total number of channels=" << nChannels );
450 ATH_MSG_INFO(
"Number of channels filled with default shape {0,0,0,0} " << nDefault <<
" (including disconnected)" );
452 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain" << nCopiedEMPS );
463 unsigned nChannels=0;
464 unsigned nCopiedEMPS=0;
467 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
468 spec->extend(
"RampVec",
"blob");
469 spec->extend<
unsigned>(
"nPoints");
470 spec->extend<
unsigned>(
"version");
473 std::vector<float> defaultRamp={0.0,1.0};
488 const unsigned nGain =
m_isSC ? 1 : 3;
489 for (
unsigned gain=0;gain<nGain;++gain) {
492 for (
unsigned hs=0;hs<
m_hashMax && nPoints==0;++hs) {
498 ATH_MSG_ERROR(
"All input Ramps for gain " << gain <<
" have 0 points!" );
502 defaultRamp.resize(nPoints,0.0);
503 ATH_MSG_INFO(
"Gain " << gain <<
": Found a ramp polynom of degree " << nPoints <<
" in input data" );
504 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
505 (*attrList)[
"version"].setValue(0U);
506 coral::Blob& blobRamp=(*attrList)[
"RampVec"].data<coral::Blob>();
507 (*attrList)[
"nPoints"].setValue(nPoints);
508 blobRamp.resize(
m_hashMax*
sizeof(
float)*nPoints);
509 float* pblobRamp=
static_cast<float*
>(blobRamp.startingAddress());
513 std::vector<float> rampVec(input->ADC2DAC(chid,gain).asVector());
514 if(rampVec.size()>=2 && rampVec[1]>500) {
518 if (rampVec.empty() && gain==2 &&
m_fakeEMBPSLowGain && cabling->isOnlineConnected(chid) ) {
519 rampVec=input->ADC2DAC(chid,1).asVector();
520 if(rampVec.empty()) {
535 if (rampVec.size()>=nPoints) {
536 for (
size_t i=0;i<nPoints;++i) {
537 pblobRamp[nPoints*hs+i]=rampVec[i];
541 std::stringstream message;
542 message <<
"Polynom degree doesn't match. Expect " << nPoints <<
", got " << rampVec.size() <<
".";
544 for (
size_t i=0;i<nPoints;++i) {
545 pblobRamp[nPoints*hs+i]=defaultRamp[i];
551 coll->add(gain,*attrList);
554 StatusCode
sc=
detStore()->record(coll,outputName);
555 if (
sc.isFailure()) {
556 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection for ramp with key " << outputName );
560 ATH_MSG_INFO(
"Converted Ramps to inline storage. Total number of channels " << nChannels );
561 ATH_MSG_INFO(
"Number of channels filled with default ramp {0,1} " << nDefault <<
" (including disconnected)" );
563 ATH_MSG_INFO(
"\t Number of low gain EMBPS channels copied from medium gain (applied factor 10)" << nCopiedEMPS );
571 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
572 spec->extend(
"DAC2uA",
"blob");
573 spec->extend<
unsigned>(
"version");
575 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
576 (*attrList)[
"version"].setValue(0U);
577 coral::Blob& blob=(*attrList)[
"DAC2uA"].data<coral::Blob>();
579 float* pblob=
static_cast<float*
>(blob.startingAddress());
582 pblob[hs]=input->DAC2UA(chid);
584 coll->add(1,*attrList);
586 StatusCode
sc=
detStore()->record(coll,outputName);
587 if (
sc.isFailure()) {
588 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection with key" << outputName );
596 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
597 spec->extend(
"uA2MeV",
"blob");
598 spec->extend<
unsigned>(
"version");
600 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
601 (*attrList)[
"version"].setValue(0U);
602 coral::Blob& blob=(*attrList)[
"uA2MeV"].data<coral::Blob>();
604 float* pblob=
static_cast<float*
>(blob.startingAddress());
607 pblob[hs]=input->UA2MEV(chid);
609 coll->add(1,*attrList);
611 StatusCode
sc=
detStore()->record(coll,outputName);
612 if (
sc.isFailure()) {
613 ATH_MSG_ERROR(
"Failed to record CondAttrListCollection with key" << outputName );
621 coral::AttributeListSpecification* spec =
new coral::AttributeListSpecification();
622 spec->extend(
"tQThr",
"blob");
623 spec->extend(
"samplesThr",
"blob");
624 spec->extend(
"trigSumThr",
"blob");
626 spec->extend(
"Name",
"string");
628 coral::AttributeList* attrList =
new coral::AttributeList(*spec);
631 coral::Blob& QBlob=(*attrList)[
"tQThr"].data<coral::Blob>();
632 coral::Blob& SamplesBlob=(*attrList)[
"samplesThr"].data<coral::Blob>();
633 coral::Blob& TrigBlob=(*attrList)[
"trigSumThr"].data<coral::Blob>();
636 SamplesBlob.resize(
m_hashMax*
sizeof(
float));
637 TrigBlob.resize(
m_hashMax*
sizeof(
float));
638 float* ptQThr=
static_cast<float*
>(QBlob.startingAddress());
639 float* pSamplesThr=
static_cast<float*
>(SamplesBlob.startingAddress());
640 float* pTrigThr=
static_cast<float*
>(TrigBlob.startingAddress());
645 ptQThr[hs] = input->tQThr(chid);
646 pSamplesThr[hs] = input->samplesThr(chid);
647 pTrigThr[hs] = input->trigSumThr(chid);
649 ATH_MSG_INFO(
"hwid: "<<chid.
getString()<<
" "<<hs<<
" | "<<ptQThr[hs]<<
" : "<<pSamplesThr[hs]<<
" | "<<pTrigThr[hs] );
654 StatusCode
sc=
detStore()->record(coll,outputName);
655 if (
sc.isFailure()) {
656 ATH_MSG_ERROR(
"Failed to record AthenaAttributeList DSPThresholds with key " << outputName );
666 std::string flatName =
"/LAR/ElecCalibFlat";
671 sc =
detStore()->retrieve(ll,
"LArOnline_SuperCellID");
672 if (
sc.isFailure()) {
674 return StatusCode::FAILURE;
683 if (
sc.isFailure()) {
685 return StatusCode::FAILURE;
699 if (
sc.isFailure()) {
707 uA2MeVFlat(uA2MeVComplete, flatName+
"/uA2MeV");
715 if (
sc.isFailure()) {
723 DAC2uAFlat(DAC2uAComplete, flatName+
"/DAC2uA");
730 if (
sc.isFailure()) {
738 const int nGain =
m_isSC ? 1 : 3;
740 singleFloatFlat(
"MphysOverMcal", MphysOverMcalComplete, flatName+
"/MphysOverMcal",nGain,
false);
748 if (
sc.isFailure()) {
756 singleFloatFlat(
"HVScaleCorr", HVScaleCorrComplete, flatName+
"/HVScaleCorr",1);
763 if (
sc.isFailure()) {
796 if (
sc.isFailure()) {
807 weightsComplete=*wHdl;
808 if(!weightsComplete) {
812 ofcFlat(ofcComplete,flatName+
"/OFC",weightsComplete);
818 if (
sc.isFailure()) {
820 ATH_MSG_ERROR(
"Failed to get LArOFCComplete object (cali)" );
826 ofcFlat(ofcComplete,flatName+
"/OFCCali");
834 if (
sc.isFailure()) {
842 shapeFlat(shapeComplete,flatName+
"/Shape");
866 if (
sc.isFailure()) {
874 rampFlat(rampComplete,flatName+
"/Ramp");
882 if (
sc.isFailure()) {
884 ATH_MSG_ERROR(
"Failed to get LArDSPThresholdsComplete object" );
907 return StatusCode::SUCCESS;
929 if (cabling->isOnlineConnected(chid)) {
931 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.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
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_uA2MeVInput
InputSGKeys.
virtual StatusCode stop()
std::string m_OFCCaliInput
std::string m_HVScaleCorrInput
CondAttrListCollection * ofcFlat(const ILArOFC *input, const std::string &outputName, const LArfSamplSC *weights=nullptr)
const LArOnlineID_Base * m_onlineID
virtual ~LArCompleteToFlat()
Destructor:
std::string m_MphysOverMcalInput
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)
std::string m_DAC2uAInput
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
void errIfConnected(const HWIdentifier chid, const int gain, const char *objName, const char *message=0) const
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKeySC
std::string m_DSPThresholdsInput
CondAttrListCollection * uA2MeVFlat(const ILAruA2MeV *input, const std::string &outputName)
SG::ReadCondHandleKey< LArfSamplSC > m_weightsKeySC
CondAttrListCollection * pedestalFlat(const ILArPedestal *input, const std::string &outputName)
CondAttrListCollection * shapeFlat(const LArShapeComplete *input, const std::string &outputName)
std::string m_PedestalInput
CondAttrListCollection * DAC2uAFlat(const ILArDAC2uA *input, const std::string &outputName)
LArCompleteToFlat()
Default constructor:
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.