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#include "TMath.h"
10
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 <cassert>
19#include <chrono>
20#include <fstream>
21#include <iostream>
22#include <string>
23#include <vector>
24
25//_________________________________________________________________________________
27
28
29void CbmTrdCheckUtil::CreateHist(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins,
30 Double_t ylow, Double_t yhigh)
31{
32 if (ybins == 0 && f1D[name]) return;
33 if (f2D[name]) return;
34 if (ybins == 0) f1D[name] = new TH1D(name.data(), name.data(), xbins, xlow, xhigh);
35 else
36 f2D[name] = new TH2D(name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh);
37}
38
39void CbmTrdCheckUtil::CreateHist3D(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins,
40 Double_t ylow, Double_t yhigh, Int_t zbins, Double_t zlow, Double_t zhigh)
41{
42 if (f3D[name]) return;
43 f3D[name] = new TH3D(name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh, zbins, zlow, zhigh);
44}
45
46void CbmTrdCheckUtil::CreateProfile(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins,
47 Double_t ylow, Double_t yhigh)
48{
49 if (ybins == 0 && fProfile1D[name]) return;
50 if (fProfile2D[name]) return;
51 if (ybins == 0) fProfile1D[name] = new TProfile(name.data(), name.data(), xbins, xlow, xhigh);
52 else
53 fProfile2D[name] = new TProfile2D(name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh);
54}
55
56void CbmTrdCheckUtil::CreateProfile3D(std::string name, Int_t xbins, Double_t xlow, Double_t xhigh, Int_t ybins,
57 Double_t ylow, Double_t yhigh, Int_t zbins, Double_t zlow, Double_t zhigh)
58{
59 if (fProfile3D[name]) return;
60 fProfile3D[name] =
61 new TProfile3D(name.data(), name.data(), xbins, xlow, xhigh, ybins, ylow, yhigh, zbins, zlow, zhigh);
62}
63
64void CbmTrdCheckUtil::Fill(std::string name, Double_t x, Double_t y)
65{
66 if (y == 9999.) {
67 if (!f1D[name]) return;
68 f1D[name]->Fill(x);
69 }
70 else {
71 if (!f2D[name]) return;
72 f2D[name]->Fill(x, y);
73 }
74}
75
76void CbmTrdCheckUtil::Fill3D(std::string name, Double_t x, Double_t y, Double_t z)
77{
78 if (!f3D[name]) return;
79 f3D[name]->Fill(x, y, z);
80}
81
82// void CbmTrdCheckUtil::FillProfile(std::string name,Double_t x, Double_t y){
83// if(y == 9999.) {if(!fProfile1D[name]) return;fProfile1D[name]->Fill(x);}
84// else {if(!fProfile2D[name]) return;fProfile2D[name]->Fill(x,y);}
85// }
86
87void CbmTrdCheckUtil::FillProfile(std::string name, Double_t x, Double_t y, Double_t z)
88{
89 if (z == 9999.) {
90 if (!fProfile1D[name]) return;
91 fProfile1D[name]->Fill(x, y);
92 }
93 else {
94 if (!fProfile2D[name]) return;
95 fProfile2D[name]->Fill(x, y, z);
96 }
97}
98
99void CbmTrdCheckUtil::FillProfile3D(std::string name, Double_t x, Double_t y, Double_t z, Double_t w)
100{
101 if (!fProfile3D[name]) return;
102 fProfile3D[name]->Fill(x, y, z, w);
103}
104
105void CbmTrdCheckUtil::Fill(std::string name, Double_t x, Double_t y, Double_t z)
106{
107 if (!f2D[name]) return;
108 f2D[name]->Fill(x, y, z);
109}
110
111void CbmTrdCheckUtil::FillW(std::string name, Double_t x, Double_t w)
112{
113 if (!f1D[name]) return;
114 f1D[name]->Fill(x, w);
115}
int Int_t
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.)