00001 #include "RecoTBCalo/EcalTBTDCReconstructor/interface/EcalTBH2TDCRecInfoAlgo.h" 00002 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00003 00004 #include <list> 00005 #include <vector> 00006 #include <iostream> 00007 00008 EcalTBH2TDCRecInfoAlgo::EcalTBH2TDCRecInfoAlgo(const std::vector<EcalTBH2TDCRanges>& tdcZeros): 00009 tdcZeros_(tdcZeros), actualRun_(-1) , actualRange_(-1) 00010 { 00011 00012 } 00013 00014 EcalTBTDCRecInfo EcalTBH2TDCRecInfoAlgo::reconstruct(const int& runNumber, const HcalTBTiming& TDCRawInfo) const 00015 { 00016 if (actualRun_ != runNumber ) 00017 { 00018 actualRun_ = runNumber; 00019 actualRange_ = -1; 00020 for (unsigned int i=0; i<tdcZeros_.size();i++) 00021 if ( runNumber <= tdcZeros_[i].runRanges.second && runNumber >= tdcZeros_[i].runRanges.first ) 00022 actualRange_ = i; 00023 00024 if (actualRange_ == -1) 00025 { 00026 edm::LogError("TDCRange not found") << "TDC range not found"; 00027 return EcalTBTDCRecInfo(-1); 00028 } 00029 } 00030 00031 int ntdc = TDCRawInfo.BeamCoincidenceCount(); 00032 edm::LogInfo("") << "EcalTBH2TDCRecInfoAlgo::reconstruct # tdc hits: " << ntdc << std::endl;; 00033 if(ntdc>1) { 00034 for(int i=0; i<ntdc; ++i) { 00035 edm::LogInfo("") << "hit i: " << i << " tdc: " << TDCRawInfo.BeamCoincidenceHits(i) << std::endl; 00036 } 00037 } 00038 00039 00040 if(ntdc==0) { 00041 edm::LogError("NoTDCHits") << "no TDC hits. TDC info not reliable" << std::endl; 00042 return EcalTBTDCRecInfo(-999.); 00043 } 00044 00045 00046 //double tdcd = TDCRawInfo.ttcL1Atime() - TDCRawInfo.beamCoincidence(); 00047 double tdcd = TDCRawInfo.ttcL1Atime() - TDCRawInfo.BeamCoincidenceHits(0); 00048 00049 if( 00050 (tdcd < tdcZeros_[actualRange_].tdcZero -1 || tdcd > tdcZeros_[actualRange_].tdcZero + 26) ) 00051 { 00052 edm::LogError("TDCOutOfRange") << " ============================\n" 00053 << " tdc value out of range = "<< tdcd 00054 << " tdcZero = " << tdcZeros_[actualRange_].tdcZero 00055 << "\n" 00056 << " ============================\n" <<std::endl; 00057 tdcRangeErrorMessageAlreadyDisplayed_ = true; 00058 return EcalTBTDCRecInfo(-999.); 00059 } 00060 00061 double offset = ( (double)tdcd - (double)tdcZeros_[actualRange_].tdcZero ) 00062 / 25.; // 00063 // if (use2004OffsetConvention) 00064 // offset = (1. - offset) ; 00065 return EcalTBTDCRecInfo(offset); 00066 } 00067