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 "AliMUONPainterGroup.h"
30 #include "AliMUONPainterMasterFrame.h"
31 #include "AliMUONPainterMatrix.h"
32 #include "AliMUONPainterRegistry.h"
33 #include "AliMUONTrackerDataCompareDialog.h"
34 #include "AliMUONTrackerDataWrapper.h"
35 #include "AliMUONVTrackerData.h"
36 #include "AliMUONVTrackerDataMaker.h"
37 #include <Riostream.h>
42 #include <TGFileDialog.h>
45 #include <TGTextView.h>
53 /// \class AliMUONMchViewApplication
55 /// Main class for the mchview program
57 ///\author Laurent Aphecetche, Subatech
60 ClassImp(AliMUONMchViewApplication)
63 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
64 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
65 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
66 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
67 const Int_t AliMUONMchViewApplication::fgkABOUT(5);
68 const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
70 const char* AliMUONMchViewApplication::fgkFileTypes[] = {
71 "ROOT files", "*.root",
75 //______________________________________________________________________________
76 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
77 int* argc, char** argv,
80 : TRint(name,argc,argv),
82 fPainterMasterFrameList(new TList),
87 /// (w,h) is the size in pixel (if 0,0 it will be computed as 70%,90% of display size)
88 /// (ox,oy) is the offset from the top-left of the display
92 w = (UInt_t)(gClient->GetDisplayWidth()*0.7);
93 h = (UInt_t)(gClient->GetDisplayHeight()*0.9);
96 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
102 // h -= 60; // menubar
104 fTabs = new TGTab(fMainFrame,w,h);
106 TGCompositeFrame* t = fTabs->AddTab("Painter Master Frame");
108 fPainterMasterFrameList->SetOwner(kTRUE);
111 AliMUONPainterMasterFrame* pmf = new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2,
112 GenerateStartupMatrix());
114 fPainterMasterFrameList->Add(pmf);
116 t->AddFrame(pmf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
118 t = fTabs->AddTab("Data Sources");
120 AliMUONPainterDataSourceFrame* dsf =
121 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
123 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
125 fMainFrame->AddFrame(fTabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
127 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
129 fMainFrame->MapSubwindows();
130 fMainFrame->Resize();
134 fMainFrame->MapWindow();
136 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
138 fMainFrame->MoveResize(ox,oy, w, h);
139 fMainFrame->SetWMPosition(ox, oy);
140 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
142 cout << "***************************************************" << endl;
143 cout << " Welcome to mchview" << endl;
144 cout << " " << FullVersion() << endl;
145 cout << "***************************************************" << endl;
147 // Trying to see if we're requested to draw something specific instead
148 // of the global view of all the chambers
150 AliMUONVPainter* painter(0x0);
152 args.SetOwner(kTRUE);
154 for ( int i = 1; i < argc[0]; ++i )
156 args.Add(new TObjString(argv[i]));
159 for ( Int_t i = 0; i <= args.GetLast(); ++i )
161 TString a(static_cast<TObjString*>(args.At(i))->String());
163 AliMUONAttPainter att;
165 att.SetPlane(kTRUE,kFALSE);
166 att.SetCathode(kFALSE,kFALSE);
167 att.SetViewPoint(kTRUE,kFALSE);
171 Int_t detElemId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
173 painter = new AliMUONDEPainter(att,detElemId);
175 painter->SetOutlined("*",kFALSE);
176 painter->SetOutlined("BUSPATCH",kTRUE);
178 painter->SetLine(1,4,3);
182 if ( a == "--chamber" )
184 Int_t chamberId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
186 painter = new AliMUONChamberPainter(att,chamberId-1);
188 painter->SetOutlined("*",kFALSE);
189 painter->SetOutlined("DE",kTRUE);
191 painter->SetLine(1,4,3);
199 pmf->ShiftClicked(painter,0x0);
206 //______________________________________________________________________________
207 AliMUONMchViewApplication::~AliMUONMchViewApplication()
210 delete fPainterMasterFrameList;
213 //_____________________________________________________________________________
214 AliMUONPainterMatrix*
215 AliMUONMchViewApplication::GenerateStartupMatrix()
217 /// Kind of bootstrap method to trigger the generation of all contours
219 AliCodeTimerAuto("",0);
221 AliMUONAttPainter att;
223 att.SetViewPoint(kTRUE,kFALSE);
224 att.SetCathode(kFALSE,kFALSE);
225 att.SetPlane(kTRUE,kFALSE);
227 AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix("Tracker",5,2);
229 for ( Int_t i = 0; i < 10; ++i )
231 AliMUONVPainter* painter = new AliMUONChamberPainter(att,i);
233 painter->SetResponder("Chamber");
235 painter->SetOutlined("*",kFALSE);
237 painter->SetOutlined("MANU",kTRUE);
239 for ( Int_t j = 0; j < 3; ++j )
241 painter->SetLine(j,1,4-j);
244 matrix->Adopt(painter);
246 AliMUONPainterRegistry::Instance()->Register(matrix);
250 //______________________________________________________________________________
252 AliMUONMchViewApplication::CompareData()
254 /// Launch compare data dialog
255 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
266 t->SetWindowName("mchview compare data tool");
267 t->SetIconName("mchview compare data tool");
272 //______________________________________________________________________________
274 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
276 /// Create the application menu bar
278 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
280 file->AddEntry("&Open...",fgkFILEOPEN);
281 file->AddEntry("&Save As...",fgkFILESAVEAS);
282 file->AddEntry("&Print As...",fgkFILEPRINTAS);
283 file->AddEntry("&Exit",fgkFILEEXIT);
285 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
287 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
288 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
290 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
291 about->AddEntry(FullVersion(),fgkABOUT);
293 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
294 about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
295 tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
297 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
298 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
299 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
301 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
303 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
306 //______________________________________________________________________________
308 AliMUONMchViewApplication::HandleMenu(Int_t i)
310 /// Handle the click of one menu item
337 //______________________________________________________________________________
339 AliMUONMchViewApplication::Open()
345 fileInfo.fFileTypes = fgkFileTypes;
347 delete[] fileInfo.fIniDir;
349 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
351 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
353 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
356 env->Set("LastOpenDir",fileInfo.fIniDir);
359 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
362 //______________________________________________________________________________
364 AliMUONMchViewApplication::Open(const char* filename)
366 /// Open a given file containing saved VTrackerDataMaker objects
368 TString sfilename(gSystem->ExpandPathName(filename));
370 if ( sfilename.Contains(TRegexp("^alien")) )
372 // insure we've initialized the grid...
375 TGrid::Connect("alien://");
379 TFile* f = TFile::Open(filename);
386 //______________________________________________________________________________
388 AliMUONMchViewApplication::ReadDir(TDirectory& dir)
390 /// Read the given directory and import VTrackerData objects found
392 TList* keys = dir.GetListOfKeys();
397 while ( ( k = static_cast<TKey*>(next()) ) )
399 TObject* object = k->ReadObj();
401 if ( object->InheritsFrom("TDirectory") )
403 TDirectory* d = static_cast<TDirectory*>(object);
408 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
410 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
413 AliMUONPainterDataRegistry::Instance()->Register(maker);
417 if ( object->InheritsFrom("AliMUONVTrackerData") )
419 // this is for backward compatibility. Early versions of mchview
420 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
422 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
425 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
426 AliMUONPainterDataRegistry::Instance()->Register(maker);
433 //______________________________________________________________________________
435 AliMUONMchViewApplication::PrintAs()
441 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
444 TIter next(fPainterMasterFrameList);
445 AliMUONPainterMasterFrame* pmf;
448 while ( ( pmf = static_cast<AliMUONPainterMasterFrame*>(next()) ) )
450 pmf->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)),
451 first ? "RECREATE" : "UPDATE");
456 //______________________________________________________________________________
458 AliMUONMchViewApplication::ReleaseNotes()
460 /// Display release notes
465 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
467 TGTextView* rn = new TGTextView(t);
471 rn->AddLine("Add Print buttons");
472 rn->AddLine("Add the automatic creation of often used canvases when using pedestal source");
473 // Internal reorganization to allow several independent tabs to be created to
474 // show different master frames (not used yet). Important for the moment
475 // is the ability to create a PainterMatrix and pass it to the PainterMasterFrame
480 rn->AddLine("Internal change (merging of AliMUONTrackerACFDataMaker and AliMUONTrackerOCDBDataMaker into AliMUONTrackerConditionDataMaker)");
481 rn->AddLine("Added --ocdb option");
482 rn->AddLine("Corrected the display of the configuration");
483 rn->AddLine("Corrected the interpretation of the switches for the HV display");
488 rn->AddLine("Added the configuration as a possible OCDB data source");
493 rn->AddLine("Added the Status and StatusMap as a possible OCDB data source");
495 rn->AddLine("Added one (computed) dimension to the Gains data source = 1/a1/0.2 (mV/fC)");
498 rn->AddLine("0.99a");
500 rn->AddLine("Added the --de and --chamber options");
505 rn->AddLine("The chamberid in the label (top right of panel) is now starting at 1 as in common usage");
510 rn->AddLine("Added --asciimapping option");
515 rn->AddLine("Adding calibration option with Emelec (aka injection) gain");
518 rn->AddLine("0.96a");
520 rn->AddLine("Internal reorganization of the contour computations, that lead to improved performance. ");
521 rn->AddLine("Improved enough to be able to remove completely the usage of the padstore.root file with precomputed contours.");
526 rn->AddLine("New features");
528 rn->AddLine("- Can now read raw data from memory (using the mem://@gdc: syntax)");
529 rn->AddLine("- Raw data decoder now automatically skips buspatches with parity errors");
534 rn->AddLine("New features");
536 rn->AddLine("- Can now read and display HV values from OCDB");
537 rn->AddLine("- New program option --geometry to force geometry of the window");
538 rn->AddLine("- Added possibility, in painters' context menu, to include or exclude part of the detector");
539 rn->AddLine(" (which will be used later on to communicate with LC2 which parts should be read out or not)");
541 rn->AddLine("Improvement");
543 rn->AddLine("- When displaying Gains, the quality information is now decoded");
548 rn->AddLine("New features");
550 rn->AddLine("Can now read ASCII calibration files produced by the DA");
555 rn->AddLine("New features");
557 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
558 rn->AddLine(" when switching between views");
559 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
560 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
561 rn->AddLine(" clicking on it will display an histo");
562 rn->AddLine("- Right-click on a painter will now display several histogram options");
563 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
564 rn->AddLine(" and sigma");
565 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
566 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
567 rn->AddLine(" in order to compare data.");
568 rn->AddLine(" - The --use option can now reference alien files");
570 rn->AddLine("Bug fixes");
572 rn->AddLine("- Can now read Capacitances from OCDB");
574 rn->Resize(width,height);
576 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
585 t->SetWindowName("mchview release notes");
586 t->SetIconName("mchview release notes");
588 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
589 // kMWMDecorMinimize | kMWMDecorMenu,
590 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
592 // kMWMInputModeless);
595 // gClient->WaitFor(t);
598 //______________________________________________________________________________
600 AliMUONMchViewApplication::Save()
602 /// Open "Save VTrackerData objects to file" dialog
606 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
609 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
612 //______________________________________________________________________________
614 AliMUONMchViewApplication::Save(const char* filename)
616 /// Save VTrackerDataMaker objects into file of given name
618 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
620 TFile f(filename,"RECREATE");
622 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
624 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);