void ProofNtuple::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. // Do nothing is not requested (dataset creation run) if (!fPlotNtuple) return; // Get the ntuple form the file if ((fProofFile = dynamic_cast<TProofOutputFile*>(fOutput->FindObject("SimpleNtuple.root")))) { TString outputFile(fProofFile->GetOutputFileName()); TString outputName(fProofFile->GetName()); outputName += ".root"; Printf("outputFile: %s", outputFile.Data()); // Read the ntuple from the file fFile = TFile::Open(outputFile); if (fFile) { Printf("Managed to open file: %s", outputFile.Data()); fNtp = (TNtuple *) fFile->Get("ntuple"); } else { Error("Terminate", "could not open file: %s", outputFile.Data()); } if (!fFile) return; } else { Error("Terminate", "TProofOutputFile not found"); return; } // Plot ntuples if (fNtp) PlotNtuple(fNtp, "proof ntuple"); }
//_____________________________________________________________________________ void ProofSimple::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 = (TCanvas *) gDirectory->FindObject("c1"); if (c1) { gDirectory->Remove(c1); delete c1; } c1 = new TCanvas("c1","Proof ProofSimple canvas",200,10,700,700); Int_t nside = (Int_t)TMath::Sqrt((Float_t)fNhist); nside = (nside*nside < fNhist) ? nside+1 : nside; c1->Divide(nside,nside,0,0); Bool_t tryfc = kFALSE; TH1F *h = 0; for (Int_t i=0; i < fNhist; i++) { if (!(h = dynamic_cast<TH1F *>(TProof::GetOutput(Form("h%d",i), fOutput)))) { // Not found: try TFileCollection tryfc = kTRUE; break; } c1->cd(i+1); h->DrawCopy(); } // If the histograms are not found they may be in files: is there a file collection? if (tryfc && GetHistosFromFC(c1) != 0) { Warning("Terminate", "histograms not found"); } else { // Final update c1->cd(); c1->Update(); } // Analyse hlab, if there if (fHLab && !gROOT->IsBatch()) { // Printout Int_t nb = fHLab->GetNbinsX(); if (nb > 0) { Double_t entb = fHLab->GetEntries() / nb; if (entb) { for (Int_t i = 0; i < nb; i++) { TString lab = TString::Format("hl%d", i); Int_t ib = fHLab->GetXaxis()->FindBin(lab); Info("Terminate"," %s [%d]:\t%f", lab.Data(), ib, fHLab->GetBinContent(ib)/entb); } } else Warning("Terminate", "no entries in the hlab histogram!"); } } // Process the ntuple, if required if (fHasNtuple != 1 || !fPlotNtuple) return; if (!(fNtp = dynamic_cast<TNtuple *>(TProof::GetOutput("ntuple", fOutput)))) { // Get the ntuple from the file if ((fProofFile = dynamic_cast<TProofOutputFile*>(fOutput->FindObject("SimpleNtuple.root")))) { TString outputFile(fProofFile->GetOutputFileName()); TString outputName(fProofFile->GetName()); outputName += ".root"; Printf("outputFile: %s", outputFile.Data()); // Read the ntuple from the file fFile = TFile::Open(outputFile); if (fFile) { Printf("Managed to open file: %s", outputFile.Data()); fNtp = (TNtuple *) fFile->Get("ntuple"); } else { Error("Terminate", "could not open file: %s", outputFile.Data()); } if (!fFile) return; } else { Error("Terminate", "TProofOutputFile not found"); return; } } // Plot ntuples if (fNtp) PlotNtuple(fNtp, "proof ntuple"); }