ATLAS Offline Software
Simulation
G4Atlas
G4AtlasTests
src
SimTestHisto.h
Go to the documentation of this file.
1
/* -*- C++ -*- */
2
3
/*
4
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
#ifndef G4ATLASTESTS_SIMTESTHISTO_H
8
#define G4ATLASTESTS_SIMTESTHISTO_H
9
14
#include "
AthenaKernel/errorcheck.h
"
15
#include "GaudiKernel/ITHistSvc.h"
16
#include "GaudiKernel/ServiceHandle.h"
17
18
#include "TH1.h"
19
#include "TH2.h"
20
class
TProfile
;
21
25
class
SimTestHisto
26
{
27
28
public
:
29
30
SimTestHisto
() =
default
;
31
~SimTestHisto
() =
default
;
32
33
protected
:
34
std::string
m_path
{
"/truth/"
};
35
ServiceHandle<ITHistSvc>
m_histSvc
{
"THistSvc"
,
"SimTestHisto"
};
36
};
37
38
// note: var should be of type "TH1*" even if it is filled with a TProfile*
39
#define _TPROFILE(var,name,nbin,xmin,xmax) \
40
if (!m_histSvc->exists(m_path+name)) { \
41
var = new TProfile(name,name,nbin,xmin,xmax); \
42
CHECK(m_histSvc->regHist(m_path+name,var)); \
43
} else { \
44
CHECK(m_histSvc->getHist(m_path+name, var)); \
45
}
46
47
#define _TH1D(var,name,nbin,xmin,xmax) \
48
if (!m_histSvc->exists(m_path+name)) { \
49
var = new TH1D(name,name,nbin,xmin,xmax); \
50
var->StatOverflows(); \
51
CHECK(m_histSvc->regHist(m_path+name,var)); \
52
} else { \
53
CHECK(m_histSvc->getHist(m_path+name,var)); \
54
}
55
56
#define _TH1D_NOCHECK(var,name,nbin,xmin,xmax) \
57
if (!m_histSvc->exists(m_path+name)) { \
58
var = new TH1D(name,name,nbin,xmin,xmax); \
59
var->StatOverflows(); \
60
if(m_histSvc->regHist(m_path+name,var).isFailure()) \
61
std::cout<<"Cannot register histogram "<<name<<std::endl; \
62
} else { \
63
if(m_histSvc->getHist(m_path+name,var).isFailure()) \
64
std::cout<<"Cannot get histogram "<<name<<std::endl; \
65
}
66
67
#define _TH1D_WEIGHTED(var,name,nbin,xmin,xmax) \
68
_TH1D(var,name,nbin,xmin,xmax); \
69
var->Sumw2();
70
71
#define _TH2D_NOCHECK(var,name,nbinx,xmin,xmax,nbiny,ymin,ymax) \
72
if (!m_histSvc->exists(m_path+name)) { \
73
var = new TH2D(name,name,nbinx,xmin,xmax,nbiny,ymin,ymax); \
74
if(m_histSvc->regHist(m_path+name,var).isFailure()) \
75
std::cout<<"Cannot register histogram "<<name<<std::endl;\
76
} else { \
77
if(m_histSvc->getHist(m_path+name,var).isFailure()) \
78
std::cout<<"Cannot get histogram "<<name<<std::endl; \
79
}
80
81
#define _TH2D(var,name,nbinx,xmin,xmax,nbiny,ymin,ymax) \
82
if (!m_histSvc->exists(m_path+name)) { \
83
var = new TH2D(name,name,nbinx,xmin,xmax,nbiny,ymin,ymax); \
84
CHECK(m_histSvc->regHist(m_path+name,var)); \
85
} else { \
86
CHECK(m_histSvc->getHist(m_path+name,var)); \
87
}
88
89
#define _TH2D_WEIGHTED(var,name,nbinx,xmin,xmax,nbiny,ymin,ymax) \
90
_TH2D(var,name,nbinx,xmin,xmax,nbiny,ymin,ymax); \
91
var->Sumw2();
92
93
#define _SET_TITLE(var,title,xaxis,yaxis) \
94
var->SetXTitle(xaxis); \
95
var->SetYTitle(yaxis); \
96
var->SetTitle((std::string(var->GetName())+" : "+title).c_str());
97
98
//#define _SET_LOGX(var)
99
//TAxis *axis = var->GetXaxis();
100
//int bins = axis->GetNbin//s();
101
102
// Axis_t from = axis->GetXmin();
103
// Axis_t to = axis->GetXmax();
104
// Axis_t width = (to - from) / bins;
105
// Axis_t *new_bins = new Axis_t[bins + 1];
106
107
// for (int i = 0; i <= bins; i++) {
108
// new_bins[i] = TMath::Power(10, from + i * width);
109
//
110
// }
111
// axis->Set(bins, new_bins);
112
// delete new_bins;
113
114
#endif //G4ATLASTESTS_SIMTESTHISTO_H
SimTestHisto::m_histSvc
ServiceHandle< ITHistSvc > m_histSvc
Definition:
SimTestHisto.h:35
SimTestHisto
Utility helper class for dealing with histograms in the sim tests.
Definition:
SimTestHisto.h:26
SimTestHisto::~SimTestHisto
~SimTestHisto()=default
python.TrigEgammaMonitorHelper.TProfile
def TProfile(*args, **kwargs)
Definition:
TrigEgammaMonitorHelper.py:81
errorcheck.h
Helpers for checking error return status codes and reporting errors.
SimTestHisto::SimTestHisto
SimTestHisto()=default
SimTestHisto::m_path
std::string m_path
Definition:
SimTestHisto.h:34
ServiceHandle< ITHistSvc >
Generated on Wed Mar 12 2025 21:18:44 for ATLAS Offline Software by
1.8.18