AnalysisTree
Loading...
Searching...
No Matches
Task.hpp
1/* Copyright (C) 2019-2021 GSI, Universität Tübingen
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Viktor Klochkov, Ilya Selyuzhenkov */
4#ifndef ANALYSISTREE_INFRA_TASK_HPP_
5#define ANALYSISTREE_INFRA_TASK_HPP_
6
7#include <set>
8
9#include "Configuration.hpp"
10#include "Constants.hpp"
11#include "EventHeader.hpp"
12
13#include "Chain.hpp"
14#include "Cuts.hpp"
15
16class TChain;
17class TTree;
18class TFile;
19
20namespace AnalysisTree {
21
22class Configuration;
23class DataHeader;
24
25class Task {
26
27 public:
28 Task() = default;
29 virtual ~Task() = default;
30
31 virtual void Init() = 0;
32 virtual void Exec() = 0;
33 virtual void Finish() = 0;
34
35 void PreInit();
36
37 void SetInConfiguration(const Configuration* config) { config_ = config; }
38 void SetDataHeader(const DataHeader* data_header) { data_header_ = data_header; }
39
40 void SetInputBranchNames(const std::set<std::string>& br) { in_branches_ = br; }
41
42 ANALYSISTREE_ATTR_NODISCARD const std::set<std::string>& GetInputBranchNames() const { return in_branches_; }
43
44 ANALYSISTREE_ATTR_NODISCARD bool IsGoodEvent(const EventHeader& event_header) const {
45 return event_cuts_ == nullptr || event_cuts_->Apply(event_header);
46 }
47
48 ANALYSISTREE_ATTR_NODISCARD bool IsGoodEvent(const Chain& t) const;
49
50 void SetEventCuts(Cuts* cuts) {
51 if (cuts->GetBranches().size() != 1) {
52 throw std::runtime_error("Event cuts on only 1 branch are allowed at the moment!");
53 }
54 event_cuts_ = cuts;
55 }
56
57 void AddInputBranch(const std::string& name) { in_branches_.emplace(name); }
58
59 protected:
60 const Configuration* config_{nullptr};
61 const DataHeader* data_header_{nullptr};
62
63 Cuts* event_cuts_{nullptr};
64
65 std::set<std::string> in_branches_{};
66 bool is_init_{false};
67
68 ClassDef(Task, 0);
69};
70
71}// namespace AnalysisTree
72
73#endif//ANALYSISTREE_INFRA_TASK_HPP_
Definition Chain.hpp:24
A class to store configuration of the whole AnalysisTree object.
Definition Configuration.hpp:58
Cuts holds list of SimpleCuts and provides Apply function which subsequently applies cuts.
Definition Cuts.hpp:25
bool Apply(const T &object) const
Evaluates all SimpleCuts.
Definition Cuts.hpp:58
Definition DataHeader.hpp:19
Definition EventHeader.hpp:18
Definition Task.hpp:25
Cuts keep list of SimpleCuts. Logical AND is applied for all SimpleCut in the Cuts object.
Definition BranchConfig.cpp:10