CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalEndcapRecHitsMaker Class Reference

#include <EcalEndcapRecHitsMaker.h>

Public Member Functions

 EcalEndcapRecHitsMaker (edm::ParameterSet const &p, const RandomEngine *random)
 
void init (const edm::EventSetup &es, bool dodigis, bool domiscalib)
 
void loadEcalEndcapRecHits (edm::Event &iEvent, EERecHitCollection &ecalHits, EEDigiCollection &ecalDigis)
 
 ~EcalEndcapRecHitsMaker ()
 

Private Member Functions

void clean ()
 
void geVtoGainAdc (float e, unsigned &gain, unsigned &adc) const
 
bool isHighInterest (const EEDetId &icell)
 
void loadPCaloHits (const edm::Event &iEvent)
 
void noisifySuperCrystals (int tthi)
 
void noisifyTriggerTowers ()
 
void randomNoisifier ()
 
int SChashedIndex (int SC, int z) const
 
int SChashedIndex (const EEDetId &detid) const
 
int towerOf (const EEDetId &detid) const
 
int towerOf (int hid) const
 
int TThashedIndexforEE (int originalhi) const
 
int TThashedIndexforEE (const EcalTrigTowerDetId &detid) const
 

Private Attributes

float adcToGeV_
 
std::vector< int > applyZSCells_
 
double calibfactor_
 
std::vector< std::vector< int > > CrystalsinSC_
 
bool doCustomHighNoise_
 
bool doDigis_
 
bool doMisCalib_
 
double EEHotFraction_
 
std::vector< uint32_t > endcapRawId_
 
const
EcalTrigTowerConstituentsMap
eTTmap_
 
float geVToAdc1_
 
float geVToAdc2_
 
float geVToAdc3_
 
std::vector< double > highNoiseParameters_
 
const std::vector< float > * ICMC_
 
edm::InputTag inputCol_
 
unsigned maxAdc_
 
double meanNoiseSigmaEt_
 
unsigned minAdc_
 
const GaussianTailmyGaussianTailGenerator_
 
double noise_
 
double noiseADC_
 
std::vector< float > noisesigma_
 
bool noisified_
 
const RandomEnginerandom_
 
double refactor_
 
double refactor_mean_
 
float sat_
 
std::vector< int > SCHighInterest_
 
std::vector< std::vector< int > > SCofTT_
 
std::vector< float > sinTheta_
 
float SRThreshold_
 
float t1_
 
float t2_
 
std::vector< float > theCalibConstants_
 
std::vector< float > theCalorimeterHits_
 
std::vector< int > theFiredCells_
 
std::vector< int > theFiredSC_
 
std::vector< int > theFiredTTs_
 
std::vector< EcalTrigTowerDetIdtheTTDetIds_
 
double threshold_
 
std::vector< int > towerOf_
 
std::vector< bool > treatedSC_
 
std::vector< std::vector< int > > TTofSC_
 
std::vector< float > TTTEnergy_
 

Detailed Description

Definition at line 20 of file EcalEndcapRecHitsMaker.h.

Constructor & Destructor Documentation

EcalEndcapRecHitsMaker::EcalEndcapRecHitsMaker ( edm::ParameterSet const &  p,
const RandomEngine random 
)

Definition at line 30 of file EcalEndcapRecHitsMaker.cc.

References applyZSCells_, alignmentValidation::c1, calibfactor_, CrystalsinSC_, doCustomHighNoise_, edm::ParameterSet::getParameter(), highNoiseParameters_, inputCol_, EEDetId::kEEhalf, EEDetId::kSizeForDenseIndexing, noise_, noiseADC_, noisified_, refactor_, refactor_mean_, SCHighInterest_, SCofTT_, sinTheta_, SRThreshold_, theCalorimeterHits_, theTTDetIds_, threshold_, towerOf_, treatedSC_, TTofSC_, and TTTEnergy_.

33  : random_(myrandom)
34 {
35  edm::ParameterSet RecHitsParameters=p.getParameter<edm::ParameterSet>("ECALEndcap");
36  inputCol_=RecHitsParameters.getParameter<edm::InputTag>("MixedSimHits");
37  noise_ = RecHitsParameters.getParameter<double>("Noise");
38  threshold_ = RecHitsParameters.getParameter<double>("Threshold");
39  SRThreshold_ = RecHitsParameters.getParameter<double> ("SRThreshold");
40  refactor_ = RecHitsParameters.getParameter<double> ("Refactor");
41  refactor_mean_ = RecHitsParameters.getParameter<double> ("Refactor_mean");
42  noiseADC_ = RecHitsParameters.getParameter<double>("NoiseADC");
43  highNoiseParameters_ = RecHitsParameters.getParameter<std::vector<double> > ("HighNoiseParameters");
44 
48  theTTDetIds_.resize(1440);
49  SCofTT_.resize(1440);
50  SCHighInterest_.resize(633,0);
51  treatedSC_.resize(633,false);
52  TTofSC_.resize(633);
53  TTTEnergy_.resize(1440,0.);
54  CrystalsinSC_.resize(633);
55  sinTheta_.resize(EEDetId::kEEhalf,0.);
56  doCustomHighNoise_=false;
57 
58  noisified_ = (noise_==0.);
59  edm::ParameterSet CalibParameters=RecHitsParameters.getParameter<edm::ParameterSet>("ContFact");
60  double c1 = CalibParameters.getParameter<double>("EEs25notContainment");
61  calibfactor_= 1./c1;
62 }
std::vector< bool > treatedSC_
T getParameter(std::string const &) const
std::vector< std::vector< int > > TTofSC_
std::vector< int > SCHighInterest_
std::vector< std::vector< int > > SCofTT_
const RandomEngine * random_
std::vector< float > TTTEnergy_
std::vector< float > theCalorimeterHits_
std::vector< float > sinTheta_
std::vector< int > applyZSCells_
std::vector< std::vector< int > > CrystalsinSC_
std::vector< EcalTrigTowerDetId > theTTDetIds_
std::vector< double > highNoiseParameters_
EcalEndcapRecHitsMaker::~EcalEndcapRecHitsMaker ( )

