Fork me on GitHub

source: git/classes/DelphesModule.cc@ 26a21bd

Last change on this file since 26a21bd was dc883b4, checked in by Pavel Demin <pavel.demin@…>, 4 years ago

add info to TreeWriter

  • Property mode set to 100644
File size: 4.3 KB
RevLine 
[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/** \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
[341014c]31#include "ExRootAnalysis/ExRootResult.h"
[d7d2da3]32#include "ExRootAnalysis/ExRootTreeBranch.h"
[341014c]33#include "ExRootAnalysis/ExRootTreeReader.h"
[d7d2da3]34#include "ExRootAnalysis/ExRootTreeWriter.h"
35
36#include "TClass.h"
37#include "TFolder.h"
38#include "TObjArray.h"
[341014c]39#include "TROOT.h"
[d7d2da3]40
41#include <iostream>
42#include <sstream>
[341014c]43#include <stdexcept>
[d7d2da3]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
[dc883b4]132void DelphesModule::AddInfo(const char *name, Double_t value)
133{
134 stringstream message;
135 if(!fTreeWriter)
136 {
137 fTreeWriter = static_cast<ExRootTreeWriter *>(GetObject("TreeWriter", ExRootTreeWriter::Class()));
138 if(!fTreeWriter)
139 {
140 message << "can't access access tree writer";
141 throw runtime_error(message.str());
142 }
143 }
144 fTreeWriter->AddInfo(name, value);
145}
146
147//------------------------------------------------------------------------------
148
[d7d2da3]149ExRootResult *DelphesModule::GetPlots()
150{
151 if(!fPlots)
152 {
153 fPlots = new ExRootResult();
154 fPlots->SetFolder(GetFolder());
155 }
156 return fPlots;
157}
158
159//------------------------------------------------------------------------------
160
161DelphesFactory *DelphesModule::GetFactory()
162{
163 stringstream message;
164 if(!fFactory)
165 {
166 fFactory = static_cast<DelphesFactory *>(GetObject("ObjectFactory", DelphesFactory::Class()));
167 if(!fFactory)
168 {
169 message << "can't access access object factory";
170 throw runtime_error(message.str());
171 }
172 }
173 return fFactory;
174}
Note: See TracBrowser for help on using the repository browser.