All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BeamInfo.cxx
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////
2 // \file BeamInfo class
3 // \author kinga.partyka@yale.edu
4 ////////////////////////////////////////////////////////////////////
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 
26  //-------------------------------------------------------------------------
28 
29  //-------------------------------------------------------------------------
30  BeamInfo::BeamInfo(double vtor101,
31  double vtortgt,
32  double vtrtgtd,
33  long long int vt_ms)
34  : tor101(vtor101)
35  , tortgt(vtortgt)
36  , trtgtd(vtrtgtd)
37  , t_ms(vt_ms)
38  , fRecordType(0)
39  , fSeconds(0)
40  , fMilliSeconds(0)
41  , fNumberOfDevices(0)
42  {
43  }
44 
45 
46 
47  //-------------------------------------------------------------------------
48  double BeamInfo::get_tor101() const
49  {
50  return tor101;
51  }
52 
53  //-------------------------------------------------------------------------
54  double BeamInfo::get_tortgt() const
55  {
56  return tortgt;
57  }
58 
59  //-------------------------------------------------------------------------
60  double BeamInfo::get_trtgtd() const
61  {
62  return trtgtd;
63  }
64 
65  //-------------------------------------------------------------------------
66  long long int BeamInfo::get_t_ms() const
67  {
68  return t_ms;
69  }
70 
71  //-------------------------------------------------------------------------
72  void BeamInfo::SetTOR101(double val)
73  {
74  tor101 = val;
75  Set("E:TOR101",val);
76  }
77 
78  //-------------------------------------------------------------------------
79  void BeamInfo::SetTORTGT(double val)
80  {
81  tortgt = val;
82  Set("E:TORTGT",val);
83  }
84 
85  //-------------------------------------------------------------------------
86  void BeamInfo::SetTRTGTD(double val)
87  {
88  trtgtd = val;
89  Set("E:TRTGTD",val);
90  }
91 
92  //-------------------------------------------------------------------------
93  void BeamInfo::SetT_MS(long long int val)
94  {
95  t_ms = val;
96  }
97 
98  void BeamInfo::Set(std::string device, double val)
99  {
100  std::vector<double> vec;
101  vec.push_back(val);
102  Set(device,vec);
103  }
104 
105  void BeamInfo::Set(std::string device, std::vector<double> val)
106  {
107  if (fDataMap.find(device)!=fDataMap.end()) {
108  //device already listed
109  return;
110  };
111  std::pair<std::string, std::vector<double> > p(device,val);
112  fDataMap.insert(p);
113  }
114 
115  //-------------------------------------------------------------------------
116  //output operator
117  std::ostream& operator<<( std::ostream& os,
118  const raw::BeamInfo& o )
119  {
120 
121  os << "Record type:" << o.GetRecordType() << std::endl;;
122  os << "Timestamp: " << o.GetSeconds() << "\t"
123  << o.GetMilliSeconds() << std::endl;
124  os << "Number of Devices: " << o.GetNumberOfDevices() << std::endl;
125 
126  const std::map<std::string, std::vector<double> > dm=o.GetDataMap();
127  std::map<std::string, std::vector<double> >::const_iterator it=dm.begin();
128  while (it!=dm.end()) {
129  os << it->first<<": ";
130  for (size_t i=0;i<it->second.size();i++) os <<it->second[i]<<", ";
131  os << std::endl;
132  it++;
133  }
134 
135  return os;
136  }
137 }// namespace
long long int get_t_ms() const
Definition: BeamInfo.cxx:66
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:72
uint8_t GetRecordType() const
Definition: BeamInfo.h:57
pdgs p
Definition: selectors.fcl:22
double trtgtd
Definition: BeamInfo.h:26
double tortgt
Definition: BeamInfo.h:25
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:93
double get_tor101() const
Definition: BeamInfo.cxx:48
std::map< std::string, std::vector< double > > GetDataMap() const
Definition: BeamInfo.h:63
uint32_t GetSeconds() const
Definition: BeamInfo.h:58
void SetTORTGT(double val)
Definition: BeamInfo.cxx:79
double tor101
Definition: BeamInfo.h:24
std::ostream & operator<<(std::ostream &os, const raw::BeamInfo &o)
Definition: BeamInfo.cxx:117
void SetTRTGTD(double val)
Definition: BeamInfo.cxx:86
void Set(std::string device_name, double val)
Definition: BeamInfo.cxx:98
double get_trtgtd() const
Definition: BeamInfo.cxx:60
double get_tortgt() const
Definition: BeamInfo.cxx:54