Jpp  19.1.0
the software that should make you happy
JChainReader.hh
Go to the documentation of this file.
1 #ifndef __JROOT__JCHAINREADER__
2 #define __JROOT__JCHAINREADER__
3 
4 #include "TChain.h"
5 
6 #include "JROOT/JRootAddress.hh"
8 
9 
10 /**
11  * \file
12  * TChain reading for template data type.
13  * \author mdejong
14  */
15 namespace JROOT {}
16 namespace JPP { using namespace JROOT; }
17 
18 namespace JROOT {
19 
20  /**
21  * Auxiliary class for template TChain reading.
22  */
23  template<class T>
24  class JChainReader :
25  public TChain,
26  public JRootAddress<T>,
27  public JTreeParameters
28  {
29  public:
30  /**
31  * Default constructor.
32  *
33  * Note that the default TTree parameters are obtained using template method JROOT::getTreeParameters.
34  */
37  {
38  configure();
39  }
40 
41 
42  /**
43  * Constructor.
44  *
45  * \param parameters parameters of TTree
46  */
47  JChainReader(const JTreeParameters& parameters) :
48  JTreeParameters(parameters)
49  {
50  configure();
51  }
52 
53 
54  /**
55  * Copy constructor.
56  *
57  * Note that the TTree parameters are copied but not the contents.
58  *
59  * \param reader TChain reader
60  */
61  JChainReader(const JChainReader<T>& reader) :
63  {
64  configure();
65  }
66 
67 
68  /**
69  * Reset this TChain.
70  *
71  * This method executes the following steps:
72  * -# TChain::Reset();
73  * -# releases the allocated memory and resets the internal pointer;
74  * -# SetBranchAddress();
75  *
76  * \param option option
77  */
78  void Reset(Option_t* option = NULL)
79  {
80  TChain::Reset(option);
81 
82  this->release();
83 
84  this->SetBranchAddress(this->getBranchName(), &this->address);
85  }
86 
87 
88  protected:
89  /**
90  * Configure this TChain.
91  */
92  void configure()
93  {
94  this->SetNameTitle(this->getTreeName(), this->getTreeTitle());
95 
96  this->SetBranchAddress(this->getBranchName(), &this->address);
97  }
98  };
99 }
100 
101 #endif
Auxiliary class for template TChain reading.
Definition: JChainReader.hh:28
JChainReader(const JTreeParameters &parameters)
Constructor.
Definition: JChainReader.hh:47
JChainReader()
Default constructor.
Definition: JChainReader.hh:35
void Reset(Option_t *option=NULL)
Reset this TChain.
Definition: JChainReader.hh:78
JChainReader(const JChainReader< T > &reader)
Copy constructor.
Definition: JChainReader.hh:61
void configure()
Configure this TChain.
Definition: JChainReader.hh:92
Data structure for TTree parameters.
const TString & getBranchName() const
Get TBranch name.
const TString & getTreeName() const
Get TTree name.
const TString & getTreeTitle() const
Get TTree title.
const JTreeParameters & getTreeParameters() const
Get TTree parameters.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.
Auxiliary classd for address handling within TTree or TChain.
Definition: JRootAddress.hh:19
void release()
Release memory.
Definition: JRootAddress.hh:46