6 #include <forward_list>
27 ATH_MSG_ERROR(
"No noise DB folder found, LArNoiseFolder, TileNoiseFolder and CaloNoiseFolder properties are all empty!");
28 return StatusCode::FAILURE;
32 if(noiseKey==
"electronicNoise") {
36 else if (noiseKey ==
"electronicNoiseNoHV") {
37 ATH_MSG_INFO(
"Will compute electronic noise without HV corrections");
44 else if (noiseKey ==
"pileupNoise") {
48 ATH_MSG_INFO(
"Disabling HV correction, only pile-up noise");
51 }
else if (noiseKey ==
"totalNoise") {
53 ATH_MSG_INFO(
"Will compute total (electronic + pileup) noise");
55 ATH_MSG_ERROR(
"Unexpected noise key given: " << noiseKey <<
". Expeced 'electronicNoise' or 'pileupNoise' or 'totalNoise'.");
56 return StatusCode::FAILURE;
63 ATH_MSG_ERROR(
"Luminosity set to < 0 but failed to initialize LumiFolder");
73 return StatusCode::SUCCESS;
81 if (writeHandle.isValid()) {
83 return StatusCode::SUCCESS;
87 std::vector<const CondAttrListCollection*> attrListNoise;
92 attrListNoise.push_back(*larNoiseHdl);
93 writeHandle.addDependency(larNoiseHdl);
94 ATH_MSG_DEBUG(
"Range of LArNoise " << larNoiseHdl.getRange() <<
", intersection:" << writeHandle.getRange());
99 attrListNoise.push_back(*tileNoiseHdl);
100 writeHandle.addDependency(tileNoiseHdl);
101 ATH_MSG_DEBUG(
"Range of TileNoise " << tileNoiseHdl.getRange() <<
", intersection:" << writeHandle.getRange());
106 attrListNoise.push_back(*caloNoiseHdl);
107 writeHandle.addDependency(caloNoiseHdl);
108 ATH_MSG_DEBUG(
"Range of CaloNoise " << caloNoiseHdl.getRange() <<
", intersection:" << writeHandle.getRange());
112 std::forward_list<std::pair<unsigned, const coral::Blob&> > blobList;
113 for (
const auto& attrListColl : attrListNoise) {
114 for (
const auto& coll : *attrListColl) {
116 const coral::Blob&
blob = (coll.second)[
"CaloCondBlob16M"].data<coral::Blob>();
118 ATH_MSG_DEBUG(
"Empty blob in channel " << coll.first <<
". Ignored.");
121 blobList.emplace_front(coll.first,
blob);
129 larHVCorr=*larHVCorrHdl;
130 writeHandle.addDependency(larHVCorrHdl);
131 ATH_MSG_DEBUG(
"Range of LArHVScale " << larHVCorrHdl.getRange() <<
", intersection:" << writeHandle.getRange());
140 writeHandle.addDependency(lumiHdl);
141 ATH_MSG_DEBUG(
"Range of Luminosity " << lumiHdl.getRange() <<
", intersection:" << writeHandle.getRange() );
143 if (attrList[
"LBAvInstLumi"].isNull()) {
144 ATH_MSG_WARNING(
" NULL Luminosity information in database ... set it to 0 " );
147 lumi = attrList[
"LBAvInstLumi"].data<
float>() *1
e-3;
149 if (std::isnan(
lumi)) {
166 const size_t nTileCells=
m_hashRange->maxTileCells();
167 std::unique_ptr<CaloNoise> caloNoiseObj=std::make_unique<CaloNoise>(nLArCells,3,
172 std::array<unsigned,4> cellsPerGain{0,0,0,0};
176 for (
auto& blobPair : blobList) {
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;
189 const unsigned nChansThisblob=
blob->getNChans();
190 const unsigned nGains=
blob->getNGains();
192 for (
unsigned i=0;
i<nChansThisblob;++
i) {
198 if (hvcorr<0.01) hvcorr=1.0;
202 ++(cellsPerGain[
igain]);
232 ATH_MSG_ERROR(
"Unexpected number of COOL channels containing noise-blobs. Got " << nBlobs <<
" expected 7 (6 LAr, 1 Tile)");
233 return StatusCode::FAILURE;
239 ATH_MSG_INFO(
"Calculated electronic noise" << (larHVCorr ?
" with " :
" without ") <<
"HV Scale correction");
245 ATH_MSG_INFO(
"Calculated total noise for lumi " <<
lumi<< (larHVCorr ?
" with " :
" without ") <<
"HV Scale correction");
253 if (
igain<3 && cellsPerGain[
igain]!=maxCells) {
263 ATH_CHECK(writeHandle.record(std::move(caloNoiseObj)));
264 ATH_MSG_INFO(
"recorded new CaloNoise object with key " << writeHandle.key() <<
" and range " << writeHandle.getRange());
266 return StatusCode::SUCCESS;