Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
evdb::EventDisplay Class Reference

ART event display service. More...

#include "/cvmfs/nova.opensciencegrid.org/externals/nuevdb/v1_00_02/source/nuevdb/EventDisplayBase/EventDisplay.h"

Public Member Functions

 EventDisplay (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
void reconfigure (fhicl::ParameterSet const &pset)
 

Public Attributes

unsigned int fAutoAdvanceInterval
 Wait time in milliseconds. More...
 
int fAutoPrintCount
 Number of events printed so far. More...
 
int fAutoPrintMax
 How many events to print (zero = disable printing). More...
 
std::string fAutoPrintPattern
 Pattern for printing output filenames. Must contain "%s" and "%d", in that order. More...
 
bool fEchoPrint
 Copy what you see in X to a .gif for each event. More...
 
std::string fEchoPrintFile
 The file to dump that .gif to. Only one file, if you want a different file for each event, use AutoPrint instead. More...
 
std::string fEchoPrintTempFile
 a temporary file to enable atomic writes More...
 

Private Member Functions

void postBeginJob ()
 
void postBeginJobWorkers (art::InputSource *inputs, std::vector< art::Worker * > const &workers)
 
void preProcessEvent (art::Event const &)
 
void postProcessEvent (art::Event const &)
 

Private Attributes

art::InputSourcefInputSource
 Input source of events. More...
 

Detailed Description

ART event display service.

Definition at line 25 of file EventDisplay.h.

Constructor & Destructor Documentation

evdb::EventDisplay::EventDisplay ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Definition at line 71 of file EventDisplay_service.cc.

References postBeginJob(), postBeginJobWorkers(), postProcessEvent(), preProcessEvent(), reconfigure(), art::ActivityRegistry::sPostBeginJob, art::ActivityRegistry::sPostBeginJobWorkers, art::ActivityRegistry::sPostProcessEvent, and art::ActivityRegistry::sPreProcessEvent.

72  :
74  {
75  // evdb::DisplayWindow::Register("Test1","Test display #1",600,900,mk_canvas1);
76  // evdb::DisplayWindow::OpenWindow(0);
77 
78  this->reconfigure(pset);
79 
80  reg.sPostBeginJob.watch (this, &EventDisplay::postBeginJob);
84  }
GlobalSignal< detail::SignalResponseType::FIFO, void()> sPostBeginJob
void postBeginJobWorkers(art::InputSource *inputs, std::vector< art::Worker * > const &workers)
GlobalSignal< detail::SignalResponseType::LIFO, void(InputSource *, std::vector< Worker * > const &)> sPostBeginJobWorkers
void preProcessEvent(art::Event const &)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &)> sPreProcessEvent
GlobalSignal< detail::SignalResponseType::LIFO, void(Event const &)> sPostProcessEvent
void reconfigure(fhicl::ParameterSet const &pset)
void postProcessEvent(art::Event const &)
int fAutoPrintCount
Number of events printed so far.
Definition: EventDisplay.h:45

Member Function Documentation

void evdb::EventDisplay::postBeginJob ( )
private

Definition at line 140 of file EventDisplay_service.cc.

References evdb::DisplayWindow::SetServicesAll().

Referenced by EventDisplay().

141  {
143  }
static void SetServicesAll()
void evdb::EventDisplay::postBeginJobWorkers ( art::InputSource inputs,
std::vector< art::Worker * > const &  workers 
)
private

Definition at line 132 of file EventDisplay_service.cc.

References fInputSource.

Referenced by EventDisplay().

134  {
135  fInputSource = input_source;
136  }
art::InputSource * fInputSource
Input source of events.
Definition: EventDisplay.h:41
void evdb::EventDisplay::postProcessEvent ( art::Event const &  evt)
private

Definition at line 154 of file EventDisplay_service.cc.

