]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mchview.cxx
Move contents of EVE/Alieve to EVE/EveDet as most code will remain there.
[u/mrichter/AliRoot.git] / MUON / mchview.cxx
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 *                                                                        *
4 * Author: The ALICE Off-line Project.                                    *
5 * Contributors are mentioned in the code where appropriate.              *
6 *                                                                        *
7 * Permission to use, copy, modify and distribute this software and its   *
8 * documentation strictly for non-commercial purposes is hereby granted   *
9 * without fee, provided that the above copyright notice appears in all   *
10 * copies and that both the copyright notice and this permission notice   *
11 * appear in the supporting documentation. The authors make no claims     *
12 * about the suitability of this software for any purpose. It is          *
13 * provided "as is" without express or implied warranty.                  *
14 **************************************************************************/
15
16 // $Id$
17
18 /// \ingroup graphics
19 /// \file mchview.cxx
20 /// \brief Tracker visualization program
21 ///
22 /// \author Laurent Aphecetche, Subatech
23
24
25 #include "AliMUONPainterDataSourceFrame.h"
26 #include "AliMUONPainterHelper.h"
27 #include "AliMUONPainterMasterFrame.h"
28 #include "AliMUONPainterRegistry.h"
29 #include "AliCDBManager.h"
30 #include "AliCodeTimer.h"
31 #include "AliLog.h"
32 #include <Riostream.h>
33 #include <TCanvas.h>
34 #include <TEnv.h>
35 #include <TGMenu.h>
36 #include <TGTab.h>
37 #include <TROOT.h>
38 #include <TRint.h>
39 #include <TString.h>
40 #include <TStyle.h>
41
42 //_____________________________________________________________________________
43 void CreateMenuBar(TRint* app, TGMainFrame* mainFrame, UInt_t w)
44 {
45   /// Create the menu bar of the program
46
47   TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
48   
49   file->AddEntry("&Exit",1);
50   
51   file->Connect("Activated(Int_t)","TRint",app,"Terminate()");
52
53   TGMenuBar* bar = new TGMenuBar(mainFrame,w);
54   
55   bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
56   
57   mainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
58   
59   AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
60 }
61
62
63 int main(int argc, char** argv)
64 {
65   /// Main function for the program
66
67   AliWarningGeneral("main","Remove default storage and run number from here...");
68   
69   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
70   AliCDBManager::Instance()->SetRun(0);
71   
72   TRint *theApp = new TRint("mchview", &argc, argv);
73
74   gROOT->SetStyle("Plain");
75   
76   gStyle->SetPalette(1);
77   
78   Int_t n = gStyle->GetNumberOfColors();
79   
80   Int_t* colors = new Int_t[n+2];
81   
82   for ( Int_t i = 1; i <= n; ++i )
83   {
84     colors[i] = gStyle->GetColorPalette(i-1);
85   }
86   
87   colors[0] = 0;
88   colors[n+1] = 1;
89   
90   gStyle->SetPalette(n+2,colors);
91   
92   delete[] colors;
93   
94   UInt_t dw = gClient->GetDisplayWidth(); 
95   UInt_t dh = gClient->GetDisplayHeight(); 
96   
97   UInt_t w = (UInt_t)(0.7*dw);
98   UInt_t h = (UInt_t)(0.90*dh);
99     
100   TGMainFrame* mainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
101   
102   const Int_t kbs = 2;
103   
104   CreateMenuBar(theApp,mainFrame,w);
105
106 //  h -= 60; // menubar
107   
108   TGTab* tabs = new TGTab(mainFrame,w,h);
109   
110   TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
111
112   AliMUONPainterMasterFrame* pf = 
113     new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
114   
115   t->AddFrame(pf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
116
117   t = tabs->AddTab("Data Sources");
118   
119   AliMUONPainterDataSourceFrame* dsf = 
120     new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
121   
122   t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
123   
124   mainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
125
126   mainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
127
128   mainFrame->MapSubwindows();
129   mainFrame->Resize();
130   mainFrame->MapWindow();
131   
132   mainFrame->Connect("CloseWindow()","TRint",theApp,"Terminate()");
133   
134   UInt_t x = dw/2 - w/2;
135   UInt_t y = 0;
136   
137   mainFrame->MoveResize(x, y, w, h); 
138   mainFrame->SetWMPosition(x, y);
139   
140   mainFrame->SetWMSizeHints(w,h,w,h,0,0);
141
142   AliCodeTimer::Instance()->Print();
143
144   // --- Start the event loop ---
145   theApp->Run(kTRUE);
146
147   AliMUONPainterHelper::Instance()->Save();
148 }