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

#include <HPDIonFeedbackSim.h>

Inheritance diagram for HPDIonFeedbackSim:
CaloVPECorrection

Public Member Functions

void addThermalNoise (CaloSamples &samples)
 
virtual double correctPE (const DetId &detId, double npe) const
 
double getIonFeedback (DetId detId, double signal, double pedWidth, bool doThermal, bool isInGeV)
 
 HPDIonFeedbackSim (const edm::ParameterSet &, const CaloShapes *shapes)
 need a shaper in order to set thermal noise More...
 
void setDbService (const HcalDbService *service)
 
void setRandomEngine (CLHEP::HepRandomEngine &engine)
 need a shaper in order to set thermal noise More...
 
 ~HPDIonFeedbackSim ()
 

Private Member Functions

double fCtoGeV (const DetId &detId) const
 

Private Attributes

const HcalDbServicetheDbService
 
CLHEP::RandBinomial * theRandBinomial
 
CLHEP::RandFlat * theRandFlat
 
CLHEP::RandGaussQ * theRandGauss
 
CLHEP::RandPoissonQ * theRandPoissonQ
 
const CaloShapestheShapes
 

Detailed Description

Definition at line 28 of file HPDIonFeedbackSim.h.

Constructor & Destructor Documentation

HPDIonFeedbackSim::HPDIonFeedbackSim ( const edm::ParameterSet iConfig,
const CaloShapes shapes 
)

need a shaper in order to set thermal noise

Definition at line 32 of file HPDIonFeedbackSim.cc.

33 : theDbService(0), theShapes(shapes),
35 {
36 }
CLHEP::RandGaussQ * theRandGauss
CLHEP::RandFlat * theRandFlat
const HcalDbService * theDbService
CLHEP::RandBinomial * theRandBinomial
CLHEP::RandPoissonQ * theRandPoissonQ
const CaloShapes * theShapes
HPDIonFeedbackSim::~HPDIonFeedbackSim ( )

Definition at line 38 of file HPDIonFeedbackSim.cc.

References theRandBinomial, theRandFlat, theRandGauss, and theRandPoissonQ.

39 {
41  if (theRandFlat) delete theRandFlat;
42  if (theRandGauss) delete theRandGauss;
43  if (theRandPoissonQ) delete theRandPoissonQ;
44 }
CLHEP::RandGaussQ * theRandGauss
CLHEP::RandFlat * theRandFlat
CLHEP::RandBinomial * theRandBinomial
CLHEP::RandPoissonQ * theRandPoissonQ

Member Function Documentation

void HPDIonFeedbackSim::addThermalNoise ( CaloSamples samples)

Definition at line 122 of file HPDIonFeedbackSim.cc.

References correctPE(), i, CaloSamples::id(), j, CaloShapes::shape(), CaloSamples::size(), theRandPoissonQ, and theShapes.

Referenced by HcalAmplifier::amplify().

123 {
124  // make some chance to add a PE (with a chance of feedback)
125  // for each time sample
126  double meanPE = 0.02;
127  DetId detId(samples.id());
128  int nSamples = samples.size();
129  const CaloVShape * shape = theShapes->shape(detId);
130  for(int i = 0; i < nSamples; ++i)
131  {
132  double npe = theRandPoissonQ->fire(meanPE);
133  // TODOprobably should time-smear these
134  if(npe > 0.)
135  {
136  // chance of feedback
137  npe = correctPE(detId, npe);
138  for(int j = i; j < nSamples; ++j)
139  {
140  double timeFromPE = (j-i) * 25.;
141  samples[j] += (*shape)(timeFromPE) * npe;
142  }
143  }
144  }
145 }
int i
Definition: DBlmapReader.cc:9
Electronic response of the preamp.
Definition: CaloVShape.h:11
virtual double correctPE(const DetId &detId, double npe) const
int j
Definition: DBlmapReader.cc:9
Definition: DetId.h:20
CLHEP::RandPoissonQ * theRandPoissonQ
int size() const
get the size
Definition: CaloSamples.h:24
const CaloShapes * theShapes
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
virtual const CaloVShape * shape(const DetId &detId) const
Definition: CaloShapes.h:15
double HPDIonFeedbackSim::correctPE ( const DetId detId,
double  npe 
) const
virtual

Implements CaloVPECorrection.

Definition at line 85 of file HPDIonFeedbackSim.cc.

References j, max(), p4, pe2Charge, theRandBinomial, and theRandGauss.

Referenced by addThermalNoise(), and getIonFeedback().

86 {
87  double rateInTail = 0.000211988;//read this from XML file
88  double rateInSecondTail = 4.61579e-06;//read this from XML file
89 
90  // three gauss fit is applied to data to get ion feedback distribution
91  // parameters (in fC)
92  // first gaussian
93  // double p0 = 9.53192e+05;
94  // double p1 = -3.13653e-01;
95  // double p2 = 2.78350e+00;
96 
97  // second gaussian
98  // double p3 = 2.41611e+03;
99  double p4 = 2.06117e+01;
100  double p5 = 1.09239e+01;
101 
102  // third gaussian
103  // double p6 = 3.42793e+01;
104  double p7 = 5.45548e+01;
105  double p8 = 1.59696e+01;
106 
107  double noise = 0.; // fC
108  int nFirst = (int)(theRandBinomial->fire(npe, rateInTail));
109  int nSecond = (int)(theRandBinomial->fire(npe, rateInSecondTail));
110 
111  for (int j = 0; j < nFirst; ++j) {
112  noise += theRandGauss->fire(p4, p5);
113  }
114  for (int j = 0; j < nSecond; ++j) {
115  noise += theRandGauss->fire(p7, p8);
116  }
117 
118  return npe + std::max(noise/pe2Charge, 0.);
119 }
CLHEP::RandGaussQ * theRandGauss
double pe2Charge
const T & max(const T &a, const T &b)
double p4[4]
Definition: TauolaWrapper.h:92
int j
Definition: DBlmapReader.cc:9
CLHEP::RandBinomial * theRandBinomial
double HPDIonFeedbackSim::fCtoGeV ( const DetId detId) const
private

