CMS 3D CMS Logo

PPSTimingCalibration.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of CTPPS offline software.
4  * Authors:
5  * Filip Dej
6  * Laurent Forthomme
7  *
8  ****************************************************************************/
9 
11 #include <ostream>
12 
13 //--------------------------------------------------------------------------
14 
16  if (db == rhs.db) {
17  if (sampic == rhs.sampic) {
18  if (channel == rhs.channel)
19  return cell < rhs.cell;
20  return channel < rhs.channel;
21  }
22  return sampic < rhs.sampic;
23  }
24  return db < rhs.db;
25 }
26 
27 std::ostream& operator<<(std::ostream& os, const PPSTimingCalibration::Key& key) {
28  return os << key.db << " " << key.sampic << " " << key.channel << " " << key.cell;
29 }
30 
31 //--------------------------------------------------------------------------
32 
33 std::vector<double> PPSTimingCalibration::parameters(int key1, int key2, int key3, int key4) const {
34  Key key{key1, key2, key3, key4};
35  auto out = parameters_.find(key);
36  if (out == parameters_.end())
37  return {};
38  return out->second;
39 }
40 
41 double PPSTimingCalibration::timeOffset(int key1, int key2, int key3, int key4) const {
42  Key key{key1, key2, key3, key4};
43  auto out = timeInfo_.find(key);
44  if (out == timeInfo_.end())
45  return 0.;
46  return out->second.first;
47 }
48 
49 double PPSTimingCalibration::timePrecision(int key1, int key2, int key3, int key4) const {
50  Key key{key1, key2, key3, key4};
51  auto out = timeInfo_.find(key);
52  if (out == timeInfo_.end())
53  return 0.;
54  return out->second.second;
55 }
56 
57 std::ostream& operator<<(std::ostream& os, const PPSTimingCalibration& data) {
58  os << "FORMULA: " << data.formula_ << "\nDB SAMPIC CHANNEL CELL PARAMETERS TIME_OFFSET\n";
59  for (const auto& kv : data.parameters_) {
60  os << kv.first << " [";
61  for (size_t i = 0; i < kv.second.size(); ++i)
62  os << (i > 0 ? ", " : "") << kv.second.at(i);
63 
64  PPSTimingCalibration::Key key = kv.first;
65  if (data.timeInfo_.find(key) == data.timeInfo_.end())
66  key = {kv.first.db, kv.first.sampic, kv.first.channel, -1};
67 
68  const auto& time = data.timeInfo_.at(key);
69  os << "] " << time.first << " " << time.second << "\n";
70  }
71  return os;
72 }
double timeOffset(int key1, int key2, int key3, int key4=-1) const
friend std::ostream & operator<<(std::ostream &os, const PPSTimingCalibration &data)
Helper structure for indexing calibration data.
bool operator<(const Key &rhs) const
Comparison operator.
double timePrecision(int key1, int key2, int key3, int key4=-1) const
std::vector< double > parameters(int key1, int key2, int key3, int key4) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79