CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
HcalAmplifier Class Reference

#include <HcalAmplifier.h>

Public Member Functions

virtual void amplify (CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
 
 HcalAmplifier (const CaloVSimParameterMap *parameters, bool addNoise, bool PreMix1, bool PreMix2)
 
void setDbService (const HcalDbService *service)
 the Producer will probably update this every event More...
 
void setIonFeedbackSim (HPDIonFeedbackSim *feedbackSim)
 
void setNoiseSignalGenerator (const CaloVNoiseSignalGenerator *noiseSignalGenerator)
 
void setStartingCapId (int capId)
 
void setTimeSlew (const HcalTimeSlew *timeSlew)
 
void setTimeSlewSim (HcalTimeSlewSim *timeSlewSim)
 
virtual ~HcalAmplifier ()
 

Public Attributes

const HcalTimeSlewtheTimeSlew = nullptr
 

Private Member Functions

void addPedestals (CaloSamples &frame, CLHEP::HepRandomEngine *) const
 
void makeNoise (HcalGenericDetId::HcalGenericSubdetector hcalSubDet, const HcalCalibrationWidths &width, int fFrames, double *fGauss, double *fNoise) const
 
void pe2fC (CaloSamples &frame) const
 

Private Attributes

bool addNoise_
 
bool preMixAdd_
 
bool preMixDigi_
 
const HcalDbServicetheDbService
 
HPDIonFeedbackSimtheIonFeedbackSim
 
const CaloVNoiseSignalGeneratortheNoiseSignalGenerator
 
const CaloVSimParameterMaptheParameterMap
 
unsigned theStartingCapId
 
HcalTimeSlewSimtheTimeSlewSim
 

Detailed Description

Definition at line 20 of file HcalAmplifier.h.

Constructor & Destructor Documentation

◆ HcalAmplifier()

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

Definition at line 24 of file HcalAmplifier.cc.

25  : theDbService(nullptr),
27  theNoiseSignalGenerator(nullptr),
28  theIonFeedbackSim(nullptr),
29  theTimeSlewSim(nullptr),
31  addNoise_(addNoise),
32  preMixDigi_(PreMix1),
33  preMixAdd_(PreMix2) {}

◆ ~HcalAmplifier()

virtual HcalAmplifier::~HcalAmplifier ( )
inlinevirtual

Definition at line 24 of file HcalAmplifier.h.

24 {}

Member Function Documentation

◆ addPedestals()

void HcalAmplifier::addPedestals ( CaloSamples frame,
CLHEP::HepRandomEngine *  engine 
) const
private

Definition at line 63 of file HcalAmplifier.cc.

63  {
64  assert(theDbService != nullptr);
65  HcalGenericDetId hcalGenDetId(frame.id());
66  HcalGenericDetId::HcalGenericSubdetector hcalSubDet = hcalGenDetId.genericSubdet();
67 
68  if (!((frame.id().subdetId() == HcalGenericDetId::HcalGenBarrel) ||
69  (frame.id().subdetId() == HcalGenericDetId::HcalGenEndcap) ||
70  (frame.id().subdetId() == HcalGenericDetId::HcalGenForward) ||
71  (frame.id().subdetId() == HcalGenericDetId::HcalGenOuter)))
72  return;
73 
74  if (hcalGenDetId.isHcalCastorDetId())
75  return;
76  if (hcalGenDetId.isHcalZDCDetId())
77  return;
78 
79  const HcalCalibrationWidths& calibWidths = theDbService->getHcalCalibrationWidths(hcalGenDetId);
80  const HcalCalibrations& calibs = theDbService->getHcalCalibrations(hcalGenDetId);
81 
82  double noise[32] = {0.}; //big enough
83  if (addNoise_) {
84  double gauss[32]; //big enough
85  for (int i = 0; i < frame.size(); i++)
86  gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
87  makeNoise(hcalSubDet, calibWidths, frame.size(), gauss, noise);
88  }
89 
90  if (!preMixDigi_) { // if we are doing initial premix, no pedestals
91  for (int tbin = 0; tbin < frame.size(); ++tbin) {
92  int capId = (theStartingCapId + tbin) % 4;
93  double pedestal = calibs.pedestal(capId) + noise[tbin];
94  frame[tbin] += pedestal;
95  }
96  }
97 }

References addNoise_, cms::cuda::assert(), amptDefault_cfi::frame, HcalGenericDetId::genericSubdet(), HcalDbService::getHcalCalibrations(), HcalDbService::getHcalCalibrationWidths(), HcalGenericDetId::HcalGenBarrel, HcalGenericDetId::HcalGenEndcap, HcalGenericDetId::HcalGenForward, HcalGenericDetId::HcalGenOuter, mps_fire::i, makeNoise(), hgcalDigitizer_cfi::noise, HcalCalibrations::pedestal(), EcalCondDBWriter_cfi::pedestal, preMixDigi_, theDbService, and theStartingCapId.

Referenced by amplify().

◆ amplify()

void HcalAmplifier::amplify ( CaloSamples linearFrame,
CLHEP::HepRandomEngine *  engine 
) const
virtual

Definition at line 41 of file HcalAmplifier.cc.

41  {
42  if (theIonFeedbackSim) {
44  }
45  pe2fC(frame);
46  // don't bother for blank signals
47  if (theTimeSlewSim && frame.size() > 4 && frame[4] > 1.e-6) {
49  }
50 
51  // if we are combining pre-mixed digis, we need noise and peds
53  addPedestals(frame, engine);
54  }
55  LogDebug("HcalAmplifier") << frame;
56 }

