Fork me on GitHub

source: svn/trunk/classes/DelphesModule.cc@ 1102

Last change on this file since 1102 was 895, checked in by Pavel Demin, 12 years ago

sort all objects in TreeWriter

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