1 |
loizides |
1.1 |
// $Id: setRootEnv.C 4721 2007-11-14 18:01:08Z loizides $
|
2 |
|
|
|
3 |
|
|
#if !defined(__CINT__) || defined(__MAKECINT__)
|
4 |
|
|
#include <Riostream.h>
|
5 |
|
|
#include <TEnv.h>
|
6 |
|
|
#include <TString.h>
|
7 |
|
|
#include <TSystem.h>
|
8 |
|
|
#include <TRegexp.h>
|
9 |
|
|
#include <TROOT.h>
|
10 |
|
|
#include <TFile.h>
|
11 |
|
|
#include <TClass.h>
|
12 |
|
|
#include <TClassTable.h>
|
13 |
|
|
#include <TInterpreter.h>
|
14 |
|
|
#include <TRandom3.h>
|
15 |
|
|
#include <TError.h>
|
16 |
|
|
#include <TStyle.h>
|
17 |
|
|
#endif
|
18 |
|
|
|
19 |
|
|
void setRootEnv()
|
20 |
|
|
{
|
21 |
|
|
gSystem->AddIncludePath("-I$CMSSW_BASE/src/ -I$CMSSW_BASE/src/MitAna/TreeMod/inc");
|
22 |
|
|
gSystem->AddIncludePath("-I$CMSSW_BASE/src/MitAna/macros");
|
23 |
|
|
gInterpreter->AddIncludePath(TString(gSystem->Getenv("CMSSW_BASE"))+"/src/");
|
24 |
|
|
gInterpreter->AddIncludePath(TString(gSystem->Getenv("CMSSW_BASE"))+"/src/MitAna/TreeMod/inc");
|
25 |
|
|
gInterpreter->AddIncludePath(TString(gSystem->Getenv("CMSSW_BASE"))+"/src/MitAna/macros");
|
26 |
|
|
gROOT->SetMacroPath(TString(gROOT->GetMacroPath())
|
27 |
|
|
+TString(gSystem->Getenv("CMSSW_BASE"))+"/src/MitAna/macros");
|
28 |
|
|
|
29 |
|
|
if (1) { // load libs
|
30 |
|
|
TDirectory::TContext context(0); // automatically restore gDirectory
|
31 |
|
|
if(1) {
|
32 |
|
|
|
33 |
|
|
TString libstr(Form("%s/lib/%s",
|
34 |
|
|
gSystem->Getenv("CMSSW_BASE"),
|
35 |
|
|
gSystem->Getenv("SCRAM_ARCH")));
|
36 |
|
|
|
37 |
|
|
void *dir = gSystem->OpenDirectory(libstr.Data());
|
38 |
|
|
if(1) {
|
39 |
|
|
TRegexp re("libMitAna*.so", kTRUE);
|
40 |
|
|
TRegexp reignore("libMitAnalysis*.so", kTRUE);
|
41 |
|
|
while(const char *direntry=gSystem->GetDirEntry(dir) ) {
|
42 |
|
|
TString sdirentry(direntry);
|
43 |
|
|
if (sdirentry.Index(re) == kNPOS) {
|
44 |
|
|
continue;
|
45 |
|
|
}
|
46 |
|
|
if (sdirentry.Index(reignore) != kNPOS) {
|
47 |
|
|
continue;
|
48 |
|
|
}
|
49 |
|
|
Int_t len=strlen(direntry)-3;
|
50 |
|
|
if(len<=0) continue;
|
51 |
|
|
char *tmpstr = new char[len+1];
|
52 |
|
|
for(Int_t i=0;i<len;i++) tmpstr[i]=direntry[i];
|
53 |
|
|
tmpstr[len]='\0';
|
54 |
|
|
if (gInterpreter->IsLoaded(tmpstr)) {
|
55 |
|
|
if (gDebug) Warning("setRootEnv","Trying to load \"%s\", but it is already loaded", tmpstr);
|
56 |
|
|
} else {
|
57 |
|
|
if(gSystem->Load(tmpstr)<0) {
|
58 |
|
|
gROOT->Error("setRootEnv", "could not load \"%s\" for use in ACLiC", tmpstr);
|
59 |
|
|
} else {
|
60 |
|
|
if(gDebug) Info("setRootEnv","Loaded \"%s\" and its dependencies", tmpstr);
|
61 |
|
|
}
|
62 |
|
|
}
|
63 |
|
|
delete[] tmpstr;
|
64 |
|
|
}
|
65 |
|
|
gSystem->FreeDirectory(dir);
|
66 |
|
|
}
|
67 |
|
|
}
|
68 |
|
|
|
69 |
|
|
if(0) { // set some common gStyle settings
|
70 |
|
|
gStyle->SetPalette(1,0);
|
71 |
|
|
|
72 |
|
|
gStyle->SetPadColor(0);
|
73 |
|
|
gStyle->SetPadBorderSize(0);
|
74 |
|
|
gStyle->SetPadBorderMode(0);
|
75 |
|
|
gStyle->SetCanvasColor(0);
|
76 |
|
|
gStyle->SetCanvasBorderMode(0);
|
77 |
|
|
gStyle->SetCanvasBorderSize(0);
|
78 |
|
|
gStyle->SetFrameBorderMode(0);
|
79 |
|
|
gStyle->SetFrameLineColor(0);
|
80 |
|
|
gStyle->SetTitleColor(0);
|
81 |
|
|
gStyle->SetTitleBorderSize(0);
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
if(1) { // set a better default random generator
|
85 |
|
|
delete gRandom;
|
86 |
|
|
gRandom = new TRandom3;
|
87 |
|
|
gRandom->SetSeed(0);
|
88 |
|
|
}
|
89 |
|
|
|
90 |
|
|
if (gClassTable->GetID("mithep::Particle") >= 0) {
|
91 |
|
|
::Info("setRootEnv", "Welcome to MITROOT!\n");
|
92 |
|
|
}
|
93 |
|
|
}
|
94 |
|
|
}
|