CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalEBFenixLinearizer Class Reference

Linearisation for Fenix strip input: 16 bits corresponding to input EBDataFrame output: 18 bits. More...

#include <EcalEBFenixLinearizer.h>

Public Member Functions

 EcalEBFenixLinearizer (bool famos)
 
template<class T >
void process (const T &, std::vector< int > &)
 
void setParameters (uint32_t raw, const EcalTPGPedestals *ecaltpPed, const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGCrystalStatus *ecaltpBadX)
 
virtual ~EcalEBFenixLinearizer ()
 

Private Member Functions

int process ()
 
int setInput (const EcalMGPASample &RawSam)
 

Private Attributes

const EcalTPGCrystalStatusCodebadXStatus_
 
int base_
 
bool famos_
 
int gainID_
 
bool init_
 
const EcalTPGLinearizationConstantlinConsts_
 
int mult_
 
const EcalTPGPedestalpeds_
 
int shift_
 
int strip_
 
int uncorrectedSample_
 
std::vector< const EcalTPGCrystalStatusCode * > vectorbadXStatus_
 

Detailed Description

Linearisation for Fenix strip input: 16 bits corresponding to input EBDataFrame output: 18 bits.

Definition at line 19 of file EcalEBFenixLinearizer.h.

Constructor & Destructor Documentation

◆ EcalEBFenixLinearizer()

EcalEBFenixLinearizer::EcalEBFenixLinearizer ( bool  famos)

Definition at line 9 of file EcalEBFenixLinearizer.cc.

10  : famos_(famos), init_(false), linConsts_(nullptr), peds_(nullptr), badXStatus_(nullptr) {}
const EcalTPGPedestal * peds_
const EcalTPGCrystalStatusCode * badXStatus_
const EcalTPGLinearizationConstant * linConsts_

◆ ~EcalEBFenixLinearizer()

EcalEBFenixLinearizer::~EcalEBFenixLinearizer ( )
virtual

Definition at line 12 of file EcalEBFenixLinearizer.cc.

References mps_fire::i, init_, createfilelist::int, and vectorbadXStatus_.

12  {
13  if (init_) {
14  for (int i = 0; i < (int)vectorbadXStatus_.size(); i++) {
15  delete vectorbadXStatus_[i];
16  }
17  }
18 }
std::vector< const EcalTPGCrystalStatusCode * > vectorbadXStatus_

Member Function Documentation

◆ process() [1/2]

int EcalEBFenixLinearizer::process ( )
private

Definition at line 51 of file EcalEBFenixLinearizer.cc.

References base_, famos_, mult_, convertSQLitetoXML_cfg::output, shift_, and uncorrectedSample_.

Referenced by process(), and EcalEBTrigPrimTestAlgo::run().

51  {
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 }

◆ process() [2/2]

template<class T >
void EcalEBFenixLinearizer::process ( const T df,
std::vector< int > &  output_percry 
)

Definition at line 52 of file EcalEBFenixLinearizer.h.

References hgcalPerformanceValidation::df, mps_fire::i, process(), and setInput().

52  {
53  //We know a tower numbering is:
54  // S1 S2 S3 S4 S5
55  //
56  // 4 5 14 15 24
57  // 3 6 13 16 23
58  // 2 7 12 17 22
59  // 1 8 11 18 21
60  // 0 9 10 19 20
61 
62  for (int i = 0; i < df.size(); i++) {
63  setInput(df[i]);
64  output_percry[i] = process();
65  }
66 
67  return;
68 }
int setInput(const EcalMGPASample &RawSam)

◆ setInput()

int EcalEBFenixLinearizer::setInput ( const EcalMGPASample RawSam)
private

Definition at line 67 of file EcalEBFenixLinearizer.cc.

References EcalMGPASample::adc(), badXStatus_, base_, famos_, EcalMGPASample::gainId(), gainID_, EcalTPGCrystalStatusCode::getStatusCode(), linConsts_, LogDebug, EcalTPGPedestal::mean_x1, EcalTPGPedestal::mean_x12, EcalTPGPedestal::mean_x6, mult_, EcalTPGLinearizationConstant::mult_x1, EcalTPGLinearizationConstant::mult_x12, EcalTPGLinearizationConstant::mult_x6, peds_, EcalMGPASample::raw(), shift_, EcalTPGLinearizationConstant::shift_x1, EcalTPGLinearizationConstant::shift_x12, EcalTPGLinearizationConstant::shift_x6, and uncorrectedSample_.

