#define histAnalysis_cxx // The class definition in histAnalysis.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. // Process(): called for each event. In this function you decide what // to read and you fill your histograms. // Terminate(): called at the end of a loop on the tree, // a convenient place to draw/fit your histograms. // // To use this file, try the following session on your Tree T // // Root > T->Process("histAnalysis.C") // Root > T->Process("histAnalysis.C","some options") // Root > T->Process("histAnalysis.C+") // #include "histAnalysis.h" #include "TH2.h" #include "TStyle.h" #include #include "dec.C" void histAnalysis::Begin(TTree *tree) { // Function called before starting the event loop. // When running with PROOF Begin() is only called in the client. // Initialize the tree branches. TString option = GetOption(); //..Output file for histograms fHistFile = new TFile("histAnalysis.root","RECREATE"); //..Define histograms (declared in dec.C) hnJpsi = new TH1F("hnJpsi", "Number of Jpsi", 20, -0.5, 19.5); hmassJpsi = new TH1F("hmassJpsi", "Raw Jpsi Mass", 60, 2.9, 3.3); } void histAnalysis::SlaveBegin(TTree *tree) { // Function called before starting the event loop. // When running with PROOF SlaveBegin() is called in each slave // Initialize the tree branches. Init(tree); TString option = GetOption(); } Bool_t histAnalysis::Process(Int_t entry) { // Processing function. This function is called // to process an event. It is the user's responsability to read // the corresponding entry in memory (may be just a partial read). // Once the entry is in memory one can apply a selection and if the // event is selected histograms can be filled. //..Just read the full event fChain->GetTree()->GetEntry(entry); //..Fill some simple histograms hnJpsi->Fill(njpsi); for(Int_t i=0; iFill(Jpsiuncmass[i]); } return kTRUE; } void histAnalysis::SlaveTerminate() { // Function called at the end of the event loop in each PROOF slave. } void histAnalysis::Terminate() { // Function called at the end of the event loop. // When running with PROOF Terminate() is only called in the client. //..Write out histograms to file fHistFile->cd(); fHistFile->Write(); fHistFile->Close(); cout << "Output file written" << endl; }