LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
BeamInfo.cxx
Go to the documentation of this file.
1 // \file BeamInfo class
3 // \author kinga.partyka@yale.edu
5 
7 
8 #include <ostream>
9 #include <string>
10 
11 namespace raw {
12 
13  //-------------------------------------------------------------------------
15  : tor101(0.)
16  , tortgt(0.)
17  , trtgtd(0.)
18  , t_ms(0)
19  , fRecordType(0)
20  , fSeconds(0)
21  , fMilliSeconds(0)
22  , fNumberOfDevices(0)
23  {}
24 
25  //-------------------------------------------------------------------------
27 
28  //-------------------------------------------------------------------------
29  BeamInfo::BeamInfo(double vtor101, double vtortgt, double vtrtgtd, long long int vt_ms)
30  : tor101(vtor101)
31  , tortgt(vtortgt)
32  , trtgtd(vtrtgtd)
33  , t_ms(vt_ms)
34  , fRecordType(0)
35  , fSeconds(0)
36  , fMilliSeconds(0)
37  , fNumberOfDevices(0)
38  {}
39 
40  //-------------------------------------------------------------------------
41  double BeamInfo::get_tor101() const
42  {
43  return tor101;
44  }
45 
46  //-------------------------------------------------------------------------
47  double BeamInfo::get_tortgt() const
48  {
49  return tortgt;
50  }
51 
52  //-------------------------------------------------------------------------
53  double BeamInfo::get_trtgtd() const
54  {
55  return trtgtd;
56  }
57 
58  //-------------------------------------------------------------------------
59  long long int BeamInfo::get_t_ms() const
60  {
61  return t_ms;
62  }
63 
64  //-------------------------------------------------------------------------
65  void BeamInfo::SetTOR101(double val)
66  {
67  tor101 = val;
68  Set("E:TOR101", val);
69  }
70 
71  //-------------------------------------------------------------------------
72  void BeamInfo::SetTORTGT(double val)
73  {
74  tortgt = val;
75  Set("E:TORTGT", val);
76  }
77 
78  //-------------------------------------------------------------------------
79  void BeamInfo::SetTRTGTD(double val)
80  {
81  trtgtd = val;
82  Set("E:TRTGTD", val);
83  }
84 
85  //-------------------------------------------------------------------------
86  void BeamInfo::SetT_MS(long long int val)
87  {
88  t_ms = val;
89  }
90 
91  void BeamInfo::Set(std::string device, double val)
92  {
93  std::vector<double> vec;
94  vec.push_back(val);
95  Set(device, vec);
96  }
97 
98  void BeamInfo::Set(std::string device, std::vector<double> val)
99  {
100  if (fDataMap.find(device) != fDataMap.end()) {
101  //device already listed
102  return;
103  };
104  std::pair<std::string, std::vector<double>> p(device, val);
105  fDataMap.insert(p);
106  }
107 
108  //-------------------------------------------------------------------------
109  //output operator
110  std::ostream& operator<<(std::ostream& os, const raw::BeamInfo& o)
111  {
112 
113  os << "Record type:" << o.GetRecordType() << std::endl;
114  ;
115  os << "Timestamp: " << o.GetSeconds() << "\t" << o.GetMilliSeconds() << std::endl;
116  os << "Number of Devices: " << o.GetNumberOfDevices() << std::endl;
117 
118  const std::map<std::string, std::vector<double>> dm = o.GetDataMap();
119  std::map<std::string, std::vector<double>>::const_iterator it = dm.begin();
120  while (it != dm.end()) {
121  os << it->first << ": ";
122  for (size_t i = 0; i < it->second.size(); i++)
123  os << it->second[i] << ", ";
124  os << std::endl;
125  it++;
126  }
127 
128  return os;
129  }
130 } // namespace
long long int get_t_ms() const
Definition: BeamInfo.cxx:59
long long int t_ms
Definition: BeamInfo.h:26
std::map< std::string, std::vector< double > > fDataMap
Definition: BeamInfo.h:31
void SetTOR101(double val)
Definition: BeamInfo.cxx:65
uint8_t GetRecordType() const
Definition: BeamInfo.h:54
double trtgtd
Definition: BeamInfo.h:25
double tortgt
Definition: BeamInfo.h:24
uint32_t fSeconds
Definition: BeamInfo.h:28
Raw data description.
Definition: RawTypes.h:6
uint16_t GetNumberOfDevices() const
Definition: BeamInfo.h:57
uint16_t GetMilliSeconds() const
Definition: BeamInfo.h:56
void SetT_MS(long long int val)
Definition: BeamInfo.cxx:86
double get_tor101() const
Definition: BeamInfo.cxx:41
uint16_t fMilliSeconds
Definition: BeamInfo.h:29
std::map< std::string, std::vector< double > > GetDataMap() const
Definition: BeamInfo.h:60
friend std::ostream & operator<<(std::ostream &, const BeamInfo &)
Definition: BeamInfo.cxx:110
uint32_t GetSeconds() const
Definition: BeamInfo.h:55
void SetTORTGT(double val)
Definition: BeamInfo.cxx:72
uint16_t fNumberOfDevices
Definition: BeamInfo.h:30
double tor101
Definition: BeamInfo.h:23
void SetTRTGTD(double val)
Definition: BeamInfo.cxx:79
void Set(std::string device_name, double val)
Definition: BeamInfo.cxx:91
double get_trtgtd() const
Definition: BeamInfo.cxx:53
double get_tortgt() const
Definition: BeamInfo.cxx:47
uint8_t fRecordType
Definition: BeamInfo.h:27