CMS 3D CMS Logo

EcalFenixLinearizer.cc
Go to the documentation of this file.
2 
6 
8 
9 EcalFenixLinearizer::EcalFenixLinearizer(bool famos) : famos_(famos), init_(false) {}
10 
12  if (init_) {
13  for (int i = 0; i < (int)vectorbadXStatus_.size(); i++) {
14  delete vectorbadXStatus_[i];
15  }
16  }
17 }
18 
19 void EcalFenixLinearizer::setParameters(uint32_t raw,
20  const EcalTPGPedestals *ecaltpPed,
21  const EcalTPGLinearizationConst *ecaltpLin,
22  const EcalTPGCrystalStatus *ecaltpBadX) {
23  const EcalTPGLinearizationConstMap &linMap = ecaltpLin->getMap();
25  if (it != linMap.end()) {
26  linConsts_ = &(*it);
27  } else
28  edm::LogWarning("EcalTPG") << " could not find EcalTPGLinearizationConstMap entry for " << raw;
29 
30  const EcalTPGPedestalsMap &pedMap = ecaltpPed->getMap();
31  EcalTPGPedestalsMapIterator itped = pedMap.find(raw);
32  if (itped != pedMap.end())
33  peds_ = &(*itped);
34  else
35  edm::LogWarning("EcalTPG") << " could not find EcalTPGPedestalsMap entry for " << raw;
36 
37  const EcalTPGCrystalStatusMap &badXMap = ecaltpBadX->getMap();
38  EcalTPGCrystalStatusMapIterator itbadX = badXMap.find(raw);
39 
40  if (itbadX != badXMap.end()) {
41  badXStatus_ = &(*itbadX);
42  } else {
43  edm::LogWarning("EcalTPG") << " could not find EcalTPGCrystalStatusMap entry for " << raw;
45  vectorbadXStatus_.push_back(&(*badXStatus_));
46  init_ = true;
47  }
48 }
49 
51  int output = (uncorrectedSample_ - base_); // Substract base
52  if (famos_ || output < 0)
53  return 0;
54 
55  if (output < 0)
56  return shift_ << 12; // FENIX bug(!)
57  output = (output * mult_) >> (shift_ + 2); // Apply multiplicative factor
58  if (output > 0X3FFFF)
59  output = 0X3FFFF; // Saturation if too high
60  return output;
61 }
62 
64  if (RawSam.raw() > 0X3FFF) {
65  LogDebug("EcalTPG") << "ERROR IN INPUT SAMPLE OF FENIX LINEARIZER";
66  return -1;
67  }
68  uncorrectedSample_ = RawSam.adc(); // uncorrectedSample_ is coded in the 12
69  // LSB
70  gainID_ = RawSam.gainId(); // uncorrectedSample_ is coded in the 2 next bits!
71  // if (gainID_==0) gainID_=3;
72 
73  if (gainID_ == 0) {
74  base_ = 0;
75  shift_ = 0;
76  mult_ = 0xFF;
77  if ((linConsts_->mult_x12 == 0) && (linConsts_->mult_x6 == 0) && (linConsts_->mult_x1 == 0)) {
78  mult_ = 0; // Implemented in CCSSupervisor to
79  // reject overflow cases in rejected channels
80  }
81  } else if (gainID_ == 1) {
82  base_ = peds_->mean_x12;
84 
85  // take into account the badX
86  // badXStatus_ == 0 if the crystal works
87  // badXStatus_ !=0 some problem with the crystal
88  if (badXStatus_->getStatusCode() != 0) {
89  mult_ = 0;
90  } else {
92  }
93  } else if (gainID_ == 2) {
94  base_ = peds_->mean_x6;
96 
97  // take into account the badX
98  // check if the badX has a status code=0 or 1
99  if (badXStatus_->getStatusCode() != 0) {
100  mult_ = 0;
101  } else {
103  }
104  } else if (gainID_ == 3) {
105  base_ = peds_->mean_x1;
107 
108  // take into account the badX
109  // check if the badX has a status code=0 or 1
110  if (badXStatus_->getStatusCode() != 0) {
111  mult_ = 0;
112  } else {
114  }
115  }
116 
117  if (famos_)
118  base_ = 200; // FIXME by preparing a correct TPG.txt for Famos
119 
120  return 1;
121 }
#define LogDebug(id)
void setParameters(uint32_t raw, const EcalTPGPedestals *ecaltpPed, const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGCrystalStatus *ecaltpBadX)
EcalTPGPedestalsMap::const_iterator EcalTPGPedestalsMapIterator
const self & getMap() const
EcalFenixLinearizer(bool famos)
uint16_t raw() const
get the raw word
int gainId() const
get the gainId (2 bits)
EcalCondObjectContainer< EcalTPGLinearizationConstant >::const_iterator EcalTPGLinearizationConstMapIterator
EcalTPGCrystalStatusMap::const_iterator EcalTPGCrystalStatusMapIterator
int setInput(const EcalMGPASample &RawSam)
const EcalTPGLinearizationConstant * linConsts_
const EcalTPGCrystalStatusCode * badXStatus_
std::vector< const EcalTPGCrystalStatusCode * > vectorbadXStatus_
const_iterator find(uint32_t rawId) const
const EcalTPGPedestal * peds_
const_iterator end() const
int adc() const
get the ADC sample (12 bits)