Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
22 #include <TBranchElement.h>
69 NTupleSvc (
const std::string& val_outputName)
70 :
m_file (0), m_tree (0), m_initialized (
false),
75 m_outputName = val_outputName;
108 while (!
line.empty() && isspace (
line[0]))
112 if (!
line.empty() &&
line[0] !=
'#')
176 treeName (
const std::string& val_treeName)
198 return EL::StatusCode::SUCCESS;
208 return EL::StatusCode::SUCCESS;
232 m_tree->SetAutoSave(10000);
234 m_tree->SetAutoFlush( -30000000 );
235 TTree::SetBranchStyle(1);
237 return EL::StatusCode::SUCCESS;
247 return EL::StatusCode::SUCCESS;
259 return EL::StatusCode::SUCCESS;
277 return EL::StatusCode::SUCCESS;
300 std::set<std::string> branchList;
330 iter->buffer.resize (1);
346 std::size_t
count = 0;
350 for (TIter branchIter (
wk()->
tree()->GetListOfBranches());
351 (
object = branchIter());)
358 branchList.insert (
str.Data());
363 RCU_THROW_MSG (
"could not find any branch that matches pattern \"" + *
iter +
"\"");
376 if (
branch->name == branchName)
381 info.name = branchName;
382 info.source =
wk()->
tree()->FindBranch (branchName.c_str());
383 if (
info.source == 0)
384 RCU_THROW_MSG (
"could not find input branch: " + branchName);
390 static_cast<void*
>(0));
393 static std::map<std::string,std::string> types;
396 types[
"Char_t"] =
"B";
397 types[
"UChar_t"] =
"b";
398 types[
"Short_t"] =
"S";
399 types[
"UShort_t"] =
"s";
400 types[
"Int_t"] =
"I";
401 types[
"UInt_t"] =
"i";
402 types[
"Float_t"] =
"F";
403 types[
"Double_t"] =
"D";
404 types[
"Long64_t"] =
"L";
405 types[
"ULong64_t"] =
"l";
406 types[
"Bool_t"] =
"O";
411 for (TIter
iter =
info.source->GetListOfLeaves(); (
object =
iter()); )
413 TLeaf *myleaf =
dynamic_cast<TLeaf*
>(
object);
417 std::string
typeName = myleaf->GetTypeName();
418 std::map<std::string,std::string>::const_iterator
type
420 if (
type == types.end())
425 leaves = leaves + myleaf->GetTitle() +
"/" +
type->second;
428 RCU_THROW_MSG (
"failed to scan leaves of branch " + branchName);
430 for (std::string::size_type
pos = 0;
431 (
pos = leaves.find (
"[",
pos)) != std::string::npos; )
434 std::string::size_type pos2 = leaves.find (
"]",
pos);
435 if (pos2 == std::string::npos)
436 RCU_THROW_MSG (
"failed to scan leaf dimensions for " + leaves);
437 std::string
dim = leaves.substr (
pos, pos2 -
pos);
438 if (!(
dim[0] >=
'0' &&
dim[0] <=
'9'))
441 info.target =
m_tree->Branch (branchName.c_str(),
static_cast<void*
>(0),
450 initOutput (
const std::set<std::string>& branchList)
452 for (std::set<std::string>::const_iterator
branch = branchList.begin(),
467 info->source =
dynamic_cast<TBranch*
>
468 (
wk()->
tree()->GetBranch (
info->name.c_str()));
480 std::size_t
size =
sizeof (
void*);
482 for (TIter
iter =
info->source->GetListOfLeaves();
485 TLeaf *myleaf =
dynamic_cast<TLeaf*
>(
object);
488 TLeaf *countleaf = myleaf->GetLeafCounter (countval);
490 countval = countleaf->GetMaximum();
492 RCU_THROW_MSG (std::string (
"could not determine size of leaf ") + myleaf->GetName() +
" in branch " +
info->name);
495 const std::size_t mysize
496 = myleaf->GetOffset() + myleaf->GetLenType() * countval;
501 info->source->SetStatus (1);
506 info->source->GetEntry (
wk()->treeEntry(), 1);
bool m_initialized
description: whether we initialized the tree we are writing out
void addWhiteArray(const std::string &varName)
effects: add an array from the whiteboard guarantee: strong failures: out of memory II
std::vector< CopyInfo >::iterator copyInfoMIter
std::string m_treeName
description: the name of the output tree
std::set< std::string > m_whiteFloat
description: the list of whiteboard floats we copy
void addWhiteFloat(const std::string &varName)
effects: add a float from the whiteboard guarantee: strong failures: out of memory II
std::vector< WhiteInfo > m_whiteInfo
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
void testInvariant() const
effects: test the invariant of this object guarantee: no-fail
TFile * m_file
description: the file we are writing out
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...
TTree * tree() const
returns: the tree we are writing out guarantee: no-fail requires(soft): initialize() has been called ...
std::set< std::string >::iterator m_whiteFloatIter
void initBranches()
effects: create all the branches when called for the first time guarantee: basic, may create some fai...
std::unique_ptr< TFile > m_file
description: this is a custom writer for the old-school drivers that don't use an actual writer
std::set< std::string >::iterator m_copyBranchesIter
void copyBranchList(const std::string &fileName)
effects: read a list of branches to copy from a file.
std::string m_outputName
description: the name of the output stream
virtual StatusCode changeInput(bool firstFile)
effects: do all changes to work with a new input file, e.g.
virtual StatusCode execute()
effects: process the next event guarantee: basic failures: algorithm dependent rationale: the virtual...
#define RCU_ASSERT2_SOFT(x, y)
#define RCU_REQUIRE_SOFT(x)
void getArray(const std::string &name, std::size_t &size, const float *&values) const
string varName
end cluster ToT and charge
::StatusCode StatusCode
StatusCode definition for legacy code.
bool m_taken
description: whether we take the current event
virtual const char * GetName() const
effects: return the name of this algorithm guarantee: no-fail
float getFloat(const std::string &name) const
returns: the content of the variable, assuming the given type guarantee: strong failures: variable no...
This module defines the arguments passed from the BATCH driver to the BATCH worker.
NTupleSvc(const std::string &val_outputName="output")
effects: standard constructor guarantee: strong failures: out of memory I requires: !...
std::vector< WhiteInfo >::iterator whiteInfoMIter
IWorker * wk() const
description: the worker that is controlling us guarantee: no-fail
virtual const std::string & name() const
std::set< std::string > m_copyBranches
description: the list of branches we copy
void copyBranch(const std::string &name)
effects: add another branch to copy.
~NTupleSvc()
effects: standard destructor guarantee: no-fail
virtual StatusCode setupJob(Job &job)
effects: give the algorithm a chance to intialize the job with anything this algorithm needs.
void findBranches(std::set< std::string > &branchList)
effects: find the branches in the input tree guarantee: basic, may create some failures: out of memor...
bool getFilterPassed() const
returns: whether the current event will be taken guarantee: no-fail
void initOutput(const std::string &branchName)
effects: create the branch in the output tree guarantee: basic, may create some failures: out of memo...
TTree * m_tree
description: the tree we are writing out
virtual StatusCode postExecute()
effects: do the post-processing for the event guarantee: basic failures: algorithm dependent rational...
bool m_connected
description: whether our output branches are properly connected to the input tree
#define RCU_REQUIRE2_SOFT(x, y)
std::set< std::string >::iterator m_whiteArrayIter
#define RCU_DESTROY_INVARIANT(x)
virtual bool hasName(const std::string &name) const
returns: whether this algorithm has the given name guarantee: basic failures: algorithm dependent rat...
WhiteBoardSvc * getWhiteBoardSvc(IWorker *worker)
effects: get the whiteboard service for this worker guarantee: strong failures: formula service not c...
std::set< std::string > m_whiteArray
description: the list of whiteboard arrays we copy
virtual TFile * getOutputFile(const std::string &label) const =0
effects: get the output file that goes into the dataset with the given label.
#define RCU_CHANGE_INVARIANT(x)
virtual StatusCode initialize()
effects: do everything that needs to be done before running the algorithm, e.g.
std::vector< CopyInfo > m_copyInfo
#define RCU_THROW_MSG(message)
void setFilterPassed(bool passed=true)
effects: take the current event if passed is set, otherwise perform a no-op guarantee: no-fail
void copyInput()
effects: copy the input branches to the output branches guarantee: basic, may copy some failures: out...
std::string m_tree_title
description: the title of the output tree
WhiteBoardSvc * m_whiteboard
description: the white board service, if we are using it
#define RCU_READ_INVARIANT(x)
virtual TTree * tree() const =0
description: the tree we are running on guarantee: no-fail
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: ...
#define RCU_NEW_INVARIANT(x)
ClassImp(EL::NTupleSvc) namespace EL