References addPedestals(), HPDIonFeedbackSim::addThermalNoise(), CaloVNoiseSignalGenerator::contains(), HcalTimeSlewSim::delay(), amptDefault_cfi::frame, LogDebug, pe2fC(), preMixAdd_, theIonFeedbackSim, theNoiseSignalGenerator, theTimeSlew, and theTimeSlewSim.

Referenced by HcalElectronicsSim::convert().

◆ makeNoise()

void HcalAmplifier::makeNoise ( HcalGenericDetId::HcalGenericSubdetector  hcalSubDet,
const HcalCalibrationWidths width,
int  fFrames,
double *  fGauss,
double *  fNoise 
) const
private

Definition at line 99 of file HcalAmplifier.cc.

103  {
104  // This is a simplified noise generation scheme using only the diagonal elements
105  // (proposed by Salavat Abduline).
106  // This is direct adaptation of the code in HcalPedestalWidth.cc
107 
108  // average over capId's
109  double s_xx_mean = 0.25 * (width.pedestal(0) * width.pedestal(0) + width.pedestal(1) * width.pedestal(1) +
110  width.pedestal(2) * width.pedestal(2) + width.pedestal(3) * width.pedestal(3));
111 
112  // Off-diagonal element approximation
113  // In principle should come from averaging the values of elements (0.1), (1,2), (2,3), (3,0)
114  // For now use the definition below (but keep structure of the code structure for development)
115  double s_xy_mean = -0.5 * s_xx_mean;
116  // Use different parameter for HF to reproduce the noise rate after zero suppression.
117  // Steven Won/Jim Hirschauer/Radek Ofierzynski 18.03.2010
118  if (hcalSubDet == HcalGenericDetId::HcalGenForward)
119  s_xy_mean = 0.08 * s_xx_mean;
120 
121  double term = s_xx_mean * s_xx_mean - 2. * s_xy_mean * s_xy_mean;
122 
123  if (term < 0.)
124  term = 1.e-50;
125  double sigma = sqrt(0.5 * (s_xx_mean + sqrt(term)));
126  double corr = sigma == 0. ? 0. : 0.5 * s_xy_mean / sigma;
127 
128  for (int i = 0; i < fFrames; i++) {
129  fNoise[i] = fGauss[i] * sigma;
130  if (i > 0)
131  fNoise[i] += fGauss[i - 1] * corr;
132  if (i < fFrames - 1)
133  fNoise[i] += fGauss[i + 1] * corr;
134  }
135 }

