CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
EcalLiteDTUCoder Class Reference

#include <EcalLiteDTUCoder.h>

Public Types

typedef CaloTSamples< float, ecalPh2::sampleSizeEcalSamples
 
typedef CorrelatedNoisifier< EcalCorrMatrix_Ph2Noisifier
 

Public Member Functions

virtual void analogToDigital (CLHEP::HepRandomEngine *, const EcalSamples &clf, EcalDataFrame_Ph2 &df) const
 from EcalSamples to EcalDataFrame_Ph2 More...
 
 EcalLiteDTUCoder (bool addNoise, bool PreMix1, Noisifier *ebCorrNoise0, Noisifier *ebCorrNoise1=nullptr)
 ctor More...
 
void setFullScaleEnergy (double EBscale)
 
void setGainRatios (float gainRatios)
 
void setIntercalibConstants (const EcalIntercalibConstantsMC *ical)
 
void setPedestals (const EcalLiteDTUPedestalsMap *pedestals)
 can be fetched every event from the EventSetup More...
 
virtual ~EcalLiteDTUCoder ()
 dtor More...
 

Private Member Functions

void encode (const EcalSamples &ecalSamples, EcalDataFrame_Ph2 &df, CLHEP::HepRandomEngine *) const
 produce the pulse-shape More...
 
void findGains (const DetId &detId, float theGains[]) const
 
void findIntercalibConstant (const DetId &detId, double &icalconst) const
 
void findPedestal (const DetId &detId, int gainId, double &pedestal, double &width) const
 
double fullScaleEnergy (const DetId &did) const
 limit on the energy scale due to the electronics range More...
 

Private Attributes

bool m_addNoise
 
const Noisifierm_ebCorrNoise [ecalPh2::NGAINS]
 
float m_gainRatios
 
const EcalIntercalibConstantsMCm_intercals
 
double m_maxEneEB
 
const EcalLiteDTUPedestalsMapm_peds
 
bool m_PreMix1
 

Detailed Description

Definition at line 24 of file EcalLiteDTUCoder.h.

Member Typedef Documentation

◆ EcalSamples

Definition at line 26 of file EcalLiteDTUCoder.h.

◆ Noisifier

Definition at line 28 of file EcalLiteDTUCoder.h.

Constructor & Destructor Documentation

◆ EcalLiteDTUCoder()

EcalLiteDTUCoder::EcalLiteDTUCoder ( bool  addNoise,
bool  PreMix1,
EcalLiteDTUCoder::Noisifier ebCorrNoise0,
EcalLiteDTUCoder::Noisifier ebCorrNoise1 = nullptr 
)

ctor

Definition at line 9 of file EcalLiteDTUCoder.cc.

13  : m_peds(nullptr),
14  m_gainRatios(0),
15  m_intercals(nullptr),
16  m_maxEneEB(ecalPh2::maxEneEB), // Maximum for CATIA: LSB gain 10: 0.048 MeV
17  m_addNoise(addNoise),
18  m_PreMix1(PreMix1),
19  m_ebCorrNoise{ebCorrNoise0, ebCorrNoise1}
20 
21 {}

◆ ~EcalLiteDTUCoder()

EcalLiteDTUCoder::~EcalLiteDTUCoder ( )
virtual

dtor

Definition at line 23 of file EcalLiteDTUCoder.cc.

23 {}

Member Function Documentation

◆ analogToDigital()

void EcalLiteDTUCoder::analogToDigital ( CLHEP::HepRandomEngine *  engine,
const EcalSamples clf,
EcalDataFrame_Ph2 df 
) const
virtual

from EcalSamples to EcalDataFrame_Ph2

Definition at line 35 of file EcalLiteDTUCoder.cc.

37  {
38  df.setSize(clf.size());
39  encode(clf, df, engine);
40 }

References hgcalPerformanceValidation::df, encode(), and CaloTSamplesBase< Ttype >::size().

◆ encode()

void EcalLiteDTUCoder::encode ( const EcalSamples ecalSamples,
EcalDataFrame_Ph2 df,
CLHEP::HepRandomEngine *  engine 
) const
private

produce the pulse-shape

Definition at line 42 of file EcalLiteDTUCoder.cc.

