EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
QAExample.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file QAExample.cc
1
#include "
QAExample.h
"
2
3
#include <qa_modules/QAHistManagerDef.h>
4
5
#include <
g4main/PHG4Particle.h
>
6
#include <
g4main/PHG4TruthInfoContainer.h
>
7
8
#include <
fun4all/Fun4AllHistoManager.h
>
9
#include <
fun4all/Fun4AllReturnCodes.h
>
10
#include <
fun4all/SubsysReco.h
>
11
12
#include <
phool/getClass.h
>
13
14
#include <TH1.h>
15
#include <TH2.h>
16
17
#include <array>
18
#include <cassert>
19
#include <cmath>
20
#include <iostream>
21
#include <map>
// for map
22
#include <utility>
// for pair
23
24
using namespace
std;
25
26
QAExample::QAExample
(
const
std::string &
name
)
27
:
SubsysReco
(name)
28
{
29
}
30
31
int
QAExample::InitRun
(
PHCompositeNode
*topNode)
32
{
33
return
Fun4AllReturnCodes::EVENT_OK
;
34
}
35
36
int
QAExample::Init
(
PHCompositeNode
*topNode)
37
{
38
Fun4AllHistoManager
*hm =
QAHistManagerDef::getHistoManager
();
39
assert(hm);
40
41
// reco pT / gen pT histogram
42
TH1 *
h
(
nullptr
);
43
44
h =
new
TH1F(TString(
get_histo_prefix
()) +
"pT"
,
45
"pT"
, 500, 0, 20);
46
hm->
registerHisto
(h);
47
48
h =
new
TH2F(TString(
get_histo_prefix
()) +
"pTpz"
,
49
"pT vs pz"
, 200, 0, 50, 500, 0, 20);
50
// QAHistManagerDef::useLogBins(h->GetXaxis());
51
hm->
registerHisto
(h);
52
53
return
Fun4AllReturnCodes::EVENT_OK
;
54
}
55
56
int
QAExample::process_event
(
PHCompositeNode
*topNode)
57
{
58
if
(
Verbosity
() > 2)
59
cout <<
"QAExample::process_event() entered"
<< endl;
60
61
// load relevant nodes from NodeTree
62
load_nodes
(topNode);
63
64
// histogram manager
65
Fun4AllHistoManager
*hm =
QAHistManagerDef::getHistoManager
();
66
assert(hm);
67
68
// reco pT / gen pT histogram
69
TH1 *pT =
dynamic_cast<
TH1 *
>
(hm->
getHisto
(
get_histo_prefix
() +
"pT"
));
70
assert(pT);
71
72
// reco pT / gen pT histogram
73
TH2 *pTpz =
dynamic_cast<
TH2 *
>
(hm->
getHisto
(
get_histo_prefix
() +
"pTpz"
));
74
assert(pTpz);
75
76
// fill histograms that need truth information
77
if
(!
m_truthContainer
)
78
{
79
cout <<
"QAExample::process_event - fatal error - missing m_truthContainer! "
;
80
return
Fun4AllReturnCodes::ABORTRUN
;
81
}
82
83
PHG4TruthInfoContainer::ConstRange
range =
m_truthContainer
->
GetPrimaryParticleRange
();
84
for
(
PHG4TruthInfoContainer::ConstIterator
iter = range.first; iter != range.second; ++iter)
85
{
86
// get the truth particle information
87
PHG4Particle
*g4particle = iter->second;
88
89
if
(
Verbosity
())
90
{
91
cout <<
"QAExample::process_event - processing "
;
92
g4particle->
identify
();
93
}
94
95
double
gpx = g4particle->
get_px
();
96
double
gpy = g4particle->
get_py
();
97
double
pt = sqrt(gpx * gpx + gpy * gpy);
98
double
gpz = g4particle->
get_pz
();
99
pT->Fill(pt);
100
pTpz->Fill(pt, gpz);
101
}
102
return
Fun4AllReturnCodes::EVENT_OK
;
103
}
104
105
int
QAExample::load_nodes
(
PHCompositeNode
*topNode)
106
{
107
m_truthContainer
= findNode::getClass<PHG4TruthInfoContainer>(topNode,
"G4TruthInfo"
);
108
if
(!
m_truthContainer
)
109
{
110
cout <<
"QAExample::load_nodes - Fatal Error - "
111
<<
"unable to find DST node "
112
<<
"G4TruthInfo"
<< endl;
113
assert(
m_truthContainer
);
114
}
115
116
return
Fun4AllReturnCodes::EVENT_OK
;
117
}
118
119
string
120
QAExample::get_histo_prefix
()
121
{
122
return
string(
"h_"
) +
Name
() + string(
"_"
);
123
}
fun4all_eic_qa
blob
master
source
QAExample.cc
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:51
using
1.8.2 with
EIC GitHub integration