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<iostream>
13 
15  theDbService(0),
16  theRandGaussQ(0),
17  theParameterMap(parameters),
18  theStartingCapId(0),
19  addNoise_(addNoise)
20 {
21 }
22 
23 
24 void CastorAmplifier::setRandomEngine(CLHEP::HepRandomEngine & engine)
25 {
26  theRandGaussQ = new CLHEP::RandGaussQ(engine);
27 }
28 
31  assert(theDbService != 0);
32  HcalGenericDetId hcalGenDetId(frame.id());
33  const CastorPedestal* peds = theDbService->getPedestal(hcalGenDetId);
34  const CastorPedestalWidth* pwidths = theDbService->getPedestalWidth(hcalGenDetId);
35  if (!peds || !pwidths )
36  {
37  edm::LogError("CastorAmplifier") << "Could not fetch HCAL/CASTOR conditions for channel " << hcalGenDetId;
38  }
39 
40  double gauss [32]; //big enough
41  double noise [32]; //big enough
42  double fCperPE = parameters.photoelectronsToAnalog(frame.id());
43 
44  for (int i = 0; i < frame.size(); i++) gauss[i] = theRandGaussQ->fire(0., 1.);
45  pwidths->makeNoise (frame.size(), gauss, noise);
46  for(int tbin = 0; tbin < frame.size(); ++tbin) {
47  int capId = (theStartingCapId + tbin)%4;
48  double pedestal = peds->getValue (capId);
49  if(addNoise_) {
50  pedestal += noise [tbin];
51  }
52  frame[tbin] *= fCperPE;
53  frame[tbin] += pedestal;
54  }
55  LogDebug("CastorAmplifier") << frame;
56 }
57 
#define LogDebug(id)
void setRandomEngine(CLHEP::HepRandomEngine &engine)
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
unsigned theStartingCapId
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
CastorAmplifier(const CastorSimParameterMap *parameters, bool addNoise)
const CastorSimParameterMap * theParameterMap
const CastorDbService * theDbService
void makeNoise(unsigned fFrames, const double *fGauss, double *fNoise) const
CastorSimParameters castorParameters() const
accessors
virtual void amplify(CaloSamples &linearFrame) const
int size() const
get the size
Definition: CaloSamples.h:26
const CastorPedestalWidth * getPedestalWidth(const HcalGenericDetId &fId) const
CLHEP::RandGaussQ * theRandGaussQ
virtual double photoelectronsToAnalog(const DetId &detId) const
DetId id() const
get the (generic) id
Definition: CaloSamples.h:23