Diana Software
MSourceRunTime.cc
Go to the documentation of this file.
1 #include "MSourceRunTime.hh"
2 #include "QEvent.hh"
3 #include "QEventList.hh"
4 #include "QBaseType.hh"
5 #include "QRunDataHandle.hh"
6 #include "QRawEvent.hh"
7 #include "QDetSourceRunHandle.hh"
8 
9 
11 
12 using namespace Diana;
13 
15 {
16 
17  ev.Add<QTime>("StartSourceRunUnix");
18 
19  ev.Require<QHeader>("DAQ","Header");
20 
21 }
22 
23 
25 {
26 
27  // source run number
28  const QHeader& header = ev.Get<QHeader>("DAQ","Header");
29 
30  QDetSourceRunHandle srh;
31  srh.SetRun(header.GetRun());
32  GlobalData().Get("",&srh,"DB");
33  const QDetSourceRun& sr = srh.Get();
34 
35  Diana::QInt source_run = sr.fSourceRun;
36 
37  // if there is no source run (non reprocessed runs)
38  // source run set to this run
39  if(source_run == Q_INT_DEFAULT) source_run = header.GetRun();
40 
41  // source run start time
42  QRunDataHandle rHandle(source_run);
43  GlobalData().Get("",&rHandle,"DB");
44  const QRunData& runData = rHandle.Get();
45 
46  unsigned int source_start_date = runData.fStartDate;
47 
48  Diana::QTime source_time;
49  // source run start
50  source_time.SetStartRunUnix(source_start_date);
51  // same time from run start
52  source_time.SetFromStartRunNs(header.GetTime().GetFromStartRunNs());
53 
54  /*
55  std::cout<<source_start_date<<" "
56  <<source_time.GetStartRunUnix()<<" "
57  <<source_time.GetFromStartRunNs()
58  <<std::endl;
59  */
60 
61  ev.Get<QTime>("StartSourceRunUnix") = source_time;
62 
63 }
64 
65 
67 {
68 
69 }
70 
QRunDataHandle rHandle(753)
QBaseType< int > QInt
int wrapped in a QObject
Definition: QBaseType.hh:174
#define Q_INT_DEFAULT
Definition: QDiana.hh:26
#define REGISTER_MODULE(clazz)
Definition: QDriver.hh:133
one-line description of your module
void Done()
Done method.
void Do(Diana::QEvent &ev)
Do method.
void Init(Diana::QEvent &ev)
Init method.
diana event
Definition: QEvent.hh:46
void Require(const std::string &owner, const std::string &name) const
notify the QEvent that we need a QObject, if not found an exception is thrown
Definition: QEvent.hh:232
void Get(const char *owner, ReadHandle< Q > &handle) const
Get a QObject Handle in read mode.
Definition: QEvent.hh:74
void Add(WriteHandle< Q > &handle)
Add a QObject to the event.
Definition: QEvent.hh:193
Raw event: basic information like run number and time.
Definition: QHeader.hh:16
const Diana::QTime & GetTime() const
get time
Definition: QHeader.hh:28
void SetRun(unsigned int run)
Set Run.
Definition: QHeader.hh:39
int GetRun() const
destructor
Definition: QHeader.hh:22
global handle for QRunData
Basic run based info.
Definition: QRunData.hh:20
time_t fStartDate
StartTime.
Definition: QRunData.hh:62
Diana time.
Definition: QTime.hh:17
the Diana namespace is needed because sometimes we use Qt libraries, that use same class names of our...