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 }
EcalCondObjectContainer::getMap
const self & getMap() const
Definition: EcalCondObjectContainer.h:78
EcalCondObjectContainer::end
const_iterator end() const
Definition: EcalCondObjectContainer.h:74
EcalTPGCrystalStatusCode::getStatusCode
uint16_t getStatusCode() const
Definition: EcalTPGCrystalStatusCode.h:26
mps_fire.i
i
Definition: mps_fire.py:428
EcalTPGLinearizationConstant::shift_x1
uint32_t shift_x1
Definition: EcalTPGLinearizationConst.h:16
MessageLogger.h
EcalEBFenixLinearizer::peds_
const EcalTPGPedestal * peds_
Definition: EcalEBFenixLinearizer.h:31
EcalTPGPedestal::mean_x1
uint32_t mean_x1
Definition: EcalTPGPedestals.h:12
funct::false
false
Definition: Factorize.h:29
EcalEBFenixLinearizer::setInput
int setInput(const EcalMGPASample &RawSam)
Definition: EcalEBFenixLinearizer.cc:67
EcalTPGLinearizationConstant::mult_x6
uint32_t mult_x6
Definition: EcalTPGLinearizationConst.h:12
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
EcalEBFenixLinearizer::linConsts_
const EcalTPGLinearizationConstant * linConsts_
Definition: EcalEBFenixLinearizer.h:30
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EcalTPGPedestalsMapIterator
EcalTPGPedestalsMap::const_iterator EcalTPGPedestalsMapIterator
Definition: EcalTPGPedestals.h:18
EcalCondObjectContainer
Definition: EcalCondObjectContainer.h:13
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalTPGCrystalStatusMapIterator
EcalTPGCrystalStatusMap::const_iterator EcalTPGCrystalStatusMapIterator
Definition: EcalTPGCrystalStatus.h:18
EcalMGPASample::gainId
int gainId() const
get the gainId (2 bits)
Definition: EcalMGPASample.h:33
EcalMGPASample::adc
int adc() const
get the ADC sample (12 bits)
Definition: EcalMGPASample.h:31
EcalEBFenixLinearizer::EcalEBFenixLinearizer
EcalEBFenixLinearizer(bool famos)
Definition: EcalEBFenixLinearizer.cc:9
EcalTPGLinearizationConstMapIterator
EcalCondObjectContainer< EcalTPGLinearizationConstant >::const_iterator EcalTPGLinearizationConstMapIterator
Definition: EcalTPGLinearizationConst.h:22
EcalEBFenixLinearizer::setParameters
void setParameters(uint32_t raw, const EcalTPGPedestals *ecaltpPed, const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGCrystalStatus *ecaltpBadX)
Definition: EcalEBFenixLinearizer.cc:20
EcalCondObjectContainer::find
const_iterator find(uint32_t rawId) const
Definition: EcalCondObjectContainer.h:53
EcalEBFenixLinearizer::shift_
int shift_
Definition: EcalEBFenixLinearizer.h:26
EcalMGPASample::raw
uint16_t raw() const
get the raw word
Definition: EcalMGPASample.h:29
EcalEBFenixLinearizer::vectorbadXStatus_
std::vector< const EcalTPGCrystalStatusCode * > vectorbadXStatus_
Definition: EcalEBFenixLinearizer.h:34
EcalEBFenixLinearizer::famos_
bool famos_
Definition: EcalEBFenixLinearizer.h:21
EcalEBFenixLinearizer::badXStatus_
const EcalTPGCrystalStatusCode * badXStatus_
Definition: EcalEBFenixLinearizer.h:32
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
EcalTPGLinearizationConst.h
EcalTPGLinearizationConstant::mult_x12
uint32_t mult_x12
Definition: EcalTPGLinearizationConst.h:11
EcalTPGLinearizationConstant::mult_x1
uint32_t mult_x1
Definition: EcalTPGLinearizationConst.h:13
EcalTPGPedestal::mean_x6
uint32_t mean_x6
Definition: EcalTPGPedestals.h:11
createfilelist.int
int
Definition: createfilelist.py:10
EcalTPGPedestals.h
EcalTPGLinearizationConstant::shift_x6
uint32_t shift_x6
Definition: EcalTPGLinearizationConst.h:15
EcalEBFenixLinearizer::base_
int base_
Definition: EcalEBFenixLinearizer.h:24
EcalEBFenixLinearizer.h
EcalTPGLinearizationConstant::shift_x12
uint32_t shift_x12
Definition: EcalTPGLinearizationConst.h:14
EcalMGPASample
Definition: EcalMGPASample.h:22
EcalEBFenixLinearizer::gainID_
int gainID_
Definition: EcalEBFenixLinearizer.h:23
EcalTPGCrystalStatusCode
Definition: EcalTPGCrystalStatusCode.h:14
EcalEBFenixLinearizer::process
int process()
Definition: EcalEBFenixLinearizer.cc:51
EcalTPGCrystalStatus.h
EcalEBFenixLinearizer::uncorrectedSample_
int uncorrectedSample_
Definition: EcalEBFenixLinearizer.h:22
EcalEBFenixLinearizer::init_
bool init_
Definition: EcalEBFenixLinearizer.h:28
EcalTPGPedestal::mean_x12
uint32_t mean_x12
Definition: EcalTPGPedestals.h:10
EcalEBFenixLinearizer::~EcalEBFenixLinearizer
virtual ~EcalEBFenixLinearizer()
Definition: EcalEBFenixLinearizer.cc:12
EcalEBFenixLinearizer::mult_
int mult_
Definition: EcalEBFenixLinearizer.h:25