Definition at line 65 of file EcalEndcapRecHitsMaker.cc.

66 {;
67 }

Member Function Documentation

void EcalEndcapRecHitsMaker::clean ( )
private

Definition at line 69 of file EcalEndcapRecHitsMaker.cc.

References applyZSCells_, noise_, noisified_, SCHighInterest_, findQualityFiles::size, theCalorimeterHits_, theFiredCells_, theFiredSC_, theFiredTTs_, treatedSC_, and TTTEnergy_.

Referenced by loadEcalEndcapRecHits().

70 {
71 
72  unsigned size=theFiredCells_.size();
73  for(unsigned ic=0;ic<size;++ic)
74  {
76  applyZSCells_[theFiredCells_[ic]] = false;
77  }
78  theFiredCells_.clear();
79  // If the noise is set to 0. No need to simulate it.
80  noisified_ = (noise_==0.);
81 
82  size=theFiredTTs_.size();
83 
84  for(unsigned itt=0;itt<size;++itt)
85  {
86  // std::cout << " TT " << theFiredTTs_[itt] << " " << TTTEnergy_[theFiredTTs_[itt]] << std::endl;
87  TTTEnergy_[theFiredTTs_[itt]]=0.;
88  }
89  theFiredTTs_.clear();
90 
91  size=theFiredSC_.size();
92  for(unsigned isc=0;isc<size;++isc)
93  {
95  treatedSC_[theFiredSC_[isc]]=false;
96  }
97  theFiredSC_.clear();
98 
99 
100 
101 // for(unsigned ic=0;ic<TTTEnergy_.size();++ic)
102 // if(TTTEnergy_[ic]!=0.) std::cout << " TT " << ic << " not cleaned " << std::endl;
103 // for(unsigned ic=0;ic<SCHighInterest_.size();++ic)
104 // if(SCHighInterest_[ic]!=0) std::cout << " SCHighInterest " << ic << SCHighInterest_[ic] << " not cleaned " << std::endl;
105 // for(unsigned ic=0;ic<treatedSC_.size();++ic)
106 // if(treatedSC_[ic]) std::cout << " treatedSC " << ic << treatedSC_[ic] << " not cleaned " << std::endl;
107 }
std::vector< bool > treatedSC_
std::vector< int > SCHighInterest_
std::vector< int > theFiredSC_
std::vector< float > TTTEnergy_
std::vector< float > theCalorimeterHits_
std::vector< int > applyZSCells_
std::vector< int > theFiredTTs_
std::vector< int > theFiredCells_
tuple size
Write out results.
void EcalEndcapRecHitsMaker::geVtoGainAdc ( float  e,
unsigned &  gain,
unsigned &  adc 
) const
private

Definition at line 519 of file EcalEndcapRecHitsMaker.cc.

References geVToAdc1_, geVToAdc2_, geVToAdc3_, maxAdc_, min, minAdc_, t1_, and t2_.

Referenced by loadEcalEndcapRecHits().

520 {
521  if(e<t1_)
522  {
523  gain = 1; // x1
524  // std::cout << " E " << e << std::endl;
525  adc = minAdc_ + (unsigned)(e*geVToAdc1_);
526  // std::cout << " e*geVtoAdc1_ " << e*geVToAdc1_ << " " <<(unsigned)(e*geVToAdc1_) << std::endl;
527  }
528  else if (e<t2_)
529  {
530  gain = 2; // x6
531  adc = minAdc_ + (unsigned)(e*geVToAdc2_);
532  }
533  else
534  {
535  gain = 3; // x12
536  adc = std::min(minAdc_+(unsigned)(e*geVToAdc3_),maxAdc_);
537  }
538 }
int adc(sample_type sample)
get the ADC sample (12 bits)
#define min(a, b)
Definition: mlp_lapack.h:161
void EcalEndcapRecHitsMaker::init ( const edm::EventSetup es,
bool  dodigis,
bool  domiscalib 
)

Definition at line 351 of file EcalEndcapRecHitsMaker.cc.

References adcToGeV_, begin, calibfactor_, CrystalsinSC_, doCustomHighNoise_, doDigis_, doMisCalib_, DetId::Ecal, EcalEndcap, EEHotFraction_, end, EcalCondObjectContainer< T >::endcapItems(), endcapRawId_, eTTmap_, spr::find(), edm::EventSetup::get(), CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), CaloSubdetectorGeometry::getValidDetIds(), geVToAdc1_, geVToAdc2_, geVToAdc3_, EEDetId::hashedIndex(), highNoiseParameters_, ICMC_, EEDetId::kEEhalf, EEDetId::kSizeForDenseIndexing, maxAdc_, timingPdfMaker::mean, meanNoiseSigmaEt_, minAdc_, myGaussianTailGenerator_, noise_, noiseADC_, noisesigma_, edm::ESHandle< class >::product(), random_, refactor_, refactor_mean_, plotscripts::rms(), sat_, SChashedIndex(), SCofTT_, funct::sin(), sinTheta_, findQualityFiles::size, mathSSE::sqrt(), t1_, t2_, theCalibConstants_, PV3DBase< T, PVType, FrameType >::theta(), theTTDetIds_, threshold_, EcalTrigTowerConstituentsMap::towerOf(), towerOf_, TThashedIndexforEE(), and TTofSC_.