44  {
45  const int nSamples(ecalSamples.size());
46 
47  DetId detId = ecalSamples.id();
48  double Emax = fullScaleEnergy(detId);
49 
50  //N Gains set to 2 in the .h
51  double pedestals[ecalPh2::NGAINS];
52  double widths[ecalPh2::NGAINS];
53  double LSB[ecalPh2::NGAINS];
54  double trueRMS[ecalPh2::NGAINS];
55  int nSaturatedSamples = 0;
56  double icalconst = 1.;
57  findIntercalibConstant(detId, icalconst);
58 
59  for (unsigned int igain(0); igain < ecalPh2::NGAINS; ++igain) {
60  // fill in the pedestal and width
61  findPedestal(detId, igain, pedestals[igain], widths[igain]);
62  // insert an absolute value in the trueRMS
63  trueRMS[igain] = std::sqrt(std::abs(widths[igain] * widths[igain] - 1. / 12.));
64 
65  LSB[igain] = Emax / (ecalPh2::MAXADC * ecalPh2::gains[igain]);
66  }
67 
68  CaloSamples noiseframe[ecalPh2::NGAINS] = {
69  CaloSamples(detId, nSamples),
70  CaloSamples(detId, nSamples),
71  };
72 
73  const Noisifier* noisy[ecalPh2::NGAINS] = {m_ebCorrNoise[0], m_ebCorrNoise[1]};
74 
75  if (m_addNoise) {
76  for (unsigned int ig = 0; ig < ecalPh2::NGAINS; ++ig) {
77  noisy[ig]->noisify(noiseframe[ig], engine);
78  }
79  }
80 
81  std::vector<std::vector<int>> adctrace(nSamples);
82  int firstSaturatedSample[ecalPh2::NGAINS] = {0, 0};
83 
84  for (int i(0); i != nSamples; ++i)
85  adctrace[i].resize(ecalPh2::NGAINS);
86 
87  for (unsigned int igain = 0; igain < ecalPh2::NGAINS; ++igain) {
88  for (int i(0); i != nSamples; ++i) {
89  adctrace[i][igain] = -1;
90  }
91  }
92 
93  // fill ADC trace in gain 0 (x10) and gain 1 (x1)
94  for (unsigned int igain = 0; igain < ecalPh2::NGAINS; ++igain) {
95  for (int i(0); i != nSamples; ++i) {
96  double asignal = 0;
97  if (!m_PreMix1) {
98  asignal = pedestals[igain] + ecalSamples[i] / (LSB[igain] * icalconst) + trueRMS[igain] * noiseframe[igain][i];
99  //Analog signal value for each sample in ADC.
100  //It is corrected by the intercalibration constants
101 
102  } else {
103  // no noise nor pedestal when premixing
104  asignal = ecalSamples[i] / (LSB[igain] * icalconst);
105  }
106  int isignal = asignal;
107 
108  unsigned int adc = asignal - (double)isignal < 0.5 ? isignal : isignal + 1;
109  // gain 0 (x10) channel is saturated, readout will use gain 1 (x10), but I count the number of saturated samples
110  if (adc > ecalPh2::MAXADC) {
112  if (nSaturatedSamples == 0)
113  firstSaturatedSample[igain] = i;
114  nSaturatedSamples++;
115  }
116  adctrace[i][igain] = adc;
117  }
118  if (nSaturatedSamples == 0) {
119  break; // gain 0 (x10) is not saturated, so don't bother with gain 1
120  }
121  } // for igain
122 
123  int igain = 0;
124 
125  //Limits of gain 1:
126  //The Lite DTU sends 5 samples before the saturating one, and 10 after with gain 1.
127  //we put the maximum in bin 5, but could happen that the system saturates before.
128 
129  int previousSaturatedSamples = 5;
130  int nextSaturatedSamples = 10;
131  int startingLowerGainSample = 0;
132  int endingLowerGainSample = (firstSaturatedSample[0] + nextSaturatedSamples + (nSaturatedSamples));
133 
134  if (nSaturatedSamples != 0 and (firstSaturatedSample[0] - previousSaturatedSamples) < 0) {
135  startingLowerGainSample = 0;
136  } else {
137  startingLowerGainSample = (firstSaturatedSample[0] - previousSaturatedSamples);
138  }
139 
140  //Setting values to the samples:
141  for (int j = 0; j < nSamples; ++j) {
142  if (nSaturatedSamples != 0 and j >= startingLowerGainSample and j < endingLowerGainSample) {
143  igain = 1;
144  } else {
145  igain = 0;
146  }
147  df.setSample(j, EcalLiteDTUSample(adctrace[j][igain], igain));
148  }
149 }

