Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JTriggeredFileScanner.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGEREDFILESCANNER__
2 #define __JTRIGGEREDFILESCANNER__
3 
4 #include "JLang/JTypeList.hh"
5 #include "JLang/JNullType.hh"
6 #include "JLang/JMultiPointer.hh"
7 
8 #include "evt/Evt.hh"
9 #include "JDAQ/JDAQEvent.hh"
12 #include "JSupport/JTreeScanner.hh"
13 #include "JSupport/JSupport.hh"
14 
15 
16 /**
17  * \file
18  *
19  * Synchronously read DAQ events and Monte Carlo events (and optionally other events).
20  * \author mdejong
21  */
22 namespace JSUPPORT {}
23 namespace JPP { using namespace JSUPPORT; }
24 
25 namespace JSUPPORT {
26 
27  using JLANG::JTypeList;
28  using JLANG::JNullType;
31 
32 
33  /**
34  * Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events).
35  * It is assumed that the TTree corresponding to the template argument and
36  * the TTree with KM3NETDAQ::JDAQEvent can be read in parallel.
37  */
38  template<class JTypelist_t = JNullType>
40  public JParallelFileScanner<JTypeList<JDAQEvent, JTypelist_t>, JMultipleFileScanner>
41  {
45 
46 
47  /**
48  * Default constructor.
49  */
51  base_class()
52  {}
53 
54 
55  /**
56  * Constructor.
57  *
58  * \param input input
59  * \param limit limit
60  */
61  JTriggeredFileScanner(const typename base_class::input_type& input, const JLimit& limit = JLimit())
62  {
63  this->configure(input, limit);
64  }
65 
66 
67  /**
68  * Check availability of next element.
69  *
70  * \return true if the iteration has more elements; else false
71  */
72  virtual bool hasNext()
73  {
74  bool has_next = base_class::hasNext();
75 
76  if (has_next && file_name != this->getFilename()) {
77 
78  in.configure(this->getFilename());
79 
80  file_name = this->getFilename();
81  }
82 
83  return has_next;
84  }
85 
86 
87  /**
88  * Get next element.
89  *
90  * \return multi-pointer to elements
91  */
92  virtual const multi_pointer_type& next()
93  {
94  static multi_pointer_type ps;
95 
97 
98  JDAQEvent* tev = __p;
99  Evt* event = in.getEntry(tev->getCounter());
100 
101  ps.reset(event, __p);
102 
103  return ps;
104  }
105 
106  protected:
108  std::string file_name;
109  };
110 }
111 
112 
113 #endif
JMultiPointer< JTypeList< Evt, typelist > > multi_pointer_type
void reset(const JMultiPointer< JClass_t > &pointer)
Reset multi-pointer.
Auxiliary class to synchronously read DAQ events and Monte Carlo events (and optionally other events)...
Structure to store the ToT mean and standard deviation of the hits produced by a nanobeacon in a sour...
General purpose class for parallel reading of objects from a single file or multiple files...
virtual bool hasNext()
Constructor.
virtual const multi_pointer_type & next()
Get next element.
Type list.
Definition: JTypeList.hh:22
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Parallel scanning of objects from a single file or multiple files according a format that follows fro...
Auxiliary class for no type definition.
Definition: JNullType.hh:19
const std::string & getFilename() const
Get current file name.
virtual const multi_pointer_type & next()
Constructor.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
void configure(const T &value, const JAbstractCollection< JAbscissa_t > &bounds, JBool< false > option)
Configuration of value.
JParallelFileScanner< typelist, JMultipleFileScanner > base_class
ROOT TTree parameter settings.
JTypeList< JDAQEvent, JTypelist_t > typelist
JFileScanner_t< JNullType >::input_type input_type
General purpose class for multiple pointers.
JTriggerCounter_t getCounter() const
Get trigger counter.
JTriggeredFileScanner()
Default constructor.