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 /// (w,h) is the size in pixel (if 0,0 it will be computed as 70%,90% of display size)
82 /// (ox,oy) is the offset from the top-left of the display
86 w = (UInt_t)(gClient->GetDisplayWidth()*0.7);
87 h = (UInt_t)(gClient->GetDisplayHeight()*0.9);
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 fMainFrame->MoveResize(ox,oy, w, h);
128 fMainFrame->SetWMPosition(ox, oy);
129 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
131 cout << "***************************************************" << endl;
132 cout << " Welcome to mchview" << endl;
133 cout << " " << FullVersion() << endl;
134 cout << "***************************************************" << endl;
138 //______________________________________________________________________________
139 AliMUONMchViewApplication::~AliMUONMchViewApplication()
144 //______________________________________________________________________________
146 AliMUONMchViewApplication::CompareData()
148 /// Launch compare data dialog
149 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
160 t->SetWindowName("mchview compare data tool");
161 t->SetIconName("mchview compare data tool");
167 //______________________________________________________________________________
169 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
171 /// Create the application menu bar
173 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
175 file->AddEntry("&Open...",fgkFILEOPEN);
176 file->AddEntry("&Save As...",fgkFILESAVEAS);
177 file->AddEntry("&Print As...",fgkFILEPRINTAS);
178 file->AddEntry("&Exit",fgkFILEEXIT);
180 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
182 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
183 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
185 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
186 about->AddEntry(FullVersion(),fgkABOUT);
188 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
189 about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
190 tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
192 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
193 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
194 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
196 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
198 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
201 //______________________________________________________________________________
203 AliMUONMchViewApplication::HandleMenu(Int_t i)
205 /// Handle the click of one menu item
232 //______________________________________________________________________________
234 AliMUONMchViewApplication::Open()
240 fileInfo.fFileTypes = fgkFileTypes;
242 delete[] fileInfo.fIniDir;
244 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
246 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
248 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
251 env->Set("LastOpenDir",fileInfo.fIniDir);
254 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
257 //______________________________________________________________________________
259 AliMUONMchViewApplication::Open(const char* filename)
261 /// Open a given file containing saved VTrackerDataMaker objects
263 TString sfilename(gSystem->ExpandPathName(filename));
265 if ( sfilename.Contains(TRegexp("^alien")) )
267 // insure we've initialized the grid...
270 TGrid::Connect("alien://");
274 TFile* f = TFile::Open(filename);
281 //______________________________________________________________________________
283 AliMUONMchViewApplication::ReadDir(TDirectory& dir)
285 TList* keys = dir.GetListOfKeys();
290 while ( ( k = static_cast<TKey*>(next()) ) )
292 TObject* object = k->ReadObj();
294 if ( object->InheritsFrom("TDirectory") )
296 TDirectory* d = static_cast<TDirectory*>(object);
301 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
303 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
306 AliMUONPainterRegistry::Instance()->Register(maker);
310 if ( object->InheritsFrom("AliMUONVTrackerData") )
312 // this is for backward compatibility. Early versions of mchview
313 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
315 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
318 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
319 AliMUONPainterRegistry::Instance()->Register(maker);
326 //______________________________________________________________________________
328 AliMUONMchViewApplication::PrintAs()
334 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
337 fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
340 //______________________________________________________________________________
342 AliMUONMchViewApplication::ReleaseNotes()
344 /// Display release notes
349 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
351 TGTextView* rn = new TGTextView(t);
355 rn->AddLine("New features");
357 rn->AddLine("- Can now read and display HV values from OCDB");
358 rn->AddLine("- New program option --geometry to force geometry of the window");
359 rn->AddLine("- Added possibility, in painters' context menu, to include or exclude part of the detector");
360 rn->AddLine(" (which will be used later on to communicate with LC2 which parts should be read out or not)");
362 rn->AddLine("Improvement");
364 rn->AddLine("- When displaying Gains, the quality information is now decoded");
369 rn->AddLine("New features");
371 rn->AddLine("Can now read ASCII calibration files produced by the DA");
376 rn->AddLine("New features");
378 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
379 rn->AddLine(" when switching between views");
380 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
381 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
382 rn->AddLine(" clicking on it will display an histo");
383 rn->AddLine("- Right-click on a painter will now display several histogram options");
384 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
385 rn->AddLine(" and sigma");
386 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
387 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
388 rn->AddLine(" in order to compare data.");
389 rn->AddLine(" - The --use option can now reference alien files");
391 rn->AddLine("Bug fixes");
393 rn->AddLine("- Can now read Capacitances from OCDB");
395 rn->Resize(width,height);
397 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
406 t->SetWindowName("mchview release notes");
407 t->SetIconName("mchview release notes");
409 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
410 // kMWMDecorMinimize | kMWMDecorMenu,
411 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
413 // kMWMInputModeless);
416 // gClient->WaitFor(t);
419 //______________________________________________________________________________
421 AliMUONMchViewApplication::Save()
423 /// Open "Save VTrackerData objects to file" dialog
427 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
430 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
433 //______________________________________________________________________________
435 AliMUONMchViewApplication::Save(const char* filename)
437 /// Save VTrackerDataMaker objects into file of given name
439 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
441 TFile f(filename,"RECREATE");
443 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
445 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);