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 {}
const EcalLiteDTUPedestalsMap * m_peds
static constexpr double maxEneEB
Definition: EcalConstants.h:40
const Noisifier * m_ebCorrNoise[ecalPh2::NGAINS]
const EcalIntercalibConstantsMC * m_intercals

◆ ~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.

References das-up-to-nevents::df, encode(), and CaloTSamplesBase< Ttype >::size().

37  {
38  df.setSize(clf.size());
39  encode(clf, df, engine);
40 }
void encode(const EcalSamples &ecalSamples, EcalDataFrame_Ph2 &df, CLHEP::HepRandomEngine *) const
produce the pulse-shape

◆ 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.

References funct::abs(), gpuClustering::adc, hcalRecHitTable_cff::detId, das-up-to-nevents::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().

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] = {
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 }
static constexpr unsigned int NGAINS
Definition: EcalConstants.h:32
CorrelatedNoisifier< EcalCorrMatrix_Ph2 > Noisifier
void noisify(T &frame, CLHEP::HepRandomEngine *, const VecDou *rangau=nullptr) const
const Noisifier * m_ebCorrNoise[ecalPh2::NGAINS]
double fullScaleEnergy(const DetId &did) const
limit on the energy scale due to the electronics range
T sqrt(T t)
Definition: SSEVec.h:23
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static constexpr const float * gains
Definition: EcalConstants.h:33
Definition: DetId.h:17
void findPedestal(const DetId &detId, int gainId, double &pedestal, double &width) const
void findIntercalibConstant(const DetId &detId, double &icalconst) const
static constexpr unsigned int MAXADC
Definition: EcalConstants.h:38
uint16_t *__restrict__ uint16_t const *__restrict__ adc

◆ 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.

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

Referenced by encode().

165  {
166  EcalIntercalibConstantMC thisconst = 1.;
167  // find intercalib constant for this xtal
168  const EcalIntercalibConstantMCMap& icalMap = m_intercals->getMap();
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 }
const EcalIntercalibConstantsMC * m_intercals
const_iterator find(uint32_t rawId) const
std::vector< Item >::const_iterator const_iterator
const_iterator end() const
float EcalIntercalibConstantMC
#define LogDebug(id)

◆ findPedestal()

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

Definition at line 151 of file EcalLiteDTUCoder.cc.

References hcalRecHitTable_cff::detId, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), ecalLiteDTU::gainId(), EcalCondObjectContainer< T >::getMap(), LogDebug, m_peds, QIE10Task_cfi::ped, and ApeEstimator_cff::width.

Referenced by encode().

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 }
const EcalLiteDTUPedestalsMap * m_peds
const_iterator find(uint32_t rawId) const
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
std::vector< Item >::const_iterator const_iterator
const_iterator end() const
#define LogDebug(id)

◆ 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.

References m_maxEneEB.

Referenced by encode().

33 { return m_maxEneEB; }

◆ setFullScaleEnergy()

void EcalLiteDTUCoder::setFullScaleEnergy ( double  EBscale)

Definition at line 25 of file EcalLiteDTUCoder.cc.

References m_maxEneEB, and ecalPh2::maxEneEB.

static constexpr double maxEneEB
Definition: EcalConstants.h:40

◆ setGainRatios()

void EcalLiteDTUCoder::setGainRatios ( float  gainRatios)

Definition at line 29 of file EcalLiteDTUCoder.cc.

References m_gainRatios.

29 { m_gainRatios = gainRatios; }

◆ setIntercalibConstants()

void EcalLiteDTUCoder::setIntercalibConstants ( const EcalIntercalibConstantsMC ical)

Definition at line 31 of file EcalLiteDTUCoder.cc.

References m_intercals.

31 { m_intercals = ical; }
const EcalIntercalibConstantsMC * 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.

References m_peds.

27 { m_peds = pedestals; }
const EcalLiteDTUPedestalsMap * 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().