00001 #define ProofEvent_cxx
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "ProofEvent.h"
00013 #include "Event.h"
00014
00015 #include <TCanvas.h>
00016 #include <TH1F.h>
00017 #include <TRandom3.h>
00018
00019
00020 ProofEvent::ProofEvent()
00021 {
00022
00023
00024 fEvent = 0;
00025 fNtrack = -1;
00026 fHisto = 0;
00027 fRandom = 0;
00028 }
00029
00030
00031 ProofEvent::~ProofEvent()
00032 {
00033
00034
00035 SafeDelete(fRandom);
00036 }
00037
00038
00039 void ProofEvent::Begin(TTree * )
00040 {
00041
00042
00043
00044
00045 TString option = GetOption();
00046 Info("Begin", "starting a simple exercise with process option: %s", option.Data());
00047 }
00048
00049
00050 void ProofEvent::SlaveBegin(TTree * )
00051 {
00052
00053
00054
00055
00056 TString option = GetOption();
00057 Info("SalveBegin", "starting on a slave with process option: %s", option.Data());
00058
00059
00060 fEvent = new Event();
00061
00062
00063 fHisto = new TH1F("histo", "tracks multiplicity", 20, 0, 100);
00064 fHisto->GetYaxis()->SetTitle("number of events");
00065 fHisto->GetXaxis()->SetTitle("number of tracks");
00066
00067
00068 fOutput->Add(fHisto);
00069
00070
00071 fRandom = new TRandom3(0);
00072 }
00073
00074
00075 Bool_t ProofEvent::Process(Long64_t )
00076 {
00077
00078
00079
00080
00081 int i= (int)(100 * (fRandom->Rndm()));
00082 fEvent->Build(i,(1+i), 2);
00083 fNtrack= (fEvent->GetNtrack());
00084 if ((fNtrack >= 0 )&& (fNtrack <= 100 ))
00085 fHisto->Fill(fNtrack, 1);
00086
00087 return kTRUE;
00088 }
00089
00090
00091 void ProofEvent::SlaveTerminate()
00092 {
00093
00094
00095 }
00096
00097
00098 void ProofEvent::Terminate()
00099 {
00100
00101
00102
00103
00104 TCanvas *c1 = new TCanvas("c1","Proof ProofEvent canvas",200,10,700,700);
00105 fHisto = dynamic_cast<TH1F *>(fOutput->FindObject(Form("histo")));
00106 if (fHisto) {
00107 fHisto->Draw("h");
00108
00109
00110 c1->cd();
00111 c1->Update();
00112 } else {
00113 Warning("Terminate", "histogram not found");
00114 }
00115 }