ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCellNoiseAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "CaloCellNoiseAlg.h"
9#include "CaloDetDescr/CaloDetDescrElement.h"
11#include "CLHEP/Matrix/Matrix.h"
12#include "CLHEP/Matrix/Vector.h"
13//=== AttributeList
14#include "CoralBase/Blob.h"
16#include "GaudiKernel/ThreadLocalContext.h"
17
18
19using CLHEP::HepMatrix;
20using CLHEP::HepVector;
21
22
23//Constructor
24CaloCellNoiseAlg::CaloCellNoiseAlg(const std::string& name, ISvcLocator* pSvcLocator):
25 AthAlgorithm(name,pSvcLocator),
26 m_ncell(0),
27 m_lumiblock(0),
29 m_first(false),
30 m_tree(nullptr),
31 m_doMC(false),
32 m_readNtuple(false),
33 m_doFit(true),
34 m_doLumiFit(true),
35 m_nmin(10),
36 m_trigDecTool(""),
39 m_deltaLumi(0.05)
40{
41 std::vector<float> data(CaloSampling::Unknown);
42 data[CaloSampling::PreSamplerB] = 300.;
43 data[CaloSampling::EMB1] = 100.;
44 data[CaloSampling::EMB2] = 400.;
45 data[CaloSampling::EMB3] = 200.;
46 data[CaloSampling::PreSamplerE] = 500.;
47 data[CaloSampling::EME1] = 200.;
48 data[CaloSampling::EME2] = 800.;
49 data[CaloSampling::EME3] = 300.;
50 data[CaloSampling::HEC0] = 2000.;
51 data[CaloSampling::HEC1] = 2000.;
52 data[CaloSampling::HEC2] = 2000.;
53 data[CaloSampling::HEC3] = 2000.;
54 data[CaloSampling::TileBar0] = 9999.;
55 data[CaloSampling::TileBar1] = 9999.;
56 data[CaloSampling::TileBar2] = 9999.;
57 data[CaloSampling::TileExt0] = 9999.;
58 data[CaloSampling::TileExt1] = 9999.;
59 data[CaloSampling::TileExt2] = 9999.;
60 data[CaloSampling::TileGap1] = 9999.;
61 data[CaloSampling::TileGap2] = 9999.;
62 data[CaloSampling::TileGap3] = 9999.;
63 data[CaloSampling::FCAL0]=10000.;
64 data[CaloSampling::FCAL1]=10000.;
65 data[CaloSampling::FCAL2]=10000.;
66
67 m_cuts.setValue(data);
68 declareProperty("doMC",m_doMC);
69 declareProperty("readNtuple",m_readNtuple);
70 declareProperty("doFit",m_doFit);
71 declareProperty("nevtMin",m_nmin);
72 declareProperty("doLumiFit",m_doLumiFit);
73 declareProperty("TrigDecisionTool", m_trigDecTool );
74 declareProperty("TriggerChain", m_triggerChainProp );
75 declareProperty("EnergyCuts",m_cuts);
76 declareProperty("LumiFolderName",m_lumiFolderName="/TRIGGER/LUMI/LBLESTONL");
77 declareProperty("NAddLumiBlock",m_addlumiblock,"Number of consecutive lumiblocks to add together ");
78 declareProperty("DeltaLumi",m_deltaLumi);
79}
80
81//__________________________________________________________________________
82//Destructor
84{
85 ATH_MSG_DEBUG ( "CaloCellNoiseAlg destructor called" );
86}
87//__________________________________________________________________________
89{
90 ATH_MSG_DEBUG ("CaloCellNoiseAlg initialize()" );
91
92 m_treeData = std::make_unique<TreeData>();
93 const CaloIdManager* mgr = nullptr;
94 ATH_CHECK( detStore()->retrieve( mgr ) );
95 m_calo_id = mgr->getCaloCell_ID();
96
97 ATH_CHECK(m_caloMgrKey.initialize());
98
99 ATH_CHECK( m_noiseKey.initialize ( m_doMC) );
100 ATH_CHECK( m_pedestalKey.initialize (!m_doMC) );
101
102 ATH_CHECK( m_adc2mevKey.initialize() );
105
106
107 m_first = true;
108 m_lumiblock = 0;
109 m_treeData->m_luminosity = 0.;
110 m_lumiblockOld = 0;
111
112 ATH_CHECK( m_thistSvc.retrieve() );
113
114 if( !m_trigDecTool.empty() ) {
115 ATH_CHECK( m_trigDecTool.retrieve() );
116 ATH_MSG_INFO ( " --> Found AlgTool TrigDecisionTool" );
117 }
118
119 ATH_CHECK( m_cablingKey.initialize());
120
121 ATH_MSG_INFO ( " end of CaloCellNoiseAlg::initialize " );
122 return StatusCode::SUCCESS;
123}
124//__________________________________________________________________________
126{
127 ATH_MSG_INFO ("CaloCellNoiseAlg stop()" );
128
129 if (!m_readNtuple) {
130 if (this->fillNtuple().isFailure()) {
131 ATH_MSG_WARNING ( " failed to fill ntuple " );
132 return StatusCode::SUCCESS;
133 }
134 }
135 else {
136 if (CaloCellNoiseAlg::readNtuple().isFailure()) {
137 ATH_MSG_WARNING ( " failed to read ntuple " );
138 return StatusCode::SUCCESS;
139 }
140 }
141
142 if (m_doFit) {
143 if (this->fitNoise().isFailure()) {
144 ATH_MSG_WARNING ( " failed to perform fit " );
145 return StatusCode::SUCCESS;
146 }
147 }
148
149 return StatusCode::SUCCESS;
150}
151
152//__________________________________________________________________________
154{
155 if (m_readNtuple) return StatusCode::SUCCESS;
156
157// check trigger
158 if ( (!m_triggerChainProp.empty()) && (!m_trigDecTool.empty()) ) {
159
160 if (m_first) {
161 ATH_MSG_INFO ( " L1 items : " << m_trigDecTool->getChainGroup("L1_.*")->getListOfTriggers() );
162 }
163 bool passTrig = false;
164 if (!m_triggerChainProp.empty()) passTrig = m_trigDecTool->isPassed(m_triggerChainProp);
165
166 if (!passTrig) {
167 ATH_MSG_DEBUG ( " Failed trigger selection " );
168 return StatusCode::SUCCESS;
169 }
170 else {
171 ATH_MSG_DEBUG ( " Pass trigger selection " );
172 }
173
174 }
175
176 const EventContext& ctx = Gaudi::Hive::currentContext();
177 unsigned int lumiblock = ctx.eventID().lumi_block();
178
179 ATH_MSG_DEBUG ( " lumiblock " << lumiblock );
180
181 if ( lumiblock != m_lumiblockOld) {
182 float luminosity = this->getLuminosity();
183 ATH_MSG_INFO ( " New lumiblock seen " << lumiblock << " " << m_lumiblock << " " << luminosity << " " << m_treeData->m_luminosity << " m_first " << m_first );
184 // lumiblock, m_lumiblock are unsigned.
185 if ( ( lumiblock - m_lumiblock >= static_cast<unsigned int>(m_addlumiblock) ||
186 std::fabs(luminosity-m_treeData->m_luminosity)>(m_treeData->m_luminosity*m_deltaLumi) ||
187 m_first )
188 && m_doLumiFit)
189 {
190 if (!m_first) {
191 ATH_MSG_INFO ( " filling ntuple for lumiblock " << m_lumiblock << " until " << lumiblock << " (excluded) " );
192 if (this->fillNtuple().isFailure()) {
193 ATH_MSG_WARNING ( " failed to fill ntuple " );
194 return StatusCode::SUCCESS;
195 }
196 }
197 m_lumiblock = lumiblock;
198 m_treeData->m_luminosity = luminosity;
199 }
200 m_lumiblockOld = lumiblock;
201 }
202
203 if (m_first) {
204 m_ncell = m_calo_id->calo_cell_hash_max();
205 ATH_MSG_DEBUG ( " number of cells " << m_ncell );
206 if (m_ncell>200000) {
207 ATH_MSG_WARNING ( " too many cells " << m_ncell );
208 return StatusCode::SUCCESS;
209 }
210 m_CellList.reserve(m_ncell);
211
212 const CaloNoise* totalNoise = nullptr;
213 if (!m_totalNoiseKey.empty()) {
215 totalNoise = noiseH.cptr();
216 }
217
219 ATH_CHECK(caloMgrHandle.isValid());
220
221 for (int i=0;i<m_ncell;i++) {
222 IdentifierHash idHash=i;
223 Identifier id=m_calo_id->cell_id(idHash);
224 const CaloDetDescrElement* calodde = (*caloMgrHandle)->get_element(id);
225 CellInfo cell0{};
226 cell0.nevt = 0;
227 cell0.average = 0.;
228 cell0.rms = 0.;
229 cell0.identifier = id.get_identifier32().get_compact();
230 cell0.sampling = m_calo_id->calo_sample(id);
231 cell0.eta = calodde->eta();
232 cell0.phi = calodde->phi();
233 cell0.nevt_good=0;
234 if (totalNoise) {
236 if (m_calo_id->is_tile(id)) {
237 if (m_calo_id->calo_sample(id) == CaloSampling::TileGap3) gain=CaloGain::TILEONEHIGH;
238 else gain=CaloGain::TILEHIGHHIGH;
239 }
240 else {
241 if(m_calo_id->is_hec(id)) gain=CaloGain::LARMEDIUMGAIN;
242 else gain=CaloGain::LARHIGHGAIN;
243 }
244 cell0.reference = totalNoise->getNoise (id, gain);
245 }
246 else{
247 cell0.reference=0.;
248 }
249 m_CellList.push_back(cell0);
250 }
251
252 m_tree = new TTree("mytree","Calo Noise ntuple");
253 m_tree->Branch("luminosity",&m_treeData->m_luminosity,"luminosity/F");
254 m_tree->Branch("ncell",&m_treeData->m_ncell,"ncell/I");
255 m_tree->Branch("identifier",m_treeData->m_identifier,"identifier[ncell]/I");
256 m_tree->Branch("layer",m_treeData->m_layer,"layer[ncell]/I");
257 m_tree->Branch("eta",m_treeData->m_eta,"eta[ncell]/F");
258 m_tree->Branch("phi",m_treeData->m_phi,"phi[ncell]/F");
259 m_tree->Branch("nevt",m_treeData->m_nevt,"nevt[ncell]/I");
260 m_tree->Branch("nevt_good",m_treeData->m_nevt_good,"nevt[ncell]/I");
261 m_tree->Branch("average",m_treeData->m_average,"average[ncell]/F");
262 m_tree->Branch("rms",m_treeData->m_rms,"rms[ncell]/F");
263 m_tree->Branch("reference",m_treeData->m_reference,"reference[ncell]/F");
264
265 if( m_thistSvc->regTree("/file1/calonoise/mytree",m_tree).isFailure()) {
266 ATH_MSG_WARNING ( " cannot register ntuple " );
267 return StatusCode::SUCCESS;
268 }
269
270 m_first = false;
271 }
272
273
274 const CaloCellContainer* cell_container = nullptr;
275 if(evtStore()->retrieve(cell_container,"AllCalo").isFailure()) {
276 ATH_MSG_WARNING( " Could not get pointer to Cell Container " );
277 return StatusCode::SUCCESS;
278 }
279
280 CaloCellContainer::const_iterator first_cell = cell_container->begin();
281 CaloCellContainer::const_iterator end_cell = cell_container->end();
282 ATH_MSG_DEBUG ( "*** Start loop over CaloCells " );
283 for (; first_cell != end_cell; ++first_cell)
284 {
285
286 Identifier cellID = (*first_cell)->ID();
287 CaloGain::CaloGain gain = (*first_cell)->gain();
288
289 if (gain==CaloGain::LARHIGHGAIN || gain ==CaloGain::TILEHIGHHIGH ||
290 (gain==CaloGain::TILEONEHIGH && m_calo_id->calo_sample(cellID) == CaloSampling::TileGap3) ||
291 (gain==CaloGain::LARMEDIUMGAIN && m_calo_id->is_hec(cellID)) ) {
292
293 double energy= (*first_cell)->energy();
294
295 int isample = m_calo_id->calo_sample(cellID);
296 if (std::fabs(energy) < m_cuts.value()[isample] ) {
297
298 IdentifierHash idhash = m_calo_id->calo_cell_hash(cellID);
299 int index = (int) (idhash);
300
301 double oldN = (double) (m_CellList[index].nevt);
302 double oldAverage = m_CellList[index].average;
303 double oldRMS = m_CellList[index].rms;
304
305 double frac = oldN/(1.+oldN);
306 double Anew = 1.+oldN;
307 double newAverage = frac*oldAverage + energy/Anew;
308 double deltaE = (energy-oldAverage);
309 double newRMS = frac*(oldRMS + deltaE*deltaE/Anew);
310
311 m_CellList[index].nevt ++;
312 m_CellList[index].average = newAverage;
313 m_CellList[index].rms = newRMS;
314
315 if (!((*first_cell)->badcell())) m_CellList[index].nevt_good++;
316 }
317 }
318 }
319
320 return StatusCode::SUCCESS;
321}
322
323//---------------------------------------------
325{
326 ATH_MSG_INFO ( " in getLuminosity() " );
327
328 float luminosity = 0.;
329 const CondAttrListCollection* attrListColl = nullptr;
330 StatusCode sc = evtStore()->retrieve(attrListColl, m_lumiFolderName);
331 if (sc.isFailure() || !attrListColl) {
332 ATH_MSG_WARNING ( "attrrListColl not found for " << m_lumiFolderName );
333 return luminosity;
334 }
335 // Loop over collection
336 CondAttrListCollection::const_iterator first = attrListColl->begin();
337 CondAttrListCollection::const_iterator last = attrListColl->end();
338 for (; first != last; ++first) {
339 if ((*first).first == 0) {
340 std::ostringstream attrStr1;
341 (*first).second.toOutputStream( attrStr1 );
342 ATH_MSG_DEBUG ( "ChanNum " << (*first).first <<
343 " Attribute list " << attrStr1.str() );
344 const coral::AttributeList& attrList = (*first).second;
345 luminosity = attrList["LBAvInstLumi"].data<float>() *1e-3; // luminosity (from 10**30 units in db to 10*33 units)
346 break;
347 }
348 }
349 ATH_MSG_INFO ( " Luminosity (10**33 units) " << luminosity << " (10**27 units) " << 1e+6*luminosity );
350 return luminosity;
351
352}
353
354//____________________________________________
356{
357 ATH_MSG_INFO ( " in fillNtuple " );
358
359 m_treeData->m_ncell = m_ncell;
360 for (int i=0;i<m_ncell;i++) {
361 m_treeData->m_identifier[i] = m_CellList[i].identifier;
362 m_treeData->m_layer[i] = m_CellList[i].sampling;
363 m_treeData->m_eta[i] = m_CellList[i].eta;
364 m_treeData->m_phi[i] = m_CellList[i].phi;
365 m_treeData->m_nevt[i] = m_CellList[i].nevt;
366 m_treeData->m_nevt_good[i] = m_CellList[i].nevt_good;
367 m_treeData->m_average[i] = (float) (m_CellList[i].average);
368 m_treeData->m_rms[i] = (float) (std::sqrt(m_CellList[i].rms));
369 m_treeData->m_reference[i] = (float) (m_CellList[i].reference);
370 ATH_MSG_DEBUG ( " hash,Nevt,Average,RMS " << i << " " << m_treeData->m_nevt[i] << " " << m_treeData->m_average[i] << " " << m_treeData->m_rms[i] );
371 }
372 m_tree->Fill();
373
374 for (int i=0;i<m_ncell;i++) {
375 m_CellList[i].nevt=0;
376 m_CellList[i].nevt_good=0;
377 m_CellList[i].average=0;
378 m_CellList[i].rms=0;
379 }
380
381
382 return StatusCode::SUCCESS;
383}
384
385//______________________________________________
387{
388 return StatusCode::SUCCESS;
389}
390
391//_________________________________________________
393{
394 const EventContext& ctx = Gaudi::Hive::currentContext();
396 const LArOnOffIdMapping* cabling=(*cablingHdl);
397
398 ATH_MSG_INFO ( " in CaloCellNoiseAlg::fitNoise() " );
399
400 const ILArPedestal* pedestal = nullptr;
401 const ILArNoise* noise = nullptr;
402 if (m_doMC) {
404 noise = noiseH.cptr();
405 }
406 else {
408 pedestal = pedH.cptr();
409 }
410
411 const CaloNoise* elecNoise = nullptr;
412 if (!m_elecNoiseKey.empty()) {
414 elecNoise = noiseH.cptr();
415 }
416
418
419 FILE* fp = fopen("calonoise.txt","w");
420
421 TBranch* b1 = m_tree->GetBranch("luminosity");
422 TBranch* b2 = m_tree->GetBranch("nevt");
423 TBranch* b3 = m_tree->GetBranch("average");
424 TBranch* b4 = m_tree->GetBranch("rms");
425 TBranch* b5 = m_tree->GetBranch("nevt_good");
426 b1->SetAddress(&m_treeData->m_luminosity);
427 b2->SetAddress(&m_treeData->m_nevt);
428 b3->SetAddress(&m_treeData->m_average);
429 b4->SetAddress(&m_treeData->m_rms);
430 b5->SetAddress(&m_treeData->m_nevt_good);
431 int nentries = m_tree->GetEntries();
432 ATH_MSG_DEBUG ( " Number of entries in ntuple " << nentries );
433
434 std::vector<float> anoise;
435 std::vector<float> bnoise;
436 anoise.resize(m_ncell,0.);
437 bnoise.resize(m_ncell,0.);
438
439 for (int icell=0;icell<m_ncell;icell++) {
440 std::vector<float> x;
441 std::vector<float> y;
442 std::vector<float> ey;
443
444 for (int i=0;i<nentries;i++) {
445 b1->GetEntry(i);
446 b2->GetEntry(i);
447 b4->GetEntry(i);
448
449 if (m_treeData->m_nevt[icell]>m_nmin) {
450 x.push_back(std::sqrt(m_treeData->m_luminosity));
451 y.push_back(m_treeData->m_rms[icell]);
452 ey.push_back(m_treeData->m_rms[icell]/std::sqrt(2.*m_treeData->m_nevt[icell]));
453 }
454 }
455
456 if (x.size()<2) {
457 if (x.size()==1) anoise[icell]=y[0];
458 }
459 else {
460 HepMatrix alpha(2,2);
461 HepVector beta(2);
462
463 for (unsigned int i=0;i<2;i++) {
464 for (unsigned int j=0;j<2;j++) {
465 alpha[i][j]=0.;
466 for (unsigned int k=0;k<x.size();k++) {
467 alpha[i][j] += ((std::pow(x[k],i))*(std::pow(x[k],j))/(std::pow(ey[k],2)));
468 }
469 }
470 }
471 for (unsigned int i=0;i<2;i++) {
472 beta[i]=0.;
473 for (unsigned int k=0;k<x.size();k++) {
474 beta[i] += (y[k]*(std::pow(x[k],i))/(std::pow(ey[k],2)));
475 }
476 }
477 HepVector comp=solve(alpha,beta);
478 anoise[icell] = comp[0];
479 bnoise[icell] = comp[1];
480
481 }
482 if (msgLvl(MSG::DEBUG)) {
483 msg() << MSG::DEBUG << " cell " << icell << " lumi/noise ";
484 for (unsigned int i=0;i<x.size();i++) {
485 msg() << MSG::DEBUG << x[i] << " " << y[i] << " / ";
486 }
487 msg() << MSG::DEBUG << " " << endmsg;
488 ATH_MSG_DEBUG ( " fitted a,b " << anoise[icell] << " " << bnoise[icell] );
489 }
490 } // end first loop over cells to store anoise and bnoise
491
492// for LAR try phi patching for missing cells, just to be sure that DB is filled with reasonable entries in case
493// the cell come back to life
494 for (int icell=0;icell<m_ncell;icell++) {
495 if (anoise[icell]<3. || m_treeData->m_nevt_good[icell]==0) {
496 IdentifierHash idHash = icell;
497 Identifier id=m_calo_id->cell_id(idHash);
498 if (m_calo_id->is_lar(id)) {
499 ATH_MSG_DEBUG ( " cell with no noise found in LAr " << m_calo_id->show_to_string(id) );
500 Identifier regionId = m_calo_id->region_id(id);
501 int eta=m_calo_id->eta(id);
502 int phimin = m_calo_id->phi_min(regionId);
503 int phimax = m_calo_id->phi_max(regionId);
504 int nring=0;
505 float sum=0.;
506 ATH_MSG_DEBUG ( " regionId,eta,phimin,phimax " << regionId << " " << eta << " " << phimin << " " << phimax );
507 for (int phi=phimin;phi<=phimax;phi++) {
508 Identifier id2 = m_calo_id->cell_id(regionId,eta,phi);
509 if (id2.is_valid()) {
510 if(msgLvl(MSG::DEBUG))
511 msg() << MSG::DEBUG << " cell in ring " << m_calo_id->show_to_string(id2) ;
512 IdentifierHash idHash2 = m_calo_id->calo_cell_hash(id2);
513 int index = (int)(idHash2);
514 if (index>=0 && index<m_ncell) {
515 ATH_MSG_DEBUG( " noise " << anoise[index] );
516 if (anoise[index]>3. && m_treeData->m_nevt_good[index]>0) {
517 nring+=1;
518 sum+=anoise[index];
519 }
520 }
521 }
522 }
523 if (nring>0) {
524 float patched_noise = sum/((float)(nring));
525 if (patched_noise>anoise[icell]) anoise[icell] = patched_noise;
526 }
527 ATH_MSG_DEBUG( " corrected noise nring, anoise[icell] " << nring << " " << anoise[icell] );
528 }
529 }
530 }
531
532
533// extrapolate to other gains and write result
534 for (int icell=0;icell<m_ncell;icell++) {
535 IdentifierHash idHash = icell;
536 Identifier id=m_calo_id->cell_id(idHash);
537 HWIdentifier hwid=cabling->createSignalChannelID(id);
538 int subCalo;
539 IdentifierHash idSubHash = m_calo_id->subcalo_cell_hash (idHash, subCalo);
540
541 int iCool=-1;
542 if (m_calo_id->is_em(id)) { // EM calo
543 if (m_calo_id->is_em_barrel(id)) {
544 if (m_calo_id->pos_neg(id) > 0 )
545 iCool=2;
546 else
547 iCool=1;
548 }
549 if (m_calo_id->is_em_endcap(id)) {
550 if (m_calo_id->pos_neg(id) > 0 )
551 iCool=3;
552 else
553 iCool=0;
554 }
555
556 }
557 if (m_calo_id->is_hec(id)) { // HEC
558 iCool=16;
559 }
560 if (m_calo_id->is_fcal(id)) { // Fcal
561 iCool=32;
562 }
563 if (m_calo_id->is_tile(id)) { // Tile
564 iCool=48;
565 }
566 int ii = (int) (idSubHash);
567
568
569// if LAr
570 if (m_calo_id->is_lar(id)) {
571 for (int igain=0;igain<3;igain++) {
573 if (igain==0) gain=CaloGain::LARHIGHGAIN;
574 if (igain==1) gain=CaloGain::LARMEDIUMGAIN;
575 if (igain==2) gain=CaloGain::LARLOWGAIN;
576
577// extrapolate electronic noise part (a term) using ratio of electronic noise values
578// for HEC start from medium gain as reference
580 if (m_calo_id->is_hec(id)) gainref=CaloGain::LARMEDIUMGAIN;
581
582 float anoise_corr=anoise[icell];
583
584 if (gain != gainref) {
585
586// noise and ADC2MeV in gain ref
587 float noise0=-1.;
588 if (m_doMC) noise0 = noise->noise(hwid,gainref);
589 else {
590 float noise = pedestal->pedestalRMS(hwid,gainref);
591 if (noise>= (1.0+LArElecCalib::ERRORCODE)) noise0 = noise;
592 }
594 polynom_adc2mev0 = adc2mev->ADC2MEV(id,gainref);
595 float adc2mev0=-1;
596 if (polynom_adc2mev0.size()>1) adc2mev0=polynom_adc2mev0[1];
597
598// noise and ADC2MeV in gain
599
600 float noise1=-1;
601 if (m_doMC) noise1 = noise->noise(hwid,gain);
602 else {
603 float noise = pedestal->pedestalRMS(hwid,gain);
604 if (noise>= (1.0+LArElecCalib::ERRORCODE)) noise1 = noise;
605 }
607 polynom_adc2mev1 = adc2mev->ADC2MEV(hwid,gain);
608 float adc2mev1=-1;
609 if (polynom_adc2mev1.size()>1) adc2mev1=polynom_adc2mev1[1];
610
611 //if (m_calo_id->is_hec(id))
612 // std::cout << " Hec noise1,noise0,adc2mev1,adc2mev0 " << noise1 << " " << noise0 << " " << adc2mev1 << " " << adc2mev0 << std::endl;
613
614 if (noise0>0 && noise1>0 && adc2mev0>0 && adc2mev1>0.) {
615 anoise_corr = anoise[icell]*noise1/noise0 * adc2mev1/adc2mev0;
616 }
617 }
618
619 //if (m_calo_id->is_hec(id))
620 // std::cout << " Hec cell gain,noise " << igain << " " << anoise_corr << std::endl;
621
622 if (elecNoise) {
623 float adb = elecNoise->getNoise(id,gain);
624
625 // if no correct noise, use reference instead
626 if (anoise_corr<1. && adb>1e-6) {
627 anoise_corr = adb;
628 ATH_MSG_WARNING ( " No noise found for cell: " <<m_calo_id->show_to_string(id) << " gain: " << gain << " Use reference value: " << adb );
629 }
630 if (adb>1e-6) {
631 float delta = std::fabs((anoise_corr-adb)/adb);
632 if (delta>0.30 && gain==CaloGain::LARHIGHGAIN)
633 ATH_MSG_WARNING ( " Noise difference cell " << m_calo_id->show_to_string(id) << " gain: " << gain
634 << " computed " << anoise_corr << " reference " << adb );
635 }
636 }
637
638
639 fprintf(fp,"%5d %5d %5d %8.3f %8.3f\n",iCool,ii,gain,anoise_corr,bnoise[icell]);
640 }
641 }
642// if Tile
643 else {
644 for (int igain=0;igain<4;igain++) {
646 if (igain==0) gain=CaloGain::TILELOWLOW;
647 if (igain==1) gain=CaloGain::TILELOWHIGH;
648 if (igain==2) gain=CaloGain::TILEHIGHLOW;
649 if (igain==3) gain=CaloGain::TILEHIGHHIGH;
650 float anoise_corr = anoise[icell];
651 if (igain>0) {
652 }
653 fprintf(fp,"%5d %5d %5d %8.3f %8.3f\n",iCool,ii,gain,anoise_corr,bnoise[icell]);
654 }
655 }
656
657 } // loop over cells
658
659 fclose(fp);
660 return StatusCode::SUCCESS;
661}
662
664{
665 return StatusCode::SUCCESS;
666}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t sc
HWIdentifier id2
#define y
#define x
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
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
Container class for CaloCell.
SG::ReadCondHandleKey< ILArNoise > m_noiseKey
SG::ReadCondHandleKey< CaloNoise > m_elecNoiseKey
std::string m_lumiFolderName
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
std::vector< CellInfo > m_CellList
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
CaloCellNoiseAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
FloatArrayProperty m_cuts
std::string m_triggerChainProp
virtual StatusCode execute() override
standard Athena-Algorithm method
unsigned int m_lumiblock
virtual StatusCode stop() override
standard Athena-Algorithm method
virtual ~CaloCellNoiseAlg()
Default Destructor.
const CaloCell_ID * m_calo_id
SG::ReadCondHandleKey< CaloNoise > m_totalNoiseKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
virtual StatusCode finalize() override
standard Athena-Algorithm method
virtual StatusCode initialize() override
standard Athena-Algorithm method
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
ToolHandle< Trig::TrigDecisionTool > m_trigDecTool
TDT handle.
ServiceHandle< ITHistSvc > m_thistSvc
unsigned int m_lumiblockOld
static StatusCode readNtuple()
std::unique_ptr< TreeData > m_treeData
This class groups all DetDescr information related to a CaloCell.
This class initializes the Calo (LAr and Tile) offline identifiers.
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition CaloNoise.h:34
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
This is a "hash" representation of an Identifier.
Proxy for accessing a range of float values like a vector.
const_pointer_type cptr()
@ LARMEDIUMGAIN
Definition CaloGain.h:18
@ TILELOWLOW
Definition CaloGain.h:12
@ LARLOWGAIN
Definition CaloGain.h:18
@ TILEONEHIGH
Definition CaloGain.h:17
@ TILELOWHIGH
Definition CaloGain.h:13
@ TILEHIGHLOW
Definition CaloGain.h:14
@ UNKNOWNGAIN
Definition CaloGain.h:21
@ TILEHIGHHIGH
Definition CaloGain.h:15
@ LARHIGHGAIN
Definition CaloGain.h:18
Definition index.py:1