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