CMS 3D CMS Logo

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