#define Anaproof_cxx // The class definition in Anaproof.h has been generated automatically // by the ROOT utility TTree::MakeSelector(). This class is derived // from the ROOT class TSelector. For more information on the TSelector // framework see $ROOTSYS/README/README.SELECTOR or the ROOT User Manual. // The following methods are defined in this file: // Begin(): called everytime a loop on the tree starts, // a convenient place to create your histograms. // SlaveBegin(): called after Begin(), when on PROOF called only on the // slave servers. // Process(): called for each event, in this function you decide what // to read and fill your histograms. // SlaveTerminate: called at the end of the loop on the tree, when on PROOF // called only on the slave servers. // Terminate(): called at the end of the 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("Anaproof.C") // Root > T->Process("Anaproof.C","some options") // Root > T->Process("Anaproof.C+") // #include "Anaproof.h" #include #include void Anaproof::Begin(TTree *tree) { // The Begin() function is called at the start of the query. // When running with PROOF Begin() is only called on the client. // The tree argument is deprecated (on PROOF 0 is passed). TString option = GetOption(); } void Anaproof::SlaveBegin(TTree *tree) { // The SlaveBegin() function is called after the Begin() function. // When running with PROOF SlaveBegin() is called on each slave server. // The tree argument is deprecated (on PROOF 0 is passed). Init(tree); TString option = GetOption(); } Bool_t Anaproof::Process(Int_t entry) { // The Process() function is called for each entry in the tree (or possibly // keyed object in the case of PROOF) to be processed. The entry argument // specifies which entry in the currently loaded tree is to be processed. // It can be passed to either TTree::GetEntry() or TBranch::GetEntry() // to read either all or the required parts of the data. When processing // keyed objects with PROOF, the object is already loaded and is available // via the fObject pointer. // // This function should contain the "body" of the analysis. It can contain // simple or elaborate selection criteria, run algorithms on the data // of the event and typically fill histograms. // WARNING when a selector is used with a TChain, you must use // the pointer to the current TTree to call GetEntry(entry). // The entry is always the local entry number in the current tree. // Assuming that fChain is the pointer to the TChain being processed, // use fChain->GetTree()->GetEntry(entry). fChain->GetTree()->GetEntry(entry); myhist->Fill(myHit->GetChamberNb()); if(myHit->GetChamberNb() == 0)chambercounter0++; else if(myHit->GetChamberNb() == 1)chambercounter1++; else if(myHit->GetChamberNb() == 2)chambercounter2++; else if(myHit->GetChamberNb() == 3)chambercounter3++; else if(myHit->GetChamberNb() == 4)chambercounter4++; else return; return kTRUE; } void Anaproof::SlaveTerminate() { // The SlaveTerminate() function is called after all entries or objects // have been processed. When running with PROOF SlaveTerminate() is called // on each slave server. counterobj = new TCounter(chambercounter0,chambercounter1,chambercounter2,chambercounter3,chambercounter4); fOutput->Add(counterobj); fOutput->Add(myhist); } void Anaproof::Terminate() { // The Terminate() function is the last function to be called during // a query. It always runs on the client, it can be used to present // the results graphically or save the results to file. TList *outList = (TList*)set->GetOutputList(); TIter *next = new TIter(outList); TObject *myobj = new TObject; cout << "OutList: " << endl; outList->Print(); while(myobj = next()) { TString name = myobj->GetName(); if(name == "TCounter") { counterobj = (TCounter*)myobj; chambercounter0 += counterobj->Getcounter0(); chambercounter1 += counterobj->Getcounter1(); chambercounter2 += counterobj->Getcounter2(); chambercounter3 += counterobj->Getcounter3(); chambercounter4 += counterobj->Getcounter4(); } else if(name == "Chamberhisto") { myhist->Add((TH1F*)myobj); } } cout << "Number of hit's in chamber 0: " << chambercounter0 << endl; cout << "Number of hit's in chamber 1: " << chambercounter1 << endl; cout << "Number of hit's in chamber 2: " << chambercounter2 << endl; cout << "Number of hit's in chamber 3: " << chambercounter3 << endl; cout << "Number of hit's in chamber 4: " << chambercounter4 << endl; myhist->Draw(); }