CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
EcalTBTDCRecInfoAlgo.cc
Go to the documentation of this file.
3 
4 #include <list>
5 #include <iostream>
6 
7 EcalTBTDCRecInfoAlgo::EcalTBTDCRecInfoAlgo(const std::vector<EcalTBTDCRanges>& tdcRanges)
8  : tdcRanges_(tdcRanges), tdcRangeErrorMessageAlreadyDisplayed_(false), actualRun_(-1), actualRange_(-1) {}
9 
11  const EcalTBEventHeader& eventHeader,
12  bool use2004OffsetConvention) const {
13  if (actualRun_ != eventHeader.runNumber()) {
14  actualRun_ = eventHeader.runNumber();
15  actualRange_ = -1;
16  for (unsigned int i = 0; i < tdcRanges_.size(); i++)
17  if (eventHeader.runNumber() <= tdcRanges_[i].runRanges.second &&
18  eventHeader.runNumber() >= tdcRanges_[i].runRanges.first)
19  actualRange_ = i;
20 
21  if (actualRange_ == -1) {
22  edm::LogError("TDCRange not found") << "TDC range not found";
23  return EcalTBTDCRecInfo(-1);
24  }
25  }
26 
27  int eventType;
28  eventType = ((eventHeader.dbEventType() == 0) ? 0 : (eventHeader.dbEventType() - 1));
29 
30  int tdcd = TDCRawInfo[0].tdcValue();
31 
33  (tdcd < tdcRanges_[actualRange_].tdcMin[eventType] || tdcd > tdcRanges_[actualRange_].tdcMax[eventType])) {
34  std::cout << " ============================" << std::endl;
35  std::cout << " Event type: " << eventType << std::endl;
36  std::cout << " TDC values not correctly set Raw TDC = " << tdcd
37  << " (Min/Max = " << tdcRanges_[actualRange_].tdcMin[eventType] << "/"
38  << tdcRanges_[actualRange_].tdcMax[eventType] << std::endl;
39  std::cout << " ============================" << std::endl;
41  }
42 
43  double offset =
44  ((double)tdcd - (double)tdcRanges_[actualRange_].tdcMin[eventType]) /
45  ((double)tdcRanges_[actualRange_].tdcMax[eventType] - (double)tdcRanges_[actualRange_].tdcMin[eventType]);
46  if (use2004OffsetConvention)
47  offset = (1. - offset);
48  return EcalTBTDCRecInfo(offset);
49 }
EcalTBTDCRecInfo reconstruct(const EcalTBTDCRawInfo &TDCRawInfo, const EcalTBEventHeader &eventHeader, bool use2004OffsetConvention) const
std::vector< EcalTBTDCRanges > tdcRanges_
Log< level::Error, false > LogError
int runNumber() const
int dbEventType() const
Returns the event type as in the H4ROOTDB.
tuple cout
Definition: gather_cfg.py:144