References funct::abs(), ecalLiteDTU::adc(), hgcalPerformanceValidation::df, findIntercalibConstant(), findPedestal(), fullScaleEnergy(), ecalPh2::gains, mps_fire::i, CaloTSamplesBase< Ttype >::id(), dqmiolumiharvest::j, m_addNoise, m_ebCorrNoise, m_PreMix1, ecalPh2::MAXADC, ecalPh2::NGAINS, CorrelatedNoisifier< M >::noisify(), PresampleTask_cfi::nSamples, CaloTSamplesBase< Ttype >::size(), and mathSSE::sqrt().

Referenced by analogToDigital().

◆ findGains()

void EcalLiteDTUCoder::findGains ( const DetId detId,
float  theGains[] 
) const
private

◆ findIntercalibConstant()

void EcalLiteDTUCoder::findIntercalibConstant ( const DetId detId,
double &  icalconst 
) const
private

Definition at line 165 of file EcalLiteDTUCoder.cc.

165  {
166  EcalIntercalibConstantMC thisconst = 1.;
167  // find intercalib constant for this xtal
168  const EcalIntercalibConstantMCMap& icalMap = m_intercals->getMap();
169  EcalIntercalibConstantMCMap::const_iterator icalit = icalMap.find(detId);
170  if (icalit != icalMap.end()) {
171  thisconst = (*icalit);
172  } else {
173  LogDebug("EcalLiteDTUCoder") << "Intercalib Constant not found, put default value \n";
174  thisconst = 1.;
175  }
176 
177  if (icalconst == 0.)
178  thisconst = 1.;
179 
180  icalconst = thisconst;
181 }

References EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), EcalCondObjectContainer< T >::getMap(), LogDebug, and m_intercals.

Referenced by encode().

◆ findPedestal()

void EcalLiteDTUCoder::findPedestal ( const DetId detId,
int  gainId,
double &  pedestal,
double &  width 
) const
private

Definition at line 151 of file EcalLiteDTUCoder.cc.

151  {
153  if (itped != m_peds->getMap().end()) {
154  ped = (*itped).mean(gainId);
155  width = (*itped).rms(gainId);
156  LogDebug("EcalLiteDTUCoder") << "Pedestals for " << detId.rawId() << " gain range " << gainId << " : \n"
157  << "Mean = " << ped << " rms = " << width;
158  } else {
159  LogDebug("EcalLiteDTUCoder") << "Pedestals not found, put default values (ped: 12; width: 2.5) \n";
160  ped = 12.;
161  width = 2.5;
162  }
163 }

References EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), ecalLiteDTU::gainId(), EcalCondObjectContainer< T >::getMap(), LogDebug, m_peds, DetId::rawId(), and ApeEstimator_cff::width.

Referenced by encode().

◆ fullScaleEnergy()

double EcalLiteDTUCoder::fullScaleEnergy ( const DetId did) const
private

limit on the energy scale due to the electronics range

Definition at line 33 of file EcalLiteDTUCoder.cc.

33 { return m_maxEneEB; }

References m_maxEneEB.

Referenced by encode().

◆ setFullScaleEnergy()

void EcalLiteDTUCoder::setFullScaleEnergy ( double  EBscale)

Definition at line 25 of file EcalLiteDTUCoder.cc.

References m_maxEneEB, and ecalPh2::maxEneEB.

◆ setGainRatios()

void EcalLiteDTUCoder::setGainRatios ( float  gainRatios)

Definition at line 29 of file EcalLiteDTUCoder.cc.

29 { m_gainRatios = gainRatios; }

References m_gainRatios.

◆ setIntercalibConstants()

void EcalLiteDTUCoder::setIntercalibConstants ( const EcalIntercalibConstantsMC ical)

Definition at line 31 of file EcalLiteDTUCoder.cc.

31 { m_intercals = ical; }

References m_intercals.

◆ setPedestals()

void EcalLiteDTUCoder::setPedestals ( const EcalLiteDTUPedestalsMap pedestals)

can be fetched every event from the EventSetup

Definition at line 27 of file EcalLiteDTUCoder.cc.

27 { m_peds = pedestals; }

References m_peds.

Member Data Documentation

◆ m_addNoise

bool EcalLiteDTUCoder::m_addNoise
private

Definition at line 69 of file EcalLiteDTUCoder.h.

Referenced by encode().

◆ m_ebCorrNoise

const Noisifier* EcalLiteDTUCoder::m_ebCorrNoise[ecalPh2::NGAINS]
private

Definition at line 72 of file EcalLiteDTUCoder.h.

Referenced by encode().

◆ m_gainRatios

float EcalLiteDTUCoder::m_gainRatios
private

Definition at line 63 of file EcalLiteDTUCoder.h.

Referenced by setGainRatios().

◆ m_intercals

