CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

EcalUncalibRecHitWorkerGlobal Class Reference

#include <EcalUncalibRecHitWorkerGlobal.h>

Inheritance diagram for EcalUncalibRecHitWorkerGlobal:
EcalUncalibRecHitWorkerBaseClass

List of all members.

Public Member Functions

 EcalUncalibRecHitWorkerGlobal (const edm::ParameterSet &)
bool run (const edm::Event &evt, const EcalDigiCollection::const_iterator &digi, EcalUncalibratedRecHitCollection &result)
void set (const edm::EventSetup &es)
virtual ~EcalUncalibRecHitWorkerGlobal ()

Protected Member Functions

template<class C >
int isSaturated (const C &digi)
double timeCorrectionEB (float ampliEB)
double timeCorrectionEE (float ampliEE)

Protected Attributes

double amplitudeThreshEB_
double amplitudeThreshEE_
const
EcalWeightSet::EcalChi2WeightMatrix
chi2mat [2]
double chi2ThreshEB_
double chi2ThreshEE_
bool doEBtimeCorrection_
bool doEEtimeCorrection_
std::vector< double > EBamplitudeFitParameters_
std::vector< double > EBchi2Parameters_
std::vector< double > ebPulseShape_
double ebSpikeThresh_
double EBtimeConstantTerm_
std::vector< double > EBtimeCorrAmplitudeBins_
std::vector< double > EBtimeCorrShiftBins_
std::pair< double, double > EBtimeFitLimits_
std::vector< double > EBtimeFitParameters_
double EBtimeNconst_
std::vector< double > EEamplitudeFitParameters_
std::vector< double > EEchi2Parameters_
std::vector< double > eePulseShape_
double EEtimeConstantTerm_
std::vector< double > EEtimeCorrAmplitudeBins_
std::vector< double > EEtimeCorrShiftBins_
std::pair< double, double > EEtimeFitLimits_
std::vector< double > EEtimeFitParameters_
double EEtimeNconst_
double gainRatios [3]
edm::ESHandle< EcalGainRatiosgains
edm::ESHandle
< EcalWeightXtalGroups
grps
edm::ESHandle
< EcalTimeCalibConstants
itime
bool kPoorRecoFlagEB_
bool kPoorRecoFlagEE_
EcalUncalibRecHitLeadingEdgeAlgo
< EBDataFrame
leadingEdgeMethod_barrel_
EcalUncalibRecHitLeadingEdgeAlgo
< EEDataFrame
leadingEdgeMethod_endcap_
double outOfTimeThreshG12mEB_
double outOfTimeThreshG12mEE_
double outOfTimeThreshG12pEB_
double outOfTimeThreshG12pEE_
double outOfTimeThreshG61mEB_
double outOfTimeThreshG61mEE_
double outOfTimeThreshG61pEB_
double outOfTimeThreshG61pEE_
double pedRMSVec [3]
edm::ESHandle< EcalPedestalspeds
double pedVec [3]
EcalUncalibRecHitRatioMethodAlgo
< EBDataFrame
ratioMethod_barrel_
EcalUncalibRecHitRatioMethodAlgo
< EEDataFrame
ratioMethod_endcap_
const EBShape testbeamEBShape
const EEShape testbeamEEShape
const
EcalWeightSet::EcalWeightMatrix
weights [2]
EcalUncalibRecHitRecWeightsAlgo
< EBDataFrame
weightsMethod_barrel_
EcalUncalibRecHitRecWeightsAlgo
< EEDataFrame
weightsMethod_endcap_
edm::ESHandle< EcalTBWeightswgts

Detailed Description

Definition at line 35 of file EcalUncalibRecHitWorkerGlobal.h.


Constructor & Destructor Documentation

EcalUncalibRecHitWorkerGlobal::EcalUncalibRecHitWorkerGlobal ( const edm::ParameterSet ps)

Definition at line 14 of file EcalUncalibRecHitWorkerGlobal.cc.

