]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONMchViewApplication.cxx
In AliMUONTrackReconstructorK:
[u/mrichter/AliRoot.git] / MUON / AliMUONMchViewApplication.cxx
CommitLineData
bf4d93eb 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
90037e4e 18#include "AliMUONMchViewApplication.h"
19
20#include "AliCDBManager.h"
21#include "AliCodeTimer.h"
22#include "AliLog.h"
8f0acce4 23#include "AliMUONPainterDataRegistry.h"
90037e4e 24#include "AliMUONPainterDataSourceFrame.h"
49419555 25#include "AliMUONPainterEnv.h"
90037e4e 26#include "AliMUONPainterHelper.h"
27#include "AliMUONPainterMasterFrame.h"
28#include "AliMUONPainterRegistry.h"
49419555 29#include "AliMUONTrackerDataCompareDialog.h"
30#include "AliMUONTrackerDataWrapper.h"
90037e4e 31#include "AliMUONVTrackerData.h"
49419555 32#include "AliMUONVTrackerDataMaker.h"
90037e4e 33#include <Riostream.h>
34#include <TCanvas.h>
35#include <TEnv.h>
36#include <TFile.h>
37#include <TGClient.h>
38#include <TGFileDialog.h>
39#include <TGMenu.h>
40#include <TGTab.h>
49419555 41#include <TGTextView.h>
42#include <TGrid.h>
90037e4e 43#include <TKey.h>
44#include <TList.h>
49419555 45#include <TRegexp.h>
90037e4e 46#include <TString.h>
47#include <TSystem.h>
48
49/// \class AliMUONMchViewApplication
50///
51/// Main class for the mchview program
52///
53///\author Laurent Aphecetche, Subatech
54
55/// \cond CLASSIMP
56ClassImp(AliMUONMchViewApplication)
57/// \endcond CLASSIMP
58
59const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
60const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
61const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
10eb3d17 62const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
49419555 63const Int_t AliMUONMchViewApplication::fgkABOUT(5);
64const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
10eb3d17 65
66const char* AliMUONMchViewApplication::fgkFileTypes[] = {
67 "ROOT files", "*.root",
68 "All files", "*",
69 0, 0 };
90037e4e 70
71//______________________________________________________________________________
72AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
73 int* argc, char** argv,
1ffbeb9d 74 UInt_t w, UInt_t h,
75 UInt_t ox, UInt_t oy)
90037e4e 76: TRint(name,argc,argv),
10eb3d17 77 fMainFrame(0x0),
78 fPainterMasterFrame(0x0)
90037e4e 79{
80
81 /// ctor
1ffbeb9d 82 /// (w,h) is the size in pixel (if 0,0 it will be computed as 70%,90% of display size)
83 /// (ox,oy) is the offset from the top-left of the display
84
85 if (!w | !h)
86 {
87 w = (UInt_t)(gClient->GetDisplayWidth()*0.7);
88 h = (UInt_t)(gClient->GetDisplayHeight()*0.9);
89 }
90037e4e 90
91 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
92
93 CreateMenuBar(w);
94
95 const Int_t kbs = 2;
96
97// h -= 60; // menubar
98
99 TGTab* tabs = new TGTab(fMainFrame,w,h);
100
101 TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
102
10eb3d17 103 fPainterMasterFrame =
90037e4e 104 new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
105
10eb3d17 106 t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
90037e4e 107
108 t = tabs->AddTab("Data Sources");
109
110 AliMUONPainterDataSourceFrame* dsf =
111 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
112
113 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
114
115 fMainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
116
117 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
118
119 fMainFrame->MapSubwindows();
120 fMainFrame->Resize();
10eb3d17 121
122 fPainterMasterFrame->Update();
123
90037e4e 124 fMainFrame->MapWindow();
125
126 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
1ffbeb9d 127
128 fMainFrame->MoveResize(ox,oy, w, h);
129 fMainFrame->SetWMPosition(ox, oy);
90037e4e 130 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
10eb3d17 131
132 cout << "***************************************************" << endl;
133 cout << " Welcome to mchview" << endl;
134 cout << " " << FullVersion() << endl;
135 cout << "***************************************************" << endl;
136
90037e4e 137}
138
139//______________________________________________________________________________
140AliMUONMchViewApplication::~AliMUONMchViewApplication()
141{
142 /// dtor
143}
144
49419555 145//______________________________________________________________________________
146void
147AliMUONMchViewApplication::CompareData()
148{
149 /// Launch compare data dialog
150 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
151 gClient->GetRoot(),
152 400,400);
153
154 t->MapSubwindows();
155 t->Resize();
156 t->MapWindow();
157 t->CenterOnParent();
158
159 // set names
160
161 t->SetWindowName("mchview compare data tool");
162 t->SetIconName("mchview compare data tool");
163
164 t->MapRaised();
165
166}
167
90037e4e 168//______________________________________________________________________________
169void
170AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
171{
172 /// Create the application menu bar
173
174 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
175
176 file->AddEntry("&Open...",fgkFILEOPEN);
177 file->AddEntry("&Save As...",fgkFILESAVEAS);
10eb3d17 178 file->AddEntry("&Print As...",fgkFILEPRINTAS);
90037e4e 179 file->AddEntry("&Exit",fgkFILEEXIT);
180
90037e4e 181 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
182
49419555 183 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
184 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
185
10eb3d17 186 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
49419555 187 about->AddEntry(FullVersion(),fgkABOUT);
10eb3d17 188
49419555 189 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
190 about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
191 tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
192
90037e4e 193 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
49419555 194 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
10eb3d17 195 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
90037e4e 196
197 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
198
199 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
200}
201
202//______________________________________________________________________________
203void
204AliMUONMchViewApplication::HandleMenu(Int_t i)
205{
206 /// Handle the click of one menu item
207
208 switch (i)
209 {
210 case fgkFILEEXIT:
211 Terminate(1);
212 break;
213 case fgkFILEOPEN:
214 Open();
215 break;
216 case fgkFILESAVEAS:
217 Save();
218 break;
10eb3d17 219 case fgkFILEPRINTAS:
220 PrintAs();
221 break;
49419555 222 case fgkABOUT:
223 ReleaseNotes();
224 break;
225 case fgkCOMPAREDATA:
226 CompareData();
227 break;
90037e4e 228 default:
229 break;
230 }
231}
232
233//______________________________________________________________________________
234void
235AliMUONMchViewApplication::Open()
236{
237 /// Open file dialog
238
239 TGFileInfo fileInfo;
240
10eb3d17 241 fileInfo.fFileTypes = fgkFileTypes;
242
49419555 243 delete[] fileInfo.fIniDir;
244
245 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
246
247 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
248
90037e4e 249 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
250 kFDOpen,&fileInfo);
49419555 251
252 env->Set("LastOpenDir",fileInfo.fIniDir);
253 env->Save();
254
90037e4e 255 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
256}
257
258//______________________________________________________________________________
259void
260AliMUONMchViewApplication::Open(const char* filename)
261{
49419555 262 /// Open a given file containing saved VTrackerDataMaker objects
90037e4e 263
49419555 264 TString sfilename(gSystem->ExpandPathName(filename));
90037e4e 265
49419555 266 if ( sfilename.Contains(TRegexp("^alien")) )
267 {
268 // insure we've initialized the grid...
269 if (!gGrid)
270 {
271 TGrid::Connect("alien://");
272 }
273 }
274
275 TFile* f = TFile::Open(filename);
276
632a2059 277 ReadDir(*f);
278
279 delete f;
280}
281
282//______________________________________________________________________________
283void
284AliMUONMchViewApplication::ReadDir(TDirectory& dir)
285{
72dae9ff 286 /// Read the given directory and import VTrackerData objects found
287
632a2059 288 TList* keys = dir.GetListOfKeys();
90037e4e 289 TIter next(keys);
290
291 TKey* k;
292
293 while ( ( k = static_cast<TKey*>(next()) ) )
294 {
295 TObject* object = k->ReadObj();
49419555 296
632a2059 297 if ( object->InheritsFrom("TDirectory") )
298 {
299 TDirectory* d = static_cast<TDirectory*>(object);
300 ReadDir(*d);
301 continue;
302 }
303
49419555 304 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
305 {
306 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
307 if ( maker )
308 {
8f0acce4 309 AliMUONPainterDataRegistry::Instance()->Register(maker);
49419555 310 }
311 }
90037e4e 312
313 if ( object->InheritsFrom("AliMUONVTrackerData") )
314 {
49419555 315 // this is for backward compatibility. Early versions of mchview
316 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
317
318 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
90037e4e 319 if ( data )
320 {
49419555 321 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
8f0acce4 322 AliMUONPainterDataRegistry::Instance()->Register(maker);
90037e4e 323 }
324 }
325 }
49419555 326
90037e4e 327}
328
10eb3d17 329//______________________________________________________________________________
330void
331AliMUONMchViewApplication::PrintAs()
332{
333 /// Print as...
334
335 TGFileInfo fileInfo;
336
337 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
338 kFDSave,&fileInfo);
339
340 fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
341}
342
49419555 343//______________________________________________________________________________
344void
345AliMUONMchViewApplication::ReleaseNotes()
346{
347 /// Display release notes
348
349 UInt_t width = 600;
350 UInt_t height = 400;
351
352 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
353
354 TGTextView* rn = new TGTextView(t);
1ffbeb9d 355
8f0acce4 356 rn->AddLine("0.96a");
357 rn->AddLine("");
358 rn->AddLine("Internal reorganization of the contour computations, that lead to improved performance. ");
359 rn->AddLine("Improved enough to be able to remove completely the usage of the padstore.root file with precomputed contours.");
360 rn->AddLine("");
361
b6f591ae 362 rn->AddLine("0.96");
363 rn->AddLine("");
364 rn->AddLine("New features");
365 rn->AddLine("");
366 rn->AddLine("- Can now read raw data from memory (using the mem://@gdc: syntax)");
367 rn->AddLine("- Raw data decoder now automatically skips buspatches with parity errors");
368 rn->AddLine("");
369
370 rn->AddLine("0.95");
1ffbeb9d 371 rn->AddLine("");
372 rn->AddLine("New features");
373 rn->AddLine("");
374 rn->AddLine("- Can now read and display HV values from OCDB");
375 rn->AddLine("- New program option --geometry to force geometry of the window");
376 rn->AddLine("- Added possibility, in painters' context menu, to include or exclude part of the detector");
377 rn->AddLine(" (which will be used later on to communicate with LC2 which parts should be read out or not)");
378 rn->AddLine("");
379 rn->AddLine("Improvement");
380 rn->AddLine("");
381 rn->AddLine("- When displaying Gains, the quality information is now decoded");
382 rn->AddLine("");
49419555 383
1286237e 384 rn->AddLine("0.94");
385 rn->AddLine("");
386 rn->AddLine("New features");
387 rn->AddLine("");
388 rn->AddLine("Can now read ASCII calibration files produced by the DA");
389 rn->AddLine("");
390
49419555 391 rn->AddLine("0.93");
392 rn->AddLine("");
393 rn->AddLine("New features");
394 rn->AddLine("");
395 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
396 rn->AddLine(" when switching between views");
397 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
398 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
399 rn->AddLine(" clicking on it will display an histo");
400 rn->AddLine("- Right-click on a painter will now display several histogram options");
401 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
402 rn->AddLine(" and sigma");
403 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
404 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
405 rn->AddLine(" in order to compare data.");
406 rn->AddLine(" - The --use option can now reference alien files");
407 rn->AddLine("");
408 rn->AddLine("Bug fixes");
409 rn->AddLine("");
410 rn->AddLine("- Can now read Capacitances from OCDB");
411
412 rn->Resize(width,height);
413
414 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
415
416 t->MapSubwindows();
417 t->Resize();
418 t->MapWindow();
419 t->CenterOnParent();
420
421 // set names
422
423 t->SetWindowName("mchview release notes");
424 t->SetIconName("mchview release notes");
425
426// t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
427// kMWMDecorMinimize | kMWMDecorMenu,
428// kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
429// kMWMFuncMinimize,
430// kMWMInputModeless);
431
432 t->MapRaised();
433// gClient->WaitFor(t);
434}
435
90037e4e 436//______________________________________________________________________________
437void
438AliMUONMchViewApplication::Save()
439{
440 /// Open "Save VTrackerData objects to file" dialog
441
442 TGFileInfo fileInfo;
443
444 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
445 kFDSave,&fileInfo);
446
447 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
448}
449
450//______________________________________________________________________________
451void
452AliMUONMchViewApplication::Save(const char* filename)
453{
49419555 454 /// Save VTrackerDataMaker objects into file of given name
90037e4e 455
8f0acce4 456 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
90037e4e 457
458 TFile f(filename,"RECREATE");
459
49419555 460 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
90037e4e 461 {
49419555 462 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);
463 maker->Write();
90037e4e 464 }
465
466 f.Close();
467}