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), theParameterMap(parameters), theStartingCapId(0), addNoise_(addNoise) {}
18 
19 void CastorAmplifier::amplify(CaloSamples &frame, CLHEP::HepRandomEngine *engine) const {
21  assert(theDbService != nullptr);
22  HcalGenericDetId hcalGenDetId(frame.id());
23  const CastorPedestal *peds = theDbService->getPedestal(hcalGenDetId);
24  const CastorPedestalWidth *pwidths = theDbService->getPedestalWidth(hcalGenDetId);
25  if (!peds || !pwidths) {
26  edm::LogError("CastorAmplifier") << "Could not fetch HCAL/CASTOR conditions for channel " << hcalGenDetId;
27  } else {
28  double gauss[32]; // big enough
29  double noise[32]; // big enough
30  double fCperPE = parameters.photoelectronsToAnalog(frame.id());
31  double nominalfCperPE = parameters.getNominalfCperPE();
32 
33  for (int i = 0; i < frame.size(); i++) {
34  gauss[i] = CLHEP::RandGaussQ::shoot(engine, 0., 1.);
35  }
36  if (addNoise_) {
37  pwidths->makeNoise(frame.size(), gauss, noise);
38  }
39  for (int tbin = 0; tbin < frame.size(); ++tbin) {
40  int capId = (theStartingCapId + tbin) % 4;
41  double pedestal = peds->getValue(capId);
42  if (addNoise_) {
43  pedestal += noise[tbin] * (fCperPE / nominalfCperPE);
44  }
45  frame[tbin] *= fCperPE;
46  frame[tbin] += pedestal;
47  }
48  }
49  LogDebug("CastorAmplifier") << frame;
50 }
BeamSpotPI::parameters
parameters
Definition: BeamSpotPayloadInspectorHelper.h:30
mps_fire.i
i
Definition: mps_fire.py:428
CastorPedestal.h
MessageLogger.h
HcalGenericDetId
Definition: HcalGenericDetId.h:15
CastorAmplifier::addNoise_
bool addNoise_
Definition: CastorAmplifier.h:30
CaloSamples.h
CastorDbService::getPedestalWidth
const CastorPedestalWidth * getPedestalWidth(const HcalGenericDetId &fId) const
Definition: CastorDbService.cc:148
cms::cuda::assert
assert(be >=bs)
CastorGain.h
CastorPedestal
Definition: CastorPedestal.h:16
CastorPedestalWidth
Definition: CastorPedestalWidth.h:16
CastorPedestalWidth.h
CastorDbService::getPedestal
const CastorPedestal * getPedestal(const HcalGenericDetId &fId) const
Definition: CastorDbService.cc:141
CastorSimParameterMap
Definition: CastorSimParameterMap.h:9
CastorAmplifier::theParameterMap
const CastorSimParameterMap * theParameterMap
Definition: CastorAmplifier.h:27
CastorPedestalWidth::makeNoise
void makeNoise(unsigned fFrames, const double *fGauss, double *fNoise) const
Definition: CastorPedestalWidth.cc:43
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
CastorAmplifier::theStartingCapId
unsigned theStartingCapId
Definition: CastorAmplifier.h:29
HcalDetId.h
CastorSimParameterMap::castorParameters
CastorSimParameters castorParameters() const
accessors
Definition: CastorSimParameterMap.h:22
CastorAmplifier::CastorAmplifier
CastorAmplifier(const CastorSimParameterMap *parameters, bool addNoise)
Definition: CastorAmplifier.cc:16
EcalCondDBWriter_cfi.pedestal
pedestal
Definition: EcalCondDBWriter_cfi.py:49
CaloSamples
Definition: CaloSamples.h:14
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
gpuVertexFinder::noise
__shared__ int noise
Definition: gpuFitVertices.h:50
CastorAmplifier::amplify
virtual void amplify(CaloSamples &linearFrame, CLHEP::HepRandomEngine *) const
Definition: CastorAmplifier.cc:19
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
CastorDbService.h
CastorAmplifier.h
CastorSimParameters.h
CastorSimParameters
Definition: CastorSimParameters.h:8
CastorAmplifier::theDbService
const CastorDbService * theDbService
Definition: CastorAmplifier.h:26
CastorGainWidth.h