References amplitudeThreshEB_, amplitudeThreshEE_, chi2ThreshEB_, chi2ThreshEE_, doEBtimeCorrection_, doEEtimeCorrection_, EBamplitudeFitParameters_, EBchi2Parameters_, ebPulseShape_, ebSpikeThresh_, EBtimeConstantTerm_, EBtimeCorrAmplitudeBins_, EBtimeCorrShiftBins_, EBtimeFitLimits_, EBtimeFitParameters_, EBtimeNconst_, EEamplitudeFitParameters_, EEchi2Parameters_, eePulseShape_, EEtimeConstantTerm_, EEtimeCorrAmplitudeBins_, EEtimeCorrShiftBins_, EEtimeFitLimits_, EEtimeFitParameters_, EEtimeNconst_, edm::ParameterSet::getParameter(), kPoorRecoFlagEB_, kPoorRecoFlagEE_, outOfTimeThreshG12mEB_, outOfTimeThreshG12mEE_, outOfTimeThreshG12pEB_, outOfTimeThreshG12pEE_, outOfTimeThreshG61mEB_, outOfTimeThreshG61mEE_, outOfTimeThreshG61pEB_, and outOfTimeThreshG61pEE_.

                                                                                     :
        EcalUncalibRecHitWorkerBaseClass(ps)
{
        // ratio method parameters
        EBtimeFitParameters_ = ps.getParameter<std::vector<double> >("EBtimeFitParameters"); 
        EEtimeFitParameters_ = ps.getParameter<std::vector<double> >("EEtimeFitParameters"); 
        EBamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EBamplitudeFitParameters");
        EEamplitudeFitParameters_ = ps.getParameter<std::vector<double> >("EEamplitudeFitParameters");
        EBtimeFitLimits_.first  = ps.getParameter<double>("EBtimeFitLimits_Lower");
        EBtimeFitLimits_.second = ps.getParameter<double>("EBtimeFitLimits_Upper");
        EEtimeFitLimits_.first  = ps.getParameter<double>("EEtimeFitLimits_Lower");
        EEtimeFitLimits_.second = ps.getParameter<double>("EEtimeFitLimits_Upper");
        EBtimeConstantTerm_=ps.getParameter<double>("EBtimeConstantTerm");
        EBtimeNconst_=ps.getParameter<double>("EBtimeNconst");
        EEtimeConstantTerm_=ps.getParameter<double>("EEtimeConstantTerm");
        EEtimeNconst_=ps.getParameter<double>("EEtimeNconst");
        outOfTimeThreshG12pEB_ = ps.getParameter<double>("outOfTimeThresholdGain12pEB");
        outOfTimeThreshG12mEB_ = ps.getParameter<double>("outOfTimeThresholdGain12mEB");
        outOfTimeThreshG61pEB_ = ps.getParameter<double>("outOfTimeThresholdGain61pEB");
        outOfTimeThreshG61mEB_ = ps.getParameter<double>("outOfTimeThresholdGain61mEB");
        outOfTimeThreshG12pEE_ = ps.getParameter<double>("outOfTimeThresholdGain12pEE");
        outOfTimeThreshG12mEE_ = ps.getParameter<double>("outOfTimeThresholdGain12mEE");
        outOfTimeThreshG61pEE_ = ps.getParameter<double>("outOfTimeThresholdGain61pEE");
        outOfTimeThreshG61mEE_ = ps.getParameter<double>("outOfTimeThresholdGain61mEE");
        amplitudeThreshEB_ = ps.getParameter<double>("amplitudeThresholdEB");
        amplitudeThreshEE_ = ps.getParameter<double>("amplitudeThresholdEE");
        // amplitude-dependent correction of time
        doEBtimeCorrection_      = ps.getParameter<bool>("doEBtimeCorrection");
        doEEtimeCorrection_      = ps.getParameter<bool>("doEEtimeCorrection");
        EBtimeCorrAmplitudeBins_ = ps.getParameter<std::vector<double> >("EBtimeCorrAmplitudeBins"); 
        EBtimeCorrShiftBins_     = ps.getParameter<std::vector<double> >("EBtimeCorrShiftBins"); 
        EEtimeCorrAmplitudeBins_ = ps.getParameter<std::vector<double> >("EEtimeCorrAmplitudeBins"); 
        EEtimeCorrShiftBins_     = ps.getParameter<std::vector<double> >("EEtimeCorrShiftBins"); 
        if(EBtimeCorrAmplitudeBins_.size() != EBtimeCorrShiftBins_.size()) {
          doEBtimeCorrection_ = false;
          edm::LogError("EcalRecHitError") << "Size of EBtimeCorrAmplitudeBins different from EBtimeCorrShiftBins. Forcing no time corrections for EB. ";
        }
        if(EEtimeCorrAmplitudeBins_.size() != EEtimeCorrShiftBins_.size()) {
          doEEtimeCorrection_ = false;
          edm::LogError("EcalRecHitError") << "Size of EEtimeCorrAmplitudeBins different from EEtimeCorrShiftBins. Forcing no time corrections for EE. ";
        }

        // spike threshold
        ebSpikeThresh_ = ps.getParameter<double>("ebSpikeThreshold");
        // leading edge parameters
        ebPulseShape_ = ps.getParameter<std::vector<double> >("ebPulseShape");
        eePulseShape_ = ps.getParameter<std::vector<double> >("eePulseShape");
        // chi2 parameters
        kPoorRecoFlagEB_ = ps.getParameter<bool>("kPoorRecoFlagEB");
        kPoorRecoFlagEE_ = ps.getParameter<bool>("kPoorRecoFlagEE");;
        chi2ThreshEB_=ps.getParameter<double>("chi2ThreshEB_");
        chi2ThreshEE_=ps.getParameter<double>("chi2ThreshEE_");
        EBchi2Parameters_ = ps.getParameter<std::vector<double> >("EBchi2Parameters");
        EEchi2Parameters_ = ps.getParameter<std::vector<double> >("EEchi2Parameters");
}
virtual EcalUncalibRecHitWorkerGlobal::~EcalUncalibRecHitWorkerGlobal ( ) [inline, virtual]

