CMS 3D CMS Logo

Public Member Functions | Private Attributes

HcalSimpleRecAlgo Class Reference

#include <HcalSimpleRecAlgo.h>

List of all members.

Public Member Functions

void beginRun (edm::EventSetup const &es)
void endRun ()
 HcalSimpleRecAlgo ()
 HcalSimpleRecAlgo (bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs)
void initPulseCorr (int toadd)
HBHERecHit reconstruct (const HBHEDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
HFRecHit reconstruct (const HFDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
HORecHit reconstruct (const HODataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
HcalCalibRecHit reconstruct (const HcalCalibDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
HBHERecHit reconstructHBHEUpgrade (const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
HFRecHit reconstructHFUpgrade (const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
void setForData ()
void setLeakCorrection ()
void setRecoParams (bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS)

Private Attributes

bool correctForPulse_
bool correctForTimeslew_
float phaseNS_
int pileupCleaningID_
std::auto_ptr
< HcalPulseContainmentManager
pulseCorr_
bool setForData_
bool setLeakCorrection_

Detailed Description

This class reconstructs RecHits from Digis for HBHE, HF, and HO by addition of selected time samples, pedestal subtraction, and gain application. The time of the hit is reconstructed using a weighted peak bin calculation supplemented by precise time lookup table. A consumer of this class also has the option of correcting the reconstructed time for energy-dependent time slew associated with the QIE.

Date:
2013/04/26 15:49:44
Revision:
1.18
Author:
J. Mans - Minnesota

Definition at line 33 of file HcalSimpleRecAlgo.h.


Constructor & Destructor Documentation

HcalSimpleRecAlgo::HcalSimpleRecAlgo ( bool  correctForTimeslew,
bool  correctForContainment,
float  fixedPhaseNs 
)

Full featured constructor for HB/HE and HO (HPD-based detectors)

Definition at line 12 of file HcalSimpleRecAlgo.cc.

References MaximumFractionalError, and pulseCorr_.

                                                                                                 : 
  correctForTimeslew_(correctForTimeslew),
  correctForPulse_(correctForPulse),
  phaseNS_(phaseNS), setForData_(false), setLeakCorrection_(false)
{ 
  
  pulseCorr_ = std::auto_ptr<HcalPulseContainmentManager>(
               new HcalPulseContainmentManager(MaximumFractionalError)
                                                          );
}
HcalSimpleRecAlgo::HcalSimpleRecAlgo ( )

Simple constructor for PMT-based detectors

Definition at line 24 of file HcalSimpleRecAlgo.cc.

                                     : 
  correctForTimeslew_(false), setForData_(false) { }

Member Function Documentation

void HcalSimpleRecAlgo::beginRun ( edm::EventSetup const &  es)

Definition at line 28 of file HcalSimpleRecAlgo.cc.

References pulseCorr_.

Referenced by HcalSimpleReconstructor::beginRun(), and HcalHitReconstructor::beginRun().

{
  pulseCorr_->beginRun(es);
}
void HcalSimpleRecAlgo::endRun ( void  )

Definition at line 34 of file HcalSimpleRecAlgo.cc.

References pulseCorr_.

Referenced by HcalHitReconstructor::endRun(), and HcalSimpleReconstructor::endRun().

{
  pulseCorr_->endRun();
}
void HcalSimpleRecAlgo::initPulseCorr ( int  toadd)

Definition at line 40 of file HcalSimpleRecAlgo.cc.

                                               {
}
HFRecHit HcalSimpleRecAlgo::reconstruct ( const HFDataFrame digi,
int  first,
int  toadd,
const HcalCoder coder,
const HcalCalibrations calibs 
) const

Definition at line 205 of file HcalSimpleRecAlgo.cc.

References HcalCoder::adc2fC(), corr, correctForPulse_, correctForTimeslew_, alignCSCRings::e, create_public_lumi_plots::exp, f, HcalPulseContainmentCorrection::getCorrection(), i, HFDataFrame::id(), LogDebug, findQualityFiles::maxI, min, HcalCalibrations::pedestal(), phaseNS_, HFDataFrame::presamples(), pulseCorr_, HcalCalibrations::respcorrgain(), CaloSamples::size(), cond::rpcobgas::time, HcalCalibrations::timecorr(), and timeshift_ns_hf().

                                                                                                                                                   {

  const HcalPulseContainmentCorrection* corr = pulseCorr_->get(digi.id(), toadd, phaseNS_);

  CaloSamples tool;
  coder.adc2fC(digi,tool);
  
  double ampl=0; int maxI = -1; double maxA = -1e10; float ta=0; float amp_fC=0;
  for (int i=first; i<tool.size() && i<first+toadd; i++) {
    int capid=digi[i].capid();
    ta = (tool[i]-calibs.pedestal(capid))*calibs.respcorrgain(capid);
    ampl+=ta;
    amp_fC += tool[i]-calibs.pedestal(capid);
    if(ta>maxA){
      maxA=ta;
      maxI=i;
    }
  }

  float time=-9999.0;
  if(maxI==0 || maxI==(tool.size()-1)) {
      LogDebug("HCAL Pulse") << "HcalSimpleRecAlgo::reconstruct :" 
                                               << " Invalid max amplitude position, " 
                                               << " max Amplitude: "<< maxI
                                               << " first: "<< first
                                               << " 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 zerocorr=std::min(t0,t2);
    if (zerocorr<0.f) {
      t0   -= zerocorr;
      t2   -= zerocorr;
      maxA -= zerocorr;
    }
    
    // pair the peak with the larger of the two neighboring time samples
    float wpksamp=0.f;
    if (t0>t2) {
      wpksamp = t0+maxA;
      if (wpksamp != 0.f) wpksamp = maxA/wpksamp;
    } else {
      wpksamp = maxA+t2;
      if (wpksamp != 0.f) wpksamp = 1.+(t2/wpksamp);
    }

    time = (maxI - digi.presamples())*25.0 + timeshift_ns_hf(wpksamp);

    if (corr!=0 && correctForPulse_) { 
      
      // Apply phase-based amplitude correction:
      
      /*
        HcalDetId cell(digi.id());
        int ieta  = cell.ieta();
        int iphi  = cell.iphi();
        int depth = cell.depth();
        std::cout << "*** 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(amp_fC);
    }

    if (correctForTimeslew_ && (amp_fC>0)) {
      // -5.12327 - put in calibs.timecorr()
      double tslew=exp(0.337681-5.94689e-4*amp_fC)+exp(2.44628-1.34888e-2*amp_fC);
      time -= (float)tslew;
    }

    time=time-calibs.timecorr();
  }

  return HFRecHit(digi.id(),ampl,time); 
}
HORecHit HcalSimpleRecAlgo::reconstruct ( const HODataFrame digi,
int  first,
int  toadd,
const HcalCoder coder,
const HcalCalibrations calibs 
) const

Definition at line 170 of file HcalSimpleRecAlgo.cc.

References correctForPulse_, correctForTimeslew_, first, phaseNS_, pulseCorr_, setForData_, and HcalTimeSlew::Slow.

                                                                                                                                                   {
  return HcalSimpleRecAlgoImpl::reco<HODataFrame,HORecHit>(digi,coder,calibs,
                                                           first,toadd,correctForTimeslew_,correctForPulse_,
                                                           pulseCorr_->get(digi.id(), toadd, phaseNS_),
                                                           HcalTimeSlew::Slow,
                                                           setForData_, false);
}
HcalCalibRecHit HcalSimpleRecAlgo::reconstruct ( const HcalCalibDataFrame digi,
int  first,
int  toadd,
const HcalCoder coder,
const HcalCalibrations calibs 
) const

Definition at line 178 of file HcalSimpleRecAlgo.cc.

References correctForPulse_, correctForTimeslew_, HcalTimeSlew::Fast, first, phaseNS_, pulseCorr_, and setForData_.

                                                                                                                                                                 {
  return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame,HcalCalibRecHit>(digi,coder,calibs,
                                                                         first,toadd,correctForTimeslew_,correctForPulse_,
                                                                         pulseCorr_->get(digi.id(), toadd, phaseNS_),
                                                                         HcalTimeSlew::Fast,
                                                                         setForData_, false );
}
HBHERecHit HcalSimpleRecAlgo::reconstruct ( const HBHEDataFrame digi,
int  first,
int  toadd,
const HcalCoder coder,
const HcalCalibrations calibs 
) const

Definition at line 162 of file HcalSimpleRecAlgo.cc.

References correctForPulse_, correctForTimeslew_, first, HcalTimeSlew::Medium, phaseNS_, pulseCorr_, setForData_, and setLeakCorrection_.

Referenced by HcalSimpleReconstructor::process(), and HcalHitReconstructor::produce().

                                                                                                                                                       {
  return HcalSimpleRecAlgoImpl::reco<HBHEDataFrame,HBHERecHit>(digi,coder,calibs,
                                                               first,toadd,correctForTimeslew_, correctForPulse_,
                                                               pulseCorr_->get(digi.id(), toadd, phaseNS_),
                                                               HcalTimeSlew::Medium,
                                                               setForData_, setLeakCorrection_);
}
HBHERecHit HcalSimpleRecAlgo::reconstructHBHEUpgrade ( const HcalUpgradeDataFrame digi,
int  first,
int  toadd,
const HcalCoder coder,
const HcalCalibrations calibs 
) const

Definition at line 197 of file HcalSimpleRecAlgo.cc.

References correctForPulse_, correctForTimeslew_, first, HcalTimeSlew::Medium, phaseNS_, pulseCorr_, HcalTDCReco::reconstruct(), query::result, and EcalTBTDCReconstructor_cfi::tdcReco.

Referenced by HcalSimpleReconstructor::processUpgrade().

                                                                                                                                                                         {
  HBHERecHit result = HcalSimpleRecAlgoImpl::reco<HcalUpgradeDataFrame,HBHERecHit>( digi, coder, calibs, first, toadd, correctForTimeslew_, correctForPulse_, pulseCorr_->get(digi.id(), toadd, phaseNS_), HcalTimeSlew::Medium, false, false);
  HcalTDCReco tdcReco;
  tdcReco.reconstruct(digi, result);
  return result;
}
HFRecHit HcalSimpleRecAlgo::reconstructHFUpgrade ( const HcalUpgradeDataFrame digi,
int  first,
int  toadd,
const HcalCoder coder,
const HcalCalibrations calibs 
) const

Definition at line 294 of file HcalSimpleRecAlgo.cc.

References HcalCoder::adc2fC(), corr, correctForPulse_, correctForTimeslew_, alignCSCRings::e, create_public_lumi_plots::exp, f, HcalPulseContainmentCorrection::getCorrection(), i, HcalUpgradeDataFrame::id(), LogDebug, findQualityFiles::maxI, min, HcalCalibrations::pedestal(), phaseNS_, HcalUpgradeDataFrame::presamples(), pulseCorr_, HcalCalibrations::respcorrgain(), CaloSamples::size(), cond::rpcobgas::time, HcalCalibrations::timecorr(), and timeshift_ns_hf().

Referenced by HcalSimpleReconstructor::processUpgrade().

                                                                                                                                                                     {

  const HcalPulseContainmentCorrection* corr = pulseCorr_->get(digi.id(), toadd, phaseNS_);

  CaloSamples tool;
  coder.adc2fC(digi,tool);
  
  double ampl=0; int maxI = -1; double maxA = -1e10; float ta=0; float amp_fC=0;
  for (int i=first; i<tool.size() && i<first+toadd; i++) {
    int capid=digi[i].capid(); 
    ta = (tool[i]-calibs.pedestal(capid))*calibs.respcorrgain(capid);
    ampl+=ta;
    amp_fC += tool[i]-calibs.pedestal(capid);
    if(ta>maxA){
      maxA=ta;
      maxI=i;
    }
  }

  float time=-9999.0;
  if(maxI==0 || maxI==(tool.size()-1)) {
      LogDebug("HCAL Pulse") << "HcalSimpleRecAlgo::reconstruct :" 
                                               << " Invalid max amplitude position, " 
                                               << " max Amplitude: "<< maxI
                                               << " first: "<< first
                                               << " 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 zerocorr=std::min(t0,t2);
    if (zerocorr<0.f) {
      t0   -= zerocorr;
      t2   -= zerocorr;
      maxA -= zerocorr;
    }
    
    // pair the peak with the larger of the two neighboring time samples
    float wpksamp=0.f;
    if (t0>t2) {
      wpksamp = t0+maxA;
      if (wpksamp != 0.f) wpksamp = maxA/wpksamp;
    } else {
      wpksamp = maxA+t2;
      if (wpksamp != 0.f) wpksamp = 1.+(t2/wpksamp);
    }

    time = (maxI - digi.presamples())*25.0 + timeshift_ns_hf(wpksamp);

    if (corr!=0 && correctForPulse_) { 
      
      // Apply phase-based amplitude correction:
      
      /*
        HcalDetId cell(digi.id());
        int ieta  = cell.ieta();
        int iphi  = cell.iphi();
        int depth = cell.depth();
        std::cout << "*** 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(amp_fC);
    }

    if (correctForTimeslew_ && (amp_fC>0)) {
      // -5.12327 - put in calibs.timecorr()
      double tslew=exp(0.337681-5.94689e-4*amp_fC)+exp(2.44628-1.34888e-2*amp_fC);
      time -= (float)tslew;
    }

    time=time-calibs.timecorr();
  }

  return HFRecHit(digi.id(),ampl,time); // new RecHit gets second time = 0.

}
void HcalSimpleRecAlgo::setForData ( )

Definition at line 51 of file HcalSimpleRecAlgo.cc.

References setForData_.

Referenced by HcalSimpleReconstructor::produce(), and HcalHitReconstructor::produce().

{ setForData_ = true;}
void HcalSimpleRecAlgo::setLeakCorrection ( )

Definition at line 53 of file HcalSimpleRecAlgo.cc.

References setLeakCorrection_.

Referenced by HcalHitReconstructor::produce(), and setRecoParams().

{ setLeakCorrection_ = true;}
void HcalSimpleRecAlgo::setRecoParams ( bool  correctForTimeslew,
bool  correctForPulse,
bool  setLeakCorrection,
int  pileupCleaningID,
float  phaseNS 
)

Member Data Documentation

float HcalSimpleRecAlgo::phaseNS_ [private]

Definition at line 71 of file HcalSimpleRecAlgo.h.

Referenced by setRecoParams().

Definition at line 69 of file HcalSimpleRecAlgo.h.

Referenced by reconstruct(), and setForData().

Definition at line 70 of file HcalSimpleRecAlgo.h.

Referenced by reconstruct(), setLeakCorrection(), and setRecoParams().