00001 #define ProofSimple_cxx
00002
00003 //
00004
00005
00006
00007
00008
00009
00010
00011 #include "ProofSimple.h"
00012 #include <TCanvas.h>
00013 #include <TFrame.h>
00014 #include <TPaveText.h>
00015 #include <TFormula.h>
00016 #include <TF1.h>
00017 #include <TH1F.h>
00018 #include <TMath.h>
00019 #include <TRandom3.h>
00020 #include <TString.h>
00021 #include <TStyle.h>
00022 #include <TSystem.h>
00023 #include <TParameter.h>
00024
00025
00026 ProofSimple::ProofSimple()
00027 {
00028
00029
00030 fNhist = -1;
00031 fHist = 0;
00032 fRandom = 0;
00033 }
00034
00035
00036 ProofSimple::~ProofSimple()
00037 {
00038
00039
00040 if (fRandom) delete fRandom;
00041 }
00042
00043
00044 void ProofSimple::Begin(TTree * )
00045 {
00046
00047
00048
00049
00050 TString option = GetOption();
00051
00052
00053 fNhist = 100;
00054 if (fInput->FindObject("ProofSimple_NHist")) {
00055 TParameter<Long_t> *p =
00056 dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist"));
00057 fNhist = (p) ? (Int_t) p->GetVal() : fNhist;
00058 }
00059 fHist = new TH1F*[fNhist];
00060 }
00061
00062
00063 void ProofSimple::SlaveBegin(TTree * )
00064 {
00065
00066
00067
00068
00069 TString option = GetOption();
00070
00071
00072 fNhist = 100;
00073 if (fInput->FindObject("ProofSimple_NHist")) {
00074 TParameter<Long_t> *p =
00075 dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist"));
00076 fNhist = (p) ? (Int_t) p->GetVal() : fNhist;
00077 }
00078 fHist = new TH1F*[fNhist];
00079
00080
00081 for (Int_t i=0; i < fNhist; i++) {
00082 fHist[i] = new TH1F(Form("h%d",i), Form("h%d",i), 100, -3., 3.);
00083 fHist[i]->SetFillColor(kRed);
00084 fOutput->Add(fHist[i]);
00085 }
00086
00087
00088 fRandom = new TRandom3(0);
00089 }
00090
00091
00092 Bool_t ProofSimple::Process(Long64_t)
00093 {
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 for (Int_t i=0; i < fNhist; i++) {
00113 if (fRandom && fHist[i]) {
00114 Double_t x = fRandom->Gaus(0.,1.);
00115 fHist[i]->Fill(x);
00116 }
00117 }
00118
00119 return kTRUE;
00120 }
00121
00122
00123 void ProofSimple::SlaveTerminate()
00124 {
00125
00126
00127
00128
00129 }
00130
00131
00132 void ProofSimple::Terminate()
00133 {
00134
00135
00136
00137
00138
00139
00140
00141 TCanvas *c1 = new TCanvas("c1","Proof ProofSimple canvas",200,10,700,700);
00142 Int_t nside = (Int_t)TMath::Sqrt((Float_t)fNhist);
00143 nside = (nside*nside < fNhist) ? nside+1 : nside;
00144 c1->Divide(nside,nside,0,0);
00145
00146 for (Int_t i=0; i < fNhist; i++) {
00147 fHist[i] = dynamic_cast<TH1F *>(fOutput->FindObject(Form("h%d",i)));
00148 c1->cd(i+1);
00149 if (fHist[i])
00150 fHist[i]->Draw();
00151 }
00152
00153
00154 c1->cd();
00155 c1->Update();
00156 }