// @(#)root/proof:$Id$
// Author: Sangsu Ryu 22/06/2010

/*************************************************************************
 * Copyright (C) 1995-2005, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TProofBenchRunCPU
#define ROOT_TProofBenchRunCPU

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TProofBenchRunCPU                                                    //
//                                                                      //
// CPU-intensive PROOF benchmark test generates events and fill 1, 2,   //
//or 3-D histograms. No I/O activity is involved.                       //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TString
#include "TString.h"
#endif

#ifndef ROOT_TProofBenchRun
#include "TProofBenchRun.h"
#endif


class TCanvas;
class TList;
class TProof;
class TProfile;
class TLegend;
class TH2;
class TTree;

class TProofBenchMode;
class TProofNodes;
class TPBHistType;

class TProofBenchRunCPU : public TProofBenchRun {

private:

   TPBHistType *fHistType;              //histogram type
   Int_t        fNHists;                //number of histograms

   Long64_t     fNEvents;               //number of events to generate
   Int_t        fNTries;                //number of tries

   Int_t        fStart;                 //start number of workers to scan
   Int_t        fStop;                  //stop number of workers to scan
   Int_t        fStep;                  //test to be performed every fStep workers

   Int_t        fDraw;                  //draw switch
   Int_t        fDebug;                 //debug switch

   TDirectory*  fDirProofBench;         //directory for proof outputs

   TProofNodes* fNodes;                 //node information

   TList*       fListPerfPlots;         //list of performance plots
   TCanvas*     fCanvas;                //canvas for performance plots

   TProfile    *fProfile_perfstat_event;
   TH2         *fHist_perfstat_event;
   TProfile    *fProfile_perfstat_evtmax;
   TProfile    *fNorm_perfstat_evtmax;
   TProfile    *fProfile_queryresult_event;
   TProfile    *fNorm_queryresult_event;
   TProfile    *fProfile_cpu_eff;

   TLegend     *fProfLegend;            // Legend for profiles
   TLegend     *fNormLegend;            // Legend for norms

   TString      fName;                  //name of CPU run

   void BuildHistos(Int_t start, Int_t stop, Int_t step, Bool_t nx);

protected:

   void FillPerfStatPerfPlots(TTree* t, Int_t nactive);

   Int_t SetParameters();
   Int_t DeleteParameters();

public:

   TProofBenchRunCPU(TPBHistType *histtype = 0,
                     Int_t nhists=16, TDirectory* dirproofbench=0,
                     TProof* proof=0, TProofNodes* nodes=0,
                     Long64_t nevents=1000000, Int_t ntries=2, Int_t start=1,
                     Int_t stop=-1, Int_t step=1, Int_t draw=0, Int_t debug=0);

   virtual ~TProofBenchRunCPU();

   void Run(Long64_t nevents, Int_t start, Int_t stop, Int_t step, Int_t ntries,
            Int_t debug, Int_t draw);
   void Run(const char *, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t) { }

   void DrawPerfPlots();

   void Print(Option_t* option="") const;

   void SetHistType(TPBHistType *histtype);
   void SetNHists(Int_t nhists) { fNHists = nhists; }
   void SetNEvents(Long64_t nevents) { fNEvents = nevents; }
   void SetNTries(Int_t ntries) { fNTries = ntries; }
   void SetStart(Int_t start) { fStart = start; }
   void SetStop(Int_t stop) { fStop = stop; }
   void SetStep(Int_t step) { fStep = step; }
   void SetDraw(Int_t draw) { fDraw = draw; }
   void SetDebug(Int_t debug) { fDebug = debug; }

   void SetDirProofBench(TDirectory* dir) { fDirProofBench = dir; }

   TPBHistType *GetHistType() const { return fHistType; }
   Int_t GetNHists() const { return fNHists; }
   Long64_t GetNEvents() const { return fNEvents; }
   Int_t GetNTries() const { return fNTries; }
   Int_t GetStart() const { return fStart; }
   Int_t GetStop() const { return fStop; }
   Int_t GetStep() const { return fStep; }
   Int_t GetDraw() const { return fDraw; }
   Int_t GetDebug() const { return fDebug; }
   TDirectory* GetDirProofBench() const { return fDirProofBench; }
   TList* GetListPerfPlots() const { return fListPerfPlots; }
   TCanvas* GetCanvas() const { return fCanvas; }
   const char* GetName() const { return fName; }

   TString GetNameStem() const;

   ClassDef(TProofBenchRunCPU,0)     //CPU-intensive PROOF benchmark
};

#endif
 TProofBenchRunCPU.h:1
 TProofBenchRunCPU.h:2
 TProofBenchRunCPU.h:3
 TProofBenchRunCPU.h:4
 TProofBenchRunCPU.h:5
 TProofBenchRunCPU.h:6
 TProofBenchRunCPU.h:7
 TProofBenchRunCPU.h:8
 TProofBenchRunCPU.h:9
 TProofBenchRunCPU.h:10
 TProofBenchRunCPU.h:11
 TProofBenchRunCPU.h:12
 TProofBenchRunCPU.h:13
 TProofBenchRunCPU.h:14
 TProofBenchRunCPU.h:15
 TProofBenchRunCPU.h:16
 TProofBenchRunCPU.h:17
 TProofBenchRunCPU.h:18
 TProofBenchRunCPU.h:19
 TProofBenchRunCPU.h:20
 TProofBenchRunCPU.h:21
 TProofBenchRunCPU.h:22
 TProofBenchRunCPU.h:23
 TProofBenchRunCPU.h:24
 TProofBenchRunCPU.h:25
 TProofBenchRunCPU.h:26
 TProofBenchRunCPU.h:27
 TProofBenchRunCPU.h:28
 TProofBenchRunCPU.h:29
 TProofBenchRunCPU.h:30
 TProofBenchRunCPU.h:31
 TProofBenchRunCPU.h:32
 TProofBenchRunCPU.h:33
 TProofBenchRunCPU.h:34
 TProofBenchRunCPU.h:35
 TProofBenchRunCPU.h:36
 TProofBenchRunCPU.h:37
 TProofBenchRunCPU.h:38
 TProofBenchRunCPU.h:39
 TProofBenchRunCPU.h:40
 TProofBenchRunCPU.h:41
 TProofBenchRunCPU.h:42
 TProofBenchRunCPU.h:43
 TProofBenchRunCPU.h:44
 TProofBenchRunCPU.h:45
 TProofBenchRunCPU.h:46
 TProofBenchRunCPU.h:47
 TProofBenchRunCPU.h:48
 TProofBenchRunCPU.h:49
 TProofBenchRunCPU.h:50
 TProofBenchRunCPU.h:51
 TProofBenchRunCPU.h:52
 TProofBenchRunCPU.h:53
 TProofBenchRunCPU.h:54
 TProofBenchRunCPU.h:55
 TProofBenchRunCPU.h:56
 TProofBenchRunCPU.h:57
 TProofBenchRunCPU.h:58
 TProofBenchRunCPU.h:59
 TProofBenchRunCPU.h:60
 TProofBenchRunCPU.h:61
 TProofBenchRunCPU.h:62
 TProofBenchRunCPU.h:63
 TProofBenchRunCPU.h:64
 TProofBenchRunCPU.h:65
 TProofBenchRunCPU.h:66
 TProofBenchRunCPU.h:67
 TProofBenchRunCPU.h:68
 TProofBenchRunCPU.h:69
 TProofBenchRunCPU.h:70
 TProofBenchRunCPU.h:71
 TProofBenchRunCPU.h:72
 TProofBenchRunCPU.h:73
 TProofBenchRunCPU.h:74
 TProofBenchRunCPU.h:75
 TProofBenchRunCPU.h:76
 TProofBenchRunCPU.h:77
 TProofBenchRunCPU.h:78
 TProofBenchRunCPU.h:79
 TProofBenchRunCPU.h:80
 TProofBenchRunCPU.h:81
 TProofBenchRunCPU.h:82
 TProofBenchRunCPU.h:83
 TProofBenchRunCPU.h:84
 TProofBenchRunCPU.h:85
 TProofBenchRunCPU.h:86
 TProofBenchRunCPU.h:87
 TProofBenchRunCPU.h:88
 TProofBenchRunCPU.h:89
 TProofBenchRunCPU.h:90
 TProofBenchRunCPU.h:91
 TProofBenchRunCPU.h:92
 TProofBenchRunCPU.h:93
 TProofBenchRunCPU.h:94
 TProofBenchRunCPU.h:95
 TProofBenchRunCPU.h:96
 TProofBenchRunCPU.h:97
 TProofBenchRunCPU.h:98
 TProofBenchRunCPU.h:99
 TProofBenchRunCPU.h:100
 TProofBenchRunCPU.h:101
 TProofBenchRunCPU.h:102
 TProofBenchRunCPU.h:103
 TProofBenchRunCPU.h:104
 TProofBenchRunCPU.h:105
 TProofBenchRunCPU.h:106
 TProofBenchRunCPU.h:107
 TProofBenchRunCPU.h:108
 TProofBenchRunCPU.h:109
 TProofBenchRunCPU.h:110
 TProofBenchRunCPU.h:111
 TProofBenchRunCPU.h:112
 TProofBenchRunCPU.h:113
 TProofBenchRunCPU.h:114
 TProofBenchRunCPU.h:115
 TProofBenchRunCPU.h:116
 TProofBenchRunCPU.h:117
 TProofBenchRunCPU.h:118
 TProofBenchRunCPU.h:119
 TProofBenchRunCPU.h:120
 TProofBenchRunCPU.h:121
 TProofBenchRunCPU.h:122
 TProofBenchRunCPU.h:123
 TProofBenchRunCPU.h:124
 TProofBenchRunCPU.h:125
 TProofBenchRunCPU.h:126
 TProofBenchRunCPU.h:127
 TProofBenchRunCPU.h:128
 TProofBenchRunCPU.h:129
 TProofBenchRunCPU.h:130
 TProofBenchRunCPU.h:131
 TProofBenchRunCPU.h:132
 TProofBenchRunCPU.h:133
 TProofBenchRunCPU.h:134
 TProofBenchRunCPU.h:135
 TProofBenchRunCPU.h:136
 TProofBenchRunCPU.h:137
 TProofBenchRunCPU.h:138
 TProofBenchRunCPU.h:139
 TProofBenchRunCPU.h:140