CMS 3D CMS Logo

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, CLHEP::HepRandomEngine *)
 
double correctPE (const DetId &detId, double npe, CLHEP::HepRandomEngine *) const override
 
double getIonFeedback (DetId detId, double signal, double pedWidth, bool doThermal, bool isInGeV, CLHEP::HepRandomEngine *)
 
 HPDIonFeedbackSim (const edm::ParameterSet &, const CaloShapes *shapes)
 need a shaper in order to set thermal noise More...
 
void setDbService (const HcalDbService *service)
 
 ~HPDIonFeedbackSim () override
 
- Public Member Functions inherited from CaloVPECorrection
virtual ~CaloVPECorrection ()
 

Private Member Functions

double fCtoGeV (const DetId &detId) const
 

Private Attributes

const HcalDbServicetheDbService
 
const CaloShapestheShapes
 

Detailed Description

Definition at line 27 of file HPDIonFeedbackSim.h.

Constructor & Destructor Documentation

◆ HPDIonFeedbackSim()

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(nullptr), theShapes(shapes) {}

◆ ~HPDIonFeedbackSim()

HPDIonFeedbackSim::~HPDIonFeedbackSim ( )
override

Definition at line 35 of file HPDIonFeedbackSim.cc.

35 {}

Member Function Documentation

◆ addThermalNoise()

