Fork me on GitHub

source: git/classes/DelphesFactory.cc@ 952bbbc

Last change on this file since 952bbbc was 341014c, checked in by Pavel Demin <pavel-demin@…>, 6 years ago

apply .clang-format to all .h, .cc and .cpp 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/** \class DelphesFactory
20 *
21 * Class handling creation of Candidate,
22 * TObjArray and all other objects.
23 *
24 * \author P. Demin - UCL, Louvain-la-Neuve
25 *
26 */
27
28#include "classes/DelphesFactory.h"
29#include "classes/DelphesClasses.h"
30
31#include "ExRootAnalysis/ExRootTreeBranch.h"
32
33#include "TClass.h"
34#include "TObjArray.h"
35
36using namespace std;
37
38//------------------------------------------------------------------------------
39
40DelphesFactory::DelphesFactory(const char *name) :
41 TNamed(name, ""), fObjArrays(0)
42{
43 fObjArrays = new ExRootTreeBranch("PermanentObjArrays", TObjArray::Class(), 0);
44}
45
46//------------------------------------------------------------------------------
47
48DelphesFactory::~DelphesFactory()
49{
50 if(fObjArrays) delete fObjArrays;
51
52 map<const TClass *, ExRootTreeBranch *>::iterator itBranches;
53 for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
54 {
55 delete(itBranches->second);
56 }
57}
58
59//------------------------------------------------------------------------------
60
61void DelphesFactory::Clear(Option_t *option)
62{
63 set<TObject *>::iterator itPool;
64 for(itPool = fPool.begin(); itPool != fPool.end(); ++itPool)
65 {
66 (*itPool)->Clear();
67 }
68
69 TProcessID::SetObjectCount(0);
70
71 map<const TClass *, ExRootTreeBranch *>::iterator itBranches;
72 for(itBranches = fBranches.begin(); itBranches != fBranches.end(); ++itBranches)
73 {
74 itBranches->second->Clear();
75 }
76}
77
78//------------------------------------------------------------------------------
79
80TObjArray *DelphesFactory::NewPermanentArray()
81{
82 TObjArray *array = static_cast<TObjArray *>(fObjArrays->NewEntry());
83 fPool.insert(array);
84 return array;
85}
86
87//------------------------------------------------------------------------------
88
89Candidate *DelphesFactory::NewCandidate()
90{
91 Candidate *object = New<Candidate>();
92 object->SetFactory(this);
93 TProcessID::AssignID(object);
94 return object;
95}
96
97//------------------------------------------------------------------------------
98
99TObject *DelphesFactory::New(TClass *cl)
100{
101 TObject *object = 0;
102 ExRootTreeBranch *branch = 0;
103 map<const TClass *, ExRootTreeBranch *>::iterator it = fBranches.find(cl);
104
105 if(it != fBranches.end())
106 {
107 branch = it->second;
108 }
109 else
110 {
111 branch = new ExRootTreeBranch(cl->GetName(), cl, 0);
112 fBranches.insert(make_pair(cl, branch));
113 }
114
115 object = branch->NewEntry();
116 object->Clear();
117 return object;
118}
119
120//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.