Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Config.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Joerg Stelzer, Fredrik Tegenfeldt, Helge Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : Config *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Implementation *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
16  * Fredrik Tegenfeldt <Fredrik.Tegenfeldt@cern.ch> - Iowa State U., USA *
17  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, GER *
18  * *
19  * Copyright (c) 2006: *
20  * CERN, Switzerland *
21  * Iowa State U., USA *
22  * MPI-K Heidelberg, Germany *
23  * *
24  * Redistribution and use in source and binary forms, with or without *
25  * modification, are permitted according to the terms listed in LICENSE *
26  * (http://mva.sourceforge.net/license.txt) *
27  **********************************************************************************/
28 
29 /*! \class TMVA::Config
30 \ingroup TMVA
31 
32 Singleton class for global configuration settings used by TMVA.
33 
34 */
35 
36 #include "TMVA/Config.h"
37 #include "TMVA/MsgLogger.h"
38 
39 #include "Rtypes.h"
40 #include "TString.h"
41 #include "TSystem.h"
42 #include "TROOT.h"
43 
44 ClassImp(TMVA::Config);
45 
46 #if __cplusplus > 199711L
47 std::atomic<TMVA::Config*> TMVA::Config::fgConfigPtr{ 0 };
48 #else
49 TMVA::Config* TMVA::Config::fgConfigPtr = 0;
50 #endif
51 
52 TMVA::Config& TMVA::gConfig() { return TMVA::Config::Instance(); }
53 
54 ////////////////////////////////////////////////////////////////////////////////
55 /// constructor - set defaults
56 
57 TMVA::Config::Config() :
58  fDrawProgressBar ( kFALSE ),
59  fNWorkers (1),
60  fUseColoredConsole ( kTRUE ),
61  fSilent ( kFALSE ),
62  fWriteOptionsReference( kFALSE ),
63  fLogger (new MsgLogger("Config"))
64 {
65  // plotting
66  fVariablePlotting.fTimesRMS = 8.0;
67  fVariablePlotting.fNbins1D = 40;
68  fVariablePlotting.fNbins2D = 300;
69  fVariablePlotting.fMaxNumOfAllowedVariables = 200;
70  fVariablePlotting.fMaxNumOfAllowedVariablesForScatterPlots = 20;
71 
72  fVariablePlotting.fNbinsMVAoutput = 40;
73  fVariablePlotting.fNbinsXOfROCCurve = 100;
74  fVariablePlotting.fUsePaperStyle = 0;
75 
76  // IO names
77  fIONames.fWeightFileDirPrefix = "";
78  fIONames.fWeightFileDir = "weights";
79  fIONames.fWeightFileExtension = "weights";
80  fIONames.fOptionsReferenceFileDir = "optionInfo";
81 
82 }
83 
84 ////////////////////////////////////////////////////////////////////////////////
85 /// destructor
86 
87 TMVA::Config::~Config()
88 {
89  delete fLogger;
90 }
91 
92 ////////////////////////////////////////////////////////////////////////////////
93 /// static function: destroy TMVA instance
94 
95 void TMVA::Config::DestroyInstance()
96 {
97 #if __cplusplus > 199711L
98  delete fgConfigPtr.exchange(0);
99 #else
100  if (fgConfigPtr != 0) { delete fgConfigPtr; fgConfigPtr = 0;}
101 #endif
102 }
103 
104 ////////////////////////////////////////////////////////////////////////////////
105 /// static function: returns TMVA instance
106 
107 TMVA::Config& TMVA::Config::Instance()
108 {
109 #if __cplusplus > 199711L
110  if(!fgConfigPtr) {
111  TMVA::Config* tmp = new Config();
112  TMVA::Config* expected = 0;
113  if(! fgConfigPtr.compare_exchange_strong(expected,tmp) ) {
114  //another thread beat us to the switch
115  delete tmp;
116  }
117  }
118  return *fgConfigPtr;
119 #else
120  return fgConfigPtr ? *fgConfigPtr :*(fgConfigPtr = new Config());
121 #endif
122 }