References alignCSCRings::corr, HcalGenericDetId::HcalGenForward, mps_fire::i, mathSSE::sqrt(), and ApeEstimator_cff::width.

Referenced by addPedestals().

◆ pe2fC()

void HcalAmplifier::pe2fC ( CaloSamples frame) const
private

Definition at line 58 of file HcalAmplifier.cc.

58  {
60  frame *= parameters.photoelectronsToAnalog(frame.id());
61 }

References amptDefault_cfi::frame, CaloVSimParameterMap::simParameters(), and theParameterMap.

Referenced by amplify().

◆ setDbService()

void HcalAmplifier::setDbService ( const HcalDbService service)

the Producer will probably update this every event

Definition at line 35 of file HcalAmplifier.cc.

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

Referenced by HcalTBDigiProducer::initializeEvent().

◆ setIonFeedbackSim()

void HcalAmplifier::setIonFeedbackSim ( HPDIonFeedbackSim feedbackSim)
inline

Definition at line 28 of file HcalAmplifier.h.

28 { theIonFeedbackSim = feedbackSim; }

References theIonFeedbackSim.

◆ setNoiseSignalGenerator()

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.

32  {
33  theNoiseSignalGenerator = noiseSignalGenerator;
34  }

References theNoiseSignalGenerator.

◆ setStartingCapId()

void HcalAmplifier::setStartingCapId ( int  capId)
inline

Definition at line 42 of file HcalAmplifier.h.

42 { theStartingCapId = capId; }

References theStartingCapId.

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

◆ setTimeSlew()

void HcalAmplifier::setTimeSlew ( const HcalTimeSlew timeSlew)
inline

Definition at line 38 of file HcalAmplifier.h.

38 { theTimeSlew = timeSlew; }

References theTimeSlew.

Referenced by HcalTBDigiProducer::initializeEvent().

◆ setTimeSlewSim()

void HcalAmplifier::setTimeSlewSim ( HcalTimeSlewSim timeSlewSim)
inline

Definition at line 35 of file HcalAmplifier.h.

35 { theTimeSlewSim = timeSlewSim; }

References theTimeSlewSim.

Referenced by HcalTBDigiProducer::HcalTBDigiProducer().

Member Data Documentation

◆ addNoise_

bool HcalAmplifier::addNoise_
private

Definition at line 59 of file HcalAmplifier.h.

Referenced by addPedestals().

◆ preMixAdd_

bool HcalAmplifier::preMixAdd_
private

Definition at line 61 of file HcalAmplifier.h.

Referenced by amplify().

◆ preMixDigi_

bool HcalAmplifier::preMixDigi_
private

Definition at line 60 of file HcalAmplifier.h.

Referenced by addPedestals().

◆ theDbService

const HcalDbService* HcalAmplifier::theDbService
private

Definition at line 53 of file HcalAmplifier.h.

Referenced by addPedestals(), and setDbService().

◆ theIonFeedbackSim

HPDIonFeedbackSim* HcalAmplifier::theIonFeedbackSim
private

Definition at line 56 of file HcalAmplifier.h.

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

◆ theNoiseSignalGenerator

const CaloVNoiseSignalGenerator* HcalAmplifier::theNoiseSignalGenerator
private

Definition at line 55 of file HcalAmplifier.h.

Referenced by amplify(), and setNoiseSignalGenerator().

◆ theParameterMap

const CaloVSimParameterMap* HcalAmplifier::theParameterMap
private

Definition at line 54 of file HcalAmplifier.h.

Referenced by pe2fC().

◆ theStartingCapId

unsigned HcalAmplifier::theStartingCapId
private

Definition at line 58 of file HcalAmplifier.h.

Referenced by addPedestals(), and setStartingCapId().

◆ theTimeSlew

const HcalTimeSlew* HcalAmplifier::theTimeSlew = nullptr

Definition at line 37 of file HcalAmplifier.h.

Referenced by amplify(), and setTimeSlew().

◆ theTimeSlewSim

HcalTimeSlewSim* HcalAmplifier::theTimeSlewSim
private

Definition at line 57 of file HcalAmplifier.h.

