Fork me on GitHub

source: git/classes/DelphesFactory.cc@ 00bcbe6

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 00bcbe6 was d7d2da3, checked in by pavel <pavel@…>, 12 years ago

move branches/ModularDelphes to trunk

  • Property mode set to 100644
File size: 2.5 KB
Line 
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#include "classes/DelphesClasses.h"
17
18#include "ExRootAnalysis/ExRootTreeBranch.h"
19
20#include "TClass.h"
21#include "TObjArray.h"
22
23using namespace std;
24
25//------------------------------------------------------------------------------
26
27DelphesFactory::DelphesFactory(const char *name) :
28 TNamed(name, ""), fObjArrays(0)
29{
30 fObjArrays = new ExRootTreeBranch("PermanentObjArrays", TObjArray::Class(), 0);
31}
32
33//------------------------------------------------------------------------------
34
35DelphesFactory::~DelphesFactory()
36{
37 if(fObjArrays) delete fObjArrays;
38
39 map< const TClass*, ExRootTreeBranch* >::iterator itBranches;
40 for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
41 {
42 delete (itBranches->second);
43 }
44}
45
46//------------------------------------------------------------------------------
47
48void DelphesFactory::Clear()
49{
50 set<TObject *>::iterator itPool;
51 for(itPool = fPool.begin(); itPool != fPool.end(); ++itPool)
52 {
53 (*itPool)->Clear();
54 }
55
56 TProcessID::SetObjectCount(0);
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
67TObjArray *DelphesFactory::NewPermanentArray()
68{
69 TObjArray *array = static_cast<TObjArray *>(fObjArrays->NewEntry());
70 fPool.insert(array);
71 return array;
72}
73
74//------------------------------------------------------------------------------
75
76Candidate *DelphesFactory::NewCandidate()
77{
78 Candidate *object = New<Candidate>();
79 object->SetFactory(this);
80 TProcessID::AssignID(object);
81 return object;
82}
83
84//------------------------------------------------------------------------------
85
86TObject *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
Note: See TracBrowser for help on using the repository browser.