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(0),
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 != 0);
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 
35  double gauss [32]; //big enough
36  double noise [32]; //big enough
37  double fCperPE = parameters.photoelectronsToAnalog(frame.id());
38 
39  for (int i = 0; i < frame.size(); i++) gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
40  pwidths->makeNoise (frame.size(), gauss, noise);
41  for(int tbin = 0; tbin < frame.size(); ++tbin) {
42  int capId = (theStartingCapId + tbin)%4;
43  double pedestal = peds->getValue (capId);
44  if(addNoise_) {
45  pedestal += noise [tbin];
46  }
47  frame[tbin] *= fCperPE;
48  frame[tbin] += pedestal;
49  }
50  LogDebug("CastorAmplifier") << frame;
51 }
52 
#define LogDebug(id)
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, 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