15 #include "CLHEP/GenericFunctions/Erf.hh"
85 if(threshold_.size()!=noise_.size())
87 edm::LogWarning(
"CaloRecHitsProducer") <<
" WARNING : HCAL Noise simulation, the number of parameters should be the same for the noise and the thresholds. Disabling the noise simulation " << std::endl;
101 for(
unsigned inoise=0;inoise<
nnoise_;++inoise)
103 if(noise_[inoise]==0) {
106 }
else if(noise_[inoise]==-1) {
153 edm::LogInfo(
"CaloRecHitsProducer") <<
"Total number of cells in HCAL " << ncells << std::endl;
179 std::map<uint32_t,float>::const_iterator it=mapHcal.
get().begin();
180 std::map<uint32_t,float>::const_iterator itend=mapHcal.
get().end();
184 float icalconst=it->second;
191 edm::FileInPath myDataFile(
"FastSimulation/CaloRecHitsProducer/data/adcvsfc.root");
192 TFile * myFile =
new TFile(myDataFile.
fullPath().c_str(),
"READ");
193 TGraph * myGraf = (TGraph*)myFile->Get(
"adcvsfc");
194 unsigned size=myGraf->GetN();
200 for(
unsigned ibin=0;ibin<
size;++ibin)
203 myGraf->GetPoint(ibin,x,y);
204 int index=(int)floor(x);
205 if(index<0||index>=10000)
continue;
209 for(
unsigned ivec=p_index;ivec<(unsigned)index;++ivec)
217 edm::FileInPath myTPGFilePath(
"CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat");
224 for(
unsigned i=0;
i<86;++
i)
232 std::cout <<
" Unable to open CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat" << std::endl;
233 std::cout <<
" Using a constant 1.2 factor " << std::endl;
246 for(
unsigned ig=0;ig<4;++ig)
254 float tpgfactor=
TPGFactor_[(ieta>0)?ieta+43:-ieta];
255 mgain*=2500./0.92*tpgfactor ;
275 for(
unsigned ig=0;ig<4;++ig)
280 float tpgfactor=
TPGFactor_[(ieta>0)?ieta+44:-ieta+1];
281 mgain*=2500./0.92*tpgfactor;
300 for(
unsigned ig=0;ig<4;++ig)
306 float tpgfactor=
TPGFactor_[(ieta>0)?ieta+43:-ieta];
307 mgain*=2500./0.92*tpgfactor;
311 peds_[hohi_[ic]]=ped;
326 for(
unsigned ig=0;ig<4;++ig)
340 peds_[hfhi_[ic]]=ped;
377 switch(
detid.subdet())
399 if(
det_==6 && time_slice==0)
425 for(
unsigned ihit=0;ihit<nhits;++ihit)
437 if(energy>
sat_[cellhashedindex])
440 energy=
sat_[cellhashedindex];
474 for(
unsigned ihit=0;ihit<nhits;++ihit)
482 int ieta = detid.
ieta();
485 if(ieta > 4 || ieta < -4 )
continue;
492 if(energy>
sat_[cellhashedindex]) energy=
sat_[cellhashedindex];
511 for(
unsigned ihit=0;ihit<nhits;++ihit)
523 if(energy>
sat_[cellhashedindex]) energy=
sat_[cellhashedindex];
565 for (std::vector<DetId>::const_iterator
i=ids.begin();
i!=ids.end();
i++)
573 cellsvec.push_back(hi);
578 return cellsvec.size();
597 theHits.push_back(
id);
637 edm::LogInfo(
"CaloRecHitsProducer") <<
"CaloRecHitsProducer : added noise in "<< total <<
" HCAL cells " << std::endl;
643 if(noise_!=-1 && hcalHotFraction==0.)
return 0;
644 if(hcalHotFraction<0.3 && noise_!=-1)
646 double mean = (double)(ncells-theHits.size())*hcalHotFraction;
650 unsigned cellindex=0;
651 uint32_t cellhashedindex=0;
656 cellhashedindex = thecells[cellindex];
661 theHits.push_back(cellhashedindex);
669 uint32_t cellhashedindex=0;
670 unsigned nhcal=thecells.size();
673 for(
unsigned ncell=0;ncell<nhcal;++ncell)
675 cellhashedindex = thecells[ncell];
680 if(noise_==-1) sigma=
noisesigma_[cellhashedindex]*correctionfactor;
686 theHits.push_back(cellhashedindex);
702 unsigned size=cells.size();
704 for(
unsigned ic=0;ic<
size;++ic)
706 hits[cells[ic]] = 0.;
716 if(fc>9985.)
return 127;
717 return fctoadc_[(unsigned)floor(fc)];
725 conditions-> getPedestalWidth(detId);
726 double ssqq_1 = pedWidth->
getSigma(0,0);
727 double ssqq_2 = pedWidth->
getSigma(1,1);
728 double ssqq_3 = pedWidth->
getSigma(2,2);
729 double ssqq_4 = pedWidth->
getSigma(3,3);
738 int ieta = detId.
ieta();
739 if (sub == 3 &&
abs (ieta) > 4)
return 0.;
743 double sig_sq_mean = 0.25 * ( ssqq_1 + ssqq_2 + ssqq_3 + ssqq_4);
748 double term =
sqrt (1. +
sqrt(1. - 2.*f*f));
750 double beta =
sqrt (0.5) * f / term;
753 double RMS4 =
sqrt(sig_sq_mean) *
sqrt (2.*beta*beta + 2.*(alpha-beta)*(alpha-beta) + 2.*(alpha-2.*beta)*(alpha-2.*beta)) ;
771 double SF = 100./88.;
772 if (time_slice==-4) {
774 }
else if (time_slice==-3) {
776 }
else if (time_slice==-2) {
778 }
else if (time_slice==-1) {
780 }
else if (time_slice==0) {
782 }
else if (time_slice==1) {
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
const std::map< uint32_t, float > & get()
static bool initializedHO_
static std::vector< float > peds_
HcalRecHitsMaker(edm::ParameterSet const &p, int, const RandomEngine *random)
virtual unsigned int detId2denseId(const DetId &id) const
return a linear packed id
HcalSubdetector subdet() const
get the subdetector
static std::vector< float > sat_
std::vector< GaussianTail * > myGaussianTailGenerators_
void Fill(int id, float energy, std::vector< int > &myHits, float noise, float correctionfactor)
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
int fCtoAdc(double fc) const
std::vector< double > hcalHotFraction_
double noiseInfCfromDB(const HcalDbService *conditions, const HcalDetId &detId)
std::vector< double > noise_
bool parseXMLMiscalibFile(std::string configFile)
std::vector< float > hcalRecHits_
static std::vector< float > TPGFactor_
void push_back(T const &t)
const Item * getValues(DetId fId, bool throwOnFail=true) const
const RandomEngine * random_
static std::vector< int > hfhi_
float getValue(int fCapId) const
get value for capId = 0..3
unsigned createVectorsOfCells(const edm::EventSetup &es)
std::vector< double > corrfac_
double gaussShoot(double mean=0.0, double sigma=1.0) const
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)
static std::vector< float > noisesigma_
double fractionOOT(int time_slice)
void loadHcalRecHits(edm::Event &iEvent, const HcalTopology &, HBHERecHitCollection &hbheHits, HBHEDigiCollection &hbheDigis)
std::vector< double > threshold_
static std::vector< int > hohi_
static std::vector< int > fctoadc_
void setSample(int i, const HcalQIESample &sam)
unsigned int poissonShoot(double mean) const
static bool initializedHE_
int ieta() const
get the cell ieta
float getValue(int fCapId) const
get value for capId = 0..3
std::string hcalfileinpath_
static std::vector< HcalDetId > theDetIds_
void setSample(int i, const HcalQIESample &sam)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
unsigned createVectorOfSubdetectorCells(const CaloGeometry &, const HcalTopology &, int subdetn, std::vector< int > &)
T const * product() const
const HcalGain * getGain(const HcalGenericDetId &fId) const
T const * product() const
double flatShoot(double xmin=0.0, double xmax=1.0) const
static unsigned maxIndex_
const HcalRespCorrs * myRespCorr
void prefillMap(const HcalTopology &topology)
unsigned noisifySubdet(std::vector< float > &theMap, std::vector< int > &theHits, const std::vector< int > &thecells, unsigned ncells, double hcalHotFraction_, const GaussianTail *, double sigma, double threshold, double correctionfactor)
static std::vector< float > gains_
void reserve(size_type n)
static bool initializedHB_
void cleanSubDet(std::vector< float > &hits, std::vector< int > &cells)
std::vector< int > firedCells_
static std::vector< int > hbhi_
void loadPCaloHits(const edm::Event &iEvent, const HcalTopology &)
std::string fullPath() const
static std::vector< float > miscalib_
std::vector< bool > noiseFromDb_
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
static bool initializedHF_
static std::vector< int > hehi_
void init(const edm::EventSetup &es, bool dodigis, bool domiscalib)
tuple size
Write out results.