Definition at line 39 of file EcalUncalibRecHitWorkerGlobal.h.

{};

Member Function Documentation

template<class C >
int EcalUncalibRecHitWorkerGlobal::isSaturated ( const C &  digi) [protected]

Definition at line 90 of file EcalUncalibRecHitWorkerGlobal.cc.

References i, and j.

{
        //bool saturated_ = 0;
        int cnt;
        for (int j = 0; j < C::MAXSAMPLES - 5; ++j) {
                cnt = 0;
                for (int i = j; i < (j + 5) && i < C::MAXSAMPLES; ++i) {
                        if ( dataFrame.sample(i).gainId() == 0 ) ++cnt;
                }
                if ( cnt == 5 ) return j-1 ; // the last unsaturated sample
        }
        return -1; // no saturation found
}
bool EcalUncalibRecHitWorkerGlobal::run ( const edm::Event evt,
const EcalDigiCollection::const_iterator digi,
EcalUncalibratedRecHitCollection result 
) [virtual]

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 183 of file EcalUncalibRecHitWorkerGlobal.cc.

References amplitudeThreshEB_, amplitudeThreshEE_, ExpressReco_HICollisions_FallBack::chi2, EcalUncalibRecHitRecChi2Algo< C >::chi2(), EcalUncalibRecHitRecChi2Algo< C >::chi2OutOfTime(), chi2ThreshEB_, chi2ThreshEE_, EcalUncalibRecHitRatioMethodAlgo< C >::computeAmplitude(), EcalUncalibRecHitRatioMethodAlgo< C >::computeTime(), cond::rpcobgas::detid, doEBtimeCorrection_, doEEtimeCorrection_, EBamplitudeFitParameters_, EBchi2Parameters_, ebPulseShape_, EBtimeConstantTerm_, EBtimeFitLimits_, EBtimeFitParameters_, EBtimeNconst_, EcalBarrel, EcalEndcap, EEamplitudeFitParameters_, EEchi2Parameters_, eePulseShape_, EEtimeConstantTerm_, EEtimeFitLimits_, EEtimeFitParameters_, EEtimeNconst_, EcalMGPAGainRatio::gain12Over6(), EcalMGPAGainRatio::gain6Over1(), gainRatios, gains, EcalUncalibRecHitRatioMethodAlgo< C >::getCalculatedRecHit(), EcalWeightSet::getWeightsAfterGainSwitch(), EcalWeightSet::getWeightsBeforeGainSwitch(), grps, EEDetId::hashedIndex(), ecalpyutils::hashedIndex(), EBDetId::hashedIndex(), EcalXtalGroupId::id(), EcalUncalibRecHitRatioMethodAlgo< C >::init(), itime, EcalUncalibratedRecHit::kLeadingEdgeRecovered, EcalUncalibratedRecHit::kOutOfTime, EcalUncalibratedRecHit::kPoorReco, kPoorRecoFlagEB_, kPoorRecoFlagEE_, EcalUncalibratedRecHit::kSaturated, leadingEdgeMethod_barrel_, leadingEdgeMethod_endcap_, EcalUncalibRecHitLeadingEdgeAlgo< C >::makeRecHit(), EcalUncalibRecHitRecWeightsAlgo< C >::makeRecHit(), EcalDataFrame::MAXSAMPLES, outOfTimeThreshG12mEB_, outOfTimeThreshG12mEE_, outOfTimeThreshG12pEB_, outOfTimeThreshG12pEE_, outOfTimeThreshG61mEB_, outOfTimeThreshG61mEE_, outOfTimeThreshG61pEB_, outOfTimeThreshG61pEE_, pedRMSVec, peds, pedVec, funct::pow(), edm::SortedCollection< T, SORT >::push_back(), ratioMethod_barrel_, ratioMethod_endcap_, EcalUncalibRecHitLeadingEdgeAlgo< C >::setLeadingEdgeSample(), EcalUncalibRecHitLeadingEdgeAlgo< C >::setPulseShape(), EcalUncalibratedRecHit::setRecoFlag(), mathSSE::sqrt(), testbeamEBShape, testbeamEEShape, timeCorrectionEB(), timeCorrectionEE(), weights, weightsMethod_barrel_, weightsMethod_endcap_, and wgts.

