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