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