CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 applyQIEdelay (CaloSamples &frame, int delayQIE) 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 ( const CaloVSimParameterMap parameters,
bool  addNoise,
bool  PreMix1,
bool  PreMix2 
)

Definition at line 24 of file HcalAmplifier.cc.

25  : theDbService(nullptr),
26  theParameterMap(parameters),
27  theNoiseSignalGenerator(nullptr),
28  theIonFeedbackSim(nullptr),
29  theTimeSlewSim(nullptr),
32  preMixDigi_(PreMix1),
33  preMixAdd_(PreMix2) {}
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:56
const CaloVSimParameterMap * theParameterMap
Definition: HcalAmplifier.h:55
const HcalDbService * theDbService
Definition: HcalAmplifier.h:54
HcalTimeSlewSim * theTimeSlewSim
Definition: HcalAmplifier.h:58
unsigned theStartingCapId
Definition: HcalAmplifier.h:59
const bool addNoise
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:57
virtual HcalAmplifier::~HcalAmplifier ( )
inlinevirtual

Definition at line 24 of file HcalAmplifier.h.

24 {}

Member Function Documentation

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

Definition at line 92 of file HcalAmplifier.cc.

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

Referenced by amplify().

92  {
93  assert(theDbService != nullptr);
94  HcalGenericDetId hcalGenDetId(frame.id());
95  HcalGenericDetId::HcalGenericSubdetector hcalSubDet = hcalGenDetId.genericSubdet();
96 
97  if (!((frame.id().subdetId() == HcalGenericDetId::HcalGenBarrel) ||
101  return;
102 
103  if (hcalGenDetId.isHcalCastorDetId())
104  return;
105  if (hcalGenDetId.isHcalZDCDetId())
106  return;
107 
108  const HcalCalibrationWidths& calibWidths = theDbService->getHcalCalibrationWidths(hcalGenDetId);
109  const HcalCalibrations& calibs = theDbService->getHcalCalibrations(hcalGenDetId);
110 
111  double noise[32] = {0.}; //big enough
112  if (addNoise_) {
113  double gauss[32]; //big enough
114  for (int i = 0; i < frame.size(); i++)
115  gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
116  makeNoise(hcalSubDet, calibWidths, frame.size(), gauss, noise);
117  }
118 
119  if (!preMixDigi_) { // if we are doing initial premix, no pedestals
120  for (int tbin = 0; tbin < frame.size(); ++tbin) {
121  int capId = (theStartingCapId + tbin) % 4;
122  double pedestal = calibs.pedestal(capId) + noise[tbin];
123  frame[tbin] += pedestal;
124  }
125  }
126 }
assert(be >=bs)
const HcalDbService * theDbService
Definition: HcalAmplifier.h:54
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
const HcalCalibrationWidths & getHcalCalibrationWidths(const HcalGenericDetId &fId) const
__shared__ int noise
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
int size() const
get the size
Definition: CaloSamples.h:24
unsigned theStartingCapId
Definition: HcalAmplifier.h:59
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 41 of file HcalAmplifier.cc.

References addPedestals(), HPDIonFeedbackSim::addThermalNoise(), applyQIEdelay(), CaloVNoiseSignalGenerator::contains(), HcalTimeSlewSim::delay(), HcalSimParameters::delayQIE(), DetId::det(), DetId::Hcal, HcalGenericDetId::HcalGenBarrel, HcalGenericDetId::HcalGenEndcap, CaloSamples::id(), LogDebug, submitPVValidationJobs::params, pe2fC(), preMixAdd_, CaloVSimParameterMap::simParameters(), CaloSamples::size(), DetId::subdetId(), theIonFeedbackSim, theNoiseSignalGenerator, theParameterMap, theTimeSlew, and theTimeSlewSim.

Referenced by HcalElectronicsSim::convert().

41  {
42  if (theIonFeedbackSim) {
43  theIonFeedbackSim->addThermalNoise(frame, engine);
44  }
45  pe2fC(frame);
46 
47  if (frame.id().det() == DetId::Hcal && ((frame.id().subdetId() == HcalGenericDetId::HcalGenBarrel) ||
48  (frame.id().subdetId() == HcalGenericDetId::HcalGenEndcap))) {
49  const HcalSimParameters& params = static_cast<const HcalSimParameters&>(theParameterMap->simParameters(frame.id()));
50  if (params.delayQIE() > 0)
51  applyQIEdelay(frame, params.delayQIE());
52  }
53 
54  // don't bother for blank signals
55  if (theTimeSlewSim && frame.size() > 4 && frame[4] > 1.e-6) {
56  theTimeSlewSim->delay(frame, engine, theTimeSlew);
57  }
58 
59  // if we are combining pre-mixed digis, we need noise and peds
60  if (theNoiseSignalGenerator == nullptr || preMixAdd_ || !theNoiseSignalGenerator->contains(frame.id())) {
61  addPedestals(frame, engine);
62  }
63  LogDebug("HcalAmplifier") << frame;
64 }
const CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Definition: HcalAmplifier.h:56
const CaloVSimParameterMap * theParameterMap
Definition: HcalAmplifier.h:55
const HcalTimeSlew * theTimeSlew
Definition: HcalAmplifier.h:37
int delayQIE() const
void addThermalNoise(CaloSamples &samples, CLHEP::HepRandomEngine *)
bool contains(const DetId &detId) const
virtual const CaloSimParameters & simParameters(const DetId &id) const =0
void delay(CaloSamples &samples, CLHEP::HepRandomEngine *, const HcalTimeSlew *hcalTimeSlew_delay) const
HcalTimeSlewSim * theTimeSlewSim
Definition: HcalAmplifier.h:58
void applyQIEdelay(CaloSamples &frame, int delayQIE) const
void addPedestals(CaloSamples &frame, CLHEP::HepRandomEngine *) const
void pe2fC(CaloSamples &frame) const
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:57
#define LogDebug(id)
void HcalAmplifier::applyQIEdelay ( CaloSamples frame,
int  delayQIE 
) const
private

Definition at line 71 of file HcalAmplifier.cc.

References fwrapper::cs, data, mps_fire::i, CaloSamples::id(), CaloSamples::preciseAt(), CaloSamples::preciseAtMod(), CaloSamples::preciseSize(), CaloSamples::resetPrecise(), CaloSamples::setBlank(), and CaloSamples::size().

Referenced by amplify().

71  {
72  DetId detId(cs.id());
73  int maxbin = cs.size();
74  int precisebin = cs.preciseSize();
75  CaloSamples data(detId, maxbin, precisebin); // make a temporary copy
76  data = cs;
77  data.setBlank();
78  data.resetPrecise();
79 
80  for (int i = 0; i < precisebin; i++) {
81  if (i < 2 * delayQIE)
82  data.preciseAtMod(i) += 0.;
83  else
84  data.preciseAtMod(i) += cs.preciseAt(i - 2 * delayQIE);
85  int samplebin = (int)i * maxbin / precisebin;
86  data[samplebin] += data.preciseAt(i);
87  }
88 
89  cs = data; // update the sample
90 }
unique_ptr< ClusterSequence > cs
Definition: DetId.h:17
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
void HcalAmplifier::makeNoise ( HcalGenericDetId::HcalGenericSubdetector  hcalSubDet,
const HcalCalibrationWidths width,
int  fFrames,
double *  fGauss,
double *  fNoise 
) const
private

Definition at line 128 of file HcalAmplifier.cc.

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

Referenced by addPedestals().

132  {
133  // This is a simplified noise generation scheme using only the diagonal elements
134  // (proposed by Salavat Abduline).
135  // This is direct adaptation of the code in HcalPedestalWidth.cc
136 
137  // average over capId's
138  double s_xx_mean = 0.25 * (width.pedestal(0) * width.pedestal(0) + width.pedestal(1) * width.pedestal(1) +
139  width.pedestal(2) * width.pedestal(2) + width.pedestal(3) * width.pedestal(3));
140 
141  // Off-diagonal element approximation
142  // In principle should come from averaging the values of elements (0.1), (1,2), (2,3), (3,0)
143  // For now use the definition below (but keep structure of the code structure for development)
144  double s_xy_mean = -0.5 * s_xx_mean;
145  // Use different parameter for HF to reproduce the noise rate after zero suppression.
146  // Steven Won/Jim Hirschauer/Radek Ofierzynski 18.03.2010
147  if (hcalSubDet == HcalGenericDetId::HcalGenForward)
148  s_xy_mean = 0.08 * s_xx_mean;
149 
150  double term = s_xx_mean * s_xx_mean - 2. * s_xy_mean * s_xy_mean;
151 
152  if (term < 0.)
153  term = 1.e-50;
154  double sigma = sqrt(0.5 * (s_xx_mean + sqrt(term)));
155  double corr = sigma == 0. ? 0. : 0.5 * s_xy_mean / sigma;
156 
157  for (int i = 0; i < fFrames; i++) {
158  fNoise[i] = fGauss[i] * sigma;
159  if (i > 0)
160  fNoise[i] += fGauss[i - 1] * corr;
161  if (i < fFrames - 1)
162  fNoise[i] += fGauss[i + 1] * corr;
163  }
164 }
double pedestal(int fCapId) const
get pedestal width for capid=0..3
T sqrt(T t)
Definition: SSEVec.h:19
void HcalAmplifier::pe2fC ( CaloSamples frame) const
private

Definition at line 66 of file HcalAmplifier.cc.

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

Referenced by amplify().

66  {
68  frame *= parameters.photoelectronsToAnalog(frame.id());
69 }
const CaloVSimParameterMap * theParameterMap
Definition: HcalAmplifier.h:55
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 35 of file HcalAmplifier.cc.

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

Referenced by HcalTBDigiProducer::initializeEvent().

35  {
36  theDbService = service;
39 }
const HcalDbService * theDbService
Definition: HcalAmplifier.h:54
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:57
void setDbService(const HcalDbService *service)
void HcalAmplifier::setIonFeedbackSim ( HPDIonFeedbackSim feedbackSim)
inline

Definition at line 28 of file HcalAmplifier.h.

References theIonFeedbackSim.

28 { theIonFeedbackSim = feedbackSim; }
HPDIonFeedbackSim * theIonFeedbackSim
Definition: HcalAmplifier.h:57
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.

References theNoiseSignalGenerator.

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

Definition at line 42 of file HcalAmplifier.h.

References theStartingCapId.

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

42 { theStartingCapId = capId; }
unsigned theStartingCapId
Definition: HcalAmplifier.h:59
void HcalAmplifier::setTimeSlew ( const HcalTimeSlew timeSlew)
inline

Definition at line 38 of file HcalAmplifier.h.

References theTimeSlew.

Referenced by HcalTBDigiProducer::initializeEvent().

38 { theTimeSlew = timeSlew; }
const HcalTimeSlew * theTimeSlew
Definition: HcalAmplifier.h:37
void HcalAmplifier::setTimeSlewSim ( HcalTimeSlewSim timeSlewSim)
inline

Definition at line 35 of file HcalAmplifier.h.

References theTimeSlewSim.

Referenced by HcalTBDigiProducer::HcalTBDigiProducer().

35 { theTimeSlewSim = timeSlewSim; }
HcalTimeSlewSim * theTimeSlewSim
Definition: HcalAmplifier.h:58

Member Data Documentation

bool HcalAmplifier::addNoise_
private

Definition at line 60 of file HcalAmplifier.h.

Referenced by addPedestals().

bool HcalAmplifier::preMixAdd_
private

Definition at line 62 of file HcalAmplifier.h.

Referenced by amplify().

bool HcalAmplifier::preMixDigi_
private

Definition at line 61 of file HcalAmplifier.h.

Referenced by addPedestals().

const HcalDbService* HcalAmplifier::theDbService
private

Definition at line 54 of file HcalAmplifier.h.

Referenced by addPedestals(), and setDbService().

HPDIonFeedbackSim* HcalAmplifier::theIonFeedbackSim
private

Definition at line 57 of file HcalAmplifier.h.

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

const CaloVNoiseSignalGenerator* HcalAmplifier::theNoiseSignalGenerator
private

Definition at line 56 of file HcalAmplifier.h.

Referenced by amplify(), and setNoiseSignalGenerator().

const CaloVSimParameterMap* HcalAmplifier::theParameterMap
private

Definition at line 55 of file HcalAmplifier.h.

Referenced by amplify(), and pe2fC().

unsigned HcalAmplifier::theStartingCapId
private

Definition at line 59 of file HcalAmplifier.h.

Referenced by addPedestals(), and setStartingCapId().

const HcalTimeSlew* HcalAmplifier::theTimeSlew = nullptr

Definition at line 37 of file HcalAmplifier.h.

Referenced by amplify(), and setTimeSlew().

HcalTimeSlewSim* HcalAmplifier::theTimeSlewSim
private

Definition at line 58 of file HcalAmplifier.h.

Referenced by amplify(), and setTimeSlewSim().