CMS 3D CMS Logo

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

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

#include <EcalFenixLinearizer.h>

Public Member Functions

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

Private Member Functions

int process ()
 
int process ()
 
int setInput (const EcalMGPASample &RawSam)
 
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 EcalFenixLinearizer.h.

Constructor & Destructor Documentation

EcalFenixLinearizer::EcalFenixLinearizer ( bool  famos)

Definition at line 9 of file EcalFenixLinearizer.cc.

10  : famos_(famos), init_(false),
11  linConsts_(nullptr),
12  peds_(nullptr),
13  badXStatus_(nullptr)
14 {
15 }
const EcalTPGLinearizationConstant * linConsts_
const EcalTPGCrystalStatusCode * badXStatus_
const EcalTPGPedestal * peds_
EcalFenixLinearizer::~EcalFenixLinearizer ( )
virtual

Definition at line 17 of file EcalFenixLinearizer.cc.

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

17  {
18  if (init_) {
19  for (int i=0;i<(int)vectorbadXStatus_.size();i++){
20  delete vectorbadXStatus_[i];
21  }
22  }
23 }
std::vector< const EcalTPGCrystalStatusCode * > vectorbadXStatus_
EcalFenixLinearizer::EcalFenixLinearizer ( bool  famos)
virtual EcalFenixLinearizer::~EcalFenixLinearizer ( )
virtual

Member Function Documentation

int EcalFenixLinearizer::process ( )
private
int EcalFenixLinearizer::process ( )
private

Definition at line 59 of file EcalFenixLinearizer.cc.

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

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

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 }
template<class T >
void EcalFenixLinearizer::process ( const T ,
std::vector< int > &   
)
template<class T >
void EcalFenixLinearizer::process ( const T df,
std::vector< int > &  output_percry 
)

Definition at line 52 of file EcalFenixLinearizer.h.

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

53 {
54 
55  //We know a tower numbering is:
56 // S1 S2 S3 S4 S5
57 //
58 // 4 5 14 15 24
59 // 3 6 13 16 23
60 // 2 7 12 17 22
61 // 1 8 11 18 21
62 // 0 9 10 19 20
63 
64  //std::cout << " EcalFenixLinearizer::process(const .. DataFrame " << std::endl;
65  for (int i=0;i<df.size();i++) {
66  //std::cout << df[i] << " ";
67  }
68 
69  for (int i=0;i<df.size();i++) {
70  setInput(df[i]);
71  output_percry[i]=process();
72  }
73 
74  //std::cout << " EcalFenixLinearizer::process(const .. Final output " << std::endl;
75  for (int i=0;i<df.size();i++) {
76  //std::cout << " output_percry " << output_percry[i]<< " ";
77  }
78 
79  return;
80 }
int setInput(const EcalMGPASample &RawSam)
int EcalFenixLinearizer::setInput ( const EcalMGPASample RawSam)
private
int EcalFenixLinearizer::setInput ( const EcalMGPASample RawSam)
private

Definition at line 75 of file EcalFenixLinearizer.cc.

References EcalMGPASample::adc(), badXStatus_, base_, famos_, EcalMGPASample::gainId(), gainID_, EcalTPGCrystalStatusCode::getStatusCode(), linConsts_, LogDebug, mult_, EcalTPGLinearizationConstant::mult_x1, EcalTPGLinearizationConstant::mult_x12, EcalTPGLinearizationConstant::mult_x6, peds_, EcalMGPASample::raw(), shift_, and uncorrectedSample_.

Referenced by process().

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 }
#define LogDebug(id)
uint16_t raw() const
get the raw word
int gainId() const
get the gainId (2 bits)
const EcalTPGLinearizationConstant * linConsts_
const EcalTPGCrystalStatusCode * badXStatus_
const EcalTPGPedestal * peds_
int adc() const
get the ADC sample (12 bits)
void EcalFenixLinearizer::setParameters ( uint32_t  raw,
const EcalTPGPedestals ecaltpPed,
const EcalTPGLinearizationConst ecaltpLin,
const EcalTPGCrystalStatus ecaltpBadX 
)
void EcalFenixLinearizer::setParameters ( uint32_t  raw,
const EcalTPGPedestals ecaltpPed,
const EcalTPGLinearizationConst ecaltpLin,
const EcalTPGCrystalStatus ecaltpBadX 
)

Definition at line 25 of file EcalFenixLinearizer.cc.

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

Referenced by EcalFenixStrip::process_part1(), and EcalEBTrigPrimTestAlgo::run().

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 }
EcalTPGPedestalsMap::const_iterator EcalTPGPedestalsMapIterator
const self & getMap() const
EcalCondObjectContainer< EcalTPGLinearizationConstant >::const_iterator EcalTPGLinearizationConstMapIterator
EcalTPGCrystalStatusMap::const_iterator EcalTPGCrystalStatusMapIterator
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

Member Data Documentation

const EcalTPGCrystalStatusCode * EcalFenixLinearizer::badXStatus_
private

Definition at line 34 of file EcalFenixLinearizer.h.

Referenced by setInput(), and setParameters().

int EcalFenixLinearizer::base_
private

Definition at line 26 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

bool EcalFenixLinearizer::famos_
private

Definition at line 23 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

int EcalFenixLinearizer::gainID_
private

Definition at line 25 of file EcalFenixLinearizer.h.

Referenced by setInput().

bool EcalFenixLinearizer::init_
private

Definition at line 30 of file EcalFenixLinearizer.h.

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

const EcalTPGLinearizationConstant * EcalFenixLinearizer::linConsts_
private

Definition at line 32 of file EcalFenixLinearizer.h.

Referenced by setInput(), and setParameters().

int EcalFenixLinearizer::mult_
private

Definition at line 27 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

const EcalTPGPedestal * EcalFenixLinearizer::peds_
private

Definition at line 33 of file EcalFenixLinearizer.h.

Referenced by setInput(), and setParameters().

int EcalFenixLinearizer::shift_
private

Definition at line 28 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

int EcalFenixLinearizer::strip_
private

Definition at line 29 of file EcalFenixLinearizer.h.

int EcalFenixLinearizer::uncorrectedSample_
private

Definition at line 24 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

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

Definition at line 36 of file EcalFenixLinearizer.h.

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