CMS 3D CMS Logo

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