CMS 3D CMS Logo

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

#include <SiTrivialDigitalConverter.h>

Inheritance diagram for SiTrivialDigitalConverter:
SiDigitalConverter

Public Member Functions

DigitalVecType convert (const std::vector< float > &, edm::ESHandle< SiStripGain > &, unsigned int detid) override
 
DigitalRawVecType convertRaw (const std::vector< float > &, edm::ESHandle< SiStripGain > &, unsigned int detid) override
 
 SiTrivialDigitalConverter (float in, bool PreMix)
 
- Public Member Functions inherited from SiDigitalConverter
virtual ~SiDigitalConverter ()
 

Private Member Functions

int convert (float in)
 
int convertRaw (float in)
 
int truncate (float in_adc) const
 
int truncateRaw (float in_adc) const
 

Private Attributes

SiDigitalConverter::DigitalVecType _temp
 
SiDigitalConverter::DigitalRawVecType _tempRaw
 
const float electronperADC
 
bool PreMixing_
 

Additional Inherited Members

- Public Types inherited from SiDigitalConverter
typedef std::vector< SiStripRawDigiDigitalRawVecType
 
typedef std::vector< SiStripDigiDigitalVecType
 

Detailed Description

Concrete implementation of SiDigitalConverter.

Definition at line 8 of file SiTrivialDigitalConverter.h.

Constructor & Destructor Documentation

◆ SiTrivialDigitalConverter()

SiTrivialDigitalConverter::SiTrivialDigitalConverter ( float  in,
bool  PreMix 
)

Definition at line 5 of file SiTrivialDigitalConverter.cc.

5  : electronperADC(in), PreMixing_(PreMix) {
6  _temp.reserve(800);
7  _tempRaw.reserve(800);
8 }

References _temp, and _tempRaw.

Member Function Documentation

◆ convert() [1/2]

SiDigitalConverter::DigitalVecType SiTrivialDigitalConverter::convert ( const std::vector< float > &  analogSignal,
edm::ESHandle< SiStripGain > &  gainHandle,
unsigned int  detid 
)
overridevirtual

Implements SiDigitalConverter.

Definition at line 10 of file SiTrivialDigitalConverter.cc.

12  {
13  _temp.clear();
14 
15  if (PreMixing_) {
16  for (size_t i = 0; i < analogSignal.size(); i++) {
17  if (analogSignal[i] <= 0)
18  continue;
19  // convert analog amplitude to digital - special algorithm for PreMixing.
20  // Need to keep all hits, including those at very low pulse heights.
21  int adc = truncate(sqrt(9.0 * analogSignal[i]));
22  if (adc > 0)
23  _temp.push_back(SiStripDigi(i, adc));
24  }
25  } else if (gainHandle.isValid()) {
26  SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
27  for (size_t i = 0; i < analogSignal.size(); i++) {
28  if (analogSignal[i] <= 0)
29  continue;
30  // convert analog amplitude to digital
31  int adc = convert((gainHandle->getStripGain(i, detGainRange)) * (analogSignal[i]));
32  if (adc > 0)
33  _temp.push_back(SiStripDigi(i, adc));
34  }
35  } else {
36  for (size_t i = 0; i < analogSignal.size(); i++) {
37  if (analogSignal[i] <= 0)
38  continue;
39  // convert analog amplitude to digital
40  int adc = convert(analogSignal[i]);
41  if (adc > 0)
42  _temp.push_back(SiStripDigi(i, adc));
43  }
44  }
45  return _temp;
46 }

References _temp, ecalMGPA::adc(), SiStripGain::getRange(), SiStripGain::getStripGain(), mps_fire::i, edm::ESHandleBase::isValid(), PreMixing_, mathSSE::sqrt(), and truncate().

Referenced by DigiSimLinkAlgorithm::run().

◆ convert() [2/2]

int SiTrivialDigitalConverter::convert ( float  in)
inlineprivate

Definition at line 16 of file SiTrivialDigitalConverter.h.

16 { return truncate(in / electronperADC); }

References electronperADC, recoMuon::in, and truncate().

◆ convertRaw() [1/2]

SiDigitalConverter::DigitalRawVecType SiTrivialDigitalConverter::convertRaw ( const std::vector< float > &  analogSignal,
edm::ESHandle< SiStripGain > &  gainHandle,
unsigned int  detid 
)
overridevirtual

Implements SiDigitalConverter.

Definition at line 48 of file SiTrivialDigitalConverter.cc.

50  {
51  _tempRaw.clear();
52 
53  if (gainHandle.isValid()) {
54  SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
55  for (size_t i = 0; i < analogSignal.size(); i++) {
56  if (analogSignal[i] <= 0) {
57  _tempRaw.push_back(SiStripRawDigi(0));
58  continue;
59  }
60  // convert analog amplitude to digital
61  int adc = convertRaw((gainHandle->getStripGain(i, detGainRange)) * (analogSignal[i]));
62  _tempRaw.push_back(SiStripRawDigi(adc));
63  }
64  } else {
65  for (size_t i = 0; i < analogSignal.size(); i++) {
66  if (analogSignal[i] <= 0) {
67  _tempRaw.push_back(SiStripRawDigi(0));
68  continue;
69  }
70  // convert analog amplitude to digital
71  int adc = convertRaw(analogSignal[i]);
72  _tempRaw.push_back(SiStripRawDigi(adc));
73  }
74  }
75  return _tempRaw;
76 }

