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  uint16_t flag = digi.flags();
92  for(int isample=0; isample<digi.samples(); ++isample) {
93  if((flag>>isample)&1) overflow = true;
94  }
95 
96  if(overflow) { // do full conversion, go back and overwrite fake entries
97  const HcalQIECoder* channelCoder = theConditions->getHcalCoder (cell);
98  const HcalQIEShape* channelShape = theConditions->getHcalShape (cell);
99  HcalCoderDb coder (*channelCoder, *channelShape);
100  coder.adc2fC(digi, result);
101 
102  // overwrite with coded information
103  for(int isample=0; isample<digi.samples(); ++isample) {
104  if(!((flag>>isample)&1)) result[isample] = float(digi[isample].adc())/HcalQIE11DigitizerTraits::PreMixFactor;
105  }
106  }
107  else { // saves creating the coder, etc., every time
108  // use coded information
109  for(int isample=0; isample<digi.samples(); ++isample) {
110  result[isample] = float(digi[isample].adc())/HcalQIE11DigitizerTraits::PreMixFactor;
111  if(digi[isample].soi()) result.setPresamples(isample);
112  }
113  }
114 
115  // translation done in fC, convert to pe:
116  fC2pe(result);
117 
118  return result;
119 }
120 
121 template<>
123  // loop over digis, adding these to the existing maps
124  for(typename COLLECTION::const_iterator it = digis->begin(); it != digis->end(); ++it)
125  {
126  QIE11DataFrame df(*it);
127  // for the first signal, set the starting cap id
128  if((it == digis->begin()) && theElectronicsSim)
129  {
130  int startingCapId = df[0].capid();
131  theElectronicsSim->setStartingCapId(startingCapId);
132  }
133  if(validDigi(df)) {
134  theNoiseSignals.push_back(samplesInPE(df));
135  }
136  }
137 }
int adc(sample_type sample)
get the ADC sample (12 bits)
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
void setPresamples(int pre)
set presample information
Definition: CaloSamples.cc:31
HcalElectronicsSim * theElectronicsSim
const HcalQIECoder * getHcalCoder(const HcalGenericDetId &fId) const
const HcalQIEShape * getHcalShape(const HcalGenericDetId &fId) const
virtual void fillDigis(const COLLECTION *digis)