CbmRoot
CbmTrdCheckUtil.cxx
Go to the documentation of this file.
1 // Includes from TRD
2 #include "CbmTrdCheckUtil.h"
3 #include "CbmTrdDigi.h"
4 #include "TMath.h"
5 #include <string>
6 
7 #include "assert.h"
8 #include <chrono>
9 #include <fstream>
10 #include <iostream>
11 #include <vector>
12 
13 #include <TH1D.h>
14 #include <TH2D.h>
15 #include <TH3D.h>
16 #include <TProfile.h>
17 #include <TProfile2D.h>
18 #include <TProfile3D.h>
19 
20 //_________________________________________________________________________________
22  : TObject()
23  , f1D()
24  , f2D()
25  , f3D()
26  , fProfile1D()
27  , fProfile2D()
28  , fProfile3D()
29 
30 {}
31 
32 
33 void CbmTrdCheckUtil::CreateHist(std::string name,
34  Int_t xbins,
35  Double_t xlow,
36  Double_t xhigh,
37  Int_t ybins,
38  Double_t ylow,
39  Double_t yhigh) {
40  if (ybins == 0 && f1D[name]) return;
41  if (f2D[name]) return;
42  if (ybins == 0)
43  f1D[name] = new TH1D(name.data(), name.data(), xbins, xlow, xhigh);
44  else
45  f2D[name] = new TH2D(
46  name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh);
47 }
48 
49 void CbmTrdCheckUtil::CreateHist3D(std::string name,
50  Int_t xbins,
51  Double_t xlow,
52  Double_t xhigh,
53  Int_t ybins,
54  Double_t ylow,
55  Double_t yhigh,
56  Int_t zbins,
57  Double_t zlow,
58  Double_t zhigh) {
59  if (f3D[name]) return;
60  f3D[name] = new TH3D(name.data(),
61  name.data(),
62  xbins,
63  xlow,
64  xhigh,
65  ybins,
66  ylow,
67  yhigh,
68  zbins,
69  zlow,
70  zhigh);
71 }
72 
73 void CbmTrdCheckUtil::CreateProfile(std::string name,
74  Int_t xbins,
75  Double_t xlow,
76  Double_t xhigh,
77  Int_t ybins,
78  Double_t ylow,
79  Double_t yhigh) {
80  if (ybins == 0 && fProfile1D[name]) return;
81  if (fProfile2D[name]) return;
82  if (ybins == 0)
83  fProfile1D[name] =
84  new TProfile(name.data(), name.data(), xbins, xlow, xhigh);
85  else
86  fProfile2D[name] = new TProfile2D(
87  name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh);
88 }
89 
90 void CbmTrdCheckUtil::CreateProfile3D(std::string name,
91  Int_t xbins,
92  Double_t xlow,
93  Double_t xhigh,
94  Int_t ybins,
95  Double_t ylow,
96  Double_t yhigh,
97  Int_t zbins,
98  Double_t zlow,
99  Double_t zhigh) {
100  if (fProfile3D[name]) return;
101  fProfile3D[name] = new TProfile3D(name.data(),
102  name.data(),
103  xbins,
104  xlow,
105  xhigh,
106  ybins,
107  ylow,
108  yhigh,
109  zbins,
110  zlow,
111  zhigh);
112 }
113 
114 void CbmTrdCheckUtil::Fill(std::string name, Double_t x, Double_t y) {
115  if (y == 9999.) {
116  if (!f1D[name]) return;
117  f1D[name]->Fill(x);
118  } else {
119  if (!f2D[name]) return;
120  f2D[name]->Fill(x, y);
121  }
122 }
123 
124 void CbmTrdCheckUtil::Fill3D(std::string name,
125  Double_t x,
126  Double_t y,
127  Double_t z) {
128  if (!f3D[name]) return;
129  f3D[name]->Fill(x, y, z);
130 }
131 
132 // void CbmTrdCheckUtil::FillProfile(std::string name,Double_t x, Double_t y){
133 // if(y == 9999.) {if(!fProfile1D[name]) return;fProfile1D[name]->Fill(x);}
134 // else {if(!fProfile2D[name]) return;fProfile2D[name]->Fill(x,y);}
135 // }
136 
137 void CbmTrdCheckUtil::FillProfile(std::string name,
138  Double_t x,
139  Double_t y,
140  Double_t z) {
141  if (z == 9999.) {
142  if (!fProfile1D[name]) return;
143  fProfile1D[name]->Fill(x, y);
144  } else {
145  if (!fProfile2D[name]) return;
146  fProfile2D[name]->Fill(x, y, z);
147  }
148 }
149 
150 void CbmTrdCheckUtil::FillProfile3D(std::string name,
151  Double_t x,
152  Double_t y,
153  Double_t z,
154  Double_t w) {
155  if (!fProfile3D[name]) return;
156  fProfile3D[name]->Fill(x, y, z, w);
157 }
158 
159 void CbmTrdCheckUtil::Fill(std::string name,
160  Double_t x,
161  Double_t y,
162  Double_t z) {
163  if (!f2D[name]) return;
164  f2D[name]->Fill(x, y, z);
165 }
166 
167 void CbmTrdCheckUtil::FillW(std::string name, Double_t x, Double_t w) {
168  if (!f1D[name]) return;
169  f1D[name]->Fill(x, w);
170 }
CbmTrdCheckUtil::FillW
void FillW(std::string name, Double_t x, Double_t w)
Definition: CbmTrdCheckUtil.cxx:167
CbmTrdCheckUtil::f2D
std::map< TString, TH2D * > f2D
Definition: CbmTrdCheckUtil.h:49
CbmTrdCheckUtil::FillProfile3D
void FillProfile3D(std::string name, Double_t x, Double_t y, Double_t z, Double_t w=1.)
Definition: CbmTrdCheckUtil.cxx:150
CbmTrdCheckUtil::Fill3D
void Fill3D(std::string name, Double_t x, Double_t y, Double_t z)
Definition: CbmTrdCheckUtil.cxx:124
CbmTrdCheckUtil::CreateProfile3D
void CreateProfile3D(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins, Double_t ylow, Double_t yhigh, Int_t zbins, Double_t zlow, Double_t zhigh)
Definition: CbmTrdCheckUtil.cxx:90
CbmTrdCheckUtil::fProfile3D
std::map< TString, TProfile3D * > fProfile3D
Definition: CbmTrdCheckUtil.h:53
CbmTrdCheckUtil::CbmTrdCheckUtil
CbmTrdCheckUtil()
default Constructor with messages
Definition: CbmTrdCheckUtil.cxx:21
CbmTrdDigi.h
CbmTrdCheckUtil::CreateHist
void CreateHist(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins=0, Double_t ylow=1., Double_t yhigh=1.)
Definition: CbmTrdCheckUtil.cxx:33
CbmTrdCheckUtil::Fill
void Fill(std::string name, Double_t x, Double_t y=9999.)
Definition: CbmTrdCheckUtil.cxx:114
CbmTrdCheckUtil::f1D
std::map< TString, TH1D * > f1D
Definition: CbmTrdCheckUtil.h:48
CbmTrdCheckUtil::fProfile2D
std::map< TString, TProfile2D * > fProfile2D
Definition: CbmTrdCheckUtil.h:52
CbmTrdCheckUtil::fProfile1D
std::map< TString, TProfile * > fProfile1D
Definition: CbmTrdCheckUtil.h:51
CbmTrdCheckUtil::CreateProfile
void CreateProfile(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins=0, Double_t ylow=1., Double_t yhigh=1.)
Definition: CbmTrdCheckUtil.cxx:73
CbmTrdCheckUtil::CreateHist3D
void CreateHist3D(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins, Double_t ylow, Double_t yhigh, Int_t zbins, Double_t zlow, Double_t zhigh)
Definition: CbmTrdCheckUtil.cxx:49
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
CbmTrdCheckUtil::f3D
std::map< TString, TH3D * > f3D
Definition: CbmTrdCheckUtil.h:50
CbmTrdCheckUtil::FillProfile
void FillProfile(std::string name, Double_t x, Double_t y, Double_t z=9999.)
Definition: CbmTrdCheckUtil.cxx:137
CbmTrdCheckUtil.h