References _tempRaw, ecalMGPA::adc(), SiStripGain::getRange(), SiStripGain::getStripGain(), mps_fire::i, and edm::ESHandleBase::isValid().

Referenced by DigiSimLinkAlgorithm::run().

◆ convertRaw() [2/2]

int SiTrivialDigitalConverter::convertRaw ( float  in)
inlineprivate

Definition at line 17 of file SiTrivialDigitalConverter.h.

17 { return truncateRaw(in / electronperADC); }

References electronperADC, recoMuon::in, and truncateRaw().

◆ truncate()

int SiTrivialDigitalConverter::truncate ( float  in_adc) const
private

Definition at line 78 of file SiTrivialDigitalConverter.cc.

78  {
79  //Rounding the ADC number instead of truncating it
80  int adc = int(in_adc + 0.5);
81  /*
82  254 ADC: 254 <= raw charge < 1023
83  255 ADC: raw charge >= 1023
84  */
85  if (PreMixing_) {
86  if (adc > 2047)
87  return 1023;
88  if (adc > 1022)
89  return 1022;
90  } else {
91  if (adc > 1022)
92  return 255;
93  if (adc > 253)
94  return 254;
95  }
96  //Protection
97  if (adc < 0)
98  return 0;
99  return adc;
100 }

References ecalMGPA::adc(), createfilelist::int, and PreMixing_.

Referenced by convert().

◆ truncateRaw()

int SiTrivialDigitalConverter::truncateRaw ( float  in_adc) const
private

Definition at line 102 of file SiTrivialDigitalConverter.cc.

102  {
103  //Rounding the ADC number
104  int adc = int(in_adc + 0.5);
105  if (adc > 1023)
106  return 1023;
107  //Protection
108  if (adc < 0)
109  return 0;
110  return adc;
111 }

References ecalMGPA::adc(), and createfilelist::int.

Referenced by convertRaw().

Member Data Documentation

◆ _temp

SiDigitalConverter::DigitalVecType SiTrivialDigitalConverter::_temp
private

Definition at line 22 of file SiTrivialDigitalConverter.h.

Referenced by convert(), and SiTrivialDigitalConverter().

◆ _tempRaw

SiDigitalConverter::DigitalRawVecType SiTrivialDigitalConverter::_tempRaw
private

Definition at line 23 of file SiTrivialDigitalConverter.h.

Referenced by convertRaw(), and SiTrivialDigitalConverter().

◆ electronperADC

const float SiTrivialDigitalConverter::electronperADC
private

Definition at line 21 of file SiTrivialDigitalConverter.h.

Referenced by convert(), and convertRaw().

◆ PreMixing_

bool SiTrivialDigitalConverter::PreMixing_
private

Definition at line 24 of file SiTrivialDigitalConverter.h.

Referenced by convert(), and truncate().

ecalMGPA::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:11
SiTrivialDigitalConverter::electronperADC
const float electronperADC
Definition: SiTrivialDigitalConverter.h:21
mps_fire.i
i
Definition: mps_fire.py:355
SiTrivialDigitalConverter::convertRaw
DigitalRawVecType convertRaw(const std::vector< float > &, edm::ESHandle< SiStripGain > &, unsigned int detid) override
Definition: SiTrivialDigitalConverter.cc:48
SiStripGain::getStripGain
static float getStripGain(const uint16_t &strip, const SiStripApvGain::Range &range)
Definition: SiStripGain.h:73
SiStripRawDigi
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
Definition: SiStripRawDigi.h:15
SiTrivialDigitalConverter::_temp
SiDigitalConverter::DigitalVecType _temp
Definition: SiTrivialDigitalConverter.h:22
SiStripGain::getRange
const SiStripApvGain::Range getRange(uint32_t detID) const
Definition: SiStripGain.h:71
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
recoMuon::in
Definition: RecoMuonEnumerators.h:6
createfilelist.int
int
Definition: createfilelist.py:10
SiTrivialDigitalConverter::truncateRaw
int truncateRaw(float in_adc) const
Definition: SiTrivialDigitalConverter.cc:102
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
SiTrivialDigitalConverter::convert
DigitalVecType convert(const std::vector< float > &, edm::ESHandle< SiStripGain > &, unsigned int detid) override
Definition: SiTrivialDigitalConverter.cc:10
SiTrivialDigitalConverter::truncate
int truncate(float in_adc) const
Definition: SiTrivialDigitalConverter.cc:78
SiStripApvGain::Range
std::pair< ContainerIterator, ContainerIterator > Range
Definition: SiStripApvGain.h:28
SiStripDigi
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
SiTrivialDigitalConverter::PreMixing_
bool PreMixing_
Definition: SiTrivialDigitalConverter.h:24
SiTrivialDigitalConverter::_tempRaw
SiDigitalConverter::DigitalRawVecType _tempRaw
Definition: SiTrivialDigitalConverter.h:23