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> >
76 gErrorIgnoreLevel = kError;
90 template<
class JClass_t = JNullType,
class JEvaluator_t = JNullType>
112 template<
class JDerived_t,
class JBase_t>
174 if (counter < this->getLowerLimit()) {
175 skip(this->getLowerLimit() - counter);
178 return (counter < this->getEntries() &&
179 counter < this->getUpperLimit());
190 if (this->hasNext()) {
192 this->
get()->GetEvent(counter++);
194 ps.reset(this->
get()->getAddress());
225 using namespace JROOT;
227 this->setLimit(limit);
231 this->
get()->Reset();
235 TFile* file = TFile::Open(i->c_str());
237 if (file != NULL && file->GetListOfKeys()->Contains(this->
get()->getTreeName())) {
238 this->
get()->Add(i->c_str());
246 actionAtFileOpen<JDerived_t>(this->
get()->GetCurrentFile());
247 actionAtFileOpen<JBase_t> (this->
get()->GetCurrentFile());
258 return this->
get()->GetEntries();
270 if (index >= 0 && index < this->getEntries()) {
272 this->
get()->GetEvent(index);
274 return this->
get()->getAddress();
299 return JDerived_t::Class_Name();
314 template<
class JClass_t>
316 public JTreeScanner<JAssertConversion<JClass_t, JClass_t>, JNullType>
359 template<
class JDerived_t,
class JBase_t,
class JEvaluator_t>
362 public JTreeScanner<JAssertConversion<JDerived_t, JBase_t>, JNullType>
384 const double __value) :
399 return first.value < second.value;
410 friend inline bool operator<(
const JEntry_t& entry,
const double value)
412 return entry.value < value;
453 const JEvaluator_t& evaluator = JEvaluator_t()) :
469 const JEvaluator_t& evaluator = JEvaluator_t()) :
483 if (this->hasNext()) {
485 this->
get()->GetEvent(
queue[this->counter++].index);
487 ps.reset(this->
get()->getAddress());
510 setBranchStatus(this->
get()->GetBranch(this->
get()->getBranchName()),
BRANCH_PATTERN,
false);
512 queue.resize(this->getEntries());
514 typename queue_type::iterator out =
queue.begin();
516 for (Long64_t i = 0; i != this->getEntries(); ++i, ++out) {
518 STATUS(left << setw(24) << this->
get()->GetName() << right <<
' ' << setw(3) << (100 * (i + 1)) / this->getEntries() <<
"%\r");
DEBUG(endl);
520 this->
get()->GetEvent(i);
522 const data_type* p = this->
get()->getAddress();
528 this->
get()->SetBranchStatus(
"*", 1);
542 if (index >= 0 && index < (Long64_t)
queue.size()) {
544 this->
get()->GetEvent(
queue[index].index);
546 return this->
get()->getAddress();
561 virtual Long64_t
find(
const double value)
const
565 if (!
queue.empty()) {
567 typename queue_type::const_iterator p = lower_bound(
queue.begin(),
queue.end(), value);
569 if (p ==
queue.end()) {
571 return queue.size() - 1;
573 }
else if (p ==
queue.begin()) {
579 typename queue_type::const_iterator q = p--;
581 if (value - p->value < q->value - value)
605 if (branch != NULL) {
607 TObjArray* array = branch->GetListOfBranches();
609 for (Int_t i = 0; i != array->GetEntries(); ++i) {
611 TBranch* p = (TBranch*) array->At(i);
613 if (p != NULL &&
string(p->GetName()).find(pattern) != string::npos) {
615 if (p->GetSplitLevel() == 0) {
617 NOTICE(
"Set status of branch " << p->GetName() <<
" to " << status << endl);
619 p->SetStatus(status);
623 setBranchStatus(p, pattern, status);
640 template<
class JClass_t,
class JEvaluator_t>
642 public JTreeScanner<JAssertConversion<JClass_t, JClass_t>, JEvaluator_t>
658 const JEvaluator_t& evaluator = JEvaluator_t()) :
672 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.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
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.
Type definition for counter for ROOT TTree and auxiliary methods.
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.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
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.
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.