Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
EDep::TEventChangeManager Class Reference

#include <TEventChangeManager.hxx>

Inheritance diagram for EDep::TEventChangeManager:

Public Member Functions

 TEventChangeManager ()
 
virtual ~TEventChangeManager ()
 
void ChangeEvent (int change=1)
 
void AddNewEventHandler (EDep::TVEventChangeHandler *handler)
 
void AddUpdateHandler (EDep::TVEventChangeHandler *handler)
 
void SetShowGeometry (bool f)
 Set the flag to show (or not show) the geometry. More...
 
bool GetShowGeometry () const
 
void AddVolumeToShow (const std::string &name)
 Add the name of a volume to be drawn. More...
 
void ClearVolumesToShow ()
 Clear the list of volumes to be shown. More...
 
void SetEventSource (TFile *source)
 
TFile * GetEventSource ()
 

Private Types

typedef std::vector< EDep::TVEventChangeHandler * > Handlers
 

Private Member Functions

void NewEvent ()
 
void UpdateEvent ()
 
 ClassDef (TEventChangeManager, 0)
 

Private Attributes

TFile * fEventSource
 The input source of events. More...
 
Handlers fUpdateHandlers
 The event update handlers. More...
 
Handlers fNewEventHandlers
 The new event handlers. More...
 
bool fShowGeometry
 Flag to determine if the geometry will be drawn. More...
 
std::vector< std::stringfVolumesToShow
 A collection of volume names to be shown if the geometry is being drawn. More...
 

Detailed Description

A class to handle a new event becoming available to the event display. There is a single instance of this class owned by TEventDisplay. This must be created after the GUI has been initialized.

Definition at line 16 of file TEventChangeManager.hxx.

Member Typedef Documentation

Definition at line 71 of file TEventChangeManager.hxx.

Constructor & Destructor Documentation

EDep::TEventChangeManager::TEventChangeManager ( )

Definition at line 77 of file TEventChangeManager.cxx.

77  {
78  TGButton* button = EDep::TEventDisplay::Get().GUI().GetNextEventButton();
79  if (button) {
80  button->Connect("Clicked()",
81  "EDep::TEventChangeManager",
82  this,
83  "ChangeEvent(=1)");
84  }
85 
87  if (button) {
88  button->Connect("Clicked()",
89  "EDep::TEventChangeManager",
90  this,
91  "ChangeEvent(=0)");
92  }
93 
95  if (button) {
96  button->Connect("Clicked()",
97  "EDep::TEventChangeManager",
98  this,
99  "ChangeEvent(=-1)");
100  }
101 
103 }
EDep::TGUIManager & GUI()
Return a reference to the gui manager.
TGButton * GetNextEventButton()
Get the next event button widget.
Definition: TGUIManager.hxx:37
static TEventDisplay & Get(void)
TGButton * GetPrevEventButton()
Get the previous event button widget.
Definition: TGUIManager.hxx:43
void ClearVolumesToShow()
Clear the list of volumes to be shown.
TGButton * GetDrawEventButton()
Get the redraw current event button widget.
Definition: TGUIManager.hxx:40
EDep::TEventChangeManager::~TEventChangeManager ( )
virtual

Definition at line 105 of file TEventChangeManager.cxx.

105 {}

Member Function Documentation

void EDep::TEventChangeManager::AddNewEventHandler ( EDep::TVEventChangeHandler handler)

Add a handler (taking ownership of the handler) for when the event changes (e.g. a new event is read). These handlers are for "once-per-event" actions and are executed by the NewEvent() method.

Definition at line 139 of file TEventChangeManager.cxx.

140  {
141  fNewEventHandlers.push_back(handler);
142 }
Handlers fNewEventHandlers
The new event handlers.
void EDep::TEventChangeManager::AddUpdateHandler ( EDep::TVEventChangeHandler handler)

Add a handler (taking ownership of the handler) for when the event needs to be redrawn. These handlers are executed by the UpdateEvent() method.

Definition at line 144 of file TEventChangeManager.cxx.

145  {
146  fUpdateHandlers.push_back(handler);
147 }
Handlers fUpdateHandlers
The event update handlers.
void EDep::TEventChangeManager::AddVolumeToShow ( const std::string name)
inline

Add the name of a volume to be drawn.

Definition at line 48 of file TEventChangeManager.hxx.

48  {
49  fVolumesToShow.push_back(name);
50  }
static QCString name
Definition: declinfo.cpp:673
std::vector< std::string > fVolumesToShow
A collection of volume names to be shown if the geometry is being drawn.
void EDep::TEventChangeManager::ChangeEvent ( int  change = 1)

Trigger an event change. The argument says how many events to read. If it's positive, then it reads forward in the file. If the change is zero, then the current event is just redrawn. This is connected to the GUI buttons.

Definition at line 149 of file TEventChangeManager.cxx.

149  {
150  std::cout << "Change Event by " << change << " entries" << std::endl;
151  if (!GetEventSource()) {
152  std::cout << "Event source is not available" << std::endl;
153  UpdateEvent();
154  return;
155  }
156 
157  gEDepSimEntryNumber += change;
158  if (gEDepSimEntryNumber >= gEDepSimTree->GetEntries()) {
159  gEDepSimEntryNumber = gEDepSimTree->GetEntries() - 1;
160  }
162 
163  if (change != 0) NewEvent();
164 
165  UpdateEvent();
166 }
TTree * gEDepSimTree
The tree containing the event.
int gEDepSimEntryNumber
QTextStream & endl(QTextStream &s)
EDep::TEventChangeManager::ClassDef ( TEventChangeManager  ,
 
)
private
void EDep::TEventChangeManager::ClearVolumesToShow ( )
inline

