Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CutMonitorXYZ.cxx
1/*
2 * CutMonitorXYZ.cxx
3 *
4 * Created on: 10-07-2013
5 * Author: Daniel Wielanek
6 */
7
8#include "CutMonitorXYZ.h"
9
10
11#include <TAxis.h>
12#include <TH1.h>
13#include <TH3.h>
14#include <TString.h>
15
16#include "Cut.h"
17#include "StdString.h"
18
19namespace Hal {
20 CutMonitorXYZ::CutMonitorXYZ() : CutMonitor(3) {
21#ifdef MPPCUTFULL
22 fWeightFlag = 0;
23#endif
24 }
25
26 CutMonitorXYZ::CutMonitorXYZ(TString cut_A, TString cut_B, TString cut_C) : CutMonitorXYZ() {
27 AddCut(cut_A);
28 AddCut(cut_B);
29 AddCut(cut_C);
30 }
31
32 CutMonitorXYZ::CutMonitorXYZ(TString cut_A,
33 Int_t par_A,
34 std::initializer_list<Double_t> xAxis,
35 TString cut_B,
36 Int_t par_B,
37 std::initializer_list<Double_t> yAxis,
38 TString cut_C,
39 Int_t par_C,
40 std::initializer_list<Double_t> zAxis) :
41 CutMonitorXYZ(cut_A, par_A, cut_B, par_B, cut_C, par_C) {
42 auto vecX = Hal::Std::GetVector(xAxis);
43 auto vecY = Hal::Std::GetVector(yAxis);
44 auto vecZ = Hal::Std::GetVector(zAxis);
45 if (vecX.size() == 3) { SetXaxis(vecX[0], vecX[1], vecX[2]); }
46 if (vecY.size() == 3) { SetYaxis(vecY[0], vecY[1], vecY[2]); }
47 if (vecZ.size() == 3) { SetZaxis(vecZ[0], vecZ[1], vecZ[2]); }
48 }
49 CutMonitorXYZ::CutMonitorXYZ(TString cut_A, Int_t par_A, TString cut_B, Int_t par_B, TString cut_C, Int_t par_C) :
51 AddCut(cut_A, par_A);
52 AddCut(cut_B, par_B);
53 AddCut(cut_C, par_C);
54 }
55
56 void CutMonitorXYZ::TrueUpdate(Bool_t pass) {
57#ifdef MPPCUTFULL
58 Double_t weight = fCut[0]->GetWeight();
59 switch (fWeightFlag) {
60 case 2: weight = fCut[0]->GetWeight() * fCut[2]->GetWeight(); break;
61 case 3: weight = fCut[0]->GetWeight() * fCut[1]->GetWeight(); break;
62 case 1: weight = fCut[0]->GetWeight(); break;
63 default: weight = fCut[0]->GetWeight() * fCut[1]->GetWeight() * fCut[2]->GetWeight(); break;
64 }
65 if (pass) {
66 ((TH3F*) fHistoPassed)
67 ->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[1]->GetValue(fOptionAxis[1]), fCut[2]->GetValue(fOptionAxis[2]), weight);
68 } else {
69 ((TH3F*) fHistoFailed)
70 ->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[1]->GetValue(fOptionAxis[1]), fCut[2]->GetValue(fOptionAxis[2]), weight);
71 }
72#endif
73 if (pass) {
74 ((TH3D*) fHistoPassed)
75 ->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[1]->GetValue(fOptionAxis[1]), fCut[2]->GetValue(fOptionAxis[2]));
76 } else {
77 ((TH3D*) fHistoFailed)
78 ->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[1]->GetValue(fOptionAxis[1]), fCut[2]->GetValue(fOptionAxis[2]));
79 }
80 }
81
83
84 CutMonitorXYZ::CutMonitorXYZ(const CutMonitorXYZ& other) : CutMonitor(other) {}
85
86 CutMonitorXYZ::~CutMonitorXYZ() {}
87
88 void CutMonitorXYZ::Update(Bool_t pass, TObject* /*obj*/) {
89 if (fExUpdate) {
90 if (fCut[0]->HasPassed() && fCut[1]->HasPassed() && fCut[2]->HasPassed()) {
91 TrueUpdate(kTRUE);
92 } else {
93 TrueUpdate(kFALSE);
94 }
95 } else {
96 TrueUpdate(pass);
97 }
98 }
99
101#ifdef MPPCUTFULL
102 // ignore 2nd weight
103 if (fCut[0] == fCut[1] || fCut[1] == fCut[2]) { fWeightFlag = 2; }
104 // ignore 3rd weight
105 if (fCut[0] == fCut[2] || fCut[1] == fCut[2]) { fWeightFlag = 3; }
106 // all 3 cuts are the same - ignore 2nd and 3rd weight
107 if ((fCut[0] == fCut[1]) && fCut[0] == fCut[2]) { fWeightFlag = 1; }
108#endif
109 TString title = Form("%s vs %s vs %s",
110 Hal::Std::RemoveUnits(fCut[2]->GetUnit(fOptionAxis[2])).Data(),
111 Hal::Std::RemoveUnits(fCut[1]->GetUnit(fOptionAxis[1])).Data(),
112 Hal::Std::RemoveUnits(fCut[0]->GetUnit(fOptionAxis[0])).Data());
113 TString
114 name; // = Form("%s_vs_%s_vs_%s",
115 // fCut[0]->GetUnit(fOptionAxis[0]).Data(),fCut[1]->GetUnit(fOptionAxis[1]).Data(),fCut[2]->GetUnit(fOptionAxis[2]).Data());
116 name = "Passed";
117 // title = title + Form(" ** %s %s %s
118 // ",fCut[0]->ClassName(),fCut[1]->ClassName(),fCut[2]->ClassName());
119 fHistoPassed = new TH3D(name,
120 title,
121 fAxisBins[0],
122 fAxisMin[0],
123 fAxisMax[0],
124 fAxisBins[1],
125 fAxisMin[1],
126 fAxisMax[1],
127 fAxisBins[2],
128 fAxisMin[2],
129 fAxisMax[2]);
130 fHistoPassed->GetXaxis()->SetTitle(fCut[0]->GetUnit(fOptionAxis[0]));
131 fHistoPassed->GetYaxis()->SetTitle(fCut[1]->GetUnit(fOptionAxis[1]));
132 fHistoPassed->GetZaxis()->SetTitle(fCut[2]->GetUnit(fOptionAxis[2]));
133 name = "Failed";
134 fHistoFailed = (TH3D*) fHistoPassed->Clone(name);
135 fInit = kTRUE;
136 }
137
138 Bool_t CutMonitorXYZ::Init(Int_t task_id) {
139 if (fInit == kFALSE) { return CutMonitor::Init(task_id); }
140 return kFALSE;
141 }
142
144 if (this != &other) { CutMonitor::operator=(other); }
145 return *this;
146 }
147} // namespace Hal
virtual CutMonitor * MakeCopy() const
CutMonitorXYZ & operator=(const CutMonitorXYZ &other)
virtual Bool_t Init(Int_t task_id)
void TrueUpdate(Bool_t pass)
virtual void Update(Bool_t pass, TObject *obj)
CutMonitor & operator=(const CutMonitor &other)
void AddCut(TString cut, Int_t parameter_no=0)
Double_t * fAxisMax
Definition CutMonitor.h:63
void SetYaxis(Int_t bins, Double_t min, Double_t max)
virtual Bool_t Init(Int_t task_id)
void SetZaxis(Int_t bins, Double_t min, Double_t max)
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)
Double_t GetWeight()
Definition Cut.h:290