NAIA  1.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
Classes | Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
NAIA::NAIAChain Class Reference

#include <NAIAChain.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

 NAIAChain (AccessMode mode=AccessMode::Read)
 Construct a new Single Tree Chain object. More...
 
const FileInfoGetEventFileInfo ()
 Get the FileInfo object associated with this event. More...
 
const MCFileInfoGetEventMCFileInfo ()
 Get the MCFileInfo object associated with this event. More...
 
const RTIInfoGetEventRTIInfo ()
 Get the RTIInfo object associated with this event. More...
 
EventGetEvent (unsigned long long iEv)
 Get the Event object. More...
 
EventGetEventWithIndex (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 create_MC_branches=false)
 Set all branch addresses for reading operations, or create all branches for writing operation. More...
 
SkimTreeHandle< NAIAChainCreateSkimTree (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 () const
 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 ()
 

Static Private Member Functions

static bool CheckVersion (const std::string &filePath)
 

Private Attributes

bool m_isMC = false
 
unsigned long int m_iEv = 0
 
AccessMode m_accessMode = AccessMode::Read
 
FileInfo m_fileInfo
 
MCFileInfo m_fileInfoMC
 
RTIInfo m_rtiInfo
 
Event m_event
 
FileInfom_fileInfoPtr = &m_fileInfo
 
MCFileInfom_fileInfoMCPtr = &m_fileInfoMC
 needed for SetBranchAddress More...
 
RTIInfom_rtiInfoPtr = &m_rtiInfo
 needed for SetBranchAddress More...
 
TC m_data {}
 
TC m_rti {}
 
TC m_file {}
 

Friends

class NtpSelector
 
class SkimTreeHandle< NAIAChain >
 

Detailed Description

Definition at line 31 of file NAIAChain.h.

Member Enumeration Documentation

Simple enum to express whether we are in read or write mode.

Enumerator
Read 
Write 

Definition at line 40 of file NAIAChain.h.

Constructor & Destructor Documentation

NAIA::NAIAChain::NAIAChain ( AccessMode  mode = AccessMode::Read)
explicit

Construct a new Single Tree Chain object.

Parameters
modeThe desired access mode

Definition at line 11 of file NAIAChain.cpp.

Member Function Documentation

int NAIA::NAIAChain::Add ( const std::string &  filePath)

Add a file to the chain.

Parameters
filePathThe path of the rootfile to be added
Returns
The result of the Add call on the event data chain

Definition at line 127 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, CheckVersion(), m_accessMode, m_data, m_file, m_rti, Read, and Write.

Referenced by main().

EventItr NAIA::NAIAChain::begin ( )
inline

Definition at line 261 of file NAIAChain.h.

bool NAIA::NAIAChain::CheckVersion ( const std::string &  filePath)
staticprivate

Definition at line 319 of file NAIAChain.cpp.

References NAIA::getLogger().

Referenced by Add().

void NAIA::NAIAChain::Clear ( )
inline

Clear all the event information.

Used only in production, don't call this.

Definition at line 148 of file NAIAChain.h.

References NAIA::Event::Clear(), and m_event.

SkimTreeHandle< NAIAChain > NAIA::NAIAChain::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.

Parameters
filenameThe rootfile where the tree will be saved
exclBranchesA list of containers to be excluded from processing, separated by ;
Returns
A new SkimTreeHandle

Definition at line 278 of file NAIAChain.cpp.

References NAIA::end(), NAIA::evDisablers, NAIA::getLogger(), m_event, m_isMC, NAIA::TokenizeString(), and Write.

Referenced by main().

EventItr NAIA::NAIAChain::end ( )
inline

Definition at line 262 of file NAIAChain.h.

References GetEntries().

int NAIA::NAIAChain::Fill ( )

Fill the event data.

Used only in production, don't call this.

Returns
The result of the Fill call on the event data chain

Definition at line 145 of file NAIAChain.cpp.

References m_accessMode, m_data, Read, NAIA::NAIAChain::TC::tree, and Write.

int NAIA::NAIAChain::FillFileInfo ( )

Fill the FileInfo data.

Used only in production, don't call this.

Returns
The result of the Fill call on the FileInfo data chain

Definition at line 167 of file NAIAChain.cpp.

References m_accessMode, m_file, Read, NAIA::NAIAChain::TC::tree, and Write.

int NAIA::NAIAChain::FillRTI ( )

Fill the RTI data.

Used only in production, don't call this.

Returns
The result of the Fill call on the RTI data chain

Definition at line 156 of file NAIAChain.cpp.

References m_accessMode, m_rti, Read, NAIA::NAIAChain::TC::tree, and Write.

unsigned long int NAIA::NAIAChain::GetEntries ( )

Get the total number of events.

Returns
the number of events

Definition at line 178 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, m_accessMode, m_data, Read, NAIA::NAIAChain::TC::tree, and Write.

Referenced by end(), NAIA::end(), and main().

Event & NAIA::NAIAChain::GetEvent ( unsigned long long  iEv)

Get the Event object.

Parameters
iEvthe event number
Returns
The corresponding Event

Definition at line 28 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, m_data, m_event, NAIA::Event::SetAllBranchAddress(), and NAIA::Event::SetEventNumber().

Referenced by GetEventWithIndex(), and NAIA::NAIAChain::EventItr::operator*().

const FileInfo & NAIA::NAIAChain::GetEventFileInfo ( )

Get the FileInfo object associated with this event.

Make sure this is called after GetEvent

Returns
The FileInfo object

Definition at line 66 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, NAIA::Event::header, m_event, m_file, m_fileInfo, and NAIA::HeaderData::Run.

const MCFileInfo & NAIA::NAIAChain::GetEventMCFileInfo ( )

Get the MCFileInfo object associated with this event.

Make sure this is called after GetEvent

Returns
The MCFileInfo object

Definition at line 77 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, NAIA::Event::header, IsMC(), m_event, m_file, m_fileInfoMC, and NAIA::HeaderData::Run.

const RTIInfo & NAIA::NAIAChain::GetEventRTIInfo ( )

Get the RTIInfo object associated with this event.

Make sure this is called after GetEvent

Returns
The RTIInfo object

Definition at line 48 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, NAIA::Event::header, IsMC(), m_event, m_rti, m_rtiInfo, and NAIA::HeaderData::UTCTime.

Event & NAIA::NAIAChain::GetEventWithIndex ( unsigned int  run,
unsigned int  eventno 
)

Get the Event object using the underlying index.

Parameters
runthe run number
eventnothe event number
Returns
The corresponding Event

Definition at line 44 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, GetEvent(), and m_data.

TChain * NAIA::NAIAChain::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

Returns
The Tree containing the FileInfo objects

Definition at line 106 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, NAIA::getLogger(), m_accessMode, m_file, Read, and Write.

TChain * NAIA::NAIAChain::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

Returns
The Tree containing the RTIInfo objects

Definition at line 91 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, NAIA::getLogger(), m_accessMode, m_rti, Read, and Write.

bool NAIA::NAIAChain::IsMC ( ) const
inline

Check if this file is a MC file.

Returns
true
false

Definition at line 190 of file NAIAChain.h.

References m_isMC.

Referenced by GetEventMCFileInfo(), and GetEventRTIInfo().

void NAIA::NAIAChain::Print ( )

Print all the chains.

Definition at line 189 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, m_accessMode, m_data, m_file, m_rti, Read, NAIA::NAIAChain::TC::tree, and Write.

void NAIA::NAIAChain::SetDirectory ( TDirectory *  directory)

Set the TDirectory for the trees.

Parameters
directory

Definition at line 121 of file NAIAChain.cpp.

References m_data, m_file, m_rti, and NAIA::NAIAChain::TC::tree.

void NAIA::NAIAChain::SetEntryList ( TEntryList *  entryList,
Option_t *  option 
)

Set an entry list for this tree.

Parameters
entryListthe TEntryList to be used
optionsee ROOT documentation for available options

Definition at line 303 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, NAIA::getLogger(), m_accessMode, m_data, Read, and Write.

void NAIA::NAIAChain::SetupBranches ( bool  create_MC_branches = false)

Set all branch addresses for reading operations, or create all branches for writing operation.

Make sure you call this before the event loop

Parameters
create_MC_branchesUsed only in write mode to enable MC-only branches. Don't use when in read mode.

Definition at line 227 of file NAIAChain.cpp.

References NAIA::Event::BranchAll(), NAIA::NAIAChain::TC::chain, m_accessMode, m_data, m_event, m_file, m_fileInfo, m_fileInfoMC, m_fileInfoMCPtr, m_fileInfoPtr, m_isMC, m_rti, m_rtiInfo, m_rtiInfoPtr, Read, NAIA::Event::SetAllBranchAddress(), NAIA::Event::SetMC(), NAIA::NAIAChain::TC::tree, and Write.

Referenced by main().

int NAIA::NAIAChain::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.

Returns
The result of the Write call on the event data tree

Definition at line 204 of file NAIAChain.cpp.

References NAIA::NAIAChain::TC::chain, m_accessMode, m_data, m_file, m_isMC, m_rti, Read, NAIA::NAIAChain::TC::tree, and Write.

Friends And Related Function Documentation

friend class NtpSelector
friend

Definition at line 32 of file NAIAChain.h.

friend class SkimTreeHandle< NAIAChain >
friend

Definition at line 33 of file NAIAChain.h.

Member Data Documentation

AccessMode NAIA::NAIAChain::m_accessMode = AccessMode::Read
private
TC NAIA::NAIAChain::m_data {}
private
Event NAIA::NAIAChain::m_event
private
TC NAIA::NAIAChain::m_file {}
private
FileInfo NAIA::NAIAChain::m_fileInfo
private

Definition at line 271 of file NAIAChain.h.

Referenced by GetEventFileInfo(), and SetupBranches().

MCFileInfo NAIA::NAIAChain::m_fileInfoMC
private

Definition at line 272 of file NAIAChain.h.

Referenced by GetEventMCFileInfo(), and SetupBranches().

MCFileInfo* NAIA::NAIAChain::m_fileInfoMCPtr = &m_fileInfoMC
private

needed for SetBranchAddress

Definition at line 277 of file NAIAChain.h.

Referenced by SetupBranches().

FileInfo* NAIA::NAIAChain::m_fileInfoPtr = &m_fileInfo
private

Definition at line 276 of file NAIAChain.h.

Referenced by SetupBranches().

unsigned long int NAIA::NAIAChain::m_iEv = 0
private

Definition at line 268 of file NAIAChain.h.

bool NAIA::NAIAChain::m_isMC = false
private

Definition at line 267 of file NAIAChain.h.

Referenced by CreateSkimTree(), IsMC(), SetupBranches(), and Write().

TC NAIA::NAIAChain::m_rti {}
private
RTIInfo NAIA::NAIAChain::m_rtiInfo
private

Definition at line 273 of file NAIAChain.h.

Referenced by GetEventRTIInfo(), and SetupBranches().

RTIInfo* NAIA::NAIAChain::m_rtiInfoPtr = &m_rtiInfo
private

needed for SetBranchAddress

Definition at line 278 of file NAIAChain.h.

Referenced by SetupBranches().


The documentation for this class was generated from the following files: