1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "AliMUONMchViewApplication.h"
20 #include "AliCDBManager.h"
21 #include "AliCodeTimer.h"
23 #include "AliMUONPainterDataSourceFrame.h"
24 #include "AliMUONPainterEnv.h"
25 #include "AliMUONPainterHelper.h"
26 #include "AliMUONPainterMasterFrame.h"
27 #include "AliMUONPainterRegistry.h"
28 #include "AliMUONTrackerDataCompareDialog.h"
29 #include "AliMUONTrackerDataWrapper.h"
30 #include "AliMUONVTrackerData.h"
31 #include "AliMUONVTrackerDataMaker.h"
32 #include <Riostream.h>
37 #include <TGFileDialog.h>
40 #include <TGTextView.h>
48 /// \class AliMUONMchViewApplication
50 /// Main class for the mchview program
52 ///\author Laurent Aphecetche, Subatech
55 ClassImp(AliMUONMchViewApplication)
58 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
59 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
60 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
61 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
62 const Int_t AliMUONMchViewApplication::fgkABOUT(5);
63 const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
65 const char* AliMUONMchViewApplication::fgkFileTypes[] = {
66 "ROOT files", "*.root",
70 //______________________________________________________________________________
71 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
72 int* argc, char** argv,
75 : TRint(name,argc,argv),
77 fPainterMasterFrame(0x0)
81 /// wfraction,hfraction are the fractions of display width and height
82 /// we want to draw on
84 UInt_t dw = gClient->GetDisplayWidth();
85 UInt_t dh = gClient->GetDisplayHeight();
87 UInt_t w = (UInt_t)(wfraction*dw);
88 UInt_t h = (UInt_t)(hfraction*dh);
90 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
96 // h -= 60; // menubar
98 TGTab* tabs = new TGTab(fMainFrame,w,h);
100 TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
102 fPainterMasterFrame =
103 new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
105 t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
107 t = tabs->AddTab("Data Sources");
109 AliMUONPainterDataSourceFrame* dsf =
110 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
112 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
114 fMainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
116 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
118 fMainFrame->MapSubwindows();
119 fMainFrame->Resize();
121 fPainterMasterFrame->Update();
123 fMainFrame->MapWindow();
125 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
127 UInt_t x = dw/2 - w/2;
130 fMainFrame->MoveResize(x, y, w, h);
131 fMainFrame->SetWMPosition(x, y);
133 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
135 cout << "***************************************************" << endl;
136 cout << " Welcome to mchview" << endl;
137 cout << " " << FullVersion() << endl;
138 cout << "***************************************************" << endl;
142 //______________________________________________________________________________
143 AliMUONMchViewApplication::~AliMUONMchViewApplication()
148 //______________________________________________________________________________
150 AliMUONMchViewApplication::CompareData()
152 /// Launch compare data dialog
153 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
164 t->SetWindowName("mchview compare data tool");
165 t->SetIconName("mchview compare data tool");
171 //______________________________________________________________________________
173 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
175 /// Create the application menu bar
177 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
179 file->AddEntry("&Open...",fgkFILEOPEN);
180 file->AddEntry("&Save As...",fgkFILESAVEAS);
181 file->AddEntry("&Print As...",fgkFILEPRINTAS);
182 file->AddEntry("&Exit",fgkFILEEXIT);
184 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
186 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
187 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
189 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
190 about->AddEntry(FullVersion(),fgkABOUT);
192 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
193 about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
194 tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
196 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
197 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
198 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
200 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
202 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
205 //______________________________________________________________________________
207 AliMUONMchViewApplication::HandleMenu(Int_t i)
209 /// Handle the click of one menu item
236 //______________________________________________________________________________
238 AliMUONMchViewApplication::Open()
244 fileInfo.fFileTypes = fgkFileTypes;
246 delete[] fileInfo.fIniDir;
248 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
250 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
252 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
255 env->Set("LastOpenDir",fileInfo.fIniDir);
258 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
261 //______________________________________________________________________________
263 AliMUONMchViewApplication::Open(const char* filename)
265 /// Open a given file containing saved VTrackerDataMaker objects
267 TString sfilename(gSystem->ExpandPathName(filename));
269 if ( sfilename.Contains(TRegexp("^alien")) )
271 // insure we've initialized the grid...
274 TGrid::Connect("alien://");
278 TFile* f = TFile::Open(filename);
280 TList* keys = f->GetListOfKeys();
285 while ( ( k = static_cast<TKey*>(next()) ) )
287 TObject* object = k->ReadObj();
289 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
291 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
294 AliMUONPainterRegistry::Instance()->Register(maker);
298 if ( object->InheritsFrom("AliMUONVTrackerData") )
300 // this is for backward compatibility. Early versions of mchview
301 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
303 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
306 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
307 AliMUONPainterRegistry::Instance()->Register(maker);
316 //______________________________________________________________________________
318 AliMUONMchViewApplication::PrintAs()
324 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
327 fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
330 //______________________________________________________________________________
332 AliMUONMchViewApplication::ReleaseNotes()
334 /// Display release notes
339 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
341 TGTextView* rn = new TGTextView(t);
345 rn->AddLine("New features");
347 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
348 rn->AddLine(" when switching between views");
349 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
350 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
351 rn->AddLine(" clicking on it will display an histo");
352 rn->AddLine("- Right-click on a painter will now display several histogram options");
353 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
354 rn->AddLine(" and sigma");
355 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
356 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
357 rn->AddLine(" in order to compare data.");
358 rn->AddLine(" - The --use option can now reference alien files");
360 rn->AddLine("Bug fixes");
362 rn->AddLine("- Can now read Capacitances from OCDB");
364 rn->Resize(width,height);
366 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
375 t->SetWindowName("mchview release notes");
376 t->SetIconName("mchview release notes");
378 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
379 // kMWMDecorMinimize | kMWMDecorMenu,
380 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
382 // kMWMInputModeless);
385 // gClient->WaitFor(t);
388 //______________________________________________________________________________
390 AliMUONMchViewApplication::Save()
392 /// Open "Save VTrackerData objects to file" dialog
396 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
399 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
402 //______________________________________________________________________________
404 AliMUONMchViewApplication::Save(const char* filename)
406 /// Save VTrackerDataMaker objects into file of given name
408 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
410 TFile f(filename,"RECREATE");
412 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
414 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);