{
        DetId detid(itdg->id());
        
        // intelligence for recHit computation
        EcalUncalibratedRecHit uncalibRecHit;
        
        
        const EcalPedestals::Item * aped = 0;
        const EcalMGPAGainRatio * aGain = 0;
        const EcalXtalGroupId * gid = 0;

        if (detid.subdetId()==EcalEndcap) {
                unsigned int hashedIndex = EEDetId(detid).hashedIndex();
                aped  = &peds->endcap(hashedIndex);
                aGain = &gains->endcap(hashedIndex);
                gid   = &grps->endcap(hashedIndex);
        } else {
                unsigned int hashedIndex = EBDetId(detid).hashedIndex();
                aped  = &peds->barrel(hashedIndex);
                aGain = &gains->barrel(hashedIndex);
                gid   = &grps->barrel(hashedIndex);
        }

        pedVec[0] = aped->mean_x12;
        pedVec[1] = aped->mean_x6;
        pedVec[2] = aped->mean_x1;
        pedRMSVec[0] = aped->rms_x12;
        pedRMSVec[1] = aped->rms_x6;
        pedRMSVec[2] = aped->rms_x1;
        gainRatios[0] = 1.;
        gainRatios[1] = aGain->gain12Over6();
        gainRatios[2] = aGain->gain6Over1()*aGain->gain12Over6();

        // compute the right bin of the pulse shape using time calibration constants
        EcalTimeCalibConstantMap::const_iterator it = itime->find( detid );
        EcalTimeCalibConstant itimeconst = 0;
        if( it != itime->end() ) {
                  itimeconst = (*it);
        } else {
                  edm::LogError("EcalRecHitError") << "No time intercalib const found for xtal "
                  << detid.rawId()
                  << "! something wrong with EcalTimeCalibConstants in your DB? ";
        }


        // === amplitude computation ===
        int leadingSample = -1;
        if (detid.subdetId()==EcalEndcap) {
                leadingSample = ((EcalDataFrame)(*itdg)).lastUnsaturatedSample();
        } else {
                leadingSample = ((EcalDataFrame)(*itdg)).lastUnsaturatedSample();
        }

        if ( leadingSample >= 0 ) { // saturation
                if ( leadingSample != 4 ) {
                        // all samples different from the fifth are not reliable for the amplitude estimation
                        // put by default the energy at the saturation threshold and flag as saturated
                        float sratio = 1;
                        if ( detid.subdetId()==EcalBarrel) {
                                sratio = ebPulseShape_[5] / ebPulseShape_[4];
                        } else {
                                sratio = eePulseShape_[5] / eePulseShape_[4];
                        }
                        uncalibRecHit = EcalUncalibratedRecHit( (*itdg).id(), 4095*12*sratio, 0, 0, 0);
                        uncalibRecHit.setRecoFlag( EcalUncalibratedRecHit::kSaturated );
                } else {
                        // float clockToNsConstant = 25.;
                        // reconstruct the rechit
                        if (detid.subdetId()==EcalEndcap) {
                                leadingEdgeMethod_endcap_.setPulseShape( eePulseShape_ );
                                // float mult = (float)eePulseShape_.size() / (float)(*itdg).size();
                                // bin (or some analogous mapping) will be used instead of the leadingSample
                                //int bin  = (int)(( (mult * leadingSample + mult/2) * clockToNsConstant + itimeconst ) / clockToNsConstant);
                                // bin is not uset for the moment
                                leadingEdgeMethod_endcap_.setLeadingEdgeSample( leadingSample );
                                uncalibRecHit = leadingEdgeMethod_endcap_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
                                uncalibRecHit.setRecoFlag( EcalUncalibratedRecHit::kLeadingEdgeRecovered );
                                leadingEdgeMethod_endcap_.setLeadingEdgeSample( -1 );
                        } else {
                                leadingEdgeMethod_barrel_.setPulseShape( ebPulseShape_ );
                                // float mult = (float)ebPulseShape_.size() / (float)(*itdg).size();
                                // bin (or some analogous mapping) will be used instead of the leadingSample
                                //int bin  = (int)(( (mult * leadingSample + mult/2) * clockToNsConstant + itimeconst ) / clockToNsConstant);
                                // bin is not uset for the moment
                                leadingEdgeMethod_barrel_.setLeadingEdgeSample( leadingSample );
                                uncalibRecHit = leadingEdgeMethod_barrel_.makeRecHit(*itdg, pedVec, gainRatios, 0, 0);
                                uncalibRecHit.setRecoFlag( EcalUncalibratedRecHit::kLeadingEdgeRecovered );
                                leadingEdgeMethod_barrel_.setLeadingEdgeSample( -1 );
                        }
                }

                uncalibRecHit.setChi2(0);         // do not propagate the default chi2 = -1 value to the calib rechit (mapped to 64), set it to 0 when saturation
                uncalibRecHit.setOutOfTimeChi2(0);
        } else {
                // weights method
                EcalTBWeights::EcalTDCId tdcid(1);
                EcalTBWeights::EcalTBWeightMap const & wgtsMap = wgts->getMap();
                EcalTBWeights::EcalTBWeightMap::const_iterator wit;
                wit = wgtsMap.find( std::make_pair(*gid,tdcid) );
                if( wit == wgtsMap.end() ) {
                        edm::LogError("EcalUncalibRecHitError") << "No weights found for EcalGroupId: " 
                                << gid->id() << " and  EcalTDCId: " << tdcid
                                << "\n  skipping digi with id: " << detid.rawId();

                        return false;
                }
                const EcalWeightSet& wset = wit->second; // this is the EcalWeightSet

                const EcalWeightSet::EcalWeightMatrix& mat1 = wset.getWeightsBeforeGainSwitch();
                const EcalWeightSet::EcalWeightMatrix& mat2 = wset.getWeightsAfterGainSwitch();

                weights[0] = &mat1;
                weights[1] = &mat2;

                // get uncalibrated recHit from weights
                if (detid.subdetId()==EcalEndcap) {
                     uncalibRecHit = weightsMethod_endcap_.makeRecHit(*itdg, pedVec, pedRMSVec, gainRatios, weights, testbeamEEShape);
                } else {
                     uncalibRecHit = weightsMethod_barrel_.makeRecHit(*itdg, pedVec, pedRMSVec, gainRatios, weights, testbeamEBShape);
                }

                // === time computation ===
                // ratio method
                float const clockToNsConstant = 25.;
                if (detid.subdetId()==EcalEndcap) {
                                ratioMethod_endcap_.init( *itdg, pedVec, pedRMSVec, gainRatios );
                                ratioMethod_endcap_.computeTime( EEtimeFitParameters_, EEtimeFitLimits_, EEamplitudeFitParameters_ );
                                ratioMethod_endcap_.computeAmplitude( EEamplitudeFitParameters_);
                                EcalUncalibRecHitRatioMethodAlgo<EEDataFrame>::CalculatedRecHit crh = ratioMethod_endcap_.getCalculatedRecHit();
                                double theTimeCorrectionEE=0;
                                if(doEEtimeCorrection_) theTimeCorrectionEE = timeCorrectionEE( uncalibRecHit.amplitude() );
                                uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEE);
                                uncalibRecHit.setJitterError( std::sqrt(pow(crh.timeError,2) + std::pow(EEtimeConstantTerm_,2)/std::pow(clockToNsConstant,2)) );
                                uncalibRecHit.setOutOfTimeEnergy( crh.amplitudeMax );
                                // consider flagging as kOutOfTime only if above noise
                                if (uncalibRecHit.amplitude() > pedRMSVec[0] * amplitudeThreshEE_){
                                  float outOfTimeThreshP = outOfTimeThreshG12pEE_;
                                  float outOfTimeThreshM = outOfTimeThreshG12mEE_;
                                  // determine if gain has switched away from gainId==1 (x12 gain)
                                  // and determine cuts (number of 'sigmas') to ose for kOutOfTime
                                  // >3k ADC is necessasry condition for gain switch to occur
                                  if (uncalibRecHit.amplitude() > 3000.){
                                    for (int iSample = 0; iSample < EEDataFrame::MAXSAMPLES; iSample++) {
                                      int GainId = ((EcalDataFrame)(*itdg)).sample(iSample).gainId();
                                      if (GainId!=1) {
                                        outOfTimeThreshP = outOfTimeThreshG61pEE_;
                                        outOfTimeThreshM = outOfTimeThreshG61mEE_;
                                        break;}
                                    }}
                                  float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst;
                                  float cterm         = EEtimeConstantTerm_;
                                  float sigmaped      = pedRMSVec[0];  // approx for lower gains
                                  float nterm         = EEtimeNconst_*sigmaped/uncalibRecHit.amplitude();
                                  float sigmat        = std::sqrt( nterm*nterm  + cterm*cterm   );
                                  if ( ( correctedTime > sigmat*outOfTimeThreshP )   ||
                                       ( correctedTime < (-1.*sigmat*outOfTimeThreshM) )) 
                                    {  uncalibRecHit.setRecoFlag( EcalUncalibratedRecHit::kOutOfTime ); }
                                }
                                
                } else {
                                ratioMethod_barrel_.init( *itdg, pedVec, pedRMSVec, gainRatios );
                                ratioMethod_barrel_.computeTime( EBtimeFitParameters_, EBtimeFitLimits_, EBamplitudeFitParameters_ );
                                ratioMethod_barrel_.computeAmplitude( EBamplitudeFitParameters_);
                                EcalUncalibRecHitRatioMethodAlgo<EBDataFrame>::CalculatedRecHit crh = ratioMethod_barrel_.getCalculatedRecHit();
                                double theTimeCorrectionEB=0;
                                if(doEBtimeCorrection_) theTimeCorrectionEB = timeCorrectionEB( uncalibRecHit.amplitude() );
                                // the correction for gain switch (when the sample before is ignored in ratioAlgo) is now included in the configurable correction
                                //      bool gainSwitch = ratioMethod_barrel_.fixMGPAslew(*itdg);
                                //      if(gainSwitch){
                                //        uncalibRecHit.setJitter( crh.timeMax - 5 - 0.04 + theTimeCorrectionEB);  // introduce additional 1ns shift
                                //      }else{
                                //        uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEB);
                                //      }
                                uncalibRecHit.setJitter( crh.timeMax - 5 + theTimeCorrectionEB);

                                uncalibRecHit.setJitterError( std::sqrt(std::pow(crh.timeError,2) + std::pow(EBtimeConstantTerm_,2)/std::pow(clockToNsConstant,2)) );
                                uncalibRecHit.setOutOfTimeEnergy( crh.amplitudeMax );
                                // consider flagging as kOutOfTime only if above noise
                                if (uncalibRecHit.amplitude() > pedRMSVec[0] * amplitudeThreshEB_){
                                  float outOfTimeThreshP = outOfTimeThreshG12pEB_;
                                  float outOfTimeThreshM = outOfTimeThreshG12mEB_;
                                  // determine if gain has switched away from gainId==1 (x12 gain)
                                  // and determine cuts (number of 'sigmas') to ose for kOutOfTime
                                  // >3k ADC is necessasry condition for gain switch to occur
                                  if (uncalibRecHit.amplitude() > 3000.){
                                    for (int iSample = 0; iSample < EBDataFrame::MAXSAMPLES; iSample++) {
                                      int GainId = ((EcalDataFrame)(*itdg)).sample(iSample).gainId();
                                      if (GainId!=1) {
                                        outOfTimeThreshP = outOfTimeThreshG61pEB_;
                                        outOfTimeThreshM = outOfTimeThreshG61mEB_;
                                        break;}
                                    } }
                                  float correctedTime = (crh.timeMax-5) * clockToNsConstant + itimeconst;
                                  float cterm         = EBtimeConstantTerm_;
                                  float sigmaped      = pedRMSVec[0];  // approx for lower gains
                                  float nterm         = EBtimeNconst_*sigmaped/uncalibRecHit.amplitude();
                                  float sigmat        = std::sqrt( nterm*nterm  + cterm*cterm   );
                                  if ( ( correctedTime > sigmat*outOfTimeThreshP )   ||
                                       ( correctedTime < (-1.*sigmat*outOfTimeThreshM) )) 
                                    {   uncalibRecHit.setRecoFlag( EcalUncalibratedRecHit::kOutOfTime );  }
                                }
                }

                // === chi2express ===
                if (detid.subdetId()==EcalEndcap) {
                      
                    double amplitude = uncalibRecHit.amplitude();
                    double amplitudeOutOfTime = uncalibRecHit.outOfTimeEnergy();
                    double jitter= uncalibRecHit.jitter();


                
                    EcalUncalibRecHitRecChi2Algo<EEDataFrame>chi2expressEE_(
                                                                            *itdg, 
                                                                            amplitude, 
                                                                            itimeconst, 
                                                                            amplitudeOutOfTime, 
                                                                            jitter, 
                                                                            pedVec, 
                                                                            pedRMSVec, 
                                                                            gainRatios, 
                                                                            testbeamEEShape,
                                                                            EEchi2Parameters_
                    );
                    double chi2 = chi2expressEE_.chi2();
                    uncalibRecHit.setChi2(chi2);
                    double chi2OutOfTime = chi2expressEE_.chi2OutOfTime();
                    uncalibRecHit.setOutOfTimeChi2(chi2OutOfTime);

                    if(kPoorRecoFlagEE_)
                    {
                        if(chi2>chi2ThreshEE_)uncalibRecHit.setRecoFlag(EcalUncalibratedRecHit::kPoorReco);
                    }                           
                        
                } else {
                    double amplitude = uncalibRecHit.amplitude();
                    double amplitudeOutOfTime = uncalibRecHit.outOfTimeEnergy();
                    double jitter= uncalibRecHit.jitter();
                  
                    EcalUncalibRecHitRecChi2Algo<EBDataFrame>chi2expressEB_(
                                                                            *itdg, 
                                                                            amplitude, 
                                                                            itimeconst, 
                                                                            amplitudeOutOfTime, 
                                                                            jitter, 
                                                                            pedVec, 
                                                                            pedRMSVec, 
                                                                            gainRatios, 
                                                                            testbeamEBShape,
                                                                            EBchi2Parameters_           
                    );
                    double chi2 = chi2expressEB_.chi2();
                    uncalibRecHit.setChi2(chi2);
                    double chi2OutOfTime = chi2expressEB_.chi2OutOfTime();
                    uncalibRecHit.setOutOfTimeChi2(chi2OutOfTime);

                    if(kPoorRecoFlagEB_)
                    {
                        if(chi2>chi2ThreshEB_)uncalibRecHit.setRecoFlag(EcalUncalibratedRecHit::kPoorReco);
                    }                           
                }
        }

        // remove setting of kFake, which can be misleading for the time being
        //if ( detid.subdetId()==EcalBarrel ) {
        //        if ( uncalibRecHit.jitter()*25. > -5 ) {
        //                EBDataFrame dt(*itdg);
        //                if ( dt.spikeEstimator() < ebSpikeThresh_ ) uncalibRecHit.setRecoFlag( EcalUncalibratedRecHit::kFake );
        //        }
        //}
        

        // put the recHit in the collection
        if (detid.subdetId()==EcalEndcap) {
                result.push_back( uncalibRecHit );
        } else {
                result.push_back( uncalibRecHit );
        }
        return true;
}
void EcalUncalibRecHitWorkerGlobal::set ( const edm::EventSetup es) [virtual]

