CMS 3D CMS Logo

Public Member Functions | Private Attributes

HcalChannelCoder Class Reference

#include <HcalChannelCoder.h>

List of all members.

Public Member Functions

int adc (const QieShape &fShape, double fCharge, int fCapId) const
 fC + capid[0..3] -> ADC conversion
double charge (const QieShape &fShape, int fAdc, int fCapId) const
 ADC[0..127]+capid[0..3]->fC conversion.
 HcalChannelCoder (const float fOffset[16], const float fSlope[16])
int index (int fCapId, int Range)

Private Attributes

double mOffset [4][4]
double mSlope [4][4]

Detailed Description

Container for ADC<->fQ conversion constants for HCAL QIE $Author: ratnikov

Date:
2006/04/13 22:40:40
Revision:
1.3

Container for ADC<->fQ conversion constants for HCAL QIE $Author: ratnikov

Revision:
1.3

Definition at line 14 of file HcalChannelCoder.h.


Constructor & Destructor Documentation

HcalChannelCoder::HcalChannelCoder ( const float  fOffset[16],
const float  fSlope[16] 
)

Definition at line 13 of file HcalChannelCoder.cc.

References index(), mOffset, and mSlope.

                                                                                     { // [CapId][Range]
  for (int range = 0; range < 4; range++) {
    for (int capId = 0; capId < 4; capId++) {
      mOffset [capId][range] = fOffset [index (capId, range)];
      mSlope [capId][range] = fSlope [index (capId, range)];
    }
  }
}

Member Function Documentation

int HcalChannelCoder::adc ( const QieShape fShape,
double  fCharge,
int  fCapId 
) const

fC + capid[0..3] -> ADC conversion

Definition at line 30 of file HcalChannelCoder.cc.

References newFWLiteAna::bin, QieShape::binSize(), QieShape::linearization(), mOffset, and mSlope.

                                                                                   {

  int adc = -1; //nothing found yet
  // search for the range
  for (int range = 0; range < 4; range++) {
    double qieCharge = (fCharge - mOffset [fCapId][range]) * mSlope [fCapId][range];
    double qieChargeMax = fShape.linearization (32*range+31) + 0.5 * fShape.binSize (32*range+31);
    if (range == 3 && qieCharge > qieChargeMax) adc = 127; // overflow
    if (qieCharge > qieChargeMax) continue; // next range
    for (int bin = 32*range; bin < 32*(range+1); bin++) {
      if (qieCharge < fShape.linearization (bin) + 0.5 * fShape.binSize (bin)) {
        adc = bin;
        break;
      }
    }
    if (adc >= 0) break; // found
  }
  if (adc < 0) adc = 0; // underflow

//   std::cout << "HcalChannelCoder::adc-> " << fCharge << '/' << fCapId 
//          << " result: " << adc << std::endl;
  return adc;
}
double HcalChannelCoder::charge ( const QieShape fShape,
int  fAdc,
int  fCapId 
) const

ADC[0..127]+capid[0..3]->fC conversion.

Definition at line 22 of file HcalChannelCoder.cc.

References QieShape::linearization(), mOffset, and mSlope.

                                                                                   {
  int range = (fAdc >> 6) & 0x3;
  double charge = fShape.linearization (fAdc) / mSlope [fCapId][range] + mOffset [fCapId][range];
//   std::cout << "HcalChannelCoder::charge-> " << fAdc << '/' << fCapId 
//          << " result: " << charge << std::endl;
  return charge;
}
int HcalChannelCoder::index ( int  fCapId,
int  Range 
) [inline]

Definition at line 21 of file HcalChannelCoder.h.

Referenced by HcalChannelCoder().

{return fCapId*4+Range;}

Member Data Documentation

double HcalChannelCoder::mOffset[4][4] [private]

Definition at line 23 of file HcalChannelCoder.h.

Referenced by adc(), charge(), and HcalChannelCoder().

double HcalChannelCoder::mSlope[4][4] [private]

Definition at line 24 of file HcalChannelCoder.h.

Referenced by adc(), charge(), and HcalChannelCoder().