Referenced by process().

67  {
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 }
const EcalTPGPedestal * peds_
const EcalTPGCrystalStatusCode * badXStatus_
const EcalTPGLinearizationConstant * linConsts_
int adc() const
get the ADC sample (12 bits)
uint16_t raw() const
get the raw word
int gainId() const
get the gainId (2 bits)
#define LogDebug(id)

◆ setParameters()

void EcalEBFenixLinearizer::setParameters ( uint32_t  raw,
const EcalTPGPedestals ecaltpPed,
const EcalTPGLinearizationConst ecaltpLin,
const EcalTPGCrystalStatus ecaltpBadX 
)

Definition at line 20 of file EcalEBFenixLinearizer.cc.

References badXStatus_, gather_cfg::cout, EcalCondObjectContainer< T >::end(), EcalCondObjectContainer< T >::find(), EcalCondObjectContainer< T >::getMap(), init_, linConsts_, peds_, and vectorbadXStatus_.

Referenced by EcalEBTrigPrimTestAlgo::run().

23  {
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 }
EcalTPGPedestalsMap::const_iterator EcalTPGPedestalsMapIterator
const EcalTPGPedestal * peds_
std::vector< const EcalTPGCrystalStatusCode * > vectorbadXStatus_
EcalCondObjectContainer< EcalTPGLinearizationConstant >::const_iterator EcalTPGLinearizationConstMapIterator
EcalTPGCrystalStatusMap::const_iterator EcalTPGCrystalStatusMapIterator
const EcalTPGCrystalStatusCode * badXStatus_
const_iterator find(uint32_t rawId) const
const EcalTPGLinearizationConstant * linConsts_
const_iterator end() const
Log< level::Warning, false > LogWarning

Member Data Documentation

◆ badXStatus_

const EcalTPGCrystalStatusCode* EcalEBFenixLinearizer::badXStatus_
private

Definition at line 32 of file EcalEBFenixLinearizer.h.

Referenced by setInput(), and setParameters().

◆ base_

int EcalEBFenixLinearizer::base_
private

Definition at line 24 of file EcalEBFenixLinearizer.h.

Referenced by process(), and setInput().

◆ famos_

bool EcalEBFenixLinearizer::famos_
private

Definition at line 21 of file EcalEBFenixLinearizer.h.

Referenced by process(), and setInput().

◆ gainID_

int EcalEBFenixLinearizer::gainID_
private

Definition at line 23 of file EcalEBFenixLinearizer.h.

Referenced by setInput().

◆ init_

bool EcalEBFenixLinearizer::init_
private

Definition at line 28 of file EcalEBFenixLinearizer.h.

Referenced by setParameters(), and ~EcalEBFenixLinearizer().

◆ linConsts_

const EcalTPGLinearizationConstant* EcalEBFenixLinearizer::linConsts_
private

Definition at line 30 of file EcalEBFenixLinearizer.h.

Referenced by setInput(), and setParameters().

◆ mult_

int EcalEBFenixLinearizer::mult_
private

Definition at line 25 of file EcalEBFenixLinearizer.h.

Referenced by process(), and setInput().

◆ peds_

const EcalTPGPedestal* EcalEBFenixLinearizer::peds_
private

Definition at line 31 of file EcalEBFenixLinearizer.h.

Referenced by setInput(), and setParameters().

◆ shift_

int EcalEBFenixLinearizer::shift_
private

Definition at line 26 of file EcalEBFenixLinearizer.h.

Referenced by process(), and setInput().

◆ strip_

int EcalEBFenixLinearizer::strip_
private

Definition at line 27 of file EcalEBFenixLinearizer.h.

◆ uncorrectedSample_

int EcalEBFenixLinearizer::uncorrectedSample_
private

Definition at line 22 of file EcalEBFenixLinearizer.h.

Referenced by process(), and setInput().

◆ vectorbadXStatus_

std::vector<const EcalTPGCrystalStatusCode *> EcalEBFenixLinearizer::vectorbadXStatus_
private

Definition at line 34 of file EcalEBFenixLinearizer.h.

Referenced by setParameters(), and ~EcalEBFenixLinearizer().