ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
MultiDraw
Root
FormulaSvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
//
8
// includes
9
//
10
11
#include <
MultiDraw/FormulaSvc.h
>
12
13
#include <memory>
14
#include <sstream>
15
#include <TTree.h>
16
#include <TTreeFormula.h>
17
#include <TTreeFormulaManager.h>
18
#include <
EventLoop/Job.h
>
19
#include <
EventLoop/StatusCode.h
>
20
#include <
EventLoop/IWorker.h
>
21
#include <
MultiDraw/Formula.h
>
22
#include <
RootCoreUtils/Assert.h
>
23
24
#include <stdexcept>
25
26
//
27
// method implementations
28
//
29
30
ClassImp
(
MD::FormulaSvc
)
31
32
namespace
MD
33
{
34
//
35
// legacy implementations
36
//
37
38
const
std::string
FormulaSvc::name
=
"MultiDraw"
;
39
40
41
42
std::string
dbg
(
const
FormulaSvc&
/*obj*/
,
unsigned
/*verbosity*/
)
43
{
44
return
"FormulaSvc"
;
45
}
46
47
48
49
void
useFormulas
(
EL::Job
& job)
50
{
51
if
(!job.algsHas (
FormulaSvc::name
))
52
job.algsAdd (
new
FormulaSvc);
53
}
54
55
56
57
FormulaSvc *
formulas
(
EL::IWorker
*worker)
58
{
59
RCU_REQUIRE_SOFT
(worker != 0);
60
61
FormulaSvc *
const
svc
62
=
dynamic_cast<
FormulaSvc*
>
(worker->
getAlg
(
FormulaSvc::name
));
63
if
(svc == 0)
64
throw
std::runtime_error (
"Job not configured for FormulaSvc support"
);
65
return
svc;
66
}
67
68
69
70
void
FormulaSvc ::
71
testInvariant ()
const
72
{
73
for
(std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
74
{
75
RCU_INVARIANT
(m_vars[form] != 0);
76
}
77
}
78
79
80
81
FormulaSvc ::
82
FormulaSvc ()
83
: m_tree (0)
84
{
85
RCU_NEW_INVARIANT
(
this
);
86
}
87
88
89
90
FormulaSvc ::
91
~FormulaSvc ()
92
{
93
RCU_DESTROY_INVARIANT
(
this
);
94
95
for
(std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
96
{
97
delete
m_vars[form];
98
}
99
}
100
101
102
103
const
Formula *FormulaSvc ::
104
addForm (
const
std::string& formula)
105
{
106
RCU_CHANGE_INVARIANT
(
this
);
107
RCU_REQUIRE_SOFT
(!formula.empty());
108
109
for
(std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
110
{
111
if
(m_vars[form]->formula() == formula)
112
return
m_vars[form];
113
}
114
RCU_ASSERT
(m_tree != 0);
115
std::ostringstream name;
116
name <<
"var"
<< m_vars.size();
117
m_vars.push_back (
new
Formula (name.str(), formula, m_tree));
118
return
m_vars.back();
119
}
120
121
122
123
const
char
*FormulaSvc ::
124
GetName ()
const
125
{
126
RCU_READ_INVARIANT
(
this
);
127
return
name.c_str();
128
}
129
130
131
132
EL::StatusCode
FormulaSvc ::
133
changeInput (
bool
/*firstFile*/
)
134
{
135
RCU_CHANGE_INVARIANT
(
this
);
136
137
m_tree = 0;
138
139
try
140
{
141
m_tree = wk()->tree();
142
m_tree->ResetBit (TTree::kForceRead);
143
144
for
(std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
145
m_vars[form]->reset (m_tree);
146
}
catch
(...)
147
{
148
m_tree = 0;
149
throw
;
150
}
151
152
return
EL::StatusCode::SUCCESS;
153
}
154
155
156
157
EL::StatusCode
FormulaSvc ::
158
execute ()
159
{
160
RCU_CHANGE_INVARIANT
(
this
);
161
if
(wk()->treeEntry() != wk()->
tree
()->GetReadEvent())
162
wk()->tree()->LoadTree (wk()->treeEntry());
163
RCU_ASSERT
(wk()->treeEntry() == wk()->
tree
()->GetReadEvent());
164
return
EL::StatusCode::SUCCESS;
165
}
166
}
Assert.h
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition
Assert.h:187
RCU_ASSERT
#define RCU_ASSERT(x)
Definition
Assert.h:210
RCU_DESTROY_INVARIANT
#define RCU_DESTROY_INVARIANT(x)
Definition
Assert.h:223
RCU_CHANGE_INVARIANT
#define RCU_CHANGE_INVARIANT(x)
Definition
Assert.h:219
RCU_NEW_INVARIANT
#define RCU_NEW_INVARIANT(x)
Definition
Assert.h:221
RCU_REQUIRE_SOFT
#define RCU_REQUIRE_SOFT(x)
Definition
Assert.h:141
RCU_READ_INVARIANT
#define RCU_READ_INVARIANT(x)
Definition
Assert.h:217
ClassImp
ClassImp(MD::FormulaSvc) namespace MD
Definition
FormulaSvc.cxx:30
FormulaSvc.h
Formula.h
IWorker.h
Job.h
StatusCode.h
EL::IWorker
the interface for algorithms to access IWorker
Definition
IWorker.h:40
EL::IWorker::getAlg
virtual EL::Algorithm * getAlg(const std::string &name) const =0
effects: returns the algorithms with the given name or NULL if there is none guarantee: strong failur...
EL::Job
Definition
Job.h:42
MD::FormulaSvc
Definition
FormulaSvc.h:45
MD::FormulaSvc::name
static const std::string name
description: the name of the service
Definition
FormulaSvc.h:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition
PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MD
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition
AlgCFlow.h:22
MD::formulas
FormulaSvc * formulas(EL::IWorker *worker)
returns: the formula service for this worker guarantee: strong failures: formula service not configur...
MD::useFormulas
void useFormulas(EL::Job &job)
effects: register the formula service for this job guarantee: strong failures: out of memory I
dbg
Definition
SGImplSvc.cxx:69
tree
TChain * tree
Definition
tile_monitor.h:30
Generated on
for ATLAS Offline Software by
1.17.0