CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiTrivialDigitalConverter.cc
Go to the documentation of this file.
4 
7  _temp.reserve(800);
8  _tempRaw.reserve(800);
9 }
10 
12 SiTrivialDigitalConverter::convert(const std::vector<double>& analogSignal, edm::ESHandle<SiStripGain> & gainHandle, unsigned int detid){
13 
14  _temp.clear();
15 
16  if(gainHandle.isValid()) {
17  SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
18  for ( size_t i=0; i<analogSignal.size(); i++) {
19  if (analogSignal[i]<=0) continue;
20  // convert analog amplitude to digital
21  int adc = convert( (gainHandle->getStripGain(i, detGainRange))*(analogSignal[i]) );
22  if ( adc > 0) _temp.push_back(SiStripDigi(i, adc));
23  }
24  } else {
25  for ( size_t i=0; i<analogSignal.size(); i++) {
26  if (analogSignal[i]<=0) continue;
27  // convert analog amplitude to digital
28  int adc = convert( analogSignal[i] );
29  if ( adc > 0) _temp.push_back(SiStripDigi(i, adc));
30  }
31  }
32  return _temp;
33 }
34 
36 SiTrivialDigitalConverter::convertRaw(const std::vector<double>& analogSignal, edm::ESHandle<SiStripGain> & gainHandle, unsigned int detid){
37 
38  _tempRaw.clear();
39 
40  if(gainHandle.isValid()) {
41  SiStripApvGain::Range detGainRange = gainHandle->getRange(detid);
42  for ( size_t i=0; i<analogSignal.size(); i++) {
43  if (analogSignal[i]<=0) { _tempRaw.push_back(SiStripRawDigi(0)); continue; }
44  // convert analog amplitude to digital
45  int adc = convertRaw( (gainHandle->getStripGain(i, detGainRange))*(analogSignal[i]));
46  _tempRaw.push_back(SiStripRawDigi(adc));
47  }
48  } else {
49  for ( size_t i=0; i<analogSignal.size(); i++) {
50  if (analogSignal[i]<=0) { _tempRaw.push_back(SiStripRawDigi(0)); continue; }
51  // convert analog amplitude to digital
52  int adc = convertRaw( analogSignal[i] );
53  _tempRaw.push_back(SiStripRawDigi(adc));
54  }
55  }
56  return _tempRaw;
57 }
58 
60  //Rounding the ADC number instead of truncating it
61  int adc = int(in_adc+0.5);
62  /*
63  254 ADC: 254 <= raw charge < 1023
64  255 ADC: raw charge >= 1023
65  */
66  if (adc > 1022 ) return 255;
67  if (adc > 253) return 254;
68  //Protection
69  if (adc < 0) return 0;
70  return adc;
71 }
72 
74  //Rounding the ADC number
75  int adc = int(in_adc+0.5);
76  if (adc > 1023 ) return 1023;
77  //Protection
78  if (adc < 0) return 0;
79  return adc;
80 }
81 
int adc(sample_type sample)
get the ADC sample (12 bits)
std::vector< SiStripDigi > DigitalVecType
int i
Definition: DBlmapReader.cc:9
DigitalVecType convert(const std::vector< double > &, edm::ESHandle< SiStripGain > &, unsigned int detid)
std::vector< SiStripRawDigi > DigitalRawVecType
std::pair< ContainerIterator, ContainerIterator > Range
SiDigitalConverter::DigitalRawVecType _tempRaw
A Digi for the silicon strip detector, containing both strip and adc information, and suitable for st...
Definition: SiStripDigi.h:12
bool isValid() const
Definition: ESHandle.h:37
DigitalRawVecType convertRaw(const std::vector< double > &, edm::ESHandle< SiStripGain > &, unsigned int detid)
A Digi for the silicon strip detector, containing only adc information, and suitable for storing raw ...
SiDigitalConverter::DigitalVecType _temp