CMS 3D CMS Logo

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