7 #include <TGeoManager.h>
11 #include <TInterpreter.h>
17 //______________________________________________________________________
23 Exc_t operator+(const Exc_t &s1, const std::string &s2)
24 { return Exc_t((std::string&)s1 + s2); }
26 Exc_t operator+(const Exc_t &s1, const TString &s2)
27 { return Exc_t((std::string&)s1 + s2.Data()); }
29 Exc_t operator+(const Exc_t &s1, const char *s2)
30 { return Exc_t((std::string&)s1 + s2); }
33 void WarnCaller(const TString& warning)
35 std::cout << "WRN: " << warning << std::endl;
38 void ColorFromIdx(Color_t ci, UChar_t* col)
40 TColor* c = gROOT->GetColor(ci);
42 col[0] = (UChar_t)(255*c->GetRed());
43 col[1] = (UChar_t)(255*c->GetGreen());
44 col[2] = (UChar_t)(255*c->GetBlue());
49 Color_t* FindColorVar(TObject* obj, const Text_t* varname)
51 static const Exc_t eH("Reve::FindColorVar");
53 Int_t off = obj->IsA()->GetDataMemberOffset(varname);
55 throw(eH + "could not find member '" + varname + "' in class " + obj->IsA()->GetName() + ".");
56 return (Color_t*) (((char*)obj) + off);
59 /**************************************************************************/
60 /**************************************************************************/
62 void SetupEnvironment()
64 // Check if REVESYS exists, try fallback to $ALICE_ROOT/EVE.
65 // Setup Include and Macro paths.
67 static const Exc_t eH("Reve::SetupEnvironment");
69 if(gSystem->Getenv("REVESYS") == 0) {
70 if(gSystem->Getenv("ALICE_ROOT") != 0) {
71 Info(eH.Data(), "setting REVESYS from ALICE_ROOT.");
72 gSystem->Setenv("REVESYS", Form("%s/EVE", gSystem->Getenv("ALICE_ROOT")));
74 Error(eH.Data(), "REVESYS not defined, neither is ALICE_ROOT.");
78 if(gSystem->AccessPathName(gSystem->Getenv("REVESYS")) == kTRUE) {
79 Error(eH.Data(), "REVESYS '%s' does not exist.", gSystem->Getenv("REVESYS"));
83 TString macPath(gROOT->GetMacroPath());
84 macPath += Form(":%s/macros", gSystem->Getenv("REVESYS"));
85 gInterpreter->AddIncludePath(gSystem->Getenv("REVESYS"));
86 if(gSystem->Getenv("ALICE_ROOT") != 0) {
87 macPath += Form(":%s/alice-macros", gSystem->Getenv("REVESYS"));
88 gInterpreter->AddIncludePath(Form("%s/include", gSystem->Getenv("ALICE_ROOT")));
89 gInterpreter->AddIncludePath(gSystem->Getenv("ALICE_ROOT"));
91 gROOT->SetMacroPath(macPath);
94 /**************************************************************************/
97 void ChompTail(TString& s, char c='.') {
104 void AssertMacro(const Text_t* mac)
106 // Load and execute macro 'mac' if it has not been loaded yet.
108 TString foo(mac); ChompTail(foo);
109 if(gROOT->GetGlobalFunction(foo.Data(), 0, true) == 0) {
114 void Macro(const Text_t* mac)
116 // Execute macro 'mac'. Do not reload the macro.
118 TString foo(mac); ChompTail(foo);
119 if(gROOT->GetGlobalFunction(foo.Data(), 0, true) == 0)
120 gROOT->LoadMacro(mac);
123 gROOT->ProcessLine(foo.Data());
126 void LoadMacro(const Text_t* mac)
128 // Makes sure that macro 'mac' is loaded, but do not reload it.
130 TString foo(mac); ChompTail(foo);
131 if(gROOT->GetGlobalFunction(foo.Data(), 0, true) == 0)
132 gROOT->LoadMacro(mac);
135 /**************************************************************************/
136 /**************************************************************************/
138 // Pad stack for RINT/GUI thread.
139 std::list<TVirtualPad*> s_Pad_Stack;
141 TVirtualPad* PushPad(TVirtualPad* new_gpad, Int_t subpad)
143 // printf("Reve::PushPad old=%p, new=%p\n", gPad, new_gpad);
144 s_Pad_Stack.push_back(gPad);
146 new_gpad->cd(subpad);
152 TVirtualPad* PopPad(Bool_t modify_update_p)
154 // printf("Reve::PopPad old=%p, new=%p\n", gPad, s_Pad_Stack.empty() ? 0 : s_Pad_Stack.back());
155 if(s_Pad_Stack.empty()) {
156 Warning("Reve::PopTPad", "stack empty.");
158 if(modify_update_p && gPad != 0) {
162 gPad = s_Pad_Stack.back();
163 s_Pad_Stack.pop_back();
168 /**************************************************************************/
170 /**************************************************************************/
172 GeoManagerHolder::GeoManagerHolder(TGeoManager* new_gmgr) :
173 fManager(gGeoManager)
175 gGeoManager = new_gmgr;
178 GeoManagerHolder::~GeoManagerHolder()
180 gGeoManager = fManager;