#define ntupleSelector_cxx // The class definition in ntupleSelector.h has been generated automatically // by the Root utility TTree::MakeSelector. // // This class is derived from the Root class TSelector. // The following members functions are called by the TTree::Process functions. // Begin: called everytime a loop on the tree starts. // a convenient place to create your histograms. // Notify(): This function is called at the first entry of a new Tree // in a chain. // ProcessCut: called at the beginning of each entry to return a flag // true if the entry must be analyzed. // ProcessFill: called in the entry loop for all entries accepted // by Select. // Terminate: called at the end of a loop on a TTree. // a convenient place to draw/fit your histograms. // // To use this file, try the following session on your Tree T // // Root > T.Process("ntupleSelector.C") // Root > T.Process("ntupleSelector.C,"some options"") // Root > T.Process("ntupleSelector.C+") // #include "ntupleSelector.h" #include "TH2.h" #include "TStyle.h" #include "TCanvas.h" void ntupleSelector::Begin(TTree *tree) { // function called before starting the event loop // initialize the tree branches Init(tree); TString option = GetOption(); } Bool_t ntupleSelector::ProcessCut(Int_t entry) { // Selection function // entry is the entry number in the current Tree // Read only the necessary branches to select entries. // return as soon as a bad entry is detected. // to read complete event, call fChain->GetTree()->GetEntry(entry) return kTRUE; } void ntupleSelector::ProcessFill(Int_t entry) { // function called for selected entries only // entry is the entry number in the current Tree // read branches not processed in ProcessCut and fill histograms // to read complete event, call fChain->GetTree()->GetEntry(entry) fChain->GetTree()->GetEntry(entry); printf("j:%i, px:%f, py:%f, pz:%f, random:%f, i:%f\n", entry, px, py, pz, random, i); } void ntupleSelector::Terminate() { // function called at the end of the event loop }