CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CastorAmplifier.cc
Go to the documentation of this file.
11 
12 #include "CLHEP/Random/RandGaussQ.h"
13 
14 #include<iostream>
15 
17  theDbService(nullptr),
18  theParameterMap(parameters),
19  theStartingCapId(0),
20  addNoise_(addNoise)
21 {
22 }
23 
24 void CastorAmplifier::amplify(CaloSamples & frame, CLHEP::HepRandomEngine* engine) const {
26  assert(theDbService != nullptr);
27  HcalGenericDetId hcalGenDetId(frame.id());
28  const CastorPedestal* peds = theDbService->getPedestal(hcalGenDetId);
29  const CastorPedestalWidth* pwidths = theDbService->getPedestalWidth(hcalGenDetId);
30  if (!peds || !pwidths )
31  {
32  edm::LogError("CastorAmplifier") << "Could not fetch HCAL/CASTOR conditions for channel " << hcalGenDetId;
33  }
34  else
35  {
36  double gauss [32]; //big enough
37  double noise [32]; //big enough
38  double fCperPE = parameters.photoelectronsToAnalog(frame.id());
39 
40  for (int i = 0; i < frame.size(); i++) { gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.); }
41  if(addNoise_) {
42  pwidths->makeNoise (frame.size(), gauss, noise);
43  }
44  for(int tbin = 0; tbin < frame.size(); ++tbin) {
45  int capId = (theStartingCapId + tbin)%4;
46  double pedestal = peds->getValue(capId);
47  if(addNoise_) {
48  if (parameters.doDynamicNoise()) {
49  pedestal += noise [tbin]*(fCperPE/parameters.getNominalfCperPE());
50  } else {
51  pedestal += noise [tbin];
52  }
53  }
54  frame[tbin] *= fCperPE;
55  frame[tbin] += pedestal;
56  }
57  }
58  LogDebug("CastorAmplifier") << frame;
59 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
bool doDynamicNoise() const
unsigned theStartingCapId
double getNominalfCperPE() const
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
CastorAmplifier(const CastorSimParameterMap *parameters, bool addNoise)
const CastorSimParameterMap * theParameterMap
assert(m_qm.get())
const CastorDbService * theDbService
#define nullptr
void makeNoise(unsigned fFrames, const double *fGauss, double *fNoise) const
CastorSimParameters castorParameters() const
accessors
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
int size() const
get the size
Definition: CaloSamples.h:24
const CastorPedestalWidth * getPedestalWidth(const HcalGenericDetId &fId) const
virtual double photoelectronsToAnalog(const DetId &detId) const
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21