[b443089] | 1 | /*
|
---|
| 2 | * Delphes: a framework for fast simulation of a generic collider experiment
|
---|
| 3 | * Copyright (C) 2012-2014 Universite catholique de Louvain (UCL), Belgium
|
---|
[1fa50c2] | 4 | *
|
---|
[b443089] | 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.
|
---|
[1fa50c2] | 9 | *
|
---|
[b443089] | 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.
|
---|
[1fa50c2] | 14 | *
|
---|
[b443089] | 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 |
|
---|
[d7d2da3] | 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 |
|
---|
| 41 | using namespace std;
|
---|
| 42 |
|
---|
| 43 | //------------------------------------------------------------------------------
|
---|
| 44 |
|
---|
| 45 | DelphesFactory::DelphesFactory(const char *name) :
|
---|
| 46 | TNamed(name, ""), fObjArrays(0)
|
---|
| 47 | {
|
---|
| 48 | fObjArrays = new ExRootTreeBranch("PermanentObjArrays", TObjArray::Class(), 0);
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | //------------------------------------------------------------------------------
|
---|
| 52 |
|
---|
| 53 | DelphesFactory::~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 |
|
---|
| 66 | void 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 |
|
---|
| 85 | TObjArray *DelphesFactory::NewPermanentArray()
|
---|
| 86 | {
|
---|
| 87 | TObjArray *array = static_cast<TObjArray *>(fObjArrays->NewEntry());
|
---|
| 88 | fPool.insert(array);
|
---|
| 89 | return array;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | //------------------------------------------------------------------------------
|
---|
| 93 |
|
---|
| 94 | Candidate *DelphesFactory::NewCandidate()
|
---|
| 95 | {
|
---|
| 96 | Candidate *object = New<Candidate>();
|
---|
| 97 | object->SetFactory(this);
|
---|
| 98 | TProcessID::AssignID(object);
|
---|
| 99 | return object;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | //------------------------------------------------------------------------------
|
---|
| 103 |
|
---|
| 104 | TObject *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 |
|
---|