Implements EcalUncalibRecHitWorkerBaseClass.

Definition at line 71 of file EcalUncalibRecHitWorkerGlobal.cc.

References gains, edm::EventSetup::get(), grps, itime, peds, and wgts.

{
        // common setup
        es.get<EcalGainRatiosRcd>().get(gains);
        es.get<EcalPedestalsRcd>().get(peds);

        // for the weights method
        es.get<EcalWeightXtalGroupsRcd>().get(grps);
        es.get<EcalTBWeightsRcd>().get(wgts);

        // for the ratio method

        // for the leading edge method
        es.get<EcalTimeCalibConstantsRcd>().get(itime);
}
double EcalUncalibRecHitWorkerGlobal::timeCorrectionEB ( float  ampliEB) [protected]

Definition at line 105 of file EcalUncalibRecHitWorkerGlobal.cc.

References newFWLiteAna::bin, EBtimeCorrAmplitudeBins_, and EBtimeCorrShiftBins_.

Referenced by run().

                                                                   {
  // computed initially in ns. Than turned in the BX's, as EcalUncalibratedRecHit need be.
  double theCorrection=0;

  
  int myBin = -1;
  for (int bin=0; bin<(int)EBtimeCorrAmplitudeBins_.size(); bin++ ){
    if(ampliEB > EBtimeCorrAmplitudeBins_.at(bin)) {
      myBin = bin;     }
    else break;
  }
  
  if (myBin == -1)
    {
      theCorrection = EBtimeCorrShiftBins_.at(0);
    }    
  else if  ( myBin == ((int)(EBtimeCorrAmplitudeBins_.size()-1))   ) 
    {
      theCorrection = EBtimeCorrShiftBins_.at( myBin );      
    }    
  else if  ( -1 < myBin   &&   myBin <  ((int)EBtimeCorrAmplitudeBins_.size()-1) )
    {
      // interpolate linearly between two assingned points
      theCorrection  = ( EBtimeCorrShiftBins_.at(myBin+1) - EBtimeCorrShiftBins_.at(myBin) );
      theCorrection *= ( ((double)ampliEB) -  EBtimeCorrAmplitudeBins_.at(myBin) ) / ( EBtimeCorrAmplitudeBins_.at(myBin+1) - EBtimeCorrAmplitudeBins_.at(myBin) );
      theCorrection += EBtimeCorrShiftBins_.at(myBin);
    }
  else
    {
      edm::LogError("EcalRecHitError") << "Assigning time correction impossible. Setting it to 0 ";
      theCorrection = 0.;
    }

  // convert ns into clocks
  return theCorrection/25.;
}
double EcalUncalibRecHitWorkerGlobal::timeCorrectionEE ( float  ampliEE) [protected]

