00001 void run_selector_tests(TString selector_name, Int_t fps, Int_t niter,
00002 TFile* outputfile, TString name_stem,
00003 const Char_t *basedir, Int_t stepsize, Int_t start);
00004
00005 void Run_Node_Tests(Int_t fps, Int_t niter, const Char_t *basedir,
00006 TFile *outputfile, Int_t stepsize=5, Int_t start=0)
00007 {
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 if (!gProof) {
00023 cout << "PROOF must be started before running this script" << endl;
00024 return;
00025 }
00026
00027 if (fps<1) {
00028 cout << "Must be testing at least 1 file per slave" << endl;
00029 return;
00030 }
00031
00032 if (niter<1) {
00033 cout << "Atleast 1 iteration per step is required" << endl;
00034 return;
00035 }
00036
00037 if (stepsize<1) {
00038 cout << "Must increase subsequent tests by atleast 1 slave" << endl;
00039 return;
00040 }
00041
00042 if (start<0) {
00043 cout << "starting number of nodes must be atleast 1" << endl
00044 << " (with 0 making start = stepsize)" << endl;
00045 return;
00046 }
00047
00048 if (start==0) start = stepsize;
00049
00050 #if 0
00051
00052 if (!TString(gSystem->GetLibraries()).Contains("Event")) {
00053 if(gSystem->Load("$ROOTSYS/test/libEvent.so")) {
00054 cout << "Could not load libEvent.so" << endl;
00055 return;
00056 }
00057 }
00058
00059
00060 if (!TString(gSystem->GetIncludePath()).Contains("-I$ROOTSYS/test"))
00061 gSystem->AddIncludePath("-I$ROOTSYS/test");
00062 #endif
00063
00064 if (gProof->UploadPackage("event")) {
00065 cout << "Could not upload Event par file to slaves" << endl;
00066 return;
00067 }
00068
00069 if (gProof->EnablePackage("event")) {
00070 cout << "Could not enable Event library on PROOF slaves" << endl;
00071 return;
00072 }
00073
00074 if (gROOT->LoadMacro("make_tdset.C")) {
00075 cout << "Could not load make_tdset macro" << endl;
00076 return;
00077 }
00078
00079 #if 0
00080
00081 gProof->AddInput(new TNamed("PROOF_NewPacketizer",""));
00082 #else
00083 gProof->SetParameter("PROOF_ForceLocal", 1);
00084
00085 #endif
00086
00087
00088 run_selector_tests("EventTree_Proc.C++", fps, niter, outputfile, "_Proc", basedir, stepsize, start);
00089 run_selector_tests("EventTree_ProcOpt.C++", fps, niter, outputfile, "_ProcOpt", basedir, stepsize, start);
00090 run_selector_tests("EventTree_NoProc.C++", fps, niter, outputfile, "_NoProc", basedir, stepsize, start);
00091
00092 }
00093
00094 void run_selector_tests(TString selector_file, Int_t fps, Int_t niter,
00095 TFile* outputfile, TString name_stem,
00096 const Char_t *basedir, Int_t stepsize, Int_t start)
00097 {
00098
00099 TString selector_name(selector_file);
00100 selector_name.Remove(selector_file.Last('.'));
00101
00102 gProof->SetParallel(9999);
00103 Int_t nslaves = gProof->GetParallel();
00104 if (start > nslaves) {
00105 cout << "starting number of nodes must be atleast 1" << endl
00106 << " (with 0 making start = stepsize)" << endl;
00107 return;
00108 }
00109
00110
00111 gEnv->SetValue("Proof.StatsHist",0);
00112 gEnv->SetValue("Proof.StatsTrace",0);
00113 gEnv->SetValue("Proof.SlaveStatsTrace",0);
00114 TDSet* dset = make_tdset(basedir, fps);
00115 cout << "Running on all nodes first" << endl;
00116 gProof->Load(selector_file);
00117 dset->Process(selector_name);
00118
00119 cout << "done" << endl;
00120
00121
00122 gEnv->SetValue("Proof.StatsHist",0);
00123 gEnv->SetValue("Proof.StatsTrace",1);
00124 gEnv->SetValue("Proof.SlaveStatsTrace",0);
00125
00126 TString perfstats_name = "PROOF_PerfStats";
00127
00128
00129 TString time_tree_name = perfstats_name;
00130 time_tree_name+=name_stem;
00131 time_tree_name+="_timing_tree";
00132 TTree timing_tree(time_tree_name,"Timing Tree");
00133 Int_t ns_holder;
00134 Int_t run_holder;
00135 Float_t time_holder;
00136 TBranch* br = timing_tree.Branch("tests",&ns_holder,"nslaves/I:run/I:time/F");
00137 if (outputfile && !outputfile->IsZombie())
00138 timing_tree.SetDirectory(outputfile);
00139 br->GetLeaf("nslaves")->SetAddress(&ns_holder);
00140 br->GetLeaf("run")->SetAddress(&run_holder);
00141 br->GetLeaf("time")->SetAddress(&time_holder);
00142
00143 Bool_t done = kFALSE;
00144 for (Int_t nactive=start; !done; nactive+=stepsize) {
00145
00146 if (nactive >= nslaves) {
00147 done=kTRUE;
00148 nactive=nslaves;
00149 }
00150
00151 gProof->SetParallel(nactive);
00152 ns_holder = nactive;
00153 for (Int_t j=0; j<niter; j++) {
00154 run_holder=j;
00155
00156 TTime starttime = gSystem->Now();
00157 dset->Process(selector_name);
00158 TTime endtime = gSystem->Now();
00159 time_holder = Long_t(endtime-starttime)/Float_t(1000);
00160 cout << "Processing time was " << time_holder << " seconds" << endl;
00161
00162 if (outputfile && !outputfile->IsZombie()) {
00163 TList* l = dset->GetOutputList();
00164
00165
00166 TTree* t = dynamic_cast<TTree*>(l->FindObject(perfstats_name.Data()));
00167 if (t) {
00168 TDirectory* trdir = t->GetDirectory();
00169 TDirectory* dirsav = gDirectory;
00170 outputfile->cd();
00171 t->SetDirectory(outputfile);
00172 TString origname = t->GetName();
00173 TString newname = perfstats_name;
00174 newname+=name_stem;
00175 newname+="_";
00176 newname+=nactive;
00177 newname+="slaves_run";
00178 newname+=j;
00179 t->SetName(newname);
00180 t->Write();
00181 t->SetName(origname);
00182 t->SetDirectory(trdir);
00183 dirsav->cd();
00184 } else {
00185 cout << perfstats_name.Data() << " tree not found" << endl << flush;
00186 }
00187
00188
00189 TString ptdist_name = "pt_dist";
00190 TH1* h = dynamic_cast<TH1*>(l->FindObject(ptdist_name.Data()));
00191 if (h) {
00192 TDirectory* hdir = h->GetDirectory();
00193 TDirectory* dirsav = gDirectory;
00194 outputfile->cd();
00195 h->SetDirectory(outputfile);
00196 TString origname = h->GetName();
00197 TString newname = ptdist_name;
00198 newname+=name_stem;
00199 newname+="_";
00200 newname+=nactive;
00201 newname+="slaves_run";
00202 newname+=j;
00203 h->SetName(newname);
00204 h->Write();
00205 h->SetName(origname);
00206 h->SetDirectory(hdir);
00207 dirsav->cd();
00208 } else {
00209 cout << ptdist_name.Data() << " histogram not found" << endl << flush;
00210 }
00211
00212 TString tracksdist_name = "ntracks_dist";
00213 TH1* h2 = dynamic_cast<TH1*>(l->FindObject(tracksdist_name.Data()));
00214 if (h2) {
00215 TDirectory* hdir = h2->GetDirectory();
00216 TDirectory* dirsav = gDirectory;
00217 outputfile->cd();
00218 h2->SetDirectory(outputfile);
00219 TString origname = h2->GetName();
00220 TString newname = tracksdist_name;
00221 newname+=name_stem;
00222 newname+="_";
00223 newname+=nactive;
00224 newname+="slaves_run";
00225 newname+=j;
00226 h2->SetName(newname);
00227 h2->Write();
00228 h2->SetName(origname);
00229 h2->SetDirectory(hdir);
00230 dirsav->cd();
00231 } else {
00232 cout << tracksdist_name.Data() << " histogram not found" << endl << flush;
00233 }
00234 }
00235
00236
00237 timing_tree.Fill();
00238 }
00239 }
00240
00241 delete dset;
00242
00243 if (outputfile && !outputfile->IsZombie()) {
00244 TDirectory* dirsav=gDirectory;
00245 outputfile->cd();
00246 timing_tree.Write();
00247 timing_tree.SetDirectory(0);
00248 dirsav->cd();
00249 }
00250 }
00251