HeaderDrawer.cxx
Go to the documentation of this file.
1 ///
2 /// \file HeaderDrawer.cxx
3 /// \brief Render the objects from the Simulation package
4 /// \author messier@indiana.edu
5 /// \version $Id: HeaderDrawer.cxx,v 1.2 2010/11/11 18:11:22 p-novaart Exp $
6 ///
8 #include "nuevdb/EventDisplayBase/Colors.h"
9 #include "nuevdb/EventDisplayBase/View2D.h"
10 #include "nuevdb/EventDisplayBase/View3D.h"
11 #include "nuevdb/EventDisplayBase/EventHolder.h"
12 
13 #include "TText.h"
14 #include "TTimeStamp.h"
15 
17 
18 namespace gar {
19 namespace evd{
20 
22 
23  //......................................................................
24 
26 
27 
28  //......................................................................
29 
33  std::string& dates,
34  std::string& times)
35  {
36  titles = "DUNE ND MPD";
37 
38  // get the event
39  const art::Event* evt = evdb::EventHolder::Instance()->GetEvent();
40  if(!evt) return;
41 
42  int run = evt->run();
43  int srun = evt->subRun();
44  int event = evt->id().event();
45 
46  unsigned int year, month, day, dayofweek;
47  unsigned int hour, minute, second;
48  int nano;
49 
50  // get the time stamp. art::Timestamp::value() returns a TimeValue_t which is a typedef to unsigned long long.
51  // The conventional use is for the upper 32 bits to have the seconds since 1970 epoch and the lower 32 bits to be
52  // the number of microseconds with the current second.
53  unsigned long long int tsval = evt->time().value();
54 
55  // taking it apart
56  // the masking isn't strictly necessary *if* "long" is truly 32bits
57  // but this can vary w/ compiler/platform
58  const unsigned long int mask32 = 0xFFFFFFFFUL;
59  unsigned long int lup = ( tsval >> 32 ) & mask32;
60  unsigned long int llo = tsval & mask32;
61  TTimeStamp ts(lup, (int)llo);
62 
63  ts.GetDate(kTRUE,0,&year,&month,&day);
64  ts.GetTime(kTRUE,0,&hour,&minute,&second);
65  nano = ts.GetNanoSec();
66  dayofweek = ts.GetDayOfWeek();
67  char eventbuff[256];
68  char runbuff[256];
69  char datebuff[256];
70  char timebuff[256];
71 
72  // Skip first one since ROOT returns these numbers starting from 1 not 0
73  static const char* days[] = {"",
74  "Mon","Tue","Wed","Thu","Fri","Sat","Sun"
75  };
76  static const char* months[] = {"",
77  "Jan","Feb","Mar","Apr","May","Jun",
78  "Jul","Aug","Sep","Oct","Nov","Dec"
79  };
80 
81  sprintf(runbuff, "Run: %d/%d",run,srun);
82  runs = runbuff;
83 
84  sprintf(eventbuff,"Event: %d",event);
85  events = eventbuff;
86 
87  sprintf(datebuff, "UTC %s %s %u, %u",
88  days[dayofweek],
89  months[month],
90  day,
91  year);
92  dates = datebuff;
93 
94  sprintf(timebuff, "%.2u:%.2u:%2.9f",
95  hour,
96  minute,
97  (float)second+(float)nano/1.0E9);
98  times = timebuff;
99  }
100 
101  void HeaderDrawer::Header(evdb::View2D* view)
102  {
106  std::string date;
108  this->Text(title,run,event,date,time);
109 
111  int c = colors->Foreground(0);
112 
113  TText& titlet = view->AddText(0.03,0.80, title.c_str());
114  TText& runt = view->AddText(0.04,0.60, run.c_str());
115  TText& eventt = view->AddText(0.04,0.45, event.c_str());
116  TText& datet = view->AddText(0.04,0.25, date.c_str());
117  TText& timet = view->AddText(0.04,0.10, time.c_str());
118 
119  titlet.SetTextSize(0.1);
120  titlet.SetTextFont(62);
121  titlet.SetTextColor(c);
122 
123  runt.SetTextSize(0.08);
124  runt.SetTextFont(42);
125  runt.SetTextColor(c);
126 
127  eventt.SetTextSize(0.08);
128  eventt.SetTextFont(42);
129  eventt.SetTextColor(c);
130 
131  datet.SetTextSize(0.08);
132  datet.SetTextFont(42);
133  datet.SetTextColor(c);
134 
135  timet.SetTextSize(0.08);
136  timet.SetTextFont(42);
137  timet.SetTextColor(c);
138  }
139  void HeaderDrawer::Header(evdb::View3D* view)
140  {
144  std::string date;
146  this->Text(title,run,event,date,time);
147 
149  int c = colors->Foreground(0);
150 
151  TText& titlet = view->AddText(-0.98,-0.75, title.c_str());
152  TText& runt = view->AddText(-0.98,-0.80, run.c_str());
153  TText& eventt = view->AddText(-0.98,-0.85, event.c_str());
154  TText& datet = view->AddText(-0.98,-0.90, date.c_str());
155  TText& timet = view->AddText(-0.98,-0.95, time.c_str());
156 
157  titlet.SetTextSize(0.04);
158  titlet.SetTextFont(62);
159  titlet.SetTextColor(c);
160 
161  runt.SetTextSize(0.03);
162  runt.SetTextFont(42);
163  runt.SetTextColor(c);
164 
165  eventt.SetTextSize(0.03);
166  eventt.SetTextFont(42);
167  eventt.SetTextColor(c);
168 
169  datet.SetTextSize(0.03);
170  datet.SetTextFont(42);
171  datet.SetTextColor(c);
172 
173  timet.SetTextSize(0.03);
174  timet.SetTextFont(42);
175  timet.SetTextColor(c);
176  }
177 }
178 }// namespace
179 ////////////////////////////////////////////////////////////////////////
std::string string
Definition: nybbler.cc:12
void Text(std::string &title, std::string &run, std::string &event, std::string &date, std::string &time)
constexpr TimeValue_t value() const
Definition: Timestamp.h:23
Timestamp time() const
LArSoft includes.
Definition: InfoTransfer.h:33
SubRunNumber_t subRun() const
Definition: DataViewImpl.cc:78
RunNumber_t run() const
Definition: DataViewImpl.cc:71
General GArSoft Utilities.
void Header(evdb::View2D *view)
EventNumber_t event() const
Definition: EventID.h:116
TCEvent evt
Definition: DataStructs.cxx:7
second_as<> second
Type of time stored in seconds, in double precision.
Definition: spacetime.h:85
EventID id() const
Definition: Event.cc:34
Event finding and building.