]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - MUON/AliMUONMchViewApplication.cxx
In QA:
[u/mrichter/AliRoot.git] / MUON / AliMUONMchViewApplication.cxx
... / ...
CommitLineData
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#include "AliMUONMchViewApplication.h"
19
20#include "AliCDBManager.h"
21#include "AliCodeTimer.h"
22#include "AliLog.h"
23#include "AliMUONPainterDataRegistry.h"
24#include "AliMUONPainterDataSourceFrame.h"
25#include "AliMUONPainterEnv.h"
26#include "AliMUONPainterHelper.h"
27#include "AliMUONPainterMasterFrame.h"
28#include "AliMUONPainterRegistry.h"
29#include "AliMUONTrackerDataCompareDialog.h"
30#include "AliMUONTrackerDataWrapper.h"
31#include "AliMUONVTrackerData.h"
32#include "AliMUONVTrackerDataMaker.h"
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>
41#include <TGTextView.h>
42#include <TGrid.h>
43#include <TKey.h>
44#include <TList.h>
45#include <TRegexp.h>
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);
62const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
63const Int_t AliMUONMchViewApplication::fgkABOUT(5);
64const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
65
66const char* AliMUONMchViewApplication::fgkFileTypes[] = {
67 "ROOT files", "*.root",
68 "All files", "*",
69 0, 0 };
70
71//______________________________________________________________________________
72AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
73 int* argc, char** argv,
74 UInt_t w, UInt_t h,
75 UInt_t ox, UInt_t oy)
76: TRint(name,argc,argv),
77 fMainFrame(0x0),
78 fPainterMasterFrame(0x0)
79{
80
81 /// ctor
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 }
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
103 fPainterMasterFrame =
104 new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
105
106 t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
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();
121
122 fPainterMasterFrame->Update();
123
124 fMainFrame->MapWindow();
125
126 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
127
128 fMainFrame->MoveResize(ox,oy, w, h);
129 fMainFrame->SetWMPosition(ox, oy);
130 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
131
132 cout << "***************************************************" << endl;
133 cout << " Welcome to mchview" << endl;
134 cout << " " << FullVersion() << endl;
135 cout << "***************************************************" << endl;
136
137}
138
139//______________________________________________________________________________
140AliMUONMchViewApplication::~AliMUONMchViewApplication()
141{
142 /// dtor
143}
144
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
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);
178 file->AddEntry("&Print As...",fgkFILEPRINTAS);
179 file->AddEntry("&Exit",fgkFILEEXIT);
180
181 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
182
183 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
184 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
185
186 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
187 about->AddEntry(FullVersion(),fgkABOUT);
188
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
193 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
194 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
195 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
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;
219 case fgkFILEPRINTAS:
220 PrintAs();
221 break;
222 case fgkABOUT:
223 ReleaseNotes();
224 break;
225 case fgkCOMPAREDATA:
226 CompareData();
227 break;
228 default:
229 break;
230 }
231}
232
233//______________________________________________________________________________
234void
235AliMUONMchViewApplication::Open()
236{
237 /// Open file dialog
238
239 TGFileInfo fileInfo;
240
241 fileInfo.fFileTypes = fgkFileTypes;
242
243 delete[] fileInfo.fIniDir;
244
245 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
246
247 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
248
249 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
250 kFDOpen,&fileInfo);
251
252 env->Set("LastOpenDir",fileInfo.fIniDir);
253 env->Save();
254
255 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
256}
257
258//______________________________________________________________________________
259void
260AliMUONMchViewApplication::Open(const char* filename)
261{
262 /// Open a given file containing saved VTrackerDataMaker objects
263
264 TString sfilename(gSystem->ExpandPathName(filename));
265
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
277 ReadDir(*f);
278
279 delete f;
280}
281
282//______________________________________________________________________________
283void
284AliMUONMchViewApplication::ReadDir(TDirectory& dir)
285{
286 /// Read the given directory and import VTrackerData objects found
287
288 TList* keys = dir.GetListOfKeys();
289 TIter next(keys);
290
291 TKey* k;
292
293 while ( ( k = static_cast<TKey*>(next()) ) )
294 {
295 TObject* object = k->ReadObj();
296
297 if ( object->InheritsFrom("TDirectory") )
298 {
299 TDirectory* d = static_cast<TDirectory*>(object);
300 ReadDir(*d);
301 continue;
302 }
303
304 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
305 {
306 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
307 if ( maker )
308 {
309 AliMUONPainterDataRegistry::Instance()->Register(maker);
310 }
311 }
312
313 if ( object->InheritsFrom("AliMUONVTrackerData") )
314 {
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);
319 if ( data )
320 {
321 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
322 AliMUONPainterDataRegistry::Instance()->Register(maker);
323 }
324 }
325 }
326
327}
328
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
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);
355
356 rn->AddLine("0.97");
357 rn->AddLine("");
358 rn->AddLine("Adding calibration option with Emelec (aka injection) gain");
359 rn->AddLine("");
360
361 rn->AddLine("0.96a");
362 rn->AddLine("");
363 rn->AddLine("Internal reorganization of the contour computations, that lead to improved performance. ");
364 rn->AddLine("Improved enough to be able to remove completely the usage of the padstore.root file with precomputed contours.");
365 rn->AddLine("");
366
367 rn->AddLine("0.96");
368 rn->AddLine("");
369 rn->AddLine("New features");
370 rn->AddLine("");
371 rn->AddLine("- Can now read raw data from memory (using the mem://@gdc: syntax)");
372 rn->AddLine("- Raw data decoder now automatically skips buspatches with parity errors");
373 rn->AddLine("");
374
375 rn->AddLine("0.95");
376 rn->AddLine("");
377 rn->AddLine("New features");
378 rn->AddLine("");
379 rn->AddLine("- Can now read and display HV values from OCDB");
380 rn->AddLine("- New program option --geometry to force geometry of the window");
381 rn->AddLine("- Added possibility, in painters' context menu, to include or exclude part of the detector");
382 rn->AddLine(" (which will be used later on to communicate with LC2 which parts should be read out or not)");
383 rn->AddLine("");
384 rn->AddLine("Improvement");
385 rn->AddLine("");
386 rn->AddLine("- When displaying Gains, the quality information is now decoded");
387 rn->AddLine("");
388
389 rn->AddLine("0.94");
390 rn->AddLine("");
391 rn->AddLine("New features");
392 rn->AddLine("");
393 rn->AddLine("Can now read ASCII calibration files produced by the DA");
394 rn->AddLine("");
395
396 rn->AddLine("0.93");
397 rn->AddLine("");
398 rn->AddLine("New features");
399 rn->AddLine("");
400 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
401 rn->AddLine(" when switching between views");
402 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
403 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
404 rn->AddLine(" clicking on it will display an histo");
405 rn->AddLine("- Right-click on a painter will now display several histogram options");
406 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
407 rn->AddLine(" and sigma");
408 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
409 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
410 rn->AddLine(" in order to compare data.");
411 rn->AddLine(" - The --use option can now reference alien files");
412 rn->AddLine("");
413 rn->AddLine("Bug fixes");
414 rn->AddLine("");
415 rn->AddLine("- Can now read Capacitances from OCDB");
416
417 rn->Resize(width,height);
418
419 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
420
421 t->MapSubwindows();
422 t->Resize();
423 t->MapWindow();
424 t->CenterOnParent();
425
426 // set names
427
428 t->SetWindowName("mchview release notes");
429 t->SetIconName("mchview release notes");
430
431// t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
432// kMWMDecorMinimize | kMWMDecorMenu,
433// kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
434// kMWMFuncMinimize,
435// kMWMInputModeless);
436
437 t->MapRaised();
438// gClient->WaitFor(t);
439}
440
441//______________________________________________________________________________
442void
443AliMUONMchViewApplication::Save()
444{
445 /// Open "Save VTrackerData objects to file" dialog
446
447 TGFileInfo fileInfo;
448
449 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
450 kFDSave,&fileInfo);
451
452 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
453}
454
455//______________________________________________________________________________
456void
457AliMUONMchViewApplication::Save(const char* filename)
458{
459 /// Save VTrackerDataMaker objects into file of given name
460
461 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
462
463 TFile f(filename,"RECREATE");
464
465 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
466 {
467 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);
468 maker->Write();
469 }
470
471 f.Close();
472}