]>
Commit | Line | Data |
---|---|---|
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 | |
56 | ClassImp(AliMUONMchViewApplication) | |
57 | /// \endcond CLASSIMP | |
58 | ||
59 | const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1); | |
60 | const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2); | |
61 | const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3); | |
10eb3d17 | 62 | const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4); |
49419555 | 63 | const Int_t AliMUONMchViewApplication::fgkABOUT(5); |
64 | const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6); | |
10eb3d17 | 65 | |
66 | const char* AliMUONMchViewApplication::fgkFileTypes[] = { | |
67 | "ROOT files", "*.root", | |
68 | "All files", "*", | |
69 | 0, 0 }; | |
90037e4e | 70 | |
71 | //______________________________________________________________________________ | |
72 | AliMUONMchViewApplication::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 | //______________________________________________________________________________ | |
140 | AliMUONMchViewApplication::~AliMUONMchViewApplication() | |
141 | { | |
142 | /// dtor | |
143 | } | |
144 | ||
49419555 | 145 | //______________________________________________________________________________ |
146 | void | |
147 | AliMUONMchViewApplication::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 | //______________________________________________________________________________ |
169 | void | |
170 | AliMUONMchViewApplication::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 | //______________________________________________________________________________ | |
203 | void | |
204 | AliMUONMchViewApplication::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 | //______________________________________________________________________________ | |
234 | void | |
235 | AliMUONMchViewApplication::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 | //______________________________________________________________________________ | |
259 | void | |
260 | AliMUONMchViewApplication::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 | //______________________________________________________________________________ | |
283 | void | |
284 | AliMUONMchViewApplication::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 | //______________________________________________________________________________ |
330 | void | |
331 | AliMUONMchViewApplication::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 | //______________________________________________________________________________ |
344 | void | |
345 | AliMUONMchViewApplication::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 | |
3f979838 | 356 | rn->AddLine("0.98"); |
357 | rn->AddLine(""); | |
358 | rn->AddLine("Added --asciimapping option"); | |
359 | rn->AddLine(""); | |
360 | ||
66cdf5b3 | 361 | rn->AddLine("0.97"); |
362 | rn->AddLine(""); | |
363 | rn->AddLine("Adding calibration option with Emelec (aka injection) gain"); | |
364 | rn->AddLine(""); | |
365 | ||
8f0acce4 | 366 | rn->AddLine("0.96a"); |
367 | rn->AddLine(""); | |
368 | rn->AddLine("Internal reorganization of the contour computations, that lead to improved performance. "); | |
369 | rn->AddLine("Improved enough to be able to remove completely the usage of the padstore.root file with precomputed contours."); | |
370 | rn->AddLine(""); | |
371 | ||
b6f591ae | 372 | rn->AddLine("0.96"); |
373 | rn->AddLine(""); | |
374 | rn->AddLine("New features"); | |
375 | rn->AddLine(""); | |
376 | rn->AddLine("- Can now read raw data from memory (using the mem://@gdc: syntax)"); | |
377 | rn->AddLine("- Raw data decoder now automatically skips buspatches with parity errors"); | |
378 | rn->AddLine(""); | |
379 | ||
380 | rn->AddLine("0.95"); | |
1ffbeb9d | 381 | rn->AddLine(""); |
382 | rn->AddLine("New features"); | |
383 | rn->AddLine(""); | |
384 | rn->AddLine("- Can now read and display HV values from OCDB"); | |
385 | rn->AddLine("- New program option --geometry to force geometry of the window"); | |
386 | rn->AddLine("- Added possibility, in painters' context menu, to include or exclude part of the detector"); | |
387 | rn->AddLine(" (which will be used later on to communicate with LC2 which parts should be read out or not)"); | |
388 | rn->AddLine(""); | |
389 | rn->AddLine("Improvement"); | |
390 | rn->AddLine(""); | |
391 | rn->AddLine("- When displaying Gains, the quality information is now decoded"); | |
392 | rn->AddLine(""); | |
49419555 | 393 | |
1286237e | 394 | rn->AddLine("0.94"); |
395 | rn->AddLine(""); | |
396 | rn->AddLine("New features"); | |
397 | rn->AddLine(""); | |
398 | rn->AddLine("Can now read ASCII calibration files produced by the DA"); | |
399 | rn->AddLine(""); | |
400 | ||
49419555 | 401 | rn->AddLine("0.93"); |
402 | rn->AddLine(""); | |
403 | rn->AddLine("New features"); | |
404 | rn->AddLine(""); | |
405 | rn->AddLine("- Adding a Lock button under the color slider to lock the range shown"); | |
406 | rn->AddLine(" when switching between views"); | |
407 | rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)"); | |
408 | rn->AddLine("- If pad is responder and there's some histo for that pad, "); | |
409 | rn->AddLine(" clicking on it will display an histo"); | |
410 | rn->AddLine("- Right-click on a painter will now display several histogram options"); | |
411 | rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean"); | |
412 | rn->AddLine(" and sigma"); | |
413 | rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved"); | |
414 | rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others"); | |
415 | rn->AddLine(" in order to compare data."); | |
416 | rn->AddLine(" - The --use option can now reference alien files"); | |
417 | rn->AddLine(""); | |
418 | rn->AddLine("Bug fixes"); | |
419 | rn->AddLine(""); | |
420 | rn->AddLine("- Can now read Capacitances from OCDB"); | |
421 | ||
422 | rn->Resize(width,height); | |
423 | ||
424 | t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); | |
425 | ||
426 | t->MapSubwindows(); | |
427 | t->Resize(); | |
428 | t->MapWindow(); | |
429 | t->CenterOnParent(); | |
430 | ||
431 | // set names | |
432 | ||
433 | t->SetWindowName("mchview release notes"); | |
434 | t->SetIconName("mchview release notes"); | |
435 | ||
436 | // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize | | |
437 | // kMWMDecorMinimize | kMWMDecorMenu, | |
438 | // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize | | |
439 | // kMWMFuncMinimize, | |
440 | // kMWMInputModeless); | |
441 | ||
442 | t->MapRaised(); | |
443 | // gClient->WaitFor(t); | |
444 | } | |
445 | ||
90037e4e | 446 | //______________________________________________________________________________ |
447 | void | |
448 | AliMUONMchViewApplication::Save() | |
449 | { | |
450 | /// Open "Save VTrackerData objects to file" dialog | |
451 | ||
452 | TGFileInfo fileInfo; | |
453 | ||
454 | new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(), | |
455 | kFDSave,&fileInfo); | |
456 | ||
457 | Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename))); | |
458 | } | |
459 | ||
460 | //______________________________________________________________________________ | |
461 | void | |
462 | AliMUONMchViewApplication::Save(const char* filename) | |
463 | { | |
49419555 | 464 | /// Save VTrackerDataMaker objects into file of given name |
90037e4e | 465 | |
8f0acce4 | 466 | AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance(); |
90037e4e | 467 | |
468 | TFile f(filename,"RECREATE"); | |
469 | ||
49419555 | 470 | for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i ) |
90037e4e | 471 | { |
49419555 | 472 | AliMUONVTrackerDataMaker* maker = reg->DataMaker(i); |
473 | maker->Write(); | |
90037e4e | 474 | } |
475 | ||
476 | f.Close(); | |
477 | } |