ATLAS Offline Software
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"
7 #include "CaloEvent/CaloCell.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 
19 using CLHEP::HepMatrix;
20 using CLHEP::HepVector;
21 
22 
23 //Constructor
24 CaloCellNoiseAlg::CaloCellNoiseAlg(const std::string& name, ISvcLocator* pSvcLocator):
25  AthAlgorithm(name,pSvcLocator),
26  m_ncell(0),
27  m_lumiblock(0),
28  m_lumiblockOld(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(""),
37  m_triggerChainProp(""),
38  m_addlumiblock(5),
39  m_deltaLumi(0.05)
40 {
41  std::vector<float> data(CaloSampling::Unknown);
43  data[CaloSampling::EMB1] = 100.;
44  data[CaloSampling::EMB2] = 400.;
45  data[CaloSampling::EMB3] = 200.;
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.;
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 
98 
101 
105 
106 
107  m_first = true;
108  m_lumiblock = 0;
109  m_treeData->m_luminosity = 0.;
110  m_lumiblockOld = 0;
111 
112  ATH_CHECK( service("THistSvc",m_thistSvc) );
113 
114  if( !m_trigDecTool.empty() ) {
115  ATH_CHECK( m_trigDecTool.retrieve() );
116  ATH_MSG_INFO ( " --> Found AlgTool TrigDecisionTool" );
117  }
118 
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  }
198  m_treeData->m_luminosity = luminosity;
199  }
201  }
202 
203  if (m_first) {
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)) {
239  }
240  else {
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 
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
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) (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(sqrt(m_treeData->m_luminosity));
451  y.push_back(m_treeData->m_rms[icell]);
452  ey.push_back(m_treeData->m_rms[icell]/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] += ((pow(x[k],i))*(pow(x[k],j))/(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]*(pow(x[k],i))/(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) ;
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++) {
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++) {
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
plotting.yearwise_luminosity_vs_mu.comp
comp
Definition: yearwise_luminosity_vs_mu.py:24
GetLCDefs::Unknown
@ Unknown
Definition: GetLCDefs.h:21
CaloCellNoiseAlg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: CaloCellNoiseAlg.h:63
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
LArADC2MeV::ADC2MEV
const LArVectorProxy ADC2MEV(const HWIdentifier &id, int gain) const
Definition: LArADC2MeV.h:32
CaloCellNoiseAlg::finalize
virtual StatusCode finalize() override
standard Athena-Algorithm method
Definition: CaloCellNoiseAlg.cxx:663
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
CaloCell_ID_FCS::TileExt2
@ TileExt2
Definition: FastCaloSim_CaloCell_ID.h:39
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
constants.EMB1
int EMB1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:53
CaloCellNoiseAlg::m_lumiblock
unsigned int m_lumiblock
Definition: CaloCellNoiseAlg.h:93
WriteCellNoiseToCool.icell
icell
Definition: WriteCellNoiseToCool.py:339
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
CaloCell_Base_ID::phi_min
int phi_min(const Identifier regId) const
min value of phi index (-999 == failure)
drawFromPickle.average
def average(lst)
Definition: drawFromPickle.py:38
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
python.MagFieldUtils.lumiblock
lumiblock
Definition: MagFieldUtils.py:188
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CaloCellNoiseAlg::m_readNtuple
bool m_readNtuple
Definition: CaloCellNoiseAlg.h:117
AtlasDetectorID::is_lar
bool is_lar(Identifier id) const
Definition: AtlasDetectorID.h:689
CaloCellNoiseAlg::m_first
bool m_first
Definition: CaloCellNoiseAlg.h:95
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
DeMoScan.luminosity
luminosity
Definition: DeMoScan.py:271
CaloCellNoiseAlg::m_elecNoiseKey
SG::ReadCondHandleKey< CaloNoise > m_elecNoiseKey
Definition: CaloCellNoiseAlg.h:76
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCellNoiseAlg::getLuminosity
float getLuminosity()
Definition: CaloCellNoiseAlg.cxx:324
CaloCell_Base_ID::is_em_endcap
bool is_em_endcap(const Identifier id) const
test if the id belongs to the EM Endcap
CaloCell_ID_FCS::TileExt0
@ TileExt0
Definition: FastCaloSim_CaloCell_ID.h:37
CaloGain::UNKNOWNGAIN
@ UNKNOWNGAIN
Definition: CaloGain.h:20
CaloCell_ID_FCS::TileBar1
@ TileBar1
Definition: FastCaloSim_CaloCell_ID.h:32
ILArPedestal
Definition: ILArPedestal.h:12
CaloCellNoiseAlg::CaloCellNoiseAlg
CaloCellNoiseAlg(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
Definition: CaloCellNoiseAlg.cxx:24
CaloCell_Base_ID::pos_neg
int pos_neg(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloCell_Base_ID::region_id
Identifier region_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy) const
Make a region ID from constituting fields and subCalo index; for (Mini)FCAL and Tiles,...
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
CaloCellNoiseAlg.h
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
CaloCellNoiseAlg::m_ncell
int m_ncell
Definition: CaloCellNoiseAlg.h:91
CaloCell_ID_FCS::FCAL1
@ FCAL1
Definition: FastCaloSim_CaloCell_ID.h:41
CaloCellNoiseAlg::m_treeData
std::unique_ptr< TreeData > m_treeData
Definition: CaloCellNoiseAlg.h:113
CaloCell.h
AthCommonMsg< Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
CaloCellNoiseAlg::~CaloCellNoiseAlg
virtual ~CaloCellNoiseAlg()
Default Destructor.
Definition: CaloCellNoiseAlg.cxx:83
CaloCellNoiseAlg::fillNtuple
StatusCode fillNtuple()
Definition: CaloCellNoiseAlg.cxx:355
reference
Definition: hcg.cxx:437
CaloCell_ID_FCS::HEC2
@ HEC2
Definition: FastCaloSim_CaloCell_ID.h:29
CaloCell_Base_ID::calo_sample
int calo_sample(const Identifier id) const
returns an int taken from Sampling enum and describing the subCalo to which the Id belongs.
Definition: CaloCell_Base_ID.cxx:141
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
CaloCellNoiseAlg::fitNoise
StatusCode fitNoise()
Definition: CaloCellNoiseAlg.cxx:392
CaloCell_Base_ID::is_tile
bool is_tile(const Identifier id) const
test if the id belongs to the Tiles
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
HWIdentifier
Definition: HWIdentifier.h:13
CaloNoise::getNoise
float getNoise(const IdentifierHash h, const int gain) const
Accessor by IdentifierHash and gain.
Definition: CaloNoise.h:34
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
x
#define x
CaloCellNoiseAlg::m_calo_id
const CaloCell_ID * m_calo_id
Definition: CaloCellNoiseAlg.h:68
Identifier::is_valid
bool is_valid() const
Check if id is in a valid state.
CaloCellNoiseAlg::m_lumiFolderName
std::string m_lumiFolderName
Definition: CaloCellNoiseAlg.h:125
CaloCellNoiseAlg::m_doFit
bool m_doFit
Definition: CaloCellNoiseAlg.h:118
CaloCellNoiseAlg::m_deltaLumi
float m_deltaLumi
Definition: CaloCellNoiseAlg.h:127
CaloCell_ID_FCS::TileGap3
@ TileGap3
Definition: FastCaloSim_CaloCell_ID.h:36
CaloGain::TILELOWLOW
@ TILELOWLOW
Definition: CaloGain.h:12
CaloCell_Base_ID::is_hec
bool is_hec(const Identifier id) const
test if the id belongs to the HEC
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
ILArNoise
Definition: ILArNoise.h:12
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
CaloGain::TILEHIGHHIGH
@ TILEHIGHHIGH
Definition: CaloGain.h:15
BchCleanup.mgr
mgr
Definition: BchCleanup.py:294
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CaloCell_Base_ID::phi_max
int phi_max(const Identifier regId) const
max value of phi index (-999 == failure)
CaloCell_Base_ID::is_em
bool is_em(const Identifier id) const
test if the id belongs to LArEM
PlotCalibFromCool.nentries
nentries
Definition: PlotCalibFromCool.py:798
CaloCell_ID_FCS::HEC1
@ HEC1
Definition: FastCaloSim_CaloCell_ID.h:28
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
CaloIdManager
This class initializes the Calo (LAr and Tile) offline identifiers.
Definition: CaloIdManager.h:45
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
id2
HWIdentifier id2
Definition: LArRodBlockPhysicsV0.cxx:564
lumiFormat.i
int i
Definition: lumiFormat.py:92
CaloCellNoiseAlg::m_tree
TTree * m_tree
Definition: CaloCellNoiseAlg.h:114
trigmenu_modify_prescale_json.fp
fp
Definition: trigmenu_modify_prescale_json.py:53
CaloCellNoiseAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: CaloCellNoiseAlg.h:124
CaloCell_Base_ID::is_fcal
bool is_fcal(const Identifier id) const
test if the id belongs to the FCAL - true also for MiniFCAL
CaloCell_ID_FCS::TileBar0
@ TileBar0
Definition: FastCaloSim_CaloCell_ID.h:31
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
checkxAOD.frac
frac
Definition: Tools/PyUtils/bin/checkxAOD.py:256
CaloCell_ID_FCS::TileGap2
@ TileGap2
Definition: FastCaloSim_CaloCell_ID.h:35
CaloCellNoiseAlg::m_noiseKey
SG::ReadCondHandleKey< ILArNoise > m_noiseKey
Definition: CaloCellNoiseAlg.h:69
CaloCellNoiseAlg::m_addlumiblock
int m_addlumiblock
Definition: CaloCellNoiseAlg.h:126
CaloCellNoiseAlg::CellInfo::nevt
int nevt
Definition: CaloCellNoiseAlg.h:80
CaloCell_Base_ID::eta
int eta(const Identifier id) const
LAr field values (NOT_VALID == invalid request)
constants.EME1
int EME1
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:55
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CaloCell_Base_ID::subcalo_cell_hash
IdentifierHash subcalo_cell_hash(const Identifier cellId, int &subCalo) const
create hash id from 'global' cell id
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
CaloCellNoiseAlg::m_trigDecTool
ToolHandle< Trig::TrigDecisionTool > m_trigDecTool
TDT handle.
Definition: CaloCellNoiseAlg.h:121
CaloGain::TILEHIGHLOW
@ TILEHIGHLOW
Definition: CaloGain.h:14
CaloCell_ID_FCS::TileGap1
@ TileGap1
Definition: FastCaloSim_CaloCell_ID.h:34
CaloCellNoiseAlg::m_doMC
bool m_doMC
Definition: CaloCellNoiseAlg.h:116
AthAlgorithm
Definition: AthAlgorithm.h:47
CaloNoise
Definition: CaloNoise.h:16
CaloCellNoiseAlg::m_thistSvc
ITHistSvc * m_thistSvc
Definition: CaloCellNoiseAlg.h:61
CaloCell_Base_ID::is_em_barrel
bool is_em_barrel(const Identifier id) const
test if the id belongs to the EM barrel
CaloCellNoiseAlg::initialize
virtual StatusCode initialize() override
standard Athena-Algorithm method
Definition: CaloCellNoiseAlg.cxx:88
CaloCellNoiseAlg::readNtuple
static StatusCode readNtuple()
Definition: CaloCellNoiseAlg.cxx:386
CaloGain::TILELOWHIGH
@ TILELOWHIGH
Definition: CaloGain.h:13
CaloCellNoiseAlg::m_lumiblockOld
unsigned int m_lumiblockOld
Definition: CaloCellNoiseAlg.h:94
CaloCellNoiseAlg::m_triggerChainProp
std::string m_triggerChainProp
Definition: CaloCellNoiseAlg.h:122
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
CaloCell_ID_FCS::TileExt1
@ TileExt1
Definition: FastCaloSim_CaloCell_ID.h:38
CaloCell_ID_FCS::EME3
@ EME3
Definition: FastCaloSim_CaloCell_ID.h:26
CaloCellNoiseAlg::m_pedestalKey
SG::ReadCondHandleKey< ILArPedestal > m_pedestalKey
Definition: CaloCellNoiseAlg.h:70
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CaloGain::LARHIGHGAIN
@ LARHIGHGAIN
Definition: CaloGain.h:18
CaloCellContainer.h
CaloCellContainer
Container class for CaloCell.
Definition: CaloCellContainer.h:55
CaloCell_Base_ID::cell_id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
CaloCellNoiseAlg::CellInfo
Definition: CaloCellNoiseAlg.h:79
EventInfo.h
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
CaloCellNoiseAlg::m_cuts
FloatArrayProperty m_cuts
Definition: CaloCellNoiseAlg.h:123
CaloCell_ID_FCS::HEC0
@ HEC0
Definition: FastCaloSim_CaloCell_ID.h:27
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
CaloGain::LARMEDIUMGAIN
@ LARMEDIUMGAIN
Definition: CaloGain.h:18
DeMoScan.index
string index
Definition: DeMoScan.py:362
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
y
#define y
AtlasDetectorID::show_to_string
std::string show_to_string(Identifier id, const IdContext *context=0, char sep='.') const
or provide the printout in string form
Definition: AtlasDetectorID.cxx:574
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
CaloCell_ID_FCS::PreSamplerE
@ PreSamplerE
Definition: FastCaloSim_CaloCell_ID.h:23
CaloCell_ID_FCS::PreSamplerB
@ PreSamplerB
Definition: FastCaloSim_CaloCell_ID.h:19
DeMoScan.first
bool first
Definition: DeMoScan.py:534
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
CaloCell_ID_FCS::FCAL2
@ FCAL2
Definition: FastCaloSim_CaloCell_ID.h:42
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
LArElecCalib::ERRORCODE
@ ERRORCODE
Definition: LArCalibErrorCode.h:17
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
CaloCellNoiseAlg::execute
virtual StatusCode execute() override
standard Athena-Algorithm method
Definition: CaloCellNoiseAlg.cxx:153
CaloGain::LARLOWGAIN
@ LARLOWGAIN
Definition: CaloGain.h:18
IdentifierHash
Definition: IdentifierHash.h:38
CaloCellNoiseAlg::m_totalNoiseKey
SG::ReadCondHandleKey< CaloNoise > m_totalNoiseKey
Definition: CaloCellNoiseAlg.h:74
CaloCellNoiseAlg::m_doLumiFit
bool m_doLumiFit
Definition: CaloCellNoiseAlg.h:119
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
CaloCell_ID_FCS::HEC3
@ HEC3
Definition: FastCaloSim_CaloCell_ID.h:30
CaloGain.h
ILArPedestal::pedestalRMS
virtual float pedestalRMS(const HWIdentifier &id, int gain) const =0
access to RMS of Pedestal index by Identifier, and gain setting
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
CaloCell_ID_FCS::FCAL0
@ FCAL0
Definition: FastCaloSim_CaloCell_ID.h:40
CaloCell_ID_FCS::EMB3
@ EMB3
Definition: FastCaloSim_CaloCell_ID.h:22
CaloCellNoiseAlg::m_nmin
int m_nmin
Definition: CaloCellNoiseAlg.h:120
CaloCell_ID_FCS::TileBar2
@ TileBar2
Definition: FastCaloSim_CaloCell_ID.h:33
readCCLHist.float
float
Definition: readCCLHist.py:83
CaloCellNoiseAlg::stop
virtual StatusCode stop() override
standard Athena-Algorithm method
Definition: CaloCellNoiseAlg.cxx:125
CaloCellNoiseAlg::m_adc2mevKey
SG::ReadCondHandleKey< LArADC2MeV > m_adc2mevKey
Definition: CaloCellNoiseAlg.h:72
CaloGain::TILEONEHIGH
@ TILEONEHIGH
Definition: CaloGain.h:17
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
WriteCellNoiseToCool.noise
noise
Definition: WriteCellNoiseToCool.py:380
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
fitman.k
k
Definition: fitman.py:528
LArVectorProxy
Proxy for accessing a range of float values like a vector.
Definition: LArVectorProxy.h:38
CaloCell_Base_ID::calo_cell_hash_max
size_type calo_cell_hash_max(void) const
cell 'global' hash table max size
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:67
CaloCellNoiseAlg::m_CellList
std::vector< CellInfo > m_CellList
Definition: CaloCellNoiseAlg.h:90