Referenced by amplify(), and setTimeSlewSim().

HcalAmplifier::pe2fC
void pe2fC(CaloSamples &frame) const
Definition: HcalAmplifier.cc:58
service
Definition: service.py:1
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
mps_fire.i
i
Definition: mps_fire.py:355
HcalDbService::getHcalCalibrationWidths
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:70
HcalGenericDetId
Definition: HcalGenericDetId.h:15
HcalTimeSlewSim::delay
void delay(CaloSamples &samples, CLHEP::HepRandomEngine *, const HcalTimeSlew *hcalTimeSlew_delay) const
Definition: HcalTimeSlewSim.cc:28
HcalAmplifier::theTimeSlew
const HcalTimeSlew * theTimeSlew
Definition: HcalAmplifier.h:37
cms::cuda::assert
assert(be >=bs)
HcalGenericDetId::HcalGenEndcap
Definition: HcalGenericDetId.h:20
HPDIonFeedbackSim::addThermalNoise
void addThermalNoise(CaloSamples &samples, CLHEP::HepRandomEngine *)
Definition: HPDIonFeedbackSim.cc:96
HcalDbService::getHcalCalibrations
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
Definition: HcalDbService.cc:65
parameters
parameters
Definition: BeamSpot_PayloadInspector.cc:14
HcalAmplifier::theParameterMap
const CaloVSimParameterMap * theParameterMap
Definition: HcalAmplifier.h:54
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CaloSimParameters
Main class for Parameters in different subdetectors.
Definition: CaloSimParameters.h:14
CaloVSimParameterMap::simParameters
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
HcalCalibrations
Definition: HcalCalibrations.h:9
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:670
HcalGenericDetId::HcalGenericSubdetector
HcalGenericSubdetector
Definition: HcalGenericDetId.h:17
hgcalDigitizer_cfi.noise
noise
Definition: hgcalDigitizer_cfi.py:150
HcalAmplifier::theDbService
const HcalDbService * theDbService
Definition: HcalAmplifier.h:53
HcalAmplifier::preMixDigi_
bool preMixDigi_
Definition: HcalAmplifier.h:60
HcalGenericDetId::HcalGenBarrel
Definition: HcalGenericDetId.h:19
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
HcalAmplifier::addNoise_
bool addNoise_
Definition: HcalAmplifier.h:59
HcalAmplifier::theTimeSlewSim
HcalTimeSlewSim * theTimeSlewSim
Definition: HcalAmplifier.h:57
HcalAmplifier::theIonFeedbackSim
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:56
HcalCalibrations::pedestal
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
Definition: HcalCalibrations.h:46
HcalGenericDetId::genericSubdet
HcalGenericSubdetector genericSubdet() const
Definition: HcalGenericDetId.cc:21
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
HcalAmplifier::preMixAdd_
bool preMixAdd_
Definition: HcalAmplifier.h:61
HcalAmplifier::makeNoise
void makeNoise(HcalGenericDetId::HcalGenericSubdetector hcalSubDet, const HcalCalibrationWidths &width, int fFrames, double *fGauss, double *fNoise) const
Definition: HcalAmplifier.cc:99
HcalAmplifier::addPedestals
void addPedestals(CaloSamples &frame, CLHEP::HepRandomEngine *) const
Definition: HcalAmplifier.cc:63
HcalGenericDetId::HcalGenOuter
Definition: HcalGenericDetId.h:21
HcalAmplifier::theNoiseSignalGenerator
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:55
HcalCalibrationWidths
Definition: HcalCalibrationWidths.h:9
HcalGenericDetId::HcalGenForward
Definition: HcalGenericDetId.h:22
HPDIonFeedbackSim::setDbService
void setDbService(const HcalDbService *service)
Definition: HPDIonFeedbackSim.h:34
CaloVNoiseSignalGenerator::contains
bool contains(const DetId &detId) const
Definition: CaloVNoiseSignalGenerator.cc:23
HcalAmplifier::theStartingCapId
unsigned theStartingCapId
Definition: HcalAmplifier.h:58