Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
AnalyzeSimpleTree.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file AnalyzeSimpleTree.cc
1
#include "
AnalyzeSimpleTree.h
"
2
#include "
MySimpleTree.h
"
3
#include "
MyTClonesArray.h
"
4
5
#include <
fun4all/Fun4AllServer.h
>
6
#include <
fun4all/Fun4AllHistoManager.h
>
7
#include <
fun4all/Fun4AllReturnCodes.h
>
8
9
#include <
phool/getClass.h
>
10
#include <
phool/PHCompositeNode.h
>
11
12
#include <TH1.h>
13
#include <TH2.h>
14
15
AnalyzeSimpleTree::AnalyzeSimpleTree
(
const
std::string
&
name
):
SubsysReco
(name)
16
{
17
return ;
18
}
19
20
int
21
AnalyzeSimpleTree::Init
(
PHCompositeNode
*
/*topNode*/
)
22
{
23
Fun4AllServer
*se =
Fun4AllServer::instance
();
24
// this makes a Fun4AllHistoManager which can be used to save your histograms easily
25
// with roots pathetic TDirectory handling and the hoops and loops Fun4All has to
26
// do to accomodate for it it's hard to save histograms on your own and it might not
27
// work reliably. But still keep local pointers to the histograms in your class instead
28
// of retrieving them from the histo manager via their name. This lookup is a string search
29
// which is extremely slow and you do not want to do this for every event
30
hm
=
new
Fun4AllHistoManager
(
"MYHISTOS"
);
31
se->
registerHistoManager
(
hm
);
32
myfloats
=
new
TH1F(
"myfloats"
,
"these are stupid floats"
, 201, -0.5, 200);
33
my2dfloats
=
new
TH2F(
"my2dfloats"
,
"these floats are stupid in 2d"
, 201, -0.5, 199.5, 201, -0.5, 199.5);
34
// this reegisters the histograms with the histo manager for later saving. It will use
35
// the names you gave to the histograms when you created them.
36
hm
->
registerHisto
(
myfloats
);
37
hm
->
registerHisto
(
my2dfloats
);
38
return
0;
39
}
40
41
int
42
AnalyzeSimpleTree::process_event
(
PHCompositeNode
*topNode)
43
{
44
// Find the object on the node tree and fill some of its content into a histogram
45
MySimpleTree
*mytree = findNode::getClass<MySimpleTree>(topNode,
"MYSIMPLETREE"
);
46
myfloats
->Fill(mytree->
MyFloat
());
47
// for TClonesArrays we need to loop over its Entries, get a pointer to the class
48
// which is stored inside it and then use that pointer to fill a histogram
49
MyTClonesArray
*mycontainer = findNode::getClass<MyTClonesArray>(topNode,
"MYTCARRAY"
);
50
for
(
int
j
= 0;
j
< mycontainer->
Entries
();
j
++)
51
{
52
MySimpleTree
*item = mycontainer->
GetItem
(
j
);
53
my2dfloats
->Fill(mytree->
MyFloat
(), item->
MyFloat
());
54
}
55
return
Fun4AllReturnCodes::EVENT_OK
;
56
}
57
58
int
AnalyzeSimpleTree::End
(
PHCompositeNode
*
/*topNode*/
)
59
{
60
hm
->
dumpHistos
(
"myhistos.root"
);
61
return
Fun4AllReturnCodes::EVENT_OK
;
62
}
tutorials
blob
master
MyOwnTTree
src
AnalyzeSimpleTree.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:49
using
1.8.2 with
sPHENIX GitHub integration