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 DelphesModule
|
---|
21 | *
|
---|
22 | * Base class for all Delphes modules
|
---|
23 | *
|
---|
24 | * $Date: 2008-06-04 13:57:25 $
|
---|
25 | * $Revision: 1.1 $
|
---|
26 | *
|
---|
27 | *
|
---|
28 | * \author P. Demin - UCL, Louvain-la-Neuve
|
---|
29 | *
|
---|
30 | */
|
---|
31 |
|
---|
32 | #include "classes/DelphesModule.h"
|
---|
33 |
|
---|
34 | #include "classes/DelphesFactory.h"
|
---|
35 |
|
---|
36 | #include "ExRootAnalysis/ExRootTreeReader.h"
|
---|
37 | #include "ExRootAnalysis/ExRootTreeBranch.h"
|
---|
38 | #include "ExRootAnalysis/ExRootTreeWriter.h"
|
---|
39 | #include "ExRootAnalysis/ExRootResult.h"
|
---|
40 |
|
---|
41 | #include "TROOT.h"
|
---|
42 | #include "TClass.h"
|
---|
43 | #include "TFolder.h"
|
---|
44 | #include "TObjArray.h"
|
---|
45 |
|
---|
46 | #include <iostream>
|
---|
47 | #include <stdexcept>
|
---|
48 | #include <sstream>
|
---|
49 |
|
---|
50 | using namespace std;
|
---|
51 |
|
---|
52 | DelphesModule::DelphesModule() :
|
---|
53 | fTreeWriter(0), fFactory(0), fPlots(0),
|
---|
54 | fPlotFolder(0), fExportFolder(0)
|
---|
55 | {
|
---|
56 | }
|
---|
57 |
|
---|
58 | //------------------------------------------------------------------------------
|
---|
59 |
|
---|
60 | DelphesModule::~DelphesModule()
|
---|
61 | {
|
---|
62 | }
|
---|
63 |
|
---|
64 | //------------------------------------------------------------------------------
|
---|
65 |
|
---|
66 | void DelphesModule::Init()
|
---|
67 | {
|
---|
68 | }
|
---|
69 |
|
---|
70 | //------------------------------------------------------------------------------
|
---|
71 |
|
---|
72 | void DelphesModule::Process()
|
---|
73 | {
|
---|
74 | }
|
---|
75 |
|
---|
76 | //------------------------------------------------------------------------------
|
---|
77 |
|
---|
78 | void DelphesModule::Finish()
|
---|
79 | {
|
---|
80 | }
|
---|
81 |
|
---|
82 | //------------------------------------------------------------------------------
|
---|
83 |
|
---|
84 | TObjArray *DelphesModule::ImportArray(const char *name)
|
---|
85 | {
|
---|
86 | stringstream message;
|
---|
87 | TObjArray *object;
|
---|
88 |
|
---|
89 | object = static_cast<TObjArray *>(GetObject(Form("Export/%s", name), TObjArray::Class()));
|
---|
90 | if(!object)
|
---|
91 | {
|
---|
92 | message << "can't access input list '" << name;
|
---|
93 | message << "' in module '" << GetName() << "'";
|
---|
94 | throw runtime_error(message.str());
|
---|
95 | }
|
---|
96 |
|
---|
97 | return object;
|
---|
98 | }
|
---|
99 |
|
---|
100 | //------------------------------------------------------------------------------
|
---|
101 |
|
---|
102 | TObjArray *DelphesModule::ExportArray(const char *name)
|
---|
103 | {
|
---|
104 | TObjArray *array;
|
---|
105 | if(!fExportFolder)
|
---|
106 | {
|
---|
107 | fExportFolder = NewFolder("Export");
|
---|
108 | }
|
---|
109 |
|
---|
110 | array = GetFactory()->NewPermanentArray();
|
---|
111 |
|
---|
112 | array->SetName(name);
|
---|
113 | fExportFolder->Add(array);
|
---|
114 |
|
---|
115 | return array;
|
---|
116 | }
|
---|
117 |
|
---|
118 | //------------------------------------------------------------------------------
|
---|
119 |
|
---|
120 | ExRootTreeBranch *DelphesModule::NewBranch(const char *name, TClass *cl)
|
---|
121 | {
|
---|
122 | stringstream message;
|
---|
123 | if(!fTreeWriter)
|
---|
124 | {
|
---|
125 | fTreeWriter = static_cast<ExRootTreeWriter *>(GetObject("TreeWriter", ExRootTreeWriter::Class()));
|
---|
126 | if(!fTreeWriter)
|
---|
127 | {
|
---|
128 | message << "can't access access tree writer";
|
---|
129 | throw runtime_error(message.str());
|
---|
130 | }
|
---|
131 | }
|
---|
132 | return fTreeWriter->NewBranch(name, cl);
|
---|
133 | }
|
---|
134 |
|
---|
135 | //------------------------------------------------------------------------------
|
---|
136 |
|
---|
137 | ExRootResult *DelphesModule::GetPlots()
|
---|
138 | {
|
---|
139 | if(!fPlots)
|
---|
140 | {
|
---|
141 | fPlots = new ExRootResult();
|
---|
142 | fPlots->SetFolder(GetFolder());
|
---|
143 | }
|
---|
144 | return fPlots;
|
---|
145 | }
|
---|
146 |
|
---|
147 | //------------------------------------------------------------------------------
|
---|
148 |
|
---|
149 | DelphesFactory *DelphesModule::GetFactory()
|
---|
150 | {
|
---|
151 | stringstream message;
|
---|
152 | if(!fFactory)
|
---|
153 | {
|
---|
154 | fFactory = static_cast<DelphesFactory *>(GetObject("ObjectFactory", DelphesFactory::Class()));
|
---|
155 | if(!fFactory)
|
---|
156 | {
|
---|
157 | message << "can't access access object factory";
|
---|
158 | throw runtime_error(message.str());
|
---|
159 | }
|
---|
160 | }
|
---|
161 | return fFactory;
|
---|
162 | }
|
---|
163 |
|
---|
164 |
|
---|