15 #include "CLHEP/GenericFunctions/Erf.hh"
80 if(threshold_.size()!=noise_.size())
82 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;
98 for(
unsigned inoise=0;inoise<
nnoise_;++inoise)
100 if(noise_[inoise]==0) {
103 }
else if(noise_[inoise]==-1) {
150 edm::LogInfo(
"CaloRecHitsProducer") <<
"Total number of cells in HCAL " << ncells << std::endl;
170 std::string hcalfile=hcalfiletmp.
fullPath();
177 std::map<uint32_t,float>::const_iterator it=mapHcal.
get().begin();
178 std::map<uint32_t,float>::const_iterator itend=mapHcal.
get().end();
182 float icalconst=it->second;
190 edm::FileInPath myDataFile(
"FastSimulation/CaloRecHitsProducer/data/adcvsfc.root");
191 TFile * myFile =
new TFile(myDataFile.
fullPath().c_str(),
"READ");
192 TGraph * myGraf = (TGraph*)myFile->Get(
"adcvsfc");
193 unsigned size=myGraf->GetN();
199 for(
unsigned ibin=0;ibin<
size;++ibin)
202 myGraf->GetPoint(ibin,x,y);
203 int index=(int)floor(x);
204 if(index<0||index>=10000)
continue;
208 for(
unsigned ivec=p_index;ivec<(unsigned)index;++ivec)
216 edm::FileInPath myTPGFilePath(
"CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat");
223 for(
unsigned i=0;
i<86;++
i)
231 std::cout <<
" Unable to open CalibCalorimetry/HcalTPGAlgos/data/RecHit-TPG-calib.dat" << std::endl;
232 std::cout <<
" Using a constant 1.2 factor " << std::endl;
239 for(
unsigned ig=0;ig<4;++ig)
247 float tpgfactor=
TPGFactor_[(ieta>0)?ieta+43:-ieta];
248 mgain*=2500./0.92*tpgfactor ;
263 for(
unsigned ig=0;ig<4;++ig)
269 float tpgfactor=
TPGFactor_[(ieta>0)?ieta+44:-ieta+1];
270 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;
305 for(
unsigned ig=0;ig<4;++ig)
319 peds_[hfhi_[ic]]=ped;
347 int hashedindex=
detid.hashed_index();
355 switch(
detid.subdet())
377 if(
det_==6 && time_slice==0)
403 for(
unsigned ihit=0;ihit<nhits;++ihit)
415 if(energy>
sat_[cellhashedindex])
418 energy=
sat_[cellhashedindex];
452 for(
unsigned ihit=0;ihit<nhits;++ihit)
460 int ieta = detid.
ieta();
463 if(ieta > 4 || ieta < -4 )
continue;
470 if(energy>
sat_[cellhashedindex]) energy=
sat_[cellhashedindex];
489 for(
unsigned ihit=0;ihit<nhits;++ihit)
501 if(energy>
sat_[cellhashedindex]) energy=
sat_[cellhashedindex];
540 for (std::vector<DetId>::const_iterator
i=ids.begin();
i!=ids.end();
i++)
548 cellsvec.push_back(hi);
553 return cellsvec.size();
572 theHits.push_back(
id);
612 edm::LogInfo(
"CaloRecHitsProducer") <<
"CaloRecHitsProducer : added noise in "<< total <<
" HCAL cells " << std::endl;
621 double mean = (double)(ncells-theHits.size())*hcalHotFraction;
625 unsigned cellindex=0;
626 uint32_t cellhashedindex=0;
631 cellhashedindex = thecells[cellindex];
636 theHits.push_back(cellhashedindex);
644 uint32_t cellhashedindex=0;
645 unsigned nhcal=thecells.size();
648 for(
unsigned ncell=0;ncell<nhcal;++ncell)
650 cellhashedindex = thecells[ncell];
654 sigma=
noisesigma_[cellhashedindex]*correctionfactor;
660 theHits.push_back(cellhashedindex);
676 unsigned size=cells.size();
678 for(
unsigned ic=0;ic<
size;++ic)
680 hits[cells[ic]] = 0.;
690 if(fc>9985.)
return 127;
691 return fctoadc_[(unsigned)floor(fc)];
699 conditions-> getPedestalWidth(detId);
700 double ssqq_1 = pedWidth->
getSigma(0,0);
701 double ssqq_2 = pedWidth->
getSigma(1,1);
702 double ssqq_3 = pedWidth->
getSigma(2,2);
703 double ssqq_4 = pedWidth->
getSigma(3,3);
712 int ieta = detId.
ieta();
713 if (sub == 3 &&
abs (ieta) > 4)
return 0.;
717 double sig_sq_mean = 0.25 * ( ssqq_1 + ssqq_2 + ssqq_3 + ssqq_4);
722 double term =
sqrt (1. +
sqrt(1. - 2.*f*f));
724 double beta =
sqrt (0.5) * f / term;
727 double RMS4 =
sqrt(sig_sq_mean) *
sqrt (2.*beta*beta + 2.*(alpha-beta)*(alpha-beta) + 2.*(alpha-2.*beta)*(alpha-2.*beta)) ;
745 double SF = 100./88.;
746 if (time_slice==-4) {
748 }
else if (time_slice==-3) {
750 }
else if (time_slice==-2) {
752 }
else if (time_slice==-1) {
754 }
else if (time_slice==0) {
756 }
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 std::vector< float > peds_
HcalRecHitsMaker(edm::ParameterSet const &p, int, const RandomEngine *random)
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_
unsigned createVectorOfSubdetectorCells(const CaloGeometry &, int subdetn, std::vector< int > &)
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 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)
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
int ieta() const
get the cell ieta
void loadPCaloHits(const edm::Event &iEvent)
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
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
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 loadHcalRecHits(edm::Event &iEvent, HBHERecHitCollection &hbheHits, HBHEDigiCollection &hbheDigis)
void reserve(size_type n)
void cleanSubDet(std::vector< float > &hits, std::vector< int > &cells)
std::vector< int > firedCells_
static std::vector< int > hbhi_
std::string fullPath() const
static std::vector< float > miscalib_
const Item * getValues(DetId fId) const
const HcalPedestal * getPedestal(const HcalGenericDetId &fId) const
static std::vector< int > hehi_
void init(const edm::EventSetup &es, bool dodigis, bool domiscalib)
tuple size
Write out results.