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) {}
const HcalDbService * theDbService
const CaloShapes * theShapes

◆ ~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.

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

Referenced by HcalAmplifier::amplify().

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 }
Electronic response of the preamp.
Definition: CaloVShape.h:11
double correctPE(const DetId &detId, double npe, CLHEP::HepRandomEngine *) const override
virtual const CaloVShape * shape(const DetId &detId, bool precise=false) const
Definition: CaloShapes.h:14
Definition: DetId.h:17
const CaloShapes * theShapes

◆ correctPE()

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

Implements CaloVPECorrection.

Definition at line 61 of file HPDIonFeedbackSim.cc.

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

Referenced by addThermalNoise(), and getIonFeedback().

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 }
static const double pe2Charge

◆ fCtoGeV()

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

Definition at line 118 of file HPDIonFeedbackSim.cc.

References cms::cuda::assert(), hcalRecHitTable_cff::detId, ecalph2::gains, HcalDbService::getGain(), HcalDbService::getGainWidth(), mps_fire::result, and theDbService.

Referenced by getIonFeedback().

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 }
const HcalGainWidth * getGainWidth(const HcalGenericDetId &fId) const
Log< level::Error, false > LogError
assert(be >=bs)
const HcalDbService * theDbService
constexpr float gains[NGAINS]
Definition: EcalConstants.h:20
const HcalGain * getGain(const HcalGenericDetId &fId) const

◆ 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.

References ALCARECOTkAlJpsiMuMu_cff::charge, correctPE(), hcalRecHitTable_cff::detId, fCtoGeV(), createfilelist::int, hgchebackDigitizer_cfi::noise, and pe2Charge.

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 }
double fCtoGeV(const DetId &detId) const
static const double pe2Charge
double correctPE(const DetId &detId, double npe, CLHEP::HepRandomEngine *) const override

◆ setDbService()

void HPDIonFeedbackSim::setDbService ( const HcalDbService service)
inline

Definition at line 34 of file HPDIonFeedbackSim.h.

References theDbService.

Referenced by HcalAmplifier::setDbService().

34 { theDbService = service; }
const HcalDbService * theDbService

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().