TProofProgressDialog.cxx

Go to the documentation of this file.
00001 // @(#)root/sessionviewer:$Id: TProofProgressDialog.cxx 36176 2010-10-08 06:47:21Z brun $
00002 // Author: Fons Rademakers   21/03/03
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2003, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 //////////////////////////////////////////////////////////////////////////
00013 //                                                                      //
00014 // TProofProgressDialog                                                 //
00015 //                                                                      //
00016 // This class provides a query progress bar.                            //
00017 //                                                                      //
00018 //////////////////////////////////////////////////////////////////////////
00019 
00020 #include "TProofProgressDialog.h"
00021 #include "TProofProgressLog.h"
00022 #include "TProofProgressMemoryPlot.h"
00023 #include "TEnv.h"
00024 #include "TError.h"
00025 #include "TGLabel.h"
00026 #include "TGButton.h"
00027 #include "TGTextBuffer.h"
00028 #include "TGTextEntry.h"
00029 #include "TGProgressBar.h"
00030 #include "TGSpeedo.h"
00031 #include "TProof.h"
00032 #include "TSlave.h"
00033 #include "TSystem.h"
00034 #include "TTimer.h"
00035 #include "TGraph.h"
00036 #include "TNtuple.h"
00037 #include "TCanvas.h"
00038 #include "TColor.h"
00039 #include "TLine.h"
00040 #include "TAxis.h"
00041 #include "TPaveText.h"
00042 #include "TMath.h"
00043 #include "TH1F.h"
00044 #include "THLimitsFinder.h"
00045 
00046 #ifdef PPD_SRV_NEWER
00047 #undef PPD_SRV_NEWER
00048 #endif
00049 #define PPD_SRV_NEWER(v) (fProof && fProof->GetRemoteProtocol() > v)
00050 #ifdef PPD_SRV_NEWER_REV
00051 #undef PPD_SRV_NEWER_REV
00052 #endif
00053 #define PPD_SRV_NEWER_REV(r) (fSVNRev > r)
00054 
00055 Bool_t TProofProgressDialog::fgKeepDefault = kTRUE;
00056 Bool_t TProofProgressDialog::fgLogQueryDefault = kFALSE;
00057 TString TProofProgressDialog::fgTextQueryDefault = "last";
00058 
00059 static const Int_t gSVNMemPlot = 25090;
00060 
00061 ClassImp(TProofProgressDialog)
00062 
00063 //______________________________________________________________________________
00064 TProofProgressDialog::TProofProgressDialog(TProof *proof, const char *selector,
00065                                            Int_t files, Long64_t first,
00066                                            Long64_t entries) : fDialog(0),
00067    fBar(0), fClose(0), fStop(0), fAbort(0), fAsyn(0), fLog(0), fRatePlot(0),
00068    fMemPlot(0), fKeepToggle(0), fLogQueryToggle(0), fTextQuery(0), fEntry(0),
00069    fTitleLab(0), fFilesEvents(0), fTimeLab(0), fProcessed(0), fEstim(0), 
00070    fTotal(0), fRate(0), fInit(0), fSelector(0), fSpeedo(0), fSmoothSpeedo(0)
00071 {
00072    // Create PROOF processing progress dialog.
00073 
00074    fProof         = proof;
00075    fFiles         = files;
00076    fFirst         = first;
00077    fEntries       = entries;
00078    fPrevProcessed = 0;
00079    fPrevTotal     = 0;
00080    fLogWindow     = 0;
00081    fMemWindow     = 0;
00082    fStatus        = kRunning;
00083    fKeep          = fgKeepDefault;
00084    fLogQuery      = fgLogQueryDefault;
00085    fRatePoints    = 0;
00086    fRateGraph     = 0;
00087    fMBRtGraph     = 0;
00088    fActWGraph     = 0;
00089    fTotSGraph     = 0;
00090    fEffSGraph     = 0;
00091    fProcTime      = 0.;
00092    fInitTime      = 0.;
00093    fAvgRate       = 0.;
00094    fAvgMBRate     = 0.;
00095    fSVNRev        = -1;
00096    fRightInfo     = 0;
00097    fSpeedoEnabled = kFALSE;
00098    fSpeedo        = 0;
00099    fUpdtSpeedo    = 0;
00100    fSmoothSpeedo  = 0;
00101 
00102    // Make sure we are attached to a good instance
00103    if (!proof || !(proof->IsValid())) {
00104       Error("TProofProgressDialog", "proof instance is invalid (%p, %s): protocol error?",
00105                                     proof, (proof && !(proof->IsValid())) ? "invalid" : "undef");
00106       return;
00107    }
00108 
00109    // Have to save this information here, in case gProof is dead when
00110    // the logs are requested
00111    fSessionUrl = (proof && proof->GetManager()) ? proof->GetManager()->GetUrl() : "";
00112 
00113    // SVN version run by the master
00114    TSlave *mst = (TSlave *) proof->GetListOfActiveSlaves()->First();
00115    if (mst) {
00116       TString vrs = mst->GetROOTVersion();
00117       Ssiz_t ib = vrs.Index("|"), from = ib + 2;
00118       if (ib != kNPOS) {
00119          TString svnr;
00120          // Strip of also the 'r' in front of the number
00121          vrs.Tokenize(svnr, from, "|");
00122          if (svnr.IsDigit()) {
00123             if (gDebug)
00124                Info("TProofProgressDialog", "svn revision run by the master: %s", svnr.Data());
00125             fSVNRev = svnr.Atoi();
00126          } else {
00127             Info("TProofProgressDialog", "could not find svn revision run by the master");
00128          }
00129       } else if (gDebug) {
00130          Info("TProofProgressDialog", "non-standard master version string:'%s'", vrs.Data());
00131       }
00132    } else {
00133       Warning("TProofProgressDialog", "list of active workers is empty!");
00134    }
00135 
00136    if (PPD_SRV_NEWER(25)) {
00137       fRatePoints = new TNtuple("RateNtuple","Rate progress info","tm:evr:mbr:act:tos:efs");
00138    } else if (PPD_SRV_NEWER(11)) {
00139       fRatePoints = new TNtuple("RateNtuple","Rate progress info","tm:evr:mbr");
00140    }
00141 
00142    fDialog = new TGTransientFrame(0, 0, 10, 10);
00143    fDialog->Connect("CloseWindow()", "TProofProgressDialog", this, "DoClose()");
00144    fDialog->DontCallClose();
00145    fDialog->SetCleanup(kDeepCleanup);
00146 
00147 //=======================================================================================
00148 
00149    TGHorizontalFrame *hf4 = new TGHorizontalFrame(fDialog, 100, 100);
00150 
00151    TGVerticalFrame *vf4 = new TGVerticalFrame(hf4, 100, 100);
00152 
00153    // Title label
00154    TString buf;
00155    buf.Form("Executing on PROOF cluster \"%s\" with %d parallel workers:",
00156             fProof ? fProof->GetMaster() : "<dummy>",
00157             fProof ? fProof->GetParallel() : 0);
00158    fTitleLab = new TGLabel(vf4, buf);
00159    fTitleLab->SetTextJustify(kTextTop | kTextLeft);
00160    vf4->AddFrame(fTitleLab, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 5, 0));
00161    buf.Form("Selector: %s", selector);
00162    fSelector = new TGLabel(vf4, buf);
00163    fSelector->SetTextJustify(kTextTop | kTextLeft);
00164    vf4->AddFrame(fSelector, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 5, 0));
00165    buf.Form("%d files, number of events %lld, starting event %lld",
00166             fFiles, fEntries, fFirst);
00167    fFilesEvents = new TGLabel(vf4, buf);
00168    fFilesEvents->SetTextJustify(kTextTop | kTextLeft);
00169    vf4->AddFrame(fFilesEvents, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 5, 0));
00170 
00171    // Progress bar
00172    fBar = new TGHProgressBar(vf4, TGProgressBar::kFancy, 200);
00173    fBar->SetBarColor("green");
00174    fBar->UsePercent();
00175    fBar->ShowPos(kTRUE);
00176    vf4->AddFrame(fBar, new TGLayoutHints(kLHintsTop | kLHintsLeft |
00177                      kLHintsExpandX, 10, 10, 5, 5));
00178 
00179    // Status labels
00180    if (PPD_SRV_NEWER(11)) {
00181       TGHorizontalFrame *hf0 = new TGHorizontalFrame(vf4, 0, 0);
00182       TGCompositeFrame *cf0 = new TGCompositeFrame(hf0, 110, 0, kFixedWidth);
00183       cf0->AddFrame(new TGLabel(cf0, "Initialization time:"));
00184       hf0->AddFrame(cf0);
00185       fInit = new TGLabel(hf0, "- secs");
00186       fInit->SetTextJustify(kTextTop | kTextLeft);
00187       hf0->AddFrame(fInit, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 0, 0));
00188       vf4->AddFrame(hf0, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 5, 0));
00189    }
00190 
00191    TGHorizontalFrame *hf1 = new TGHorizontalFrame(vf4, 0, 0);
00192    TGCompositeFrame *cf1 = new TGCompositeFrame(hf1, 110, 0, kFixedWidth);
00193    fTimeLab = new TGLabel(cf1, "Estimated time left:");
00194    fTimeLab->SetTextJustify(kTextTop | kTextLeft);
00195    cf1->AddFrame(fTimeLab, new TGLayoutHints(kLHintsLeft));
00196    hf1->AddFrame(cf1);
00197    fEstim = new TGLabel(hf1, "- sec");
00198    fEstim->SetTextJustify(kTextTop | kTextLeft);
00199    hf1->AddFrame(fEstim, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 0, 0));
00200    vf4->AddFrame(hf1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 5, 0));
00201 
00202    hf1 = new TGHorizontalFrame(vf4, 0, 0);
00203    cf1 = new TGCompositeFrame(hf1, 110, 0, kFixedWidth);
00204    fProcessed = new TGLabel(cf1, "Processing status:");
00205    fProcessed->SetTextJustify(kTextTop | kTextLeft);
00206    cf1->AddFrame(fProcessed, new TGLayoutHints(kLHintsLeft));
00207    hf1->AddFrame(cf1);
00208    fTotal= new TGLabel(hf1, "- / - events");
00209    fTotal->SetTextJustify(kTextTop | kTextLeft);
00210    hf1->AddFrame(fTotal, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 0, 0));
00211 
00212    vf4->AddFrame(hf1, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 5, 0));
00213 
00214    TGHorizontalFrame *hf2 = new TGHorizontalFrame(vf4, 0, 0);
00215    TGCompositeFrame *cf2 = new TGCompositeFrame(hf2, 110, 0, kFixedWidth);
00216    cf2->AddFrame(new TGLabel(cf2, "Processing rate:"));
00217    hf2->AddFrame(cf2);
00218    fRate = new TGLabel(hf2, "- events/sec \n");
00219    fRate->SetTextJustify(kTextTop | kTextLeft);
00220    hf2->AddFrame(fRate, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 0, 0));
00221    vf4->AddFrame(hf2, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 10, 10, 5, 0));
00222 
00223    // Keep toggle button
00224    fKeepToggle = new TGCheckButton(vf4,
00225                     new TGHotString("Close dialog when processing is complete"));
00226    if (!fKeep) fKeepToggle->SetState(kButtonDown);
00227    fKeepToggle->Connect("Toggled(Bool_t)",
00228                         "TProofProgressDialog", this, "DoKeep(Bool_t)");
00229    vf4->AddFrame(fKeepToggle, new TGLayoutHints(kLHintsBottom, 10, 10, 10, 5));
00230 
00231    hf4->AddFrame(vf4, new TGLayoutHints(kLHintsExpandY | kLHintsExpandX));
00232 
00233    TGVerticalFrame *vf51 = new TGVerticalFrame(hf4, 20, 20);
00234 
00235    Int_t enablespeedo = gEnv->GetValue("Proof.EnableSpeedo", 0);
00236    if (enablespeedo) fSpeedoEnabled = kTRUE;
00237 
00238    fSpeedo = new TGSpeedo(vf51, 0.0, 1.0, "", "  Ev/s");
00239    if (fSpeedoEnabled) {
00240       fSpeedo->Connect("OdoClicked()", "TProofProgressDialog", this, "ToggleOdometerInfos()");
00241       fSpeedo->Connect("LedClicked()", "TProofProgressDialog", this, "ToggleThreshold()");
00242    }
00243    vf51->AddFrame(fSpeedo);
00244    fSpeedo->SetDisplayText("Init Time", "[ms]");
00245    fSpeedo->EnablePeakMark();
00246    fSpeedo->SetThresholds(0.0, 25.0, 50.0);
00247    fSpeedo->SetThresholdColors(TGSpeedo::kRed, TGSpeedo::kOrange, TGSpeedo::kGreen);
00248    fSpeedo->SetOdoValue(0);
00249    fSpeedo->EnableMeanMark();
00250 
00251    fSmoothSpeedo = new TGCheckButton(vf51, new TGHotString("Smooth speedometer update"));
00252    if (fSpeedoEnabled) {
00253       fSmoothSpeedo->SetState(kButtonDown);
00254       fSmoothSpeedo->SetToolTipText("Control smoothness in refreshing the speedo");
00255    } else {
00256       fSmoothSpeedo->SetToolTipText("Speedo refreshing is disabled");
00257       fSmoothSpeedo->SetState(kButtonDisabled);
00258    }
00259    vf51->AddFrame(fSmoothSpeedo, new TGLayoutHints(kLHintsBottom | kLHintsCenterX, 0, 0, 5, 0));
00260 
00261    hf4->AddFrame(vf51, new TGLayoutHints(kLHintsBottom, 5, 5, 5, 5));
00262 
00263    fDialog->AddFrame(hf4, new TGLayoutHints(kLHintsTop | kLHintsExpandX, 5, 5, 5, 5));
00264 
00265 //==========================================================================================
00266 
00267    // Stop, cancel and close buttons
00268    TGHorizontalFrame *hf3 = new TGHorizontalFrame(fDialog, 60, 20);
00269 
00270    UInt_t  nb1 = 0, width1 = 0, height1 = 0;
00271 
00272    fAsyn = new TGTextButton(hf3, "&Run in background");
00273    if (fProof->GetRemoteProtocol() >= 22 && fProof->IsSync()) {
00274       fAsyn->SetToolTipText("Continue running in the background (asynchronous mode), releasing the ROOT prompt");
00275    } else {
00276       fAsyn->SetToolTipText("Switch to asynchronous mode disabled: functionality not supported by the server");
00277       fAsyn->SetState(kButtonDisabled);
00278    }
00279    fAsyn->Connect("Clicked()", "TProofProgressDialog", this, "DoAsyn()");
00280    hf3->AddFrame(fAsyn, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 7, 7, 0, 0));
00281    height1 = TMath::Max(height1, fAsyn->GetDefaultHeight());
00282    width1  = TMath::Max(width1, fAsyn->GetDefaultWidth()); ++nb1;
00283 
00284    fStop = new TGTextButton(hf3, "&Stop");
00285    fStop->SetToolTipText("Stop processing, Terminate() will be executed");
00286    fStop->Connect("Clicked()", "TProofProgressDialog", this, "DoStop()");
00287    hf3->AddFrame(fStop, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 7, 7, 0, 0));
00288    height1 = TMath::Max(height1, fStop->GetDefaultHeight());
00289    width1  = TMath::Max(width1, fStop->GetDefaultWidth()); ++nb1;
00290 
00291    fAbort = new TGTextButton(hf3, "&Cancel");
00292    fAbort->SetToolTipText("Cancel processing, Terminate() will NOT be executed");
00293    fAbort->Connect("Clicked()", "TProofProgressDialog", this, "DoAbort()");
00294    hf3->AddFrame(fAbort, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 7, 7, 0, 0));
00295    height1 = TMath::Max(height1, fAbort->GetDefaultHeight());
00296    width1  = TMath::Max(width1, fAbort->GetDefaultWidth()); ++nb1;
00297 
00298    fClose = new TGTextButton(hf3, "&Close");
00299    fClose->SetToolTipText("Close this dialog");
00300    fClose->SetState(kButtonDisabled);
00301    fClose->Connect("Clicked()", "TProofProgressDialog", this, "DoClose()");
00302    hf3->AddFrame(fClose, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 7, 7, 0, 0));
00303    height1 = TMath::Max(height1, fClose->GetDefaultHeight());
00304    width1  = TMath::Max(width1, fClose->GetDefaultWidth()); ++nb1;
00305 
00306    fDialog->AddFrame(hf3, new TGLayoutHints(kLHintsBottom | kLHintsCenterX | kLHintsExpandX, 5, 5, 5, 5));
00307 
00308    TGHorizontalFrame *hf5 = new TGHorizontalFrame(fDialog, 60, 20);
00309 
00310    fLog = new TGTextButton(hf5, "&Show Logs");
00311    fLog->SetToolTipText("Show query log messages");
00312    fLog->Connect("Clicked()", "TProofProgressDialog", this, "DoLog()");
00313    hf5->AddFrame(fLog, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 7, 7, 0, 0));
00314 
00315    if (PPD_SRV_NEWER(11)) {
00316       fRatePlot = new TGTextButton(hf5, "&Performance plot");
00317       fRatePlot->SetToolTipText("Show rates, chunck sizes, cluster activities ... vs time");
00318       fRatePlot->SetState(kButtonDisabled);
00319       fRatePlot->Connect("Clicked()", "TProofProgressDialog", this, "DoPlotRateGraph()");
00320       hf5->AddFrame(fRatePlot, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 7, 7, 0, 0));
00321    }
00322 
00323    fMemPlot = new TGTextButton(hf5, "&Memory Plot");
00324    fMemPlot->Connect("Clicked()", "TProofProgressDialog", this, "DoMemoryPlot()");
00325    fMemPlot->SetToolTipText("Show memory consumption vs entry / merging phase");
00326    hf5->AddFrame(fMemPlot, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 7, 7, 0, 0));
00327 
00328    fUpdtSpeedo = new TGTextButton(hf5, "&Enable speedometer");
00329    fUpdtSpeedo->Connect("Clicked()", "TProofProgressDialog", this, "DoEnableSpeedo()");
00330    if (fSpeedoEnabled) {
00331       fUpdtSpeedo->ChangeText("&Disable speedometer");
00332       fUpdtSpeedo->SetToolTipText("Disable speedometer");
00333    } else {
00334       fUpdtSpeedo->ChangeText("&Enable speedometer");
00335       fUpdtSpeedo->SetToolTipText("Enable speedometer (may have an impact on performance)");
00336    }
00337    hf5->AddFrame(fUpdtSpeedo, new TGLayoutHints(kLHintsCenterY | kLHintsExpandX, 7, 7, 0, 0));
00338 
00339    fDialog->AddFrame(hf5, new TGLayoutHints(kLHintsBottom | kLHintsCenterX | kLHintsExpandX, 5, 5, 5, 5));
00340 
00341    // Only enable if master supports it
00342    if (!PPD_SRV_NEWER(18)) {
00343       fMemPlot->SetState(kButtonDisabled);
00344       TString tip = TString::Format("Not supported by the master: required protocol 19 > %d",
00345                                     (fProof ? fProof->GetRemoteProtocol() : -1));
00346       fMemPlot->SetToolTipText(tip.Data());
00347    } else {
00348       fMemPlot->SetToolTipText("Show memory consumption");
00349    }
00350 
00351    // Connect slot to proof progress signal
00352    if (fProof) {
00353       fProof->Connect("Progress(Long64_t,Long64_t)", "TProofProgressDialog",
00354                       this, "Progress(Long64_t,Long64_t)");
00355       fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
00356                       "TProofProgressDialog", this,
00357                       "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
00358       fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)",
00359                       "TProofProgressDialog", this,
00360                       "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
00361       fProof->Connect("StopProcess(Bool_t)", "TProofProgressDialog", this,
00362                       "IndicateStop(Bool_t)");
00363       fProof->Connect("ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)",
00364                       "TProofProgressDialog", this,
00365                       "ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)");
00366       fProof->Connect("CloseProgressDialog()", "TProofProgressDialog", this, "DoClose()");
00367       fProof->Connect("DisableGoAsyn()", "TProofProgressDialog", this, "DisableAsyn()");
00368    }
00369 
00370    // Set dialog title
00371    if (fProof) {
00372       if (strlen(fProof->GetUser()) > 0)
00373          fDialog->SetWindowName(Form("PROOF Query Progress: %s@%s",
00374                                      fProof->GetUser(), fProof->GetMaster()));
00375       else
00376          fDialog->SetWindowName(Form("PROOF Query Progress: %s", fProof->GetMaster()));
00377    } else
00378       fDialog->SetWindowName("PROOF Query Progress: <dummy>");
00379 
00380    // Map all widgets and calculate size of dialog
00381    fDialog->MapSubwindows();
00382 
00383    fDialog->Resize(fDialog->GetDefaultSize());
00384 
00385    const TGWindow *main = gClient->GetRoot();
00386    // Position relative to the parent window (which is the root window)
00387    Window_t wdum;
00388    int      ax, ay;
00389    Int_t    mw = ((TGFrame *) main)->GetWidth();
00390    Int_t    mh = ((TGFrame *) main)->GetHeight();
00391    Int_t    width  = fDialog->GetDefaultWidth();
00392    Int_t    height = fDialog->GetDefaultHeight();
00393 
00394    gVirtualX->TranslateCoordinates(main->GetId(), main->GetId(),
00395                           (mw - width), (mh - height) >> 1, ax, ay, wdum);
00396 
00397    // Make the message box non-resizable
00398    fDialog->SetWMSize(width, height);
00399    fDialog->SetWMSizeHints(width, height, width, height, 0, 0);
00400 
00401    fDialog->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH  | kMWMDecorMaximize |
00402                                        kMWMDecorMinimize | kMWMDecorMenu,
00403                         kMWMFuncAll  | kMWMFuncResize    | kMWMFuncMaximize |
00404                                        kMWMFuncMinimize,
00405                         kMWMInputModeless);
00406 
00407    fDialog->Move(ax-10, ay - mh/4);
00408    fDialog->SetWMPosition(ax-10, ay - mh/4);
00409    // Popup dialog and wait till user replies
00410    fDialog->MapWindow();
00411 
00412    fStartTime = gSystem->Now();
00413 }
00414 
00415 //______________________________________________________________________________
00416 void TProofProgressDialog::ToggleOdometerInfos()
00417 {
00418    // Toggle information displayed in Analog Meter
00419 
00420    if (fRightInfo < 1)
00421       fRightInfo++;
00422    else
00423       fRightInfo = 0;
00424    if (fRightInfo == 0) {
00425       fSpeedo->SetDisplayText("Init Time", "[ms]");
00426       fSpeedo->SetOdoValue((Int_t)(fInitTime * 1000.0));
00427    }
00428    else if (fRightInfo == 1) {
00429       fSpeedo->SetDisplayText("Proc Time", "[ms]");
00430       fSpeedo->SetOdoValue((Int_t)(fProcTime * 1000.0));
00431    }
00432 }
00433 
00434 //______________________________________________________________________________
00435 void TProofProgressDialog::ToggleThreshold()
00436 {
00437    if (fSpeedo->IsThresholdActive()) {
00438       fSpeedo->DisableThreshold();
00439       fSpeedo->Glow(TGSpeedo::kNoglow);
00440    }
00441    else
00442       fSpeedo->EnableThreshold();
00443 }
00444 
00445 //______________________________________________________________________________
00446 void TProofProgressDialog::ResetProgressDialog(const char *selec,
00447                                                Int_t files, Long64_t first,
00448                                                Long64_t entries)
00449 {
00450    // Reset dialog box preparing for new query
00451    TString buf;
00452 
00453    // Update title
00454    buf.Form("Executing on PROOF cluster \"%s\" with %d parallel workers:",
00455             fProof ? fProof->GetMaster() : "<dummy>",
00456             fProof ? fProof->GetParallel() : 0);
00457    fTitleLab->SetText(buf);
00458 
00459    // Reset members
00460    fFiles         = files;
00461    fFirst         = first;
00462    fEntries       = entries;
00463    fPrevProcessed = 0;
00464    fPrevTotal     = 0;
00465    fStatus        = kRunning;
00466 
00467    // Update selector name
00468    buf.Form("Selector: %s", selec);
00469    fSelector->SetText(buf);
00470 
00471    // Reset 'estim' and 'processed' text
00472    fTimeLab->SetText("Estimated time left:");
00473    fProcessed->SetText("Processing status:");
00474 
00475    // Update numbers
00476    buf.Form("%d files, number of events %lld, starting event %lld",
00477             fFiles, fEntries, fFirst);
00478    fFilesEvents->SetText(buf);
00479 
00480    // Reset progress bar
00481    fBar->SetBarColor("green");
00482    fBar->Reset();
00483 
00484    // Reset speedo
00485    fSpeedo->SetMinMaxScale(0.0, 1.0);
00486    fSpeedo->SetMeanValue(0.0);
00487    fSpeedo->ResetPeakVal();
00488 
00489    // Reset buttons
00490    fStop->SetState(kButtonUp);
00491    fAbort->SetState(kButtonUp);
00492    fClose->SetState(kButtonDisabled);
00493    if (fProof && fProof->IsSync() && fProof->GetRemoteProtocol() >= 22) {
00494       fAsyn->SetState(kButtonUp);
00495    } else {
00496       fAsyn->SetState(kButtonDisabled);
00497    }
00498 
00499    // Reconnect the slots
00500    if (fProof) {
00501       fProof->Connect("Progress(Long64_t,Long64_t)", "TProofProgressDialog",
00502                       this, "Progress(Long64_t,Long64_t)");
00503       fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
00504                       "TProofProgressDialog", this,
00505                       "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
00506       fProof->Connect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)",
00507                       "TProofProgressDialog", this,
00508                       "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
00509       fProof->Connect("StopProcess(Bool_t)", "TProofProgressDialog", this,
00510                       "IndicateStop(Bool_t)");
00511       fProof->Connect("DisableGoAsyn()", "TProofProgressDialog", this, "DisableAsyn()");
00512    }
00513 
00514    // Reset start time
00515    fStartTime = gSystem->Now();
00516 
00517    // Clear the list of performances points
00518    if (PPD_SRV_NEWER(11))
00519       fRatePoints->Reset();
00520    SafeDelete(fRateGraph);
00521    SafeDelete(fMBRtGraph);
00522    SafeDelete(fActWGraph);
00523    SafeDelete(fTotSGraph);
00524    SafeDelete(fEffSGraph);
00525    fAvgRate = 0.;
00526    fAvgMBRate = 0.;
00527 }
00528 
00529 //______________________________________________________________________________
00530 void TProofProgressDialog::Progress(Long64_t total, Long64_t processed)
00531 {
00532    // Update progress bar and status labels.
00533    // Use "processed == total" or "processed < 0" to indicate end of processing.
00534 
00535    Long_t tt;
00536    UInt_t hh=0, mm=0, ss=0;
00537    TString buf;
00538    TString stm;
00539    static const char *cproc[] = { "running", "done",
00540                                   "STOPPED", "ABORTED", "***EVENTS SKIPPED***"};
00541 
00542    // Update title
00543    buf.Form("Executing on PROOF cluster \"%s\" with %d parallel workers:",
00544             fProof ? fProof->GetMaster() : "<dummy>",
00545             fProof ? fProof->GetParallel() : 0);
00546    fTitleLab->SetText(buf);
00547 
00548    if (total < 0)
00549       total = fPrevTotal;
00550    else
00551       fPrevTotal = total;
00552 
00553    // Nothing to update
00554    if (fPrevProcessed == processed)
00555       return;
00556 
00557    // Number of processed events
00558    Long64_t evproc = (processed >= 0) ? processed : fPrevProcessed;
00559 
00560    if (fEntries != total) {
00561       fEntries = total;
00562       buf.Form("%d files, number of events %lld, starting event %lld",
00563                fFiles, fEntries, fFirst);
00564       fFilesEvents->SetText(buf);
00565    }
00566 
00567    // Update position
00568    Float_t pos = Float_t(Double_t(evproc * 100)/Double_t(total));
00569    fBar->SetPosition(pos);
00570 
00571    // get current time
00572    fEndTime = gSystem->Now();
00573    TTime tdiff = fEndTime - fStartTime;
00574    Float_t eta = 0;
00575    if (evproc > 0)
00576       eta = ((Float_t)((Long64_t)tdiff)*total/Float_t(evproc) - Long64_t(tdiff))/1000.;
00577 
00578    if (processed >= 0 && processed >= total) {
00579       tt = (Long_t)Long64_t(tdiff)/1000;
00580       if (tt > 0) {
00581          hh = (UInt_t)(tt / 3600);
00582          mm = (UInt_t)((tt % 3600) / 60);
00583          ss = (UInt_t)((tt % 3600) % 60);
00584       }
00585       if (hh)
00586          stm.Form("%d h %d min %d sec", hh, mm, ss);
00587       else if (mm)
00588          stm.Form("%d min %d sec", mm, ss);
00589       else
00590          stm.Form("%d sec", ss);
00591       fProcessed->SetText("Processed:");
00592       buf.Form("%lld events in %s\n", total, stm.Data());
00593       fTotal->SetText(buf);
00594 
00595       fEstim->SetText("0 sec");
00596 
00597       if (fProof) {
00598          fProof->Disconnect("Progress(Long64_t,Long64_t)", this,
00599                             "Progress(Long64_t,Long64_t)");
00600          fProof->Disconnect("StopProcess(Bool_t)", this,
00601                             "IndicateStop(Bool_t)");
00602          fProof->Disconnect("DisableGoAsyn()", this, "DisableAsyn()");
00603       }
00604 
00605       // Set button state
00606       fAsyn->SetState(kButtonDisabled);
00607       fStop->SetState(kButtonDisabled);
00608       fAbort->SetState(kButtonDisabled);
00609       fClose->SetState(kButtonUp);
00610       if (!fKeep) DoClose();
00611 
00612       // Set the status to done
00613       fStatus = kDone;
00614 
00615    } else {
00616       // A negative value for process indicates that we are finished,
00617       // no matter whether the processing was complete
00618       Bool_t incomplete = (processed < 0 &&
00619                           (fPrevProcessed < total || fPrevProcessed == 0))
00620                         ? kTRUE : kFALSE;
00621       if (incomplete) {
00622          fStatus = kIncomplete;
00623          // We use a different color to highlight incompletion
00624          fBar->SetBarColor("magenta");
00625       }
00626       tt = (Long_t)eta;
00627       if (tt > 0) {
00628          hh = (UInt_t)(tt / 3600);
00629          mm = (UInt_t)((tt % 3600) / 60);
00630          ss = (UInt_t)((tt % 3600) % 60);
00631       }
00632       if (hh)
00633          stm.Form("%d h %d min %d sec", hh, mm, ss);
00634       else if (mm)
00635          stm.Form("%d min %d sec", mm, ss);
00636       else
00637          stm.Form("%d sec", ss);
00638 
00639       fEstim->SetText(stm.Data());
00640       buf.Form("%lld / %lld events", evproc, total);
00641       if (fStatus > kDone) {
00642          buf += TString::Format(" - %s", cproc[fStatus]);
00643       }
00644       fTotal->SetText(buf);
00645 
00646       buf.Form("%.1f events/sec\n", Float_t(evproc)/Long64_t(tdiff)*1000.);
00647       fRate->SetText(buf);
00648 
00649       if (processed < 0) {
00650          // And we disable the buttons
00651          fAsyn->SetState(kButtonDisabled);
00652          fStop->SetState(kButtonDisabled);
00653          fAbort->SetState(kButtonDisabled);
00654          fClose->SetState(kButtonUp);
00655 
00656          // Set the status to done
00657          fStatus = kDone;
00658       }
00659    }
00660    fPrevProcessed = evproc;
00661 }
00662 
00663 //______________________________________________________________________________
00664 void TProofProgressDialog::Progress(Long64_t total, Long64_t processed,
00665                                     Long64_t bytesread,
00666                                     Float_t initTime, Float_t procTime,
00667                                     Float_t evtrti, Float_t mbrti,
00668                                     Int_t actw, Int_t tses, Float_t eses)
00669 {
00670    // Update progress bar and status labels.
00671    // Use "processed == total" or "processed < 0" to indicate end of processing.
00672 
00673    Double_t BinLow, BinHigh;
00674    Int_t nbins;
00675    Long_t tt;
00676    UInt_t hh=0, mm=0, ss=0;
00677    TString buf;
00678    TString stm;
00679    static const char *cproc[] = { "running", "done",
00680                                   "STOPPED", "ABORTED", "***EVENTS SKIPPED***"};
00681 
00682    // Update title
00683    buf.Form("Executing on PROOF cluster \"%s\" with %d parallel workers:",
00684             fProof ? fProof->GetMaster() : "<dummy>",
00685             fProof ? fProof->GetParallel() : 0);
00686    fTitleLab->SetText(buf);
00687 
00688    if (initTime >= 0.) {
00689       // Set init time
00690       fInitTime = initTime;
00691       buf.Form("%.1f secs", initTime);
00692       fInit->SetText(buf);
00693       if (fSpeedoEnabled && fRightInfo == 0)
00694          fSpeedo->SetOdoValue((Int_t)(fInitTime * 1000.0));
00695    }
00696 
00697    Bool_t over = kFALSE;
00698    if (total < 0) {
00699       total = fPrevTotal;
00700       over = kTRUE;
00701    } else {
00702       fPrevTotal = total;
00703    }
00704 
00705    // Show proc time by default when switching from init to proc
00706    if (processed > 0 && fPrevProcessed <= 0)
00707       while (fRightInfo != 1)
00708          ToggleOdometerInfos();
00709 
00710    // Nothing to update
00711    if (fPrevProcessed == processed)
00712       return;
00713 
00714    // Number of processed events
00715    Long64_t evproc = (processed >= 0) ? processed : fPrevProcessed;
00716    Float_t mbsproc = bytesread / TMath::Power(2.,20.);
00717 
00718    if (fEntries != total) {
00719       fEntries = total;
00720       buf.Form("%d files, number of events %lld, starting event %lld",
00721                fFiles, fEntries, fFirst);
00722       fFilesEvents->SetText(buf);
00723    }
00724 
00725    // Update position
00726    Float_t pos = Float_t(Double_t(evproc * 100)/Double_t(total));
00727    fBar->SetPosition(pos);
00728 
00729    Float_t eta = 0;
00730    if (evproc > 0 && procTime > 0.)
00731       eta = (Float_t) (total - evproc) / (Double_t)evproc * procTime;
00732 
00733    // Update average rates
00734    if (procTime > 0.) {
00735       fProcTime = procTime;
00736       fAvgRate = Float_t(evproc) / procTime;
00737       fAvgMBRate = mbsproc / procTime;
00738    }
00739 
00740    if (fSpeedoEnabled) {
00741       if (fRightInfo == 0)
00742          fSpeedo->SetOdoValue((Int_t)(fInitTime * 1000.0));
00743       else if (fRightInfo == 1)
00744          fSpeedo->SetOdoValue((Int_t)(fProcTime * 1000.0));
00745    }
00746 
00747    if (over || (processed >= 0 && processed >= total)) {
00748 
00749       // A negative value for process indicates that we are finished,
00750       // no matter whether the processing was complete
00751       Bool_t incomplete = (processed < 0 &&
00752                           (fPrevProcessed < total || fPrevProcessed == 0))
00753                         ? kTRUE : kFALSE;
00754       TString st = "";
00755       if (incomplete) {
00756          fStatus = kIncomplete;
00757          // We use a different color to highlight incompletion
00758          fBar->SetBarColor("magenta");
00759          st = TString::Format(" %s", cproc[fStatus]);
00760       }
00761 
00762       tt = (Long_t)fProcTime;
00763       if (tt > 0) {
00764          hh = (UInt_t)(tt / 3600);
00765          mm = (UInt_t)((tt % 3600) / 60);
00766          ss = (UInt_t)((tt % 3600) % 60);
00767       }
00768       if (hh)
00769          stm.Form("%d h %d min %d sec", hh, mm, ss);
00770       else if (mm)
00771          stm.Form("%d min %d sec", mm, ss);
00772       else
00773          stm.Form("%d sec", ss);
00774       fProcessed->SetText("Processed:");
00775       TString sf("MB");
00776       Float_t xb = fAvgMBRate*fProcTime;
00777       xb = AdjustBytes(xb, sf);
00778       buf.Form("%lld events (%.2f %s)\n",
00779                std::max(fPrevProcessed, processed), xb, sf.Data());
00780       fTotal->SetText(buf);
00781       buf.Form("%s %s\n", stm.Data(), st.Data());
00782       fTimeLab->SetText("Processing time:");
00783       fEstim->SetText(buf);
00784       buf.Form("%.1f evts/sec (%.1f MB/sec)\n", fAvgRate, fAvgMBRate);
00785       fRate->SetText(buf);
00786       // Fill rate graph
00787       Bool_t useAvg = gEnv->GetValue("Proof.RatePlotUseAvg", 0);
00788       if (useAvg) {
00789          if (fAvgRate > 0.) {
00790             fRatePoints->Fill(procTime, fAvgRate, fAvgMBRate);
00791             fRatePlot->SetState(kButtonUp);
00792          }
00793       } else {
00794          if (evtrti > 0.) {
00795             fRatePoints->Fill(procTime, evtrti, mbrti, (Float_t)actw, (Float_t)tses, eses);
00796             fRatePlot->SetState(kButtonUp);
00797          }
00798       }
00799 
00800       if (fProof) {
00801          fProof->Disconnect("Progress(Long64_t,Long64_t)", this,
00802                             "Progress(Long64_t,Long64_t)");
00803          fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
00804                             this,
00805                             "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
00806          fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)",
00807                             this,
00808                             "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
00809          fProof->Disconnect("StopProcess(Bool_t)", this, "IndicateStop(Bool_t)");
00810          fProof->Disconnect("DisableGoAsyn()", this, "DisableAsyn()");
00811       }
00812 
00813       // Set button state
00814       fAsyn->SetState(kButtonDisabled);
00815       fStop->SetState(kButtonDisabled);
00816       fAbort->SetState(kButtonDisabled);
00817       fClose->SetState(kButtonUp);
00818 
00819       if (fSmoothSpeedo->GetState() == kButtonDown)
00820          fSpeedo->SetScaleValue(0.0, 0);
00821       else
00822          fSpeedo->SetScaleValue(0.0);
00823       fSpeedo->Glow(TGSpeedo::kNoglow);
00824 
00825       if (!fKeep) DoClose();
00826 
00827       // Set the status to done
00828       fStatus = kDone;
00829 
00830    } else {
00831       // A negative value for process indicates that we are finished,
00832       // no matter whether the processing was complete
00833       Bool_t incomplete = (processed < 0 &&
00834                           (fPrevProcessed < total || fPrevProcessed == 0))
00835                         ? kTRUE : kFALSE;
00836       if (incomplete) {
00837          fStatus = kIncomplete;
00838          // We use a different color to highlight incompletion
00839          fBar->SetBarColor("magenta");
00840       }
00841       tt = (Long_t)eta;
00842       if (tt > 0) {
00843          hh = (UInt_t)(tt / 3600);
00844          mm = (UInt_t)((tt % 3600) / 60);
00845          ss = (UInt_t)((tt % 3600) % 60);
00846       }
00847       if (hh)
00848          stm.Form("%d h %d min %d sec", hh, mm, ss);
00849       else if (mm)
00850          stm.Form("%d min %d sec", mm, ss);
00851       else
00852          stm.Form("%d sec", ss);
00853 
00854       fEstim->SetText(stm.Data());
00855       TString sf("MB");
00856       Float_t xb = AdjustBytes(mbsproc, sf);
00857       buf.Form("%lld / %lld events - %.2f %s", evproc, total, xb, sf.Data());
00858       if (fStatus > kDone) {
00859          buf += TString::Format(" - %s", cproc[fStatus]);
00860       }
00861       fTotal->SetText(buf);
00862 
00863       // Post
00864       if (evtrti > 0.) {
00865          buf.Form("%.1f evts/sec \navg: %.1f evts/sec (%.1f MB/sec)",
00866                   evtrti, fAvgRate, fAvgMBRate);
00867          fRatePoints->Fill(procTime, evtrti, mbrti, (Float_t)actw, (Float_t)tses, eses);
00868          fRatePlot->SetState(kButtonUp);
00869          if (fSpeedoEnabled) {
00870             if (evtrti > fSpeedo->GetScaleMax()) {
00871                nbins = 4;
00872                BinLow = fSpeedo->GetScaleMin();
00873                BinHigh = 1.5 * evtrti;
00874                THLimitsFinder::OptimizeLimits(4, nbins, BinLow, BinHigh, kFALSE);
00875                fSpeedo->SetMinMaxScale(fSpeedo->GetScaleMin(), BinHigh);
00876             }
00877             if (fSmoothSpeedo->GetState() == kButtonDown)
00878                fSpeedo->SetScaleValue(evtrti, 0);
00879             else
00880                fSpeedo->SetScaleValue(evtrti);
00881             fSpeedo->SetMeanValue(fAvgRate);
00882          }
00883       } else {
00884          buf.Form("avg: %.1f evts/sec (%.1f MB/sec)", fAvgRate, fAvgMBRate);
00885       }
00886       fRate->SetText(buf);
00887 
00888       if (processed < 0) {
00889          // And we disable the buttons
00890          fAsyn->SetState(kButtonDisabled);
00891          fStop->SetState(kButtonDisabled);
00892          fAbort->SetState(kButtonDisabled);
00893          fClose->SetState(kButtonUp);
00894 
00895          if (fSpeedoEnabled) {
00896             if (fSmoothSpeedo->GetState() == kButtonDown)
00897                fSpeedo->SetScaleValue(0.0, 0);
00898             else
00899                fSpeedo->SetScaleValue(0.0);
00900             fSpeedo->Glow(TGSpeedo::kNoglow);
00901          }
00902 
00903          // Set the status to done
00904          fStatus = kDone;
00905       }
00906    }
00907    fPrevProcessed = evproc;
00908 }
00909 
00910 //______________________________________________________________________________
00911 Float_t TProofProgressDialog::AdjustBytes(Float_t mbs, TString &sf)
00912 {
00913    // Transform MBs to GBs ot TBs and get the correct suffix
00914 
00915    Float_t xb = mbs;
00916    sf = "MB";
00917    if (xb > 1024.) {
00918       xb = xb / 1024.;
00919       sf = "GB";
00920    }
00921    if (xb > 1024.) {
00922       xb = xb / 1024.;
00923       sf = "TB";
00924    }
00925    // Done
00926    return xb;
00927 }
00928 
00929 //______________________________________________________________________________
00930 TProofProgressDialog::~TProofProgressDialog()
00931 {
00932    // Cleanup dialog.
00933 
00934    if (fProof) {
00935       fProof->Disconnect("Progress(Long64_t,Long64_t)", this,
00936                          "Progress(Long64_t,Long64_t)");
00937       fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
00938                          this,
00939                          "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
00940       fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)",
00941                          this,
00942                          "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
00943       fProof->Disconnect("StopProcess(Bool_t)", this, "IndicateStop(Bool_t)");
00944       fProof->Disconnect("DisableGoAsyn()", this, "DisableAsyn()");
00945       fProof->Disconnect("ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)",
00946                          this,
00947                          "ResetProgressDialog(const char*,Int_t,Long64_t,Long64_t)");
00948       fProof->Disconnect("CloseProgressDialog()", this, "CloseProgressDialog()");
00949       fProof->ResetProgressDialogStatus();
00950       // We are called after a TProofDetach: we delete the instance
00951       if (!fProof->IsValid())
00952          SafeDelete(fProof);
00953    }
00954    if (fLogWindow)
00955       delete fLogWindow;
00956    if (fMemWindow)
00957       delete fMemWindow;
00958    fDialog->Cleanup();
00959    delete fDialog;
00960 }
00961 
00962 //______________________________________________________________________________
00963 void TProofProgressDialog::CloseWindow()
00964 {
00965    // Called when dialog is closed.
00966 
00967    delete this;
00968 }
00969 
00970 //______________________________________________________________________________
00971 void TProofProgressDialog::DisableAsyn()
00972 {
00973    // Disable the asyn switch when an external request for going asynchronous is issued
00974 
00975    fProof->Disconnect("DisableGoAsyn()", this, "DisableAsyn()");
00976    fAsyn->SetState(kButtonDisabled);
00977 }
00978 
00979 //______________________________________________________________________________
00980 void TProofProgressDialog::IndicateStop(Bool_t aborted)
00981 {
00982    // Indicate that Cancel or Stop was clicked.
00983 
00984    if (aborted == kTRUE)
00985       fBar->SetBarColor("red");
00986    else
00987       fBar->SetBarColor("yellow");
00988 
00989    if (fProof) {
00990       fProof->Disconnect("Progress(Long64_t,Long64_t)", this,
00991                          "Progress(Long64_t,Long64_t)");
00992       fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)",
00993                          this,
00994                          "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t)");
00995       fProof->Disconnect("Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)",
00996                          this,
00997                          "Progress(Long64_t,Long64_t,Long64_t,Float_t,Float_t,Float_t,Float_t,Int_t,Int_t,Float_t)");
00998       fProof->Disconnect("StopProcess(Bool_t)", this, "IndicateStop(Bool_t)");
00999       fProof->Disconnect("DisableGoAsyn()", this, "DisableAsyn()");
01000       // These buttons are meaningless at this point
01001       fAsyn->SetState(kButtonDisabled);
01002       fStop->SetState(kButtonDisabled);
01003       fAbort->SetState(kButtonDisabled);
01004    }
01005 
01006    fClose->SetState(kButtonUp);
01007    if (!fKeep)
01008       DoClose();
01009 }
01010 
01011 //______________________________________________________________________________
01012 void TProofProgressDialog::LogMessage(const char *msg, Bool_t all)
01013 {
01014    // Load/append a log msg in the log frame, if open
01015 
01016    if (fLogWindow) {
01017       if (all) {
01018          // load buffer
01019          fLogWindow->LoadBuffer(msg);
01020       } else {
01021          // append
01022          fLogWindow->AddBuffer(msg);
01023       }
01024    }
01025 }
01026 
01027 //______________________________________________________________________________
01028 void TProofProgressDialog::DoClose()
01029 {
01030    // Close dialog.
01031 
01032    fClose->SetState(kButtonDisabled);
01033    TTimer::SingleShot(50, "TProofProgressDialog", this, "CloseWindow()");
01034 }
01035 
01036 //______________________________________________________________________________
01037 void TProofProgressDialog::DoLog()
01038 {
01039    // Ask proof session for logs
01040 
01041    if (fProof) {
01042       if (!fLogWindow) {
01043          fLogWindow = new TProofProgressLog(this);
01044          if (!fLogWindow->TestBit(TObject::kInvalidObject))
01045             fLogWindow->DoLog();
01046       } else {
01047          // Clear window
01048          if (!fLogWindow->TestBit(TObject::kInvalidObject)) {
01049             fLogWindow->Clear();
01050             fLogWindow->DoLog();
01051          }
01052       }
01053    }
01054 }
01055 
01056 //______________________________________________________________________________
01057 void TProofProgressDialog::DoKeep(Bool_t)
01058 {
01059    // Handle keep toggle button.
01060 
01061    fKeep = !fKeep;
01062 
01063    // Last choice will be the default for the future
01064    fgKeepDefault = fKeep;
01065 }
01066 
01067 //______________________________________________________________________________
01068 void TProofProgressDialog::DoSetLogQuery(Bool_t)
01069 {
01070    // Handle log-current-query-only toggle button.
01071 
01072    fLogQuery = !fLogQuery;
01073    fEntry->SetEnabled(fLogQuery);
01074    if (fLogQuery)
01075       fEntry->SetToolTipText("Enter the query number ('last' for the last query)",50);
01076    else
01077       fEntry->SetToolTipText(0);
01078 
01079    // Last choice will be the default for the future
01080    fgLogQueryDefault = fLogQuery;
01081 }
01082 
01083 //______________________________________________________________________________
01084 void TProofProgressDialog::DoStop()
01085 {
01086    // Handle Stop button.
01087 
01088    // Do not wait for ever, but al least 10 seconds
01089    Long_t timeout = gEnv->GetValue("Proof.ShutdownTimeout", 60) / 2;
01090    timeout = (timeout > 10) ? timeout : 10;
01091    fProof->StopProcess(kFALSE, timeout);
01092    fStatus = kStopped;
01093 
01094    // Set buttons states
01095    fAsyn->SetState(kButtonDisabled);
01096    fStop->SetState(kButtonDisabled);
01097    fAbort->SetState(kButtonDisabled);
01098    fClose->SetState(kButtonUp);
01099 }
01100 
01101 //______________________________________________________________________________
01102 void TProofProgressDialog::DoAbort()
01103 {
01104    // Handle Cancel button.
01105 
01106    fProof->StopProcess(kTRUE);
01107    fStatus = kAborted;
01108 
01109    // Set buttons states
01110    fAsyn->SetState(kButtonDisabled);
01111    fStop->SetState(kButtonDisabled);
01112    fAbort->SetState(kButtonDisabled);
01113    fClose->SetState(kButtonUp);
01114 }
01115 
01116 //______________________________________________________________________________
01117 void TProofProgressDialog::DoAsyn()
01118 {
01119    // Handle Asyn button.
01120 
01121    fProof->GoAsynchronous();
01122 
01123    // Set buttons states
01124    fAsyn->SetState(kButtonDisabled);
01125 }
01126 
01127 //______________________________________________________________________________
01128 void TProofProgressDialog::DoPlotRateGraph()
01129 {
01130    // Handle Plot Rate Graph.
01131 
01132    // We must have some point to plot
01133    if (!fRatePoints || fRatePoints->GetEntries() <= 0) {
01134       Info("DoPlotRateGraph","list is empty!");
01135       return;
01136    }
01137 
01138    // Fill the graphs
01139    Int_t np = (Int_t)fRatePoints->GetEntries();
01140    Double_t eymx = -1., bymx = -1., wymx = -1., tymx=-1., symx = -1.;
01141    SafeDelete(fRateGraph);
01142    SafeDelete(fMBRtGraph);
01143    SafeDelete(fActWGraph);
01144    SafeDelete(fTotSGraph);
01145    SafeDelete(fEffSGraph);
01146    fRateGraph = new TGraph(np);
01147    fMBRtGraph = new TGraph(np);
01148    if (PPD_SRV_NEWER(25)) {
01149       fActWGraph = new TGraph(np);
01150       fTotSGraph = new TGraph(np);
01151       fEffSGraph = new TGraph(np);
01152    }
01153    Float_t *nar = fRatePoints->GetArgs();
01154    Int_t ii = 0;
01155    for ( ; ii < np; ++ii) {
01156       fRatePoints->GetEntry(ii);
01157       if (!(nar[1] > 0.)) continue;
01158       // Evts/s
01159       fRateGraph->SetPoint(ii, (Double_t) nar[0], (Double_t) nar[1]);
01160       eymx = (nar[1] > eymx) ? nar[1] : eymx;
01161       // MBs/s
01162       fMBRtGraph->SetPoint(ii, (Double_t) nar[0], (Double_t) nar[2]);
01163       bymx = (nar[2] > bymx) ? nar[2] : bymx;
01164       // Active workers
01165       if (PPD_SRV_NEWER(25)) {
01166          fActWGraph->SetPoint(ii, (Double_t) nar[0], (Double_t) nar[3]);
01167          wymx = (nar[3] > wymx) ? nar[3] : wymx;
01168       }
01169       // Sessions info
01170       if (PPD_SRV_NEWER(25)) {
01171          fTotSGraph->SetPoint(ii, (Double_t) nar[0], (Double_t) nar[4]);
01172          tymx = (nar[4] > tymx) ? nar[4] : tymx;
01173          fEffSGraph->SetPoint(ii, (Double_t) nar[0], (Double_t) nar[5]);
01174          symx = (nar[5] > symx) ? nar[5] : symx;
01175       }
01176    }
01177 
01178    // Pad numbering
01179    Int_t npads = 4;
01180    Int_t kEvrt = 1;
01181    Int_t kMBrt = 2;
01182    Int_t kActW = 3;
01183    Int_t kSess = 4;
01184    if (bymx <= 0.) {
01185       SafeDelete(fMBRtGraph);
01186       npads--;
01187       kActW--;
01188       kSess--;
01189    }
01190    if (wymx <= 0.) {
01191       SafeDelete(fActWGraph);
01192       npads--;
01193       kSess--;
01194    }
01195    // Plot only if more than one active session during the query
01196    if (tymx <= 1.) {
01197       SafeDelete(fTotSGraph);
01198       SafeDelete(fEffSGraph);
01199       npads--;
01200       kSess--;
01201    }
01202    if (tymx <= 0.) SafeDelete(fTotSGraph);
01203    if (symx <= 0.) SafeDelete(fEffSGraph);
01204 
01205    // Create a canvas
01206    Int_t jsz = 200*npads;
01207    TCanvas *c1 = new TCanvas("c1","Rate vs Time",200,10,700,jsz);
01208    c1->SetFillColor(0);
01209    c1->SetGrid();
01210    c1->SetBorderMode(0);
01211    c1->SetFrameBorderMode(0);
01212 
01213    // Padding
01214    c1->Divide(1, npads);
01215 
01216    // Event Rate plot
01217    TPad *cpad = (TPad *) c1->GetPad(kEvrt);
01218    cpad->cd();
01219    cpad->SetFillColor(0);
01220    cpad->SetBorderMode(20);
01221    cpad->SetFrameBorderMode(0);
01222 
01223    fRateGraph->SetMinimum(0.);
01224    fRateGraph->SetMaximum(eymx*1.1);
01225    fRateGraph->SetLineColor(50);
01226    fRateGraph->SetLineWidth(2);
01227    fRateGraph->SetMarkerColor(38);
01228    fRateGraph->SetMarkerStyle(25);
01229    fRateGraph->SetMarkerSize(0.8);
01230    fRateGraph->SetTitle("Processing rate (evts/sec)");
01231    fRateGraph->GetXaxis()->SetTitle("elapsed time (sec)");
01232    fRateGraph->Draw("ALP");
01233 
01234    // Line with average
01235    TLine *line = new TLine(fRateGraph->GetXaxis()->GetXmin(),fAvgRate,
01236                            fRateGraph->GetXaxis()->GetXmax(),fAvgRate);
01237    line->SetLineColor(8);
01238    line->SetLineStyle(2);
01239    line->SetLineWidth(2);
01240    line->Draw();
01241 
01242    // Label
01243    Double_t xax0 = fRateGraph->GetXaxis()->GetXmin();
01244    Double_t xax1 = fRateGraph->GetXaxis()->GetXmax();
01245    Double_t yax0 = 0.;
01246    Double_t yax1 = eymx*1.1;
01247    Double_t x0 = xax0 + 0.05 * (xax1 - xax0);
01248    Double_t x1 = xax0 + 0.60 * (xax1 - xax0);
01249    Double_t y0 = yax0 + 0.10 * (yax1 - yax0);
01250    Double_t y1 = yax0 + 0.20 * (yax1 - yax0);
01251    TPaveText *pt = new TPaveText(x0, y0, x1, y1, "br");
01252    pt->SetFillColor(0);
01253    pt->AddText(Form("Global average: %.2f evts/sec", fAvgRate));
01254    pt->Draw();
01255 
01256    // MB Rate plot
01257    if (fMBRtGraph) {
01258       cpad = (TPad *) c1->GetPad(kMBrt);
01259       cpad->cd();
01260       cpad->SetFillColor(0);
01261       cpad->SetBorderMode(0);
01262       cpad->SetFrameBorderMode(0);
01263 
01264       fMBRtGraph->SetFillColor(38);
01265       TH1F *graph2 = new TH1F("graph2","Average read chunck size (MBs/request)",100,
01266                                fRateGraph->GetXaxis()->GetXmin(),fRateGraph->GetXaxis()->GetXmax());
01267       graph2->SetMinimum(0);
01268       graph2->SetMaximum(1.1*bymx);
01269       graph2->SetDirectory(0);
01270       graph2->SetStats(0);
01271       graph2->GetXaxis()->SetTitle("elapsed time (sec)");
01272       fMBRtGraph->SetHistogram(graph2);
01273       fMBRtGraph->Draw("AB");
01274    }
01275 
01276    // MB Rate plot
01277    if (fActWGraph) {
01278       cpad = (TPad *) c1->GetPad(kActW);
01279       cpad->cd();
01280       cpad->SetFillColor(0);
01281       cpad->SetBorderMode(0);
01282       cpad->SetFrameBorderMode(0);
01283 
01284       fActWGraph->SetMinimum(0.);
01285       fActWGraph->SetMaximum(wymx*1.1);
01286       fActWGraph->SetLineColor(50);
01287       fActWGraph->SetLineWidth(2);
01288       fActWGraph->SetMarkerColor(38);
01289       fActWGraph->SetMarkerStyle(25);
01290       fActWGraph->SetMarkerSize(0.8);
01291       fActWGraph->SetTitle("Active workers");
01292       fActWGraph->GetXaxis()->SetTitle("elapsed time (sec)");
01293       fActWGraph->Draw("ALP");
01294    }
01295 
01296    // MB Rate plot
01297    if (fTotSGraph) {
01298       cpad = (TPad *) c1->GetPad(kSess);
01299       cpad->cd();
01300       cpad->SetFillColor(0);
01301       cpad->SetBorderMode(0);
01302       cpad->SetFrameBorderMode(0);
01303 
01304       fTotSGraph->SetMinimum(0.);
01305       fTotSGraph->SetMaximum(tymx*1.1);
01306       fTotSGraph->SetLineColor(50);
01307       fTotSGraph->SetLineWidth(2);
01308       fTotSGraph->SetMarkerColor(38);
01309       fTotSGraph->SetMarkerStyle(25);
01310       fTotSGraph->SetMarkerSize(0.8);
01311       fTotSGraph->SetTitle("Active, Effective sessions");
01312       fTotSGraph->GetXaxis()->SetTitle("elapsed time (sec)");
01313       fTotSGraph->Draw("ALP");
01314 
01315       // Effective sessions
01316       if (fEffSGraph) {
01317          fEffSGraph->SetMinimum(0.);
01318          fEffSGraph->SetMaximum(tymx*1.1);
01319          fEffSGraph->SetLineColor(38);
01320          fEffSGraph->SetLineWidth(2);
01321          fEffSGraph->SetMarkerColor(50);
01322          fEffSGraph->SetMarkerStyle(21);
01323          fEffSGraph->SetMarkerSize(0.6);
01324          fEffSGraph->Draw("SLP");
01325       }
01326    }
01327 
01328    c1->Modified();
01329 }
01330 
01331 //______________________________________________________________________________
01332 void TProofProgressDialog::DoMemoryPlot()
01333 {
01334    // Do a memory plot
01335 
01336    if (!fMemWindow) {
01337       fMemWindow = new TProofProgressMemoryPlot(this, 500, 300);
01338       fMemWindow->DoPlot();
01339    } else {
01340       // Clear window
01341       fMemWindow->Clear();
01342       fMemWindow->DoPlot();
01343    }
01344 }
01345 
01346 //______________________________________________________________________________
01347 void TProofProgressDialog::DoEnableSpeedo()
01348 {
01349    // Enable/Disable speedometer
01350 
01351    if (!fSpeedoEnabled) {
01352       // Enable and connect
01353       fSpeedoEnabled = kTRUE;
01354       fSpeedo->Connect("OdoClicked()", "TProofProgressDialog", this, "ToggleOdometerInfos()");
01355       fSpeedo->Connect("LedClicked()", "TProofProgressDialog", this, "ToggleThreshold()");
01356       fUpdtSpeedo->ChangeText("&Disable speedometer");
01357       fUpdtSpeedo->SetToolTipText("Disable speedometer");
01358       fSmoothSpeedo->SetState(kButtonDown);
01359       fSmoothSpeedo->SetToolTipText("Control smoothness in refreshing the speedo");
01360    } else {
01361       // Disable and disconnect
01362       fSpeedoEnabled = kFALSE;
01363       // Reset speedo
01364       fSpeedo->SetScaleValue(0);
01365       fUpdtSpeedo->ChangeText("&Enable speedometer");
01366       fUpdtSpeedo->SetToolTipText("Enable speedometer (may have an impact on performance)");
01367       fSmoothSpeedo->SetToolTipText("Speedo refreshing is disabled");
01368       fSmoothSpeedo->SetState(kButtonDisabled);
01369    }
01370 }

Generated on Tue Jul 5 14:22:42 2011 for ROOT_528-00b_version by  doxygen 1.5.1