Belle II Software light-2406-ragdoll
InputController Class Reference

A static class to control supported input modules. More...

#include <InputController.h>

Collaboration diagram for InputController:

Static Public Member Functions

static bool canControlInput ()
 Is there an input module to be controlled.
 
static void setCanControlInput (bool on)
 Call this function from supported input modules.
 
static bool getEventMerging ()
 Get if we are merging events from two paths.
 
static void enableEventMerging (Module *steerRootInputModule)
 Set that we are merging events from two paths.
 
static void setNextEntry (long entry, bool independentPath=false)
 Set the file entry to be loaded the next time event() is called.
 
static long getNextEntry (bool independentPath=false)
 Return entry number set via setNextEntry().
 
static void setNextEntry (long exp, long run, long event)
 Set the file entry to be loaded the next time event() is called, by evt/run/exp number.
 
static void setSkippedEntries (long entries, bool independentPath=false)
 set the number of entries skipped by the RootInputModule.
 
static long getNextExperiment ()
 Return experiment number set via setNextEntry().
 
static long getNextRun ()
 Return run number set via setNextEntry().
 
static long getNextEvent ()
 Return event number set via setNextEntry().
 
static long getCurrentEntry (bool independentPath=false)
 returns the entry number currently loaded.
 
static long getSkippedEntries (bool independentPath=false)
 returns the number of entries skipped by the RootInputModule.
 
static long numEntries (bool independentPath=false)
 Returns total number of entries in the event tree.
 
static std::string getCurrentFileName (bool independentPath=false)
 Return name of current file in loaded chain (or empty string if none loaded).
 
static void eventLoaded (long entry, bool independentPath=false)
 Indicate that an event (in the given entry) was loaded and reset all members related to the next entry.
 
static void setChain (const TChain *chain, bool independentPath=false)
 Set the loaded TChain (event durability).
 