Definition at line 143 of file EcalUncalibRecHitWorkerGlobal.cc.

References newFWLiteAna::bin, EEtimeCorrAmplitudeBins_, and EEtimeCorrShiftBins_.

Referenced by run().

                                                                   {
  // computed initially in ns. Than turned in the BX's, as EcalUncalibratedRecHit need be.
  double theCorrection=0;
  
  int myBin = -1;
  for (int bin=0; bin<(int)EEtimeCorrAmplitudeBins_.size(); bin++ ){
    if(ampliEE > EEtimeCorrAmplitudeBins_.at(bin)) {
      myBin = bin;     }
    else break;
  }
  
  if (myBin == -1)
    {
      theCorrection = EEtimeCorrShiftBins_.at(0);
    }    
  else if  ( myBin == ((int)(EEtimeCorrAmplitudeBins_.size()-1))   ) 
    {
      theCorrection = EEtimeCorrShiftBins_.at( myBin );      
    }    
  else if  ( -1 < myBin   &&   myBin <  ((int)EEtimeCorrAmplitudeBins_.size()-1) )
    {
      // interpolate linearly between two assingned points
      theCorrection  = ( EEtimeCorrShiftBins_.at(myBin+1) - EEtimeCorrShiftBins_.at(myBin) );
      theCorrection *= ( ((double)ampliEE) -  EEtimeCorrAmplitudeBins_.at(myBin) ) / ( EEtimeCorrAmplitudeBins_.at(myBin+1) - EEtimeCorrAmplitudeBins_.at(myBin) );
      theCorrection += EEtimeCorrShiftBins_.at(myBin);
    }
  else
    {
      edm::LogError("EcalRecHitError") << "Assigning time correction impossible. Setting it to 0 ";
      theCorrection = 0.;
    }
  
  // convert ns into clocks
  return theCorrection/25.;
}

