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==
"pileupNoise") {
40 ATH_MSG_INFO(
"Disabling HV correction, only pile-up noise");
44 else if (noiseKey==
"totalNoise") {
46 ATH_MSG_INFO(
"Will compute total (electronic + pileup) noise");
49 ATH_MSG_ERROR(
"Unexpected noise key given: " << noiseKey <<
". Expeced 'electronicNoise' or 'pileupNoise' or 'totalNoise'.");
50 return StatusCode::FAILURE;
58 ATH_MSG_ERROR(
"Luminosity set to < 0 but failed to initialize LumiFolder");
68 return StatusCode::SUCCESS;
76 if (writeHandle.isValid()) {
78 return StatusCode::SUCCESS;
82 std::vector<const CondAttrListCollection*> attrListNoise;
87 attrListNoise.push_back(*larNoiseHdl);
88 writeHandle.addDependency(larNoiseHdl);
89 ATH_MSG_DEBUG(
"Range of LArNoise " << larNoiseHdl.getRange() <<
", intersection:" << writeHandle.getRange());
94 attrListNoise.push_back(*tileNoiseHdl);
95 writeHandle.addDependency(tileNoiseHdl);
96 ATH_MSG_DEBUG(
"Range of TileNoise " << tileNoiseHdl.getRange() <<
", intersection:" << writeHandle.getRange());
101 attrListNoise.push_back(*caloNoiseHdl);
102 writeHandle.addDependency(caloNoiseHdl);
103 ATH_MSG_DEBUG(
"Range of CaloNoise " << caloNoiseHdl.getRange() <<
", intersection:" << writeHandle.getRange());
107 std::forward_list<std::pair<unsigned, const coral::Blob&> > blobList;
108 for (
const auto& attrListColl : attrListNoise) {
109 for (
const auto& coll : *attrListColl) {
111 const coral::Blob&
blob = (coll.second)[
"CaloCondBlob16M"].data<coral::Blob>();
113 ATH_MSG_DEBUG(
"Empty blob in channel " << coll.first <<
". Ignored.");
116 blobList.emplace_front(coll.first,
blob);
124 larHVCorr=*larHVCorrHdl;
125 writeHandle.addDependency(larHVCorrHdl);
126 ATH_MSG_DEBUG(
"Range of LArHVScale " << larHVCorrHdl.getRange() <<
", intersection:" << writeHandle.getRange());
135 writeHandle.addDependency(lumiHdl);
136 ATH_MSG_DEBUG(
"Range of Luminosity " << lumiHdl.getRange() <<
", intersection:" << writeHandle.getRange() );
138 if (attrList[
"LBAvInstLumi"].isNull()) {
139 ATH_MSG_WARNING(
" NULL Luminosity information in database ... set it to 0 " );
142 lumi = attrList[
"LBAvInstLumi"].data<
float>() *1
e-3;
144 if (std::isnan(
lumi)) {
161 const size_t nTileCells=
m_hashRange->maxTileCells();
162 std::unique_ptr<CaloNoise> caloNoiseObj=std::make_unique<CaloNoise>(nLArCells,3,
167 std::array<unsigned,4> cellsPerGain{0,0,0,0};
171 for (
auto& blobPair : blobList) {
176 if (
blob->getObjVersion()!=1) {
177 ATH_MSG_ERROR(
"Unexpected blob object version in COOL channel " << blobPair.first
178 <<
". Found " <<
blob->getObjVersion() <<
", expected 1");
179 return StatusCode::FAILURE;
184 const unsigned nChansThisblob=
blob->getNChans();
185 const unsigned nGains=
blob->getNGains();
187 for (
unsigned i=0;
i<nChansThisblob;++
i) {
193 if (hvcorr<0.01) hvcorr=1.0;
197 ++(cellsPerGain[
igain]);
227 ATH_MSG_ERROR(
"Unexpected number of COOL channels containing noise-blobs. Got " << nBlobs <<
" expected 7 (6 LAr, 1 Tile)");
228 return StatusCode::FAILURE;
234 ATH_MSG_INFO(
"Calculated electronic noise" << (larHVCorr ?
" with " :
" without ") <<
"HV Scale correction");
240 ATH_MSG_INFO(
"Calculated total noise for lumi " <<
lumi<< (larHVCorr ?
" with " :
" without ") <<
"HV Scale correction");
248 if (
igain<3 && cellsPerGain[
igain]!=maxCells) {
258 ATH_CHECK(writeHandle.record(std::move(caloNoiseObj)));
259 ATH_MSG_INFO(
"recorded new CaloNoise object with key " << writeHandle.key() <<
" and range " << writeHandle.getRange());
261 return StatusCode::SUCCESS;