static void resetForChildProcess ()
 Reset InputController (e.g.
 
static long getNumEntriesToProcess ()
 Necessary to make sure the ProgressModule shows reasonable output.
 

Static Private Attributes

static bool s_canControlInput = false
 Is there an input module to be controlled?
 
static bool s_doEventMerging = false
 Are we merging events from two paths?
 
static Modules_steerRootInputModule = nullptr
 Explicit pointer to steerRootInput.
 
static std::pair< long, long > s_nextEntry = { -1, -1}
 entry to be loaded the next time event() is called in an input module.
 
static long s_nextExperiment = -1
 Experiment number to load next.
 
static long s_nextRun = -1
 Run number to load next.
 
static long s_nextEvent = -1
 Event (not entry!) to load next.
 
static std::pair< long, long > s_eventNumbers
 number of events in paths if two input modules are used (independent paths)
 
static std::pair< long, long > s_currentEntry = { 0, 0}
 current entry in file.
 
static std::pair< long, long > s_skippedEntries = { 0, 0}
 entries skipped by RootInputModule (if any) Storing two values (second one if independent path is executed)
 
static std::pair< const TChain *, const TChain * > s_chain = { nullptr, nullptr}
 Opened TChain (event durability).
 

Detailed Description

A static class to control supported input modules.

You can use setNextEntry() to request loading of any event in 0..numEntries()-1, which will be done the next time the input module's event() function is called.

Use canControlInput() to check wether control is actually possible.

Definition at line 30 of file InputController.h.

Constructor & Destructor Documentation

◆ InputController()

InputController ( )
inlineprivate

Definition at line 101 of file InputController.h.

101{ }

◆ ~InputController()

~InputController ( )
inlineprivate

Definition at line 102 of file InputController.h.

102{ }

Member Function Documentation

◆ canControlInput()

static bool canControlInput ( )
inlinestatic

Is there an input module to be controlled.

Definition at line 33 of file InputController.h.

33{ return s_canControlInput; }
static bool s_canControlInput
Is there an input module to be controlled?

◆ enableEventMerging()

void enableEventMerging ( Module steerRootInputModule)
static

Set that we are merging events from two paths.

Definition at line 27 of file InputController.cc.

28{
29 if (s_doEventMerging) {
30 B2FATAL("Event merging is already enabled, can not merge twice in the same job, aborting");
31 };
32 s_doEventMerging = true;
33 s_steerRootInputModule = steerRootInputModule;
34}
static Module * s_steerRootInputModule
Explicit pointer to steerRootInput.
static bool s_doEventMerging
Are we merging events from two paths?

◆ eventLoaded()

void eventLoaded ( long  entry,
bool  independentPath = false 
)
static

Indicate that an event (in the given entry) was loaded and reset all members related to the next entry.

Definition at line 46 of file InputController.cc.

47{
48 if (!independentPath) s_nextEntry.first = -1;
49 else s_nextEntry.second = -1;
51 s_nextRun = -1;
52 s_nextEvent = -1;
53 if (!independentPath) s_currentEntry.first = entry;
54 else s_currentEntry.second = entry;
55}
static std::pair< long, long > s_currentEntry
current entry in file.
static long s_nextExperiment
Experiment number to load next.
static long s_nextEvent
Event (not entry!) to load next.
static long s_nextRun
Run number to load next.
static std::pair< long, long > s_nextEntry
entry to be loaded the next time event() is called in an input module.

◆ getCurrentEntry()

static long getCurrentEntry ( bool  independentPath = false)
inlinestatic

returns the entry number currently loaded.

Definition at line 74 of file InputController.h.

74{ return (!independentPath) ? s_currentEntry.first : s_currentEntry.second; }

◆ getCurrentFileName()

std::string getCurrentFileName ( bool  independentPath = false)
static

Return name of current file in loaded chain (or empty string if none loaded).

Definition at line 68 of file InputController.cc.

69{
70 const TChain* chain = !independentPath ? s_chain.first : s_chain.second;
71 if (!chain)
72 return "";
73
74 const TFile* f = chain->GetFile();
75 if (!f)
76 return "";
77
78 return f->GetName();
79}
static std::pair< const TChain *, const TChain * > s_chain
Opened TChain (event durability).

◆ getEventMerging()

static bool getEventMerging ( )
inlinestatic

Get if we are merging events from two paths.

Definition at line 39 of file InputController.h.

39{ return s_doEventMerging; }

◆ getNextEntry()

static long getNextEntry ( bool  independentPath = false)
inlinestatic

Return entry number set via setNextEntry().

Definition at line 53 of file InputController.h.

53{ return (!independentPath) ? s_nextEntry.first : s_nextEntry.second;};

◆ getNextEvent()

static long getNextEvent ( )
inlinestatic

Return event number set via setNextEntry().

Definition at line 71 of file InputController.h.

71{ return s_nextEvent; }

◆ getNextExperiment()

static long getNextExperiment ( )
inlinestatic

Return experiment number set via setNextEntry().

Definition at line 65 of file InputController.h.

65{ return s_nextExperiment; }

◆ getNextRun()

static long getNextRun ( )
inlinestatic

Return run number set via setNextEntry().

Definition at line 68 of file InputController.h.

68{ return s_nextRun; }

◆ getNumEntriesToProcess()

long getNumEntriesToProcess ( )
static

Necessary to make sure the ProgressModule shows reasonable output.

Definition at line 94 of file InputController.cc.

95{
96 if (!s_doEventMerging) {
97 return numEntries();
98 } else {
99 return numEntries(true) * numEntries(false);
100 }
101}
static long numEntries(bool independentPath=false)
Returns total number of entries in the event tree.

◆ getSkippedEntries()

static long getSkippedEntries ( bool  independentPath = false)
inlinestatic

returns the number of entries skipped by the RootInputModule.

Definition at line 77 of file InputController.h.

77{ return (!independentPath) ? s_skippedEntries.first : s_skippedEntries.second; }
static std::pair< long, long > s_skippedEntries
entries skipped by RootInputModule (if any) Storing two values (second one if independent path is exe...

◆ numEntries()

long numEntries ( bool  independentPath = false)
static

Returns total number of entries in the event tree.

If no file is opened, zero is returned.

Definition at line 81 of file InputController.cc.

82{
83 if (!independentPath) {
84 if (s_chain.first)
85 return s_chain.first->GetEntries();
86 } else {
87 if (s_chain.second)
88 return s_chain.second->GetEntries();
89 }
90
91 return 0;
92}

◆ resetForChildProcess()

void resetForChildProcess ( )
static

Reset InputController (e.g.

after forking a thread)

Definition at line 57 of file InputController.cc.

58{
59 s_canControlInput = false;
60 s_nextEntry = { -1, -1};
62 s_nextRun = -1;
63 s_nextEvent = -1;
64 s_currentEntry = { 0, 0};
65 //s_chain is not touched, so numEntries() still works
66}

◆ setCanControlInput()

static void setCanControlInput ( bool  on)
inlinestatic

Call this function from supported input modules.

Definition at line 36 of file InputController.h.

36{ s_canControlInput = on; }

◆ setChain()

void setChain ( const TChain *  chain,
bool  independentPath = false 
)
static

Set the loaded TChain (event durability).

Definition at line 37 of file InputController.cc.

38{
39 if (!independentPath) {
40 s_chain.first = chain;
41 } else {
42 s_chain.second = chain;
43 }
44}

◆ setNextEntry() [1/2]

static void setNextEntry ( long  entry,
bool  independentPath = false 
)
inlinestatic

Set the file entry to be loaded the next time event() is called.

This is mainly useful for interactive applications (e.g. event display).

The input module should call eventLoaded() after the entry was loaded.

Definition at line 50 of file InputController.h.

50{ (!independentPath) ? s_nextEntry.first = entry : s_nextEntry.second = entry; }

◆ setNextEntry() [2/2]

static void setNextEntry ( long  exp,
long  run,
long  event 
)
inlinestatic

Set the file entry to be loaded the next time event() is called, by evt/run/exp number.

The input module should call eventLoaded() after the entry was loaded.

Definition at line 59 of file InputController.h.

59{ s_nextExperiment = exp; s_nextRun = run; s_nextEvent = event; }

◆ setSkippedEntries()

static void setSkippedEntries ( long  entries,
bool  independentPath = false 
)
inlinestatic

set the number of entries skipped by the RootInputModule.

Definition at line 62 of file InputController.h.

62{ (!independentPath) ? s_skippedEntries.first = entries : s_skippedEntries.second = entries; }

Member Data Documentation

◆ s_canControlInput

bool s_canControlInput = false
staticprivate

Is there an input module to be controlled?

Definition at line 105 of file InputController.h.

◆ s_chain

std::pair< const TChain *, const TChain * > s_chain = { nullptr, nullptr}
staticprivate

Opened TChain (event durability).

Storing two values (second one if independent path is executed)

Definition at line 148 of file InputController.h.

◆ s_currentEntry

std::pair< long, long > s_currentEntry = { 0, 0}
staticprivate

current entry in file.

Storing two values (second one if independent path is executed)

Definition at line 138 of file InputController.h.

◆ s_doEventMerging

bool s_doEventMerging = false
staticprivate

Are we merging events from two paths?

Definition at line 108 of file InputController.h.

◆ s_eventNumbers

std::pair<long, long> s_eventNumbers
staticprivate

number of events in paths if two input modules are used (independent paths)

Definition at line 133 of file InputController.h.

◆ s_nextEntry

std::pair< long, long > s_nextEntry = { -1, -1}
staticprivate

entry to be loaded the next time event() is called in an input module.

Storing two values (second one if independent path is executed) -1 indicates that execution should continue normally.

Definition at line 118 of file InputController.h.

◆ s_nextEvent

long s_nextEvent = -1
staticprivate

Event (not entry!) to load next.

Definition at line 130 of file InputController.h.

◆ s_nextExperiment

long s_nextExperiment = -1
staticprivate

Experiment number to load next.

-1 by default.

Definition at line 124 of file InputController.h.

◆ s_nextRun

long s_nextRun = -1
staticprivate

Run number to load next.

Definition at line 127 of file InputController.h.

◆ s_skippedEntries

std::pair< long, long > s_skippedEntries = { 0, 0}
staticprivate

entries skipped by RootInputModule (if any) Storing two values (second one if independent path is executed)

Definition at line 143 of file InputController.h.

◆ s_steerRootInputModule

Module * s_steerRootInputModule = nullptr
staticprivate

Explicit pointer to steerRootInput.

Definition at line 111 of file InputController.h.


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