1 | |
---|
2 | /** \class DelphesFactory |
---|
3 | * |
---|
4 | * Class handling creation of Candidate, |
---|
5 | * TObjArray and all other objects. |
---|
6 | * |
---|
7 | * $Date: 2008-06-04 13:57:25 $ |
---|
8 | * $Revision: 1.1 $ |
---|
9 | * |
---|
10 | * |
---|
11 | * \author P. Demin - UCL, Louvain-la-Neuve |
---|
12 | * |
---|
13 | */ |
---|
14 | |
---|
15 | #include "classes/DelphesFactory.h" |
---|
16 | |
---|
17 | #include "classes/DelphesClasses.h" |
---|
18 | |
---|
19 | #include "ExRootAnalysis/ExRootTreeBranch.h" |
---|
20 | |
---|
21 | |
---|
22 | #include "TClass.h" |
---|
23 | #include "TObjArray.h" |
---|
24 | |
---|
25 | using namespace std; |
---|
26 | |
---|
27 | //------------------------------------------------------------------------------ |
---|
28 | |
---|
29 | DelphesFactory::DelphesFactory(const char *name) : |
---|
30 | TNamed(name, ""), fObjArrays(0) |
---|
31 | { |
---|
32 | fObjArrays = new ExRootTreeBranch("PermanentObjArrays", TObjArray::Class(), 0); |
---|
33 | } |
---|
34 | |
---|
35 | //------------------------------------------------------------------------------ |
---|
36 | |
---|
37 | DelphesFactory::~DelphesFactory() |
---|
38 | { |
---|
39 | if(fObjArrays) delete fObjArrays; |
---|
40 | |
---|
41 | map< const TClass*, ExRootTreeBranch* >::iterator itBranches; |
---|
42 | for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches) |
---|
43 | { |
---|
44 | delete (itBranches->second); |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|
48 | //------------------------------------------------------------------------------ |
---|
49 | |
---|
50 | void DelphesFactory::Clear() |
---|
51 | { |
---|
52 | set<TObject *>::iterator itPool; |
---|
53 | for(itPool = fPool.begin(); itPool != fPool.end(); ++itPool) |
---|
54 | { |
---|
55 | (*itPool)->Clear(); |
---|
56 | } |
---|
57 | |
---|
58 | map< const TClass*, ExRootTreeBranch* >::iterator itBranches; |
---|
59 | for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches) |
---|
60 | { |
---|
61 | itBranches->second->Clear(); |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | //------------------------------------------------------------------------------ |
---|
66 | |
---|
67 | TObjArray *DelphesFactory::NewPermanentArray() |
---|
68 | { |
---|
69 | TObjArray *array = static_cast<TObjArray *>(fObjArrays->NewEntry()); |
---|
70 | fPool.insert(array); |
---|
71 | return array; |
---|
72 | } |
---|
73 | |
---|
74 | //------------------------------------------------------------------------------ |
---|
75 | |
---|
76 | Candidate *DelphesFactory::NewCandidate() |
---|
77 | { |
---|
78 | Candidate *object = New<Candidate>(); |
---|
79 | object->SetFactory(this); |
---|
80 | TProcessID::AssignID(object); |
---|
81 | return object; |
---|
82 | } |
---|
83 | |
---|
84 | //------------------------------------------------------------------------------ |
---|
85 | |
---|
86 | TObject *DelphesFactory::New(TClass *cl) |
---|
87 | { |
---|
88 | TObject *object = 0; |
---|
89 | ExRootTreeBranch *branch = 0; |
---|
90 | map<const TClass *, ExRootTreeBranch *>::iterator it = fBranches.find(cl); |
---|
91 | |
---|
92 | if(it != fBranches.end()) |
---|
93 | { |
---|
94 | branch = it->second; |
---|
95 | } |
---|
96 | else |
---|
97 | { |
---|
98 | branch = new ExRootTreeBranch(cl->GetName(), cl, 0); |
---|
99 | fBranches.insert(make_pair(cl, branch)); |
---|
100 | } |
---|
101 | |
---|
102 | object = branch->NewEntry(); |
---|
103 | object->Clear(); |
---|
104 | return object; |
---|
105 | } |
---|
106 | |
---|
107 | //------------------------------------------------------------------------------ |
---|
108 | |
---|