#include "Analysis.h" #include "TH1F.h" #include "TLeaf.h" #include "TList.h" #include "TObject.h" #include "TFile.h" #include "TCanvas.h" #include "TROOT.h" #include "TProof.h" #include #include using namespace std; void Analysis::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). //print the option specified in the Process function. TString option = GetOption(); Info("Begin ", "Starting analysis with process option: %s", option.Data()); } void Analysis::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). //initialize the Tree branch addresses // Instanciate objects Init(tree); //print the option specified in the Process function. TString option = GetOption(); Info("Slave Begin", "Starting core analysis with process option: %s", option.Data()); // fEvtHeader = new MyEvtHeader(); // track = new Track(); // Create the histogram fHisto = new TH1F("histo", "Tracks multiplicity", 101, 0, 100); fHisto->SetDirectory(0); fHisto->GetYaxis()->SetTitle("number of events"); fHisto->GetXaxis()->SetTitle("number of Tracks"); // adding histogram to selector output list fOutput->Add(fHisto); /* // Book all objects defined in current TDirectory TList* obj_list = (TList*) gDirectory->GetList() ; TIter next_object((TList*) obj_list) ; TObject* obj ; cout << "-- Booking objects:" << endl; while ((obj = next_object())) { TString objname = obj->GetName() ; cout << " " << objname << endl ; fOutput->Add(obj) ; } */ } Bool_t Analysis::Process(Long64_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 ProofFirst::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. // // The processing can be stopped by calling Abort(). // // Use fStatus to set the return value of TTree::Process(). // The return value is currently not used. // chain->GetTree()->GetEntry(entry); b_fHeader->GetEntry(entry); trcksNo = fHeader->GetEvtTracks(); Printf("++++++++++ Event tracks = %d ++++++++++\n",trcksNo); fHisto->Fill(trcksNo); return kTRUE; } void Analysis::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. } void Analysis::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. // Create a canvas, with 100 pads TCanvas *c1 = new TCanvas("c1","Proof Event canvas",200,10,700,700); c1->SetBorderMode(0); // c1->SetLogy(); // fHisto = dynamic_cast(fOutput->FindObject(Form("histo"))); if (fHisto) { fHisto->Draw(""); // Final update c1->cd(); c1->Update(); } else { Warning("Terminate", "histogram not found"); } /* TFile *outfile = new TFile("histograms.root", "RECREATE"); TCanvas *c1 = new TCanvas("c1", "Proof ProofFirst canvas",10,10,1280,800); c1->SetBottomMargin(0.15); TPad *p1 = 0; //once defined you have to use it c1->Divide(2,2); p1 = (TPad *)c1->cd(1); // without this will not plot and crashes p1->SetBorderMode(0); fH1->GetXaxis()->SetTitle("E_{#gamma}"); fH1->GetXaxis()->SetTitleOffset(1.4); fH1->Draw(""); p1 = (TPad *)c1->cd(2); // without this will not plot and crashes p1->SetBorderMode(0); fH2->GetXaxis()->SetTitle("#theta^{0}"); fH2->GetXaxis()->SetTitleOffset(1.4); fH2->Draw(""); p1 = (TPad *)c1->cd(3); // without this will not plot and crashes p1->SetBorderMode(0); fH3->GetXaxis()->SetTitle("#phi^{0}"); fH3->GetXaxis()->SetTitleOffset(1.4); fH3->Draw(""); p1 = (TPad *)c1->cd(4); // without this will not plot and crashes p1->SetBorderMode(0); fH4->GetXaxis()->SetTitle("Id"); fH4->GetXaxis()->SetTitleOffset(1.4); fH4->Draw(""); fH1->Write(); fH2->Write(); fH3->Write(); fH4->Write(); */ // Info("Terminate", "processed %lld events", fProcessed); //Info("Terminate", "Terminate analysis with processed events of: %lld",fProcessed); }