CMS 3D CMS Logo

Public Member Functions | Private Attributes

CastorChannelCoder Class Reference

#include <CastorChannelCoder.h>

List of all members.

Public Member Functions

int adc (const QieShape &fShape, double fCharge, int fCapId) const
 fC + capid[0..3] -> ADC conversion
 CastorChannelCoder (const float fOffset[16], const float fSlope[16])
double charge (const QieShape &fShape, int fAdc, int fCapId) const
 ADC[0..127]+capid[0..3]->fC conversion.
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/Castor QIE

Container for ADC<->fQ conversion constants for HCAL/Castor QIE $Original author: ratnikov

Revision:
1.1

Definition at line 12 of file CastorChannelCoder.h.


Constructor & Destructor Documentation

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

Definition at line 13 of file CastorChannelCoder.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 CastorChannelCoder::adc ( const QieShape fShape,
double  fCharge,
int  fCapId 
) const

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

Definition at line 30 of file CastorChannelCoder.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 << "CastorChannelCoder::adc-> " << fCharge << '/' << fCapId 
  //        << " result: " << adc << std::endl;
  return adc;
}
double CastorChannelCoder::charge ( const QieShape fShape,
int  fAdc,
int  fCapId 
) const

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

Definition at line 22 of file CastorChannelCoder.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 << "CastorChannelCoder::charge-> " << fAdc << '/' << fCapId 
//          << " result: " << charge << std::endl;
  return charge;
}
int CastorChannelCoder::index ( int  fCapId,
int  Range 
) [inline]

Definition at line 19 of file CastorChannelCoder.h.

Referenced by CastorChannelCoder().

{return fCapId*4+Range;}

Member Data Documentation

double CastorChannelCoder::mOffset[4][4] [private]

Definition at line 21 of file CastorChannelCoder.h.

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

double CastorChannelCoder::mSlope[4][4] [private]

Definition at line 22 of file CastorChannelCoder.h.

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