CMS 3D CMS Logo

EcalEBPhase2Linearizer.cc
Go to the documentation of this file.
2 
3 //#include <CondFormats/EcalObjects/interface/EcalTPGCrystalStatus.h>
4 
6 
8  : debug_(debug), init_(false), peds_(nullptr), badXStatus_(nullptr) {}
9 
11  if (init_) {
12  for (int i = 0; i < (int)vectorbadXStatus_.size(); i++) {
13  delete vectorbadXStatus_[i];
14  }
15  }
16 }
17 
19  const EcalLiteDTUPedestalsMap *ecaltpPed,
20  const EcalEBPhase2TPGLinearizationConstMap *ecaltpLin,
21  const EcalTPGCrystalStatus *ecaltpBadX)
22 
23 {
25  if (itped != ecaltpPed->end())
26  peds_ = &(*itped);
27  else
28  edm::LogError("EcalEBPhase2Linearizer") << " could not find EcalLiteDTUPedestal entry for " << detId << std::endl;
29 
30  const EcalEBPhase2TPGLinearizationConstMap &linMap = ecaltpLin->getMap();
32  if (it != linMap.end()) {
33  linConsts_ = &(*it);
34  } else
35  edm::LogError("EcalEBPhase2Linearizer")
36  << " could not find EcalEBPhase2TPGLinearizationConstMap entry for " << detId.rawId() << std::endl;
37 
38  const EcalTPGCrystalStatusMap &badXMap = ecaltpBadX->getMap();
39  EcalTPGCrystalStatusMapIterator itbadX = badXMap.find(detId.rawId());
40  if (itbadX != badXMap.end()) {
41  badXStatus_ = &(*itbadX);
42  } else {
43  edm::LogWarning("EcalTPG") << " could not find EcalTPGCrystalStatusMap entry for " << detId.rawId();
45  vectorbadXStatus_.push_back(&(*badXStatus_));
46  init_ = true;
47  }
48 }
49 
51  int tmpIntOut;
52  if (uncorrectedSample_) {
53  tmpIntOut = (uncorrectedSample_ - base_ + I2CSub_); //Substract base. Add I2C
54  } else {
55  tmpIntOut = 0;
56  }
57  if (tmpIntOut < 0) {
58  tmpIntOut = 0;
59  }
60  uint output = tmpIntOut;
61  output = (output * mult_) >> shift_;
62  // protect against saturation
63  // ...........
64 
65  return output;
66 }
67 
69 
70 {
71  uncorrectedSample_ = RawSam.adc(); //uncorrectedSample_
72  gainID_ = RawSam.gainId();
73 
74  base_ = peds_->mean(gainID_);
75 
76  if (gainID_ == 0) {
80  } else {
84  }
85 
86  return 1;
87 }
88 
89 void EcalEBPhase2Linearizer::process(const EBDigiCollectionPh2::Digi &df, std::vector<int> &output_percry) {
90  //We know a tower numbering is: // S1 S2 S3 S4 S5
91 
92  // 4 5 14 15 24
93  // 3 6 13 16 23
94  // 2 7 12 17 22
95  // 1 8 11 18 21
96  // 0 9 10 19 20
97 
98  for (int i = 0; i < df.size(); i++) {
99  EcalLiteDTUSample thisSample = df[i];
100  setInput(thisSample);
101  output_percry[i] = doOutput();
102  }
103 
104  if (debug_) {
105  LogDebug("EcalEBPhase2Linearizer") << " mult "
106  << " ";
107  for (int i = 0; i < df.size(); i++) {
108  EcalLiteDTUSample thisSample = df[i];
109  setInput(thisSample);
110  LogDebug("") << mult_ << " ";
111  }
112  LogDebug("") << " " << std::endl;
113 
114  LogDebug("") << " gainID "
115  << " ";
116  for (int i = 0; i < df.size(); i++) {
117  EcalLiteDTUSample thisSample = df[i];
118  setInput(thisSample);
119  LogDebug("") << gainID_ << " ";
120  }
121  LogDebug("") << " " << std::endl;
122 
123  LogDebug("") << " Ped "
124  << " ";
125  for (int i = 0; i < df.size(); i++) {
126  EcalLiteDTUSample thisSample = df[i];
127  setInput(thisSample);
128  LogDebug("") << base_ << " ";
129  }
130  LogDebug("") << " " << std::endl;
131 
132  LogDebug("") << " i2c "
133  << " ";
134  for (int i = 0; i < df.size(); i++) {
135  EcalLiteDTUSample thisSample = df[i];
136  setInput(thisSample);
137  LogDebug("") << I2CSub_ << " ";
138  }
139  LogDebug("") << " " << std::endl;
140 
141  LogDebug("") << " shift "
142  << " ";
143  for (int i = 0; i < df.size(); i++) {
144  EcalLiteDTUSample thisSample = df[i];
145  setInput(thisSample);
146  LogDebug("") << shift_ << " ";
147  }
148  LogDebug("") << " " << std::endl;
149 
150  LogDebug("") << " lin out "
151  << " ";
152  for (int i = 0; i < df.size(); i++) {
153  LogDebug("") << output_percry[i] << " ";
154  }
155 
156  LogDebug("") << " " << std::endl;
157 
158  LogDebug("") << " EcalEBPhase2Linearizer::process(const .. Final output " << std::endl;
159  LogDebug("") << " output_percry "
160  << " ";
161  for (int i = 0; i < df.size(); i++) {
162  LogDebug("") << output_percry[i] << " ";
163  }
164  LogDebug("") << " " << std::endl;
165  }
166  return;
167 }
const EcalEBPhase2TPGLinearizationConstant * linConsts_
std::vector< const EcalTPGCrystalStatusCode * > vectorbadXStatus_
EcalCondObjectContainer< EcalEBPhase2TPGLinearizationConstant >::const_iterator EcalEBPhase2TPGLinearizationConstMapIterator
void process(const EBDigiCollectionPh2::Digi &df, std::vector< int > &output_percry)
int adc() const
get the ADC sample (12 bits)
Log< level::Error, false > LogError
float mean(unsigned int i) const
EcalTPGCrystalStatusMap::const_iterator EcalTPGCrystalStatusMapIterator
int setInput(const EcalLiteDTUSample &RawSam)
const_iterator find(uint32_t rawId) const
const EcalLiteDTUPedestals * peds_
int gainId() const
get the gainId (2 bits)
#define debug
Definition: HDRShower.cc:19
std::vector< Item >::const_iterator const_iterator
void setParameters(EBDetId id, const EcalLiteDTUPedestalsMap *peds, const EcalEBPhase2TPGLinearizationConstMap *ecaltplin, const EcalTPGCrystalStatus *ecaltpBadX)
const EcalTPGCrystalStatusCode * badXStatus_
const_iterator end() const
Definition: output.py:1
Log< level::Warning, false > LogWarning
#define LogDebug(id)