ATLAS Offline Software
LArOFCFlat.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "CoralBase/Blob.h"
8 
10  : LArCondFlatBase("LArOFCFlat"),
11  m_nChannels(0),
12  m_nSamples(0)
13  {}
14 
16 
17 
19  : LArCondFlatBase("LArOFCFlat"),
20  m_nChannels(0),
21  m_nSamples(0)
22 {
23  if (initializeBase().isFailure()) return;
24 
25  if (!attrList) return;
26 
28  CondAttrListCollection::const_iterator gainIt_e=attrList->end();
29 
30  m_pOFCa.resize(attrList->size());
31  m_pOFCb.resize(attrList->size());
32  m_pTimeOffset.resize(attrList->size());
33  ATH_MSG_DEBUG( "Found data for " << attrList->size() << " gains." );
34 
35  int blobSize=0; //FIXME Force size to hash-max??? m_onlineHelper->channelHashMax()
36 
37  m_nSamples=0;
38 
39  for(;gainIt!=gainIt_e;++gainIt) {
40  const unsigned gain=gainIt->first;
41  if (gain>=attrList->size() || gain>2) {
42  ATH_MSG_ERROR( "Found unexpected COOL-channel (=gain) number:" << gain );
43  return; //ERROR
44  }
45  const coral::AttributeList& attr=gainIt->second;
46  const coral::Blob& ofcaBlob = attr["OFCa"].data<coral::Blob>();
47  const coral::Blob& ofcbBlob = attr["OFCb"].data<coral::Blob>();
48  const coral::Blob& toBlob = attr["TimeOffset"].data<coral::Blob>();
49  if (blobSize==0) blobSize=ofcaBlob.size();
50  if (m_nSamples==0) m_nSamples=attr["nSamples"].data<unsigned>();
51 
52  //Sanity checks:
53  if (blobSize!=ofcaBlob.size() || blobSize!=ofcbBlob.size()) {
54  ATH_MSG_ERROR( "Unequal blob size (" << blobSize << "/"
55  << ofcaBlob.size() << "/" << ofcbBlob.size() << ")" );
56  return;
57  }
58  if (m_nSamples!=attr["nSamples"].data<unsigned>()) {
59  ATH_MSG_ERROR( "Unequal number of samples (" << m_nSamples << "/"
60  << attr["nSamples"].data<unsigned>() << ")" );
61  return;
62  }
63 
64 
65  m_pOFCa[gain]=static_cast<const float*>(ofcaBlob.startingAddress());
66  m_pOFCb[gain]=static_cast<const float*>(ofcbBlob.startingAddress());
67  m_pTimeOffset[gain]=static_cast<const float*>(toBlob.startingAddress());
68  }// end loop over COOL channels
69 
70  if (m_nSamples==0) {
71  ATH_MSG_ERROR( "Number of samples is zero!" );
72  return;
73  }
74  m_nChannels=blobSize/(sizeof(float)*m_nSamples);
75  ATH_MSG_DEBUG( "Found data for " << m_nChannels );
76 }
77 
78 LArOFCFlat::OFCRef_t LArOFCFlat::OFC_a(const HWIdentifier& onId, int gain, int tbin) const {
79  if (tbin!=0) return OFCRef_t(nullptr,nullptr);
80  return this->OFC_a(m_onlineHelper->channel_Hash(onId),gain);
81 }
82 
83 LArOFCFlat::OFCRef_t LArOFCFlat::OFC_b(const HWIdentifier& onId, int gain, int tbin) const {
84  if (tbin!=0) return OFCRef_t(nullptr,nullptr);
85  return this->OFC_b(m_onlineHelper->channel_Hash(onId),gain);
86 }
87 
88 float LArOFCFlat::timeOffset(const HWIdentifier& CellID, int gain) const {
90  return m_pTimeOffset[gain][hs];
91 }
92 
93 
94 unsigned LArOFCFlat::nTimeBins(const HWIdentifier&, int) const {
95  return 1;
96 }
97 
98 
99 float LArOFCFlat::timeBinWidth(const HWIdentifier&, int ) const {
100  return (25./24.);
101 }
102 
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1632
LArOFCFlat::m_pTimeOffset
std::vector< const float * > m_pTimeOffset
Definition: LArOFCFlat.h:77
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
LArCondFlatBase
Definition: LArCondFlatBase.h:15
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
LArOFCFlat::m_pOFCb
std::vector< const float * > m_pOFCb
Definition: LArOFCFlat.h:76
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
LArOFCFlat::OFC_b
virtual OFCRef_t OFC_b(const HWIdentifier &CellID, int gain, int tbin=0) const
Definition: LArOFCFlat.cxx:83
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
LArCondFlatBase::m_onlineHelper
const LArOnlineID * m_onlineHelper
Definition: LArCondFlatBase.h:24
LArOFCFlat::m_nSamples
unsigned m_nSamples
Definition: LArOFCFlat.h:80
HWIdentifier
Definition: HWIdentifier.h:13
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
LArOFCFlat.h
LArOFCFlat::nTimeBins
virtual unsigned nTimeBins(const HWIdentifier &CellID, int gain) const
Definition: LArOFCFlat.cxx:94
LArOFCFlat::m_pOFCa
std::vector< const float * > m_pOFCa
Definition: LArOFCFlat.h:75
LArOFCFlat::timeBinWidth
virtual float timeBinWidth(const HWIdentifier &CellID, int gain) const
Definition: LArOFCFlat.cxx:99
LArOFCFlat::OFCRef_t
ILArOFC::OFCRef_t OFCRef_t
Definition: LArOFCFlat.h:24
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOFCFlat::LArOFCFlat
LArOFCFlat()
Definition: LArOFCFlat.cxx:9
CreatePhysValWebPage.hs
hs
Definition: CreatePhysValWebPage.py:107
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArOFCFlat::~LArOFCFlat
virtual ~LArOFCFlat()
Definition: LArOFCFlat.cxx:15
LArOFCFlat::m_nChannels
unsigned m_nChannels
Definition: LArOFCFlat.h:79
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
LArCondFlatBase::initializeBase
StatusCode initializeBase()
Definition: LArCondFlatBase.cxx:26
LArOFCFlat::timeOffset
virtual float timeOffset(const HWIdentifier &CellID, int gain) const
Definition: LArOFCFlat.cxx:88
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
readCCLHist.float
float
Definition: readCCLHist.py:83
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38
LArOFCFlat::OFC_a
virtual OFCRef_t OFC_a(const HWIdentifier &CellID, int gain, int tbin=0) const
access to OFCs by online ID, gain, and tbin (!=0 for testbeam)
Definition: LArOFCFlat.cxx:78