| NAIA
    1.0.2
    | 
Mixin class to add "read-on-demand" behavior to an existing container class. More...
#include <OnDemandContainer.h>
| Public Member Functions | |
| OnDemandContainer ()=default | |
| void | LoadEvent () | 
| Wrapper to call GetEntryon the underlying TBranch.  More... | |
| void | SetTreeEntry (unsigned long long treeEntry) | 
| Set the TTree entry number.  More... | |
| void | Branch (TTree *tree) | 
| Create the TBranch associated with this container.  More... | |
| void | MirrorBranch (TTree *targetTree, const T *sourceContainer) | 
| Create a TBranch associated with this container mirroring from an existing container.  More... | |
| void | SetBranchAddress (TTree *tree) | 
| Setup reading of the data container.  More... | |
| void | DisableIO () const | 
| Disables I/O for this container. It won't be written on disk and trying to read it will cause an exception.  More... | |
| T * | operator-> () | 
| Access operator. Use this to access container data  More... | |
| Private Attributes | |
| T * | myPtrAddress | 
| TBranch * | m_branch = nullptr | 
| unsigned long long | m_treeEntry = std::numeric_limits<unsigned long long>::max() | 
| bool | m_cacheIsValid = false | 
| bool | m_ioEnabled = true | 
Mixin class to add "read-on-demand" behavior to an existing container class.
This class is designed as a mixin so that every "data container" class can inherit from this using the CRTP pattern and have automatically enabled branch handling and cached reading from a TTree object.
Example of container definition (for production only): ```cpp class TofBaseData : public TObject; // the data-container class class TofBase : public OnDemandContainer<TofBase>, public TofBaseData; // CRTP mixin in action! ```
Exampe usage during analysis ```cpp for(size_t iEv=0; iEv < chain->GetEntries(); iEv++){ auto event = chain->GetEvent(iEv); // this calls SetTreeEntry betaHist->Fill( event.tofBase->Beta ); // this triggers "read-on-demand" due to use of operator-> } ```
NOTE: T class must have a static std::string BranchName. This is because multiple std::map insertion in the T "Data" corresponding class might write into private members of OnDemandContainer while writing, so BranchName can't be a non-static member or data layout might be screwed up. This shouldn't happen in read mode but it should be tested. 
| T | - the data container class | 
Definition at line 44 of file OnDemandContainer.h.
| 
 | default | 
| 
 | inline | 
Create the TBranch associated with this container.
| tree | The TTree hosting the TBranch | 
Definition at line 80 of file OnDemandContainer.h.
Referenced by NAIA::Event::BranchAll().
| 
 | inline | 
Disables I/O for this container. It won't be written on disk and trying to read it will cause an exception.
Definition at line 116 of file OnDemandContainer.h.
| 
 | inline | 
Wrapper to call GetEntry on the underlying TBranch. 
Check if event changed before calling GetEntry, otherwise return same event 
Definition at line 54 of file OnDemandContainer.h.
Referenced by NAIA::Event::ForceReadAllBranches(), and NAIA::OnDemandContainer< RichBase >::operator->().
| 
 | inline | 
Create a TBranch associated with this container mirroring from an existing container.
| tree | The TTree hosting the TBranch | 
| sourceContainer | The container from which to read the data | 
Definition at line 91 of file OnDemandContainer.h.
Referenced by NAIA::Event::MirrorBranches().
| 
 | inline | 
Access operator. Use this to access container data
We overload the -> operator to wrap the data access and insert the "read-on-demand" behavior before the data access.
this, as it should be | std::runtime_error | if this container I/O capabilities have been disabled previously | 
Definition at line 127 of file OnDemandContainer.h.
| 
 | inline | 
Setup reading of the data container.
| tree | The input TTree | 
Definition at line 103 of file OnDemandContainer.h.
Referenced by NAIA::Event::SetAllBranchAddress().
| 
 | inline | 
Set the TTree entry number.
| treeEntry | the TTree entry to be loaded | 
Definition at line 68 of file OnDemandContainer.h.
Referenced by NAIA::Event::SetEventNumber().
| 
 | private | 
Definition at line 139 of file OnDemandContainer.h.
Referenced by NAIA::OnDemandContainer< RichBase >::LoadEvent(), and NAIA::OnDemandContainer< RichBase >::SetBranchAddress().
| 
 | mutableprivate | 
Definition at line 142 of file OnDemandContainer.h.
Referenced by NAIA::OnDemandContainer< RichBase >::LoadEvent(), and NAIA::OnDemandContainer< RichBase >::SetTreeEntry().
| 
 | mutableprivate | 
Definition at line 143 of file OnDemandContainer.h.
Referenced by NAIA::OnDemandContainer< RichBase >::Branch(), NAIA::OnDemandContainer< RichBase >::DisableIO(), NAIA::OnDemandContainer< RichBase >::LoadEvent(), NAIA::OnDemandContainer< RichBase >::MirrorBranch(), NAIA::OnDemandContainer< RichBase >::operator->(), and NAIA::OnDemandContainer< RichBase >::SetBranchAddress().
| 
 | private | 
Definition at line 140 of file OnDemandContainer.h.
Referenced by NAIA::OnDemandContainer< RichBase >::LoadEvent(), and NAIA::OnDemandContainer< RichBase >::SetTreeEntry().
| 
 | private | 
Definition at line 138 of file OnDemandContainer.h.
Referenced by NAIA::OnDemandContainer< RichBase >::operator->(), and NAIA::OnDemandContainer< RichBase >::SetBranchAddress().
 1.8.5
 1.8.5