void HPDIonFeedbackSim::addThermalNoise ( CaloSamples samples,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 96 of file HPDIonFeedbackSim.cc.

96  {
97  // make some chance to add a PE (with a chance of feedback)
98  // for each time sample
99  double meanPE = 0.02;
100  DetId detId(samples.id());
101  int nSamples = samples.size();
102  const CaloVShape* shape = theShapes->shape(detId);
103  for (int i = 0; i < nSamples; ++i) {
104  CLHEP::RandPoissonQ theRandPoissonQ(*engine, meanPE);
105  double npe = theRandPoissonQ.fire();
106  // TODOprobably should time-smear these
107  if (npe > 0.) {
108  // chance of feedback
109  npe = correctPE(detId, npe, engine);
110  for (int j = i; j < nSamples; ++j) {
111  double timeFromPE = (j - i) * 25.;
112  samples[j] += (*shape)(timeFromPE)*npe;
113  }
114  }
115  }
116 }

References correctPE(), mps_fire::i, dqmiolumiharvest::j, PresampleTask_cfi::nSamples, EgammaValidation_cff::samples, CaloShapes::shape(), and theShapes.

Referenced by HcalAmplifier::amplify().

◆ correctPE()

double HPDIonFeedbackSim::correctPE ( const DetId detId,
double  npe,
CLHEP::HepRandomEngine *  engine 
) const
overridevirtual

Implements CaloVPECorrection.

Definition at line 61 of file HPDIonFeedbackSim.cc.

61  {
62  double rateInTail = 0.000211988; //read this from XML file
63  double rateInSecondTail = 4.61579e-06; //read this from XML file
64 
65  // three gauss fit is applied to data to get ion feedback distribution
66  // parameters (in fC)
67  // first gaussian
68  // double p0 = 9.53192e+05;
69  // double p1 = -3.13653e-01;
70  // double p2 = 2.78350e+00;
71 
72  // second gaussian
73  // double p3 = 2.41611e+03;
74  double p4 = 2.06117e+01;
75  double p5 = 1.09239e+01;
76 
77  // third gaussian
78  // double p6 = 3.42793e+01;
79  double p7 = 5.45548e+01;
80  double p8 = 1.59696e+01;
81 
82  double noise = 0.; // fC
83  int nFirst = (int)(CLHEP::RandBinomial::shoot(engine, npe, rateInTail));
84  int nSecond = (int)(CLHEP::RandBinomial::shoot(engine, npe, rateInSecondTail));
85 
86  for (int j = 0; j < nFirst; ++j) {
87  noise += CLHEP::RandGaussQ::shoot(engine, p4, p5);
88  }
89  for (int j = 0; j < nSecond; ++j) {
90  noise += CLHEP::RandGaussQ::shoot(engine, p7, p8);
91  }
92 
93  return npe + std::max(noise / pe2Charge, 0.);
94 }

References createfilelist::int, dqmiolumiharvest::j, SiStripPI::max, hgcalDigitizer_cfi::noise, p4, and pe2Charge.

Referenced by addThermalNoise(), and getIonFeedback().

◆ fCtoGeV()

double HPDIonFeedbackSim::fCtoGeV ( const DetId detId) const
private

Definition at line 118 of file HPDIonFeedbackSim.cc.

118  {
119  assert(theDbService != nullptr);
120  HcalGenericDetId hcalGenDetId(detId);
121  const HcalGain* gains = theDbService->getGain(hcalGenDetId);
122  const HcalGainWidth* gwidths = theDbService->getGainWidth(hcalGenDetId);
123  double result = 0.0;
124  if (!gains || !gwidths) {
125  edm::LogError("HcalAmplifier") << "Could not fetch HCAL conditions for channel " << hcalGenDetId;
126  } else {
127  // only one gain will be recorded per channel, so just use capID 0 for now
128  result = gains->getValue(0);
129  }
130  return result;
131 }

References cms::cuda::assert(), HcalDbService::getGain(), HcalDbService::getGainWidth(), HcalGain::getValue(), mps_fire::result, and theDbService.

Referenced by getIonFeedback().

◆ getIonFeedback()

double HPDIonFeedbackSim::getIonFeedback ( DetId  detId,
double  signal,
double  pedWidth,
bool  doThermal,
bool  isInGeV,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 37 of file HPDIonFeedbackSim.cc.

38  {
39  // HcalDetId id = detId;
40 
41  double GeVperfC = 1.;
42  if (isInGeV)
43  GeVperfC = 1. / fCtoGeV(detId);
44 
45  double charge = signal / GeVperfC;
46 
47  double noise = 0.; // fC
48  if (charge > 3. * pedWidth) { // 3 sigma away from pedestal mean
49  int npe = int(charge / pe2Charge);
50  if (doThermal) {
51  double electronEmission = 0.08;
52  CLHEP::RandPoissonQ theRandPoissonQ(*engine, electronEmission);
53  npe += theRandPoissonQ.fire();
54  }
55 
56  noise = correctPE(detId, npe, engine) - npe;
57  }
58  return (noise * GeVperfC);
59 }

References ALCARECOTkAlJpsiMuMu_cff::charge, correctPE(), fCtoGeV(), createfilelist::int, hgcalDigitizer_cfi::noise, and pe2Charge.

◆ setDbService()

void HPDIonFeedbackSim::setDbService ( const HcalDbService service)
inline

Definition at line 34 of file HPDIonFeedbackSim.h.

34 { theDbService = service; }

References theDbService.

Referenced by HcalAmplifier::setDbService().

Member Data Documentation

◆ theDbService

const HcalDbService* HPDIonFeedbackSim::theDbService
private

Definition at line 45 of file HPDIonFeedbackSim.h.

Referenced by fCtoGeV(), and setDbService().

◆ theShapes

const CaloShapes* HPDIonFeedbackSim::theShapes
private

Definition at line 46 of file HPDIonFeedbackSim.h.

Referenced by addThermalNoise().

service
Definition: service.py:1
mps_fire.i
i
Definition: mps_fire.py:355
HcalDbService::getGainWidth
const HcalGainWidth * getGainWidth(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:312
HcalGain::getValue
float getValue(int fCapId) const
get value for capId = 0..3
Definition: HcalGain.h:21
HcalGenericDetId
Definition: HcalGenericDetId.h:15
cms::cuda::assert
assert(be >=bs)
HcalDbService::getGain
const HcalGain * getGain(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:305
PresampleTask_cfi.nSamples
nSamples
Definition: PresampleTask_cfi.py:7
EgammaValidation_cff.samples
samples
Definition: EgammaValidation_cff.py:19
HPDIonFeedbackSim::fCtoGeV
double fCtoGeV(const DetId &detId) const
Definition: HPDIonFeedbackSim.cc:118
DetId
Definition: DetId.h:17
HPDIonFeedbackSim::theDbService
const HcalDbService * theDbService
Definition: HPDIonFeedbackSim.h:45
HPDIonFeedbackSim::correctPE
double correctPE(const DetId &detId, double npe, CLHEP::HepRandomEngine *) const override
Definition: HPDIonFeedbackSim.cc:61
HcalGain
Definition: HcalGain.h:16
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
edm::LogError
Definition: MessageLogger.h:183
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
hgcalDigitizer_cfi.noise
noise
Definition: hgcalDigitizer_cfi.py:150
createfilelist.int
int
Definition: createfilelist.py:10
p4
double p4[4]
Definition: TauolaWrapper.h:92
CaloVShape
Electronic response of the preamp.
Definition: CaloVShape.h:11
CaloShapes::shape
virtual const CaloVShape * shape(const DetId &detId, bool precise=false) const
Definition: CaloShapes.h:14
pe2Charge
static const double pe2Charge
Definition: HPDIonFeedbackSim.cc:30
mps_fire.result
result
Definition: mps_fire.py:303
HPDIonFeedbackSim::theShapes
const CaloShapes * theShapes
Definition: HPDIonFeedbackSim.h:46
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
HcalGainWidth
Definition: HcalGainWidth.h:15