References demo::app, evdb::ServiceTable::ApplyEdits(), DEFINE_ART_SERVICE, evdb::DisplayWindow::DrawAll(), errno, art::Event::event(), exit(), fAutoPrintCount, fAutoPrintMax, fAutoPrintPattern, fEchoPrint, fEchoPrintFile, fEchoPrintTempFile, fInputSource, genie::utils::style::Format(), evdb::Printable::GetPrintables(), art::Event::id(), evdb::EventHolder::Instance(), evdb::ServiceTable::Instance(), art::SubRunID::invalidSubRun(), it, evdb::kGOTO_EVENT, evdb::kNEXT_EVENT, evdb::kPREV_EVENT, evdb::kRELOAD_EVENT, evdb::kSEQUENTIAL_ONLY, LOG_DEBUG, art::errors::LogicError, evdb::Printable::Print(), evdb::Printable::PrintTag(), nd_projection_maker::ps, fillBadChanDBTables::result, art::RootInput::seekToEvent(), evdb::NavState::Set(), evdb::EventHolder::SetEvent(), evdb::NavState::TargetEvent(), evdb::NavState::TargetRun(), and evdb::NavState::Which().

Referenced by EventDisplay().

155  {
156  // stuff the event into the holder
158  holder->SetEvent(&evt);
159 
161 
162  if(fAutoPrintMax == 0){
163  TApplication* app = gROOT->GetApplication();
164 
165  // Hold here for user input from the GUI...
166  app->Run(kTRUE);
167  }
168 
169  //
170  // Apply edits to any services that may have been reconfigured
171  //
173 
174  if(fAutoPrintMax > 0){
175  ++fAutoPrintCount;
176  std::map<std::string, Printable*>& ps = Printable::GetPrintables();
177  for(std::map<std::string,Printable*>::iterator it = ps.begin(); it != ps.end(); ++it){
178  Printable* p = it->second;
179  // Ensure the format string is well-formed
180  if(fAutoPrintPattern.find("%s") == std::string::npos)
181  throw cet::exception("EventDisplay") << "Cannot find AutoPrintPattern"
182  << " format for %s";
183  if(fAutoPrintPattern.find("%d") == std::string::npos)
184  throw cet::exception("EventDisplay") << "Cannot find AutoPrintPattern"
185  << " format for %d";
186  // png doesn't seem to work for some reason
187  p->Print(TString::Format(fAutoPrintPattern.c_str(), p->PrintTag(), evt.event()));
188  }
190  }
191 
192  // if fEchoPrint is set, do so
193  if (fEchoPrint){
194  std::map<std::string, Printable*>& ps = Printable::GetPrintables();
195  for(std::map<std::string,Printable*>::iterator it = ps.begin(); it != ps.end(); ++it){
196  Printable* p = it->second;
197  // lack of more parameters to Print() call means use the file format
198  // that's specified by the file name extension
199  p->Print(fEchoPrintTempFile.c_str());
200  }
201  // move temporary file to final file. This makes the creation of the
202  // newly printed file close to atomic
203  int result;
204  result=rename(fEchoPrintTempFile.c_str(),fEchoPrintFile.c_str());
205  if (result==0)
206  LOG_DEBUG("EventDisplayBase") << fEchoPrintTempFile
207  << " tempfile successfully renamed to "
208  << fEchoPrintFile;
209  else
210  mf::LogWarning("EventDisplayBase") << "Error renaming file "
212  << " to " << fEchoPrintFile
213  << " " << strerror(errno) <<"\n";
214  }
215 
216  art::RootInput* rootInput = dynamic_cast<art::RootInput*>(fInputSource);
217 
218  if(!rootInput && NavState::Which() != kSEQUENTIAL_ONLY){
220  mf::LogWarning("EventDisplayBase")
221  << "Random access for the EventDisplay requires a RootInput source for proper operation.\n"
222  << "You do not have a RootInput source so only sequential access works.\n";
223  }
224 
225 
226  // Figure out where to go in the input stream from here
227  switch (NavState::Which()) {
228  case kSEQUENTIAL_ONLY: break;
229  case kNEXT_EVENT: {
230  // Contrary to appearances, this is *not* a NOP: it ensures run and
231  // subRun are (re-)read as necessary if we've been doing random
232  // access. Come the revolution ...
233  //
234  // 2011/04/10 CG.
235  if(rootInput) rootInput->seekToEvent(0);
236  break;
237  }
238  case kPREV_EVENT: {
239  if(rootInput) rootInput->seekToEvent(-2);
240  break;
241  }
242  case kRELOAD_EVENT: {
243  if(rootInput) rootInput->seekToEvent(evt.id());
244  break;
245  }
246  case kGOTO_EVENT: {
248  if(rootInput){
249  if (!rootInput->seekToEvent(id)) { // Couldn't find event
250  mf::LogWarning("EventDisplayBase") << "Unable to find "
251  << id
252  << " -- reloading current event.";
253  // Reload current event.
254  rootInput->seekToEvent(evt.id());
255  }
256  }// end if not a RootInput
257  break;
258  }
259  default: {
261  << "EvengtDisplay in unhandled state "
262  << NavState::Which()
263  << ".\n";
264  }
265  } // end switch statement
266 
267  }
::xsd::cxx::tree::id< char, ncname > id
Definition: Database.h:165
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
static void Set(int which)
Definition: NavState.cxx:24
static int TargetEvent()
Definition: NavState.cxx:51
int fAutoPrintMax
How many events to print (zero = disable printing).
Definition: EventDisplay.h:46
static ServiceTable & Instance()
set< int >::iterator it
std::string fEchoPrintFile
The file to dump that .gif to. Only one file, if you want a different file for each event...
Definition: EventDisplay.h:49
const char * p
Definition: xmltok.h:285
bool fEchoPrint
Copy what you see in X to a .gif for each event.
Definition: EventDisplay.h:48
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::string fEchoPrintTempFile
a temporary file to enable atomic writes
Definition: EventDisplay.h:50
static int TargetRun()
Definition: NavState.cxx:47
static std::map< std::string, evdb::Printable * > & GetPrintables()
Definition: Printable.cxx:61
static EventHolder * Instance()
Definition: EventHolder.cxx:15
int evt
bool seekToEvent(T eventSpec, bool exact=false)
Definition: RootInput.h:144
static void DrawAll(const char *opt=0)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
app
Definition: demo.py:189
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static int Which()
Definition: NavState.cxx:20
exit(0)
static SubRunID invalidSubRun(RunID const &rID)
Definition: SubRunID.h:163
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
int fAutoPrintCount
Number of events printed so far.
Definition: EventDisplay.h:45
std::string fAutoPrintPattern
Pattern for printing output filenames. Must contain "%s" and "%d", in that order. ...
Definition: EventDisplay.h:47
void SetEvent(art::Event const *evt)
Definition: EventHolder.cxx:32
int errno
Definition: errno.cpp:12
art::InputSource * fInputSource
Input source of events.
Definition: EventDisplay.h:41
void evdb::EventDisplay::preProcessEvent ( art::Event const &  evt)
private

