LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
evdb::RootEnv Class Reference

Configure the ROOT environment. More...

#include "RootEnv.h"

Public Member Functions

 RootEnv (int argc, char **argv)
 
 ~RootEnv ()
 
int Run ()
 

Private Member Functions

void SetStyle ()
 
void InterpreterConfig ()
 
void SignalConfig ()
 
void LoadIncludes ()
 
void LoadClasses ()
 

Detailed Description

Configure the ROOT environment.

Definition at line 14 of file RootEnv.h.

Constructor & Destructor Documentation

evdb::RootEnv::RootEnv ( int  argc,
char **  argv 
)

Definition at line 30 of file RootEnv.cxx.

References InterpreterConfig(), LoadClasses(), LoadIncludes(), SetStyle(), and SignalConfig().

31  {
32  //======================================================================
33  // Setup the root environment for a program started with command line
34  // options argc and argv
35  //======================================================================
36  TApplication* app = ROOT::GetROOT()->GetApplication();
37 
38  // ROOT::GetROOT() should initialize gROOT.
39  if(!gROOT)
40  throw cet::exception("RootEnv") << "No ROOT global pointer";
41 
42  if (app == 0) {
43  int largc = 0;
44  char** largv = 0;
45  TRint* rapp = new TRint("TAPP",&largc, largv, 0, 0, kTRUE);
46 
47  // std::string p = gSystem->BaseName(argv[0]); p+= " [%d] ";
48  rapp->SetPrompt("evd [%d] ");
49  }
50  else {
51  gROOT->SetBatch(kFALSE);
52  if (gClient==0) {
53  gSystem->Load("libGX11.so");
54  gVirtualX = new TGX11("X11","X11 session");
55  new TGClient(getenv("DISPLAY"));
56  }
57  }
58 
59  this->SetStyle();
60  this->SignalConfig();
61  this->InterpreterConfig();
62  this->LoadIncludes();
63  this->LoadClasses();
64  }
void LoadIncludes()
Definition: RootEnv.cxx:132
void SetStyle()
Definition: RootEnv.cxx:209
void SignalConfig()
Definition: RootEnv.cxx:104
void InterpreterConfig()
Definition: RootEnv.cxx:91
void LoadClasses()
Definition: RootEnv.cxx:191
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
evdb::RootEnv::~RootEnv ( )

Definition at line 68 of file RootEnv.cxx.

69  {
70  // ROOT takes care of the following delete so don't do it twice
71  // if (fTheApp) { delete fTheApp; fTheApp = 0; }
72  }

Member Function Documentation

void evdb::RootEnv::InterpreterConfig ( )
private

Definition at line 91 of file RootEnv.cxx.

Referenced by RootEnv().

92  {
93  //======================================================================
94  // Configure the root interpreter
95  //======================================================================
96  if (gInterpreter) { // gInterpreter from TInterpreter.h
97  gInterpreter->SaveContext();
98  gInterpreter->SaveGlobalsContext();
99  }
100  }
void evdb::RootEnv::LoadClasses ( )
private

Definition at line 191 of file RootEnv.cxx.

Referenced by RootEnv().

192  {
193  //======================================================================
194  // Load classes to make the root session more covenient
195  //======================================================================
196  if (gROOT) {
197  gROOT->LoadClass("TGeometry", "Graf3d");
198  gROOT->LoadClass("TTree", "Tree");
199  gROOT->LoadClass("TMatrix", "Matrix");
200  gROOT->LoadClass("TMinuit", "Minuit");
201  gROOT->LoadClass("TPostScript", "Postscript");
202  gROOT->LoadClass("TCanvas", "Gpad");
203  gROOT->LoadClass("THtml", "Html");
204  }
205  }
void evdb::RootEnv::LoadIncludes ( )
private

Definition at line 132 of file RootEnv.cxx.

Referenced by RootEnv().

133  {
134  //======================================================================
135  // Load include files to make the root session more covenient
136  //======================================================================
137  TApplication* app = gROOT->GetApplication();
138  if (app) {
139  // Load a set of useful C++ includes.
140  // app->ProcessLine("#include <iostream>"); // Root gets this one itself
141  app->ProcessLine("#include <iomanip>");
142  app->ProcessLine("#include <string>");
143 
144  // Load experiment include files
145  // Have to be careful here, not every experiment uses
146  // SRT, so don't try to load the SRT macro paths
147  // if SRT variables aren't defined.
148  std::string mp = gROOT->GetMacroPath();
149  std::string ip;
150  const char* p;
151  bool srtPrivate = false;
152  bool srtPublic = false;
153  p = gSystem->Getenv("SRT_PRIVATE_CONTEXT");
154  if (p) {
155  srtPrivate = true;
156  mp += ":";
157  mp += p;
158  mp += ":";
159  mp += p;
160  mp += "/macros";
161  ip += " -I";
162  ip += p;
163 
164  std::string dip = ".include ";
165  dip += gSystem->Getenv("SRT_PRIVATE_CONTEXT");
166  gROOT->ProcessLine(dip.c_str());
167  }
168  p = gSystem->Getenv("SRT_PUBLIC_CONTEXT");
169  if (p) {
170  srtPublic = true;
171  mp += ":";
172  mp += p;
173  mp += "/macros";
174  ip += " -I";
175  ip += p;
176 
177  std::string dip = ".include ";
178  dip += gSystem->Getenv("SRT_PUBLIC_CONTEXT");
179  gROOT->ProcessLine(dip.c_str());
180  }
181 
182  if(srtPublic || srtPrivate){
183  gROOT->SetMacroPath(mp.c_str());
184  gSystem->SetIncludePath(ip.c_str());
185  }
186  }
187  }
int evdb::RootEnv::Run ( )

