ATLAS Offline Software
Loading...
Searching...
No Matches
NTupleSvc.h
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#ifndef EVENT_LOOP_ALGS__NTUPLE_SVC_H
8#define EVENT_LOOP_ALGS__NTUPLE_SVC_H
9
12
13
14
16
17#include <set>
18#include <EventLoop/Algorithm.h>
19
20class TBranch;
21class TFile;
22class TTree;
23
24namespace EL
25{
34 const std::string& outputStream,
35 const std::string& treeName = "");
36
37
38
39 class NTupleSvc : public EL::Algorithm
40 {
41 //
42 // public interface
43 //
44
47 public:
48 void testInvariant () const;
49
50
55 public:
56 NTupleSvc (const std::string& val_outputName = "output");
57
58
61 public:
63
64
69 public:
70 void copyBranch (const std::string& name);
71
72
80 public:
81 void copyBranchList (const std::string& fileName);
82
83
87 public:
88 void addWhiteFloat (const std::string& varName);
89
90
94 public:
95 void addWhiteArray (const std::string& varName);
96
97
102 public:
103 TTree *tree () const;
104
105
108 public:
109 bool getFilterPassed () const;
110
111
115 public:
116 void setFilterPassed (bool passed = true);
117
118
123 public:
124 const std::string& treeName () const;
125 void treeName (const std::string& val_treeName);
126
127
128 //
129 // interface inherited from Algorithm
130 //
131
134 public:
135 virtual const char *GetName () const;
136
137
146 private:
147 virtual StatusCode setupJob (Job& job);
148
149
155 private:
156 virtual StatusCode changeInput (bool firstFile);
157
158
169 private:
171
172
177 private:
178 virtual StatusCode execute ();
179
180
188 private:
190
191
198 private:
199 virtual bool hasName (const std::string& name) const;
200
201
202
203 //
204 // private interface
205 //
206
208 private:
209 std::string m_outputName;
210
212 private:
213 std::string m_treeName;
214
216 private:
217 std::string m_tree_title;
218
220 private:
221 std::set<std::string> m_copyBranches;
222 typedef std::set<std::string>::iterator m_copyBranchesIter;
223
225 private:
226 std::set<std::string> m_whiteFloat;
227 typedef std::set<std::string>::iterator m_whiteFloatIter;
228
230 private:
231 std::set<std::string> m_whiteArray;
232 typedef std::set<std::string>::iterator m_whiteArrayIter;
233
235 private:
236 TFile *m_file;
237
239 private:
240 TTree *m_tree;
241
243 private:
245
247 private:
248 bool m_taken;
249
252 private:
254
256 private:
258
260 private:
261 struct CopyInfo
262 {
264 public:
265 std::string name;
266
268 public:
269 TBranch *source;
270
272 public:
273 TBranch *target;
274
276 public:
277 std::vector<char> buffer;
278 };
279 std::vector<CopyInfo> m_copyInfo;
280 typedef std::vector<CopyInfo>::iterator copyInfoMIter;
281
283 private:
285 {
287 public:
288 std::string name;
289
291 public:
292 bool array;
293
295 public:
296 std::vector<float> buffer;
297
300 public:
301 std::vector<float> *pointer;
302 };
303 std::vector<WhiteInfo> m_whiteInfo;
304 typedef std::vector<WhiteInfo>::iterator whiteInfoMIter;
305
306
311 private:
313
314
319 private:
320 void findBranches (std::set<std::string>& branchList);
321
322
331 private:
332 void initOutput (const std::string& branchName);
333
334
340 private:
341 void initOutput (const std::set<std::string>& branchList);
342
343
347 private:
348 void copyInput ();
349
350
352 };
353}
354
355#endif
bool passed(DecisionID id, const DecisionIDContainer &)
checks if required decision ID is in the set of IDs in the container
virtual const std::string & name() const
friend class Job
Definition Algorithm.h:292
the interface for algorithms to access IWorker
Definition IWorker.h:40
std::set< std::string > m_whiteFloat
description: the list of whiteboard floats we copy
Definition NTupleSvc.h:226
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
std::set< std::string >::iterator m_copyBranchesIter
Definition NTupleSvc.h:222
void addWhiteFloat(const std::string &varName)
effects: add a float from the whiteboard guarantee: strong failures: out of memory II
ClassDef(NTupleSvc, 1)
std::set< std::string >::iterator m_whiteFloatIter
Definition NTupleSvc.h:227
TTree * tree() const
returns: the tree we are writing out guarantee: no-fail requires(soft): initialize() has been called ...
TFile * m_file
description: the file we are writing out
Definition NTupleSvc.h:236
bool m_connected
description: whether our output branches are properly connected to the input tree
Definition NTupleSvc.h:253
std::vector< CopyInfo >::iterator copyInfoMIter
Definition NTupleSvc.h:280
std::string m_outputName
description: the name of the output stream
Definition NTupleSvc.h:209
virtual StatusCode setupJob(Job &job)
effects: give the algorithm a chance to intialize the job with anything this algorithm needs.
void initOutput(const std::string &branchName)
effects: create the branch in the output tree guarantee: basic, may create some failures: out of memo...
std::string m_treeName
description: the name of the output tree
Definition NTupleSvc.h:213
std::string m_tree_title
description: the title of the output tree
Definition NTupleSvc.h:217
void treeName(const std::string &val_treeName)
NTupleSvc(const std::string &val_outputName="output")
effects: standard constructor guarantee: strong failures: out of memory I requires: !...
void addWhiteArray(const std::string &varName)
effects: add an array from the whiteboard guarantee: strong failures: out of memory II
void initOutput(const std::set< std::string > &branchList)
effects: create the branches in the output tree guarantee: basic, may create some failures: out of me...
virtual const char * GetName() const
effects: return the name of this algorithm guarantee: no-fail
void copyInput()
effects: copy the input branches to the output branches guarantee: basic, may copy some failures: out...
virtual bool hasName(const std::string &name) const
returns: whether this algorithm has the given name guarantee: basic failures: algorithm dependent rat...
virtual StatusCode changeInput(bool firstFile)
effects: do all changes to work with a new input file, e.g.
const std::string & treeName() const
description: the name of the tree, or the empty string to use the name of the input tree guarantee: n...
virtual StatusCode postExecute()
effects: do the post-processing for the event guarantee: basic failures: algorithm dependent rational...
TTree * m_tree
description: the tree we are writing out
Definition NTupleSvc.h:240
std::vector< WhiteInfo > m_whiteInfo
Definition NTupleSvc.h:303
virtual StatusCode execute()
effects: process the next event guarantee: basic failures: algorithm dependent rationale: the virtual...
void setFilterPassed(bool passed=true)
effects: take the current event if passed is set, otherwise perform a no-op guarantee: no-fail
~NTupleSvc()
effects: standard destructor guarantee: no-fail
virtual StatusCode initialize()
effects: do everything that needs to be done before running the algorithm, e.g.
bool getFilterPassed() const
returns: whether the current event will be taken guarantee: no-fail
std::set< std::string >::iterator m_whiteArrayIter
Definition NTupleSvc.h:232
bool m_taken
description: whether we take the current event
Definition NTupleSvc.h:248
void initBranches()
effects: create all the branches when called for the first time guarantee: basic, may create some fai...
std::vector< CopyInfo > m_copyInfo
Definition NTupleSvc.h:279
void copyBranch(const std::string &name)
effects: add another branch to copy.
std::set< std::string > m_whiteArray
description: the list of whiteboard arrays we copy
Definition NTupleSvc.h:231
void copyBranchList(const std::string &fileName)
effects: read a list of branches to copy from a file.
WhiteBoardSvc * m_whiteboard
description: the white board service, if we are using it
Definition NTupleSvc.h:257
std::set< std::string > m_copyBranches
description: the list of branches we copy
Definition NTupleSvc.h:221
std::vector< WhiteInfo >::iterator whiteInfoMIter
Definition NTupleSvc.h:304
bool m_initialized
description: whether we initialized the tree we are writing out
Definition NTupleSvc.h:244
void findBranches(std::set< std::string > &branchList)
effects: find the branches in the input tree guarantee: basic, may create some failures: out of memor...
This module defines the arguments passed from the BATCH driver to the BATCH worker.
NTupleSvc * getNTupleSvc(IWorker *worker, const std::string &outputStream, const std::string &treeName="")
effects: get the skimming algorithm for the given output for this worker guarantee: strong failures: ...
::StatusCode StatusCode
StatusCode definition for legacy code.
description: the information we need for copying branches
Definition NTupleSvc.h:262
std::vector< char > buffer
description: the buffer used if none is set
Definition NTupleSvc.h:277
std::string name
description: the name of the branch
Definition NTupleSvc.h:265
TBranch * target
description: the branch in the output tree
Definition NTupleSvc.h:273
TBranch * source
description: the branch in the source tree
Definition NTupleSvc.h:269
description: the information we need for whiteboard variables
Definition NTupleSvc.h:285
std::vector< float > * pointer
description: a pointer to the buffer rationale: this is used when writing arrays
Definition NTupleSvc.h:301
std::string name
description: the name of the branch
Definition NTupleSvc.h:288
bool array
description: whether this is an array branch
Definition NTupleSvc.h:292
std::vector< float > buffer
description: the buffer we are writing
Definition NTupleSvc.h:296