CMS 3D CMS Logo

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, 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 setTimeSlewSim (HcalTimeSlewSim *timeSlewSim)
 
virtual ~HcalAmplifier ()
 

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 19 of file HcalAmplifier.h.

Constructor & Destructor Documentation

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

Definition at line 24 of file HcalAmplifier.cc.

24  :
25  theDbService(nullptr),
26  theParameterMap(parameters),
27  theNoiseSignalGenerator(nullptr),
28  theIonFeedbackSim(nullptr),
29  theTimeSlewSim(nullptr),
31  addNoise_(addNoise),
32  preMixDigi_(PreMix1),
33  preMixAdd_(PreMix2)
34 { }
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:50
const CaloVSimParameterMap * theParameterMap
Definition: HcalAmplifier.h:49
const HcalDbService * theDbService
Definition: HcalAmplifier.h:48
HcalTimeSlewSim * theTimeSlewSim
Definition: HcalAmplifier.h:52
unsigned theStartingCapId
Definition: HcalAmplifier.h:53
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:51
virtual HcalAmplifier::~HcalAmplifier ( )
inlinevirtual

Definition at line 23 of file HcalAmplifier.h.

23 {}

Member Function Documentation

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

Definition at line 70 of file HcalAmplifier.cc.

References addNoise_, HcalGenericDetId::genericSubdet(), HcalDbService::getHcalCalibrations(), HcalDbService::getHcalCalibrationWidths(), HcalGenericDetId::HcalGenBarrel, HcalGenericDetId::HcalGenEndcap, HcalGenericDetId::HcalGenForward, HcalGenericDetId::HcalGenOuter, mps_fire::i, CaloSamples::id(), makeNoise(), muonCSCDigis_cfi::pedestal, HcalCalibrations::pedestal(), preMixDigi_, CaloSamples::size(), DetId::subdetId(), theDbService, and theStartingCapId.

Referenced by amplify().

71 {
72  assert(theDbService != nullptr);
73  HcalGenericDetId hcalGenDetId(frame.id());
74  HcalGenericDetId::HcalGenericSubdetector hcalSubDet = hcalGenDetId.genericSubdet();
75 
76  if ( !( (frame.id().subdetId()==HcalGenericDetId::HcalGenBarrel) ||
79  (frame.id().subdetId()==HcalGenericDetId::HcalGenOuter) ) ) return;
80 
81  if(hcalGenDetId.isHcalCastorDetId()) return;
82  if(hcalGenDetId.isHcalZDCDetId()) return;
83 
84  const HcalCalibrationWidths & calibWidths = theDbService->getHcalCalibrationWidths(hcalGenDetId);
85  const HcalCalibrations& calibs = theDbService->getHcalCalibrations(hcalGenDetId);
86 
87  double noise [32] = {0.}; //big enough
88  if(addNoise_)
89  {
90  double gauss [32]; //big enough
91  for (int i = 0; i < frame.size(); i++) gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
92  makeNoise(hcalSubDet, calibWidths, frame.size(), gauss, noise);
93  }
94 
95  if(!preMixDigi_){ // if we are doing initial premix, no pedestals
96  for (int tbin = 0; tbin < frame.size(); ++tbin) {
97  int capId = (theStartingCapId + tbin)%4;
98  double pedestal = calibs.pedestal(capId) + noise[tbin];
99  frame[tbin] += pedestal;
100  }
101  }
102 }
double pedestal(int fCapId) const
get pedestal for capid=0..3
const HcalDbService * theDbService
Definition: HcalAmplifier.h:48
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
int size() const
get the size
Definition: CaloSamples.h:24
unsigned theStartingCapId
Definition: HcalAmplifier.h:53
void makeNoise(HcalGenericDetId::HcalGenericSubdetector hcalSubDet, const HcalCalibrationWidths &width, int fFrames, double *fGauss, double *fNoise) const
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21
HcalGenericSubdetector genericSubdet() const
const HcalCalibrations & getHcalCalibrations(const HcalGenericDetId &fId) const
void HcalAmplifier::amplify ( CaloSamples linearFrame,
CLHEP::HepRandomEngine *  engine 
) const
virtual

Definition at line 43 of file HcalAmplifier.cc.

References addPedestals(), HPDIonFeedbackSim::addThermalNoise(), CaloVNoiseSignalGenerator::contains(), HcalTimeSlewSim::delay(), CaloSamples::id(), LogDebug, pe2fC(), preMixAdd_, CaloSamples::size(), theIonFeedbackSim, theNoiseSignalGenerator, and theTimeSlewSim.

Referenced by HcalElectronicsSim::convert().

