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
HcalAmplifier Class Reference

#include <HcalAmplifier.h>

Public Member Functions

virtual void amplify (CaloSamples &linearFrame) const
 
 HcalAmplifier (const CaloVSimParameterMap *parameters, bool addNoise)
 
void setADCPeds (const HcalPedestals *ADCPeds)
 
void setCholesky (const HcalCholeskyMatrices *Cholesky)
 
void setDbService (const HcalDbService *service)
 the Producer will probably update this every event More...
 
void setHBtuningParameter (double tp)
 
void setHEtuningParameter (double tp)
 
void setHFtuningParameter (double tp)
 
void setHOtuningParameter (double tp)
 
void setIonFeedbackSim (HPDIonFeedbackSim *feedbackSim)
 
void setNoiseSignalGenerator (const CaloVNoiseSignalGenerator *noiseSignalGenerator)
 
void setRandomEngine (CLHEP::HepRandomEngine &engine)
 
void setStartingCapId (int capId)
 
void setUseOldHB (bool useOld)
 
void setUseOldHE (bool useOld)
 
void setUseOldHF (bool useOld)
 
void setUseOldHO (bool useOld)
 
virtual ~HcalAmplifier ()
 

Private Member Functions

void addPedestals (CaloSamples &frame) const
 
void makeNoise (const HcalCholeskyMatrix &thisChanCholesky, int fFrames, double *fGauss, double *fNoise, int m) const
 
void makeNoiseOld (HcalGenericDetId::HcalGenericSubdetector hcalSubDet, const HcalCalibrationWidths &width, int fFrames, double *fGauss, double *fNoise) const
 
void pe2fC (CaloSamples &frame) const
 

Private Attributes

bool addNoise_
 
double HB_ff
 
double HE_ff
 
double HF_ff
 
double HO_ff
 
const HcalPedestalsmyADCPeds
 
const HcalCholeskyMatricesmyCholeskys
 
const HcalDbServicetheDbService
 
HPDIonFeedbackSimtheIonFeedbackSim
 
const CaloVNoiseSignalGeneratortheNoiseSignalGenerator
 
const CaloVSimParameterMaptheParameterMap
 
CLHEP::RandFlat * theRandFlat
 
CLHEP::RandGaussQ * theRandGaussQ
 
unsigned theStartingCapId
 
bool useOldHB
 
bool useOldHE
 
bool useOldHF
 
bool useOldHO
 

Detailed Description

Definition at line 20 of file HcalAmplifier.h.

Constructor & Destructor Documentation

HcalAmplifier::HcalAmplifier ( const CaloVSimParameterMap parameters,
bool  addNoise 
)

Definition at line 21 of file HcalAmplifier.cc.

21  :
22  theDbService(0),
23  theRandGaussQ(0),
24  theRandFlat(0),
25  theParameterMap(parameters),
28  theStartingCapId(0),
29  addNoise_(addNoise),
30  useOldHB(false),
31  useOldHE(false),
32  useOldHF(false),
33  useOldHO(false)
34 {
35 }
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:61
const CaloVSimParameterMap * theParameterMap
Definition: HcalAmplifier.h:60
CLHEP::RandGaussQ * theRandGaussQ
Definition: HcalAmplifier.h:58
const HcalDbService * theDbService
Definition: HcalAmplifier.h:57
unsigned theStartingCapId
Definition: HcalAmplifier.h:63
CLHEP::RandFlat * theRandFlat
Definition: HcalAmplifier.h:59
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:62
virtual HcalAmplifier::~HcalAmplifier ( )
inlinevirtual

Definition at line 23 of file HcalAmplifier.h.

References theRandGaussQ.

23 { delete theRandGaussQ; }
CLHEP::RandGaussQ * theRandGaussQ
Definition: HcalAmplifier.h:58

Member Function Documentation

void HcalAmplifier::addPedestals ( CaloSamples frame) const
private

Definition at line 81 of file HcalAmplifier.cc.

References addNoise_, HcalQIECoder::charge(), HcalGenericDetId::genericSubdet(), HcalDbService::getHcalCalibrations(), HcalDbService::getHcalCalibrationWidths(), HcalDbService::getHcalCoder(), HcalDbService::getHcalShape(), HcalPedestal::getValue(), HcalCholeskyMatrices::getValues(), HcalCondObjectContainer< Item >::getValues(), HB_ff, HcalGenericDetId::HcalGenBarrel, HcalGenericDetId::HcalGenEndcap, HcalGenericDetId::HcalGenForward, HcalGenericDetId::HcalGenOuter, HE_ff, HF_ff, HO_ff, i, CaloSamples::id(), makeNoise(), makeNoiseOld(), myADCPeds, myCholeskys, HcalCalibrations::pedestal(), CaloSamples::size(), theDbService, theRandFlat, theRandGaussQ, theStartingCapId, useOldHB, useOldHE, useOldHF, useOldHO, and x.

