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 "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>
38 #include <TGFileDialog.h>
41 #include <TGTextView.h>
49 /// \class AliMUONMchViewApplication
51 /// Main class for the mchview program
53 ///\author Laurent Aphecetche, Subatech
56 ClassImp(AliMUONMchViewApplication)
59 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
60 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
61 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
62 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
63 const Int_t AliMUONMchViewApplication::fgkABOUT(5);
64 const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
66 const char* AliMUONMchViewApplication::fgkFileTypes[] = {
67 "ROOT files", "*.root",
71 //______________________________________________________________________________
72 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
73 int* argc, char** argv,
76 : TRint(name,argc,argv),
78 fPainterMasterFrame(0x0)
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
87 w = (UInt_t)(gClient->GetDisplayWidth()*0.7);
88 h = (UInt_t)(gClient->GetDisplayHeight()*0.9);
91 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
97 // h -= 60; // menubar
99 TGTab* tabs = new TGTab(fMainFrame,w,h);
101 TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
103 fPainterMasterFrame =
104 new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
106 t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
108 t = tabs->AddTab("Data Sources");
110 AliMUONPainterDataSourceFrame* dsf =
111 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
113 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
115 fMainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
117 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
119 fMainFrame->MapSubwindows();
120 fMainFrame->Resize();
122 fPainterMasterFrame->Update();
124 fMainFrame->MapWindow();
126 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
128 fMainFrame->MoveResize(ox,oy, w, h);
129 fMainFrame->SetWMPosition(ox, oy);
130 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
132 cout << "***************************************************" << endl;
133 cout << " Welcome to mchview" << endl;
134 cout << " " << FullVersion() << endl;
135 cout << "***************************************************" << endl;
139 //______________________________________________________________________________
140 AliMUONMchViewApplication::~AliMUONMchViewApplication()
145 //______________________________________________________________________________
147 AliMUONMchViewApplication::CompareData()
149 /// Launch compare data dialog
150 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
161 t->SetWindowName("mchview compare data tool");
162 t->SetIconName("mchview compare data tool");
168 //______________________________________________________________________________
170 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
172 /// Create the application menu bar
174 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
176 file->AddEntry("&Open...",fgkFILEOPEN);
177 file->AddEntry("&Save As...",fgkFILESAVEAS);
178 file->AddEntry("&Print As...",fgkFILEPRINTAS);
179 file->AddEntry("&Exit",fgkFILEEXIT);
181 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
183 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
184 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
186 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
187 about->AddEntry(FullVersion(),fgkABOUT);
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)");
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));
197 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
199 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
202 //______________________________________________________________________________
204 AliMUONMchViewApplication::HandleMenu(Int_t i)
206 /// Handle the click of one menu item
233 //______________________________________________________________________________
235 AliMUONMchViewApplication::Open()
241 fileInfo.fFileTypes = fgkFileTypes;
243 delete[] fileInfo.fIniDir;
245 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
247 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
249 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
252 env->Set("LastOpenDir",fileInfo.fIniDir);
255 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
258 //______________________________________________________________________________
260 AliMUONMchViewApplication::Open(const char* filename)
262 /// Open a given file containing saved VTrackerDataMaker objects
264 TString sfilename(gSystem->ExpandPathName(filename));
266 if ( sfilename.Contains(TRegexp("^alien")) )
268 // insure we've initialized the grid...
271 TGrid::Connect("alien://");
275 TFile* f = TFile::Open(filename);
282 //______________________________________________________________________________
284 AliMUONMchViewApplication::ReadDir(TDirectory& dir)
286 /// Read the given directory and import VTrackerData objects found
288 TList* keys = dir.GetListOfKeys();
293 while ( ( k = static_cast<TKey*>(next()) ) )
295 TObject* object = k->ReadObj();
297 if ( object->InheritsFrom("TDirectory") )
299 TDirectory* d = static_cast<TDirectory*>(object);
304 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
306 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
309 AliMUONPainterDataRegistry::Instance()->Register(maker);
313 if ( object->InheritsFrom("AliMUONVTrackerData") )
315 // this is for backward compatibility. Early versions of mchview
316 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
318 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
321 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
322 AliMUONPainterDataRegistry::Instance()->Register(maker);
329 //______________________________________________________________________________
331 AliMUONMchViewApplication::PrintAs()
337 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
340 fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
343 //______________________________________________________________________________
345 AliMUONMchViewApplication::ReleaseNotes()
347 /// Display release notes
352 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
354 TGTextView* rn = new TGTextView(t);
358 rn->AddLine("Adding calibration option with Emelec (aka injection) gain");
361 rn->AddLine("0.96a");
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.");
369 rn->AddLine("New features");
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");
377 rn->AddLine("New features");
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)");
384 rn->AddLine("Improvement");
386 rn->AddLine("- When displaying Gains, the quality information is now decoded");
391 rn->AddLine("New features");
393 rn->AddLine("Can now read ASCII calibration files produced by the DA");
398 rn->AddLine("New features");
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");
413 rn->AddLine("Bug fixes");
415 rn->AddLine("- Can now read Capacitances from OCDB");
417 rn->Resize(width,height);
419 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
428 t->SetWindowName("mchview release notes");
429 t->SetIconName("mchview release notes");
431 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
432 // kMWMDecorMinimize | kMWMDecorMenu,
433 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
435 // kMWMInputModeless);
438 // gClient->WaitFor(t);
441 //______________________________________________________________________________
443 AliMUONMchViewApplication::Save()
445 /// Open "Save VTrackerData objects to file" dialog
449 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
452 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
455 //______________________________________________________________________________
457 AliMUONMchViewApplication::Save(const char* filename)
459 /// Save VTrackerDataMaker objects into file of given name
461 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
463 TFile f(filename,"RECREATE");
465 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
467 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);