NAIA
|
#include <SingleTreeChain.h>
Classes | |
class | EventItr |
union | TC |
needed for SetBranchAddress More... | |
Public Types | |
enum | AccessMode { AccessMode::Read, AccessMode::Write } |
Simple enum to express whether we are in read or write mode. More... | |
Public Member Functions | |
SingleTreeChain (AccessMode mode=AccessMode::Read) | |
Construct a new Single Tree Chain object. More... | |
const FileInfo & | GetEventFileInfo () |
Get the FileInfo object associated with this event. More... | |
const RTIInfo & | GetEventRTIInfo () |
Get the RTIInfo object associated with this event. More... | |
Event & | GetEvent (unsigned long long iEv) |
Get the Event object. More... | |
Event & | GetEventWithIndex (unsigned int run, unsigned int eventno) |
Get the Event object using the underlying index. More... | |
TChain * | GetFileInfoTree () |
Get the FileInfo TTree object. More... | |
TChain * | GetRTITree () |
Get the RTIInfo TTree object. More... | |
void | SetupBranches (bool isMC=false) |
Set all branch addresses for reading operations, or create all branches for writing operation. More... | |
SkimTreeHandle< SingleTreeChain > | CreateSkimTree (const std::string &filename, const std::string &exclBranches) |
Create a new SkimTree handle object and setup all internal branches. More... | |
int | Add (const std::string &filePath) |
Add a file to the chain. More... | |
void | Clear () |
Clear all the event information. More... | |
int | Fill () |
Fill the event data. More... | |
int | FillRTI () |
Fill the RTI data. More... | |
int | FillFileInfo () |
Fill the FileInfo data. More... | |
unsigned long int | GetEntries () |
Get the total number of events. More... | |
bool | IsMC () |
Check if this file is a MC file. More... | |
void | Print () |
Print all the chains. More... | |
int | Write () |
Write the trees to disk. More... | |
void | SetDirectory (TDirectory *directory) |
Set the TDirectory for the trees. More... | |
void | SetEntryList (TEntryList *entryList, Option_t *option) |
Set an entry list for this tree. More... | |
EventItr | begin () |
EventItr | end () |
Private Attributes | |
unsigned long int | m_iEv = 0 |
AccessMode | m_accessMode = AccessMode::Read |
FileInfo | m_fileInfo |
MCFileInfo | m_fileInfoMC |
RTIInfo | m_rtiInfo |
Event | m_event |
FileInfo * | m_fileInfoPtr = &m_fileInfo |
MCFileInfo * | m_fileInfoMCPtr = &m_fileInfoMC |
needed for SetBranchAddress More... | |
RTIInfo * | m_rtiInfoPtr = &m_rtiInfo |
needed for SetBranchAddress More... | |
TC | m_data {} |
TC | m_rti {} |
TC | m_file {} |
Friends | |
class | NtpSelector |
class | SkimTreeHandle< SingleTreeChain > |
Definition at line 31 of file SingleTreeChain.h.
|
strong |
Simple enum to express whether we are in read or write mode.
Enumerator | |
---|---|
Read | |
Write |
Definition at line 40 of file SingleTreeChain.h.
NAIA::SingleTreeChain::SingleTreeChain | ( | AccessMode | mode = AccessMode::Read | ) |
Construct a new Single Tree Chain object.
mode | The desired access mode |
Definition at line 11 of file SingleTreeChain.cpp.
int NAIA::SingleTreeChain::Add | ( | const std::string & | filePath | ) |
Add a file to the chain.
filePath | The path of the rootfile to be added |
Add
call on the event data chain Definition at line 107 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, m_accessMode, m_data, m_file, m_rti, Read, and Write.
Referenced by main().
|
inline |
Definition at line 252 of file SingleTreeChain.h.
|
inline |
Clear all the event information.
Used only in production, don't call this.
Definition at line 139 of file SingleTreeChain.h.
References NAIA::Event::Clear(), and m_event.
SkimTreeHandle< SingleTreeChain > NAIA::SingleTreeChain::CreateSkimTree | ( | const std::string & | filename, |
const std::string & | exclBranches | ||
) |
Create a new SkimTree handle object and setup all internal branches.
This will create a new tree in a new root file and will create all the corresponding NAIA branches (except the ones that you excluded). During the event loop you can call SkimTreeHandle::Fill to add the current event to the new tree. After looping you can call SkimTreeHandle::Write to write the new tree to disk.
filename | The rootfile where the tree will be saved |
exclBranches | A list of containers to be excluded from processing, separated by ; |
Definition at line 248 of file SingleTreeChain.cpp.
References NAIA::end(), NAIA::evDisablers, NAIA::getLogger(), m_event, m_file, m_fileInfo, m_fileInfoMC, m_rtiInfo, NAIA::TokenizeString(), NAIA::SingleTreeChain::TC::tree, and Write.
Referenced by main().
|
inline |
Definition at line 253 of file SingleTreeChain.h.
References GetEntries().
int NAIA::SingleTreeChain::Fill | ( | ) |
Fill the event data.
Used only in production, don't call this.
Fill
call on the event data chain Definition at line 121 of file SingleTreeChain.cpp.
References m_accessMode, m_data, Read, NAIA::SingleTreeChain::TC::tree, and Write.
int NAIA::SingleTreeChain::FillFileInfo | ( | ) |
Fill the FileInfo data.
Used only in production, don't call this.
Fill
call on the FileInfo data chain Definition at line 143 of file SingleTreeChain.cpp.
References m_accessMode, m_file, Read, NAIA::SingleTreeChain::TC::tree, and Write.
int NAIA::SingleTreeChain::FillRTI | ( | ) |
Fill the RTI data.
Used only in production, don't call this.
Fill
call on the RTI data chain Definition at line 132 of file SingleTreeChain.cpp.
References m_accessMode, m_rti, Read, NAIA::SingleTreeChain::TC::tree, and Write.
unsigned long int NAIA::SingleTreeChain::GetEntries | ( | ) |
Get the total number of events.
Definition at line 154 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, m_accessMode, m_data, Read, NAIA::SingleTreeChain::TC::tree, and Write.
Referenced by end(), NAIA::end(), and main().
Event & NAIA::SingleTreeChain::GetEvent | ( | unsigned long long | iEv | ) |
Get the Event object.
iEv | the event number |
Definition at line 28 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, m_data, m_event, NAIA::Event::SetAllBranchAddress(), and NAIA::Event::SetEventNumber().
Referenced by GetEventWithIndex(), and NAIA::SingleTreeChain::EventItr::operator*().
const FileInfo & NAIA::SingleTreeChain::GetEventFileInfo | ( | ) |
Get the FileInfo object associated with this event.
Make sure this is called after GetEvent
Definition at line 59 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, NAIA::Event::header, m_event, m_file, m_fileInfo, and NAIA::HeaderData::Run.
const RTIInfo & NAIA::SingleTreeChain::GetEventRTIInfo | ( | ) |
Get the RTIInfo object associated with this event.
Make sure this is called after GetEvent
Definition at line 48 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, NAIA::Event::header, m_event, m_rti, m_rtiInfo, and NAIA::HeaderData::UTCTime.
Event & NAIA::SingleTreeChain::GetEventWithIndex | ( | unsigned int | run, |
unsigned int | eventno | ||
) |
Get the Event object using the underlying index.
run | the run number |
eventno | the event number |
Definition at line 44 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, GetEvent(), and m_data.
TChain * NAIA::SingleTreeChain::GetFileInfoTree | ( | ) |
Get the FileInfo TTree object.
If you don't want to loop on events but only care about FileInfo you can get the corresponding chain directly
Definition at line 86 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, NAIA::getLogger(), m_accessMode, m_file, Read, and Write.
TChain * NAIA::SingleTreeChain::GetRTITree | ( | ) |
Get the RTIInfo TTree object.
If you don't want to loop on events but only care about RTIInfo you can get the corresponding chain directly
Definition at line 70 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, NAIA::getLogger(), m_accessMode, m_rti, Read, and Write.
|
inline |
Check if this file is a MC file.
Definition at line 181 of file SingleTreeChain.h.
References NAIA::MCTruthBase::BranchName, NAIA::SingleTreeChain::TC::chain, and m_data.
void NAIA::SingleTreeChain::Print | ( | ) |
Print all the chains.
Definition at line 165 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, m_accessMode, m_data, m_file, m_rti, Read, NAIA::SingleTreeChain::TC::tree, and Write.
void NAIA::SingleTreeChain::SetDirectory | ( | TDirectory * | directory | ) |
Set the TDirectory for the trees.
directory |
Definition at line 101 of file SingleTreeChain.cpp.
References m_data, m_file, m_rti, and NAIA::SingleTreeChain::TC::tree.
void NAIA::SingleTreeChain::SetEntryList | ( | TEntryList * | entryList, |
Option_t * | option | ||
) |
Set an entry list for this tree.
entryList | the TEntryList to be used |
option | see ROOT documentation for available options |
Definition at line 277 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, NAIA::getLogger(), m_accessMode, m_data, Read, and Write.
void NAIA::SingleTreeChain::SetupBranches | ( | bool | isMC = false | ) |
Set all branch addresses for reading operations, or create all branches for writing operation.
Make sure you call this before the event loop
isMC | Used only in write mode to enable MC-only branches. Don't use when in read mode. |
Definition at line 200 of file SingleTreeChain.cpp.
References NAIA::Event::BranchAll(), NAIA::SingleTreeChain::TC::chain, m_accessMode, m_data, m_event, m_file, m_fileInfo, m_fileInfoMC, m_fileInfoMCPtr, m_fileInfoPtr, m_rti, m_rtiInfo, m_rtiInfoPtr, Read, NAIA::Event::SetAllBranchAddress(), NAIA::Event::SetMC(), NAIA::SingleTreeChain::TC::tree, and Write.
Referenced by main().
int NAIA::SingleTreeChain::Write | ( | ) |
Write the trees to disk.
Works correctly if the chain is in write mode (which happens during production). Implemented but not tested for chains in read mode.
Write
call on the event data tree Definition at line 180 of file SingleTreeChain.cpp.
References NAIA::SingleTreeChain::TC::chain, m_accessMode, m_data, m_file, m_rti, Read, NAIA::SingleTreeChain::TC::tree, and Write.
|
friend |
Definition at line 32 of file SingleTreeChain.h.
|
friend |
Definition at line 33 of file SingleTreeChain.h.
|
private |
Definition at line 257 of file SingleTreeChain.h.
Referenced by Add(), Fill(), FillFileInfo(), FillRTI(), GetEntries(), GetFileInfoTree(), GetRTITree(), Print(), SetEntryList(), SetupBranches(), and Write().
|
private |
Definition at line 274 of file SingleTreeChain.h.
Referenced by Add(), Fill(), GetEntries(), GetEvent(), GetEventWithIndex(), IsMC(), Print(), SetDirectory(), SetEntryList(), SetupBranches(), and Write().
|
private |
Definition at line 262 of file SingleTreeChain.h.
Referenced by Clear(), CreateSkimTree(), GetEvent(), GetEventFileInfo(), GetEventRTIInfo(), and SetupBranches().
|
private |
Definition at line 276 of file SingleTreeChain.h.
Referenced by Add(), CreateSkimTree(), FillFileInfo(), GetEventFileInfo(), GetFileInfoTree(), Print(), SetDirectory(), SetupBranches(), and Write().
|
private |
Definition at line 259 of file SingleTreeChain.h.
Referenced by CreateSkimTree(), GetEventFileInfo(), and SetupBranches().
|
private |
Definition at line 260 of file SingleTreeChain.h.
Referenced by CreateSkimTree(), and SetupBranches().
|
private |
needed for SetBranchAddress
Definition at line 265 of file SingleTreeChain.h.
Referenced by SetupBranches().
|
private |
Definition at line 264 of file SingleTreeChain.h.
Referenced by SetupBranches().
|
private |
Definition at line 256 of file SingleTreeChain.h.
|
private |
Definition at line 275 of file SingleTreeChain.h.
Referenced by Add(), FillRTI(), GetEventRTIInfo(), GetRTITree(), Print(), SetDirectory(), SetupBranches(), and Write().
|
private |
Definition at line 261 of file SingleTreeChain.h.
Referenced by CreateSkimTree(), GetEventRTIInfo(), and SetupBranches().
needed for SetBranchAddress
Definition at line 266 of file SingleTreeChain.h.
Referenced by SetupBranches().