Member Data Documentation

Definition at line 96 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 97 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 62 of file EcalUncalibRecHitWorkerGlobal.h.

Definition at line 110 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 111 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 75 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 76 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 71 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EBchi2Parameters_ [protected]

Definition at line 112 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::ebPulseShape_ [protected]

Definition at line 102 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 98 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal().

Definition at line 84 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EBtimeCorrShiftBins_ [protected]
std::pair<double,double> EcalUncalibRecHitWorkerGlobal::EBtimeFitLimits_ [protected]

Definition at line 73 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EBtimeFitParameters_ [protected]

Definition at line 69 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 85 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 72 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EEchi2Parameters_ [protected]

Definition at line 113 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::eePulseShape_ [protected]

Definition at line 103 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 86 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EEtimeCorrShiftBins_ [protected]
std::pair<double,double> EcalUncalibRecHitWorkerGlobal::EEtimeFitLimits_ [protected]

Definition at line 74 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

std::vector<double> EcalUncalibRecHitWorkerGlobal::EEtimeFitParameters_ [protected]

Definition at line 70 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 87 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 48 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 51 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

Definition at line 59 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

Definition at line 101 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

Definition at line 108 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 109 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 104 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 105 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 89 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 93 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 88 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 92 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 91 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 95 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 90 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 94 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by EcalUncalibRecHitWorkerGlobal(), and run().

Definition at line 47 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 50 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().

Definition at line 46 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 81 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 82 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 66 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 65 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 61 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 63 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 64 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run().

Definition at line 60 of file EcalUncalibRecHitWorkerGlobal.h.

Referenced by run(), and set().