CMS 3D CMS Logo

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>

List of all members.

Public Member Functions

 EcalFenixLinearizer (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 ~EcalFenixLinearizer ()

Private Member Functions

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

Private Attributes

const EcalTPGCrystalStatusCodebadXStatus_
int base_
bool famos_
int gainID_
bool init_
const
EcalTPGLinearizationConstant
linConsts_
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.

  : famos_(famos), init_(false)
{
}
EcalFenixLinearizer::~EcalFenixLinearizer ( ) [virtual]

Definition at line 14 of file EcalFenixLinearizer.cc.

References i, init_, and vectorbadXStatus_.

                                         {
  if (init_) {
    for (int i=0;i<(int)vectorbadXStatus_.size();i++){
      delete vectorbadXStatus_[i];
    }
  }    
}

Member Function Documentation

int EcalFenixLinearizer::process ( ) [private]

Definition at line 51 of file EcalFenixLinearizer.cc.

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

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

{
  int output=(uncorrectedSample_-base_); //Substract base
  if(output<0) return 0;
  output=(output*mult_)>>(shift_+2);        //Apply multiplicative factor
  if(output>0X3FFFF)output=0X3FFFF;         //Saturation if too high
  return output;
}
template<class T >
void EcalFenixLinearizer::process ( const T &  df,
std::vector< int > &  output_percry 
)

Definition at line 52 of file EcalFenixLinearizer.h.

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

{

  //We know a tower numbering is:
// S1 S2 S3 S4 S5
//
// 4  5  14 15 24
// 3  6  13 16 23
// 2  7  12 17 22
// 1  8  11 18 21
// 0  9  10 19 20
  for (int i=0;i<df.size();i++) {
    setInput(df[i]);
    output_percry[i]=process();
  }

  return;
}
int EcalFenixLinearizer::setInput ( const EcalMGPASample RawSam) [private]

Definition at line 60 of file EcalFenixLinearizer.cc.

References EcalMGPASample::adc(), badXStatus_, base_, famos_, EcalMGPASample::gainId(), gainID_, EcalTPGCrystalStatusCode::getStatusCode(), linConsts_, LogDebug, cond::ecalped::mean_x12, cond::ecalped::mean_x6, mult_, peds_, EcalMGPASample::raw(), shift_, and uncorrectedSample_.

Referenced by process().

{ 
  if(RawSam.raw()>0X3FFF)
    {
      LogDebug("EcalTPG")<<"ERROR IN INPUT SAMPLE OF FENIX LINEARIZER";
      return -1;
    }
  uncorrectedSample_=RawSam.adc(); //uncorrectedSample_ is coded in the 12 LSB
  gainID_=RawSam.gainId();       //uncorrectedSample_ is coded in the 2 next bits!
  if (gainID_==0)    gainID_=3;

  if (gainID_==1) {
    base_ = peds_ -> mean_x12; 
    shift_ = linConsts_ -> shift_x12;
    
    // take into account the badX
    // badXStatus_ == 0 if the crystal works
    // badXStatus_ !=0 some problem with the crystal
    if (badXStatus_->getStatusCode()!=0){
      mult_ = 0;
    }
    else{ 
      mult_ = linConsts_ -> mult_x12;
    }
  }
  else if (gainID_==2) {
    base_ = peds_ -> mean_x6;
    shift_ = linConsts_ -> shift_x6;
    
    // take into account the badX
    // check if the badX has a status code=0 or 1 
    if (badXStatus_->getStatusCode()!=0){
      mult_ = 0;
    }
    else{
      mult_ = linConsts_ -> mult_x6;
    }  
  }
  else if (gainID_==3){
    base_ = peds_-> mean_x1; 
    shift_ = linConsts_ -> shift_x1;
    
    // take into account the badX 
    // check if the badX has a status code=0 or 1
    if (badXStatus_->getStatusCode()!=0){
      mult_ = 0;
    }
    else{
      mult_ = linConsts_ -> mult_x1;
    } 
  }

  if (famos_) base_=200; //FIXME by preparing a correct TPG.txt for Famos
 
  return 1;
}
void EcalFenixLinearizer::setParameters ( uint32_t  raw,
const EcalTPGPedestals ecaltpPed,
const EcalTPGLinearizationConst ecaltpLin,
const EcalTPGCrystalStatus ecaltpBadX 
)

Definition at line 22 of file EcalFenixLinearizer.cc.

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

Referenced by EcalFenixStrip::process_part1().

{
  const EcalTPGLinearizationConstMap & linMap = ecaltpLin->getMap() ; 
  EcalTPGLinearizationConstMapIterator it=linMap.find(raw);
  if (it!=linMap.end()) {
    linConsts_=&(*it);
  }
  else edm::LogWarning("EcalTPG")<<" could not find EcalTPGLinearizationConstMap entry for "<<raw;
  
  const EcalTPGPedestalsMap & pedMap = ecaltpPed->getMap() ; 
  EcalTPGPedestalsMapIterator itped=pedMap.find(raw);
  if (itped!=pedMap.end())   peds_=&(*itped);
  else edm::LogWarning("EcalTPG")<<" could not find EcalTPGPedestalsMap entry for "<<raw;

  const EcalTPGCrystalStatusMap & badXMap = ecaltpBadX->getMap();
  EcalTPGCrystalStatusMapIterator itbadX=badXMap.find(raw); 
  
  if (itbadX!=badXMap.end()) {
    badXStatus_=&(*itbadX);
  }  
  else 
  {   
    edm::LogWarning("EcalTPG")<<" could not find EcalTPGCrystalStatusMap entry for "<<raw; 
    badXStatus_ = new EcalTPGCrystalStatusCode();
    vectorbadXStatus_.push_back(&(*badXStatus_));
    init_ = true;       
  }
}

Member Data Documentation

Definition at line 34 of file EcalFenixLinearizer.h.

Referenced by setInput(), and setParameters().

Definition at line 26 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

Definition at line 23 of file EcalFenixLinearizer.h.

Referenced by setInput().

Definition at line 25 of file EcalFenixLinearizer.h.

Referenced by setInput().

Definition at line 30 of file EcalFenixLinearizer.h.

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

Definition at line 32 of file EcalFenixLinearizer.h.

Referenced by setInput(), and setParameters().

Definition at line 27 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

Definition at line 33 of file EcalFenixLinearizer.h.

Referenced by setInput(), and setParameters().

Definition at line 28 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

Definition at line 29 of file EcalFenixLinearizer.h.

Definition at line 24 of file EcalFenixLinearizer.h.

Referenced by process(), and setInput().

Definition at line 36 of file EcalFenixLinearizer.h.

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