ROOT  6.06/09
Reference Guide
ProofConfig.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id$
2 // Author: Kyle Cranmer and Sven Kreiss July 2010
3 /*************************************************************************
4  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef ROOSTATS_ProofConfig
12 #define ROOSTATS_ProofConfig
13 
14 
15 
16 
17 #ifndef ROOT_Rtypes
18 #include "Rtypes.h"
19 #endif
20 
21 #include "RooWorkspace.h"
22 #include "RooStudyManager.h"
23 
24 #include "TROOT.h"
25 
26 namespace RooStats {
27 
28 /**
29 
30 Holds configuration options for proof and proof-lite.
31 
32 This class will be expanded in the future to hold more specific configuration
33 options for the tools in RooStats.
34 
35 Access to TProof::Mgr for configuration is still possible as usual
36 (e.g. to set Root Version to be used on workers). You can do:
37 
38 * ``TProof::Mgr("my.server.url")->ShowROOTVersions()``
39 * ``TProof::Mgr("my.server.url")->SetROOTVersion("v5-27-06_dbg")``
40 
41 
42 See doc: http://root.cern.ch/drupal/content/changing-default-root-version
43 
44 \ingroup Roostats
45 
46 */
47 
48 
49 class ProofConfig {
50 
51  public:
52 
53  // configure proof with number of experiments and host session
54  // in case of Prooflite, it is better to define the number of workers as "worker=n" in the host string
55 
56  ProofConfig(RooWorkspace &w, Int_t nExperiments = 0, const char *host = "", Bool_t showGui = kFALSE) :
57  fWorkspace(w),
58  fNExperiments(nExperiments),
59  fHost(host),
60  fShowGui(showGui)
61  {
62 
63  // case of ProofLite
64  if (fHost == "" || fHost.Contains("lite") ) {
65  fLite = true;
66 
67 
68  // get the default value of the machine - use CINT inetrface until we have a poper PROOF interface that we can call
69  int nMaxWorkers = gROOT->ProcessLineFast("TProofLite::GetNumberOfWorkers()");
70 
71  if (nExperiments == 0) {
72  fNExperiments = nMaxWorkers;
73  }
74 
75  if (nExperiments > nMaxWorkers)
76  std::cout << "ProofConfig - Warning: using a number of workers = " << nExperiments << " which is larger than the number of cores in the machine "
77  << nMaxWorkers << std::endl;
78 
79  // set the number of workers in the Host string
80  fHost = TString::Format("workers=%d",fNExperiments);
81  }
82  else {
83  fLite = false;
84  // have always a default number of experiments
85  if (nExperiments == 0) fNExperiments = 8;
86  }
87  }
88 
89 
90  virtual ~ProofConfig() {
92  }
93 
94  /// close all proof connections
95  static void CloseProof(Option_t *option = "s") { RooStudyManager::closeProof(option); }
96 
97  // returns fWorkspace
98  RooWorkspace& GetWorkspace(void) const { return fWorkspace; }
99  // returns fHost
100  const char* GetHost(void) const { return fHost; }
101  // return fNExperiments
102  Int_t GetNExperiments(void) const { return fNExperiments; }
103  // return fShowGui
104  Bool_t GetShowGui(void) const { return fShowGui; }
105  // return true if it is a Lite session (ProofLite)
106  Bool_t IsLite() const { return fLite; }
107 
108  protected:
109  RooWorkspace& fWorkspace; // workspace that is to be used with the RooStudyManager
110  Int_t fNExperiments; // number of experiments. This is sometimes called "events" in proof; "experiments" in RooStudyManager.
111  TString fHost; // Proof hostname. Use empty string (ie "") for proof-lite. Can also handle options like "workers=2" to run on two nodes.
112  Bool_t fShowGui; // Whether to show the Proof Progress window.
113  Bool_t fLite; // Whether we have a Proof Lite session
114 
115  protected:
116  ClassDef(ProofConfig,1) // Configuration options for proof.
117 };
118 }
119 
120 
121 #endif
virtual ~ProofConfig()
Definition: ProofConfig.h:90
Holds configuration options for proof and proof-lite.
Definition: ProofConfig.h:49
static void closeProof(Option_t *option="s")
"Option_t *option" takes the parameters forwarded to gProof->Close(option).
const char Option_t
Definition: RtypesCore.h:62
RooWorkspace & GetWorkspace(void) const
Definition: ProofConfig.h:98
#define gROOT
Definition: TROOT.h:340
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t GetNExperiments(void) const
Definition: ProofConfig.h:102
RooWorkspace & fWorkspace
Definition: ProofConfig.h:109
#define ClassDef(name, id)
Definition: Rtypes.h:254
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
Definition: TString.cxx:2334
ProofConfig(RooWorkspace &w, Int_t nExperiments=0, const char *host="", Bool_t showGui=kFALSE)
Definition: ProofConfig.h:56
Namespace for the RooStats classes.
Definition: Asimov.h:20
Bool_t GetShowGui(void) const
Definition: ProofConfig.h:104
Bool_t IsLite() const
Definition: ProofConfig.h:106
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition: TString.h:567
const char * GetHost(void) const
Definition: ProofConfig.h:100
static void CloseProof(Option_t *option="s")
close all proof connections
Definition: ProofConfig.h:95