43  {
45  {
46  theIonFeedbackSim->addThermalNoise(frame, engine);
47  }
48  pe2fC(frame);
49  // don't bother for blank signals
50  if(theTimeSlewSim && frame.size()>4 && frame[4] > 1.e-6)
51  {
52  theTimeSlewSim->delay(frame, engine);
53  }
54 
55  // if we are combining pre-mixed digis, we need noise and peds
56  if(theNoiseSignalGenerator==nullptr || preMixAdd_ || !theNoiseSignalGenerator->contains(frame.id()) )
57  {
58  addPedestals(frame, engine);
59  }
60  LogDebug("HcalAmplifier") << frame;
61 }
#define LogDebug(id)
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:50
void addThermalNoise(CaloSamples &samples, CLHEP::HepRandomEngine *)
void delay(CaloSamples &samples, CLHEP::HepRandomEngine *) const
bool contains(const DetId &detId) const
HcalTimeSlewSim * theTimeSlewSim
Definition: HcalAmplifier.h:52
void addPedestals(CaloSamples &frame, CLHEP::HepRandomEngine *) const
void pe2fC(CaloSamples &frame) const
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:51
void HcalAmplifier::makeNoise ( HcalGenericDetId::HcalGenericSubdetector  hcalSubDet,
const HcalCalibrationWidths width,
int  fFrames,
double *  fGauss,
double *  fNoise 
) const
private

Definition at line 104 of file HcalAmplifier.cc.

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

Referenced by addPedestals().

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

Definition at line 64 of file HcalAmplifier.cc.

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

Referenced by amplify().

65 {
67  frame *= parameters.photoelectronsToAnalog(frame.id());
68 }
const CaloVSimParameterMap * theParameterMap
Definition: HcalAmplifier.h:49
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::setDbService ( const HcalDbService service)

the Producer will probably update this every event

Definition at line 37 of file HcalAmplifier.cc.

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

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

37  {
38  theDbService = service;
40 }
const HcalDbService * theDbService
Definition: HcalAmplifier.h:48
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:51
void setDbService(const HcalDbService *service)
void HcalAmplifier::setIonFeedbackSim ( HPDIonFeedbackSim feedbackSim)
inline

Definition at line 27 of file HcalAmplifier.h.

Referenced by HcalDigitizer::HcalDigitizer().

27 {theIonFeedbackSim = feedbackSim;}
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:51
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 31 of file HcalAmplifier.h.

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

31  {
32  theNoiseSignalGenerator = noiseSignalGenerator;
33  }
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:50
void HcalAmplifier::setStartingCapId ( int  capId)
inline

Definition at line 40 of file HcalAmplifier.h.

References ApeEstimator_cff::width.

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

40 {theStartingCapId = capId;}
unsigned theStartingCapId
Definition: HcalAmplifier.h:53
void HcalAmplifier::setTimeSlewSim ( HcalTimeSlewSim timeSlewSim)
inline

Definition at line 34 of file HcalAmplifier.h.

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

34  {
35  theTimeSlewSim = timeSlewSim;
36  }
HcalTimeSlewSim * theTimeSlewSim
Definition: HcalAmplifier.h:52

Member Data Documentation

bool HcalAmplifier::addNoise_
private

Definition at line 54 of file HcalAmplifier.h.

Referenced by addPedestals().

bool HcalAmplifier::preMixAdd_
private

Definition at line 56 of file HcalAmplifier.h.

Referenced by amplify().

bool HcalAmplifier::preMixDigi_
private

Definition at line 55 of file HcalAmplifier.h.

Referenced by addPedestals().

const HcalDbService* HcalAmplifier::theDbService
private

Definition at line 48 of file HcalAmplifier.h.

Referenced by addPedestals(), and setDbService().

HPDIonFeedbackSim* HcalAmplifier::theIonFeedbackSim
private

Definition at line 51 of file HcalAmplifier.h.

Referenced by amplify(), and setDbService().

const CaloVNoiseSignalGenerator* HcalAmplifier::theNoiseSignalGenerator
private

Definition at line 50 of file HcalAmplifier.h.

Referenced by amplify().

const CaloVSimParameterMap* HcalAmplifier::theParameterMap
private

Definition at line 49 of file HcalAmplifier.h.

Referenced by pe2fC().

unsigned HcalAmplifier::theStartingCapId
private

Definition at line 53 of file HcalAmplifier.h.

Referenced by addPedestals().

HcalTimeSlewSim* HcalAmplifier::theTimeSlewSim
private

Definition at line 52 of file HcalAmplifier.h.

Referenced by amplify().