Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
Analysis Software
Deprecated List
Modules
Namespaces
Classes
Files
File List
acts
acts-fatras
analysis
analysis_tpc_prototype
coresoftware
Doxygen_Assist
g4exampledetector
GenFit
JETSCAPE
KFParticle
macros
online_distribution
OnlMon
prototype
pythia6
rcdaq
RDBC
tutorials
blob
master
AnaTutorial
block
CaloAna
clusters
CreateSubsysRecoModule
cylinder
eventgenerator_display
IonGun
MagneticField
materialscan
Momentum
myjetanalysis
MyOwnTTree
macro
src
AnalyzeSimpleTree.cc
AnalyzeSimpleTree.h
MakeSimpleTree.cc
MakeSimpleTree.h
MySimpleTree.cc
MySimpleTree.h
MySimpleTreeLinkDef.h
MyTClonesArray.cc
MyTClonesArray.h
MyTClonesArrayLinkDef.h
PHG4DSTReader
sPHENIX_sims
doxygen_mainpage.h
File Members
Examples
External Links
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
MyTClonesArray.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file MyTClonesArray.cc
1
// This class puts rows of MySimpleTree classes into a TClonesArray
2
3
#include "
MyTClonesArray.h
"
4
#include "
MySimpleTree.h
"
5
6
#include <
phool/phool.h
>
7
8
#include <TClonesArray.h>
9
10
#include <iostream>
11
12
// DEFAULTSIZE gives the initial number of entries
13
// the TClonesArray can hold and also the step size
14
// by which it is extended when needed
15
// this should be a meaningful number (like what you
16
// expect in most of the cases) to limit the number of
17
// times the TClonesArray has to be extended (and shrunk again
18
// at the end of the event) which eats a bit of cpu time
19
20
static
int
DEFAULTSIZE
= 10;
21
22
MyTClonesArray::MyTClonesArray
()
23
{
24
MyTCArray
=
new
TClonesArray(
"MySimpleTree"
,
DEFAULTSIZE
);
25
}
26
27
28
MyTClonesArray::~MyTClonesArray
()
29
{
30
if
(
MyTCArray
)
31
{
32
MyTCArray
->Clear();
33
delete
MyTCArray
;
34
}
35
return ;
36
}
37
38
39
void
40
MyTClonesArray::Reset
()
41
{
42
myeventint
= 0;
43
myeventfloat
= NAN;
44
MyTCArray
->Clear();
45
if
(
MyTCArray
->GetSize() >
DEFAULTSIZE
)
46
{
47
MyTCArray
->Expand(
DEFAULTSIZE
);
48
}
49
return ;
50
}
51
52
// this method returns a pointer to the newly generated item
53
// in the TClonesArray.
54
// There is a bit TCLonesArray magic involved here but if you
55
// replace MySimpleTree by your class everywhere you should be fine.
56
// I once figured out a way to do this even more generic, but I couldn't
57
// locate this code on short notice (it's somewhere in our phuniverse I guess)
58
MySimpleTree
*
59
MyTClonesArray::GetNewItem
()
60
{
61
// in a TClonesArray GetLast returns the last valid index, so add 1 to get
62
// the one we need to create
63
TClonesArray &cl = *
MyTCArray
;
64
int
nextindex =
MyTCArray
->GetLast()+1;
65
// check if we are at the current capacity of our TClonesArray and
66
// if so extend the TClonesArray
67
if
(nextindex ==
MyTCArray
->GetSize())
68
{
69
MyTCArray
->Expand(
MyTCArray
->GetSize() +
DEFAULTSIZE
);
70
}
71
new
(cl[nextindex])
MySimpleTree
();
72
return
(static_cast<MySimpleTree *> (cl[nextindex]));
73
}
74
75
MySimpleTree
*
76
MyTClonesArray::GetItem
(
const
unsigned
int
i
)
const
77
{
78
79
if
(i > (
unsigned
int
)
MyTCArray
->GetLast())
80
{
81
std::cout <<
PHWHERE
<<
" Index "
<< i
82
<<
" out of range, max = "
<<
MyTCArray
->GetLast() << std::endl;
83
return
0;
84
}
85
86
return
(static_cast<MySimpleTree *> (
MyTCArray
->UncheckedAt(i)));
87
}
88
89
int
90
MyTClonesArray::Entries
()
91
{
92
return
MyTCArray
->GetEntriesFast();
93
}
tutorials
blob
master
MyOwnTTree
src
MyTClonesArray.cc
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:49
using
1.8.2 with
sPHENIX GitHub integration