Definition at line 147 of file EventDisplay_service.cc.

References art::EventID::event(), art::Event::id(), art::EventID::run(), and evdb::DisplayWindow::SetRunEventAll().

Referenced by EventDisplay().

148  {
149  evdb::DisplayWindow::SetRunEventAll(evt.id().run(), evt.id().event());
150  }
static void SetRunEventAll(int run, int event)
int evt
void evdb::EventDisplay::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 88 of file EventDisplay_service.cc.

References fAutoAdvanceInterval, fAutoPrintMax, fAutoPrintPattern, fEchoPrint, fEchoPrintFile, fEchoPrintTempFile, fhicl::ParameterSet::get(), compare_h5_caf::idx, string, and w.

Referenced by EventDisplay().

89  {
90  fAutoAdvanceInterval = pset.get<unsigned int>("AutoAdvanceInterval" );
91  fAutoPrintMax = pset.get<int >("AutoPrintMax", 0 );
92  fAutoPrintPattern = pset.get<std::string >("AutoPrintPattern", "");
93  fEchoPrint = pset.get<bool >("EchoPrint", false);
94  fEchoPrintFile = pset.get<std::string >("EchoPrintFile", "$HOME/evt_echo.gif");
95  // Sanitize filename: root's OK with env variables, straight system
96  // calls are not. So, force a substitution of env. variables in the
97  // filename so we can do atomic-write "renames" later using a tmp file
98  if (fEchoPrint) {
99  wordexp_t p;
100  char** w;
101  wordexp( fEchoPrintFile.c_str(), &p, 0 );
102  w = p.we_wordv;
103  fEchoPrintFile = std::string(*w);
104  // the tempfile has to end with the same extension (eg, ".gif") as
105  // the specified filename. root's printing takes the format of the file
106  // from that extension. So, we have to construct a name with the same
107  // path, and extension: need to insert a "tmp" before the final .gif
108  // Sp, simply grab the file extension and stick it back on the end
110  std::string extension;
111  idx = fEchoPrintFile.rfind('.');
112  if(idx != std::string::npos) {
113  extension = fEchoPrintFile.substr(idx);
114  fEchoPrintTempFile = std::string(*w) + ".tmp" + extension;
115  } else {
116  // No extension found, can't do this
117  fEchoPrint = false;
118  fEchoPrintTempFile = "";
119  mf::LogWarning("EventDisplayBase")
120  << "No file extension given to EchoPrintFile "
121  << fEchoPrintFile
122  << " so cannot determine file format, disabling EchoPrint\n";
123  }
124  wordfree(&p);
125  } else {
126  fEchoPrintTempFile = "";
127  }
128  }
int fAutoPrintMax
How many events to print (zero = disable printing).
Definition: EventDisplay.h:46
std::string fEchoPrintFile
The file to dump that .gif to. Only one file, if you want a different file for each event...
Definition: EventDisplay.h:49
const char * p
Definition: xmltok.h:285
unsigned int fAutoAdvanceInterval
Wait time in milliseconds.
Definition: EventDisplay.h:44
bool fEchoPrint
Copy what you see in X to a .gif for each event.
Definition: EventDisplay.h:48
std::string fEchoPrintTempFile
a temporary file to enable atomic writes
Definition: EventDisplay.h:50
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Definition: typedefs.hpp:11
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
std::string fAutoPrintPattern
Pattern for printing output filenames. Must contain "%s" and "%d", in that order. ...
Definition: EventDisplay.h:47
Float_t w
Definition: plot.C:20
enum BeamMode string

