EventTree_NoProc.C

Go to the documentation of this file.
00001 #define EventTree_NoProc_cxx
00002 // The class definition in EventTree_NoProc.h has been generated automatically
00003 // by the ROOT utility TTree::MakeSelector(). This class is derived
00004 // from the ROOT class TSelector. For more information on the TSelector
00005 // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual.
00006 
00007 // The following methods are defined in this file:
00008 //    Begin():        called everytime a loop on the tree starts,
00009 //                    a convenient place to create your histograms.
00010 //    SlaveBegin():   called after Begin(), when on PROOF called only on the
00011 //                    slave servers.
00012 //    Process():      called for each event, in this function you decide what
00013 //                    to read and fill your histograms.
00014 //    SlaveTerminate: called at the end of the loop on the tree, when on PROOF
00015 //                    called only on the slave servers.
00016 //    Terminate():    called at the end of the loop on the tree,
00017 //                    a convenient place to draw/fit your histograms.
00018 //
00019 // To use this file, try the following session on your Tree T:
00020 //
00021 // Root > T->Process("EventTree_NoProc.C")
00022 // Root > T->Process("EventTree_NoProc.C","some options")
00023 // Root > T->Process("EventTree_NoProc.C+")
00024 //
00025 
00026 #include "EventTree_NoProc.h"
00027 #include <TH2.h>
00028 #include <TStyle.h>
00029 #include "TCanvas.h"
00030 
00031 
00032 void EventTree_NoProc::Begin(TTree *)
00033 {
00034    // The Begin() function is called at the start of the query.
00035    // When running with PROOF Begin() is only called on the client.
00036    // The tree argument is deprecated (on PROOF 0 is passed).
00037 
00038    TString option = GetOption();
00039 
00040 }
00041 
00042 void EventTree_NoProc::SlaveBegin(TTree *tree)
00043 {
00044    // The SlaveBegin() function is called after the Begin() function.
00045    // When running with PROOF SlaveBegin() is called on each slave server.
00046    // The tree argument is deprecated (on PROOF 0 is passed).
00047 
00048    Init(tree);
00049 
00050    TString option = GetOption();
00051 
00052    fPtHist = new TH1F("pt_dist","p_{T} Distribution",100,0,5);
00053    fPtHist->SetDirectory(0);
00054    fPtHist->GetXaxis()->SetTitle("p_{T}");
00055    fPtHist->GetYaxis()->SetTitle("dN/p_{T}dp_{T}");
00056 
00057    fOutput->Add(fPtHist);
00058 
00059    fNTracksHist = new TH1I("ntracks_dist","N_{Tracks} per Event Distribution",5,0,5);
00060    fNTracksHist->SetDirectory(0);
00061    fNTracksHist->GetXaxis()->SetTitle("N_{Tracks}");
00062    fNTracksHist->GetYaxis()->SetTitle("N_{Events}");
00063 
00064    fOutput->Add(fNTracksHist);
00065 
00066 }
00067 
00068 Bool_t EventTree_NoProc::Process(Long64_t)
00069 {
00070    // The Process() function is called for each entry in the tree (or possibly
00071    // keyed object in the case of PROOF) to be processed. The entry argument
00072    // specifies which entry in the currently loaded tree is to be processed.
00073    // It can be passed to either TTree::GetEntry() or TBranch::GetEntry()
00074    // to read either all or the required parts of the data. When processing
00075    // keyed objects with PROOF, the object is already loaded and is available
00076    // via the fObject pointer.
00077    //
00078    // This function should contain the "body" of the analysis. It can contain
00079    // simple or elaborate selection criteria, run algorithms on the data
00080    // of the event and typically fill histograms.
00081 
00082    // WARNING when a selector is used with a TChain, you must use
00083    //  the pointer to the current TTree to call GetEntry(entry).
00084    //  The entry is always the local entry number in the current tree.
00085    //  Assuming that fChain is the pointer to the TChain being processed,
00086    //  use fChain->GetTree()->GetEntry(entry).
00087 
00088    return kTRUE;
00089 }
00090 
00091 void EventTree_NoProc::SlaveTerminate()
00092 {
00093    // The SlaveTerminate() function is called after all entries or objects
00094    // have been processed. When running with PROOF SlaveTerminate() is called
00095    // on each slave server.
00096 
00097 }
00098 
00099 void EventTree_NoProc::Terminate()
00100 {
00101    // The Terminate() function is the last function to be called during
00102    // a query. It always runs on the client, it can be used to present
00103    // the results graphically or save the results to file.
00104 
00105    TCanvas* canvas = new TCanvas("can","can",800,600);
00106    canvas->SetBorderMode(0);
00107    //canvas->SetLogy();
00108    TH1F* h = dynamic_cast<TH1F*>(fOutput->FindObject("pt_dist"));
00109    if (h) h->DrawCopy();
00110    else Warning("Terminate", "no pt dist found");
00111 
00112 }

Generated on Tue Jul 5 15:15:07 2011 for ROOT_528-00b_version by  doxygen 1.5.1