ECCE @ EIC Software
Reference for
ECCE @ 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
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
using namespace
std;
16
17
AnalyzeSimpleTree::AnalyzeSimpleTree
(
const
string
&
name
):
SubsysReco
(name)
18
{
19
return
;
20
}
21
22
int
23
AnalyzeSimpleTree::Init
(
PHCompositeNode
*topNode)
24
{
25
Fun4AllServer
*se =
Fun4AllServer::instance
();
26
// this makes a Fun4AllHistoManager which can be used to save your histograms easily
27
// with roots pathetic TDirectory handling and the hoops and loops Fun4All has to
28
// do to accomodate for it it's hard to save histograms on your own and it might not
29
// work reliably. But still keep local pointers to the histograms in your class instead
30
// of retrieving them from the histo manager via their name. This lookup is a string search
31
// which is extremely slow and you do not want to do this for every event
32
hm
=
new
Fun4AllHistoManager
(
"MYHISTOS"
);
33
se->
registerHistoManager
(
hm
);
34
myfloats
=
new
TH1F(
"myfloats"
,
"these are stupid floats"
, 201, -0.5, 200);
35
my2dfloats
=
new
TH2F(
"my2dfloats"
,
"these floats are stupid in 2d"
, 201, -0.5, 199.5, 201, -0.5, 199.5);
36
// this reegisters the histograms with the histo manager for later saving. It will use
37
// the names you gave to the histograms when you created them.
38
hm
->
registerHisto
(
myfloats
);
39
hm
->
registerHisto
(
my2dfloats
);
40
return
0;
41
}
42
43
int
44
AnalyzeSimpleTree::process_event
(
PHCompositeNode
*topNode)
45
{
46
// Find the object on the node tree and fill some of its content into a histogram
47
MySimpleTree
*mytree = findNode::getClass<MySimpleTree>(topNode,
"MYSIMPLETREE"
);
48
myfloats
->Fill(mytree->
MyFloat
());
49
// for TClonesArrays we need to loop over its Entries, get a pointer to the class
50
// which is stored inside it and then use that pointer to fill a histogram
51
MyTClonesArray
*mycontainer = findNode::getClass<MyTClonesArray>(topNode,
"MYTCARRAY"
);
52
for
(
int
j = 0; j < mycontainer->
Entries
();j++)
53
{
54
MySimpleTree
*item = mycontainer->
GetItem
(j);
55
my2dfloats
->Fill(mytree->
MyFloat
(), item->
MyFloat
());
56
}
57
return
Fun4AllReturnCodes::EVENT_OK
;
58
}
tutorials
blob
master
MyOwnTTree
src
AnalyzeSimpleTree.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:26:00
using
1.8.2 with
ECCE GitHub integration