Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
QAEventTask.cxx
1/*
2 * QAEventTask.cxx
3 *
4 * Created on: 14 paź 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "QAEventTask.h"
11
12
13#include "Cout.h"
14#include "Event.h"
15#include "Package.h"
16#include "QAPlotReport.h"
17#include "Std.h"
18#include "Track.h"
19
20namespace Hal {
21 QAEventTask::QAEventTask() : fEventQA(nullptr), fTempEventPlot(nullptr) { AddTags("qa"); }
22
23 QAEventTask::~QAEventTask() {
24 if (fEventQA) delete fEventQA;
25 if (fTempEventPlot) delete fTempEventPlot;
26 }
27
28 QAEventTask::QAEventTask(const QAEventTask& other) : EventAna(other), fEventQA(nullptr), fTempEventPlot(nullptr) {
29 if (other.fEventQA) {
30 fEventQA = new TObjArray();
31 for (int i = 0; i < other.fEventQA->GetEntriesFast(); i++) {
32 QAPlot* plot = (QAPlot*) other.fEventQA->UncheckedAt(i);
33 fEventQA->Add(plot->MakeCopy());
34 }
35 }
36 if (other.fTempEventPlot) { fTempEventPlot = other.fTempEventPlot->MakeCopy(); }
37 fEventColNames = other.fEventColNames;
38 }
39
40 Task::EInitFlag QAEventTask::Init() {
41 Task::EInitFlag stat = EventAna::Init();
42 if (stat == Task::EInitFlag::kFATAL) return stat;
43 if (fTempEventPlot == nullptr) {
44 Cout::PrintInfo("Lack of Event QA", EInfo::kError);
45 return Task::EInitFlag::kFATAL;
46 } else {
47 fEventQA = new TObjArray();
48 for (int i = 0; i < fEventCollectionsNo; i++) {
49 QAPlot* plot = fTempEventPlot->MakeCopy();
50 plot->Init(GetTaskID());
51 fEventQA->Add(plot);
52 }
53 delete fTempEventPlot;
54 fTempEventPlot = nullptr;
55 }
56 return Task::EInitFlag::kSUCCESS;
57 }
58
59 Package* QAEventTask::Report() const {
60 Package* report = EventAna::Report();
61 for (int i = 0; i < fEventCollectionsNo; i++) {
62 QAPlot* plot = (QAPlot*) fEventQA->UncheckedAt(i);
63 QAPlotReport* event_report = plot->GetReport();
64 if (i < (int) fEventColNames.size()) {
65 event_report->SetName(fEventColNames[i]);
66 } else {
67 event_report->SetName(Form("Ev %i", i));
68 }
69 event_report->Recalculate();
70 report->AddObject(event_report);
71 }
72 return report;
73 }
74
75 void QAEventTask::SetQAPlot(const QAPlot& plot) {
76 if (plot.GetUpdateRatio() == ECutUpdate::kEvent) fTempEventPlot = plot.MakeCopy();
77 }
78
79 void QAEventTask::ProcessEvent() { GetQAPlot(fCurrentEventCollectionID)->Fill(fCurrentEvent); }
80
81 QAEventTask& QAEventTask::operator=(const QAEventTask& other) {
82 if (this == &other) return *this;
83 if (other.fTempEventPlot) {
84 if (fTempEventPlot) delete fTempEventPlot;
85 fTempEventPlot = other.fTempEventPlot->MakeCopy();
86 }
87 fEventColNames = other.fEventColNames;
88 return *this;
89 }
90} // namespace Hal
void AddObject(TObject *object)
Definition Package.cxx:209
virtual void Recalculate()
virtual void Fill(TObject *obj)
Definition QAPlot.cxx:144
virtual Bool_t Init(Int_t id_task=-1)
Definition QAPlot.cxx:47
virtual QAPlot * MakeCopy() const
Definition QAPlot.h:142