Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CutMonitorX.cxx
1/*
2 * CutMonitorX.cxx
3 *
4 * Created on: 10-07-2013
5 * Author: Daniel Wielanek
6 */
7
8#include "CutMonitorX.h"
9
10
11#include <TAttFill.h>
12#include <TAxis.h>
13#include <TH1.h>
14#include <TString.h>
15
16#include "Cut.h"
17#include "StdString.h"
18
19namespace Hal {
20 CutMonitorX::CutMonitorX() : CutMonitor(1) {}
21
22 CutMonitorX::CutMonitorX(TString cut_name, Int_t parameter_no, std::initializer_list<Double_t> list) :
23 CutMonitorX(cut_name, parameter_no) {
24 auto vec = Hal::Std::GetVector(list);
25 if (vec.size() < 3) return;
26 SetXaxis(vec[0], vec[1], vec[2]);
27 }
28
29 CutMonitorX::CutMonitorX(TString cut_name, Int_t parameter_no) : CutMonitorX() { AddCut(cut_name, parameter_no); }
30
31 void CutMonitorX::TrueUpdate(Bool_t passed) {
32#ifdef MPPCUTFULL
33 if (passed) {
34 fHistoPassed->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[0]->GetWeight());
35 } else {
36 fHistoFailed->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[0]->GetWeight());
37 }
38#else
39 if (passed) {
40 fHistoPassed->Fill(fCut[0]->GetValue(fOptionAxis[0]), 1.0);
41 } else {
42 fHistoFailed->Fill(fCut[0]->GetValue(fOptionAxis[0]), 1.0);
43 }
44#endif
45 }
46
47 CutMonitor* CutMonitorX::MakeCopy() const { return (CutMonitor*) new CutMonitorX(*this); }
48
49 CutMonitorX::CutMonitorX(const CutMonitorX& other) : CutMonitor(other) {}
50
51 CutMonitorX::~CutMonitorX() {}
52
53 void CutMonitorX::Update(Bool_t passed, TObject* /*obj*/) {
54 if (fExUpdate) {
55 TrueUpdate(fCut[0]->HasPassed());
56 } else {
57 TrueUpdate(passed);
58 }
59 }
60
62 TString title = Form("%s", Hal::Std::RemoveUnits(fCut[0]->GetUnit(fOptionAxis[0])).Data());
63 TString name = "Passed";
64 fHistoPassed = new TH1D(name, title, fAxisBins[0], fAxisMin[0], fAxisMax[0]);
65 fHistoPassed->GetXaxis()->SetTitle(fCut[0]->GetUnit(fOptionAxis[0]).Data());
66 TString y_axis_name = fCut[0]->GetGroupFlag(); // take flag group like dNTracks
67 TString y_axis_name_units = fCut[0]->GetUnit(fOptionAxis[0]);
68 y_axis_name = y_axis_name + "/";
69 y_axis_name = y_axis_name + Hal::Std::RemoveUnits(y_axis_name_units);
70 fHistoPassed->GetYaxis()->SetTitle(y_axis_name);
71 fHistoPassed->SetFillColor(kGreen);
72 name = "Failed";
73 fHistoFailed = (TH1D*) fHistoPassed->Clone(name);
74 fHistoFailed->SetFillColor(kRed);
75 }
76
77 Bool_t CutMonitorX::Init(Int_t task_id) {
78 if (fInit == kFALSE) { return CutMonitor::Init(task_id); }
79 return kFALSE;
80 }
81
83 if (this != &other) { CutMonitor::operator=(other); }
84 return *this;
85 }
86} // namespace Hal
CutMonitorX & operator=(const CutMonitorX &other)
virtual CutMonitor * MakeCopy() const
void TrueUpdate(Bool_t)
virtual Bool_t Init(Int_t task_id)
virtual void Update(Bool_t passed, TObject *obj)
virtual void CreateHistograms()
CutMonitor & operator=(const CutMonitor &other)
void AddCut(TString cut, Int_t parameter_no=0)
Double_t * fAxisMax
Definition CutMonitor.h:63
virtual Bool_t Init(Int_t task_id)
Int_t * fAxisBins
Definition CutMonitor.h:43
Int_t * fOptionAxis
Definition CutMonitor.h:47
Double_t * fAxisMin
Definition CutMonitor.h:59
void SetXaxis(Int_t bins, Double_t min, Double_t max)
TString GetGroupFlag() const
Definition Cut.h:204
TString GetUnit(Int_t i) const
Definition Cut.h:311