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

ART event display service. More...

#include <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 &, art::ScheduleContext)
 
void postProcessEvent (art::Event const &, art::ScheduleContext)
 

Private Attributes

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

Detailed Description

ART event display service.

Definition at line 26 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.

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)
void preProcessEvent(art::Event const &, art::ScheduleContext)
GlobalSignal< detail::SignalResponseType::LIFO, void(InputSource *, std::vector< Worker * > const &)> sPostBeginJobWorkers
void postProcessEvent(art::Event const &, art::ScheduleContext)
GlobalSignal< detail::SignalResponseType::FIFO, void(Event const &, ScheduleContext)> sPreProcessEvent
GlobalSignal< detail::SignalResponseType::LIFO, void(Event const &, ScheduleContext)> sPostProcessEvent
void reconfigure(fhicl::ParameterSet const &pset)
int fAutoPrintCount
Number of events printed so far.
Definition: EventDisplay.h:46

Member Function Documentation

void evdb::EventDisplay::postBeginJob ( )
private

Definition at line 140 of file EventDisplay_service.cc.

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.

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

Definition at line 154 of file EventDisplay_service.cc.

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  }
189  if(fAutoPrintCount >= fAutoPrintMax) exit(0);
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  MF_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  }
intermediate_table::iterator iterator
static void Set(int which)
Definition: NavState.cxx:24
static int TargetEvent()
Definition: NavState.cxx:51
unsigned int event
Definition: DataStructs.h:574
int fAutoPrintMax
How many events to print (zero = disable printing).
Definition: EventDisplay.h:47
static ServiceTable & Instance()
static QCString result
static const double ps
Definition: Units.h:103
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:50
bool fEchoPrint
Copy what you see in X to a .gif for each event.
Definition: EventDisplay.h:49
std::string fEchoPrintTempFile
a temporary file to enable atomic writes
Definition: EventDisplay.h:51
int errno
Contains the last error code.
Definition: structcmd.h:53
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
static void DrawAll(const char *opt=0)
p
Definition: test.py:223
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static int Which()
Definition: NavState.cxx:20
#define MF_LOG_DEBUG(id)
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
TCEvent evt
Definition: DataStructs.cxx:7
int fAutoPrintCount
Number of events printed so far.
Definition: EventDisplay.h:46
std::string fAutoPrintPattern
Pattern for printing output filenames. Must contain "%s" and "%d", in that order. ...
Definition: EventDisplay.h:48
void SetEvent(art::Event const *evt)
Definition: EventHolder.cxx:32
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::InputSource * fInputSource
Input source of events.
Definition: EventDisplay.h:42
def rename(src, dest)
void evdb::EventDisplay::preProcessEvent ( art::Event const &  evt,
art::ScheduleContext   
)
private

Definition at line 147 of file EventDisplay_service.cc.

148  {
150  }
unsigned int event
Definition: DataStructs.h:574
unsigned int run
Definition: DataStructs.h:575
static void SetRunEventAll(int run, int event)
TCEvent evt
Definition: DataStructs.cxx:7
void evdb::EventDisplay::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 88 of file EventDisplay_service.cc.

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
109  std::string::size_type idx;
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:47
std::string string
Definition: nybbler.cc:12
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:50
unsigned int fAutoAdvanceInterval
Wait time in milliseconds.
Definition: EventDisplay.h:45
bool fEchoPrint
Copy what you see in X to a .gif for each event.
Definition: EventDisplay.h:49
std::string fEchoPrintTempFile
a temporary file to enable atomic writes
Definition: EventDisplay.h:51
p
Definition: test.py:223
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:48

Member Data Documentation

unsigned int evdb::EventDisplay::fAutoAdvanceInterval

Wait time in milliseconds.

Definition at line 45 of file EventDisplay.h.

int evdb::EventDisplay::fAutoPrintCount

Number of events printed so far.

Definition at line 46 of file EventDisplay.h.

int evdb::EventDisplay::fAutoPrintMax

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

Definition at line 47 of file EventDisplay.h.

std::string evdb::EventDisplay::fAutoPrintPattern

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

Definition at line 48 of file EventDisplay.h.

bool evdb::EventDisplay::fEchoPrint

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

Definition at line 49 of file EventDisplay.h.

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 50 of file EventDisplay.h.

std::string evdb::EventDisplay::fEchoPrintTempFile

a temporary file to enable atomic writes

Definition at line 51 of file EventDisplay.h.

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

Input source of events.

Definition at line 42 of file EventDisplay.h.


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