CMS 3D CMS Logo

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