CMS 3D CMS Logo

HcalSignalGenerator.cc
Go to the documentation of this file.
2 
3 //specializations
4 
5 template<>
7 {
8  int DigiSum = 0;
9  for(int id = 0; id<digi.samples(); id++) {
10  if(digi[id].adc() > 0) ++DigiSum;
11  }
12  return(DigiSum>0);
13 }
14 
15 template<>
17  HcalDetId cell = digi.id();
18  CaloSamples result = CaloSamples(cell,digi.samples());
19 
20  // first, check if there was an overflow in this fake digi:
21  bool overflow = false;
22  // find and list them
23 
24  for(int isample=0; isample<digi.samples(); ++isample) {
25  //only check error bit for non-zero ADCs
26  if(digi[isample].adc()>0 && !digi[isample].ok()) overflow = true;
27  }
28 
29  if(overflow) { // do full conversion, go back and overwrite fake entries
30  const HcalQIECoder* channelCoder = theConditions->getHcalCoder (cell);
31  const HcalQIEShape* channelShape = theConditions->getHcalShape (cell);
32  HcalCoderDb coder (*channelCoder, *channelShape);
33  coder.adc2fC(digi, result);
34 
35  // overwrite with coded information
36  for(int isample=0; isample<digi.samples(); ++isample) {
37  if(digi[isample].ok()) result[isample] = float(digi[isample].adc())/HcalQIE10DigitizerTraits::PreMixFactor;
38  }
39  }
40  else { // saves creating the coder, etc., every time
41  // use coded information
42  for(int isample=0; isample<digi.samples(); ++isample) {
43  result[isample] = float(digi[isample].adc())/HcalQIE10DigitizerTraits::PreMixFactor;
44  if(digi[isample].soi()) result.setPresamples(isample);
45  }
46  }
47 
48  // translation done in fC, convert to pe:
49  fC2pe(result);
50 
51  return result;
52 }
53 
54 template<>
56  // loop over digis, adding these to the existing maps
57  for(typename COLLECTION::const_iterator it = digis->begin(); it != digis->end(); ++it)
58  {
59  QIE10DataFrame df(*it);
60  // for the first signal, set the starting cap id
61  if((it == digis->begin()) && theElectronicsSim)
62  {
63  int startingCapId = df[0].capid();
64  theElectronicsSim->setStartingCapId(startingCapId);
65  }
66  if(validDigi(df)) {
67  theNoiseSignals.push_back(samplesInPE(df));
68  }
69  }
70 }
71 
72 template<>
74 {
75  int DigiSum = 0;
76  for(int id = 0; id<digi.samples(); id++) {
77  if(digi[id].adc() > 0) ++DigiSum;
78  }
79  return(DigiSum>0);
80 }
81 
82 template<>
84  HcalDetId cell = digi.id();
85  CaloSamples result = CaloSamples(cell,digi.samples());
86 
87  // first, check if there was an overflow in this fake digi:
88  bool overflow = false;
89  // find and list them
90 
91  for(int isample=0; isample<digi.samples(); ++isample) {
92  if(digi[isample].tdc()==1){
93  overflow = true;
94  break;
95  }
96  }
97 
98  if(overflow) { // do full conversion, go back and overwrite fake entries
99  const HcalQIECoder* channelCoder = theConditions->getHcalCoder (cell);
100  const HcalQIEShape* channelShape = theConditions->getHcalShape (cell);
101  HcalCoderDb coder (*channelCoder, *channelShape);
102  coder.adc2fC(digi, result);
103 
104  // overwrite with coded information
105  for(int isample=0; isample<digi.samples(); ++isample) {
106  if(digi[isample].tdc()==0) result[isample] = float(digi[isample].adc())/HcalQIE11DigitizerTraits::PreMixFactor;
107  }
108  }
109  else { // saves creating the coder, etc., every time
110  // use coded information
111  for(int isample=0; isample<digi.samples(); ++isample) {
112  result[isample] = float(digi[isample].adc())/HcalQIE11DigitizerTraits::PreMixFactor;
113  if(digi[isample].soi()) result.setPresamples(isample);
114  }
115  }
116 
117  // translation done in fC, convert to pe:
118  fC2pe(result);
119 
120  return result;
121 }
122 
123 template<>
125  // loop over digis, adding these to the existing maps
126  for(typename COLLECTION::const_iterator it = digis->begin(); it != digis->end(); ++it)
127  {
128  QIE11DataFrame df(*it);
129  // for the first signal, set the starting cap id
130  if((it == digis->begin()) && theElectronicsSim)
131  {
132  int startingCapId = df[0].capid();
133  theElectronicsSim->setStartingCapId(startingCapId);
134  }
135  if(validDigi(df)) {
136  theNoiseSignals.push_back(samplesInPE(df));
137  }
138  }
139 }
edm::ESHandle< HcalDbService > theConditions
CaloSamples samplesInPE(const DIGI &digi)
void setStartingCapId(int startingCapId)
void fC2pe(CaloSamples &samples) const
bool validDigi(const DIGI &digi)
std::vector< CaloSamples > theNoiseSignals
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
void setPresamples(int pre)
set presample information
Definition: CaloSamples.cc:33
HcalElectronicsSim * theElectronicsSim
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
virtual void fillDigis(const COLLECTION *digis)