Definition at line 148 of file HPDIonFeedbackSim.cc.

References HcalDbService::getGain(), HcalDbService::getGainWidth(), HcalGain::getValue(), query::result, and theDbService.

Referenced by getIonFeedback().

149 {
150  assert(theDbService != 0);
151  HcalGenericDetId hcalGenDetId(detId);
152  const HcalGain* gains = theDbService->getGain(hcalGenDetId);
153  const HcalGainWidth* gwidths = theDbService->getGainWidth(hcalGenDetId);
154  if (!gains || !gwidths )
155  {
156  edm::LogError("HcalAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
157  }
158  // only one gain will be recorded per channel, so just use capID 0 for now
159  double result = gains->getValue(0);
160  return result;
161 }
const HcalGainWidth * getGainWidth(const HcalGenericDetId &fId) const
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:20
const HcalDbService * theDbService
tuple result
Definition: query.py:137
const HcalGain * getGain(const HcalGenericDetId &fId) const
double HPDIonFeedbackSim::getIonFeedback ( DetId  detId,
double  signal,
double  pedWidth,
bool  doThermal,
bool  isInGeV 
)

Definition at line 60 of file HPDIonFeedbackSim.cc.

References DeDxDiscriminatorTools::charge(), correctPE(), fCtoGeV(), pe2Charge, and theRandPoissonQ.

61 {
62 
63  // HcalDetId id = detId;
64 
65  double GeVperfC = 1.;
66  if(isInGeV) GeVperfC = 1./fCtoGeV(detId);
67 
68  double charge = signal / GeVperfC;
69 
70  double noise = 0.; // fC
71  if (charge > 3. * pedWidth) { // 3 sigma away from pedestal mean
72  int npe = int (charge / pe2Charge);
73  if(doThermal) {
74  double electronEmission = 0.08;
75  npe += theRandPoissonQ->fire(electronEmission);
76  }
77 
78  noise = correctPE(detId, npe) - npe;
79  }
80  return (noise * GeVperfC);
81 
82 }
double fCtoGeV(const DetId &detId) const
double pe2Charge
double charge(const std::vector< uint8_t > &Ampls)
virtual double correctPE(const DetId &detId, double npe) const
CLHEP::RandPoissonQ * theRandPoissonQ
void HPDIonFeedbackSim::setDbService ( const HcalDbService service)
inline

Definition at line 36 of file HPDIonFeedbackSim.h.

References theDbService.

Referenced by HcalAmplifier::setDbService().

36 {theDbService = service;}
const HcalDbService * theDbService
void HPDIonFeedbackSim::setRandomEngine ( CLHEP::HepRandomEngine &  engine)

need a shaper in order to set thermal noise

Definition at line 47 of file HPDIonFeedbackSim.cc.

References theRandBinomial, theRandFlat, theRandGauss, and theRandPoissonQ.

Referenced by HcalDigitizer::HcalDigitizer(), and HcalAmplifier::setRandomEngine().

48 {
50  if (theRandFlat) delete theRandFlat;
51  if (theRandGauss) delete theRandGauss;
52  if (theRandPoissonQ) delete theRandPoissonQ;
53 
54  theRandBinomial = new CLHEP::RandBinomial(engine);
55  theRandFlat = new CLHEP::RandFlat(engine);
56  theRandGauss = new CLHEP::RandGaussQ(engine);
57  theRandPoissonQ = new CLHEP::RandPoissonQ(engine);
58 }
CLHEP::RandGaussQ * theRandGauss
CLHEP::RandFlat * theRandFlat
CLHEP::RandBinomial * theRandBinomial
CLHEP::RandPoissonQ * theRandPoissonQ

Member Data Documentation

const HcalDbService* HPDIonFeedbackSim::theDbService
private

Definition at line 48 of file HPDIonFeedbackSim.h.

Referenced by fCtoGeV(), and setDbService().

CLHEP::RandBinomial* HPDIonFeedbackSim::theRandBinomial
mutableprivate

Definition at line 51 of file HPDIonFeedbackSim.h.

Referenced by correctPE(), setRandomEngine(), and ~HPDIonFeedbackSim().

CLHEP::RandFlat* HPDIonFeedbackSim::theRandFlat
mutableprivate

Definition at line 52 of file HPDIonFeedbackSim.h.

Referenced by setRandomEngine(), and ~HPDIonFeedbackSim().

CLHEP::RandGaussQ* HPDIonFeedbackSim::theRandGauss
mutableprivate

Definition at line 53 of file HPDIonFeedbackSim.h.

Referenced by correctPE(), setRandomEngine(), and ~HPDIonFeedbackSim().

CLHEP::RandPoissonQ* HPDIonFeedbackSim::theRandPoissonQ
mutableprivate
const CaloShapes* HPDIonFeedbackSim::theShapes
private

Definition at line 49 of file HPDIonFeedbackSim.h.

Referenced by addThermalNoise().