Fork me on GitHub

source: git/classes/DelphesModule.cc@ a5ff49f

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