Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
CutMonitorXY.cxx
1/*
2 * CutMonitorXY.cpp
3 *
4 * Created on: 10-07-2013
5 * Author: Daniel Wielanek
6 */
7
8#include "CutMonitorXY.h"
9
10#include "Cut.h"
11
12#include <RtypesCore.h>
13#include <TAxis.h>
14#include <TH1.h>
15#include <TH2.h>
16#include <TString.h>
17
18#include "StdString.h"
19
20namespace Hal {
21 CutMonitorXY::CutMonitorXY() : CutMonitor(2) {
22#ifdef MPPCUTFULL
23 fIdenticalCuts = kFALSE;
24#endif
25 }
26
27 CutMonitorXY::CutMonitorXY(TString cut_A, TString cut_B) : CutMonitorXY() {
28 AddCut(cut_A);
29 AddCut(cut_B);
30 }
31
32 CutMonitorXY::CutMonitorXY(TString cut_A,
33 Int_t parameter_A,
34 std::initializer_list<Double_t> xAxis,
35 TString cut_B,
36 Int_t parameter_B,
37 std::initializer_list<Double_t> yAxis) :
38 CutMonitorXY(cut_A, parameter_A, cut_B, parameter_B) {
39 auto vecX = Hal::Std::GetVector(xAxis);
40 auto vecY = Hal::Std::GetVector(yAxis);
41 if (vecX.size() == 3) SetXaxis(vecX[0], vecX[1], vecX[2]);
42 if (vecY.size() == 3) SetYaxis(vecY[0], vecY[1], vecY[2]);
43 }
44
45 CutMonitorXY::CutMonitorXY(TString cut_A, Int_t parameter_A, TString cut_B, Int_t parameter_B) : CutMonitorXY() {
46 AddCut(cut_A, parameter_A);
47 AddCut(cut_B, parameter_B);
48 }
49
50 void CutMonitorXY::TrueUpdate(Bool_t passed) {
51#ifdef MPPCUTFULL
52 Double_t weight = fCut[0]->GetWeight();
53 if (fIdenticalCuts == kFALSE) { weight = weight * fCut[1]->GetWeight(); }
54 if (passed) {
55 ((TH2*) fHistoPassed)->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[1]->GetValue(fOptionAxis[0]), weight);
56 } else {
57 ((TH2*) fHistoFailed)->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[1]->GetValue(fOptionAxis[0]), weight);
58 }
59#else
60 if (passed) {
61 ((TH2D*) fHistoPassed)->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[1]->GetValue(fOptionAxis[1]));
62 } else {
63 ((TH2D*) fHistoFailed)->Fill(fCut[0]->GetValue(fOptionAxis[0]), fCut[1]->GetValue(fOptionAxis[1]));
64 }
65#endif
66 }
67
68 CutMonitor* CutMonitorXY::MakeCopy() const { return (CutMonitor*) new CutMonitorXY(*this); }
69
70 CutMonitorXY::CutMonitorXY(const CutMonitorXY& other) : CutMonitor(other) {}
71
72 CutMonitorXY::~CutMonitorXY() {}
73
74 Bool_t CutMonitorXY::Init(Int_t task_id) {
75 return CutMonitor::Init(task_id);
76#ifdef MPPCUTFULL
77 if (fCut[0] == fCut[1]) fIdenticalCuts = kTRUE;
78#endif
79 }
80
81 void CutMonitorXY::Update(Bool_t passed, TObject* /*obj*/) {
82 if (fExUpdate) {
83 if (fCut[0]->HasPassed() && fCut[1]->HasPassed()) {
84 TrueUpdate(kTRUE);
85 } else {
86 TrueUpdate(kFALSE);
87 }
88 } else {
89 TrueUpdate(passed);
90 }
91 }
92
94 TString title = Form("%s vs %s",
95 Hal::Std::RemoveUnits(fCut[1]->GetUnit(fOptionAxis[1])).Data(),
96 Hal::Std::RemoveUnits(fCut[0]->GetUnit(fOptionAxis[0])).Data());
97 TString name; // = Form("%s_vs_%s",
98 // fCut[0]->GetUnit(fOptionAxis[0]).Data(),fCut[1]->GetUnit(fOptionAxis[1]).Data());
99 name = "Passed";
100 fHistoPassed = new TH2D(name, title, fAxisBins[0], fAxisMin[0], fAxisMax[0], fAxisBins[1], fAxisMin[1], fAxisMax[1]);
101 fHistoPassed->GetXaxis()->SetTitle(fCut[0]->GetUnit(fOptionAxis[0]));
102 fHistoPassed->GetYaxis()->SetTitle(fCut[1]->GetUnit(fOptionAxis[1]));
103 name = name + "_F";
104 name = "Failed";
105 fHistoFailed = new TH2D(name, title, fAxisBins[0], fAxisMin[0], fAxisMax[0], fAxisBins[1], fAxisMin[1], fAxisMax[1]);
106 fHistoFailed->GetXaxis()->SetTitle(fCut[0]->GetUnit(fOptionAxis[0]));
107 fHistoFailed->GetYaxis()->SetTitle(fCut[1]->GetUnit(fOptionAxis[1]));
108
109#ifdef MPPCUTFULL
110 if (fCut[0] == fCut[1]) { fIdenticalCuts = kTRUE; }
111#endif
112 }
113
115 if (this != &other) { CutMonitor::operator=(other); }
116 return *this;
117 }
118} // namespace Hal
void TrueUpdate(Bool_t passed)
virtual CutMonitor * MakeCopy() const
virtual Bool_t Init(Int_t task_id)
virtual void Update(Bool_t passed, TObject *obj)
CutMonitorXY & operator=(const CutMonitorXY &other)
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)
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