Referenced by amplify().

82 {
83  assert(theDbService != 0);
84  HcalGenericDetId hcalGenDetId(frame.id());
85  HcalGenericDetId::HcalGenericSubdetector hcalSubDet = hcalGenDetId.genericSubdet();
86 
87  bool useOld=false;
88  if(hcalSubDet==HcalGenericDetId::HcalGenBarrel) useOld = useOldHB;
89  if(hcalSubDet==HcalGenericDetId::HcalGenEndcap) useOld = useOldHE;
90  if(hcalSubDet==HcalGenericDetId::HcalGenForward) useOld = useOldHF;
91  if(hcalSubDet==HcalGenericDetId::HcalGenOuter) useOld = useOldHO;
92 
93  if(useOld)
94  {
95  const HcalCalibrationWidths & calibWidths =
97  const HcalCalibrations& calibs = theDbService->getHcalCalibrations(hcalGenDetId);
98 
99  double noise [32] = {0.}; //big enough
100  if(addNoise_)
101  {
102  double gauss [32]; //big enough
103  for (int i = 0; i < frame.size(); i++) gauss[i] = theRandGaussQ->fire(0., 1.);
104  makeNoiseOld(hcalSubDet, calibWidths, frame.size(), gauss, noise);
105  }
106 
107  for (int tbin = 0; tbin < frame.size(); ++tbin) {
108  int capId = (theStartingCapId + tbin)%4;
109  double pedestal = calibs.pedestal(capId) + noise[tbin];
110  frame[tbin] += pedestal;
111  }
112  return;
113  }
114 
115 
116  double fudgefactor = 1;
117  if(hcalSubDet==HcalGenericDetId::HcalGenBarrel) fudgefactor = HB_ff;
118  if(hcalSubDet==HcalGenericDetId::HcalGenEndcap) fudgefactor = HE_ff;
119  if(hcalSubDet==HcalGenericDetId::HcalGenForward) fudgefactor = HF_ff;
120  if(hcalSubDet==HcalGenericDetId::HcalGenOuter) fudgefactor = HO_ff;
121  if(hcalGenDetId.isHcalCastorDetId()) return;
122  if(hcalGenDetId.isHcalZDCDetId()) return;
123 
124  const HcalCholeskyMatrix * thisChanCholesky = myCholeskys->getValues(hcalGenDetId);
125  const HcalPedestal * thisChanADCPeds = myADCPeds->getValues(hcalGenDetId);
126  int theStartingCapId_2 = (int)floor(theRandFlat->fire(0.,4.));
127 
128  double noise [32] = {0.}; //big enough
129  if(addNoise_)
130  {
131  double gauss [32]; //big enough
132  for (int i = 0; i < frame.size(); i++) gauss[i] = theRandGaussQ->fire(0., 1.);
133  makeNoise(*thisChanCholesky, frame.size(), gauss, noise, (int)theStartingCapId_2);
134  }
135 
136  const HcalQIECoder* coder = theDbService->getHcalCoder(hcalGenDetId);
137  const HcalQIEShape* shape = theDbService->getHcalShape();
138 
139  for (int tbin = 0; tbin < frame.size(); ++tbin) {
140  int capId = (theStartingCapId_2 + tbin)%4;
141  double x = noise[tbin] * fudgefactor + thisChanADCPeds->getValue(capId);//*(values+capId); //*.70 goes here!
142  int x1=(int)std::floor(x);
143  int x2=(int)std::floor(x+1);
144  float y2=coder->charge(*shape,x2,capId);
145  float y1=coder->charge(*shape,x1,capId);
146  frame[tbin] = (y2-y1)*(x-x1)+y1;
147  }
148 }
void makeNoiseOld(HcalGenericDetId::HcalGenericSubdetector hcalSubDet, const HcalCalibrationWidths &width, int fFrames, double *fGauss, double *fNoise) const
int i
Definition: DBlmapReader.cc:9
double pedestal(int fCapId) const
get pedestal for capid=0..3
CLHEP::RandGaussQ * theRandGaussQ
Definition: HcalAmplifier.h:58
const HcalDbService * theDbService
Definition: HcalAmplifier.h:57
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalPedestal.h:19
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
int size() const
get the size
Definition: CaloSamples.h:24
void makeNoise(const HcalCholeskyMatrix &thisChanCholesky, int fFrames, double *fGauss, double *fNoise, int m) const
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
unsigned theStartingCapId
Definition: HcalAmplifier.h:63
const HcalCholeskyMatrix * getValues(DetId fId) const
CLHEP::RandFlat * theRandFlat
Definition: HcalAmplifier.h:59
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
HcalGenericSubdetector genericSubdet() const
Definition: DDAxes.h:10
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
const Item * getValues(DetId fId) const
const HcalPedestals * myADCPeds
Definition: HcalAmplifier.h:75
const HcalQIEShape * getHcalShape() const
const HcalCholeskyMatrices * myCholeskys
Definition: HcalAmplifier.h:74
float charge(const HcalQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -&gt; fC conversion.
Definition: HcalQIECoder.cc:22
void HcalAmplifier::amplify ( CaloSamples linearFrame) const
virtual

Definition at line 52 of file HcalAmplifier.cc.

References addPedestals(), HPDIonFeedbackSim::addThermalNoise(), CaloVNoiseSignalGenerator::contains(), CaloSamples::id(), LogDebug, pe2fC(), theIonFeedbackSim, and theNoiseSignalGenerator.

Referenced by HcalElectronicsSim::convert().

52  {
54  {
56  }
57  pe2fC(frame);
59  {
60  addPedestals(frame);
61  }
62  LogDebug("HcalAmplifier") << frame;
63 }
#define LogDebug(id)
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:61
void addThermalNoise(CaloSamples &samples)
bool contains(const DetId &detId) const
void addPedestals(CaloSamples &frame) const
void pe2fC(CaloSamples &frame) const
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:62
void HcalAmplifier::makeNoise ( const HcalCholeskyMatrix thisChanCholesky,
int  fFrames,
double *  fGauss,
double *  fNoise,
int  m 
) const
private

Definition at line 150 of file HcalAmplifier.cc.

References HcalCholeskyMatrix::getValue(), i, and j.

Referenced by addPedestals().

150  {
151  if(fFrames > 10) return;
152 
153  for(int i = 0; i != 10; i++){
154  for(int j = 0; j != 10; j++){ //fNoise is initialized to zero in function above! Must be zero before this step
155  fNoise[i] += thisChanCholesky.getValue(m,i,j) * fGauss[j];
156  }
157  }
158 }
float getValue(int capid, int i, int j) const
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
void HcalAmplifier::makeNoiseOld ( HcalGenericDetId::HcalGenericSubdetector  hcalSubDet,
const HcalCalibrationWidths width,
int  fFrames,
double *  fGauss,
double *  fNoise 
) const
private

Definition at line 160 of file HcalAmplifier.cc.

References corr, HcalGenericDetId::HcalGenForward, i, HcalCalibrationWidths::pedestal(), and mathSSE::sqrt().

Referenced by addPedestals().

161 {
162  // This is a simplified noise generation scheme using only the diagonal elements
163  // (proposed by Salavat Abduline).
164  // This is direct adaptation of the code in HcalPedestalWidth.cc
165 
166  // average over capId's
167  double s_xx_mean = 0.25 * (width.pedestal(0)*width.pedestal(0) +
168  width.pedestal(1)*width.pedestal(1) +
169  width.pedestal(2)*width.pedestal(2) +
170  width.pedestal(3)*width.pedestal(3));
171 
172 
173  // Off-diagonal element approximation
174  // In principle should come from averaging the values of elements (0.1), (1,2), (2,3), (3,0)
175  // For now use the definition below (but keep structure of the code structure for development)
176  double s_xy_mean = -0.5 * s_xx_mean;
177  // Use different parameter for HF to reproduce the noise rate after zero suppression.
178  // Steven Won/Jim Hirschauer/Radek Ofierzynski 18.03.2010
179  if (hcalSubDet == HcalGenericDetId::HcalGenForward) s_xy_mean = 0.08 * s_xx_mean;
180 
181  double term = s_xx_mean*s_xx_mean - 2.*s_xy_mean*s_xy_mean;
182 
183  if (term < 0.) term = 1.e-50 ;
184  double sigma = sqrt (0.5 * (s_xx_mean + sqrt(term)));
185  double corr = sigma == 0. ? 0. : 0.5*s_xy_mean / sigma;
186 
187  for (int i = 0; i < fFrames; i++) {
188  fNoise [i] = fGauss[i]*sigma;
189  if (i > 0) fNoise [i] += fGauss[i-1]*corr;
190  if (i < fFrames-1) fNoise [i] += fGauss[i+1]*corr;
191  }
192 }
int i
Definition: DBlmapReader.cc:9
double pedestal(int fCapId) const
get pedestal width for capid=0..3
T sqrt(T t)
Definition: SSEVec.h:28
JetCorrectorParameters corr
Definition: classes.h:9
void HcalAmplifier::pe2fC ( CaloSamples frame) const
private

Definition at line 66 of file HcalAmplifier.cc.

References CaloSamples::id(), Parameters::parameters, CaloSimParameters::photoelectronsToAnalog(), CaloVSimParameterMap::simParameters(), and theParameterMap.

Referenced by amplify().

67 {
69  frame *= parameters.photoelectronsToAnalog(frame.id());
70 }
dictionary parameters
Definition: Parameters.py:2
const CaloVSimParameterMap * theParameterMap
Definition: HcalAmplifier.h:60
Main class for Parameters in different subdetectors.
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
double photoelectronsToAnalog() const
the factor which goes from photoelectrons to whatever gets read by ADCs
void HcalAmplifier::setADCPeds ( const HcalPedestals ADCPeds)
inline

Definition at line 48 of file HcalAmplifier.h.

References myADCPeds.

Referenced by HcalDigitizer::produce().

48 { myADCPeds = ADCPeds; }
const HcalPedestals * myADCPeds
Definition: HcalAmplifier.h:75
void HcalAmplifier::setCholesky ( const HcalCholeskyMatrices Cholesky)
inline

Definition at line 47 of file HcalAmplifier.h.

References myCholeskys.

Referenced by HcalDigitizer::produce().

47 { myCholeskys = Cholesky; }
const HcalCholeskyMatrices * myCholeskys
Definition: HcalAmplifier.h:74
void HcalAmplifier::setDbService ( const HcalDbService service)

the Producer will probably update this every event

Definition at line 38 of file HcalAmplifier.cc.

References HPDIonFeedbackSim::setDbService(), theDbService, and theIonFeedbackSim.

Referenced by HcalTBDigiProducer::produce(), and HcalDigitizer::produce().

38  {
39  theDbService = service;
41 }
const HcalDbService * theDbService
Definition: HcalAmplifier.h:57
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:62
void setDbService(const HcalDbService *service)
void HcalAmplifier::setHBtuningParameter ( double  tp)

Definition at line 72 of file HcalAmplifier.cc.

References HB_ff.

72 { HB_ff = tp; }
void HcalAmplifier::setHEtuningParameter ( double  tp)

Definition at line 73 of file HcalAmplifier.cc.

References HE_ff.

73 { HE_ff = tp; }
void HcalAmplifier::setHFtuningParameter ( double  tp)

Definition at line 74 of file HcalAmplifier.cc.

References HF_ff.

Referenced by HcalDigitizer::HcalDigitizer().

74 { HF_ff = tp; }
void HcalAmplifier::setHOtuningParameter ( double  tp)

Definition at line 75 of file HcalAmplifier.cc.

References HO_ff.

Referenced by HcalDigitizer::HcalDigitizer().

75 { HO_ff = tp; }
void HcalAmplifier::setIonFeedbackSim ( HPDIonFeedbackSim feedbackSim)
inline

Definition at line 28 of file HcalAmplifier.h.

References theIonFeedbackSim.

28 {theIonFeedbackSim = feedbackSim;}
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:62
void HcalAmplifier::setNoiseSignalGenerator ( const CaloVNoiseSignalGenerator noiseSignalGenerator)
inline

if it's set, the amplifier will only use it to check if it has already added noise

Definition at line 32 of file HcalAmplifier.h.

References theNoiseSignalGenerator.

Referenced by HcalDigitizer::setHBHENoiseSignalGenerator(), HcalDigitizer::setHFNoiseSignalGenerator(), HcalDigitizer::setHONoiseSignalGenerator(), and HcalDigitizer::setZDCNoiseSignalGenerator().

32  {
33  theNoiseSignalGenerator = noiseSignalGenerator;
34  }
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:61
void HcalAmplifier::setRandomEngine ( CLHEP::HepRandomEngine &  engine)

Definition at line 44 of file HcalAmplifier.cc.

References HPDIonFeedbackSim::setRandomEngine(), theIonFeedbackSim, theRandFlat, and theRandGaussQ.

Referenced by HcalElectronicsSim::setRandomEngine().

45 {
46  theRandGaussQ = new CLHEP::RandGaussQ(engine);
47  theRandFlat = new CLHEP::RandFlat(engine);
49 }
CLHEP::RandGaussQ * theRandGaussQ
Definition: HcalAmplifier.h:58
void setRandomEngine(CLHEP::HepRandomEngine &engine)
CLHEP::RandFlat * theRandFlat
Definition: HcalAmplifier.h:59
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:62
void HcalAmplifier::setStartingCapId ( int  capId)
inline

Definition at line 38 of file HcalAmplifier.h.

References theStartingCapId.

Referenced by HcalElectronicsSim::newEvent(), and HcalElectronicsSim::setStartingCapId().

38 {theStartingCapId = capId;}
unsigned theStartingCapId
Definition: HcalAmplifier.h:63
void HcalAmplifier::setUseOldHB ( bool  useOld)

Definition at line 76 of file HcalAmplifier.cc.

References useOldHB.

76 { useOldHB = useOld; }
void HcalAmplifier::setUseOldHE ( bool  useOld)

Definition at line 77 of file HcalAmplifier.cc.

References useOldHE.

77 { useOldHE = useOld; }
void HcalAmplifier::setUseOldHF ( bool  useOld)

Definition at line 78 of file HcalAmplifier.cc.

References useOldHF.

Referenced by HcalDigitizer::HcalDigitizer().

78 { useOldHF = useOld; }
void HcalAmplifier::setUseOldHO ( bool  useOld)

Definition at line 79 of file HcalAmplifier.cc.

References useOldHO.

Referenced by HcalDigitizer::HcalDigitizer().

79 { useOldHO = useOld; }

Member Data Documentation

bool HcalAmplifier::addNoise_
private

Definition at line 64 of file HcalAmplifier.h.

Referenced by addPedestals().

double HcalAmplifier::HB_ff
private

Definition at line 70 of file HcalAmplifier.h.

Referenced by addPedestals(), and setHBtuningParameter().

double HcalAmplifier::HE_ff
private

Definition at line 71 of file HcalAmplifier.h.

Referenced by addPedestals(), and setHEtuningParameter().

double HcalAmplifier::HF_ff
private

Definition at line 72 of file HcalAmplifier.h.

Referenced by addPedestals(), and setHFtuningParameter().

double HcalAmplifier::HO_ff
private

Definition at line 73 of file HcalAmplifier.h.

Referenced by addPedestals(), and setHOtuningParameter().

const HcalPedestals* HcalAmplifier::myADCPeds
private

Definition at line 75 of file HcalAmplifier.h.

Referenced by addPedestals(), and setADCPeds().

const HcalCholeskyMatrices* HcalAmplifier::myCholeskys
private

Definition at line 74 of file HcalAmplifier.h.

Referenced by addPedestals(), and setCholesky().

const HcalDbService* HcalAmplifier::theDbService
private

Definition at line 57 of file HcalAmplifier.h.

Referenced by addPedestals(), and setDbService().

HPDIonFeedbackSim* HcalAmplifier::theIonFeedbackSim
private

Definition at line 62 of file HcalAmplifier.h.

Referenced by amplify(), setDbService(), setIonFeedbackSim(), and setRandomEngine().

const CaloVNoiseSignalGenerator* HcalAmplifier::theNoiseSignalGenerator
private

Definition at line 61 of file HcalAmplifier.h.

Referenced by amplify(), and setNoiseSignalGenerator().

const CaloVSimParameterMap* HcalAmplifier::theParameterMap
private

Definition at line 60 of file HcalAmplifier.h.

Referenced by pe2fC().

CLHEP::RandFlat* HcalAmplifier::theRandFlat
private

Definition at line 59 of file HcalAmplifier.h.

Referenced by addPedestals(), and setRandomEngine().

CLHEP::RandGaussQ* HcalAmplifier::theRandGaussQ
private

Definition at line 58 of file HcalAmplifier.h.

Referenced by addPedestals(), setRandomEngine(), and ~HcalAmplifier().

unsigned HcalAmplifier::theStartingCapId
private

Definition at line 63 of file HcalAmplifier.h.

Referenced by addPedestals(), and setStartingCapId().

bool HcalAmplifier::useOldHB
private

Definition at line 65 of file HcalAmplifier.h.

Referenced by addPedestals(), and setUseOldHB().

bool HcalAmplifier::useOldHE
private

Definition at line 66 of file HcalAmplifier.h.

Referenced by addPedestals(), and setUseOldHE().

bool HcalAmplifier::useOldHF
private

Definition at line 67 of file HcalAmplifier.h.

Referenced by addPedestals(), and setUseOldHF().

bool HcalAmplifier::useOldHO
private

Definition at line 68 of file HcalAmplifier.h.

Referenced by addPedestals(), and setUseOldHO().