ATLAS Offline Software
TileDigitsFromPulse.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //*****************************************************************************
6 // Filename : TileDigitsFromPulse.cxx
7 // Author : Simon Molander
8 // Created : February 2013
9 //
10 // DESCRIPTION
11 //
12 // Create TileDigits from simulated pulses.
13 //
14 // HISTORY:
15 //
16 // BUGS:
17 //
18 //*****************************************************************************
19 
20 // Tile includes
22 #include "TileEvent/TileDigits.h"
28 
29 //Simulator includes
33 
34 // Athena includes
35 #include "AthAllocators/DataPool.h"
37 //Random number service
40 
41 #include <CLHEP/Random/Randomize.h>
42 #include <CLHEP/Units/SystemOfUnits.h>
43 
44 //Root includes
45 #include "TRandom3.h"
46 #include "TFile.h"
47 #include "TH1F.h"
48 #include "TKey.h"
49 #include "TF1.h"
50 
51 //C++ STL includes
52 #include <vector>
53 
54 
55 using CLHEP::RandGaussQ;
56 using CLHEP::RandFlat;
57 
58 //
59 // Constructor
60 //
61 TileDigitsFromPulse::TileDigitsFromPulse(const std::string& name, ISvcLocator* pSvcLocator) :
62  AthAlgorithm(name, pSvcLocator),
63  m_tileHWID(0),
64  m_tileInfo(0)
65 {
68 
69  declareProperty("ImperfectionMean", m_imperfectionMean = 1.01);
70  declareProperty("ImperfectionRms", m_imperfectionRms = 0.02);
71  declareProperty("InTimeAmp", m_inTimeAmp = 300.);
72  declareProperty("OutOfTimeAmp", m_ootAmp = 150.);
73  declareProperty("InTimeOffset", m_itOffset = 0.);
74  declareProperty("OutOfTimeOffset", m_ootOffset = 50.);
75  declareProperty("OutOfTimeOffsetHistogramFile", m_ootOffsetFileName = "");
76  declareProperty("OutOfTimeOffsetHistogramName", m_ootOffsetHistName = "");
77  declareProperty("UseGaussNoise", m_gaussNoise = kFALSE);
78  declareProperty("GaussNoiseAmpOne", m_GNAmpOne = 1 / 1.039);
79  declareProperty("GaussNoiseSigmaOne", m_GNSigmaOne = 1.6);
80  declareProperty("GaussNoiseAmpTwo", m_GNAmpTwo = 0.039);
81  declareProperty("GaussNoiseSigmaTwo", m_GNSigmaTwo = 3.6);
82  declareProperty("UseInTimeAmpDist", m_useItADist = kFALSE);
83  declareProperty("UseOutOfTimeAmpDist", m_useOotADist = kFALSE);
84  declareProperty("InTimeAmpDistFileName", m_itADistFileName = "");
85  declareProperty("OutOfTimeAmpDistFileName", m_ootADistFileName = "");
86  declareProperty("PileUpFraction", m_pileUpFraction = 1);
87  declareProperty("GaussianC2CPhaseVariation", m_gausC2C = 0);
88  declareProperty("ChannelSpecificPedestal", m_chanPed = kFALSE);
89  declareProperty("ChannelSpecificNoise", m_chanNoise = kFALSE);
90  declareProperty("PedestalValueHG", m_ped_HG = 100);
91  declareProperty("PedestalValueLG", m_ped_LG = 100);
92  declareProperty("AmpDistLowerLimit", m_AmpDistLowLim = 135);
93  declareProperty("InTimeAmpDistHistogramName", m_itADistHistName = "h_Eopt_hi");
94  declareProperty("OutOfTimeAmpDistHistogramName", m_ootADistHistName = "h_Eopt_hi");
95 
96  declareProperty("SimulatePileUpWithPoiss", m_simPUwPoisson = kFALSE);
97  declareProperty("AvgMuForPileUpSimulation", m_avgMuForPU = 40);
98  declareProperty("PileUpAmpDistFileName", m_pileupAmpDistFileName = "");
99 
100  declareProperty("RandomSeed", m_seed = 4357);
101  declareProperty("BunchSpacing", m_BunchSpacing = 25.); // 25, 50 or 75
102  declareProperty("SimulateQIE", m_simQIE = kFALSE);
103 
104  declareProperty("TileInfoName", m_infoName = "TileInfo");
105  declareProperty("TilePhaseII", m_PhaseII = kFALSE);
106  declareProperty("Bigain", m_bigain = kFALSE);
107  declareProperty("NSamples", m_nSamples = 7);
108  declareProperty("nPulses", m_nPul = 21);
109 
110  //Initialisations
111  m_ps[0] = new TilePulseShape(msgSvc(), "TilePulseShapeLo"); //Low Gain
112  m_ps[1] = new TilePulseShape(msgSvc(), "TilePulseShapeHi"); //High Gain
113 
114 
115  m_itFile = new TFile();
116  m_itDist = new TH1F();
117  m_ootFile = new TFile();
118  m_ootDist = new TH1F();
119  m_ootOffsetDist = new TH1F();
120  m_ootOffsetFile = new TFile();
121 
122  m_pileup_AmpDistFile = new TFile();
123 
124  m_useOffsetHisto = kFALSE;
125 
126 }
127 
129 
130  delete m_ootOffsetFile;
131  delete m_ootFile;
132  delete m_itFile;
133  delete m_pileup_AmpDistFile;
134 
135  delete m_ps[0];
136  delete m_ps[1];
137 }
138 
139 //
140 // Alg standard initialize function
141 //
143 
144  ATH_MSG_DEBUG("in initialize()");
145 
146  m_buf = new TileSampleBuffer(m_nSamples, -(m_nSamples-1)*25/2, 25.);
147 
148  m_tsg = new TileSampleGenerator(m_ps[0], m_buf, false); //Set third parameter to true for debug of the sum of pulses
149 
150  m_nPul_eff = (m_nPul - 1) / 2; //Used for symetrization of PU in computation
151 
152  ATH_CHECK(detStore()->retrieve(m_tileHWID, "TileHWID"));
155  ATH_MSG_DEBUG("Max ADC counts TileDigitsFromPulse: " << m_i_ADCmax);
156 
157  ATH_CHECK(m_tileToolNoiseSample.retrieve());
158 
160  ATH_MSG_INFO("Output digits container: " << m_digitsContainerKey.key());
161 
163  ATH_MSG_INFO("Output raw channel container: " << m_rawChannelContainerKey.key());
164 
165 
166  //Build pulse shapes
169 
170  //Initialise distribution histograms if in use
171  if (m_useItADist) {
172  if (m_itADistFileName.size() == 0) {
173  m_itADistFileName = PathResolver::find_file("Distributions_small_h2000_177531_JetTauEtmiss.root", "DATAPATH");
174  if (m_itADistFileName.size() == 0) {
175  ATH_MSG_FATAL("Could not find input file Distributions_small_h2000_177531_JetTauEtmiss.root");
176  return StatusCode::FAILURE;
177  }
178  }
180  return StatusCode::FAILURE;
181  ATH_MSG_DEBUG("Made in-time distribution");
182  } else
183  delete m_itDist;
184 
185  if (m_simPUwPoisson){
186 
187  if (m_pileupAmpDistFileName.size() == 0) {
188  m_pileupAmpDistFileName = PathResolver::find_file("Distributions_MB_minbias_inelastic_lowjetphoton_e8314_e7400_s3508.root", "DATAPATH");
189  //m_pileupAmpDistFileName = PathResolver::find_file("Distributions_small_h2000_177531_ZeroBias.root", "DATAPATH");
190  if (m_pileupAmpDistFileName.size() == 0 ) {
191  ATH_MSG_FATAL("Could not find input file Distributions_MB_minbias_inelastic_lowjetphoton_e8314_e7400_s3508.root");
192  return StatusCode::FAILURE;
193  }
194 
195  }
197  return StatusCode::FAILURE;
198  ATH_MSG_DEBUG("Made PU amp distributions for each partition and channel");
199 
200  }
201 
202  if (m_useOotADist) {
203  if (m_ootADistFileName.size() == 0) {
204  m_ootADistFileName = PathResolver::find_file("Distributions_small_h2000_177531_ZeroBias.root", "DATAPATH");
205  if (m_ootADistFileName.size() == 0) {
206  ATH_MSG_FATAL("Could not find input file Distributions_small_h2000_177531_ZeroBias.root");
207  return StatusCode::FAILURE;
208  }
209  }
211  return StatusCode::FAILURE;
212  ATH_MSG_DEBUG("Made Oot distribution");
213  } else
214  delete m_ootDist;
215 
216  //Initialise timing offset distribution. If filename is empty, use static offset
217  if (m_ootOffsetFileName.size() != 0) {
218  m_ootOffsetFile = TFile::Open(m_ootOffsetFileName.c_str());
219  if (m_ootOffsetFile->IsZombie()) {
220  ATH_MSG_WARNING("Error reading offset timing distribution from " << m_ootOffsetFileName << ". Using static timing offset.");
221  } else {
222  TKey *key = m_ootOffsetFile->FindKey(m_ootOffsetHistName.c_str());
223  if (key == 0) {
224  ATH_MSG_WARNING("Histogram " << m_ootOffsetHistName << " not found in file " << m_ootOffsetFileName << ". Using static timing offset.");
225  } else {
227  m_useOffsetHisto = kTRUE;
228  }
229  }
230  }
231 
232  //Start the random number service used to create channel specific noise
233  if (!m_rndmSvc.retrieve().isSuccess()) {
234  ATH_MSG_FATAL("Could not initialize find Random Number Service.");
235  return StatusCode::FAILURE;
236  }
237  if (m_chanNoise)
238  m_gaussNoise = kFALSE; //Make sure channel noise overrides gaussian noise.
239 
240  ATH_MSG_DEBUG("initialize() successful");
241 
242  return StatusCode::SUCCESS;
243 }
244 /*==========================================================================*/
245 //
246 // Begin Execution Phase.
247 //
249 
250  ATH_MSG_DEBUG("in execute()");
251 
252  const EventContext& ctx = Gaudi::Hive::currentContext();
253 
254  // Prepare RNG service
255  ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, m_randomStreamName);
256  rngWrapper->setSeed( m_randomStreamName, ctx );
257 
258  // Create new container for digits
259  auto digitsContainer = std::make_unique<TileMutableDigitsContainer>(true,
263 
264  ATH_CHECK( digitsContainer->status() );
265 
266  //Create RawChannel for truth values.
267  auto rawChannelContainer = std::make_unique<TileMutableRawChannelContainer>(true, m_rChType, m_rChUnit);
268  ATH_CHECK( rawChannelContainer->status() );
269 
271 
272  TRandom3 *random = new TRandom3(m_seed); //Randomizer for pulse-shape imperfection
273  double tFit = 0, ped = 100; //Settings for simulation
274  double mu = 0; //Interaction per bunch crossing for PU simulation
275 
276  TF1 *pdf = new TF1();
277  TF1 *pdf_PhaseI = new TF1();
278  TF1 *pdf_lo = new TF1();
279  TF1 *pdf_hi = new TF1();
280  if (!m_simQIE) {
281 
282 
283  if(m_PhaseII){
284  Double_t sigma_lo = 1; //Noise value obtained from ATL-COM-TILECAL-2020-031
285  pdf_lo = new TF1("pdf_lo","(1/(sqrt(2*pi)*[0])) * (exp(-0.5*(x/[0])**2)/(sqrt(2*pi)*[0]))", -100, 100);
286  pdf_lo->SetParameter(0,sigma_lo);
287 
288  Double_t sigma_hi = 2.5; //Noise value obtained from ATL-COM-TILECAL-2020-031
289  pdf_hi = new TF1("pdf_hi","(1/(sqrt(2*pi)*[0])) * (exp(-0.5*(x/[0])**2)/(sqrt(2*pi)*[0]))", -100, 100);
290  pdf_hi->SetParameter(0,sigma_hi);
291  }
292  else{
293  //Noise pdf for general noise. Maybe use as a member and put in init.
294  //pdf = new TF1("pdf", "[0] * (Gaus(x,0,[1]) + [2] * Gaus(x,0,[3]))", -100., 100.); //Root goes not like "Gaus"
295 
296  pdf_PhaseI = new TF1("pdf_PhaseI", "[0] * (exp(-0.5*(x/[1])**2)/(sqrt(2*pi)*[1]) + [2] *exp(-0.5*(x/[3])**2)/(sqrt(2*pi)*[3]))", -100., 100.);
297  pdf_PhaseI->SetParameters(m_GNAmpOne, m_GNSigmaOne, m_GNAmpTwo, m_GNSigmaTwo);
298  }
299  }
300 
301  std::vector<float> samples(m_nSamples);
302 
303  double Rndm[16]; // Can't use variable size array,
304  double Rndm_dG[1]; // uniform random number for the double gaussian
305 
306  double amp_1;
307  double amp_2;
308 
309  ATH_MSG_DEBUG("Starting loop");
310  int gain = 1;
311  double n_inTimeAmp = 0.0;
312 
313  for (int ros = 1; ros < 5; ++ros) {
314  for (int drawer = 0; drawer < 64; ++drawer) {
315  unsigned int drawerIdx = TileCalibUtils::getDrawerIdx(ros, drawer);
316  for (int channel = 0; channel < 48; ++channel) {
317 
318  if (!m_simQIE) { //3-in-1 is simulated below
319 
320  if(m_PhaseII){
321  ATH_MSG_VERBOSE("executing FENICS code");
322  }
323  else{
324  ATH_MSG_VERBOSE("executing 3-in-1 code");
325  }
326 
327 
328  bool isHGSaturated = false;
329 
330  for (int igain = 1; igain >= 0; igain--) {
331  gain = igain;
332  if (gain == 1) {
333  n_inTimeAmp = m_useItADist ? m_itDist->GetRandom() : m_inTimeAmp;
334 
335  if (m_chanPed){
337  }
338  else{
339  ped = m_ped_HG;
340  }
341  if (random->Rndm() >= m_pileUpFraction)
342  m_ootAmp = 0; //Set oot amplitude to 0 if no pile-up.
343  tFit = random->Gaus(0., m_gausC2C); //C2C phase variation
344  double deformatedTime = random->Gaus(m_imperfectionMean, m_imperfectionRms); //Widening of pulseshape
345  m_ps[gain]->scalePulse(deformatedTime, deformatedTime); // Deformation of pulse shape by changing its width
346  //if(m_useOffsetHisto) m_ootOffset = m_ootOffsetDist->GetRandom(); //OLD Remove for 7 samples -> BunchSpacing
347 
348  //Pileup samples
349  m_PUAmp.clear();
350  m_PUAmp.resize(m_nPul);
351 
352  for (int i = 0; i <= m_nPul_eff; i++) {
353  if (((i * 25) % m_BunchSpacing) == 0) {
354  if(m_simPUwPoisson){
355  mu=random->Poisson(m_avgMuForPU);
356  ATH_MSG_VERBOSE("Effective pulse number " << i);
357  ATH_MSG_VERBOSE("Number of interactions for simulation: " << mu );
358  for (int imu = 0; imu<mu; imu++){
359 
360  amp_1 = m_pileup_AmpDists[ros-1][channel]->GetRandom();
361  amp_2 = m_pileup_AmpDists[ros-1][channel]->GetRandom();
362 
363  ATH_MSG_VERBOSE("Random amplitudes for PU: " << amp_1 << " " << amp_2);
364 
365  if(i==0){
366  m_PUAmp.at(m_nPul_eff) += abs(amp_1);
367  }
368  else{
369  m_PUAmp.at(m_nPul_eff + i) += abs(amp_1);
370  m_PUAmp.at(m_nPul_eff - i) += abs(amp_2);
371  }
372  }
373 
374  ATH_MSG_VERBOSE("Final amplitudes for pulse " << m_PUAmp.at(m_nPul_eff + i) << " " << m_PUAmp.at(m_nPul_eff - i));
375  }
376  else{
377  m_PUAmp.at(m_nPul_eff + i) = m_useOotADist ? m_ootDist->GetRandom() : m_ootAmp;
378  m_PUAmp.at(m_nPul_eff - i) = m_useOotADist ? m_ootDist->GetRandom() : m_ootAmp;
379  }
380  } else {
381  m_PUAmp.at(m_nPul_eff + i) = 0;
382  m_PUAmp.at(m_nPul_eff - i) = 0;
383  }
384  }
385 
386 
387  } else {
388  if (m_chanPed)
390  double deformatedTime = random->Gaus(m_imperfectionMean, m_imperfectionRms); //Widening of pulseshape
391  m_ps[gain]->scalePulse(deformatedTime, deformatedTime); // Deformation of pulse shape by changing its width
392 
393  if (m_chanPed)
395 
396  else{
397  ped=m_ped_LG;
398  }
399 
400  if(!m_PhaseII){
401  n_inTimeAmp /= 64;
402  for (int i = 0; i <= m_nPul_eff; i++) {
403  m_PUAmp.at(m_nPul_eff + i) /= 64;
404  m_PUAmp.at(m_nPul_eff - i) /= 64;
405  }
406  } else{
407  n_inTimeAmp /= 40;
408  for (int i = 0; i <= m_nPul_eff; i++) {
409  m_PUAmp.at(m_nPul_eff + i) /= 40;
410  m_PUAmp.at(m_nPul_eff - i) /= 40;
411  }
412  }
413  }
414 
415  if(m_PhaseII && m_gaussNoise){
416  pdf = (gain==1) ? pdf_hi : pdf_lo;
417  }
418  else if(m_gaussNoise){
419  pdf = pdf_PhaseI;
420  }
421 
423  m_tsg->fillNSamples(tFit, ped, n_inTimeAmp, m_PUAmp, pdf, m_gaussNoise, m_itOffset, m_nSamples, m_nPul); // Sum of Intime + PU pulses
424 
425  samples.clear();
426  samples.resize(m_nSamples);
428 
429  if (m_chanNoise) {
430  double Hfn1 = m_tileToolNoiseSample->getHfn1(drawerIdx, channel, gain, ctx);
431  double Hfn2 = m_tileToolNoiseSample->getHfn2(drawerIdx, channel, gain, ctx);
432  double Norm = m_tileToolNoiseSample->getHfnNorm(drawerIdx, channel, gain, ctx);
433  RandGaussQ::shootArray(*rngWrapper, samples.size(), Rndm, 0.0, 1.0);
434  RandFlat::shootArray(*rngWrapper, 1, Rndm_dG, 0.0, 1.0);
435  for (unsigned int js = 0; js < samples.size(); ++js) {
436  //using the same gaussian(sigma) for all samples in one channel in one event
437  if (Rndm_dG[0] < Norm)
438  samples[js] += (float) Hfn1 * Rndm[js];
439  else
440  samples[js] += (float) Hfn2 * Rndm[js];
441  }
442  }
443 
444  for (unsigned int i = 0; i < samples.size(); ++i) {
445  if (samples[i] >= m_i_ADCmax){
446  isHGSaturated = true;
448  }
449 
450  }
451 
452  if(!m_bigain){
453  if (!isHGSaturated)
454  break;
455  }
456 
457  if(m_bigain){
458  ATH_MSG_VERBOSE("New ADC " << ros << "/" << drawer << "/" << channel << "/ saving gain " << gain);
459 
460  TileDigits * digit = tileDigitsPool.nextElementPtr();
462  std::move(samples));
463 
464  ATH_CHECK( digitsContainer->push_back(digit) );
465 
466  auto rawChannel = std::make_unique<TileRawChannel>(digit->adc_HWID(),
467  n_inTimeAmp,
468  tFit,
469  m_ootAmp,
470  m_ootOffset);
471 
472  ATH_CHECK( rawChannelContainer->push_back(std::move(rawChannel)) );
473  }
474  }
475 
476  } else { //QIE is simulated here --------------------------------------------
477 
478  //ATH_MSG_DEBUG("executing QIE code");
479 
480  gain = 1; //This is just a place holder. The gain is not used in QIE.
481  n_inTimeAmp = m_useItADist ? m_itDist->GetRandom() : m_inTimeAmp;
482  //if (random->Rndm() >= m_pileUpFraction) //m_pileUpFraction is 1 by default
483  m_ootAmp = 0; //Set oot amplitude to 0 if no pile-up.
484  tFit = 0; //TODO: Introduce jitter of the PMT pulse; random->Gaus(0., m_gausC2C); //C2C phase variation
485 
486  //Pileup samples
487  //m_PUAmp.clear();
488  //m_PUAmp.resize(nPul);
489  float my_PUAmp[7]; //I use an array to store the energies/charges of the out-of-time pulses
490 
491  for (int i = 0; i < 7; i++)
492  if ((((i - 3) * 25) % (int) m_BunchSpacing) == 0) {
493  if (i != 3) { //index 3 corresponds to the in-time pulse, the signal
494  //m_PUAmp.at(i) = m_useOotADist ? m_ootDist->GetRandom() : m_ootAmp; //out-of-time pulses
495  my_PUAmp[i] = m_useOotADist ? m_ootDist->GetRandom() : m_ootAmp; //out-of-time pulses
496  } else {
497  //m_PUAmp.at(i) = 0; //it-time pulse
498  my_PUAmp[i] = 0;
499  }
500  }
501 
502  //fill7SamplesQIE(float t0, float amp_it, float *amp_pu, bool addNoise);
503  m_tsg->fill7SamplesQIE((float) n_inTimeAmp, my_PUAmp); // Sum of In time + out-of-time PU pulses
504 
505  samples.clear();
506  samples.resize(m_nSamples);
508  }
509 
510  if(!m_bigain){
511 
512  ATH_MSG_VERBOSE("New ADC " << ros << "/" << drawer << "/" << channel << "/ saving gain " << gain);
513 
514  TileDigits * digit = tileDigitsPool.nextElementPtr();
516  std::move(samples));
517 
518  ATH_CHECK( digitsContainer->push_back(digit) );
519 
520  auto rawChannel = std::make_unique<TileRawChannel>(digit->adc_HWID(),
521  n_inTimeAmp,
522  tFit,
523  m_ootAmp,
524  m_ootOffset);
525 
526  ATH_CHECK( rawChannelContainer->push_back(std::move(rawChannel)) );
527  }
528  }
529  }
530  }
531 
533  ATH_CHECK( rawChannelCnt.record(std::move(rawChannelContainer)) );
534 
536  ATH_CHECK( digitsCnt.record(std::move(digitsContainer)) );
537 
538  if (!m_simQIE) {
539  //delete pdf;
540  delete pdf_PhaseI;
541  delete pdf_hi;
542  delete pdf_lo;
543  }
544  delete random;
545 
546  ATH_MSG_DEBUG("Execution completed");
547 
548  return StatusCode::SUCCESS;
549 }
550 
552  ATH_MSG_DEBUG("in finalize()");
553  delete m_buf;
554  delete m_tsg;
555 
556 
557  if (m_useItADist)
558  m_itFile->Close();
559  if (m_useOotADist)
560  m_ootFile->Close();
561  if (m_simPUwPoisson)
562  m_pileup_AmpDistFile->Close();
563 
564  return StatusCode::SUCCESS;
565 }
566 
567 bool TileDigitsFromPulse::makeDist(TFile*& file, TH1F*& hist, const std::string& fileName, const std::string& histName) {
568  file = new TFile(fileName.c_str());
569  if (file->IsZombie()) {
570  ATH_MSG_FATAL("Error reading amplitude distribution from " << fileName << ".");
571  return kFALSE;
572  }
573  TKey *key = file->FindKey(histName.c_str());
574  if (key == 0) {
575  ATH_MSG_FATAL("Could not find histogram " << histName << " in file " << fileName << ".");
576  return kFALSE;
577  }
578  hist = (TH1F*) file->Get(histName.c_str());
579  for (int i = 0; i < m_AmpDistLowLim; i++)
580  hist->SetBinContent(i, 0.); // Puts a cut on the amplitude distribution.
581  return kTRUE;
582 
583 }
584 
585 bool TileDigitsFromPulse::makeDist(TFile*& file, std::vector<std::vector<TH1F*>>& hists, const std::string& fileName) {
586 
587  std::string histName;
588  TKey *key;
589  TH1F* hist;
590 
591  file = new TFile(fileName.c_str());
592  if (file->IsZombie()) {
593  ATH_MSG_FATAL("Error reading amplitude distributions from " << fileName << ".");
594  return kFALSE;
595  }
596 
597  for(int ros=0; ros<4; ros++){
598 
599  hists.push_back(std::vector<TH1F*>());
600  for(int channel=0; channel<48; channel++){
601 
602  histName = "ene_ros_" + std::to_string(ros+1) + "_channel_" + std::to_string(channel+1);
603 
604  key = file->FindKey(histName.c_str());
605  if (key == 0) {
606  ATH_MSG_FATAL("Could not find histogram " << histName << " in file " << fileName << ".");
607  return kFALSE;
608  }
609 
610  hist = (TH1F*) file->Get(histName.c_str());
611 
612  for (int i = 0; i < m_AmpDistLowLim; i++)
613  hist->SetBinContent(i, 0.); // Puts a cut on the amplitude distribution.
614 
615  hists[ros].push_back(hist);
616  hist->Clear();
617  }
618  }
619 
620  return kTRUE;
621 
622 }
TileDigitsFromPulse::m_ped_LG
double m_ped_LG
Pedestal value for LG if specific channel pedestal is not used.
Definition: TileDigitsFromPulse.h:134
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TileDigitsFromPulse::makeDist
bool makeDist(TFile *&file, TH1F *&hist, const std::string &fileName, const std::string &histName="h_Eopt_hi")
Method to read distribution from file.
Definition: TileDigitsFromPulse.cxx:567
TileDigitsFromPulse::finalize
virtual StatusCode finalize() override
finalize method
Definition: TileDigitsFromPulse.cxx:551
TileDigitsFromPulse::m_buf
TileSampleBuffer * m_buf
Buffer class to hold generated pulses.
Definition: TileDigitsFromPulse.h:171
TileDigitsFromPulse::m_i_ADCmax
int m_i_ADCmax
Definition: TileDigitsFromPulse.h:107
ATHRNG::RNGWrapper::setSeed
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition: RNGWrapper.h:169
TileDigitsFromPulse::m_GNSigmaOne
double m_GNSigmaOne
Standard deviation of first gaussian of double gaussian noise.
Definition: TileDigitsFromPulse.h:137
TileSampleGenerator::fillNSamples
void fillNSamples(double t0, double pedestal, double amp_it, const std::vector< float > &amp_pu, TF1 *pdf, bool addNoise, double itOffset=0, int nSamples=7, int nPul=21)
Definition: TileSampleGenerator.cxx:64
TileDigitsFromPulse::m_tsg
TileSampleGenerator * m_tsg
Pulse generating class.
Definition: TileDigitsFromPulse.h:172
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
TileInfo::digitsFullShapeLo
const std::vector< double > & digitsFullShapeLo() const
Return shape vector with full binning to produce the TileDigits from sub-hits.
Definition: TileInfo.h:186
TileDigitsFromPulse::m_nPul
int m_nPul
number of pileup pulses
Definition: TileDigitsFromPulse.h:159
TileDigitsFromPulse::m_ps
TilePulseShape * m_ps[2]
Class for defining pulse.
Definition: TileDigitsFromPulse.h:170
AddEmptyComponent.histName
string histName
Definition: AddEmptyComponent.py:64
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
TileDigitsFromPulse::m_pileup_AmpDists
std::vector< std::vector< TH1F * > > m_pileup_AmpDists
Matrix of PU amplitude distribution histograms (PU per partition and channel)
Definition: TileDigitsFromPulse.h:183
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition: OwnershipPolicy.h:18
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
plotmaker.hist
hist
Definition: plotmaker.py:148
TileDigitsFromPulse::m_tileHWID
const TileHWID * m_tileHWID
Definition: TileDigitsFromPulse.h:102
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
TileDigitsFromPulse::m_simQIE
bool m_simQIE
Raw PMT pulses are generated if the option is set to true.
Definition: TileDigitsFromPulse.h:154
TileSampleBuffer::getValueVector
void getValueVector(std::vector< float > &vec)
Definition: TileSampleBuffer.h:29
TileDigitsFromPulse::m_pileup_AmpDistFile
TFile * m_pileup_AmpDistFile
File containing amplitude histograms for PU pulses.
Definition: TileDigitsFromPulse.h:182
TileDigitsFromPulse::m_itADistHistName
std::string m_itADistHistName
Name of histogram for in-time amplitude distribution.
Definition: TileDigitsFromPulse.h:151
TileDigitsFromPulse::m_ootOffset
double m_ootOffset
Out-of-time pulse offset from nominal time.
Definition: TileDigitsFromPulse.h:132
TileDigitsFromPulse::m_useOffsetHisto
bool m_useOffsetHisto
Internally used to keep track of wether a histogram has been opened or not.
Definition: TileDigitsFromPulse.h:181
TileInfo.h
TilePulseShape
Definition: TilePulseShape.h:17
TileDigitsFromPulse::m_PUAmp
std::vector< float > m_PUAmp
Definition: TileDigitsFromPulse.h:161
TileCalibUtils.h
TileDigitsFromPulse::m_imperfectionRms
double m_imperfectionRms
RMS of pulse shape broadening.
Definition: TileDigitsFromPulse.h:128
TileSampleBuffer
Definition: TileSampleBuffer.h:14
TileDigitsFromPulse::m_nPul_eff
int m_nPul_eff
Definition: TileDigitsFromPulse.h:160
TileDigitsFromPulse::m_chanPed
bool m_chanPed
Use channel specific pedestal value if true.
Definition: TileDigitsFromPulse.h:146
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
TileFragHash::Digitizer
@ Digitizer
Definition: TileFragHash.h:33
TileDigitsFromPulse::m_ootOffsetHistName
std::string m_ootOffsetHistName
Name of the histogram for timing offset distribution.
Definition: TileDigitsFromPulse.h:149
TileSampleGenerator::fill7SamplesQIE
void fill7SamplesQIE(float amp_it, float *amp_pu)
Definition: TileSampleGenerator.cxx:135
Example_ReadSampleNoise.drawer
drawer
Definition: Example_ReadSampleNoise.py:39
TileDigitsFromPulse::m_infoName
std::string m_infoName
Definition: TileDigitsFromPulse.h:105
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
TileDigitsFromPulse::m_ootAmp
double m_ootAmp
Amplitude of out-of-time pulse.
Definition: TileDigitsFromPulse.h:130
TileDigitsFromPulse::m_nSamples
int m_nSamples
number of read out samples
Definition: TileDigitsFromPulse.h:158
TileDigitsFromPulse::m_useItADist
bool m_useItADist
Set to TRUE in order to use a distribution for the in-time amplitude instead of a constant value.
Definition: TileDigitsFromPulse.h:140
TileDigitsFromPulse::m_chanNoise
bool m_chanNoise
Add channel specific noise.
Definition: TileDigitsFromPulse.h:147
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
TileHWID.h
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
lumiFormat.i
int i
Definition: lumiFormat.py:92
TileDigitsFromPulse::m_bigain
bool m_bigain
Definition: TileDigitsFromPulse.h:163
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
01SubmitToGrid.samples
samples
Definition: 01SubmitToGrid.py:58
TileDigitsFromPulse::m_itADistFileName
std::string m_itADistFileName
Filename of file to use for amplitude distribution of in-time pulses.
Definition: TileDigitsFromPulse.h:144
TileInfo::digitsFullShapeHi
const std::vector< double > & digitsFullShapeHi() const
Return shape vector with full binning to produce the TileDigits from sub-hits.
Definition: TileInfo.h:184
TileDigitsFromPulse::m_digitsContainerKey
SG::WriteHandleKey< TileDigitsContainer > m_digitsContainerKey
Definition: TileDigitsFromPulse.h:115
TileDigitsFromPulse::m_pileupAmpDistFileName
std::string m_pileupAmpDistFileName
Filename for PU amplitude distribution histograms.
Definition: TileDigitsFromPulse.h:167
JetVoronoiDiagramHelpers::Norm
Point Norm(const Point &a)
Definition: JetVoronoiDiagramHelpers.cxx:79
file
TFile * file
Definition: tile_monitor.h:29
TileSampleGenerator
Definition: TileSampleGenerator.h:16
TileMutableDigitsContainer.h
Helper for holding non-const raw data prior to recording in SG.
TileDigitsFromPulse::m_ootDist
TH1F * m_ootDist
Histogram to hold the distribution of out-of-time amplitudes.
Definition: TileDigitsFromPulse.h:175
TileHWID::adc_hash_max
size_type adc_hash_max(void) const
ADC hash table max size.
Definition: TileHWID.h:276
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TileDigitsFromPulse::m_ootOffsetFileName
std::string m_ootOffsetFileName
File name for offset timing distribution histogram.
Definition: TileDigitsFromPulse.h:148
MakeTH3DFromTH2Ds.hists
hists
Definition: MakeTH3DFromTH2Ds.py:72
TileDigitsFromPulse::m_tileInfo
const TileInfo * m_tileInfo
Definition: TileDigitsFromPulse.h:106
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
TileDigitsFromPulse::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Random number service to use.
Definition: TileDigitsFromPulse.h:121
maskDeadModules.ros
ros
Definition: maskDeadModules.py:35
DataPool::nextElementPtr
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
TileDigitsFromPulse::m_itOffset
double m_itOffset
In-time pulse offset from nominal time.
Definition: TileDigitsFromPulse.h:131
AthAlgorithm
Definition: AthAlgorithm.h:47
TilePulseShape::scalePulse
int scalePulse(double leftSF=1., double rightSF=1.)
Definition: TilePulseShape.cxx:138
TileDigitsFromPulse::m_imperfectionMean
double m_imperfectionMean
Mean value of pulse shape broadening.
Definition: TileDigitsFromPulse.h:127
TileDigitsFromPulse::m_useOotADist
bool m_useOotADist
Set to TRUE in order to use a distribution for the out-of-time amplitude instead of a constant value.
Definition: TileDigitsFromPulse.h:141
DataPool.h
TileDigitsFromPulse::initialize
virtual StatusCode initialize() override
initialize method
Definition: TileDigitsFromPulse.cxx:142
TileDigitsFromPulse::m_BunchSpacing
int m_BunchSpacing
Time between pulses in ms 25, 50 or 75.
Definition: TileDigitsFromPulse.h:157
PathResolver.h
TileDigitsFromPulse::m_GNAmpTwo
double m_GNAmpTwo
Amplitude of second gaussian of double gaussian noise.
Definition: TileDigitsFromPulse.h:138
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
ATHRNG::RNGWrapper
A wrapper class for event-slot-local random engines.
Definition: RNGWrapper.h:56
TileDigits
Definition: TileDigits.h:30
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TileDigitsFromPulse::m_ootOffsetDist
TH1F * m_ootOffsetDist
Histogram to hold the distribution of out-of-time timing offsets.
Definition: TileDigitsFromPulse.h:179
TileDigitsFromPulse::m_ootADistHistName
std::string m_ootADistHistName
Name of histogram for out-of-time amplitude distribution.
Definition: TileDigitsFromPulse.h:152
TileDigitsFromPulse::m_ootADistFileName
std::string m_ootADistFileName
Filename of file to use for amplitude distribution of out-of-time pulses.
Definition: TileDigitsFromPulse.h:145
RNGWrapper.h
Example_ReadSampleNoise.ped
ped
Definition: Example_ReadSampleNoise.py:45
TileDigitsFromPulse::m_simPUwPoisson
bool m_simPUwPoisson
Definition: TileDigitsFromPulse.h:165
TileHWID::adc_id
HWIdentifier adc_id(int ros, int drawer, int channel, int adc) const
adc HWIdentifer
Definition: TileHWID.cxx:228
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TileDigitsFromPulse::m_gaussNoise
bool m_gaussNoise
Set to TRUE in order to create noise from double gaussian.
Definition: TileDigitsFromPulse.h:135
TileDigitsFromPulse::m_GNSigmaTwo
double m_GNSigmaTwo
Standard deviation of second gaussian of double gaussian noise.
Definition: TileDigitsFromPulse.h:139
TileDigitsFromPulse::TileDigitsFromPulse
TileDigitsFromPulse(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TileDigitsFromPulse.cxx:61
TileDigitsFromPulse::m_seed
int m_seed
Definition: TileDigitsFromPulse.h:156
TileMutableRawChannelContainer.h
Helper for holding non-const raw data prior to recording in SG.
TileDigitsFromPulse::m_ped_HG
double m_ped_HG
Pedestal value for HG if specific channel pedestal is not used.
Definition: TileDigitsFromPulse.h:133
TileDigitsFromPulse::m_AmpDistLowLim
int m_AmpDistLowLim
Set all bins to the left of this bin to 0 in the amplitude distribution histograms.
Definition: TileDigitsFromPulse.h:150
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
TH1F
Definition: rootspy.cxx:320
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TileDigitsFromPulse::~TileDigitsFromPulse
virtual ~TileDigitsFromPulse()
Definition: TileDigitsFromPulse.cxx:128
TileDigitsFromPulse::m_gausC2C
float m_gausC2C
RMS for the in-time pulse offset (channel-to-channel phase variation)
Definition: TileDigitsFromPulse.h:143
TileDigitsFromPulse::m_PhaseII
bool m_PhaseII
Definition: TileDigitsFromPulse.h:162
TileSampleGenerator.h
TileDigitsFromPulse::m_tileToolNoiseSample
ToolHandle< TileCondToolNoiseSample > m_tileToolNoiseSample
Definition: TileDigitsFromPulse.h:112
TileDigitsFromPulse::m_itFile
TFile * m_itFile
File that holds the distribution of in-time amplitudes.
Definition: TileDigitsFromPulse.h:177
TileDigitsFromPulse::m_pileUpFraction
float m_pileUpFraction
Probability that an out-of-time component will be added.
Definition: TileDigitsFromPulse.h:142
PowhegPythia8EvtGen_jetjet.pdf
pdf
Definition: PowhegPythia8EvtGen_jetjet.py:4
DataPool
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
Definition: DataPool.h:47
TileSampleGenerator::setPulseShape
void setPulseShape(TilePulseShape *ps)
Definition: TileSampleGenerator.h:22
TileDigitsFromPulse::m_itDist
TH1F * m_itDist
Histogram to hold the distribution of in-time amplitudes.
Definition: TileDigitsFromPulse.h:176
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
TileCalibUtils::getDrawerIdx
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Definition: TileCalibUtils.cxx:60
TileDigitsFromPulse::m_GNAmpOne
double m_GNAmpOne
Amplitude of first gaussian of double gaussian noise.
Definition: TileDigitsFromPulse.h:136
TileAANtupleConfig.rawChannelContainer
rawChannelContainer
Definition: TileAANtupleConfig.py:120
TileDigitsFromPulse::m_rChUnit
TileRawChannelUnit::UNIT m_rChUnit
Units used for the TileRawChannels (ADC, pCb, etc.)(see TileInfo.h)
Definition: TileDigitsFromPulse.h:109
TileDigitsFromPulse::m_rChType
TileFragHash::TYPE m_rChType
Type of TileRawChannels (Digitizar, OF1, OF2, Fit, etc.)(see TileFragHash.h)
Definition: TileDigitsFromPulse.h:110
TileDigits.h
TileDigitsFromPulse::m_ootFile
TFile * m_ootFile
File that holds the distribution of out-of-time amplitudes.
Definition: TileDigitsFromPulse.h:178
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
TileDigitsFromPulse::m_rawChannelContainerKey
SG::WriteHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Definition: TileDigitsFromPulse.h:118
TileDigitsFromPulse.h
TileDigitsFromPulse::m_inTimeAmp
double m_inTimeAmp
Amplitude of in-time pulse.
Definition: TileDigitsFromPulse.h:129
TilePulseShape.h
TileSampleBuffer.h
readCCLHist.float
float
Definition: readCCLHist.py:83
TilePulseShape::setPulseShape
void setPulseShape(const std::vector< double > &shapevec)
Definition: TilePulseShape.cxx:60
TileInfo::ADCmax
int ADCmax() const
Returns the maximum ADC output (10 bits --> 1023)
Definition: TileInfo.h:71
TileFragHash::Default
@ Default
Definition: TileFragHash.h:33
TileRawChannelUnit::ADCcounts
@ ADCcounts
Definition: TileRawChannelUnit.h:17
TileDigitsFromPulse::m_avgMuForPU
int m_avgMuForPU
Definition: TileDigitsFromPulse.h:166
TileDigitsFromPulse::m_randomStreamName
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Definition: TileDigitsFromPulse.h:123
TileDigitsFromPulse::execute
virtual StatusCode execute() override
execute method
Definition: TileDigitsFromPulse.cxx:248
IAthRNGSvc.h
TileDigitsFromPulse::m_ootOffsetFile
TFile * m_ootOffsetFile
File that holds the distribution of out-of-time timing offsets.
Definition: TileDigitsFromPulse.h:180
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37