Referenced by CaloRecHitsProducer::beginRun().

352 {
353  doDigis_=doDigis;
354  doMisCalib_=domiscalib;
355 
356 
358  es.get<EcalADCToGeVConstantRcd>().get(agc);
359 
360  adcToGeV_= agc->getEEValue() ; // ~0.06
361  minAdc_ = 200;
362  maxAdc_ = 4085;
363 
364  geVToAdc1_ = 1./adcToGeV_;
365  geVToAdc2_ = geVToAdc1_/2.;
366  geVToAdc3_ = geVToAdc1_/12.;
367 
368  t1_ = ((int)maxAdc_-(int)minAdc_)*adcToGeV_;
369  t2_ = 2.* t1_ ;
370 
371  sat_ = 12.*t1_*calibfactor_;
372 
374 
376 
378  es.get<CaloGeometryRecord>().get(pG);
379 
381  es.get<IdealGeometryRecord>().get(hetm);
382  eTTmap_ = &(*hetm);
383 
384  const EcalEndcapGeometry * myEcalEndcapGeometry = dynamic_cast<const EcalEndcapGeometry*>(pG->getSubdetectorGeometry(DetId::Ecal,EcalEndcap));
385  const std::vector<DetId>& vec(myEcalEndcapGeometry->getValidDetIds(DetId::Ecal,EcalEndcap));
386  unsigned size=vec.size();
387  for(unsigned ic=0; ic<size; ++ic)
388  {
389  EEDetId myDetId(vec[ic]);
390  int cellhashedindex=myDetId.hashedIndex();
391  endcapRawId_[cellhashedindex]=vec[ic].rawId();
392  // trick to save a bit of memory. sin Theta is identical in EE+/-
393  if (cellhashedindex< EEDetId::kEEhalf)
394  {
395  float sintheta=std::sin(myEcalEndcapGeometry->getGeometry(myDetId)->getPosition().theta());
396  sinTheta_[cellhashedindex]=sintheta;
397  }
398  // a bit of trigger tower and SuperCrystals algebra
399  // first get the trigger tower
400  EcalTrigTowerDetId towid1= eTTmap_->towerOf(vec[ic]);
401  int tthashedindex=TThashedIndexforEE(towid1);
402  towerOf_[cellhashedindex]=tthashedindex;
403 
404  // get the SC of the cell
405  int schi=SChashedIndex(EEDetId(vec[ic]));
406  if(schi<0)
407  {
408  // std::cout << " OOps " << schi << std::endl;
409  EEDetId myID(vec[ic]);
410  // std::cout << " DetId " << myID << " " << myID.isc() << " " << myID.zside() << " " << myID.isc()+(myID.zside()+1)*158 << std::endl;
411  }
412 
413  theTTDetIds_[tthashedindex]=towid1;
414 
415  // check if this SC is already in the list of the corresponding TT
416  std::vector<int>::const_iterator itcheck=find(SCofTT_[tthashedindex].begin(),
417  SCofTT_[tthashedindex].end(),
418  schi);
419  if(itcheck==SCofTT_[tthashedindex].end())
420  SCofTT_[tthashedindex].push_back(schi);
421 
422  // check if this crystal is already in the list of crystals per sc
423  itcheck=find(CrystalsinSC_[schi].begin(),CrystalsinSC_[schi].end(),cellhashedindex);
424  if(itcheck==CrystalsinSC_[schi].end())
425  CrystalsinSC_[schi].push_back(cellhashedindex);
426 
427  // check if the TT is already in the list of sc
428  // std::cout << " SCHI " << schi << " " << TTofSC_.size() << std::endl;
429  // std::cout << TTofSC_[schi].size() << std::endl;
430  itcheck=find(TTofSC_[schi].begin(),TTofSC_[schi].end(),tthashedindex);
431  if(itcheck==TTofSC_[schi].end())
432  TTofSC_[schi].push_back(tthashedindex);
433  }
434  // std::cout << " Made the array " << std::endl;
435  // Stores the miscalibration constants
436  if(doMisCalib_||noise_==-1.)
437  {
438  double rms=0.;
439  double mean=0.;
440  unsigned ncells=0;
441 
442  if(noise_==-1.)
444 
445  // Intercalib constants IC_MC_i
447  es.get<EcalIntercalibConstantsMCRcd>().get(pJcal);
448  const EcalIntercalibConstantsMC* jcal = pJcal.product();
449  const std::vector<float>& ICMC = jcal->endcapItems();
450 
451  // should be saved, used by the zero suppression
452  ICMC_ = &ICMC;
453 
454  // Intercalib constants IC_i
455  // IC = IC_MC * (1+delta)
456  // where delta is the miscalib
458  es.get<EcalIntercalibConstantsRcd>().get(pIcal);
459  const EcalIntercalibConstants* ical = pIcal.product();
460  const std::vector<float>& IC = ical->endcapItems();
461 
462 
463  unsigned nic = IC.size();
464  meanNoiseSigmaEt_ = 0.;
465  for(unsigned ic=0;ic<nic;++ic)
466  {
467  // the miscalibration factor is
468  float factor = IC[ic]/ICMC[ic];
469  // Apply Refactor & refactor_mean
471  rms+=(factor-1.)*(factor-1.);
472  mean+=(factor-1.);
473 
474  // the miscalibration on the noise will be applied later one; so it is really ICMC here
475  if(noise_==-1.)
476  {
477  // the calibfactor will be applied later on
480  // EEDetId myDetId(EEDetId::unhashIndex(ic));
481  // std::cout << " DDD " << myDetId << " " << myDetId.ix() << " " << myDetId.iy() << " " << ic << " " << noiseADC_ << " " << agc->getEEValue() << " " << ICMC[ic] << " " << noisesigma_[ic] << std::endl;
482  }
483  ++ncells;
484  }
485 
486  mean/=(float)ncells;
487  rms/=(float)ncells;
488 
489  rms=sqrt(rms-mean*mean);
490 
491  meanNoiseSigmaEt_ /=(float)ncells;
492 
493  edm::LogInfo("CaloRecHitsProducer") << "Found " << ncells << " cells in the endcap calibration map. RMS is " << rms << std::endl;
494  // std::cout << "Found " << ncells << " cells in the endcap calibration map. RMS is " << rms << std::endl;
495  }
496 
497  // Initialize the Gaussian tail generator
498  // Two options : noise is set by the user (to a positive value). In this case, this value is taken
499  // or the user chose to use the noise from DB. In this case, the noise is flat in pT and not in energy
500  // but the threshold is in energy and not in pT.
501 
503  Genfun::Erf myErf;
504  if( noise_>0. ) {
505  EEHotFraction_ = 0.5-0.5*myErf(threshold_/noise_/sqrt(2.));
507  edm::LogInfo("CaloRecHitsProducer") <<"Uniform noise simulation selected";
508  }
509  else if( noise_==-1 && doCustomHighNoise_)
510  {
511  // computes the hot fraction from the threshold applied on the online amplitude reconstruction
512  //
514  edm::LogInfo("CaloRecHitsProducer")<< " The gaussian model for high noise fluctuation cells after ZS is selected (best model), hot fraction " << EEHotFraction_ << std::endl;
515  }
516 }
int TThashedIndexforEE(int originalhi) const
std::vector< std::vector< int > > TTofSC_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< std::vector< int > > SCofTT_
const GaussianTail * myGaussianTailGenerator_
const RandomEngine * random_
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
EcalTrigTowerDetId towerOf(const DetId &id) const
Get the tower id for this det id (or null if not known)
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
const EcalTrigTowerConstituentsMap * eTTmap_
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
Geom::Theta< T > theta() const
Definition: PV3DBase.h:74
int SChashedIndex(int SC, int z) const
std::vector< float > theCalibConstants_
T sqrt(T t)
Definition: SSEVec.h:46
const std::vector< float > * ICMC_
std::vector< float > sinTheta_
#define end
Definition: vmac.h:38
std::vector< float > noisesigma_
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
std::vector< std::vector< int > > CrystalsinSC_
#define begin
Definition: vmac.h:31
std::vector< uint32_t > endcapRawId_
std::vector< EcalTrigTowerDetId > theTTDetIds_
std::vector< double > highNoiseParameters_
const Items & endcapItems() const
tuple size
Write out results.
bool EcalEndcapRecHitsMaker::isHighInterest ( const EEDetId icell)
private

Definition at line 540 of file EcalEndcapRecHitsMaker.cc.

References query::result, SChashedIndex(), SCHighInterest_, findQualityFiles::size, SRThreshold_, theFiredSC_, TTofSC_, and TTTEnergy_.

Referenced by loadEcalEndcapRecHits().

541 {
542  // std::cout << " is HI " ;
543  int schi=SChashedIndex(detid);
544  // std::cout << detid << " " << schi << " ";
545  // check if it has already been treated or not
546  // 0 <=> not treated
547  // 1 <=> high interest
548  // -1 <=> low interest
549  // std::cout << SCHighInterest_[schi] << std::endl;
550  if(SCHighInterest_[schi]!=0) return (SCHighInterest_[schi]>0);
551 
552  // now look if a TT contributing is of high interest
553  const std::vector<int> & tts(TTofSC_[schi]);
554  unsigned size=tts.size();
555  bool result=false;
556  for(unsigned itt=0;itt<size&&!result;++itt)
557  {
558  // std::cout << " Checking TT " << tts[itt] << std::endl;
559  if(TTTEnergy_[tts[itt]]>SRThreshold_) result=true;
560  }
561  SCHighInterest_[schi]=(result)? 1:-1;
562  theFiredSC_.push_back(schi);
563  return result;
564 }
std::vector< std::vector< int > > TTofSC_
std::vector< int > SCHighInterest_
std::vector< int > theFiredSC_
int SChashedIndex(int SC, int z) const
std::vector< float > TTTEnergy_
tuple result
Definition: query.py:137
tuple size
Write out results.
void EcalEndcapRecHitsMaker::loadEcalEndcapRecHits ( edm::Event iEvent,
EERecHitCollection ecalHits,
EEDigiCollection ecalDigis 
)

Definition at line 110 of file EcalEndcapRecHitsMaker.cc.

References ecalMGPA::adc(), applyZSCells_, edm::DataFrameContainer::back(), clean(), doDigis_, endcapRawId_, relval_parameters_module::energy, geVtoGainAdc(), ICMC_, isHighInterest(), loadPCaloHits(), noisified_, edm::DataFrameContainer::push_back(), edm::SortedCollection< T, SORT >::push_back(), edm::DataFrameContainer::reserve(), edm::SortedCollection< T, SORT >::reserve(), sat_, theCalorimeterHits_, theFiredCells_, and threshold_.

Referenced by CaloRecHitsProducer::produce().

111 {
112  clean();
113  loadPCaloHits(iEvent);
114 
115  unsigned nhit=theFiredCells_.size();
116  unsigned gain, adc;
117  ecalDigis.reserve(nhit);
118  ecalHits.reserve(nhit);
119  for(unsigned ihit=0;ihit<nhit;++ihit)
120  {
121  unsigned icell = theFiredCells_[ihit];
122 
123  EEDetId myDetId(endcapRawId_[icell]);
124  if(doDigis_)
125  {
126  ecalDigis.push_back( myDetId );
127  EEDataFrame myDataFrame( ecalDigis.back() );
128  // myDataFrame.setSize(1); // now useless - by construction fixed at 1 frame - FIXME
129  // The real work is in the following line
130  geVtoGainAdc(theCalorimeterHits_[icell],gain,adc);
131  myDataFrame.setSample(0,EcalMGPASample(adc,gain));
132  //ecalDigis.push_back(myDataFrame);
133  }
134 
135  // If the energy+noise is below the threshold, a hit is nevertheless created, otherwise, there is a risk that a "noisy" hit
136  // is afterwards put in this cell which would not be correct.
137  float energy=theCalorimeterHits_[icell];
138 
139  // the threshold is in amplitude, so the intercalibration constant should be injected
140  if ( energy<threshold_*((*ICMC_)[icell]) && !isHighInterest(myDetId) && applyZSCells_[icell])
141  {
142  theCalorimeterHits_[icell]=0.;
143  // int TThashedindex=towerOf_[icell];
144  // std::cout << " SR " << TTTEnergy_[TThashedindex] << " Cell energy " << energy << " 0 "<< std::endl;
145  energy=0.;
146  }
147  else
148  if( energy > sat_)
149  {
150  energy=sat_;
151  theCalorimeterHits_[icell]=sat_;
152  }
153  if(energy!=0.)
154  {
155  ecalHits.push_back(EcalRecHit(myDetId,energy,0.));
156  }
157  }
158  noisified_ = true;
159 
160 }
int adc(sample_type sample)
get the ADC sample (12 bits)
bool isHighInterest(const EEDetId &icell)
void geVtoGainAdc(float e, unsigned &gain, unsigned &adc) const
void push_back(T const &t)
const std::vector< float > * ICMC_
std::vector< float > theCalorimeterHits_
void loadPCaloHits(const edm::Event &iEvent)
void reserve(size_t isize)
void push_back(id_type iid, data_type const *idata)
std::vector< int > applyZSCells_
std::vector< int > theFiredCells_
void reserve(size_type n)
std::vector< uint32_t > endcapRawId_
void EcalEndcapRecHitsMaker::loadPCaloHits ( const edm::Event iEvent)
private

Definition at line 162 of file EcalEndcapRecHitsMaker.cc.

References calib, calibfactor_, doMisCalib_, relval_parameters_module::energy, RandomEngine::gaussShoot(), edm::Event::getByLabel(), ecalpyutils::hashedIndex(), inputCol_, EEDetId::kEEhalf, noise_, noisesigma_, noisified_, noisifyTriggerTowers(), edm::Handle< T >::product(), random_, randomNoisifier(), sinTheta_, theCalibConstants_, theCalorimeterHits_, theFiredCells_, theFiredTTs_, towerOf_, and TTTEnergy_.

Referenced by loadEcalEndcapRecHits().

163 {
164  // std::cout << " loadPCaloHits " << std::endl;
166  iEvent.getByLabel(inputCol_,cf);
167  std::auto_ptr<MixCollection<PCaloHit> > colcalo(new MixCollection<PCaloHit>(cf.product(),std::pair<int,int>(0,0) ));
168 
169  theFiredCells_.reserve(colcalo->size());
171  MixCollection<PCaloHit>::iterator cficaloend=colcalo->end();
172  for (cficalo=colcalo->begin(); cficalo!=cficaloend;cficalo++)
173  {
174 
175  unsigned hashedindex = EEDetId(cficalo->id()).hashedIndex();
176  // Check if the hit already exists
178  if(theCalorimeterHits_[hashedindex]==0.)
179  {
180  theFiredCells_.push_back(hashedindex);
181  float noise=(noise_==-1.) ? noisesigma_[hashedindex] : noise_ ;
182  if (!noisified_ ) {
183  theCalorimeterHits_[hashedindex] += random_->gaussShoot(0.,noise*calib);
184  }
185  }
186  // the famous 1/0.97 calibration factor is applied here !
187  // the miscalibration is applied here:
188 
189  // cficalo->energy can be 0 (a 7x7 grid is always built), in this case, one should not kill the cell (for later noise injection), but it should
190  // be added only once. This is a dirty trick.
191  float energy=(cficalo->energy()==0.) ? 0.000001 : cficalo->energy() ;
192  energy*=calib;
193  theCalorimeterHits_[hashedindex]+=energy;
194 
195  // Now deal with the TTs
196  int TThashedindex=towerOf_[hashedindex];
197 
198  if(TTTEnergy_[TThashedindex]==0.)
199  {
200  theFiredTTs_.push_back(TThashedindex);
201  }
202  // the same dirty trick as before. sinTheta is stored only for one endcap
203  TTTEnergy_[TThashedindex]+=energy*sinTheta_[(hashedindex<EEDetId::kEEhalf)? hashedindex : hashedindex-EEDetId::kEEhalf];
204 
205  }
206  // std::cout << " Noisifying the TT " << std::endl;
208  randomNoisifier();
209 }
const RandomEngine * random_
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngine.h:37
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
std::vector< float > TTTEnergy_
std::vector< float > theCalibConstants_
std::vector< float > theCalorimeterHits_
std::vector< float > sinTheta_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
std::vector< float > noisesigma_
T const * product() const
Definition: Handle.h:74
std::vector< int > theFiredTTs_
std::vector< int > theFiredCells_
void EcalEndcapRecHitsMaker::noisifySuperCrystals ( int  tthi)
private

Definition at line 226 of file EcalEndcapRecHitsMaker.cc.

References calib, calibfactor_, prof2calltree::count, CrystalsinSC_, doMisCalib_, relval_parameters_module::energy, RandomEngine::gaussShoot(), EEDetId::kEEhalf, noise_, noisesigma_, random_, SCofTT_, sinTheta_, findQualityFiles::size, theCalibConstants_, theCalorimeterHits_, theFiredCells_, theFiredTTs_, towerOf_, treatedSC_, and TTTEnergy_.

Referenced by noisifyTriggerTowers().

227 {
228  unsigned size=SCofTT_[tthi].size();
229  // get the list of Supercrytals
230  for(unsigned isc=0;isc<size;++isc)
231  {
232  // std::cout << " Looking at SC " << isc << " " << SCofTT_[tthi][isc] << std::endl;
233  // should not do it twice
234  if(treatedSC_[SCofTT_[tthi][isc]]) continue;
235 
236  const std::vector<int> & xtals(CrystalsinSC_[SCofTT_[tthi][isc]]);
237  unsigned nxtals=xtals.size();
238  unsigned count=0;
239 // if (nxtals!=25)
240 // {
241 // std::cout << " This SC has " << nxtals << " crystals " << std::endl;
242 // }
243  for(unsigned ix=0;ix<nxtals;++ix)
244  {
245  unsigned hashedindex=xtals[ix];
246  // check if the crystal has already something or not
247  // std::cout << " Looking at crystal " << EEDetId(endcapRawId_[hashedindex]) << std::endl;
248  if(theCalorimeterHits_[hashedindex]==0.)
249  {
251  float noise = (noise_==-1.) ? noisesigma_[hashedindex]:noise_;
252  float energy = calib*random_->gaussShoot(0.,noise);
253  theCalorimeterHits_[hashedindex]=energy;
254  theFiredCells_.push_back(hashedindex);
255  // the corresponding trigger tower should be updated
256  int newtthi=towerOf_[hashedindex];
257  // std::cout << " Updatung TT " << newtthi << std::endl;
258  if(TTTEnergy_[newtthi]==0.)
259  {
260  theFiredTTs_.push_back(newtthi);
261  }
262  TTTEnergy_[newtthi]+=energy*sinTheta_[(hashedindex<EEDetId::kEEhalf)? hashedindex : hashedindex-EEDetId::kEEhalf];
263  ++count;
264  }
265  }
266  treatedSC_[SCofTT_[tthi][isc]]=true;
267  // std::cout << "SC " << SCofTT_[tthi][isc] << " done ; injected " << count << std::endl;
268  }
269 }
std::vector< bool > treatedSC_
std::vector< std::vector< int > > SCofTT_
const RandomEngine * random_
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngine.h:37
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
std::vector< float > TTTEnergy_
std::vector< float > theCalibConstants_
std::vector< float > theCalorimeterHits_
std::vector< float > sinTheta_
std::vector< float > noisesigma_
std::vector< std::vector< int > > CrystalsinSC_
std::vector< int > theFiredTTs_
std::vector< int > theFiredCells_
tuple size
Write out results.
void EcalEndcapRecHitsMaker::noisifyTriggerTowers ( )
private

Definition at line 211 of file EcalEndcapRecHitsMaker.cc.

References noise_, noisifySuperCrystals(), nTT, and theFiredTTs_.

Referenced by loadPCaloHits().

212 {
213  if(noise_==0.) return;
214 
215  // noise should be injected in all the Super-crystals contained in each trigger tower
216  unsigned nTT=theFiredTTs_.size();
217  for(unsigned itt=0;itt<nTT;++itt)
218  {
219  // shoot noise in the trigger tower
220  // std::cout << " Treating " << theFiredTTs_[itt] << " " << theTTDetIds_[theFiredTTs_[itt]] << " " << TTTEnergy_[theFiredTTs_[itt]] << std::endl;
222  }
223 }
#define nTT
Definition: TMEGeom.h:6
std::vector< int > theFiredTTs_
void EcalEndcapRecHitsMaker::randomNoisifier ( )
private

Definition at line 276 of file EcalEndcapRecHitsMaker.cc.

References adcToGeV_, applyZSCells_, calib, calibfactor_, doCustomHighNoise_, doMisCalib_, EEHotFraction_, relval_parameters_module::energy, RandomEngine::flatShoot(), RandomEngine::gaussShoot(), highNoiseParameters_, ICMC_, EEDetId::kEEhalf, EEDetId::kSizeForDenseIndexing, timingPdfMaker::mean, myGaussianTailGenerator_, noise_, noisesigma_, RandomEngine::poissonShoot(), random_, GaussianTail::shoot(), sinTheta_, theCalibConstants_, theCalorimeterHits_, theFiredCells_, theFiredTTs_, towerOf_, TTTEnergy_, and EEDetId::unhashIndex().

Referenced by loadPCaloHits().

277 {
278  // first of cells where some noise will be injected
280  unsigned ncells= random_->poissonShoot(mean);
281 
282  // for debugging
283  // std::vector<int> listofNewTowers;
284 
285  if(noise_==-1. && !doCustomHighNoise_)
287 
288  unsigned icell=0;
289  while(icell < ncells)
290  {
291  unsigned cellindex= (noise_!=-1. || doCustomHighNoise_) ?
292  (unsigned)(floor(random_->flatShoot()*EEDetId::kSizeForDenseIndexing)): icell ;
293 
294  if(theCalorimeterHits_[cellindex]==0.)
295  {
296  // if noise_>0 the following is really an energy, if -1. it is a transverse energy
297  double energy=0.;
298  if(noise_>0.)
300  if(noise_==-1.)
301  {
302  // in this case the generated noise might be below the threshold but it
303  // does not matter, the threshold will be applied anyway
304  // energy/=sinTheta_[(cellindex<EEDetId::kEEhalf)?cellindex : cellindex-EEDetId::kEEhalf];
305  float noisemean = (doCustomHighNoise_)? highNoiseParameters_[0]*(*ICMC_)[cellindex]*adcToGeV_: 0.;
306  float noisesigma = (doCustomHighNoise_)? highNoiseParameters_[1]*(*ICMC_)[cellindex]*adcToGeV_ : noisesigma_[cellindex];
307  energy=random_->gaussShoot(noisemean,noisesigma);
308 
309  // in the case of high noise fluctuation, the ZS should not be applied later
310  if(doCustomHighNoise_) applyZSCells_[cellindex]=false;
311  }
313  energy *= calib;
314  theCalorimeterHits_[cellindex]=energy;
315  theFiredCells_.push_back(cellindex);
316  EEDetId myDetId(EEDetId::unhashIndex(cellindex));
317  // now get the TT
318  int TThashedindex=towerOf_[cellindex];
319  // std::cout << " myDetIds " << myDetId << " "TTHI " << TThashedindex<< std::endl;
320  if(TTTEnergy_[TThashedindex]==0.)
321  {
322  theFiredTTs_.push_back(TThashedindex);
323  TTTEnergy_[TThashedindex]+=energy*sinTheta_[(cellindex<EEDetId::kEEhalf)?cellindex : cellindex-EEDetId::kEEhalf];
324  // listofNewTowers.push_back(TThashedindex);
325  }
326 // else
327 // {
328 // std::vector<int>::const_iterator itcheck=std::find(listofNewTowers.begin(),listofNewTowers.end(),
329 // TThashedindex);
330 // if(itcheck==listofNewTowers.end())
331 // {
332 // const std::vector<int> & scxtals=SCofTT_[TThashedindex];
333 // for(unsigned isc=0;isc<scxtals.size();++isc)
334 // {
335 // const std::vector<int> & xtals(CrystalsinSC_[SCofTT_[TThashedindex][isc]]);
336 // for(unsigned ic=0;ic<xtals.size();++ic)
337 // std::cout << isc << " " << EEDetId::unhashIndex(xtals[ic]) << " " << theCalorimeterHits_[xtals[ic]] << std::endl;
338 // }
339 // }
340 // }
341  if(noise_>0.)
342  ++icell;
343  }
344  if(noise_==-1.)
345  ++icell;
346  }
347  // std::cout << " Injected random noise in " << ncells << " cells " << std::endl;
348 }
const GaussianTail * myGaussianTailGenerator_
const RandomEngine * random_
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:115
double gaussShoot(double mean=0.0, double sigma=1.0) const
Definition: RandomEngine.h:37
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
std::vector< float > TTTEnergy_
std::vector< float > theCalibConstants_
const std::vector< float > * ICMC_
unsigned int poissonShoot(double mean) const
Definition: RandomEngine.h:44
std::vector< float > theCalorimeterHits_
std::vector< float > sinTheta_
std::vector< float > noisesigma_
double flatShoot(double xmin=0.0, double xmax=1.0) const
Definition: RandomEngine.h:30
std::vector< int > applyZSCells_
double shoot() const
Definition: GaussianTail.cc:20
std::vector< int > theFiredTTs_
std::vector< int > theFiredCells_
std::vector< double > highNoiseParameters_
int EcalEndcapRecHitsMaker::SChashedIndex ( int  SC,
int  z 
) const
inlineprivate

Definition at line 38 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and isHighInterest().

38 {return SC+(z+1)*158;}
double double double z
int EcalEndcapRecHitsMaker::SChashedIndex ( const EEDetId detid) const
inlineprivate

Definition at line 39 of file EcalEndcapRecHitsMaker.h.

References EEDetId::isc(), and EEDetId::zside().

39  {
40  // std::cout << "In SC hashedIndex " << detid.isc() << " " << detid.zside() << " " << detid.isc()+(detid.zside()+1)*158 << std::endl;
41  return detid.isc()+(detid.zside()+1)*158;}
int isc() const
Definition: EEDetId.cc:301
int zside() const
Definition: EEDetId.h:65
int EcalEndcapRecHitsMaker::towerOf ( const EEDetId detid) const
inlineprivate

Definition at line 42 of file EcalEndcapRecHitsMaker.h.

References EEDetId::hashedIndex(), and towerOf_.

42 {return towerOf_[detid.hashedIndex()];}
int hashedIndex() const
Definition: EEDetId.h:177
int EcalEndcapRecHitsMaker::towerOf ( int  hid) const
inlineprivate

Definition at line 43 of file EcalEndcapRecHitsMaker.h.

References towerOf_.

43 {return towerOf_[hid];}
int EcalEndcapRecHitsMaker::TThashedIndexforEE ( int  originalhi) const
inlineprivate

Definition at line 34 of file EcalEndcapRecHitsMaker.h.

Referenced by init().

34 {return originalhi-2448;}
int EcalEndcapRecHitsMaker::TThashedIndexforEE ( const EcalTrigTowerDetId detid) const
inlineprivate

Definition at line 35 of file EcalEndcapRecHitsMaker.h.

References EcalTrigTowerDetId::hashedIndex().

35 {return detid.hashedIndex()-2448;}
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]

Member Data Documentation

float EcalEndcapRecHitsMaker::adcToGeV_
private

Definition at line 79 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and randomNoisifier().

std::vector<int> EcalEndcapRecHitsMaker::applyZSCells_
private
double EcalEndcapRecHitsMaker::calibfactor_
private
std::vector<std::vector<int> > EcalEndcapRecHitsMaker::CrystalsinSC_
private

Definition at line 106 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), init(), and noisifySuperCrystals().

bool EcalEndcapRecHitsMaker::doCustomHighNoise_
private

Definition at line 123 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), init(), and randomNoisifier().

bool EcalEndcapRecHitsMaker::doDigis_
private

Definition at line 51 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and loadEcalEndcapRecHits().

bool EcalEndcapRecHitsMaker::doMisCalib_
private
double EcalEndcapRecHitsMaker::EEHotFraction_
private

Definition at line 59 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and randomNoisifier().

std::vector<uint32_t> EcalEndcapRecHitsMaker::endcapRawId_
private

Definition at line 75 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and loadEcalEndcapRecHits().

const EcalTrigTowerConstituentsMap* EcalEndcapRecHitsMaker::eTTmap_
private

Definition at line 85 of file EcalEndcapRecHitsMaker.h.

Referenced by init().

float EcalEndcapRecHitsMaker::geVToAdc1_
private

Definition at line 80 of file EcalEndcapRecHitsMaker.h.

Referenced by geVtoGainAdc(), and init().

float EcalEndcapRecHitsMaker::geVToAdc2_
private

Definition at line 80 of file EcalEndcapRecHitsMaker.h.

Referenced by geVtoGainAdc(), and init().

float EcalEndcapRecHitsMaker::geVToAdc3_
private

Definition at line 80 of file EcalEndcapRecHitsMaker.h.

Referenced by geVtoGainAdc(), and init().

std::vector<double> EcalEndcapRecHitsMaker::highNoiseParameters_
private

Definition at line 122 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), init(), and randomNoisifier().

const std::vector<float>* EcalEndcapRecHitsMaker::ICMC_
private

Definition at line 118 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), loadEcalEndcapRecHits(), and randomNoisifier().

edm::InputTag EcalEndcapRecHitsMaker::inputCol_
private

Definition at line 50 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), and loadPCaloHits().

unsigned EcalEndcapRecHitsMaker::maxAdc_
private

Definition at line 82 of file EcalEndcapRecHitsMaker.h.

Referenced by geVtoGainAdc(), and init().

double EcalEndcapRecHitsMaker::meanNoiseSigmaEt_
private

Definition at line 112 of file EcalEndcapRecHitsMaker.h.

Referenced by init().

unsigned EcalEndcapRecHitsMaker::minAdc_
private

Definition at line 81 of file EcalEndcapRecHitsMaker.h.

Referenced by geVtoGainAdc(), and init().

const GaussianTail* EcalEndcapRecHitsMaker::myGaussianTailGenerator_
private

Definition at line 61 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and randomNoisifier().

double EcalEndcapRecHitsMaker::noise_
private
double EcalEndcapRecHitsMaker::noiseADC_
private

Definition at line 114 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), and init().

std::vector<float> EcalEndcapRecHitsMaker::noisesigma_
private
bool EcalEndcapRecHitsMaker::noisified_
private
const RandomEngine* EcalEndcapRecHitsMaker::random_
private
double EcalEndcapRecHitsMaker::refactor_
private

Definition at line 53 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), and init().

double EcalEndcapRecHitsMaker::refactor_mean_
private

Definition at line 54 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), and init().

float EcalEndcapRecHitsMaker::sat_
private

Definition at line 83 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and loadEcalEndcapRecHits().

std::vector<int> EcalEndcapRecHitsMaker::SCHighInterest_
private

Definition at line 98 of file EcalEndcapRecHitsMaker.h.

Referenced by clean(), EcalEndcapRecHitsMaker(), and isHighInterest().

std::vector<std::vector<int> > EcalEndcapRecHitsMaker::SCofTT_
private

Definition at line 93 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), init(), and noisifySuperCrystals().

std::vector<float> EcalEndcapRecHitsMaker::sinTheta_
private
float EcalEndcapRecHitsMaker::SRThreshold_
private

Definition at line 116 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), and isHighInterest().

float EcalEndcapRecHitsMaker::t1_
private

Definition at line 83 of file EcalEndcapRecHitsMaker.h.

Referenced by geVtoGainAdc(), and init().

float EcalEndcapRecHitsMaker::t2_
private

Definition at line 83 of file EcalEndcapRecHitsMaker.h.

Referenced by geVtoGainAdc(), and init().

std::vector<float> EcalEndcapRecHitsMaker::theCalibConstants_
private
std::vector<float> EcalEndcapRecHitsMaker::theCalorimeterHits_
private
std::vector<int> EcalEndcapRecHitsMaker::theFiredCells_
private
std::vector<int> EcalEndcapRecHitsMaker::theFiredSC_
private

Definition at line 100 of file EcalEndcapRecHitsMaker.h.

Referenced by clean(), and isHighInterest().

std::vector<int> EcalEndcapRecHitsMaker::theFiredTTs_
private
std::vector<EcalTrigTowerDetId> EcalEndcapRecHitsMaker::theTTDetIds_
private

Definition at line 91 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), and init().

double EcalEndcapRecHitsMaker::threshold_
private

Definition at line 56 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), init(), and loadEcalEndcapRecHits().

std::vector<int> EcalEndcapRecHitsMaker::towerOf_
private
std::vector<bool> EcalEndcapRecHitsMaker::treatedSC_
private

Definition at line 97 of file EcalEndcapRecHitsMaker.h.

Referenced by clean(), EcalEndcapRecHitsMaker(), and noisifySuperCrystals().

std::vector<std::vector<int> > EcalEndcapRecHitsMaker::TTofSC_
private

Definition at line 95 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), init(), and isHighInterest().

std::vector<float> EcalEndcapRecHitsMaker::TTTEnergy_
private