const EcalIntercalibConstantsMC* EcalLiteDTUCoder::m_intercals
private

Definition at line 65 of file EcalLiteDTUCoder.h.

Referenced by findIntercalibConstant(), and setIntercalibConstants().

◆ m_maxEneEB

double EcalLiteDTUCoder::m_maxEneEB
private

Definition at line 67 of file EcalLiteDTUCoder.h.

Referenced by fullScaleEnergy(), and setFullScaleEnergy().

◆ m_peds

const EcalLiteDTUPedestalsMap* EcalLiteDTUCoder::m_peds
private

Definition at line 61 of file EcalLiteDTUCoder.h.

Referenced by findPedestal(), and setPedestals().

◆ m_PreMix1

bool EcalLiteDTUCoder::m_PreMix1
private

Definition at line 70 of file EcalLiteDTUCoder.h.

Referenced by encode().

EcalCondObjectContainer::getMap
const self & getMap() const
Definition: EcalCondObjectContainer.h:80
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:76
ecalLiteDTU::gainId
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
Definition: EcalLiteDTUSample.h:14
ApeEstimator_cff.width
width
Definition: ApeEstimator_cff.py:24
mps_fire.i
i
Definition: mps_fire.py:428
EcalLiteDTUCoder::findIntercalibConstant
void findIntercalibConstant(const DetId &detId, double &icalconst) const
Definition: EcalLiteDTUCoder.cc:165
EcalLiteDTUCoder::fullScaleEnergy
double fullScaleEnergy(const DetId &did) const
limit on the energy scale due to the electronics range
Definition: EcalLiteDTUCoder.cc:33
ecalPh2::MAXADC
static constexpr unsigned int MAXADC
Definition: EcalConstants.h:14
EcalLiteDTUCoder::m_intercals
const EcalIntercalibConstantsMC * m_intercals
Definition: EcalLiteDTUCoder.h:65
EcalLiteDTUCoder::m_gainRatios
float m_gainRatios
Definition: EcalLiteDTUCoder.h:63
EcalLiteDTUCoder::m_PreMix1
bool m_PreMix1
Definition: EcalLiteDTUCoder.h:70
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
PresampleTask_cfi.nSamples
nSamples
Definition: PresampleTask_cfi.py:7
ecalLiteDTU::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalLiteDTUSample.h:12
EcalLiteDTUCoder::findPedestal
void findPedestal(const DetId &detId, int gainId, double &pedestal, double &width) const
Definition: EcalLiteDTUCoder.cc:151
DetId
Definition: DetId.h:17
EcalLiteDTUCoder::m_addNoise
bool m_addNoise
Definition: EcalLiteDTUCoder.h:69
CorrelatedNoisifier::noisify
void noisify(T &frame, CLHEP::HepRandomEngine *, const VecDou *rangau=nullptr) const
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
EcalLiteDTUCoder::m_maxEneEB
double m_maxEneEB
Definition: EcalLiteDTUCoder.h:67
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
EcalLiteDTUSample
Definition: EcalLiteDTUSample.h:25
EcalLiteDTUCoder::m_peds
const EcalLiteDTUPedestalsMap * m_peds
Definition: EcalLiteDTUCoder.h:61
CaloSamples
Definition: CaloSamples.h:14
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
EcalLiteDTUCoder::Noisifier
CorrelatedNoisifier< EcalCorrMatrix_Ph2 > Noisifier
Definition: EcalLiteDTUCoder.h:28
EcalIntercalibConstantMC
float EcalIntercalibConstantMC
Definition: EcalIntercalibConstantsMC.h:10
hgcalPerformanceValidation.df
df
Definition: hgcalPerformanceValidation.py:640
EcalLiteDTUCoder::encode
void encode(const EcalSamples &ecalSamples, EcalDataFrame_Ph2 &df, CLHEP::HepRandomEngine *) const
produce the pulse-shape
Definition: EcalLiteDTUCoder.cc:42
ecalPh2::gains
static constexpr float gains[NGAINS]
Definition: EcalConstants.h:9
EcalLiteDTUCoder::m_ebCorrNoise
const Noisifier * m_ebCorrNoise[ecalPh2::NGAINS]
Definition: EcalLiteDTUCoder.h:72
EcalCondObjectContainer::const_iterator
std::vector< Item >::const_iterator const_iterator
Definition: EcalCondObjectContainer.h:19
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ecalPh2::maxEneEB
static constexpr double maxEneEB
Definition: EcalConstants.h:16
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
ecalPh2::NGAINS
static constexpr unsigned int NGAINS
Definition: EcalConstants.h:8