Macros | Functions | Variables
status.cxx File Reference
#include <gtk/gtk.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include "event.h"
#include "status.h"

Go to the source code of this file.

Macros

#define BOTANY_BAY_OH_NO(x)   x < 0?"−":"", fabs(x)
 
#define BOTANY_BAY_OH_INT(x)   x < 0?"−":"", abs((int)x)
 

Functions

void set_status (const int boxn, const char *format,...)
 
void set_eventn_status_runevent ()
 
void set_eventn_status_timing ()
 
void set_eventn_status_hit ()
 
void set_eventn_status_vertex ()
 
void set_eventn_status_track ()
 
void set_eventn_status_progress (const int nhit, const int tothits)
 
void set_eventn_status ()
 

Variables

GtkTextBuffer * stattext [NSTATBOXES]
 
GtkWidget * statbox [NSTATBOXES]
 
bool theevents_memory_limited
 
std::vector< noeeventtheevents
 
int gevi
 
int active_plane
 
int active_cell
 
int active_track
 
int active_vertex
 
bool ghave_read_all
 
static const int MAXSTATUS = 1024
 

Macro Definition Documentation

#define BOTANY_BAY_OH_INT (   x)    x < 0?"−":"", abs((int)x)

Definition at line 28 of file status.cxx.

Referenced by set_eventn_status_hit(), and set_eventn_status_timing().

#define BOTANY_BAY_OH_NO (   x)    x < 0?"−":"", fabs(x)

Definition at line 27 of file status.cxx.

Referenced by set_eventn_status_hit(), and set_eventn_status_timing().

Function Documentation

void set_eventn_status ( )

Definition at line 192 of file status.cxx.

References set_eventn_status_hit(), set_eventn_status_runevent(), set_eventn_status_timing(), set_eventn_status_track(), set_eventn_status_vertex(), and theevents.

Referenced by draw_event().

193 {
195 
196  if(theevents.empty()) return;
197 
202 }
void set_eventn_status_vertex()
Definition: status.cxx:135
std::vector< noeevent > theevents
Definition: noe_module.cc:29
void set_eventn_status_runevent()
Definition: status.cxx:42
void set_eventn_status_timing()
Definition: status.cxx:58
void set_eventn_status_hit()
Definition: status.cxx:91
void set_eventn_status_track()
Definition: status.cxx:159
void set_eventn_status_hit ( )

Definition at line 91 of file status.cxx.

References active_cell, active_plane, BOTANY_BAY_OH_INT, BOTANY_BAY_OH_NO, getBrightness::cell, gevi, MECModelEnuComparisons::i, overlay_prestage_def::matches, MAXSTATUS, NDAPDHVSetting::plane, elec2geo::pos, set_status(), stathit, and theevents.

Referenced by set_eventn_status(), and update_active_objects().

92 {
93  if(active_plane < 0 || active_cell < 0){
94  set_status(stathit, "Mouse over a cell for more information");
95  return;
96  }
97 
98  char status2[MAXSTATUS];
99  int pos = snprintf(status2, MAXSTATUS, "Plane %d, cell %d: ",
101 
102  // TODO: display calibrated energies when possible
103  std::vector<hit> & THEhits = theevents[gevi].hits;
104  bool needseparator = false;
105 
106  // TODO: make this more flexible.
107  const int maxmatches = 3;
108  int matches = 0;
109  for(unsigned int i = 0; i < THEhits.size(); i++){
110  if(THEhits[i].plane == active_plane &&
111  THEhits[i].cell == active_cell &&
112  THEhits[i].tdc >= theevents[gevi].current_mintick &&
113  THEhits[i].tdc <= theevents[gevi].current_maxtick){
114  matches++;
115  if(matches <= maxmatches){
116  pos += pos >= MAXSTATUS?0:snprintf(status2+pos, MAXSTATUS-pos,
117  "%sTDC = %s%d (%s%.3f μs), TNS = %s%.3f μs%s, ADC = %s%d",
118  needseparator?"; ":"",
119  BOTANY_BAY_OH_INT(THEhits[i].tdc),
120  BOTANY_BAY_OH_NO (THEhits[i].tdc/64.),
121  BOTANY_BAY_OH_NO (THEhits[i].tns/1000),
122  THEhits[i].good_tns?"":"(bad)",
123  BOTANY_BAY_OH_INT(THEhits[i].adc));
124  needseparator = true;
125  }
126  else if(matches == maxmatches+1){
127  pos += pos >= MAXSTATUS?0:snprintf(status2+pos, MAXSTATUS-pos,
128  "; and more...");
129  }
130  }
131  }
132  set_status(stathit, status2);
133 }
int active_cell
Definition: main.cxx:78
int active_plane
Definition: main.cxx:78
static const int MAXSTATUS
Definition: status.cxx:22
int gevi
Definition: main.cxx:76
void set_status(const int boxn, const char *format,...)
Definition: status.cxx:30
std::vector< noeevent > theevents
Definition: noe_module.cc:29
#define BOTANY_BAY_OH_NO(x)
Definition: status.cxx:27
#define BOTANY_BAY_OH_INT(x)
Definition: status.cxx:28
Definition: status.h:4
void set_eventn_status_progress ( const int  nhit,
const int  tothits 
)

Definition at line 187 of file status.cxx.

References set_status(), and stathit.

Referenced by draw_hits().

188 {
189  set_status(stathit, "Processing big event, %d/%d hits", nhit, tothits);
190 }
nhit
Definition: demo1.py:25
void set_status(const int boxn, const char *format,...)
Definition: status.cxx:30
Definition: status.h:4
void set_eventn_status_runevent ( )

Definition at line 42 of file status.cxx.

References check_time_usage::float, gevi, nevent, fillBadChanDBTables::nrun, set_status(), statrunevent, theevents, and theevents_memory_limited.

Referenced by realmain(), and set_eventn_status().

43 {
44  if(theevents.empty()){
45  set_status(statrunevent, "No events");
46  return;
47  }
48 
49  set_status(statrunevent, "Run %'d, subrun %d, event %'d "
50  "(%'d/%'d %s, %.0f%% loaded)",
51  theevents[gevi].nrun, theevents[gevi].nsubrun,
53  (int)theevents.capacity(),
54  theevents_memory_limited?"that fit in memory":"in the file(s)",
55  100*float(theevents.size())/theevents.capacity());
56 }
int gevi
Definition: main.cxx:76
void set_status(const int boxn, const char *format,...)
Definition: status.cxx:30
std::vector< noeevent > theevents
Definition: noe_module.cc:29
Int_t nevent
Definition: macro.C:10
bool theevents_memory_limited
Definition: noe_module.cc:28
void set_eventn_status_timing ( )

Definition at line 58 of file status.cxx.

References BOTANY_BAY_OH_INT, BOTANY_BAY_OH_NO, noeevent::current_maxtick, noeevent::current_mintick, E, noeevent::fdlike, gevi, hits(), MAXSTATUS, noeevent::maxtick, noeevent::mintick, elec2geo::pos, set_status(), stattiming, and theevents.

Referenced by set_eventn_status().

59 {
60  noeevent & E = theevents[gevi];
61 
62  char status1[MAXSTATUS];
63 
64  int pos = snprintf(status1, MAXSTATUS, "Ticks %s%d through %d. ",
67  pos += snprintf(status1+pos, MAXSTATUS-pos,
68  "Showing ticks %s%d through %s%d (%s%.3f through %s%.3f μs)",
72 
73  // Print the time at the end of the 4-tick segment for the FD,
74  // since it only reads out every 4 ticks. I *think* the ND
75  // reads out every tick (but not every channel every tick), so
76  // print the time at the end of the last tick.
77  BOTANY_BAY_OH_NO( (E.current_maxtick+(E.fdlike?4:1))/64.));
78  else
79  pos += snprintf(status1+pos, MAXSTATUS-pos,
80  "Showing tick %s%d (%s%.3f μs)",
83 
84  // If there are no hits, all of the above is nonsense, so overwrite it
85  if(theevents[gevi].hits.empty())
86  snprintf(status1, MAXSTATUS, "Empty event");
87 
88  set_status(stattiming, status1);
89 }
int32_t current_maxtick
Definition: event.h:69
static const int MAXSTATUS
Definition: status.cxx:22
Definition: event.h:41
int32_t current_mintick
Definition: event.h:69
void hits()
Definition: readHits.C:15
int gevi
Definition: main.cxx:76
int32_t maxtick
Definition: event.h:48
void set_status(const int boxn, const char *format,...)
Definition: status.cxx:30
std::vector< noeevent > theevents
Definition: noe_module.cc:29
Float_t E
Definition: plot.C:20
bool fdlike
Definition: event.h:71
int32_t mintick
Definition: event.h:48
#define BOTANY_BAY_OH_NO(x)
Definition: status.cxx:27
#define BOTANY_BAY_OH_INT(x)
Definition: status.cxx:28
void set_eventn_status_track ( )

Definition at line 159 of file status.cxx.

References active_track, gevi, MAXSTATUS, elec2geo::pos, set_status(), stattrack, fabricate::status, and theevents.

Referenced by set_eventn_status(), and update_active_objects().

160 {
161  if(active_track < 0){
162  if(theevents[gevi].tracks.empty())
163  set_status(stattrack, "There are no tracks");
164  else
165  set_status(stattrack, "Mouse over a track for information on it");
166  return;
167  }
168 
169  if(theevents[gevi].tracks.empty()) return;
170 
171  char status[MAXSTATUS];
172  int pos = snprintf(status, MAXSTATUS, "Track %d\n", active_track);
173  pos += snprintf(status+pos, MAXSTATUS-pos, "start (%.1f, %.1f, %.1f)\n"
174  "stop (%.1f, %.1f, %.1f)\n",
175  theevents[gevi].tracks[active_track].startx/10.,
176  theevents[gevi].tracks[active_track].starty/10.,
177  theevents[gevi].tracks[active_track].startz/10.,
178  theevents[gevi].tracks[active_track].stopx/10.,
179  theevents[gevi].tracks[active_track].stopy/10.,
180  theevents[gevi].tracks[active_track].stopz/10.);
181  pos += snprintf(status+pos, MAXSTATUS-pos, "time %.4f %c%cs",
182  theevents[gevi].tracks[active_track].tns/1000, 0xce, 0xbc);
183 
184  set_status(stattrack, status);
185 }
int status
Definition: fabricate.py:1613
static const int MAXSTATUS
Definition: status.cxx:22
int gevi
Definition: main.cxx:76
void set_status(const int boxn, const char *format,...)
Definition: status.cxx:30
std::vector< noeevent > theevents
Definition: noe_module.cc:29
int active_track
Definition: main.cxx:78
void set_eventn_status_vertex ( )

Definition at line 135 of file status.cxx.

References active_vertex, gevi, MAXSTATUS, elec2geo::pos, set_status(), fabricate::status, statvertex, and theevents.

Referenced by set_eventn_status(), and update_active_objects().

136 {
137  if(active_vertex < 0){
138  if(theevents[gevi].vertices.empty())
139  set_status(statvertex, "There are no vertices");
140  else
141  set_status(statvertex, "Mouse over a vertex for information on it");
142  return;
143  }
144 
145  if(theevents[gevi].vertices.empty()) return;
146 
147  char status[MAXSTATUS];
148  int pos = snprintf(status, MAXSTATUS, "Vertex %d\n", active_vertex);
149  pos += snprintf(status+pos, MAXSTATUS-pos, "at (%.1f, %.1f, %.1f)\n",
150  theevents[gevi].vertices[active_vertex].posx/10.,
151  theevents[gevi].vertices[active_vertex].posy/10.,
152  theevents[gevi].vertices[active_vertex].posz/10.);
153  pos += snprintf(status+pos, MAXSTATUS-pos, "time %.4f %c%cs",
154  theevents[gevi].vertices[active_vertex].tns/1000, 0xce, 0xbc);
155 
156  set_status(statvertex, status);
157 }
int status
Definition: fabricate.py:1613
static const int MAXSTATUS
Definition: status.cxx:22
int active_vertex
Definition: main.cxx:78
int gevi
Definition: main.cxx:76
void set_status(const int boxn, const char *format,...)
Definition: status.cxx:30
std::vector< noeevent > theevents
Definition: noe_module.cc:29
void set_status ( const int  boxn,
const char *  format,
  ... 
)

Definition at line 30 of file status.cxx.

References MAXSTATUS, statbox, and stattext.

Referenced by clear_error_message(), getuserevent(), set_eventn_status_hit(), set_eventn_status_progress(), set_eventn_status_runevent(), set_eventn_status_timing(), set_eventn_status_track(), and set_eventn_status_vertex().

31 {
32  va_list ap;
33  va_start(ap, format);
34  static char buf[MAXSTATUS];
35  vsnprintf(buf, MAXSTATUS-1, format, ap);
36 
37  gtk_text_buffer_set_text(stattext[boxn], buf, strlen(buf));
38  gtk_text_view_set_buffer(GTK_TEXT_VIEW(statbox[boxn]), stattext[boxn]);
39  gtk_widget_draw(statbox[boxn], NULL);
40 }
static const int MAXSTATUS
Definition: status.cxx:22
GtkTextBuffer * stattext[NSTATBOXES]
Definition: status.cxx:11
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
GtkWidget * statbox[NSTATBOXES]
Definition: status.cxx:12

Variable Documentation

int active_cell
int active_plane
int active_track

Definition at line 78 of file main.cxx.

Referenced by set_eventn_status_track().

int active_vertex

Definition at line 78 of file main.cxx.

Referenced by set_eventn_status_vertex().

int gevi
bool ghave_read_all

Definition at line 101 of file main.cxx.

Referenced by get_event(), getuserevent(), prefetch_an_event(), realmain(), setup(), and to_next_free_run().

const int MAXSTATUS = 1024
static
GtkWidget* statbox[NSTATBOXES]

Definition at line 12 of file status.cxx.

Referenced by make_aux_win(), makestatbox(), set_status(), and setup().

GtkTextBuffer* stattext[NSTATBOXES]

Definition at line 11 of file status.cxx.

Referenced by makestatbox(), and set_status().

std::vector<noeevent> theevents
bool theevents_memory_limited

Definition at line 28 of file noe_module.cc.

Referenced by noe::noe::produce(), and set_eventn_status_runevent().