![]() |
![]() |
00001 #ifndef RecoLocalCalo_EcalRecAlgos_EcalRecHitSimpleAlgo_HH 00002 #define RecoLocalCalo_EcalRecAlgos_EcalRecHitSimpleAlgo_HH 00003 00013 #include "RecoLocalCalo/EcalRecAlgos/interface/EcalRecHitAbsAlgo.h" 00014 #include "DataFormats/EcalDigi/interface/EcalDataFrame.h" 00015 #include "TMath.h" 00016 #include <iostream> 00017 00018 class EcalRecHitSimpleAlgo : public EcalRecHitAbsAlgo { 00019 public: 00020 // default ctor 00021 EcalRecHitSimpleAlgo() { 00022 adcToGeVConstant_ = -1; 00023 adcToGeVConstantIsSet_ = false; 00024 } 00025 00026 virtual void setADCToGeVConstant(const float& value) { 00027 adcToGeVConstant_ = value; 00028 adcToGeVConstantIsSet_ = true; 00029 } 00030 00031 00032 // destructor 00033 virtual ~EcalRecHitSimpleAlgo() { }; 00034 00036 virtual EcalRecHit makeRecHit(const EcalUncalibratedRecHit& uncalibRH, 00037 const float& intercalibConstant, 00038 const float& timeIntercalib = 0, 00039 const uint32_t& flags = 0) const { 00040 00041 if(!adcToGeVConstantIsSet_) { 00042 std::cout << "EcalRecHitSimpleAlgo::makeRecHit: adcToGeVConstant_ not set before calling this method!" << 00043 " will use -1 and produce bogus rechits!" << std::endl; 00044 } 00045 00046 float clockToNsConstant = 25; 00047 float energy = uncalibRH.amplitude()*adcToGeVConstant_*intercalibConstant; 00048 float time = uncalibRH.jitter() * clockToNsConstant + timeIntercalib; 00049 00050 EcalRecHit rh( uncalibRH.id(), energy, time ); 00051 rh.setChi2( uncalibRH.chi2() ); 00052 rh.setOutOfTimeEnergy( uncalibRH.outOfTimeEnergy() * adcToGeVConstant_ * intercalibConstant ); 00053 rh.setOutOfTimeChi2( uncalibRH.outOfTimeChi2() ); 00054 rh.setTimeError(uncalibRH.jitterErrorBits()); 00055 00056 // Now fill both recoFlag and the new flagBits 00057 uint32_t flagbits(0); 00058 uint32_t recoFlag = flags; // so far contains only v_DB_reco_flags_[ statusCode ] from the worker 00059 // for the time being ignore them in flagBits 00060 00061 if ( uncalibRH.recoFlag() == EcalUncalibratedRecHit::kLeadingEdgeRecovered ) { 00062 recoFlag = EcalRecHit::kLeadingEdgeRecovered; 00063 flagbits |= (0x1 << EcalRecHit::kLeadingEdgeRecovered); 00064 00065 } else if ( uncalibRH.recoFlag() == EcalUncalibratedRecHit::kSaturated ) { 00066 // leading edge recovery failed - still keep the information 00067 // about the saturation and do not flag as dead 00068 recoFlag = EcalRecHit::kSaturated; 00069 // and at some point may try the recovery with the neighbours 00070 flagbits |= (0x1 << EcalRecHit::kSaturated); 00071 00072 } else if( uncalibRH.isSaturated() ) { 00073 recoFlag = EcalRecHit::kSaturated; 00074 flagbits |= (0x1 << EcalRecHit::kSaturated); 00075 00076 } else if ( uncalibRH.recoFlag() == EcalUncalibratedRecHit::kOutOfTime ) { 00077 recoFlag = EcalRecHit::kOutOfTime; 00078 flagbits |= (0x1 << EcalRecHit::kOutOfTime); 00079 00080 } else if ( uncalibRH.recoFlag() == EcalUncalibratedRecHit::kFake ) { 00081 recoFlag = EcalRecHit::kFake; 00082 flagbits |= (0x1 << EcalRecHit::kFake); 00083 } 00084 else if ( uncalibRH.recoFlag() == EcalUncalibratedRecHit::kPoorReco ) { 00085 recoFlag = EcalRecHit::kPoorReco; 00086 flagbits |= (0x1 << EcalRecHit::kPoorReco); 00087 } 00088 00089 // now set both the reco flag and the new flagBits_ 00090 rh.setRecoFlag( recoFlag ); 00091 rh.setFlagBits( flagbits ); 00092 00093 return rh; 00094 } 00095 00096 private: 00097 float adcToGeVConstant_; 00098 bool adcToGeVConstantIsSet_; 00099 00100 }; 00101 #endif