SimCalorimetry
CastorSim
src
CastorAmplifier.cc
Go to the documentation of this file.
1
#include "
CalibFormats/CaloObjects/interface/CaloSamples.h
"
2
#include "
CalibFormats/CastorObjects/interface/CastorDbService.h
"
3
#include "
CondFormats/CastorObjects/interface/CastorGain.h
"
4
#include "
CondFormats/CastorObjects/interface/CastorGainWidth.h
"
5
#include "
CondFormats/CastorObjects/interface/CastorPedestal.h
"
6
#include "
CondFormats/CastorObjects/interface/CastorPedestalWidth.h
"
7
#include "
DataFormats/HcalDetId/interface/HcalDetId.h
"
8
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
9
#include "
SimCalorimetry/CastorSim/src/CastorAmplifier.h
"
10
#include "
SimCalorimetry/CastorSim/src/CastorSimParameters.h
"
11
12
#include "CLHEP/Random/RandGaussQ.h"
13
14
#include <iostream>
15
16
CastorAmplifier::CastorAmplifier
(
const
CastorSimParameterMap
*
parameters
,
bool
addNoise)
17
: theDbService(nullptr), theParameterMap(
parameters
), theStartingCapId(0), addNoise_(addNoise) {}
18
19
void
CastorAmplifier::amplify
(
CaloSamples
&
frame
, CLHEP::HepRandomEngine *engine)
const
{
20
const
CastorSimParameters
&
parameters
=
theParameterMap
->
castorParameters
();
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
}
mps_fire.i
i
Definition:
mps_fire.py:355
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
parameters
parameters
Definition:
BeamSpot_PayloadInspector.cc:14
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:670
edm::LogError
Definition:
MessageLogger.h:183
CastorAmplifier::theStartingCapId
unsigned theStartingCapId
Definition:
CastorAmplifier.h:29
HcalDetId.h
hgcalDigitizer_cfi.noise
noise
Definition:
hgcalDigitizer_cfi.py:150
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
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
Generated for CMSSW Reference Manual by
1.8.16