7 #include <TGeoManager.h>
16 //______________________________________________________________________
22 Exc_t operator+(const Exc_t &s1, const std::string &s2)
23 { return Exc_t((std::string&)s1 + s2); }
25 Exc_t operator+(const Exc_t &s1, const TString &s2)
26 { return Exc_t((std::string&)s1 + s2.Data()); }
28 Exc_t operator+(const Exc_t &s1, const char *s2)
29 { return Exc_t((std::string&)s1 + s2); }
32 void WarnCaller(const TString& warning)
34 std::cout << "WRN: " << warning << std::endl;
37 void ColorFromIdx(Color_t ci, UChar_t* col)
39 TColor* c = gROOT->GetColor(ci);
41 col[0] = (UChar_t)(255*c->GetRed());
42 col[1] = (UChar_t)(255*c->GetGreen());
43 col[2] = (UChar_t)(255*c->GetBlue());
48 Color_t* FindColorVar(TObject* obj, const Text_t* varname)
50 static const Exc_t eH("Reve::FindColorVar");
52 Int_t off = obj->IsA()->GetDataMemberOffset(varname);
54 throw(eH + "could not find member '" + varname + "' in class " + obj->IsA()->GetName() + ".");
55 return (Color_t*) (((char*)obj) + off);
58 /**************************************************************************/
59 /**************************************************************************/
61 void SetupEnvironment()
63 // Check REVESYS exists, try fallback to $ALICE_ROOT/EVE.
65 static const Exc_t eH("Reve::SetupEnvironment");
67 if(gSystem->Getenv("REVESYS") == 0) {
68 if(gSystem->Getenv("ALICE_ROOT") != 0) {
69 Info(eH.Data(), "setting REVESYS from ALICE_ROOT.");
70 gSystem->Setenv("REVESYS", Form("%s/EVE", gSystem->Getenv("ALICE_ROOT")));
72 Error(eH.Data(), "REVESYS not defined, neither is ALICE_ROOT.");
76 if(gSystem->AccessPathName(gSystem->Getenv("REVESYS")) == kTRUE) {
77 Error(eH.Data(), "REVESYS '%s' does not exist.", gSystem->Getenv("REVESYS"));
82 /**************************************************************************/
85 void ChompTail(TString& s, char c='.') {
92 void AssertMacro(const Text_t* mac)
94 // Load and execute macro 'mac' if it has not been loaded yet.
96 TString foo(mac); ChompTail(foo);
97 if(gROOT->GetGlobalFunction(foo.Data(), 0, true) == 0) {
102 void Macro(const Text_t* mac)
104 // Execute macro 'mac'. Do not reload the macro.
106 TString foo(mac); ChompTail(foo);
107 if(gROOT->GetGlobalFunction(foo.Data(), 0, true) == 0)
108 gROOT->LoadMacro(mac);
111 gROOT->ProcessLine(foo.Data());
114 void LoadMacro(const Text_t* mac)
116 // Makes sure that macro 'mac' is loaded, but do not reload it.
118 TString foo(mac); ChompTail(foo);
119 if(gROOT->GetGlobalFunction(foo.Data(), 0, true) == 0)
120 gROOT->LoadMacro(mac);
123 /**************************************************************************/
124 /**************************************************************************/
126 // Pad stack for RINT/GUI thread.
127 std::list<TVirtualPad*> s_Pad_Stack;
129 TVirtualPad* PushPad(TVirtualPad* new_gpad, Int_t subpad)
131 // printf("Reve::PushPad old=%p, new=%p\n", gPad, new_gpad);
132 s_Pad_Stack.push_back(gPad);
134 new_gpad->cd(subpad);
140 TVirtualPad* PopPad(Bool_t modify_update_p)
142 // printf("Reve::PopPad old=%p, new=%p\n", gPad, s_Pad_Stack.empty() ? 0 : s_Pad_Stack.back());
143 if(s_Pad_Stack.empty()) {
144 Warning("Reve::PopTPad", "stack empty.");
146 if(modify_update_p && gPad != 0) {
150 gPad = s_Pad_Stack.back();
151 s_Pad_Stack.pop_back();
156 /**************************************************************************/
158 /**************************************************************************/
160 GeoManagerHolder::GeoManagerHolder(TGeoManager* new_gmgr) :
161 fManager(gGeoManager)
163 gGeoManager = new_gmgr;
166 GeoManagerHolder::~GeoManagerHolder()
168 gGeoManager = fManager;