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
5#ifndef EVENT_LOOP_ALGS__NTUPLE_SVC_H
6#define EVENT_LOOP_ALGS__NTUPLE_SVC_H
7
8//
9// Distributed under the Boost Software License, Version 1.0.
10// (See accompanying file LICENSE_1_0.txt or copy at
11// http://www.boost.org/LICENSE_1_0.txt)
12
13// Please feel free to contact me (krumnack@iastate.edu) for bug
14// reports, feature suggestions, praise and complaints.
15
16
21
22
23
25
26#include <set>
27#include <EventLoop/Algorithm.h>
28
29class TBranch;
30class TFile;
31class TTree;
32
33namespace EL
34{
43 const std::string& outputStream,
44 const std::string& treeName = "");
45
46
47
48 class NTupleSvc : public EL::Algorithm
49 {
50 //
51 // public interface
52 //
53
56 public:
57 void testInvariant () const;
58
59
64 public:
65 NTupleSvc (const std::string& val_outputName = "output");
66
67
70 public:
72
73
78 public:
79 void copyBranch (const std::string& name);
80
81
89 public:
90 void copyBranchList (const std::string& fileName);
91
92
96 public:
97 void addWhiteFloat (const std::string& varName);
98
99
103 public:
104 void addWhiteArray (const std::string& varName);
105
106
111 public:
112 TTree *tree () const;
113
114
117 public:
118 bool getFilterPassed () const;
119
120
124 public:
125 void setFilterPassed (bool passed = true);
126
127
132 public:
133 const std::string& treeName () const;
134 void treeName (const std::string& val_treeName);
135
136
137 //
138 // interface inherited from Algorithm
139 //
140
143 public:
144 virtual const char *GetName () const;
145
146
155 private:
156 virtual StatusCode setupJob (Job& job);
157
158
164 private:
165 virtual StatusCode changeInput (bool firstFile);
166
167
178 private:
180
181
186 private:
187 virtual StatusCode execute ();
188
189
197 private:
199
200
207 private:
208 virtual bool hasName (const std::string& name) const;
209
210
211
212 //
213 // private interface
214 //
215
217 private:
218 std::string m_outputName;
219
221 private:
222 std::string m_treeName;
223
225 private:
226 std::string m_tree_title;
227
229 private:
230 std::set<std::string> m_copyBranches;
231 typedef std::set<std::string>::iterator m_copyBranchesIter;
232
234 private:
235 std::set<std::string> m_whiteFloat;
236 typedef std::set<std::string>::iterator m_whiteFloatIter;
237
239 private:
240 std::set<std::string> m_whiteArray;
241 typedef std::set<std::string>::iterator m_whiteArrayIter;
242
244 private:
245 TFile *m_file;
246
248 private:
249 TTree *m_tree;
250
252 private:
254
256 private:
257 bool m_taken;
258
261 private:
263
265 private:
267
269 private:
270 struct CopyInfo
271 {
273 public:
274 std::string name;
275
277 public:
278 TBranch *source;
279
281 public:
282 TBranch *target;
283
285 public:
286 std::vector<char> buffer;
287 };
288 std::vector<CopyInfo> m_copyInfo;
289 typedef std::vector<CopyInfo>::iterator copyInfoMIter;
290
292 private:
294 {
296 public:
297 std::string name;
298
300 public:
301 bool array;
302
304 public:
305 std::vector<float> buffer;
306
309 public:
310 std::vector<float> *pointer;
311 };
312 std::vector<WhiteInfo> m_whiteInfo;
313 typedef std::vector<WhiteInfo>::iterator whiteInfoMIter;
314
315
320 private:
322
323
328 private:
329 void findBranches (std::set<std::string>& branchList);
330
331
340 private:
341 void initOutput (const std::string& branchName);
342
343
349 private:
350 void initOutput (const std::set<std::string>& branchList);
351
352
356 private:
357 void copyInput ();
358
359
361 };
362}
363
364#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:235
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
std::set< std::string >::iterator m_copyBranchesIter
Definition NTupleSvc.h:231
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:236
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:245
bool m_connected
description: whether our output branches are properly connected to the input tree
Definition NTupleSvc.h:262
std::vector< CopyInfo >::iterator copyInfoMIter
Definition NTupleSvc.h:289
std::string m_outputName
description: the name of the output stream
Definition NTupleSvc.h:218
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:222
std::string m_tree_title
description: the title of the output tree
Definition NTupleSvc.h:226
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:249
std::vector< WhiteInfo > m_whiteInfo
Definition NTupleSvc.h:312
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:241
bool m_taken
description: whether we take the current event
Definition NTupleSvc.h:257
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:288
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:240
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:266
std::set< std::string > m_copyBranches
description: the list of branches we copy
Definition NTupleSvc.h:230
std::vector< WhiteInfo >::iterator whiteInfoMIter
Definition NTupleSvc.h:313
bool m_initialized
description: whether we initialized the tree we are writing out
Definition NTupleSvc.h:253
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:271
std::vector< char > buffer
description: the buffer used if none is set
Definition NTupleSvc.h:286
std::string name
description: the name of the branch
Definition NTupleSvc.h:274
TBranch * target
description: the branch in the output tree
Definition NTupleSvc.h:282
TBranch * source
description: the branch in the source tree
Definition NTupleSvc.h:278
description: the information we need for whiteboard variables
Definition NTupleSvc.h:294
std::vector< float > * pointer
description: a pointer to the buffer rationale: this is used when writing arrays
Definition NTupleSvc.h:310
std::string name
description: the name of the branch
Definition NTupleSvc.h:297
bool array
description: whether this is an array branch
Definition NTupleSvc.h:301
std::vector< float > buffer
description: the buffer we are writing
Definition NTupleSvc.h:305