CMS 3D CMS Logo

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")
33  << "Could not fetch HCAL/CASTOR conditions for channel " << hcalGenDetId;
34  }
35  else
36  {
37  double gauss [32]; //big enough
38  double noise [32]; //big enough
39  double fCperPE = parameters.photoelectronsToAnalog(frame.id());
40 
41  for (int i = 0; i < frame.size(); i++) { gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.); }
42  if(addNoise_) {
43  pwidths->makeNoise (frame.size(), gauss, noise);
44  }
45  for(int tbin = 0; tbin < frame.size(); ++tbin) {
46  int capId = (theStartingCapId + tbin)%4;
47  double pedestal = peds->getValue (capId);
48  if(addNoise_) {
49  pedestal += noise [tbin];
50  }
51  frame[tbin] *= fCperPE;
52  frame[tbin] += pedestal;
53  }
54  }
55  LogDebug("CastorAmplifier") << frame;
56 }
57 
#define LogDebug(id)
unsigned theStartingCapId
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
CastorAmplifier(const CastorSimParameterMap *parameters, bool addNoise)
const CastorSimParameterMap * theParameterMap
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