CMS 3D CMS Logo

Functions

CastorSimpleRecAlgoImpl Namespace Reference

Functions

template<class Digi , class RecHit >
bool corrSaturation (RecHit &rechit, const CastorCoder &coder, const CastorCalibrations &calibs, const Digi &digi, const int &maxADCvalue, const double &satCorrConst, int ifirst, int n)
template<class Digi >
bool isSaturated (const Digi &digi, const int &maxADCvalue, int ifirst, int n)
template<class Digi , class RecHit >
RecHit reco (const Digi &digi, const CastorCoder &coder, const CastorCalibrations &calibs, int ifirst, int n, bool slewCorrect, const CastorPulseContainmentCorrection *corr, CastorTimeSlew::BiasSetting slewFlavor)

Function Documentation

template<class Digi , class RecHit >
bool CastorSimpleRecAlgoImpl::corrSaturation ( RecHit &  rechit,
const CastorCoder coder,
const CastorCalibrations calibs,
const Digi &  digi,
const int &  maxADCvalue,
const double &  satCorrConst,
int  ifirst,
int  n 
) [inline]

Definition at line 103 of file CastorSimpleRecAlgo.cc.

References ecalMGPA::adc(), CastorCoder::adc2fC(), CastorCalibrations::gain(), and CastorCalibrations::pedestal().

  {
    // correction works only with 2 used TS
    if(n != 2) return false;

    // to avoid segmentation violation
    if(ifirst+n > digi.size()) return false;

    // look if first TS is saturated not the second one
    // in case the second one is saturated do no correction
    if(digi[ifirst].adc() >= maxADCvalue && digi[ifirst+1].adc() < maxADCvalue) {
      float ampl = 0;

      CaloSamples tool;
      coder.adc2fC(digi,tool);

      // get energy of first TS
      int capid = digi[ifirst].capid();
      float ta = tool[ifirst]-calibs.pedestal(capid); // pedestal subtraction
      float ta1 = ta*calibs.gain(capid); // fC --> GeV

      // get energy of second TS
      capid = digi[ifirst+1].capid();
      ta = tool[ifirst+1]-calibs.pedestal(capid); // pedestal subtraction
      float ta2 = ta*calibs.gain(capid); // fC --> GeV

      // use second TS to calc the first one
      // check if recalculated TS ampl is
      // realy greater than the saturated value
      if(ta2 / satCorrConst <= ta1) return false;

      // ampl = TS5 + TS4 => TS4 = TS5 / TSratio
      // ampl = TS5 + TS5 / TSratio
      ampl    = ta2  + ta2  / satCorrConst;

      // reset energy of rechit
      rechit.setEnergy(ampl);

      return true;
    }

    return false;
  }
template<class Digi >
bool CastorSimpleRecAlgoImpl::isSaturated ( const Digi &  digi,
const int &  maxADCvalue,
int  ifirst,
int  n 
) [inline]
template<class Digi , class RecHit >
RecHit CastorSimpleRecAlgoImpl::reco ( const Digi &  digi,
const CastorCoder coder,
const CastorCalibrations calibs,
int  ifirst,
int  n,
bool  slewCorrect,
const CastorPulseContainmentCorrection corr,
CastorTimeSlew::BiasSetting  slewFlavor 
) [inline]

Definition at line 37 of file CastorSimpleRecAlgo.cc.

References CastorCoder::adc2fC(), CastorTimeSlew::delay(), CastorCalibrations::gain(), CastorPulseContainmentCorrection::getCorrection(), i, max(), findQualityFiles::maxI, CastorCalibrations::pedestal(), CaloSamples::size(), cond::rpcobgas::time, and timeshift_ns_hf().

                                                                                                                                              {
    CaloSamples tool;
    coder.adc2fC(digi,tool);

    double ampl=0; int maxI = -1; double maxA = -1e10; float ta=0;
    double fc_ampl=0;
    for (int i=ifirst; i<tool.size() && i<n+ifirst; i++) {
      int capid=digi[i].capid();
      ta = (tool[i]-calibs.pedestal(capid)); // pedestal subtraction
      fc_ampl+=ta; 
      ta*=calibs.gain(capid); // fC --> GeV
      ampl+=ta;
      if(ta>maxA){
        maxA=ta;
        maxI=i;
      }
    }

    float time=-9999;
    if(maxI==0 || maxI==(tool.size()-1)) {      
      // supress warning and use dummy time value for 2009 data
      /*
      edm::LogWarning("HCAL/CASTOR Pulse") << "CastorSimpleRecAlgo::reconstruct :" 
                                               << " Invalid max amplitude position, " 
                                               << " max Amplitude: "<< maxI
                                               << " first: "<<ifirst
                                               << " last: "<<(tool.size()-1)
                                               << std::endl;
    */
    } else {
      maxA=fabs(maxA);
      int capid=digi[maxI-1].capid();
      float t0 = fabs((tool[maxI-1]-calibs.pedestal(capid))*calibs.gain(capid));
      capid=digi[maxI+1].capid();
      float t2 = fabs((tool[maxI+1]-calibs.pedestal(capid))*calibs.gain(capid));    
      float wpksamp = (t0 + maxA + t2);
      if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp; 
      time = (maxI - digi.presamples())*25.0 + timeshift_ns_hf(wpksamp);

      if (corr!=0) {
        // Apply phase-based amplitude correction:
        ampl *= corr->getCorrection(fc_ampl);
        //      std::cout << fc_ampl << " --> " << corr->getCorrection(fc_ampl) << std::endl;
      }

    
      if (slewCorrect) time-=CastorTimeSlew::delay(std::max(1.0,fc_ampl),slewFlavor);
    }
    return RecHit(digi.id(),ampl,time);    
  }