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
RCU_INVARIANT
(
this
!= 0);
74
75
for
(std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
76
{
77
RCU_INVARIANT
(m_vars[form] != 0);
78
}
79
}
80
81
82
83
FormulaSvc ::
84
FormulaSvc ()
85
: m_tree (0)
86
{
87
RCU_NEW_INVARIANT
(
this
);
88
}
89
90
91
92
FormulaSvc ::
93
~FormulaSvc ()
94
{
95
RCU_DESTROY_INVARIANT
(
this
);
96
97
for
(std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
98
{
99
delete
m_vars[form];
100
}
101
}
102
103
104
105
const
Formula *FormulaSvc ::
106
addForm (
const
std::string& formula)
107
{
108
RCU_CHANGE_INVARIANT
(
this
);
109
RCU_REQUIRE_SOFT
(!formula.empty());
110
111
for
(std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
112
{
113
if
(m_vars[form]->formula() == formula)
114
return
m_vars[form];
115
}
116
RCU_ASSERT
(m_tree != 0);
117
std::ostringstream name;
118
name <<
"var"
<< m_vars.size();
119
m_vars.push_back (
new
Formula (name.str(), formula, m_tree));
120
return
m_vars.back();
121
}
122
123
124
125
const
char
*FormulaSvc ::
126
GetName ()
const
127
{
128
RCU_READ_INVARIANT
(
this
);
129
return
name.c_str();
130
}
131
132
133
134
EL::StatusCode
FormulaSvc ::
135
changeInput (
bool
/*firstFile*/
)
136
{
137
RCU_CHANGE_INVARIANT
(
this
);
138
139
m_tree = 0;
140
141
try
142
{
143
m_tree = wk()->tree();
144
m_tree->ResetBit (TTree::kForceRead);
145
146
for
(std::size_t form = 0, end = m_vars.size(); form != end; ++ form)
147
m_vars[form]->reset (m_tree);
148
}
catch
(...)
149
{
150
m_tree = 0;
151
throw
;
152
}
153
154
return
EL::StatusCode::SUCCESS;
155
}
156
157
158
159
EL::StatusCode
FormulaSvc ::
160
execute ()
161
{
162
RCU_CHANGE_INVARIANT
(
this
);
163
if
(wk()->treeEntry() != wk()->
tree
()->GetReadEvent())
164
wk()->tree()->LoadTree (wk()->treeEntry());
165
RCU_ASSERT
(wk()->treeEntry() == wk()->
tree
()->GetReadEvent());
166
return
EL::StatusCode::SUCCESS;
167
}
168
}
Assert.h
RCU_INVARIANT
#define RCU_INVARIANT(x)
Definition
Assert.h:189
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