Belle II Software development
InputController.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <framework/core/Module.h>
12
13#include <string>
14#include <utility>
15
16class TChain;
17
18namespace Belle2 {
31 public:
33 static bool canControlInput() { return s_canControlInput; }
34
36 static void setCanControlInput(bool on) { s_canControlInput = on; }
37
39 static bool getEventMerging() { return s_doEventMerging; }
40
42 static void enableEventMerging(Module* steerRootInputModule);
43
50 static void setNextEntry(long entry, bool independentPath = false) { (!independentPath) ? s_nextEntry.first = entry : s_nextEntry.second = entry; }
51
53 static long getNextEntry(bool independentPath = false) { return (!independentPath) ? s_nextEntry.first : s_nextEntry.second;};
54
59 static void setNextEntry(long exp, long run, long event) { s_nextExperiment = exp; s_nextRun = run; s_nextEvent = event; }
60
62 static void setSkippedEntries(long entries, bool independentPath = false) { (!independentPath) ? s_skippedEntries.first = entries : s_skippedEntries.second = entries; }
63
65 static long getNextExperiment() { return s_nextExperiment; }
66
68 static long getNextRun() { return s_nextRun; }
69
71 static long getNextEvent() { return s_nextEvent; }
72
74 static long getCurrentEntry(bool independentPath = false) { return (!independentPath) ? s_currentEntry.first : s_currentEntry.second; }
75
77 static long getSkippedEntries(bool independentPath = false) { return (!independentPath) ? s_skippedEntries.first : s_skippedEntries.second; }
78
83 static long numEntries(bool independentPath = false);
84
86 static std::string getCurrentFileName(bool independentPath = false);
87
89 static void eventLoaded(long entry, bool independentPath = false);
90
92 static void setChain(const TChain* chain, bool independentPath = false);
93
95 static void resetForChildProcess();
96
98 static long getNumEntriesToProcess();
99
100 private:
101 InputController() { }
102 ~InputController() { }
103
105 static bool s_canControlInput;
106
108 static bool s_doEventMerging;
109
112
118 static std::pair<long, long> s_nextEntry;
119
124 static long s_nextExperiment;
125
127 static long s_nextRun;
128
130 static long s_nextEvent;
131
133 static std::pair<long, long> s_eventNumbers;
134
138 static std::pair<long, long> s_currentEntry;
139
143 static std::pair<long, long> s_skippedEntries;
144
148 static std::pair<const TChain*, const TChain*> s_chain;
149 };
151}
A static class to control supported input modules.
static std::string getCurrentFileName(bool independentPath=false)
Return name of current file in loaded chain (or empty string if none loaded).
static long getNextRun()
Return run number set via setNextEntry().
static long getSkippedEntries(bool independentPath=false)
returns the number of entries skipped by the RootInputModule.
static void setNextEntry(long entry, bool independentPath=false)
Set the file entry to be loaded the next time event() is called.
static long getNextExperiment()
Return experiment number set via setNextEntry().
static bool getEventMerging()
Get if we are merging events from two paths.
static long getCurrentEntry(bool independentPath=false)
returns the entry number currently loaded.
static std::pair< long, long > s_currentEntry
current entry in file.
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 entr...
static long numEntries(bool independentPath=false)
Returns total number of entries in the event tree.
static void resetForChildProcess()
Reset InputController (e.g.
static long s_nextExperiment
Experiment number to load next.
static long getNextEntry(bool independentPath=false)
Return entry number set via setNextEntry().
static long getNumEntriesToProcess()
Necessary to make sure the ProgressModule shows reasonable output.
static std::pair< long, long > s_skippedEntries
entries skipped by RootInputModule (if any) Storing two values (second one if independent path is exe...
static void enableEventMerging(Module *steerRootInputModule)
Set that we are merging events from two paths.
static bool canControlInput()
Is there an input module to be controlled.
static void setSkippedEntries(long entries, bool independentPath=false)
set the number of entries skipped by the RootInputModule.
static long s_nextEvent
Event (not entry!) to load next.
static long s_nextRun
Run number to load next.
static std::pair< const TChain *, const TChain * > s_chain
Opened TChain (event durability).
static void setChain(const TChain *chain, bool independentPath=false)
Set the loaded TChain (event durability).
static Module * s_steerRootInputModule
Explicit pointer to steerRootInput.
static void setCanControlInput(bool on)
Call this function from supported input modules.
static bool s_doEventMerging
Are we merging events from two paths?
static std::pair< long, long > s_nextEntry
entry to be loaded the next time event() is called in an input module.
static bool s_canControlInput
Is there an input module to be controlled?
static long getNextEvent()
Return event number set via setNextEntry().
static std::pair< long, long > s_eventNumbers
number of events in paths if two input modules are used (independent paths)
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.
Base class for Modules.
Definition: Module.h:72
Abstract base class for different kinds of events.