BeamInfo.cxx
Go to the documentation of this file.
1 /////////////////////////////////////////////////////////////////////
2 // \version $Id: BeamInfo.cxx,v 1.3 2010/03/26 19:36:42 brebel Exp $
3 // \file BeamInfo class
4 // \author kinga.partyka@yale.edu
5 ////////////////////////////////////////////////////////////////////
6 
7 #include <iostream>
8 #include <fstream>
10 #include <string.h>
11 #include <time.h>
12 #include <cmath>
13 #include <iomanip>
14 
15 namespace gar {
16  namespace raw{
17 
18  //-------------------------------------------------------------------------
20  : tor101(0.)
21  , tortgt(0.)
22  , trtgtd(0.)
23  , t_ms(0)
24  , fRecordType(0)
25  , fSeconds(0)
26  , fMilliSeconds(0)
27  , fNumberOfDevices(0)
28  {
29  }
30 
31  //-------------------------------------------------------------------------
33 
34  //-------------------------------------------------------------------------
35  BeamInfo::BeamInfo(double vtor101,
36  double vtortgt,
37  double vtrtgtd,
38  long long int vt_ms)
39  : tor101(vtor101)
40  , tortgt(vtortgt)
41  , trtgtd(vtrtgtd)
42  , t_ms(vt_ms)
43  , fRecordType(0)
44  , fSeconds(0)
45  , fMilliSeconds(0)
46  , fNumberOfDevices(0)
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  //-------------------------------------------------------------------------
102  void BeamInfo::Set(std::string device, double val)
103  {
104  std::vector<double> vec;
105  vec.push_back(val);
106  Set(device,vec);
107  }
108 
109  //-------------------------------------------------------------------------
110  void BeamInfo::Set(std::string device, std::vector<double> val)
111  {
112  if (fDataMap.find(device)!=fDataMap.end()) {
113  //device already listed
114  return;
115  };
116  std::pair<std::string, std::vector<double> > p(device,val);
117  fDataMap.insert(p);
118  }
119 
120  //-------------------------------------------------------------------------
121  //output operator
122  std::ostream& operator<<( std::ostream& os,
123  const raw::BeamInfo& o )
124  {
125 
126  os << "Record type:" << o.GetRecordType() << std::endl;;
127  os << "Timestamp: " << o.GetSeconds() << "\t"
128  << o.GetMilliSeconds() << std::endl;
129  os << "Number of Devices: " << o.GetNumberOfDevices() << std::endl;
130 
131  const std::map<std::string, std::vector<double> > dm=o.GetDataMap();
132  std::map<std::string, std::vector<double> >::const_iterator it=dm.begin();
133  while (it!=dm.end()) {
134  os << it->first<<": ";
135  for (size_t i=0;i<it->second.size();i++) os <<it->second[i]<<", ";
136  os << std::endl;
137  ++it;
138  }
139 
140  return os;
141  }
142  }// namespace
143 } // gar
double get_tor101() const
Definition: BeamInfo.cxx:51
uint32_t GetSeconds() const
Definition: BeamInfo.h:61
uint8_t GetRecordType() const
Definition: BeamInfo.h:60
uint32_t fSeconds
Definition: BeamInfo.h:31
void SetTORTGT(double val)
Definition: BeamInfo.cxx:82
std::string string
Definition: nybbler.cc:12
void Set(std::string device_name, double val)
Definition: BeamInfo.cxx:102
long long int t_ms
Definition: BeamInfo.h:29
Raw data description.
uint16_t fMilliSeconds
Definition: BeamInfo.h:32
uint16_t GetMilliSeconds() const
Definition: BeamInfo.h:62
uint16_t GetNumberOfDevices() const
Definition: BeamInfo.h:63
friend std::ostream & operator<<(std::ostream &, const BeamInfo &)
Definition: BeamInfo.cxx:122
void SetTRTGTD(double val)
Definition: BeamInfo.cxx:89
p
Definition: test.py:223
long long int get_t_ms() const
Definition: BeamInfo.cxx:69
void SetT_MS(long long int val)
Definition: BeamInfo.cxx:96
std::map< std::string, std::vector< double > > GetDataMap() const
Definition: BeamInfo.h:66
uint16_t fNumberOfDevices
Definition: BeamInfo.h:33
General GArSoft Utilities.
double get_trtgtd() const
Definition: BeamInfo.cxx:63
std::map< std::string, std::vector< double > > fDataMap
Definition: BeamInfo.h:34
uint8_t fRecordType
Definition: BeamInfo.h:30
QTextStream & endl(QTextStream &s)
void SetTOR101(double val)
Definition: BeamInfo.cxx:75
double get_tortgt() const
Definition: BeamInfo.cxx:57