77 {
78
79
80 SG::WriteCondHandle<CaloNoise> writeHandle{
m_outputKey,ctx};
83 return StatusCode::SUCCESS;
84 }
85
86
87 std::vector<const CondAttrListCollection*> attrListNoise;
88
90
91 SG::ReadCondHandle<CondAttrListCollection> larNoiseHdl{
m_larNoiseKey,ctx};
92 attrListNoise.push_back(*larNoiseHdl);
95 }
96
98 SG::ReadCondHandle<CondAttrListCollection> tileNoiseHdl{
m_tileNoiseKey,ctx};
99 attrListNoise.push_back(*tileNoiseHdl);
102 }
103
105 SG::ReadCondHandle<CondAttrListCollection> caloNoiseHdl{
m_caloNoiseKey,ctx};
106 attrListNoise.push_back(*caloNoiseHdl);
109 }
110
111
112 std::forward_list<std::pair<unsigned, const coral::Blob&> > blobList;
113 for (const auto& attrListColl : attrListNoise) {
114 for (const auto& coll : *attrListColl) {
118 ATH_MSG_DEBUG(
"Empty blob in channel " << coll.first <<
". Ignored.");
119 continue;
120 }
121 blobList.emplace_front(coll.first, blob);
122 }
123 }
124
125
128 SG::ReadCondHandle<LArHVCorr> larHVCorrHdl{
m_hvCorrKey,ctx};
129 larHVCorr=*larHVCorrHdl;
132 }
133
134
136
138 SG::ReadCondHandle<CondAttrListCollection> lumiHdl{
m_lumiFolderKey,ctx};
139 const CondAttrListCollection* lumiAttrListColl=*lumiHdl;
142 const coral::AttributeList& attrList = lumiAttrListColl->
attributeList(0);
143 if (attrList["LBAvInstLumi"].isNull()) {
144 ATH_MSG_WARNING(
" NULL Luminosity information in database ... set it to 0 " );
146 } else {
147 lumi = attrList[
"LBAvInstLumi"].data<
float>() *1e-3;
148 }
149 if (std::isnan(lumi)) {
152 }
153 }
154 else if (lumi < 0) {
155
156
157
158
160 }
161
162
163 const size_t maxCells=
m_caloCellID->calo_cell_hash_max();
164
166 const size_t nTileCells=
m_hashRange->maxTileCells();
167 std::unique_ptr<CaloNoise> caloNoiseObj=std::make_unique<CaloNoise>(nLArCells,3,
168 nTileCells,4,
170
171
172 std::array<unsigned,4> cellsPerGain{0,0,0,0};
173 unsigned nBlobs=0;
174
175
176 for (auto& blobPair : blobList) {
177 nBlobs++;
181 if (
blob->getObjVersion()!=1) {
182 ATH_MSG_ERROR(
"Unexpected blob object version in COOL channel " << blobPair.first
183 <<
". Found " <<
blob->getObjVersion() <<
", expected 1");
184 return StatusCode::FAILURE;
185 }
186
188
189 const unsigned nChansThisblob=
blob->getNChans();
190 const unsigned nGains=
blob->getNGains();
192 for (
unsigned i=0;
i<nChansThisblob;++
i) {
193 float hvcorr=1.0;
195 const IdentifierHash oflHash(offset+i);
197
198 if (hvcorr<0.01) hvcorr=1.0;
199 }
200 const float a=
blob->getData(i,igain,0)*hvcorr;
201 const float b=
blob->getData(i,igain,1);
202 ++(cellsPerGain[
igain]);
207 break;
210 break;
213 break;
214 default:
215 break;
216 }
217 }
218 }
219
220
221
222
224 caloNoiseObj->setTileBlob(std::move(blob),lumi);
225 }
226
227 }
228
229
230
231 if (nBlobs!=7) {
232 ATH_MSG_ERROR(
"Unexpected number of COOL channels containing noise-blobs. Got " << nBlobs <<
" expected 7 (6 LAr, 1 Tile)");
233 return StatusCode::FAILURE;
234 }
235
236
239 ATH_MSG_INFO(
"Calculated electronic noise" << (larHVCorr ?
" with " :
" without ") <<
"HV Scale correction");
240 break;
242 ATH_MSG_INFO(
"Calculated pile-up noise for lumi " << lumi);
243 break;
245 ATH_MSG_INFO(
"Calculated total noise for lumi " << lumi<< (larHVCorr ?
" with " :
" without ") <<
"HV Scale correction");
246 break;
247 default:
248 break;
249 }
250
252
253 if (igain<3 && cellsPerGain[igain]!=maxCells) {
254 ATH_MSG_ERROR(
"Expected " << maxCells <<
" cells for gain " << igain <<
", got " << cellsPerGain[igain]);
255 }
256 else {
257 ATH_MSG_DEBUG(
"Gain " << igain <<
" Nbr of cells: " << cellsPerGain[igain]);
258 }
259
260 }
261
262
264 ATH_MSG_INFO(
"recorded new CaloNoise object with key " << writeHandle.
key() <<
" and range " << writeHandle.
getRange());
265
266 return StatusCode::SUCCESS;
267}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
static CaloCondBlobFlt * getInstance(coral::Blob &blob)
Returns a pointer to a non-const CaloCondBlobFlt.
CaloNoise::NOISETYPE m_noiseType
Gaudi::Property< bool > m_useHVCorr
SG::ReadCondHandleKey< CondAttrListCollection > m_larNoiseKey
const CaloCell_ID * m_caloCellID
std::unique_ptr< CaloNoiseHashRanges > m_hashRange
SG::ReadCondHandleKey< LArHVCorr > m_hvCorrKey
SG::ReadCondHandleKey< CondAttrListCollection > m_lumiFolderKey
SG::WriteCondHandleKey< CaloNoise > m_outputKey
SG::ReadCondHandleKey< CondAttrListCollection > m_tileNoiseKey
Gaudi::Property< float > m_lumi0
SG::ReadCondHandleKey< CondAttrListCollection > m_caloNoiseKey
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
const float & HVScaleCorr_oflHash(const IdentifierHash &h) const
const EventIDRange & getRange()
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED