15 #include "CLHEP/GenericFunctions/Erf.hh"
69 if(threshold_.size()!=noise_.size())
71 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;
85 for(
unsigned inoise=0;inoise<
nnoise_;++inoise)
87 if(noise_[inoise]==0) {
90 }
else if(noise_[inoise]==-1) {
137 edm::LogInfo(
"CaloRecHitsProducer") <<
"Total number of cells in HCAL " << ncells << std::endl;
163 std::map<uint32_t,float>::const_iterator it=mapHcal.
get().begin();
164 std::map<uint32_t,float>::const_iterator itend=mapHcal.
get().end();
168 float icalconst=it->second;
175 edm::FileInPath myDataFile(
"FastSimulation/CaloRecHitsProducer/data/adcvsfc.root");
176 TFile * myFile =
new TFile(myDataFile.
fullPath().c_str(),
"READ");
177 TGraph * myGraf = (TGraph*)myFile->Get(
"adcvsfc");
178 unsigned size=myGraf->GetN();
184 for(
unsigned ibin=0;ibin<
size;++ibin)
187 myGraf->GetPoint(ibin,x,y);
188 int index=(int)floor(x);
189 if(index<0||index>=10000)
continue;
193 for(
unsigned ivec=p_index;ivec<(unsigned)index;++ivec)
201 edm::FileInPath myTPGFilePath(
"CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat");
208 for(
unsigned i=0;
i<86;++
i)
216 std::cout <<
" Unable to open CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat" << std::endl;
217 std::cout <<
" Using a constant 1.2 factor " << std::endl;
230 for(
unsigned ig=0;ig<4;++ig)
238 float tpgfactor=
TPGFactor_[(ieta>0)?ieta+43:-ieta];
239 mgain*=2500./0.92*tpgfactor ;
259 for(
unsigned ig=0;ig<4;++ig)
264 float tpgfactor=
TPGFactor_[(ieta>0)?ieta+44:-ieta+1];
265 mgain*=2500./0.92*tpgfactor;
284 for(
unsigned ig=0;ig<4;++ig)
290 float tpgfactor=
TPGFactor_[(ieta>0)?ieta+43:-ieta];
291 mgain*=2500./0.92*tpgfactor;
295 peds_[hohi_[ic]]=ped;
310 for(
unsigned ig=0;ig<4;++ig)
324 peds_[hfhi_[ic]]=ped;
362 switch(
detid.subdet())
384 if(
det_==6 && time_slice==0)
411 for(
unsigned ihit=0;ihit<nhits;++ihit)
423 if(energy>
sat_[cellhashedindex])
426 energy=
sat_[cellhashedindex];
461 for(
unsigned ihit=0;ihit<nhits;++ihit)
469 int ieta = detid.
ieta();
472 if(ieta > 4 || ieta < -4 )
continue;
479 if(energy>
sat_[cellhashedindex]) energy=
sat_[cellhashedindex];
499 for(
unsigned ihit=0;ihit<nhits;++ihit)
511 if(energy>
sat_[cellhashedindex]) energy=
sat_[cellhashedindex];
553 for (std::vector<DetId>::const_iterator
i=ids.begin();
i!=ids.end();
i++)
561 cellsvec.push_back(hi);
566 return cellsvec.size();
586 theHits.push_back(
id);
626 edm::LogInfo(
"CaloRecHitsProducer") <<
"CaloRecHitsProducer : added noise in "<< total <<
" HCAL cells " << std::endl;
633 if(noise_!=-1 && hcalHotFraction==0.)
return 0;
634 if(hcalHotFraction<0.3 && noise_!=-1)
636 double mean = (double)(ncells-theHits.size())*hcalHotFraction;
640 unsigned cellindex=0;
641 uint32_t cellhashedindex=0;
645 cellindex = (unsigned)(random->
flatShoot()*ncells);
646 cellhashedindex = thecells[cellindex];
651 theHits.push_back(cellhashedindex);
659 uint32_t cellhashedindex=0;
660 unsigned nhcal=thecells.size();
663 for(
unsigned ncell=0;ncell<nhcal;++ncell)
665 cellhashedindex = thecells[ncell];
670 if(noise_==-1) sigma=
noisesigma_[cellhashedindex]*correctionfactor;
676 theHits.push_back(cellhashedindex);
692 unsigned size=cells.size();
694 for(
unsigned ic=0;ic<
size;++ic)
696 hits[cells[ic]] = 0.;
706 if(fc>9985.)
return 127;
707 return fctoadc_[(unsigned)floor(fc)];
715 conditions-> getPedestalWidth(detId);
716 double ssqq_1 = pedWidth->
getSigma(0,0);
717 double ssqq_2 = pedWidth->
getSigma(1,1);
718 double ssqq_3 = pedWidth->
getSigma(2,2);
719 double ssqq_4 = pedWidth->
getSigma(3,3);
728 int ieta = detId.
ieta();
729 if (sub == 3 &&
abs (ieta) > 4)
return 0.;
733 double sig_sq_mean = 0.25 * ( ssqq_1 + ssqq_2 + ssqq_3 + ssqq_4);
738 double term =
sqrt (1. +
sqrt(1. - 2.*f*f));
740 double beta =
sqrt (0.5) * f / term;
743 double RMS4 =
sqrt(sig_sq_mean) *
sqrt (2.*beta*beta + 2.*(alpha-beta)*(alpha-beta) + 2.*(alpha-2.*beta)*(alpha-2.*beta)) ;
761 double SF = 100./88.;
762 if (time_slice==-4) {
764 }
else if (time_slice==-3) {
766 }
else if (time_slice==-2) {
768 }
else if (time_slice==-1) {
770 }
else if (time_slice==0) {
772 }
else if (time_slice==1) {
void loadHcalRecHits(edm::Event &iEvent, const HcalTopology &, HBHERecHitCollection &hbheHits, HBHEDigiCollection &hbheDigis, RandomEngineAndDistribution const *)
HcalRecHitsMaker(edm::ParameterSet const &p, int)
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()
std::vector< float > gains_
virtual unsigned int detId2denseId(const DetId &id) const
return a linear packed id
std::vector< float > miscalib_
HcalSubdetector subdet() const
get the subdetector
double flatShoot(double xmin=0.0, double xmax=1.0) const
std::vector< GaussianTail * > myGaussianTailGenerators_
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_
void push_back(T const &t)
std::vector< float > noisesigma_
const Item * getValues(DetId fId, bool throwOnFail=true) const
float getValue(int fCapId) const
get value for capId = 0..3
unsigned createVectorsOfCells(const edm::EventSetup &es)
std::vector< double > corrfac_
void loadPCaloHits(const edm::Event &iEvent, const HcalTopology &, RandomEngineAndDistribution const *)
void Fill(int id, float energy, std::vector< int > &myHits, float noise, float correctionfactor, RandomEngineAndDistribution 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)
double shoot(RandomEngineAndDistribution const *) const
double fractionOOT(int time_slice)
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, RandomEngineAndDistribution const *)
std::vector< double > threshold_
void setSample(int i, const HcalQIESample &sam)
int ieta() const
get the cell ieta
Abs< T >::type abs(const T &t)
std::vector< float > sat_
float getValue(int fCapId) const
get value for capId = 0..3
std::string hcalfileinpath_
void setSample(int i, const HcalQIESample &sam)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
void noisify(RandomEngineAndDistribution const *)
std::vector< float > TPGFactor_
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
const HcalRespCorrs * myRespCorr
void prefillMap(const HcalTopology &topology)
static std::atomic< unsigned int > counter
std::vector< int > fctoadc_
double gaussShoot(double mean=0.0, double sigma=1.0) const
unsigned int poissonShoot(double mean) const
void reserve(size_type n)
void cleanSubDet(std::vector< float > &hits, std::vector< int > &cells)
std::vector< int > firedCells_
volatile std::atomic< bool > shutdown_flag false
std::string fullPath() const
std::vector< bool > noiseFromDb_
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
std::vector< HcalDetId > theDetIds_
void init(const edm::EventSetup &es, bool dodigis, bool domiscalib)
tuple size
Write out results.
std::vector< float > peds_