9#include "QATrackTask.h"
13#include "CutCollection.h"
14#include "CutContainer.h"
23 QATrackTask::QATrackTask() :
24 TrackAna(), fEventQA(nullptr), fTempEventPlot(nullptr), fTrackQA(nullptr), fTempTrackPlot(nullptr) {
28 QATrackTask::~QATrackTask() {
29 if (fEventQA)
delete fEventQA;
30 if (fTempEventPlot)
delete fTempEventPlot;
31 if (fTrackQA)
delete fTrackQA;
32 if (fTempTrackPlot)
delete fTempTrackPlot;
35 QATrackTask::QATrackTask(
const QATrackTask& other) :
36 TrackAna(other), fEventQA(nullptr), fTempEventPlot(nullptr), fTrackQA(nullptr), fTempTrackPlot(nullptr) {
38 fEventQA = new TObjArray();
39 for (int i = 0; i < other.fEventQA->GetEntriesFast(); i++) {
40 QAPlot* plot = (QAPlot*) other.fEventQA->UncheckedAt(i);
41 fEventQA->Add(plot->MakeCopy());
44 if (other.fTempEventPlot) { fTempEventPlot = other.fTempEventPlot->MakeCopy(); }
47 fTrackQA = new TObjArray();
48 for (int i = 0; i < other.fTrackQA->GetEntriesFast(); i++) {
49 QAPlot* plot = (QAPlot*) other.fTrackQA->UncheckedAt(i);
50 fTrackQA->Add(plot->MakeCopy());
53 fEventColNames = other.fEventColNames;
54 fTrackColNames = other.fTrackColNames;
55 if (other.fTempTrackPlot) { fTempTrackPlot = other.fTempTrackPlot->MakeCopy(); }
58 void QATrackTask::SetQAPlot(
const QAPlot& plot) {
59 switch (plot.GetUpdateRatio()) {
60 case ECutUpdate::kEvent: {
61 fTempEventPlot = plot.MakeCopy();
63 case ECutUpdate::kTrack: {
64 fTempTrackPlot = plot.MakeCopy();
67 Cout::PrintInfo(
"Unkown QAPlot::GetUpdateRatio()", EInfo::kLowWarning);
72 void QATrackTask::ProcessEvent() {
73 TrackAna::ProcessEvent();
74 GetEventQAPlot(fCurrentEventCollectionID)->Fill(fCurrentEvent);
77 void QATrackTask::ProcessTrack() {
78 Int_t
id = fCurrentEventCollectionID * fTrackCollectionsNo + fCurrentTrackCollectionID;
79 GetTrackQAPlot(
id)->Fill(fCurrentTrack);
82 Task::EInitFlag QATrackTask::Init() {
83 Task::EInitFlag stat = TrackAna::Init();
84 if (stat == Task::EInitFlag::kFATAL)
return stat;
85 if (fTempEventPlot ==
nullptr) { fTempEventPlot =
new QAPlot(
"Null", ECutUpdate::kEvent); }
86 if (fTempTrackPlot ==
nullptr) {
87 Cout::PrintInfo(
"Lack of Track QA", EInfo::kError);
88 return Task::EInitFlag::kFATAL;
90 fEventQA =
new TObjArray();
91 for (
int i = 0; i < fEventCollectionsNo; i++) {
93 plot->
Init(GetTaskID());
96 delete fTempEventPlot;
97 fTempEventPlot =
nullptr;
99 fTrackQA =
new TObjArray();
100 for (
int i = 0; i < fTrackCollectionsNo * fEventCollectionsNo; i++) {
102 plot->
Init(GetTaskID());
105 delete fTempTrackPlot;
106 fTempTrackPlot =
nullptr;
107 return Task::EInitFlag::kSUCCESS;
111 if (
this == &other)
return *
this;
112 if (other.fTempEventPlot) {
113 if (fTempEventPlot)
delete fTempEventPlot;
114 fTempEventPlot = other.fTempEventPlot->
MakeCopy();
116 if (other.fTempTrackPlot) {
117 if (fTempTrackPlot)
delete fTempTrackPlot;
118 fTempTrackPlot = other.fTempTrackPlot->
MakeCopy();
120 fEventColNames = other.fEventColNames;
121 fTrackColNames = other.fTrackColNames;
125 void QATrackTask::LinkCollections() {
126 fCutContainer->LinkCollections(ECutUpdate::kEvent, ECutUpdate::kTrack, CutContainer::ELinkPolicy::kAnyToAny);
130 Package* pack = TrackAna::Report();
131 const Int_t eventCol = fEventQA->GetEntries();
132 const Int_t trackCol = fTrackQA->GetEntries() / fEventQA->GetEntries();
134 for (
int iEventCol = 0; iEventCol < eventCol; iEventCol++) {
138 TString eventColName = Form(
"Event coll. %i", iEventCol);
139 if ((
int) fEventColNames.size() > iEventCol) { eventColName = fEventColNames[iEventCol]; }
140 event_report->SetName(eventColName);
142 for (
int jTrackCol = 0; jTrackCol < trackCol; jTrackCol++) {
143 QAPlot* qa_track = (
QAPlot*) fTrackQA->At(iEventCol * trackCol + jTrackCol);
146 if (jTrackCol < (
int) fTrackColNames.size()) {
147 TString name = Form(
"%s %s", eventColName.Data(), fTrackColNames[jTrackCol].Data());
148 track_report->SetName(name);
150 track_report->SetName(Form(
"Event coll. %i Track coll. %i", iEventCol, jTrackCol));
158 void QATrackTask::SetEventCollectionNames(
const std::initializer_list<TString>& init) {
159 fEventColNames.clear();
160 for (
auto const name : init) {
161 fEventColNames.push_back(name);
165 void QATrackTask::SetTrackCollectionNames(
const std::initializer_list<TString>& init) {
166 fTrackColNames.clear();
167 for (
auto const name : init) {
168 fTrackColNames.push_back(name);
void AddObject(TObject *object)
virtual void Recalculate()
virtual Bool_t Init(Int_t id_task=-1)
virtual QAPlot * MakeCopy() const