Fork me on GitHub

source: git/classes/DelphesFactory.cc@ 944c250

ImprovedOutputFile Timing dual_readout llp
Last change on this file since 944c250 was 7c0fcd5, checked in by Pavel Demin <demin@…>, 10 years ago

delete duplicate license file and prepend GPLv3 header to all source code files

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Delphes: a framework for fast simulation of a generic collider experiment
3 * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19
20/** \class DelphesFactory
21 *
22 * Class handling creation of Candidate,
23 * TObjArray and all other objects.
24 *
25 * $Date: 2008-06-04 13:57:25 $
26 * $Revision: 1.1 $
27 *
28 *
29 * \author P. Demin - UCL, Louvain-la-Neuve
30 *
31 */
32
33#include "classes/DelphesFactory.h"
34#include "classes/DelphesClasses.h"
35
36#include "ExRootAnalysis/ExRootTreeBranch.h"
37
38#include "TClass.h"
39#include "TObjArray.h"
40
41using namespace std;
42
43//------------------------------------------------------------------------------
44
45DelphesFactory::DelphesFactory(const char *name) :
46 TNamed(name, ""), fObjArrays(0)
47{
48 fObjArrays = new ExRootTreeBranch("PermanentObjArrays", TObjArray::Class(), 0);
49}
50
51//------------------------------------------------------------------------------
52
53DelphesFactory::~DelphesFactory()
54{
55 if(fObjArrays) delete fObjArrays;
56
57 map< const TClass*, ExRootTreeBranch* >::iterator itBranches;
58 for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
59 {
60 delete (itBranches->second);
61 }
62}
63
64//------------------------------------------------------------------------------
65
66void DelphesFactory::Clear()
67{
68 set<TObject *>::iterator itPool;
69 for(itPool = fPool.begin(); itPool != fPool.end(); ++itPool)
70 {
71 (*itPool)->Clear();
72 }
73
74 TProcessID::SetObjectCount(0);
75
76 map< const TClass*, ExRootTreeBranch* >::iterator itBranches;
77 for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
78 {
79 itBranches->second->Clear();
80 }
81}
82
83//------------------------------------------------------------------------------
84
85TObjArray *DelphesFactory::NewPermanentArray()
86{
87 TObjArray *array = static_cast<TObjArray *>(fObjArrays->NewEntry());
88 fPool.insert(array);
89 return array;
90}
91
92//------------------------------------------------------------------------------
93
94Candidate *DelphesFactory::NewCandidate()
95{
96 Candidate *object = New<Candidate>();
97 object->SetFactory(this);
98 TProcessID::AssignID(object);
99 return object;
100}
101
102//------------------------------------------------------------------------------
103
104TObject *DelphesFactory::New(TClass *cl)
105{
106 TObject *object = 0;
107 ExRootTreeBranch *branch = 0;
108 map<const TClass *, ExRootTreeBranch *>::iterator it = fBranches.find(cl);
109
110 if(it != fBranches.end())
111 {
112 branch = it->second;
113 }
114 else
115 {
116 branch = new ExRootTreeBranch(cl->GetName(), cl, 0);
117 fBranches.insert(make_pair(cl, branch));
118 }
119
120 object = branch->NewEntry();
121 object->Clear();
122 return object;
123}
124
125//------------------------------------------------------------------------------
126
Note: See TracBrowser for help on using the repository browser.