1 #ifndef __JSUPPORT__JTREESCANNER__
2 #define __JSUPPORT__JTREESCANNER__
27 namespace JPP {
using namespace JSUPPORT; }
51 template<
class JClass_t>
53 public JPointer< JChainReader<JClass_t> >
88 template<
class JClass_t = JNullType,
class JEvaluator_t = JNullType>
110 template<
class JDerived_t,
class JBase_t>
172 if (counter < this->getLowerLimit()) {
173 skip(this->getLowerLimit() - counter);
176 return (counter < this->getEntries() &&
177 counter < this->getUpperLimit());
188 if (this->hasNext()) {
190 this->
get()->GetEvent(counter++);
192 ps.reset(this->
get()->getAddress());
223 using namespace JROOT;
225 this->setLimit(limit);
229 this->
get()->Reset();
232 if (TFile(i->c_str()).GetListOfKeys()->Contains(this->
get()->getTreeName())) {
233 this->
get()->Add(i->c_str());
239 actionAtFileOpen<JDerived_t>(this->
get()->GetCurrentFile());
240 actionAtFileOpen<JBase_t> (this->
get()->GetCurrentFile());
251 return this->
get()->GetEntries();
263 if (index >= 0 && index < this->getEntries()) {
265 this->
get()->GetEvent(index);
267 return this->
get()->getAddress();
292 return JDerived_t::Class_Name();
307 template<
class JClass_t>
309 public JTreeScanner<JAssertConversion<JClass_t, JClass_t>, JNullType>
352 template<
class JDerived_t,
class JBase_t,
class JEvaluator_t>
355 public JTreeScanner<JAssertConversion<JDerived_t, JBase_t>, JNullType>
377 const double __value) :
390 friend inline bool operator<(
const JEntry_t& first,
const JEntry_t& second)
392 return first.value < second.value;
403 friend inline bool operator<(
const JEntry_t& entry,
const double value)
405 return entry.value < value;
446 const JEvaluator_t& evaluator = JEvaluator_t()) :
462 const JEvaluator_t& evaluator = JEvaluator_t()) :
476 if (this->hasNext()) {
478 this->
get()->GetEvent(queue[this->counter++].index);
480 ps.reset(this->
get()->getAddress());
503 setBranchStatus(this->
get()->GetBranch(this->
get()->getBranchName()),
BRANCH_PATTERN,
false);
505 queue.resize(this->getEntries());
507 typename queue_type::iterator out = queue.begin();
509 for (Long64_t i = 0; i != this->getEntries(); ++i, ++out) {
511 STATUS(left << setw(24) << this->
get()->GetName() << right <<
' ' << setw(3) << (100 * (i + 1)) / this->getEntries() <<
"%\r");
DEBUG(endl);
513 this->
get()->GetEvent(i);
515 const data_type* p = this->
get()->getAddress();
521 this->
get()->SetBranchStatus(
"*", 1);
523 sort(queue.begin(), queue.end());
538 if (index >= 0 && index < (Long64_t) queue.size()) {
540 this->
get()->GetEvent(queue[index].index);
542 return this->
get()->getAddress();
557 virtual Long64_t
find(
const double value)
const
561 if (!queue.empty()) {
563 typename queue_type::const_iterator p = lower_bound(queue.begin(), queue.end(), value);
565 if (p == queue.end()) {
567 return queue.size() - 1;
569 }
else if (p == queue.begin()) {
575 typename queue_type::const_iterator q = p--;
577 if (value - p->value < q->value - value)
578 return distance(queue.begin(), p);
580 return distance(queue.begin(), q);
601 if (branch != NULL) {
603 TObjArray* array = branch->GetListOfBranches();
605 for (Int_t i = 0; i != array->GetEntries(); ++i) {
607 TBranch* p = (TBranch*) array->At(i);
609 if (p != NULL &&
string(p->GetName()).find(pattern) != string::npos) {
611 if (p->GetSplitLevel() == 0) {
613 NOTICE(
"Set status of branch " << p->GetName() <<
" to " << status << endl);
615 p->SetStatus(status);
619 setBranchStatus(p, pattern, status);
636 template<
class JClass_t,
class JEvaluator_t>
638 public JTreeScanner<JAssertConversion<JClass_t, JClass_t>, JEvaluator_t>
654 const JEvaluator_t& evaluator = JEvaluator_t()) :
668 const JEvaluator_t& evaluator = JEvaluator_t()) :
std::ostream & rewind(std::ostream &out)
Rewind character.
virtual Long64_t getEntries() const
Get number of entries.
virtual void configure(const JMultipleFileScanner_t &file_list, const JLimit &limit)
Configure.
virtual data_type * getEntry(Long64_t index)
Get entry at given index.
virtual const pointer_type & next()
Get next element.
JTreeScanner(const JMultipleFileScanner_t &file_list, const JLimit &limit=JLimit())
Constructor.
JTreeScanner(const JMultipleFileScanner_t &file_list, const JLimit &limit, const JEvaluator_t &evaluator=JEvaluator_t())
Constructor.
JEntry_t(const Long64_t __index, const double __value)
Constructor.
unsigned int skip_type
Type definition for number of objects to skip.
JTreeScanner(const JMultipleFileScanner_t &file_list, const JEvaluator_t &evaluator=JEvaluator_t())
Constructor.
static void setBranchStatus(TBranch *branch, const char *pattern, const bool status)
Set status of branch.
JTreeScannerInterface< JBase_t >::pointer_type pointer_type
JTreeScanner(const JMultipleFileScanner_t &file_list, const JLimit &limit, const JEvaluator_t &evaluator=JEvaluator_t())
Constructor.
JTreeScanner(const JMultipleFileScanner_t &file_list, const JEvaluator_t &evaluator=JEvaluator_t())
Constructor.
Auxialiary class to assert type conversion.
Long64_t counter_type
Type definition for counter.
friend bool operator<(const JEntry_t &entry, const double value)
Comparison between TChain entry and value.
JTreeScanner()
Default constructor.
bool is_valid() const
Check validity of pointer.
Template definition for direct access of elements in ROOT TChain.
JTreeScanner()
Default constructor.
Auxiliary interface for direct access of elements in ROOT TChain.
virtual const pointer_type & next()
Get next element.
Auxiliary class for template TChain reading.
Scanning of objects from a single file according a format that follows from the extension of each fil...
friend bool operator<(const JEntry_t &first, const JEntry_t &second)
Comparison between two TChain entries.
Auxiliary class for defining the range of iterations of objects.
JTreeScannerInterface< JBase_t, JEvaluator_t >::pointer_type pointer_type
virtual bool hasNext()
Check availability of next element.
TChain reading for template data type.
virtual data_type * getEntry(Long64_t index)
Get entry at given index.
JTreeScanner()
Default constructor.
Long64_t index
index in TChain
std::vector< JEntry_t > queue_type
Type definition of internal queue for ordering the elements in the TChain.
Auxiliary class for no type definition.
Template implementation of class that holds pointer to object(s).
Data type dependent action methods for customised ROOT version management.
virtual void configure(const JMultipleFileScanner_t &file_list, const JLimit &limit)
Configure.
virtual counter_type getCounter() const
Get internal counter.
General purpose messaging.
counter_type advance(counter_type &counter, const counter_type value, const counter_type limit=std::numeric_limits< counter_type >::max())
Advance counter.
JTreeScanner(const JTreeScanner &input)
Copy constructor.
static const char *const BRANCH_PATTERN
Pattern match for names of sub-branches that will not be read when ordering elements in a TTree...
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Base class for JTreeScanner.
JEntry_t()
Default constructor.
Auxiliary base class for list of file names.
JTreeScanner(const JTreeScanner &input)
Copy constructor.
General purpose class for object reading from a list of file names.
JTreeScanner(const JMultipleFileScanner_t &file_list, const JLimit &limit=JLimit())
Constructor.
Type definition for counter for ROOT TTree and auxiliary methods.
virtual Long64_t find(const double value) const
Find index of element that is closest in value to given value.
virtual skip_type skip(const skip_type ns)
Skip items.
double value
corresponding value
virtual void rewind()
Rewind.
JTreeScanner()
Default constructor.
JTreeScanner_t()
Default constructor.
#define DEBUG(A)
Message macros.
virtual const char * getClassName() const
Get actual class name.
Auxiliary class for handling debug parameter within a class.