Definition at line 76 of file RootEnv.cxx.

77  {
78  //======================================================================
79  // Turn control of the application over to ROOT's event loop
80  //======================================================================
81  TApplication* app = ROOT::GetROOT()->GetApplication();
82  if (app) {
83  app->Run(kFALSE); // kTRUE == "Return from run" request...
84  return 1;
85  }
86  return 0;
87  }
void evdb::RootEnv::SetStyle ( )
private

Definition at line 209 of file RootEnv.cxx.

Referenced by RootEnv().

210  {
211  gROOT->SetStyle("Plain");
212 
213  // Set Line Widths
214  gStyle->SetFrameLineWidth(1);
215  gStyle->SetFuncWidth(1);
216  gStyle->SetHistLineWidth(1);
217 
218  gStyle->SetFuncColor(2);
219  gStyle->SetGridColor(18);
220  gStyle->SetGridStyle(1);
221  // SetGridWidth expects a short, the default value is 1, just use that
222  gStyle->SetGridWidth();
223 
224  // Set margins -- I like to shift the plot a little up and to the
225  // right to make more room for axis labels
226  gStyle->SetPadTopMargin(0.08);
227  gStyle->SetPadBottomMargin(0.36);
228  gStyle->SetPadRightMargin(0.03);
229  gStyle->SetPadLeftMargin(0.10);
230 
231  // Set fonts
232  gStyle->SetTextFont(132);
233  gStyle->SetLabelFont(132,"XYZ");
234  gStyle->SetStatFont(132);
235  gStyle->SetTitleFont(132,"XYZ");
236 
237  gStyle->SetStatFontSize(0.07);
238  gStyle->SetTitleFontSize(0.07);
239  gStyle->SetLabelSize(0.07,"XYZ");
240  gStyle->SetTitleSize(0.07,"XYZ");
241  gStyle->SetTextSize(0.07);
242 
243  gStyle->SetStatW(0.19);
244  gStyle->SetStatX(0.90);
245  gStyle->SetStatY(0.90);
246  gStyle->SetOptTitle(0);
247  gStyle->SetOptStat(0);
248 
249  // Set tick marks and turn off grids
250  gStyle->SetNdivisions(510,"XYZ");
251  gStyle->SetPadTickX(1);
252  gStyle->SetPadTickY(1);
253 
254  // Set paper size for life in the US
255  gStyle->SetPaperSize(TStyle::kUSLetter);
256  gStyle->SetPalette(1);
257 
258  // Force this style on all histograms
259  gROOT->ForceStyle();
260  }
void evdb::RootEnv::SignalConfig ( )
private

Definition at line 104 of file RootEnv.cxx.

Referenced by RootEnv().

105  {
106  //======================================================================
107  // Configure root's signale handlers
108  //======================================================================
109  return;
110  if (gSystem) { // gSystem from TSystem.h
111  // Reset ROOT's signal handling to the defaults...
112  gSystem->ResetSignal(kSigBus, kTRUE);
113  gSystem->ResetSignal(kSigSegmentationViolation,kTRUE);
114  gSystem->ResetSignal(kSigSystem, kTRUE);
115  gSystem->ResetSignal(kSigPipe, kTRUE);
116  gSystem->ResetSignal(kSigIllegalInstruction, kTRUE);
117  gSystem->ResetSignal(kSigQuit, kTRUE);
118  gSystem->ResetSignal(kSigInterrupt, kTRUE);
119  gSystem->ResetSignal(kSigWindowChanged, kTRUE);
120  gSystem->ResetSignal(kSigAlarm, kTRUE);
121  gSystem->ResetSignal(kSigChild, kTRUE);
122  gSystem->ResetSignal(kSigUrgent, kTRUE);
123  gSystem->ResetSignal(kSigFloatingException, kTRUE);
124  gSystem->ResetSignal(kSigTermination, kTRUE);
125  gSystem->ResetSignal(kSigUser1, kTRUE);
126  gSystem->ResetSignal(kSigUser2, kTRUE);
127  }
128  }

The documentation for this class was generated from the following files: