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)
 
void init (const edm::EventSetup &es, bool dodigis, bool domiscalib)
 
void loadEcalEndcapRecHits (edm::Event &iEvent, EERecHitCollection &ecalHits, EEDigiCollection &ecalDigis, RandomEngineAndDistribution const *)
 
 ~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, RandomEngineAndDistribution const *)
 
void noisifySuperCrystals (int tthi, RandomEngineAndDistribution const *)
 
void noisifyTriggerTowers (RandomEngineAndDistribution const *)
 
void randomNoisifier (RandomEngineAndDistribution const *)
 
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_
 
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)

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_.

31 {
32  edm::ParameterSet RecHitsParameters=p.getParameter<edm::ParameterSet>("ECALEndcap");
33  inputCol_=RecHitsParameters.getParameter<edm::InputTag>("MixedSimHits");
34  noise_ = RecHitsParameters.getParameter<double>("Noise");
35  threshold_ = RecHitsParameters.getParameter<double>("Threshold");
36  SRThreshold_ = RecHitsParameters.getParameter<double> ("SRThreshold");
37  refactor_ = RecHitsParameters.getParameter<double> ("Refactor");
38  refactor_mean_ = RecHitsParameters.getParameter<double> ("Refactor_mean");
39  noiseADC_ = RecHitsParameters.getParameter<double>("NoiseADC");
40  highNoiseParameters_ = RecHitsParameters.getParameter<std::vector<double> > ("HighNoiseParameters");
41 
45  theTTDetIds_.resize(1440);
46  SCofTT_.resize(1440);
47  SCHighInterest_.resize(633,0);
48  treatedSC_.resize(633,false);
49  TTofSC_.resize(633);
50  TTTEnergy_.resize(1440,0.);
51  CrystalsinSC_.resize(633);
52  sinTheta_.resize(EEDetId::kEEhalf,0.);
53  doCustomHighNoise_=false;
54 
55  noisified_ = (noise_==0.);
56  edm::ParameterSet CalibParameters=RecHitsParameters.getParameter<edm::ParameterSet>("ContFact");
57  double c1 = CalibParameters.getParameter<double>("EEs25notContainment");
58  calibfactor_= 1./c1;
59 }
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_
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 62 of file EcalEndcapRecHitsMaker.cc.

63 {;
64 }

Member Function Documentation

void EcalEndcapRecHitsMaker::clean ( )
private

Definition at line 66 of file EcalEndcapRecHitsMaker.cc.

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

Referenced by loadEcalEndcapRecHits().

67 {
68 
69  unsigned size=theFiredCells_.size();
70  for(unsigned ic=0;ic<size;++ic)
71  {
73  applyZSCells_[theFiredCells_[ic]] = false;
74  }
75  theFiredCells_.clear();
76  // If the noise is set to 0. No need to simulate it.
77  noisified_ = (noise_==0.);
78 
79  size=theFiredTTs_.size();
80 
81  for(unsigned itt=0;itt<size;++itt)
82  {
83  // std::cout << " TT " << theFiredTTs_[itt] << " " << TTTEnergy_[theFiredTTs_[itt]] << std::endl;
84  TTTEnergy_[theFiredTTs_[itt]]=0.;
85  }
86  theFiredTTs_.clear();
87 
88  size=theFiredSC_.size();
89  for(unsigned isc=0;isc<size;++isc)
90  {
92  treatedSC_[theFiredSC_[isc]]=false;
93  }
94  theFiredSC_.clear();
95 
96 
97 
98 // for(unsigned ic=0;ic<TTTEnergy_.size();++ic)
99 // if(TTTEnergy_[ic]!=0.) std::cout << " TT " << ic << " not cleaned " << std::endl;
100 // for(unsigned ic=0;ic<SCHighInterest_.size();++ic)
101 // if(SCHighInterest_[ic]!=0) std::cout << " SCHighInterest " << ic << SCHighInterest_[ic] << " not cleaned " << std::endl;
102 // for(unsigned ic=0;ic<treatedSC_.size();++ic)
103 // if(treatedSC_[ic]) std::cout << " treatedSC " << ic << treatedSC_[ic] << " not cleaned " << std::endl;
104 }
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 517 of file EcalEndcapRecHitsMaker.cc.

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

Referenced by loadEcalEndcapRecHits().

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

Definition at line 349 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(), 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().

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

Definition at line 538 of file EcalEndcapRecHitsMaker.cc.

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

Referenced by loadEcalEndcapRecHits().

539 {
540  // std::cout << " is HI " ;
541  int schi=SChashedIndex(detid);
542  // std::cout << detid << " " << schi << " ";
543  // check if it has already been treated or not
544  // 0 <=> not treated
545  // 1 <=> high interest
546  // -1 <=> low interest
547  // std::cout << SCHighInterest_[schi] << std::endl;
548  if(SCHighInterest_[schi]!=0) return (SCHighInterest_[schi]>0);
549 
550  // now look if a TT contributing is of high interest
551  const std::vector<int> & tts(TTofSC_[schi]);
552  unsigned size=tts.size();
553  bool result=false;
554  for(unsigned itt=0;itt<size&&!result;++itt)
555  {
556  // std::cout << " Checking TT " << tts[itt] << std::endl;
557  if(TTTEnergy_[tts[itt]]>SRThreshold_) result=true;
558  }
559  SCHighInterest_[schi]=(result)? 1:-1;
560  theFiredSC_.push_back(schi);
561  return result;
562 }
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,
RandomEngineAndDistribution const *  random 
)

Definition at line 107 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().

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

Definition at line 160 of file EcalEndcapRecHitsMaker.cc.

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

Referenced by loadEcalEndcapRecHits().

161 {
162  // std::cout << " loadPCaloHits " << std::endl;
164  iEvent.getByLabel(inputCol_,cf);
165  std::auto_ptr<MixCollection<PCaloHit> > colcalo(new MixCollection<PCaloHit>(cf.product(),std::pair<int,int>(0,0) ));
166 
167  theFiredCells_.reserve(colcalo->size());
169  MixCollection<PCaloHit>::iterator cficaloend=colcalo->end();
170  for (cficalo=colcalo->begin(); cficalo!=cficaloend;cficalo++)
171  {
172 
173  unsigned hashedindex = EEDetId(cficalo->id()).hashedIndex();
174  // Check if the hit already exists
176  if(theCalorimeterHits_[hashedindex]==0.)
177  {
178  theFiredCells_.push_back(hashedindex);
179  float noise=(noise_==-1.) ? noisesigma_[hashedindex] : noise_ ;
180  if (!noisified_ ) {
181  theCalorimeterHits_[hashedindex] += random->gaussShoot(0.,noise*calib);
182  }
183  }
184  // the famous 1/0.97 calibration factor is applied here !
185  // the miscalibration is applied here:
186 
187  // 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
188  // be added only once. This is a dirty trick.
189  float energy=(cficalo->energy()==0.) ? 0.000001 : cficalo->energy() ;
190  energy*=calib;
191  theCalorimeterHits_[hashedindex]+=energy;
192 
193  // Now deal with the TTs
194  int TThashedindex=towerOf_[hashedindex];
195 
196  if(TTTEnergy_[TThashedindex]==0.)
197  {
198  theFiredTTs_.push_back(TThashedindex);
199  }
200  // the same dirty trick as before. sinTheta is stored only for one endcap
201  TTTEnergy_[TThashedindex]+=energy*sinTheta_[(hashedindex<EEDetId::kEEhalf)? hashedindex : hashedindex-EEDetId::kEEhalf];
202 
203  }
204  // std::cout << " Noisifying the TT " << std::endl;
207 }
TRandom random
Definition: MVATrainer.cc:138
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
MVATrainerComputer * calib
Definition: MVATrainer.cc:64
std::vector< float > TTTEnergy_
std::vector< float > theCalibConstants_
void noisifyTriggerTowers(RandomEngineAndDistribution const *)
std::vector< float > theCalorimeterHits_
std::vector< float > sinTheta_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
std::vector< float > noisesigma_
T const * product() const
Definition: Handle.h:81
void randomNoisifier(RandomEngineAndDistribution const *)
std::vector< int > theFiredTTs_
std::vector< int > theFiredCells_
void EcalEndcapRecHitsMaker::noisifySuperCrystals ( int  tthi,
RandomEngineAndDistribution const *  random 
)
private

Definition at line 224 of file EcalEndcapRecHitsMaker.cc.

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

Referenced by noisifyTriggerTowers().

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

Definition at line 209 of file EcalEndcapRecHitsMaker.cc.

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

Referenced by loadPCaloHits().

210 {
211  if(noise_==0.) return;
212 
213  // noise should be injected in all the Super-crystals contained in each trigger tower
214  unsigned nTT=theFiredTTs_.size();
215  for(unsigned itt=0;itt<nTT;++itt)
216  {
217  // shoot noise in the trigger tower
218  // std::cout << " Treating " << theFiredTTs_[itt] << " " << theTTDetIds_[theFiredTTs_[itt]] << " " << TTTEnergy_[theFiredTTs_[itt]] << std::endl;
220  }
221 }
TRandom random
Definition: MVATrainer.cc:138
#define nTT
Definition: TMEGeom.h:6
std::vector< int > theFiredTTs_
void noisifySuperCrystals(int tthi, RandomEngineAndDistribution const *)
void EcalEndcapRecHitsMaker::randomNoisifier ( RandomEngineAndDistribution const *  random)
private

Definition at line 274 of file EcalEndcapRecHitsMaker.cc.

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

Referenced by loadPCaloHits().

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

Definition at line 39 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and isHighInterest().

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

Definition at line 40 of file EcalEndcapRecHitsMaker.h.

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

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

Definition at line 43 of file EcalEndcapRecHitsMaker.h.

References EEDetId::hashedIndex(), and towerOf_.

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

Definition at line 44 of file EcalEndcapRecHitsMaker.h.

References towerOf_.

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

Definition at line 35 of file EcalEndcapRecHitsMaker.h.

Referenced by init().

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

Definition at line 36 of file EcalEndcapRecHitsMaker.h.

References EcalTrigTowerDetId::hashedIndex().

36 {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 52 of file EcalEndcapRecHitsMaker.h.

Referenced by init(), and loadEcalEndcapRecHits().

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

Definition at line 60 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 51 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
double EcalEndcapRecHitsMaker::refactor_
private

Definition at line 54 of file EcalEndcapRecHitsMaker.h.

Referenced by EcalEndcapRecHitsMaker(), and init().

double EcalEndcapRecHitsMaker::refactor_mean_
private

Definition at line 55 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 57 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