18 #include "CLHEP/Random/RandGaussQ.h"
19 #include "CLHEP/Random/RandFlat.h"
26 theParameterMap(parameters),
27 theNoiseSignalGenerator(
nullptr),
103 double noise [32] = {0.};
107 for (
int i = 0;
i < frame.
size();
i++) gauss[
i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
112 for (
int tbin = 0; tbin < frame.
size(); ++tbin) {
123 double fudgefactor = 1;
134 if(hcalGenDetId.isHcalCastorDetId())
return;
135 if(hcalGenDetId.isHcalZDCDetId())
return;
137 int theStartingCapId_2 = (int)floor(CLHEP::RandFlat::shoot(engine, 0., 4.));
138 double noise [32] = {0.};
142 if ( !thisChanCholesky ) {
143 edm::LogWarning(
"HcalAmplifier") <<
"no Cholesky " << hcalSubDet <<
" "
144 << hcalGenDetId.rawId() <<
" "
152 for (
int i = 0;
i < frame.
size();
i++) gauss[
i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
165 for (
int i = 0;
i < frame.
size();
i++) gauss[
i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
168 edm::LogWarning(
"HcalAmplifier") <<
"No Cholesky Matrices provided for new HCAL noise simulation.";
176 for (
int tbin = 0; tbin < frame.
size(); ++tbin) {
177 int capId = (theStartingCapId_2 + tbin)%4;
178 double x = noise[tbin] * fudgefactor + thisChanADCPeds->
getValue(capId);
179 int x1=(int)std::floor(x);
180 int x2=(int)std::floor(x+1);
181 float y2=coder->
charge(*shape,x2,capId);
182 float y1=coder->
charge(*shape,x1,capId);
183 frame[tbin] = (y2-y1)*(x-x1)+y1;
186 edm::LogWarning(
"HcalAmplifier") <<
"No ADC pedestals provided for new HCAL simulation.";
191 if(fFrames > 10)
return;
193 for(
int i = 0;
i != 10;
i++){
194 for(
int j = 0;
j != 10;
j++){
195 fNoise[
i] += thisChanCholesky.
getValue(m,
i,
j) * fGauss[
j];
216 double s_xy_mean = -0.5 * s_xx_mean;
221 double term = s_xx_mean*s_xx_mean - 2.*s_xy_mean*s_xy_mean;
223 if (term < 0.) term = 1.e-50 ;
224 double sigma =
sqrt (0.5 * (s_xx_mean +
sqrt(term)));
225 double corr = sigma == 0. ? 0. : 0.5*s_xy_mean / sigma;
227 for (
int i = 0;
i < fFrames;
i++) {
228 fNoise [
i] = fGauss[
i]*sigma;
229 if (
i > 0) fNoise [
i] += fGauss[
i-1]*
corr;
230 if (
i < fFrames-1) fNoise [
i] += fGauss[
i+1]*
corr;
void setUseOldHB(bool useOld)
float getValue(int capid, int i, int j) const
void setHOtuningParameter(double tp)
void makeNoiseOld(HcalGenericDetId::HcalGenericSubdetector hcalSubDet, const HcalCalibrationWidths &width, int fFrames, double *fGauss, double *fNoise) const
void setDbService(const HcalDbService *service)
the Producer will probably update this every event
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
const CaloVSimParameterMap * theParameterMap
void setUseOldHF(bool useOld)
double pedestal(int fCapId) const
get pedestal for capid=0..3
const Item * getValues(DetId fId, bool throwOnFail=true) const
void setHFtuningParameter(double tp)
Main class for Parameters in different subdetectors.
HcalAmplifier(const CaloVSimParameterMap *parameters, bool addNoise, bool PreMix1, bool PreMix2)
void addThermalNoise(CaloSamples &samples, CLHEP::HepRandomEngine *)
void setUseOldHO(bool useOld)
void delay(CaloSamples &samples, CLHEP::HepRandomEngine *) const
void setHEtuningParameter(double tp)
void setUseOldHE(bool useOld)
double pedestal(int fCapId) const
get pedestal width for capid=0..3
const HcalDbService * theDbService
bool contains(const DetId &detId) const
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
float getValue(int fCapId) const
get value for capId = 0..3
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
HcalTimeSlewSim * theTimeSlewSim
int size() const
get the size
void makeNoise(const HcalCholeskyMatrix &thisChanCholesky, int fFrames, double *fGauss, double *fNoise, int m) const
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
unsigned theStartingCapId
void addPedestals(CaloSamples &frame, CLHEP::HepRandomEngine *) const
void pe2fC(CaloSamples &frame) const
volatile std::atomic< bool > shutdown_flag false
DetId id() const
get the (generic) id
HPDIonFeedbackSim * theIonFeedbackSim
HcalGenericSubdetector genericSubdet() const
void setHBtuningParameter(double tp)
const HcalCholeskyMatrix * getValues(DetId fId, bool throwOnFail=true) const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
void setDbService(const HcalDbService *service)
const HcalPedestals * myADCPeds
double photoelectronsToAnalog() const
the factor which goes from photoelectrons to whatever gets read by ADCs
const HcalCholeskyMatrices * myCholeskys
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.