RAPIDO
Repeatable Analysis Programming for Interpretability, Durability, and Organization
Loading...
Searching...
No Matches
Looper Class Reference

#include <looper.h>

Public Member Functions

 Looper (TChain *new_tchain)
 
 Looper (HEPCLI &cli)
 
virtual ~Looper ()
 
void run (std::function< void(TTree *ttree)> init, std::function< void(int entry)> eval)
 
void stop ()
 

Public Attributes

TChain * tchain
 
TString ttree_name
 
unsigned int current_entry
 
unsigned int n_events_processed
 
unsigned int n_events_total
 

Protected Attributes

bool keep_alive
 

Detailed Description

Object to handle looping over ROOT files

Constructor & Destructor Documentation

◆ Looper() [1/2]

Looper::Looper ( TChain * new_tchain)

Looper object constructor

Parameters
new_tchainpointer to ROOT TChain of files to loop over
Returns
none

◆ Looper() [2/2]

Looper::Looper ( HEPCLI & cli)

Looper object constructor

Parameters
cliHEPCLI object
Returns
none

◆ ~Looper()

virtual Looper::~Looper ( )
virtual

Looper object destructor

Returns
none

Member Function Documentation

◆ run()

void Looper::run ( std::function< void(TTree *ttree)> init,
std::function< void(int entry)> eval )

Run looper with file- and event-processing logic captured in void lambda functions.

The following example uses a class named "Selector" generated by ROOT::MakeSelector; this class requires certain file- and event-processing initialization steps:

int main()
{
TChain* tchain = new TChain("Events");
tchain->Add("/path/to/file.root");
selector = Selector(); // generated by ROOT::MakeSelector
looper = Looper(tchain, "Events");
looper.run(
[&](TTree* ttree) { selector.Init(ttree); },
[&](int entry)
{
selector.GetEntry(entry);
selector.Process(entry);
// -> insert your favorite cutflow here <--
}
);
}
Looper(TChain *new_tchain)
TChain * tchain
Definition looper.h:23
Parameters
initfile-level initialization steps captured in a void lambda function
evalevent-level logic captured in a void lambda function
Returns
none

◆ stop()

void Looper::stop ( )

Stop event loop

Returns
none

Member Data Documentation

◆ current_entry

unsigned int Looper::current_entry

Current entry in TTree (i.e. current index of event loop)

◆ keep_alive

bool Looper::keep_alive
protected

Flag for continuing event loop

◆ n_events_processed

unsigned int Looper::n_events_processed

Number of events that have been processed

◆ n_events_total

unsigned int Looper::n_events_total

Number of events in the TChain

◆ tchain

TChain* Looper::tchain

ROOT TChain of files to loop over

◆ ttree_name

TString Looper::ttree_name

ROOT TTree name


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