Fork me on GitHub

source: git/modules/Delphes.cc@ c61b5ce

Last change on this file since c61b5ce was 06630ef, checked in by Pavel Demin <pavel.demin@…>, 4 years ago

fix Delphes destructor

  • Property mode set to 100644
File size: 3.9 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 Delphes
20 *
21 * Main Delphes module.
22 * Controls execution of all other modules.
23 *
24 * \author P. Demin - UCL, Louvain-la-Neuve
25 *
26 */
27
28#include "modules/Delphes.h"
29
30#include "classes/DelphesClasses.h"
31#include "classes/DelphesFactory.h"
32#include "classes/DelphesFormula.h"
33
34#include "ExRootAnalysis/ExRootClassifier.h"
35#include "ExRootAnalysis/ExRootConfReader.h"
36#include "ExRootAnalysis/ExRootFilter.h"
37#include "ExRootAnalysis/ExRootResult.h"
38#include "ExRootAnalysis/ExRootTreeWriter.h"
39
40#include "TDatabasePDG.h"
41#include "TFolder.h"
42#include "TFormula.h"
43#include "TLorentzVector.h"
44#include "TMath.h"
45#include "TObjArray.h"
46#include "TROOT.h"
47#include "TRandom3.h"
48#include "TString.h"
49
50#include <algorithm>
51#include <iostream>
52#include <sstream>
53#include <stdexcept>
54
55#include <stdio.h>
56#include <string.h>
57
58using namespace std;
59
60Delphes::Delphes(const char *name) :
61 fFactory(0)
62{
63 TFolder *folder;
64
65 fFactory = new DelphesFactory("ObjectFactory");
66
67 folder = new TFolder(name, "");
68
69 SetName(name);
70 SetFolder(folder);
71
72 folder->Add(this);
73 folder->Add(fFactory);
74
75 gROOT->GetListOfBrowsables()->Add(folder);
76}
77
78//------------------------------------------------------------------------------
79
80Delphes::~Delphes()
81{
82 TFolder *folder = GetFolder();
83 if(folder)
84 {
85 gROOT->GetListOfBrowsables()->Remove(folder);
86 folder->Clear();
87 delete folder;
88 }
89 if(fFactory) delete fFactory;
90}
91
92//------------------------------------------------------------------------------
93
94void Delphes::Clear()
95{
96 if(fFactory) fFactory->Clear();
97}
98
99//------------------------------------------------------------------------------
100
101void Delphes::SetTreeWriter(ExRootTreeWriter *treeWriter)
102{
103 treeWriter->SetName("TreeWriter");
104 GetFolder()->Add(treeWriter);
105}
106
107//------------------------------------------------------------------------------
108
109void Delphes::Init()
110{
111 stringstream message;
112 ExRootConfReader *confReader = GetConfReader();
113 confReader->SetName("ConfReader");
114 GetFolder()->Add(confReader);
115
116 TString name;
117 ExRootTask *task;
118 const ExRootConfReader::ExRootTaskMap *modules = confReader->GetModules();
119 ExRootConfReader::ExRootTaskMap::const_iterator itModules;
120
121 ExRootConfParam param = confReader->GetParam("::ExecutionPath");
122 Long_t i, size = param.GetSize();
123
124 gRandom->SetSeed(confReader->GetInt("::RandomSeed", 0));
125
126 for(i = 0; i < size; ++i)
127 {
128 name = param[i].GetString();
129 itModules = modules->find(name);
130 if(itModules != modules->end())
131 {
132 task = NewTask(itModules->second, itModules->first);
133 if(task)
134 {
135 task->SetFolder(GetFolder());
136 Add(task);
137 }
138 }
139 else
140 {
141 message << "module '" << name;
142 message << "' is specified in ExecutionPath but not configured.";
143 throw runtime_error(message.str());
144 }
145 }
146}
147
148//------------------------------------------------------------------------------
149
150void Delphes::Process()
151{
152}
153
154//------------------------------------------------------------------------------
155
156void Delphes::Finish()
157{
158}
159
160//------------------------------------------------------------------------------
Note: See TracBrowser for help on using the repository browser.