CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalBarrelRecHitsMaker.cc
Go to the documentation of this file.
6 
27 
28 #include "CLHEP/GenericFunctions/Erf.hh"
29 //#include <algorithm>
30 
32  const RandomEngine* myrandom)
33  : random_(myrandom)
34 {
35  edm::ParameterSet RecHitsParameters=p.getParameter<edm::ParameterSet>("ECALBarrel");
36  inputCol_=RecHitsParameters.getParameter<edm::InputTag>("MixedSimHits");
37  noise_ = RecHitsParameters.getParameter<double>("Noise");
38  threshold_ = RecHitsParameters.getParameter<double>("Threshold");
39  refactor_ = RecHitsParameters.getParameter<double> ("Refactor");
40  refactor_mean_ = RecHitsParameters.getParameter<double> ("Refactor_mean");
41  noiseADC_ = RecHitsParameters.getParameter<double>("NoiseADC");
42  highNoiseParameters_ = RecHitsParameters.getParameter<std::vector<double> > ("HighNoiseParameters");
43  SRThreshold_ = RecHitsParameters.getParameter<double> ("SRThreshold");
44  SREtaSize_ = RecHitsParameters.getUntrackedParameter<int> ("SREtaSize",1);
45  SRPhiSize_ = RecHitsParameters.getUntrackedParameter<int> ("SRPhiSize",1);
48  crystalsinTT_.resize(2448);
49  TTTEnergy_.resize(2448,0.);
50  TTHighInterest_.resize(2448,0);
51  treatedTTs_.resize(2448,false);
52  theTTDetIds_.resize(2448);
53  neighboringTTs_.resize(2448);
54  sinTheta_.resize(86,0.);
55  doCustomHighNoise_=false;
56  // Initialize the Gaussian tail generator
57  // Two options : noise is set by the user (to a positive value). In this case, this value is taken
58  // or the user chose to use the noise from DB. In this case, the noise is flat in pT and not in energy
59  // but the threshold is in energy and not in pT.
60  doCustomHighNoise_=highNoiseParameters_.size()>=3;
61  Genfun::Erf myErf;
62  if( noise_>0. ) {
63  EBHotFraction_ = 0.5-0.5*myErf(threshold_/noise_/sqrt(2.));
64  myGaussianTailGenerator_ = new GaussianTail(random_, noise_, threshold_);
65  edm::LogInfo("CaloRecHitsProducer") <<"Uniform noise simulation selected in the barrel";
66  } else if (noise_==-1 && doCustomHighNoise_)
67  {
68  if(highNoiseParameters_.size()==4)
69  EBHotFraction_ = 0.5-0.5*myErf(highNoiseParameters_[3]/highNoiseParameters_[2]/sqrt(2.));
70  if(highNoiseParameters_.size()==3)
71  EBHotFraction_ = highNoiseParameters_[2] ;
72  edm::LogInfo("CaloRecHitsProducer")<< " The gaussian model for high noise fluctuation cells after ZS is selected (best model), hot fraction " << EBHotFraction_ << std::endl;
73  }
74 
75  noisified_ = (noise_==0.);
76  edm::ParameterSet CalibParameters = RecHitsParameters.getParameter<edm::ParameterSet>("ContFact");
77  double c1=CalibParameters.getParameter<double>("EBs25notContainment");
78  calibfactor_=1./c1;
79 
80 
81 }
82 
84 {;
85 }
86 
87 
89 {
90  // std::cout << " clean " << std::endl;
91  unsigned size=theFiredCells_.size();
92  for(unsigned ic=0;ic<size;++ic)
93  {
95  applyZSCells_[theFiredCells_[ic]] = true;
96  }
97  theFiredCells_.clear();
98  // If the noise is set to 0. No need to simulate it.
99  noisified_ = (noise_==0.);
100  // std::cout << " Finished to clean " << std::endl;
101 
102  size=theFiredTTs_.size();
103  // std::cout << " Number of barrel TT " << size << std::endl;
104  for(unsigned itt=0;itt<size;++itt)
105  {
106  // std::cout << " TT " << theFiredTTs_[itt] << " " << TTTEnergy_[theFiredTTs_[itt]] << std::endl;
107  TTTEnergy_[theFiredTTs_[itt]]=0.;
108  treatedTTs_[theFiredTTs_[itt]]=false;
109  }
110  theFiredTTs_.clear();
111 
112  size=theTTofHighInterest_.size();
113  for(unsigned itt=0;itt<size;++itt)
115  theTTofHighInterest_.clear();
116 
117 // std::cout << " Check cleaning " << std::endl;
118 // for(unsigned ic=0;ic<TTTEnergy_.size();++ic)
119 // if(TTTEnergy_[ic]!=0.) std::cout << " TT " << ic << " not cleaned " << std::endl;
120 // for(unsigned ic=0;ic<TTHighInterest_.size();++ic)
121 // if(TTHighInterest_[ic]!=0) std::cout << " TTHighInterest " << ic << TTHighInterest_[ic] << " not cleaned " << std::endl;
122 // for(unsigned ic=0;ic<treatedTTs_.size();++ic)
123 // if(treatedTTs_[ic]) std::cout << " treatedTT " << ic << treatedTTs_[ic] << " not cleaned " << std::endl;
124 
125 }
126 
128 {
129 
130  clean();
131  loadPCaloHits(iEvent);
132 
133  unsigned nhit=theFiredCells_.size();
134  // std::cout << " loadEcalBarrelRecHits " << nhit << std::endl;
135  unsigned gain, adc;
136  ecalDigis.reserve(nhit);
137  ecalHits.reserve(nhit);
138  for(unsigned ihit=0;ihit<nhit;++ihit)
139  {
140  unsigned icell = theFiredCells_[ihit];
141 
142  EBDetId myDetId(barrelRawId_[icell]);
143  EcalTrigTowerDetId towid= eTTmap_->towerOf(myDetId);
144  int TThashedindex=towid.hashedIndex();
145 
146  if(doDigis_)
147  {
148  ecalDigis.push_back( myDetId );
149  EBDataFrame myDataFrame( ecalDigis.back() );
150  // myDataFrame.setSize(1); // now useless - by construction fixed at 1 frame - FIXME
151  // The real work is in the following line
152  geVtoGainAdc(theCalorimeterHits_[icell],gain,adc);
153  myDataFrame.setSample(0,EcalMGPASample(adc,gain));
154 
155  // std::cout << "myDataFrame" << myDataFrame.sample(0).raw() << std::endl;
156  //ecalDigis.push_back(myDataFrame);
157  }
158 
159  // If the energy+noise is below the threshold, a hit is nevertheless created, otherwise, there is a risk that a "noisy" hit
160  // is afterwards put in this cell which would not be correct.
161  float energy=theCalorimeterHits_[icell];
162  // std::cout << myDetId << " Energy " << theCalorimeterHits_[icell] << " " << TTTEnergy_[TThashedindex] << " " << isHighInterest(TThashedindex) << std::endl;
163  if ( SRThreshold_ && energy < threshold_ && !isHighInterest(TThashedindex) && applyZSCells_[icell])
164  {
165  // std::cout << " Killed " << std::endl;
166  theCalorimeterHits_[icell]=0.;
167  energy=0.;
168  }
169  // else
170  // std::cout << " SR " << TTTEnergy_[TThashedindex] << " Cell energy " << energy << " 1" << std::endl;
171 // if( TTTEnergy_[TThashedindex] < SRThreshold_ && energy > threshold_)
172 // std::cout << " SR " << TTTEnergy_[TThashedindex] << " Cell energy " << energy << std::endl;
173  if (energy > sat_)
174  {
175  theCalorimeterHits_[icell]=sat_;
176  energy=sat_;
177  }
178 // std::cout << " Threshold ok " << std::endl;
179 // std::cout << " Raw Id " << barrelRawId_[icell] << std::endl;
180 // std::cout << " Adding " << icell << " " << barrelRawId_[icell] << " " << energy << std::endl;
181  if(energy!=0.)
182  ecalHits.push_back(EcalRecHit(myDetId,energy,0.));
183  // std::cout << " Hit stored " << std::endl;
184  }
185  // std::cout << " Done " << std::endl;
186 
187 }
188 
190 {
191 
193  iEvent.getByLabel(inputCol_,cf);
194  std::auto_ptr<MixCollection<PCaloHit> > colcalo(new MixCollection<PCaloHit>(cf.product(),std::pair<int,int>(0,0) ));
195 
196 
197  theFiredCells_.reserve(colcalo->size());
198 
200  MixCollection<PCaloHit>::iterator cficaloend=colcalo->end();
201 
202  for (cficalo=colcalo->begin(); cficalo!=cficaloend;cficalo++)
203  {
204  unsigned hashedindex = EBDetId(cficalo->id()).hashedIndex();
205  // the famous 1/0.97 calibration factor is applied here !
206  // the miscalibration is applied here:
208  // Check if the hit already exists
209  if(theCalorimeterHits_[hashedindex]==0.)
210  {
211  theFiredCells_.push_back(hashedindex);
212  float noise=(noise_==-1.) ? noisesigma_[hashedindex] : noise_ ;
213  if (!noisified_ ) theCalorimeterHits_[hashedindex] += random_->gaussShoot(0.,noise*calib);
214  }
215 
216 
217  // cficalo->energy can be 0 (a 7x7 grid is always built) if there is no noise simulated, in this case the cells should
218  // not be added several times.
219  float energy=(cficalo->energy()==0.) ? 0.000001 : cficalo->energy() ;
220  energy*=calib;
221  theCalorimeterHits_[hashedindex]+=energy;
222 
223  // Now deal with the TTs.
224  EBDetId myDetId(EBDetId(cficalo->id()));
225  EcalTrigTowerDetId towid= eTTmap_->towerOf(myDetId);
226 // std::cout << " Added " << energy << " in " << EBDetId(cficalo->id()) << std::endl;
227  int TThashedindex=towid.hashedIndex();
228  if(TTTEnergy_[TThashedindex]==0.)
229  {
230  theFiredTTs_.push_back(TThashedindex);
231 // std::cout << " Creating " ;
232  }
233  // std::cout << " Updating " << TThashedindex << " " << energy << " " << sinTheta_[myDetId.ietaAbs()] <<std::endl;
234  TTTEnergy_[TThashedindex]+=energy*sinTheta_[myDetId.ietaAbs()];
235  // std::cout << " TT " << TThashedindex << " updated, now contains " << TTTEnergy_[TThashedindex] << std::endl;
236  }
238  noisified_ = true;
239 }
240 
242 {
243  if(noise_==0.) return;
244 // std::cout << " List of TT before" << std::endl;
245 // for(unsigned itt=0;itt<theFiredTTs_.size();++itt)
246 // std::cout << " TT " << theFiredTTs_[itt] << " " << TTTEnergy_[theFiredTTs_[itt]] << std::endl;
247 
248  // std::cout << " Starting to noisify the trigger towers " << std::endl;
249  unsigned nTT=theFiredTTs_.size();
250  for(unsigned itt=0;itt<nTT;++itt)
251  {
252  // std::cout << "Treating " << theFiredTTs_[itt] << " " << theTTDetIds_[theFiredTTs_[itt]].ieta() << " " << theTTDetIds_[theFiredTTs_[itt]].iphi() << " " << TTTEnergy_[theFiredTTs_[itt]] << std::endl;
253  // shoot noise in the trigger tower
255  // get the neighboring TTs
256  const std::vector<int>& neighbors=neighboringTTs_[theFiredTTs_[itt]];
257  unsigned nneighbors=neighbors.size();
258  // inject noise in those towers only if they have not been looked at yet
259  // std::cout << " Now looking at the neighbours " << std::endl;
260  for(unsigned in=0;in<nneighbors;++in)
261  {
262  // std::cout << " TT " << neighbors[in] << " " << theTTDetIds_[neighbors[in]] << " has been treated " << treatedTTs_[neighbors[in]] << std::endl;
263  if(!treatedTTs_[neighbors[in]])
264  {
265  noisifyTriggerTower(neighbors[in]);
266  if(TTTEnergy_[neighbors[in]]==0.)
267  theFiredTTs_.push_back(neighbors[in]);
268  // std::cout << " Added " << neighbors[in] << " in theFiredTTs_ " << std::endl;;
269  }
270  }
271  }
272 // std::cout << " List of TT after" << std::endl;
273 // for(unsigned itt=0;itt<theFiredTTs_.size();++itt)
274 // {
275 // std::cout << " TT " << theFiredTTs_[itt] << " " << TTTEnergy_[theFiredTTs_[itt]] << std::endl;
276 // const std::vector<int> & xtals=crystalsinTT_[theFiredTTs_[itt]];
277 // for(unsigned ic=0;ic<xtals.size();++ic)
278 // std::cout << EBDetId::unhashIndex(xtals[ic]) << " " << theCalorimeterHits_[xtals[ic]] << std::endl;
279 // }
280 
281  randomNoisifier();
282 }
283 
285 {
286  // check if the TT has already been treated or not
287  if(treatedTTs_[tthi]) return false;
288  // get the crystals in the TT (this info might need to be cached)
289  // const std::vector<DetId> & xtals=eTTmap_->constituentsOf(theTTDetIds_[tthi]);
290  const std::vector<int> & xtals(crystalsinTT_[tthi]);
291  unsigned nxtals=xtals.size();
292  unsigned counter =0 ;
293  float energy=0.;
294  for(unsigned ic=0;ic<nxtals;++ic)
295  {
296  unsigned hashedindex=xtals[ic];
297  // check if the crystal has been already hit
298 // std::cout << " Checking " << EBDetId(barrelRawId_[xtals[ic]]) << " " << theCalorimeterHits_[hashedindex] << std::endl;
299  if(theCalorimeterHits_[hashedindex]==0)
300  {
302  float noise = (noise_==-1.) ? noisesigma_[hashedindex]:noise_;
303  float energy = calib*random_->gaussShoot(0.,noise);
304  theCalorimeterHits_[hashedindex]=energy;
305  // std::cout << " Updating with noise " << tthi << " " << energy << " " << sinTheta_[EBDetId(barrelRawId_[hashedindex]).ietaAbs()] << std::endl;
306  if(TTTEnergy_[tthi]==0.)
307  theFiredTTs_.push_back(tthi);
308  TTTEnergy_[tthi]+=energy*sinTheta_[EBDetId(barrelRawId_[hashedindex]).ietaAbs()];
309 
310  theFiredCells_.push_back(hashedindex);
311  ++counter;
312  }
313  else
314  energy+=theCalorimeterHits_[hashedindex];
315  }
316 // std::cout << " Energy " << energy << " Added noise in " << counter << " cells" << std::endl;
317  treatedTTs_[tthi]=true;
318  return true;
319 }
320 
321 
322 // injects high noise fluctuations cells. It is assumed that these cells cannot
323 // make of the tower a high interest one
325 {
326  // first number of cells where some noise will be injected
328  unsigned ncells= random_->poissonShoot(mean);
329 
330  // if hot fraction is high (for example, no ZS, inject everywhere)
331  bool fullInjection=(noise_==-1. && !doCustomHighNoise_);
332 
333  if(fullInjection)
335  // for debugging
336  // std::vector<int> listofNewTowers;
337 
338  unsigned icell=0;
339  while(icell < ncells)
340  {
341  unsigned cellindex= (!fullInjection) ?
342  (unsigned)(floor(random_->flatShoot()*EBDetId::kSizeForDenseIndexing)): icell ;
343 
344  if(theCalorimeterHits_[cellindex]==0.)
345  {
346  float energy=0.;
347  if(noise_>0.)
349  if(noise_==-1.)
350  {
351  // in this case the generated noise might be below the threshold but it
352  // does not matter, the threshold will be applied anyway
353  // energy/=sinTheta_[(cellindex<EEDetId::kEEhalf)?cellindex : cellindex-EEDetId::kEEhalf];
354  float noisemean = (doCustomHighNoise_)? highNoiseParameters_[0]*(*ICMC_)[cellindex]*adcToGeV_: 0.;
355  float noisesigma = (doCustomHighNoise_)? highNoiseParameters_[1]*(*ICMC_)[cellindex]*adcToGeV_ : noisesigma_[cellindex];
356  energy=random_->gaussShoot(noisemean,noisesigma);
357 
358  // in the case of high noise fluctuation, the ZS should not be applied later
359  if(doCustomHighNoise_) applyZSCells_[cellindex]=false;
360  }
362  energy *= calib;
363  theCalorimeterHits_[cellindex]=energy;
364  theFiredCells_.push_back(cellindex);
365  EBDetId myDetId(EBDetId::unhashIndex(cellindex));
366  // now get the TT
367  int TThashedindex=(eTTmap_->towerOf(myDetId)).hashedIndex();
368  // std::cout << " myDetIds " << myDetId << " "TTHI " << TThashedindex<< std::endl;
369  if(TTTEnergy_[TThashedindex]==0.)
370  {
371  theFiredTTs_.push_back(TThashedindex);
372  TTTEnergy_[TThashedindex]+=energy*sinTheta_[myDetId.ietaAbs()];
373  // listofNewTowers.push_back(TThashedindex);
374  }
375 // else
376 // {
377 // std::vector<int>::const_iterator itcheck=std::find(listofNewTowers.begin(),listofNewTowers.end(),
378 // TThashedindex);
379 // if(itcheck==listofNewTowers.end())
380 // {
381 // std::cout << " EcalBarrelRecHitsMaker : this tower has already been treated " << TTTEnergy_[TThashedindex] << std::endl;
382 // const std::vector<int> & xtals=crystalsinTT_[TThashedindex];
383 // for(unsigned ic=0;ic<xtals.size();++ic)
384 // std::cout << EBDetId::unhashIndex(xtals[ic]) << " " << theCalorimeterHits_[xtals[ic]] << std::endl;
385 // }
386 // }
387  if(noise_>0.)
388  ++icell;
389  }
390  if(noise_==-1.)
391  ++icell;
392  }
393  // std::cout << " Injected random noise in " << ncells << " cells " << std::endl;
394 }
395 
396 void EcalBarrelRecHitsMaker::init(const edm::EventSetup &es,bool doDigis,bool doMiscalib)
397 {
398  // std::cout << " Initializing EcalBarrelRecHitsMaker " << std::endl;
399  doDigis_=doDigis;
400  doMisCalib_=doMiscalib;
401 
403  es.get<EcalADCToGeVConstantRcd>().get(agc);
404 
405  adcToGeV_= agc->getEBValue();// 0.035 ;
406  minAdc_ = 200;
407  maxAdc_ = 4085;
408 
409  geVToAdc1_ = 1./adcToGeV_;
410  geVToAdc2_ = geVToAdc1_/2.;
411  geVToAdc3_ = geVToAdc1_/12.;
412 
413  t1_ = ((int)maxAdc_-(int)minAdc_)*adcToGeV_;
414  t2_ = 2.* t1_ ;
415 
416  // Saturation value. Not needed in the digitization
417  sat_ = 12.*t1_*calibfactor_;
418 
422  es.get<CaloGeometryRecord>().get(pG);
423 
424 // edm::ESHandle<CaloTopology> theCaloTopology;
425 // es.get<CaloTopologyRecord>().get(theCaloTopology);
426 
428  es.get<IdealGeometryRecord>().get(hetm);
429  eTTmap_ = &(*hetm);
430 
431  const EcalBarrelGeometry * myEcalBarrelGeometry = dynamic_cast<const EcalBarrelGeometry*>(pG->getSubdetectorGeometry(DetId::Ecal,EcalBarrel));
432  // std::cout << " Got the geometry " << myEcalBarrelGeometry << std::endl;
433  const std::vector<DetId>& vec(myEcalBarrelGeometry->getValidDetIds(DetId::Ecal,EcalBarrel));
434  unsigned size=vec.size();
435  for(unsigned ic=0; ic<size; ++ic)
436  {
437  EBDetId myDetId(vec[ic]);
438  int crystalHashedIndex=myDetId.hashedIndex();
439  barrelRawId_[crystalHashedIndex]=vec[ic].rawId();
440  // save the Trigger tower DetIds
441  EcalTrigTowerDetId towid= eTTmap_->towerOf(EBDetId(vec[ic]));
442  int TThashedindex=towid.hashedIndex();
443  theTTDetIds_[TThashedindex]=towid;
444  crystalsinTT_[TThashedindex].push_back(crystalHashedIndex);
445  int ietaAbs=myDetId.ietaAbs();
446  if(sinTheta_[ietaAbs]==0.)
447  {
448  sinTheta_[ietaAbs]=std::sin(myEcalBarrelGeometry->getGeometry(myDetId)->getPosition().theta());
449  // std::cout << " Ieta abs " << ietaAbs << " " << sinTheta_[ietaAbs] << std::endl;
450  }
451  }
452 
453 
454  unsigned nTTs=theTTDetIds_.size();
455 
456 // EBDetId myDetId(-58,203);
458 // EcalTrigTowerDetId towid= eTTmap_->towerOf(myDetId);
461 // const std::vector<int> & xtals(crystalsinTT_[towid.hashedIndex()]);
462 // unsigned Size=xtals.size();
463 // for(unsigned i=0;i<Size;++i)
464 // {
465 // std::cout << EBDetId(barrelRawId_[xtals[i]]) << std::endl;
466 // }
467 
468  // now loop on each TT and save its neighbors.
469  for(unsigned iTT=0;iTT<nTTs;++iTT)
470  {
471  int ietaPivot=theTTDetIds_[iTT].ieta();
472  int iphiPivot=theTTDetIds_[iTT].iphi();
473  int TThashedIndex=theTTDetIds_[iTT].hashedIndex();
474  // std::cout << " TT Pivot " << TThashedIndex << " " << ietaPivot << " " << iphiPivot << " iz " << theTTDetIds_[iTT].zside() << std::endl;
475  int ietamin=std::max(ietaPivot-SREtaSize_,-17);
476  if(ietamin==0) ietamin=-1;
477  int ietamax=std::min(ietaPivot+SREtaSize_,17);
478  if(ietamax==0) ietamax=1;
479  int iphimin=iphiPivot-SRPhiSize_;
480  int iphimax=iphiPivot+SRPhiSize_;
481  for(int ieta=ietamin;ieta<=ietamax;)
482  {
483  int iz=(ieta>0)? 1 : -1;
484  for(int iphi=iphimin;iphi<=iphimax;)
485  {
486  int riphi=iphi;
487  if(riphi<1) riphi+=72;
488  else if(riphi>72) riphi-=72;
489  EcalTrigTowerDetId neighborTTDetId(iz,EcalBarrel,abs(ieta),riphi);
490  // std::cout << " Voisin " << ieta << " " << riphi << " " <<neighborTTDetId.hashedIndex()<< " " << neighborTTDetId.ieta() << " " << neighborTTDetId.iphi() << std::endl;
491  if(ieta!=ietaPivot||riphi!=iphiPivot)
492  {
493  neighboringTTs_[TThashedIndex].push_back(neighborTTDetId.hashedIndex());
494  }
495  ++iphi;
496 
497  }
498  ++ieta;
499  if(ieta==0) ieta=1;
500  }
501  }
502 
503  // std::cout << " Made the array " << std::endl;
504 
505  // Stores the miscalibration constants
506  if(doMisCalib_ || noise_==-1.)
507  {
508  double rms=0.;
509  double mean=0.;
510  unsigned ncells=0;
511 
512  if(noise_==-1.)
514 
515  // Intercalib MC constants IC_MC_i
517  es.get<EcalIntercalibConstantsMCRcd>().get(pJcal);
518  const EcalIntercalibConstantsMC* jcal = pJcal.product();
519  const std::vector<float>& ICMC = jcal->barrelItems();
520 
521  // should be saved, used by the zero suppression
522  ICMC_ = &ICMC;
523 
524  // Intercalib constants IC_i
525  // IC = IC_MC * (1+delta)
526  // where delta is the miscalib
528  es.get<EcalIntercalibConstantsRcd>().get(pIcal);
529  const EcalIntercalibConstants* ical = pIcal.product();
530  const std::vector<float> & IC = ical->barrelItems();
531 
532  float meanIC=0.;
533  unsigned nic = IC.size();
534  for ( unsigned ic=0; ic <nic ; ++ic ) {
535  // the miscalibration factor is
536  float factor = IC[ic]/ICMC[ic];
537  meanIC+=(IC[ic]-1.);
538  // Apply Refactor & refactor_mean
539  theCalibConstants_[ic] = refactor_mean_+(factor-1.)*refactor_;
540 
541  rms+=(factor-1.)*(factor-1.);
542  mean+=(factor-1.);
543  ++ncells;
544  if(noise_==-1.)
545  {
546  // the calibfactor will be applied later on
548  }
549 
550  }
551 
552  mean/=(float)ncells;
553  rms/=(float)ncells;
554 
555  rms=sqrt(rms-mean*mean);
556  meanIC = 1.+ meanIC/ncells;
557  // The following should be on LogInfo
558  // float NoiseSigma = 1.26 * meanIC * adcToGeV_ ;
559  // std::cout << " Found " << ncells <<
560  edm::LogInfo("CaloRecHitsProducer") << "Found " << ncells << " cells in the barrel calibration map. RMS is " << rms << std::endl;
561  // std::cout << "Found " << ncells << " cells in the barrel calibration map. RMS is " << rms << std::endl;
562  }
563 }
564 
565 void EcalBarrelRecHitsMaker::geVtoGainAdc(float e,unsigned & gain, unsigned &adc) const
566 {
567  if(e<t1_)
568  {
569  gain = 1; // x1
570  // std::cout << " E " << e << std::endl;
571  adc = minAdc_ + (unsigned)(e*geVToAdc1_);
572  // std::cout << " e*geVtoAdc1_ " << e*geVToAdc1_ << " " <<(unsigned)(e*geVToAdc1_) << std::endl;
573  }
574  else if (e<t2_)
575  {
576  gain = 2;
577  adc = minAdc_ + (unsigned)(e*geVToAdc2_);
578  }
579  else
580  {
581  gain = 3;
582  adc = std::min(minAdc_+(unsigned)(e*geVToAdc3_),maxAdc_);
583  }
584 }
585 
587 {
588 
589  if(TTHighInterest_[tthi]!=0) return (TTHighInterest_[tthi]>0);
590 
591  TTHighInterest_[tthi]=(TTTEnergy_[tthi] > SRThreshold_) ? 1:-1;
592  // if high interest, can leave ; otherwise look at the neighbours)
593  if( TTHighInterest_[tthi]==1)
594  {
595  theTTofHighInterest_.push_back(tthi);
596  return true;
597  }
598 
599  // now look if a neighboring TT is of high interest
600  const std::vector<int> & tts(neighboringTTs_[tthi]);
601  // a tower is of high interest if it or one of its neighbour is above the SR threshold
602  unsigned size=tts.size();
603  bool result=false;
604  for(unsigned itt=0;itt<size&&!result;++itt)
605  {
606  if(TTTEnergy_[tts[itt]] > SRThreshold_) result=true;
607  }
608  TTHighInterest_[tthi]=(result)? 1:-1;
609  theTTofHighInterest_.push_back(tthi);
610  return result;
611 }
int adc(sample_type sample)
get the ADC sample (12 bits)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:87
const GaussianTail * myGaussianTailGenerator_
const RandomEngine * random_
const std::vector< float > * ICMC_
std::vector< int > theFiredCells_
const Items & barrelItems() const
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
void push_back(T const &t)
#define abs(x)
Definition: mlp_lapack.h:159
void loadEcalBarrelRecHits(edm::Event &iEvent, EBRecHitCollection &ecalHits, EBDigiCollection &ecaldigis)
#define min(a, b)
Definition: mlp_lapack.h:161
bool noisifyTriggerTower(unsigned tthi)
std::vector< float > sinTheta_
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngine.h:37
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
std::vector< float > theCalorimeterHits_
std::vector< float > noisesigma_
#define nTT
Definition: TMEGeom.h:6
void loadPCaloHits(const edm::Event &iEvent)
void geVtoGainAdc(float e, unsigned &gain, unsigned &adc) const
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
int iEvent
Definition: GenABIO.cc:243
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:48
unsigned int poissonShoot(double mean) const
Definition: RandomEngine.h:44
tuple result
Definition: query.py:137
std::vector< uint32_t > barrelRawId_
std::vector< double > highNoiseParameters_
std::vector< unsigned > theFiredTTs_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void reserve(size_t isize)
const EcalTrigTowerConstituentsMap * eTTmap_
std::vector< float > TTTEnergy_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
EcalBarrelRecHitsMaker(edm::ParameterSet const &p, const RandomEngine *)
T const * product() const
Definition: Handle.h:74
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
void push_back(id_type iid, data_type const *idata)
std::vector< std::vector< int > > crystalsinTT_
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:115
double shoot() const
Definition: GaussianTail.cc:20
std::vector< std::vector< int > > neighboringTTs_
std::vector< float > theCalibConstants_
std::vector< int > theTTofHighInterest_
void reserve(size_type n)
std::vector< int > applyZSCells_
int ietaAbs() const
get the absolute value of the crystal ieta
Definition: EBDetId.h:50
tuple size
Write out results.
void init(const edm::EventSetup &es, bool dodigis, bool doMiscalib)
std::vector< EcalTrigTowerDetId > theTTDetIds_
std::vector< bool > treatedTTs_
std::vector< int > TTHighInterest_