]> git.uio.no Git - u/mrichter/AliRoot.git/blob - macros/display.C
Adding presentation style (T.Kuhr)
[u/mrichter/AliRoot.git] / macros / display.C
1 // This macro displays the hits belonging to a track for selected detectors
2 // Input: in the tracks contains the interesting tracks
3 //        ntracks is the number of interesing tracks
4 //        The default values correspond to "Show everything"
5 // Note: For the moment it works only with HIJING events, the PYTHIA is 
6 //       still not supported 
7 void display (const char *filename="galice.root",Int_t nevent=0, Int_t * tracks=0, Int_t ntracks=0) {
8 // Dynamically link some shared libs
9    if (gClassTable->GetID("AliRun") < 0) {
10       gROOT->LoadMacro("loadlibs.C");
11       loadlibs();
12    } else {
13       delete gAlice->GetRunLoader();
14       delete gAlice;
15       gAlice = 0;
16    }
17       
18 // Connect the Root Galice file containing Geometry, Kine and Hits
19    AliRunLoader *rl = 0x0;
20    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename);
21    if(file){
22      cout<<"galice.root is already open \n";
23    }
24
25    
26    rl = AliRunLoader::Open(filename,"DISPLAYED EVENT");
27    
28    if (rl == 0x0)
29     {
30       cerr<<"Error <display.C()>: can not get Run Loader. Exiting"<<endl;
31       return;
32     }
33 // Get AliRun object from file or create it if not on file
34
35    rl->LoadgAlice();
36  
37    gAlice = rl->GetAliRun();
38    if (!gAlice) {
39     cerr<<"AliTPCHits2Digits.C : AliRun object not found on file\n";
40     return;
41   }
42     
43 // Create Event Display object
44    AliDisplay *edisplay = new AliDisplay(750);
45    if (ntracks>0) edisplay->SetTracksToDisplay(tracks, ntracks);
46
47 // Display the requested event
48    rl->GetEvent(nevent);
49    rl->LoadKinematics();
50    rl->LoadHeader();
51    rl->LoadHits();
52
53    AliDisplay *edisplay = new AliDisplay(750);
54    
55    edisplay->ShowNextEvent(0);
56
57 // Define the buttons to switch on/off the existing modules
58    Float_t nodet=0.;
59    TObjArray *moduli = gAlice->Modules();
60    Int_t nomod=moduli->GetEntriesFast();
61    AliModule *modu;
62    for (Int_t j=0; j<nomod; j++){
63      modu=(AliModule*)moduli->At(j);
64      char *avoid=strstr("BODY MAG ABSO DIPO HALL FRAME SHIL PIPE",modu->GetName());
65      if(avoid)continue;
66      nodet++;
67    }
68    TDialogCanvas *dialog = new TDialogCanvas("Modules"," ",150,30*nodet);
69    Float_t yval1=1./nodet*0.9*0.05;
70    Float_t yval2=1./nodet*0.9*0.95;
71    char action[50];
72    char title[30];
73    char bname[30];
74    TButton *butto1;
75    for (Int_t j=0; j<nomod; j++){
76      modu=(AliModule*)moduli->At(j);
77      char *avoid=strstr(" BODY MAG ABSO DIPO HALL FRAME SHIL PIPE",modu->GetName());
78      if(avoid)continue;
79      sprintf(action,"swioff(\"%s\")",modu->GetName());
80      sprintf(title,"%s is on",modu->GetName());
81      sprintf(bname,"but%s",modu->GetName());
82      butto1 = new TButton(title,action,.05,yval1,.95,yval2);
83      butto1->SetName(bname);
84      butto1->SetFillColor(3);
85      butto1->Draw();
86      yval1+=1./nodet;
87      yval2+=1./nodet;
88    }
89
90
91 void swioff(const char *dete){
92   gAlice->Display()->DisableDetector(dete);
93   gAlice->Display()->Pad()->Modified();
94   gAlice->Display()->Pad()->Update();
95   char bname[30];
96   char action[50];
97   char title[30];
98   sprintf(bname,"but%s",dete);
99   TDialogCanvas *dia = (TDialogCanvas *)gROOT->FindObject("Modules");
100   TButton *bt = (TButton *)dia->FindObject(bname);
101   bt->SetFillColor(2);
102   sprintf(action,"swion(\"%s\")",dete);
103   bt->SetMethod(action);
104   sprintf(title,"%s is off",dete);
105   bt->SetTitle(title);
106   dia->Draw();
107 }
108
109 void swion(const char *dete){
110   gAlice->Display()->EnableDetector(dete);
111   gAlice->Display()->Pad()->Modified();
112   gAlice->Display()->Pad()->Update();
113   TDialogCanvas *dia = (TDialogCanvas *)gROOT->FindObject("Modules");
114   char bname[30];
115   char action[50];
116   char title[30];
117   sprintf(bname,"but%s",dete);
118   TButton *bt = (TButton *)dia->FindObject(bname);
119   bt->SetFillColor(3);
120   sprintf(action,"swioff(\"%s\")",dete);
121   bt->SetMethod(action);
122   sprintf(title,"%s is on",dete);
123   bt->SetTitle(title);
124   dia->Draw();
125 }
126