CbmRoot
Loading...
Searching...
No Matches
CbmTrdCheckUtil.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020 Institut fuer Kernphysik, Goethe-Universitaet Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Etienne Bechtel [committer] */
4
5// Includes from TRD
6#include "CbmTrdCheckUtil.h"
7
8#include "CbmTrdDigi.h"
9
10#include "TMath.h"
11#include <TH1D.h>
12#include <TH2D.h>
13#include <TH3D.h>
14#include <TProfile.h>
15#include <TProfile2D.h>
16#include <TProfile3D.h>
17
18#include <chrono>
19#include <fstream>
20#include <iostream>
21#include <string>
22#include <vector>
23
24#include "assert.h"
25
26//_________________________________________________________________________________
27CbmTrdCheckUtil::CbmTrdCheckUtil() : TObject(), f1D(), f2D(), f3D(), fProfile1D(), fProfile2D(), fProfile3D() {}
28
29
30void CbmTrdCheckUtil::CreateHist(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins,
31 Double_t ylow, Double_t yhigh)
32{
33 if (ybins == 0 && f1D[name]) return;
34 if (f2D[name]) return;
35 if (ybins == 0) f1D[name] = new TH1D(name.data(), name.data(), xbins, xlow, xhigh);
36 else
37 f2D[name] = new TH2D(name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh);
38}
39
40void CbmTrdCheckUtil::CreateHist3D(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins,
41 Double_t ylow, Double_t yhigh, Int_t zbins, Double_t zlow, Double_t zhigh)
42{
43 if (f3D[name]) return;
44 f3D[name] = new TH3D(name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh, zbins, zlow, zhigh);
45}
46
47void CbmTrdCheckUtil::CreateProfile(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins,
48 Double_t ylow, Double_t yhigh)
49{
50 if (ybins == 0 && fProfile1D[name]) return;
51 if (fProfile2D[name]) return;
52 if (ybins == 0) fProfile1D[name] = new TProfile(name.data(), name.data(), xbins, xlow, xhigh);
53 else
54 fProfile2D[name] = new TProfile2D(name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh);
55}
56
57void CbmTrdCheckUtil::CreateProfile3D(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins,
58 Double_t ylow, Double_t yhigh, Int_t zbins, Double_t zlow, Double_t zhigh)
59{
60 if (fProfile3D[name]) return;
61 fProfile3D[name] =
62 new TProfile3D(name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh, zbins, zlow, zhigh);
63}
64
65void CbmTrdCheckUtil::Fill(std::string name, Double_t x, Double_t y)
66{
67 if (y == 9999.) {
68 if (!f1D[name]) return;
69 f1D[name]->Fill(x);
70 }
71 else {
72 if (!f2D[name]) return;
73 f2D[name]->Fill(x, y);
74 }
75}
76
77void CbmTrdCheckUtil::Fill3D(std::string name, Double_t x, Double_t y, Double_t z)
78{
79 if (!f3D[name]) return;
80 f3D[name]->Fill(x, y, z);
81}
82
83// void CbmTrdCheckUtil::FillProfile(std::string name,Double_t x, Double_t y){
84// if(y == 9999.) {if(!fProfile1D[name]) return;fProfile1D[name]->Fill(x);}
85// else {if(!fProfile2D[name]) return;fProfile2D[name]->Fill(x,y);}
86// }
87
88void CbmTrdCheckUtil::FillProfile(std::string name, Double_t x, Double_t y, Double_t z)
89{
90 if (z == 9999.) {
91 if (!fProfile1D[name]) return;
92 fProfile1D[name]->Fill(x, y);
93 }
94 else {
95 if (!fProfile2D[name]) return;
96 fProfile2D[name]->Fill(x, y, z);
97 }
98}
99
100void CbmTrdCheckUtil::FillProfile3D(std::string name, Double_t x, Double_t y, Double_t z, Double_t w)
101{
102 if (!fProfile3D[name]) return;
103 fProfile3D[name]->Fill(x, y, z, w);
104}
105
106void CbmTrdCheckUtil::Fill(std::string name, Double_t x, Double_t y, Double_t z)
107{
108 if (!f2D[name]) return;
109 f2D[name]->Fill(x, y, z);
110}
111
112void CbmTrdCheckUtil::FillW(std::string name, Double_t x, Double_t w)
113{
114 if (!f1D[name]) return;
115 f1D[name]->Fill(x, w);
116}
CbmTrdCheckUtil()
default Constructor with messages
std::map< TString, TH1D * > f1D
std::map< TString, TH3D * > f3D
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.)
std::map< TString, TH2D * > f2D
void Fill(std::string name, Double_t x, Double_t y=9999.)
std::map< TString, TProfile3D * > fProfile3D
void FillW(std::string name, Double_t x, Double_t w)
std::map< TString, TProfile * > fProfile1D
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)
std::map< TString, TProfile2D * > fProfile2D
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)
void Fill3D(std::string name, Double_t x, Double_t y, Double_t z)
void FillProfile(std::string name, Double_t x, Double_t y, Double_t z=9999.)
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.)
void FillProfile3D(std::string name, Double_t x, Double_t y, Double_t z, Double_t w=1.)