CMS 3D CMS Logo

Functions

HcalSimpleRecAlgoImpl Namespace Reference

Functions

template<class Digi , class RecHit >
RecHit reco (const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, int ifirst, int n, bool slewCorrect, bool pulseCorrect, const HcalPulseContainmentCorrection *corr, HcalTimeSlew::BiasSetting slewFlavor, bool forData, bool useLeak)

Function Documentation

template<class Digi , class RecHit >
RecHit HcalSimpleRecAlgoImpl::reco ( const Digi &  digi,
const HcalCoder coder,
const HcalCalibrations calibs,
int  ifirst,
int  n,
bool  slewCorrect,
bool  pulseCorrect,
const HcalPulseContainmentCorrection corr,
HcalTimeSlew::BiasSetting  slewFlavor,
bool  forData,
bool  useLeak 
) [inline]

Definition at line 72 of file HcalSimpleRecAlgo.cc.

References HcalCoder::adc2fC(), HcalTimeSlew::delay(), eCorr(), HcalPulseContainmentCorrection::getCorrection(), i, HcalDetId::ieta(), leakCorr(), LogDebug, max(), findQualityFiles::maxI, HcalCalibrations::pedestal(), HcalCalibrations::respcorrgain(), CaloSamples::size(), cond::rpcobgas::time, HcalCalibrations::timecorr(), and timeshift_ns_hbheho().

                                                                                     {
    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.respcorrgain(capid) ; // fC --> GeV
      ampl+=ta;
      if(ta>maxA){
        maxA=ta;
        maxI=i;
      }
    }

    float time = -9999;
    if(maxI==0 || maxI==(tool.size()-1)) {      
      LogDebug("HCAL Pulse") << "HcalSimpleRecAlgo::reconstruct :" 
                                               << " Invalid max amplitude position, " 
                                               << " max Amplitude: "<< maxI
                                               << " first: "<<ifirst
                                               << " last: "<<(tool.size()-1)
                                               << std::endl;
    } else {
      int capid=digi[maxI-1].capid();
      float t0 = ((tool[maxI-1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
      capid=digi[maxI+1].capid();
      float t2 = ((tool[maxI+1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );

      // Handle negative excursions by moving "zero":
      float minA=t0;
      if (maxA<minA) minA=maxA;
      if (t2<minA)   minA=t2;
      if (minA<0) { maxA-=minA; t0-=minA; t2-=minA; } // positivizes all samples

      float wpksamp = (t0 + maxA + t2);
      if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp; 
      time = (maxI - digi.presamples())*25.0 + timeshift_ns_hbheho(wpksamp);
      if (corr!=0 && pulseCorrect ) {
        // Apply phase-based amplitude correction:

        /*
        HcalDetId cell(digi.id());
        int ieta  = cell.ieta();
        int iphi  = cell.iphi();
        int depth = cell.depth();
        std::cout << "HcalSimpleRecAlgo::reco  cell:  ieta, iphi, depth =  " 
                  << ieta << ", " << iphi
                  << ", " << depth 
                  << "    first, toadd = " << ifirst << ", " << n << std::endl
                  << "    ampl,  corr,  ampl_after_corr = "
                  << ampl << ",   " << corr->getCorrection(fc_ampl)
                  << ",   "
                  << ampl * corr->getCorrection(fc_ampl) << std::endl;
        */

        ampl *= corr->getCorrection(fc_ampl);

      }
      if (slewCorrect) time-=HcalTimeSlew::delay(std::max(1.0,fc_ampl),slewFlavor);

      time=time-calibs.timecorr(); // time calibration
    }


    // Temoprary hack to apply energy-dependent corrections to some HB- cells
    if(forData) {
      HcalDetId cell(digi.id());
      int ieta  = cell.ieta();
      int iphi  = cell.iphi();
      ampl *= eCorr(ieta,iphi,ampl);
    }

    // Correction for a leak to pre-sample
    if(useLeak) {
      ampl *= leakCorr(ampl); 
    }


    return RecHit(digi.id(),ampl,time);    
  }