]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/Reve/RMacro.cxx
Missing initialization; fiddle with the track marker-style a bit more.
[u/mrichter/AliRoot.git] / EVE / Reve / RMacro.cxx
1 // $Header$
2
3 #include "RMacro.h"
4
5 #include <TSystem.h>
6 #include <TROOT.h>
7 #include <G__ci.h>
8
9 using namespace Reve;
10
11 //______________________________________________________________________
12 // RMacro
13 //
14 // Sub-class of TMacro, overriding Exec to unload the previous verison
15 // and cleanup after the execution.
16
17 ClassImp(RMacro)
18
19 RMacro::RMacro() : TMacro() {}
20
21 RMacro::RMacro(const RMacro& m) : TMacro(m) {}
22
23 RMacro::RMacro(const char* name) :
24   TMacro()
25 {
26   if (!name) return;
27
28   fTitle = name;
29
30   char *dot   = (char*)strrchr(name, '.');
31   char *slash = (char*)strrchr(name, '/');
32   if (dot) *dot = 0;
33   if (slash) fName = slash + 1;
34   else       fName = name;
35
36   ReadFile(fTitle);
37 }
38
39 /**************************************************************************/
40
41 #include <TTimer.h>
42
43 void RMacro::Exec(const char* params)
44 {
45   if(Reve::CheckMacro(fTitle.Data()))
46     G__unloadfile(fTitle.Data());
47
48   // Copy from TMacro::Exec. Difference is that the file is really placed
49   // into the /tmp.
50   TString fname = "/tmp/";
51   {
52     //the current implementation uses a file in the current directory.
53     //should be replaced by a direct execution from memory by CINT
54     fname += GetName();
55     fname += ".C";
56     SaveSource(fname);
57     //disable a possible call to gROOT->Reset from the executed script
58     gROOT->SetExecutingMacro(kTRUE);
59     //execute script in /tmp
60     TString exec = ".x " + fname;
61     TString p = params;
62     if (p == "") p = fParams;
63     if (p != "")
64       exec += "(" + p + ")";
65     Int_t exit;
66     gROOT->ProcessLine(exec, &exit);
67     //enable gROOT->Reset
68     gROOT->SetExecutingMacro(kFALSE);
69     //delete the temporary file
70     gSystem->Unlink(fname);
71   }
72
73   G__unloadfile(fname);
74
75   // In case an exception was thrown (which i do not know how to detect
76   // the execution of next macros does not succeed.
77   // However strange this might seem, this solves the problem.
78   TTimer::SingleShot(100, "Reve::RMacro", this, "ResetRoot()");
79 }
80
81 #include <TApplication.h>
82
83 void RMacro::ResetRoot()
84 {
85   // printf ("RMacro::ResetRoot doing 'gROOT->Reset()'.\n");
86   gROOT->GetApplication()->ProcessLine("gROOT->Reset()");
87 }