Skip to content

Commit a500e40

Browse files
committed
enable start TaskManager::Run() from arbitrary event
1 parent 22712e8 commit a500e40

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

infra/TaskManager.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,18 @@ void TaskManager::InitOutChain() {
9393
}
9494

9595
void TaskManager::Run(long long nEvents) {
96+
if (chain_->GetEntries() > 0) {
97+
nEvents = nEvents < 0 || nEvents > chain_->GetEntries() ? chain_->GetEntries() : nEvents;
98+
}
99+
Run(0, nEvents);
100+
}
96101

102+
void TaskManager::Run(long long nEventFrom, long long nEvents) {
97103
std::cout << "AnalysisTree::Manager::Run" << std::endl;
98104
auto start = std::chrono::system_clock::now();
99105

100-
if (chain_->GetEntries() > 0) {
101-
nEvents = nEvents < 0 || nEvents > chain_->GetEntries() ? chain_->GetEntries() : nEvents;
106+
if (nEventFrom + nEvents > chain_->GetEntries()) {
107+
throw std::runtime_error("TaskManager::Run() - nEventFrom + nEvents > chain_->GetEntries()");
102108
}
103109

104110
if (verbosity_frequency_ > 0) {
@@ -107,7 +113,7 @@ void TaskManager::Run(long long nEvents) {
107113
verbosity_period_ = static_cast<int>(std::pow(10, vPlog));
108114
}
109115

110-
for (long long iEvent = 0; iEvent < nEvents; ++iEvent) {
116+
for (long long iEvent = nEventFrom; iEvent < nEventFrom + nEvents; ++iEvent) {
111117
if (verbosity_period_ > 0 && iEvent % verbosity_period_ == 0) {
112118
std::cout << "Event no " << iEvent << "\n";
113119
}

infra/TaskManager.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class TaskManager {
5555
* Initialization in case of only creating AnalysisTree
5656
*/
5757
virtual void Init();
58-
virtual void Run(long long nEvents = -1);
58+
void Run(long long nEventFrom, long long nEvents);
59+
void Run(long long nEvents = -1);
5960
virtual void Finish();
6061

6162
void AddTask(Task* task) { tasks_.emplace_back(task); }

0 commit comments

Comments
 (0)