Clear the list of volumes to be shown.

Definition at line 53 of file TEventChangeManager.hxx.

53  {
54  fVolumesToShow.clear();
55  }
std::vector< std::string > fVolumesToShow
A collection of volume names to be shown if the geometry is being drawn.
TFile* EDep::TEventChangeManager::GetEventSource ( )
inline

Definition at line 24 of file TEventChangeManager.hxx.

24 {return fEventSource;}
TFile * fEventSource
The input source of events.
bool EDep::TEventChangeManager::GetShowGeometry ( ) const
inline

Definition at line 45 of file TEventChangeManager.hxx.

45 {return fShowGeometry;}
bool fShowGeometry
Flag to determine if the geometry will be drawn.
void EDep::TEventChangeManager::NewEvent ( )
private

This updates the event display for a new event using the event change handlers. It is used to do once-per-event initializations and does not call UpdateEvent().

Definition at line 168 of file TEventChangeManager.cxx.

168  {
169  std::cout << "New Event" << std::endl;
170 
172 
173  // Run through all of the handlers.
174  for (Handlers::iterator h = fNewEventHandlers.begin();
175  h != fNewEventHandlers.end(); ++h) {
176  (*h)->Apply();
177  }
178 
179 }
Handlers fNewEventHandlers
The new event handlers.
intermediate_table::iterator iterator
TTree * gEDepSimTree
The tree containing the event.
int gEDepSimEntryNumber
QTextStream & endl(QTextStream &s)
void EDep::TEventChangeManager::SetEventSource ( TFile *  source)

Set or get the event source. When the event source is set, the first event is read.

Definition at line 107 of file TEventChangeManager.cxx.

107  {
108  if (!source) {
109  std::cout << "Invalid event source" << std::endl;
110  return;
111  }
113  gEDepSimTree = (TTree*) fEventSource->Get("EDepSimEvents");
114  if (!gEDepSimTree) {
115  std::cout << "Missing the event tree" << std::endl;
116  return;
117  }
118  gEDepSimTree->SetBranchAddress("Event",&gEDepSimEvent);
121 
122  fEventSource->Get("EDepSimGeometry");
123 
124  if (GetShowGeometry() && !fVolumesToShow.empty()) {
125  TEveElementList* simple = new TEveElementList("simplifiedGeometry");
126  PickVolumes visitor(simple);
127  visitor.fVolumesToShow.clear();
128  visitor.fVolumesToShow.reserve(fVolumesToShow.size());
129  std::copy(fVolumesToShow.begin(), fVolumesToShow.end(),
130  std::back_inserter(visitor.fVolumesToShow));
131  visitor.Apply();
132  gEve->AddGlobalElement(simple);
133  }
134 
135  NewEvent();
136  UpdateEvent();
137 }
TFile * fEventSource
The input source of events.
TTree * gEDepSimTree
The tree containing the event.
int gEDepSimEntryNumber
TG4Event * gEDepSimEvent
The event being displayed.
std::vector< std::string > fVolumesToShow
A collection of volume names to be shown if the geometry is being drawn.
T copy(T const &v)
QTextStream & endl(QTextStream &s)
void EDep::TEventChangeManager::SetShowGeometry ( bool  f)
inline

Set the flag to show (or not show) the geometry.

Definition at line 44 of file TEventChangeManager.hxx.

44 {fShowGeometry = f;}
bool fShowGeometry
Flag to determine if the geometry will be drawn.
void EDep::TEventChangeManager::UpdateEvent ( )
private

This updates the event display for an event using the event change handlers.

Definition at line 181 of file TEventChangeManager.cxx.

181  {
182 
183  if (!gEDepSimEvent) {
184  std::cout << "Invalid event" << std::endl;;
185  return;
186  }
187 
188  // Run through all of the handlers.
189  for (Handlers::iterator h = fUpdateHandlers.begin();
190  h != fUpdateHandlers.end(); ++h) {
191  (*h)->Apply();
192  }
193 
194  // Make sure EVE is up to date.
195  gEve->Redraw3D(kTRUE);
196 }
intermediate_table::iterator iterator
Handlers fUpdateHandlers
The event update handlers.
TG4Event * gEDepSimEvent
The event being displayed.
QTextStream & endl(QTextStream &s)

Member Data Documentation

TFile* EDep::TEventChangeManager::fEventSource
private

The input source of events.

Definition at line 69 of file TEventChangeManager.hxx.

Handlers EDep::TEventChangeManager::fNewEventHandlers
private

The new event handlers.

Definition at line 77 of file TEventChangeManager.hxx.

bool EDep::TEventChangeManager::fShowGeometry
private

Flag to determine if the geometry will be drawn.

Definition at line 80 of file TEventChangeManager.hxx.

Handlers EDep::TEventChangeManager::fUpdateHandlers
private

The event update handlers.

Definition at line 74 of file TEventChangeManager.hxx.

std::vector<std::string> EDep::TEventChangeManager::fVolumesToShow
private

A collection of volume names to be shown if the geometry is being drawn.

Definition at line 83 of file TEventChangeManager.hxx.


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