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 "AliMUONChamberPainter.h"
24 #include "AliMUONDEPainter.h"
25 #include "AliMUONPainterDataRegistry.h"
26 #include "AliMUONPainterDataSourceFrame.h"
27 #include "AliMUONPainterEnv.h"
28 #include "AliMUONPainterHelper.h"
29 #include "AliMUONPainterMasterFrame.h"
30 #include "AliMUONPainterRegistry.h"
31 #include "AliMUONTrackerDataCompareDialog.h"
32 #include "AliMUONTrackerDataWrapper.h"
33 #include "AliMUONVTrackerData.h"
34 #include "AliMUONVTrackerDataMaker.h"
35 #include <Riostream.h>
40 #include <TGFileDialog.h>
43 #include <TGTextView.h>
51 /// \class AliMUONMchViewApplication
53 /// Main class for the mchview program
55 ///\author Laurent Aphecetche, Subatech
58 ClassImp(AliMUONMchViewApplication)
61 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
62 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
63 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
64 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
65 const Int_t AliMUONMchViewApplication::fgkABOUT(5);
66 const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
68 const char* AliMUONMchViewApplication::fgkFileTypes[] = {
69 "ROOT files", "*.root",
73 //______________________________________________________________________________
74 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
75 int* argc, char** argv,
78 : TRint(name,argc,argv),
80 fPainterMasterFrame(0x0)
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
89 w = (UInt_t)(gClient->GetDisplayWidth()*0.7);
90 h = (UInt_t)(gClient->GetDisplayHeight()*0.9);
93 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
95 AliMUONPainterHelper::Instance()->GenerateDefaultMatrices();
101 // h -= 60; // menubar
103 TGTab* tabs = new TGTab(fMainFrame,w,h);
105 TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
107 fPainterMasterFrame =
108 new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
110 t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
112 t = tabs->AddTab("Data Sources");
114 AliMUONPainterDataSourceFrame* dsf =
115 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
117 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
119 fMainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
121 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
123 fMainFrame->MapSubwindows();
124 fMainFrame->Resize();
126 fPainterMasterFrame->Update();
128 fMainFrame->MapWindow();
130 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
132 fMainFrame->MoveResize(ox,oy, w, h);
133 fMainFrame->SetWMPosition(ox, oy);
134 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
136 cout << "***************************************************" << endl;
137 cout << " Welcome to mchview" << endl;
138 cout << " " << FullVersion() << endl;
139 cout << "***************************************************" << endl;
141 // Trying to see if we're requested to draw something specific instead
142 // of the global view of all the chambers
144 AliMUONVPainter* painter(0x0);
146 args.SetOwner(kTRUE);
148 for ( int i = 1; i < argc[0]; ++i )
150 args.Add(new TObjString(argv[i]));
153 for ( Int_t i = 0; i <= args.GetLast(); ++i )
155 TString a(static_cast<TObjString*>(args.At(i))->String());
157 AliMUONAttPainter att;
159 att.SetPlane(kTRUE,kFALSE);
160 att.SetCathode(kFALSE,kFALSE);
161 att.SetViewPoint(kTRUE,kFALSE);
165 Int_t detElemId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
167 painter = new AliMUONDEPainter(att,detElemId);
169 painter->SetOutlined("*",kFALSE);
170 painter->SetOutlined("BUSPATCH",kTRUE);
172 painter->SetLine(1,4,3);
176 if ( a == "--chamber" )
178 Int_t chamberId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
180 painter = new AliMUONChamberPainter(att,chamberId-1);
182 painter->SetOutlined("*",kFALSE);
183 painter->SetOutlined("DE",kTRUE);
185 painter->SetLine(1,4,3);
193 fPainterMasterFrame->ShiftClicked(painter,0x0);
195 fPainterMasterFrame->Update();
200 //______________________________________________________________________________
201 AliMUONMchViewApplication::~AliMUONMchViewApplication()
206 //______________________________________________________________________________
208 AliMUONMchViewApplication::CompareData()
210 /// Launch compare data dialog
211 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
222 t->SetWindowName("mchview compare data tool");
223 t->SetIconName("mchview compare data tool");
229 //______________________________________________________________________________
231 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
233 /// Create the application menu bar
235 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
237 file->AddEntry("&Open...",fgkFILEOPEN);
238 file->AddEntry("&Save As...",fgkFILESAVEAS);
239 file->AddEntry("&Print As...",fgkFILEPRINTAS);
240 file->AddEntry("&Exit",fgkFILEEXIT);
242 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
244 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
245 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
247 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
248 about->AddEntry(FullVersion(),fgkABOUT);
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)");
254 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
255 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
256 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
258 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
260 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
263 //______________________________________________________________________________
265 AliMUONMchViewApplication::HandleMenu(Int_t i)
267 /// Handle the click of one menu item
294 //______________________________________________________________________________
296 AliMUONMchViewApplication::Open()
302 fileInfo.fFileTypes = fgkFileTypes;
304 delete[] fileInfo.fIniDir;
306 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
308 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
310 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
313 env->Set("LastOpenDir",fileInfo.fIniDir);
316 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
319 //______________________________________________________________________________
321 AliMUONMchViewApplication::Open(const char* filename)
323 /// Open a given file containing saved VTrackerDataMaker objects
325 TString sfilename(gSystem->ExpandPathName(filename));
327 if ( sfilename.Contains(TRegexp("^alien")) )
329 // insure we've initialized the grid...
332 TGrid::Connect("alien://");
336 TFile* f = TFile::Open(filename);
343 //______________________________________________________________________________
345 AliMUONMchViewApplication::ReadDir(TDirectory& dir)
347 /// Read the given directory and import VTrackerData objects found
349 TList* keys = dir.GetListOfKeys();
354 while ( ( k = static_cast<TKey*>(next()) ) )
356 TObject* object = k->ReadObj();
358 if ( object->InheritsFrom("TDirectory") )
360 TDirectory* d = static_cast<TDirectory*>(object);
365 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
367 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
370 AliMUONPainterDataRegistry::Instance()->Register(maker);
374 if ( object->InheritsFrom("AliMUONVTrackerData") )
376 // this is for backward compatibility. Early versions of mchview
377 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
379 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
382 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
383 AliMUONPainterDataRegistry::Instance()->Register(maker);
390 //______________________________________________________________________________
392 AliMUONMchViewApplication::PrintAs()
398 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
401 fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
404 //______________________________________________________________________________
406 AliMUONMchViewApplication::ReleaseNotes()
408 /// Display release notes
413 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
415 TGTextView* rn = new TGTextView(t);
419 rn->AddLine("Added the configuration as a possible OCDB data source");
424 rn->AddLine("Added the Status and StatusMap as a possible OCDB data source");
426 rn->AddLine("Added one (computed) dimension to the Gains data source = 1/a1/0.2 (mV/fC)");
429 rn->AddLine("0.99a");
431 rn->AddLine("Added the --de and --chamber options");
436 rn->AddLine("The chamberid in the label (top right of panel) is now starting at 1 as in common usage");
441 rn->AddLine("Added --asciimapping option");
446 rn->AddLine("Adding calibration option with Emelec (aka injection) gain");
449 rn->AddLine("0.96a");
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.");
457 rn->AddLine("New features");
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");
465 rn->AddLine("New features");
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)");
472 rn->AddLine("Improvement");
474 rn->AddLine("- When displaying Gains, the quality information is now decoded");
479 rn->AddLine("New features");
481 rn->AddLine("Can now read ASCII calibration files produced by the DA");
486 rn->AddLine("New features");
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");
501 rn->AddLine("Bug fixes");
503 rn->AddLine("- Can now read Capacitances from OCDB");
505 rn->Resize(width,height);
507 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
516 t->SetWindowName("mchview release notes");
517 t->SetIconName("mchview release notes");
519 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
520 // kMWMDecorMinimize | kMWMDecorMenu,
521 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
523 // kMWMInputModeless);
526 // gClient->WaitFor(t);
529 //______________________________________________________________________________
531 AliMUONMchViewApplication::Save()
533 /// Open "Save VTrackerData objects to file" dialog
537 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
540 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
543 //______________________________________________________________________________
545 AliMUONMchViewApplication::Save(const char* filename)
547 /// Save VTrackerDataMaker objects into file of given name
549 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
551 TFile f(filename,"RECREATE");
553 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
555 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);