source: HiSusy/trunk/Delphes-3.0.0/classes/DelphesFactory.cc @ 1

Last change on this file since 1 was 1, checked in by zerwas, 11 years ago

first import of structure, PYTHIA8 and DELPHES

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
17#include "classes/DelphesClasses.h"
18
19#include "ExRootAnalysis/ExRootTreeBranch.h"
20
21
22#include "TClass.h"
23#include "TObjArray.h"
24
25using namespace std;
26
27//------------------------------------------------------------------------------
28
29DelphesFactory::DelphesFactory(const char *name) :
30  TNamed(name, ""), fObjArrays(0)
31{
32  fObjArrays = new ExRootTreeBranch("PermanentObjArrays", TObjArray::Class(), 0);
33}
34
35//------------------------------------------------------------------------------
36
37DelphesFactory::~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
50void 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
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.