Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
PropertyMonitorX.cxx
1/*
2 * CutMonitorObjectX.cxx
3 *
4 * Created on: 21 sie 2020
5 * Author: Daniel Wielanek
6 * E-mail: daniel.wielanek@gmail.com
7 * Warsaw University of Technology, Faculty of Physics
8 */
9
10#include "PropertyMonitorX.h"
11
12#include "ComplexEvent.h"
13#include "ComplexTrack.h"
14#include "Cout.h"
15#include "DataFormatManager.h"
16#include "Event.h"
17#include "Package.h"
18#include "Parameter.h"
19#include "Std.h"
20#include "StdString.h"
21
22#include <TAttFill.h>
23#include <TAxis.h>
24#include <TH1.h>
25#include <TString.h>
26#include <iostream>
27
28
29namespace Hal {
31 TH1::AddDirectory(kFALSE);
32 TString title = Form("%s", Hal::Std::RemoveUnits(fXaxisName).Data());
33 TString name = "Passed";
34 fHistoPassed = new TH1D(name, title, fAxisBins[0], fAxisMin[0], fAxisMax[0]);
35 fHistoPassed->GetXaxis()->SetTitle(fXaxisName);
36 fHistoPassed->GetYaxis()->SetTitle(fYaxisName);
37 fHistoPassed->SetFillColor(kGreen);
38 name = "Failed";
39 fHistoFailed = (TH1D*) fHistoPassed->Clone(name);
40 fHistoFailed->SetFillColor(kRed);
41 TH1::AddDirectory(kTRUE);
42 }
43
44 PropertyMonitorX::PropertyMonitorX(TString xLabel, TString yLabel, ECutUpdate update) :
45 CutMonitorX(), fXaxisName(xLabel), fYaxisName(yLabel), fFormatType(EFormatType::kReco) {
46 fUpdateRatio = update;
47 }
48
50 fXaxisName = other.fXaxisName;
51 fYaxisName = other.fYaxisName;
52 fFormatType = other.fFormatType;
53 }
54
55 Bool_t PropertyMonitorX::Init(Int_t task_id) {
56 if (fInit) {
57#ifdef HAL_DEBUG
58 Cout::PrintInfo(Form("%s is initialized ", this->ClassName()), EInfo::kDebugInfo);
59#endif
60 return kFALSE;
61 }
62 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
63 fFormatType = ev->GetFormatType();
64 TH1::AddDirectory(kFALSE);
66 TH1::AddDirectory(kTRUE);
67 fInit = kTRUE;
68 return kTRUE;
69 }
70
72 Package* report = CutMonitorX::Report();
73 report->AddObject(new ParameterString("AxisX", fXaxisName));
74 report->AddObject(new ParameterString("CutXName", "-"));
75 report->AddObject(new ParameterDouble("CutXMin", 0));
76 report->AddObject(new ParameterDouble("CutXMax", 0));
77 report->AddObject(new ParameterInt("CutXAxis", 0));
78 report->AddObject(new ParameterInt("CutXCollection", fCollectionID));
79 return report;
80 }
81
83 if (this != &other) {
85 fXaxisName = other.fXaxisName;
86 fYaxisName = other.fYaxisName;
87 fFormatType = other.fFormatType;
88 }
89 return *this;
90 }
91
92 PropertyMonitorX::~PropertyMonitorX() {}
93
94 //========================================================================
96 PropertyMonitorX("", "N_{events}", ECutUpdate::kEvent), fFieldID(fieldID) {}
97
98 EventFieldMonitorX::EventFieldMonitorX(Int_t fieldID, std::initializer_list<Double_t> xAxis) : EventFieldMonitorX(fieldID) {
99 SetAxisList(xAxis, 'x');
100 }
101
102 void EventFieldMonitorX::Update(Bool_t passed, TObject* obj) {
103 Event* ev = (Event*) obj;
104 if (passed) {
105 fHistoPassed->Fill(ev->GetFieldVal(fFieldID));
106 } else {
107 fHistoFailed->Fill(ev->GetFieldVal(fFieldID));
108 }
109 }
110
111 Bool_t EventFieldMonitorX::Init(Int_t task_id) {
112 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
113 fXaxisName = ev->GetFieldName(fFieldID);
114 return PropertyMonitorX::Init(task_id);
115 }
116 //========================================================================
118 PropertyMonitorX("", "N_{tracks}", ECutUpdate::kTrack), fFieldID(fieldID) {}
119
120 TrackFieldMonitorX::TrackFieldMonitorX(Int_t fieldID, std::initializer_list<Double_t> xAxis) : TrackFieldMonitorX(fieldID) {
121 SetAxisList(xAxis, 'x');
122 }
123
124 void TrackFieldMonitorX::Update(Bool_t passed, TObject* obj) {
125 Track* tr = (Track*) obj;
126 if (passed) {
127 fHistoPassed->Fill(tr->GetFieldVal(fFieldID));
128 } else {
129 fHistoFailed->Fill(tr->GetFieldVal(fFieldID));
130 }
131 }
132
133 Bool_t TrackFieldMonitorX::Init(Int_t task_id) {
134 const Event* ev = DataFormatManager::Instance()->GetFormat(task_id, EFormatDepth::kNonBuffered);
135 if (ev->InheritsFrom("Hal::ComplexEvent")) {
137 ComplexEvent* tev = (ComplexEvent*) ev->GetNewEvent();
138 tr->SetEvent(tev);
139 fXaxisName = tr->GetFieldName(fFieldID);
140 delete tr;
141 delete tev;
142 } else {
143 Track* tr = ev->GetNewTrack();
144 fXaxisName = tr->GetFieldName(fFieldID);
145 delete tr;
146 }
147 return PropertyMonitorX::Init(task_id);
148 }
149} // namespace Hal
virtual TString GetFieldName(Int_t fieldID) const
static void PrintInfo(TString text, Hal::EInfo status)
Definition Cout.cxx:370
CutMonitorX & operator=(const CutMonitorX &other)
Double_t * fAxisMax
Definition CutMonitor.h:63
Int_t fCollectionID
Definition CutMonitor.h:39
Int_t * fAxisBins
Definition CutMonitor.h:43
void SetAxisList(std::initializer_list< Double_t > axis, Char_t opt)
Double_t * fAxisMin
Definition CutMonitor.h:59
ECutUpdate fUpdateRatio
Definition CutMonitor.h:83
virtual Package * Report() const
const Event * GetFormat(Int_t task_id, EFormatDepth format_depth=EFormatDepth::kAll) const
static DataFormatManager * Instance()
virtual void Update(Bool_t passed, TObject *obj)
EventFieldMonitorX(Int_t fieldID=0)
virtual Bool_t Init(Int_t task_id)
virtual EFormatType GetFormatType() const
Definition Event.h:266
Track * GetNewTrack() const
Definition Event.cxx:204
virtual Float_t GetFieldVal(Int_t fieldID) const
Definition Event.cxx:254
virtual Event * GetNewEvent() const
Definition Event.cxx:215
virtual TString GetFieldName(Int_t fieldID) const
Definition Event.cxx:272
void AddObject(TObject *object)
Definition Package.cxx:209
virtual Package * Report() const
virtual Bool_t Init(Int_t task_id)
PropertyMonitorX(TString xLabel="", TString yLabel="", ECutUpdate ratio=ECutUpdate::kEvent)
virtual void CreateHistograms()
PropertyMonitorX & operator=(const PropertyMonitorX &other)
TrackFieldMonitorX(Int_t fieldID=0)
virtual void Update(Bool_t passed, TObject *obj)
virtual Bool_t Init(Int_t task_id)
void SetEvent(Event *event)
Definition Track.h:337
virtual Float_t GetFieldVal(Int_t fieldID) const
Definition Track.cxx:206
virtual TString GetFieldName(Int_t fieldID) const
Definition Track.cxx:244