1 #include "AliMUONMchViewApplication.h"
3 #include "AliCDBManager.h"
4 #include "AliCodeTimer.h"
6 #include "AliMUONPainterDataSourceFrame.h"
7 #include "AliMUONPainterHelper.h"
8 #include "AliMUONPainterMasterFrame.h"
9 #include "AliMUONPainterRegistry.h"
10 #include "AliMUONVTrackerData.h"
11 #include <Riostream.h>
16 #include <TGFileDialog.h>
24 /// \class AliMUONMchViewApplication
26 /// Main class for the mchview program
28 ///\author Laurent Aphecetche, Subatech
31 ClassImp(AliMUONMchViewApplication)
34 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
35 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
36 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
37 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
39 const char* AliMUONMchViewApplication::fgkFileTypes[] = {
40 "ROOT files", "*.root",
44 //______________________________________________________________________________
45 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
46 int* argc, char** argv,
49 : TRint(name,argc,argv),
51 fPainterMasterFrame(0x0)
55 /// wfraction,hfraction are the fractions of display width and height
56 /// we want to draw on
58 UInt_t dw = gClient->GetDisplayWidth();
59 UInt_t dh = gClient->GetDisplayHeight();
61 UInt_t w = (UInt_t)(wfraction*dw);
62 UInt_t h = (UInt_t)(hfraction*dh);
64 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
70 // h -= 60; // menubar
72 TGTab* tabs = new TGTab(fMainFrame,w,h);
74 TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
77 new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
79 t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
81 t = tabs->AddTab("Data Sources");
83 AliMUONPainterDataSourceFrame* dsf =
84 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
86 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
88 fMainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
90 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
92 fMainFrame->MapSubwindows();
95 fPainterMasterFrame->Update();
97 fMainFrame->MapWindow();
99 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
101 UInt_t x = dw/2 - w/2;
104 fMainFrame->MoveResize(x, y, w, h);
105 fMainFrame->SetWMPosition(x, y);
107 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
109 cout << "***************************************************" << endl;
110 cout << " Welcome to mchview" << endl;
111 cout << " " << FullVersion() << endl;
112 cout << "***************************************************" << endl;
116 //______________________________________________________________________________
117 AliMUONMchViewApplication::~AliMUONMchViewApplication()
122 //______________________________________________________________________________
124 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
126 /// Create the application menu bar
128 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
130 file->AddEntry("&Open...",fgkFILEOPEN);
131 file->AddEntry("&Save As...",fgkFILESAVEAS);
132 file->AddEntry("&Print As...",fgkFILEPRINTAS);
133 file->AddEntry("&Exit",fgkFILEEXIT);
135 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
137 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
139 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
140 about->AddLabel(FullVersion());
142 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
143 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
146 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
148 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
151 //______________________________________________________________________________
153 AliMUONMchViewApplication::HandleMenu(Int_t i)
155 /// Handle the click of one menu item
176 //______________________________________________________________________________
178 AliMUONMchViewApplication::Open()
184 fileInfo.fFileTypes = fgkFileTypes;
186 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
189 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
192 //______________________________________________________________________________
194 AliMUONMchViewApplication::Open(const char* filename)
196 /// Open a given file containing saved VTrackerData objects
200 TList* keys = f.GetListOfKeys();
205 while ( ( k = static_cast<TKey*>(next()) ) )
207 TObject* object = k->ReadObj();
209 if ( object->InheritsFrom("AliMUONVTrackerData") )
211 AliMUONVTrackerData* data = static_cast<AliMUONVTrackerData*>(object);
214 AliMUONPainterRegistry::Instance()->Register(data);
221 //______________________________________________________________________________
223 AliMUONMchViewApplication::PrintAs()
229 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
232 fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
235 //______________________________________________________________________________
237 AliMUONMchViewApplication::Save()
239 /// Open "Save VTrackerData objects to file" dialog
243 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
246 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
249 //______________________________________________________________________________
251 AliMUONMchViewApplication::Save(const char* filename)
253 /// Save VTrackerData objects into file of given name
255 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
257 TFile f(filename,"RECREATE");
259 for ( Int_t i = 0; i < reg->NumberOfDataSources(); ++i )
261 AliMUONVTrackerData* data = reg->DataSource(i);