|
11 | 11 | * or submit itself to any jurisdiction. *
|
12 | 12 | ******************************************************************************/
|
13 | 13 |
|
| 14 | +// NOTE: comments below are only meant for eduational purpose. DO NOT include them in your code! |
| 15 | + |
14 | 16 | // ROOT headers
|
15 |
| -#include "TClonesArray.h" |
16 |
| -#include "TMath.h" |
17 |
| -#include "TRandom.h" |
| 17 | +#include <TClonesArray.h> |
| 18 | +#include <TMath.h> |
| 19 | +#include <TRandom.h> |
18 | 20 |
|
19 | 21 | // Fair headers
|
20 |
| -#include "FairLogger.h" |
21 |
| -#include "FairRootManager.h" |
22 |
| -#include "FairRunAna.h" |
23 |
| -#include "FairRuntimeDb.h" |
| 22 | +#include <FairLogger.h> |
| 23 | +#include <FairRootManager.h> |
| 24 | +#include <FairRunAna.h> |
| 25 | +#include <FairRuntimeDb.h> |
24 | 26 |
|
25 | 27 | // R3B headers
|
26 | 28 | #include "NewTask.h"
|
| 29 | +#include <R3BLogger.h> |
| 30 | +#include <fmt/core.h> |
27 | 31 |
|
28 |
| -// ---- Default constructor ------------------------------------------- |
29 |
| -NewTask::NewTask() |
30 |
| - : NewTask("NewTask", 1) |
31 |
| -{ |
32 |
| -} |
33 |
| - |
34 |
| -// ---- Standard Constructor ------------------------------------------ |
35 |
| -NewTask::NewTask(const TString& name, Int_t iVerbose) |
36 |
| - : FairTask(name, iVerbose) |
37 |
| - , fOnline(kFALSE) |
38 |
| -{ |
39 |
| -} |
40 |
| - |
41 |
| -// ---- Destructor ---------------------------------------------------- |
42 |
| -NewTask::~NewTask() |
43 |
| -{ |
44 |
| - LOG(debug) << "Destructor of NewTask"; |
45 |
| - if (fDataInput) |
46 |
| - delete fDataInput; |
47 |
| -} |
48 |
| - |
49 |
| -// ---- Initialisation ---------------------------------------------- |
50 |
| -void NewTask::SetParContainers() |
51 |
| -{ |
52 |
| - LOG(debug) << "SetParContainers of NewTask"; |
53 |
| - // Load all necessary parameter containers from the runtime data base |
54 |
| -} |
55 |
| - |
56 |
| -// ---- Init ---------------------------------------------------------- |
57 |
| -InitStatus NewTask::Init() |
| 32 | +namespace R3B |
58 | 33 | {
|
59 |
| - LOG(info) << "NewTask::Init()"; |
| 34 | + // ---- Standard Constructor ------------------------------------------ |
| 35 | + NewTask::NewTask(const std::string& name, int iVerbose) |
| 36 | + : FairTask(name.c_str(), iVerbose) |
| 37 | + { |
| 38 | + } |
60 | 39 |
|
61 |
| - // Get a handle from the IO manager |
62 |
| - FairRootManager* ioman = FairRootManager::Instance(); |
63 |
| - if (!ioman) |
| 40 | + // ---- Default constructor ------------------------------------------- |
| 41 | + // use constructor delegation |
| 42 | + NewTask::NewTask() |
| 43 | + : NewTask("NewTask", 1) |
64 | 44 | {
|
65 |
| - return kFATAL; |
66 | 45 | }
|
67 | 46 |
|
68 |
| - // Get a pointer to the previous already existing data level |
69 |
| - /* |
70 |
| - fDataInput = (TClonesArray*) ioman->GetObject("InputDataLevelName"); |
71 |
| - if ( ! fDataInput ) { |
72 |
| - return kERROR; |
| 47 | + // ---- Initialisation ---------------------------------------------- |
| 48 | + void NewTask::SetParContainers() |
| 49 | + { |
| 50 | + R3BLOG(debug, "SetParContainers of NewTask"); |
| 51 | + // Load all necessary parameter containers from the runtime data base |
73 | 52 | }
|
74 |
| - */ |
75 | 53 |
|
76 |
| - // Create the TClonesArray for the output data and register it |
77 |
| - /* |
78 |
| - fDataOutput = new TClonesArray("OutputDataLevelName", 10); |
79 |
| - ioman->Register("OutputDataLevelName","OutputDataLevelName",fDataOutput,fOnline); |
80 |
| - */ |
| 54 | + // ---- Init ---------------------------------------------------------- |
| 55 | + InitStatus NewTask::Init() |
| 56 | + { |
| 57 | + R3BLOG(debug, "NewTask::Init()"); |
81 | 58 |
|
82 |
| - // Do whatever else is needed at the initilization stage |
83 |
| - // Create histograms to be filled |
84 |
| - // initialize variables |
| 59 | + // Get a handle from the IO manager |
| 60 | + if (auto* ioman = FairRootManager::Instance(); ioman == nullptr) |
| 61 | + { |
| 62 | + return kFATAL; |
| 63 | + } |
85 | 64 |
|
86 |
| - return kSUCCESS; |
87 |
| -} |
| 65 | + input_data_.init(); |
| 66 | + output_data_.init(); |
88 | 67 |
|
89 |
| -// ---- ReInit ------------------------------------------------------- |
90 |
| -InitStatus NewTask::ReInit() |
91 |
| -{ |
92 |
| - LOG(debug) << "ReInit of NewTask"; |
93 |
| - SetParContainers(); |
94 |
| - return kSUCCESS; |
95 |
| -} |
| 68 | + // Do whatever else is needed at the initilization stage |
| 69 | + // Create histograms to be filled |
| 70 | + // initialize variables |
96 | 71 |
|
97 |
| -// ---- Exec ---------------------------------------------------------- |
98 |
| -void NewTask::Exec(Option_t* opt) { LOG(debug) << "Exec of NewTask"; } |
| 72 | + return kSUCCESS; |
| 73 | + } |
99 | 74 |
|
100 |
| -// ---- Finish -------------------------------------------------------- |
101 |
| -void NewTask::Finish() { LOG(debug) << "Finish of NewTask"; } |
| 75 | + // ---- Exec ---------------------------------------------------------- |
| 76 | + void NewTask::Exec(Option_t* /*opt*/) |
| 77 | + { |
| 78 | + R3BLOG(debug, "Exec of NewTask"); |
| 79 | + output_data_.clear(); |
| 80 | + |
| 81 | + // Read input data |
| 82 | + for (const auto& calData : input_data_) |
| 83 | + { |
| 84 | + // do something with calData |
| 85 | + fmt::print("qdc value: {}", calData.GetQdc()); |
| 86 | + |
| 87 | + // to write data: |
| 88 | + output_data_.get().emplace_back(); |
| 89 | + } |
| 90 | + } |
102 | 91 |
|
103 |
| -// ---- Reset --------------------------------------------------------- |
104 |
| -void NewTask::Reset() |
105 |
| -{ |
106 |
| - LOG(debug) << "Reset Data Structures"; |
107 |
| - if (fDataOutput) |
108 |
| - fDataOutput->Clear(); |
109 |
| -} |
| 92 | + // ---- Finish -------------------------------------------------------- |
| 93 | + void NewTask::Finish() { R3BLOG(debug, "Finish of NewTask"); } |
| 94 | +} // namespace R3B |
110 | 95 |
|
111 |
| -ClassImp(NewTask); |
| 96 | +ClassImp(R3B::NewTask); |
0 commit comments