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  double nominalfCperPE = parameters.getNominalfCperPE();
41 
42  for (int i = 0; i < frame.size(); i++) { gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.); }
43  if(addNoise_) {
44  pwidths->makeNoise (frame.size(), gauss, noise);
45  }
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]*(fCperPE/nominalfCperPE);
51  }
52  frame[tbin] *= fCperPE;
53  frame[tbin] += pedestal;
54  }
55  }
56  LogDebug("CastorAmplifier") << frame;
57 }
#define LogDebug(id)
unsigned theStartingCapId
double getNominalfCperPE() const
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
CastorAmplifier(const CastorSimParameterMap *parameters, bool addNoise)
const CastorSimParameterMap * theParameterMap
const CastorDbService * theDbService
#define nullptr
double photoelectronsToAnalog(const DetId &detId) const override
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
DetId id() const
get the (generic) id
Definition: CaloSamples.h:21