Member Data Documentation

unsigned int evdb::EventDisplay::fAutoAdvanceInterval

Wait time in milliseconds.

Definition at line 44 of file EventDisplay.h.

Referenced by evdb::ButtonBar::AutoAdvance(), evdb::ButtonBar::HandleTimer(), and reconfigure().

int evdb::EventDisplay::fAutoPrintCount

Number of events printed so far.

Definition at line 45 of file EventDisplay.h.

Referenced by postProcessEvent().

int evdb::EventDisplay::fAutoPrintMax

How many events to print (zero = disable printing).

Definition at line 46 of file EventDisplay.h.

Referenced by postProcessEvent(), and reconfigure().

std::string evdb::EventDisplay::fAutoPrintPattern

Pattern for printing output filenames. Must contain "%s" and "%d", in that order.

Definition at line 47 of file EventDisplay.h.

Referenced by postProcessEvent(), and reconfigure().

bool evdb::EventDisplay::fEchoPrint

Copy what you see in X to a .gif for each event.

Definition at line 48 of file EventDisplay.h.

Referenced by postProcessEvent(), and reconfigure().

std::string evdb::EventDisplay::fEchoPrintFile

The file to dump that .gif to. Only one file, if you want a different file for each event, use AutoPrint instead.

Definition at line 49 of file EventDisplay.h.

Referenced by postProcessEvent(), and reconfigure().

std::string evdb::EventDisplay::fEchoPrintTempFile

a temporary file to enable atomic writes

Definition at line 50 of file EventDisplay.h.

Referenced by postProcessEvent(), and reconfigure().

art::InputSource* evdb::EventDisplay::fInputSource
private

Input source of events.

Definition at line 41 of file EventDisplay.h.

Referenced by postBeginJobWorkers(), and postProcessEvent().


The documentation for this class was generated from the following files: