CMS 3D CMS Logo

EcalTBH2TDCRecInfoAlgo.cc
Go to the documentation of this file.
3 
4 #include <list>
5 #include <vector>
6 #include <iostream>
7 
8 EcalTBH2TDCRecInfoAlgo::EcalTBH2TDCRecInfoAlgo(const std::vector<EcalTBH2TDCRanges>& tdcZeros)
9  : tdcZeros_(tdcZeros), actualRun_(-1), actualRange_(-1) {}
10 
12  if (actualRun_ != runNumber) {
14  actualRange_ = -1;
15  for (unsigned int i = 0; i < tdcZeros_.size(); i++)
16  if (runNumber <= tdcZeros_[i].runRanges.second && runNumber >= tdcZeros_[i].runRanges.first)
17  actualRange_ = i;
18 
19  if (actualRange_ == -1) {
20  edm::LogError("TDCRange not found") << "TDC range not found";
21  return EcalTBTDCRecInfo(-1);
22  }
23  }
24 
25  int ntdc = TDCRawInfo.BeamCoincidenceCount();
26  edm::LogInfo("") << "EcalTBH2TDCRecInfoAlgo::reconstruct # tdc hits: " << ntdc << std::endl;
27  ;
28  if (ntdc > 1) {
29  for (int i = 0; i < ntdc; ++i) {
30  edm::LogInfo("") << "hit i: " << i << " tdc: " << TDCRawInfo.BeamCoincidenceHits(i) << std::endl;
31  }
32  }
33 
34  if (ntdc == 0) {
35  edm::LogError("NoTDCHits") << "no TDC hits. TDC info not reliable" << std::endl;
36  return EcalTBTDCRecInfo(-999.);
37  }
38 
39  //double tdcd = TDCRawInfo.ttcL1Atime() - TDCRawInfo.beamCoincidence();
40  double tdcd = TDCRawInfo.ttcL1Atime() - TDCRawInfo.BeamCoincidenceHits(0);
41 
42  if (
43  (tdcd < tdcZeros_[actualRange_].tdcZero - 1 || tdcd > tdcZeros_[actualRange_].tdcZero + 26)) {
44  edm::LogError("TDCOutOfRange") << " ============================\n"
45  << " tdc value out of range = " << tdcd
46  << " tdcZero = " << tdcZeros_[actualRange_].tdcZero << "\n"
47  << " ============================\n"
48  << std::endl;
50  return EcalTBTDCRecInfo(-999.);
51  }
52 
53  double offset = ((double)tdcd - (double)tdcZeros_[actualRange_].tdcZero) / 25.; //
54  // if (use2004OffsetConvention)
55  // offset = (1. - offset) ;
56  return EcalTBTDCRecInfo(offset);
57 }
double BeamCoincidenceHits(int index) const
Returns the indexed hit time from Beam Coincidence.
Definition: HcalTBTiming.h:71
EcalTBTDCRecInfo reconstruct(const int &runNumber, const HcalTBTiming &TDCRawInfo) const
Log< level::Error, false > LogError
double ttcL1Atime() const
Returns the Level 1 Accept time in ns.
Definition: HcalTBTiming.h:27
int BeamCoincidenceCount() const
Returns the number of hits from Beam Coincidence.
Definition: HcalTBTiming.h:44
Log< level::Info, false > LogInfo
std::vector< EcalTBH2TDCRanges > tdcZeros_