21 namespace PhysicsTools {
36 tree(tree), upToDate(
false)
77 <<
"No TTree set in TreeReader::addBranch."
80 TBranch *branch =
tree->GetBranch(expression.c_str());
83 <<
"Tree branch \"" << expression <<
"\" missing."
91 TString branchName = branch->GetName();
93 name = (
const char*)branchName;
95 TLeaf *
leaf =
dynamic_cast<TLeaf*
>(branch->GetLeaf(branchName));
98 <<
"Tree branch \"" << branchName <<
"\" has no leaf."
101 TString typeName = leaf->GetTypeName();
104 if (typeName ==
"Double_t" || typeName ==
"double")
106 else if (typeName ==
"Float_t" || typeName ==
"float")
108 else if (typeName ==
"Int_t" || typeName ==
"int")
110 else if (typeName ==
"Bool_t" || typeName ==
"bool")
114 if (typeName ==
"vector<double>" ||
115 typeName ==
"Vector<Double_t>")
117 else if (typeName ==
"vector<float>" ||
118 typeName ==
"Vector<Float_t>")
120 else if (typeName ==
"vector<int>" ||
121 typeName ==
"Vector<Int_t>")
123 else if (typeName ==
"vector<bool>" ||
124 typeName ==
"Vector<Bool_t>")
130 <<
"Tree branch \"" << branchName <<
"\" is of "
131 "unsupported type \"" << typeName <<
"\"."
144 std::map<AtomicId, Value>::iterator pos =
valueMap.find(name);
147 <<
"Variable \"" <<name <<
"\" is not known to the "
148 "TreeReader." << std::endl;
150 pos->second.setOpt(opt, optVal);
155 std::map<AtomicId, Value>::const_iterator pos =
valueMap.find(name);
158 <<
"Duplicate Variable \"" << name <<
"\"."
161 if (type !=
'D' && type !=
'F' && type !=
'I' && type !=
'B')
163 <<
"Unsupported type '" << type <<
"' in call to"
164 "TreeReader::addTypeSingle." << std::endl;
197 {
return std::pair<void*, std::vector<T> >(0, std::vector<T>()); }
201 std::map<AtomicId, Value>::const_iterator pos =
valueMap.find(name);
204 <<
"Duplicate Variable \"" << name <<
"\"."
207 if (type !=
'D' && type !=
'F' && type !=
'I' && type !=
'B')
209 <<
"Unsupported type '" << type <<
"' in call to"
210 "TreeReader::addTypeMulti." << std::endl;
225 multiInt.push_back(makeMulti<Int_t>());
229 multiBool.push_back(makeMulti<Bool_t>());
245 <<
"No TTree set in TreeReader::automaticAdd."
248 TIter iter(
tree->GetListOfBranches());
250 while((obj = iter())) {
251 TBranch *branch =
dynamic_cast<TBranch*
>(
obj);
256 !std::strcmp(branch->GetName(),
"__TARGET__"))
260 !std::strcmp(branch->GetName(),
"__WEIGHT__"))
288 <<
"No TTree set in TreeReader::automaticAdd."
291 for(std::map<AtomicId, Value>::iterator iter =
valueMap.begin();
293 iter->second.update(
this);
302 <<
"No TTree set in TreeReader::automaticAdd."
309 for(Long64_t entry = 0; entry <
entries; entry++)
311 tree->GetEntry(entry);
320 for(std::map<AtomicId, Value>::const_iterator iter =
valueMap.begin();
322 iter->second.fill(iter->first,
this);
332 for(std::map<AtomicId, Value>::const_iterator iter =
valueMap.begin();
334 iter->second.fill(iter->first,
this);
344 std::vector<AtomicId>
result;
345 for(std::map<AtomicId, Value>::const_iterator iter =
valueMap.begin();
347 result.push_back(iter->first);
397 reader->
tree->SetBranchAddress(
name, value);
405 const std::vector<Double_t> *
values =
406 static_cast<const std::vector<Double_t>*
>(ptr);
409 for(std::vector<Double_t>::const_iterator iter =
410 values->begin(); iter != values->end(); iter++)
415 const std::vector<Float_t> *
values =
416 static_cast<const std::vector<Float_t>*
>(ptr);
419 for(std::vector<Float_t>::const_iterator iter =
420 values->begin(); iter != values->end(); iter++)
425 const std::vector<Int_t> *
values =
426 static_cast<const std::vector<Int_t>*
>(ptr);
429 for(std::vector<Int_t>::const_iterator iter =
430 values->begin(); iter != values->end(); iter++)
435 const std::vector<Bool_t> *
values =
436 static_cast<const std::vector<Bool_t>*
>(ptr);
439 for(std::vector<Bool_t>::const_iterator iter =
440 values->begin(); iter != values->end(); iter++)
450 value = ptr ? *(
const Double_t*)ptr
454 value = ptr ? *(
const Float_t*)ptr
458 value = ptr ? *(
const Int_t*)ptr
462 value = ptr ? *(
const Bool_t*)ptr
467 if (!optional || value != optVal)
472 #define TREEREADER_ADD_IMPL(T, C) \
474 void TreeReader::addSingle<T>(AtomicId name, const T *value, bool opt) \
475 { addTypeSingle(name, value, C, opt); } \
478 void TreeReader::addMulti(AtomicId name, const std::vector<T> *value) \
479 { addTypeMulti(name, value, C); }
486 #undef TREEREADER_ADD_IMPL
const std::complex< double > I
unsigned long long uint64_t
volatile std::atomic< bool > shutdown_flag false
static uInt32 F(BLOWFISH_CTX *ctx, uInt32 x)
#define TREEREADER_ADD_IMPL(T, C)