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 "AliMUONAlignmentCompareDialog.h"
24 #include "AliMUONChamberPainter.h"
25 #include "AliMUONDEPainter.h"
26 #include "AliMUONPainterDataRegistry.h"
27 #include "AliMUONPainterDataSourceFrame.h"
28 #include "AliMUONPainterEnv.h"
29 #include "AliMUONPainterHelper.h"
30 #include "AliMUONPainterGroup.h"
31 #include "AliMUONPainterMasterFrame.h"
32 #include "AliMUONPainterMatrix.h"
33 #include "AliMUONPainterRegistry.h"
34 #include "AliMUONTrackerDataCompareDialog.h"
35 #include "AliMUONTrackerDataWrapper.h"
36 #include "AliMUONVTrackerData.h"
37 #include "AliMUONVTrackerDataMaker.h"
38 #include <Riostream.h>
43 #include <TGFileDialog.h>
46 #include <TGTextView.h>
54 /// \class AliMUONMchViewApplication
56 /// Main class for the mchview program
58 ///\author Laurent Aphecetche, Subatech
61 ClassImp(AliMUONMchViewApplication)
64 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
65 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
66 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
67 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
68 const Int_t AliMUONMchViewApplication::fgkABOUT(5);
69 const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
70 const Int_t AliMUONMchViewApplication::fgkCOMPAREALIGNMENTS(7);
72 const char* AliMUONMchViewApplication::fgkFileTypes[] = {
73 "ROOT files", "*.root",
77 //______________________________________________________________________________
78 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
79 int* argc, char** argv,
82 : TRint(name,argc,argv),
84 fPainterMasterFrameList(new TList),
89 /// (w,h) is the size in pixel (if 0,0 it will be computed as 70%,90% of display size)
90 /// (ox,oy) is the offset from the top-left of the display
94 w = (UInt_t)(gClient->GetDisplayWidth()*0.7);
95 h = (UInt_t)(gClient->GetDisplayHeight()*0.9);
98 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
104 // h -= 60; // menubar
106 fTabs = new TGTab(fMainFrame,w,h);
108 TGCompositeFrame* t = fTabs->AddTab("Painter Master Frame");
110 fPainterMasterFrameList->SetOwner(kTRUE);
113 AliMUONPainterMasterFrame* pmf = new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2,
114 GenerateStartupMatrix());
116 fPainterMasterFrameList->Add(pmf);
118 t->AddFrame(pmf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
120 t = fTabs->AddTab("Data Sources");
122 AliMUONPainterDataSourceFrame* dsf =
123 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
125 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
127 fMainFrame->AddFrame(fTabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
129 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
131 fMainFrame->MapSubwindows();
132 fMainFrame->Resize();
136 fMainFrame->MapWindow();
138 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
140 // fMainFrame->MoveResize(ox,oy, w, h);
141 fMainFrame->SetWMPosition(ox, oy);
142 // fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
143 // fMainFrame->SetWMSizeHints(w,h,w,h,10,10);
145 cout << "***************************************************" << endl;
146 cout << " Welcome to mchview" << endl;
147 cout << " " << FullVersion() << endl;
148 cout << "***************************************************" << endl;
150 // Trying to see if we're requested to draw something specific instead
151 // of the global view of all the chambers
153 AliMUONVPainter* painter(0x0);
155 args.SetOwner(kTRUE);
157 for ( int i = 1; i < argc[0]; ++i )
159 args.Add(new TObjString(argv[i]));
162 for ( Int_t i = 0; i <= args.GetLast(); ++i )
164 TString a(static_cast<TObjString*>(args.At(i))->String());
166 AliMUONAttPainter att;
168 att.SetPlane(kTRUE,kFALSE);
169 att.SetCathode(kFALSE,kFALSE);
170 att.SetViewPoint(kTRUE,kFALSE);
174 Int_t detElemId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
176 painter = new AliMUONDEPainter(att,detElemId);
178 painter->SetOutlined("*",kFALSE);
179 painter->SetOutlined("BUSPATCH",kTRUE);
181 painter->SetLine(1,4,3);
185 if ( a == "--chamber" )
187 Int_t chamberId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
189 painter = new AliMUONChamberPainter(att,chamberId-1);
191 painter->SetOutlined("*",kFALSE);
192 painter->SetOutlined("DE",kTRUE);
194 painter->SetLine(1,4,3);
202 pmf->ShiftClicked(painter,0x0);
209 //______________________________________________________________________________
210 AliMUONMchViewApplication::~AliMUONMchViewApplication()
213 delete fPainterMasterFrameList;
216 //_____________________________________________________________________________
217 AliMUONPainterMatrix*
218 AliMUONMchViewApplication::GenerateStartupMatrix()
220 /// Kind of bootstrap method to trigger the generation of all contours
222 AliCodeTimerAuto("",0);
224 AliMUONAttPainter att;
226 att.SetViewPoint(kTRUE,kFALSE);
227 att.SetCathode(kFALSE,kFALSE);
228 att.SetPlane(kTRUE,kFALSE);
230 AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix("Tracker",5,2);
232 for ( Int_t i = 0; i < 10; ++i )
234 AliMUONVPainter* painter = new AliMUONChamberPainter(att,i);
236 painter->SetResponder("Chamber");
238 painter->SetOutlined("*",kFALSE);
240 painter->SetOutlined("MANU",kTRUE);
242 for ( Int_t j = 0; j < 3; ++j )
244 painter->SetLine(j,1,4-j);
247 matrix->Adopt(painter);
249 AliMUONPainterRegistry::Instance()->Register(matrix);
253 //______________________________________________________________________________
255 AliMUONMchViewApplication::CompareAlignments()
257 /// Launch compare data dialog
258 TGTransientFrame* t = new AliMUONAlignmentCompareDialog(gClient->GetRoot(),
269 t->SetWindowName("mchview compare alignments tool");
270 t->SetIconName("mchview compare alignments tool");
275 //______________________________________________________________________________
277 AliMUONMchViewApplication::CompareData()
279 /// Launch compare data dialog
280 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
291 t->SetWindowName("mchview compare data tool");
292 t->SetIconName("mchview compare data tool");
297 //______________________________________________________________________________
299 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
301 /// Create the application menu bar
303 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
305 file->AddEntry("&Open...",fgkFILEOPEN);
306 file->AddEntry("&Save As...",fgkFILESAVEAS);
307 file->AddEntry("&Print As...",fgkFILEPRINTAS);
308 file->AddEntry("&Exit",fgkFILEEXIT);
310 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
312 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
313 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
314 tools->AddEntry("&Compare alignments",fgkCOMPAREALIGNMENTS);
316 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
317 about->AddEntry(FullVersion(),fgkABOUT);
319 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
320 about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
321 tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
323 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
324 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
325 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
327 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
329 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
332 //______________________________________________________________________________
334 AliMUONMchViewApplication::HandleMenu(Int_t i)
336 /// Handle the click of one menu item
358 case fgkCOMPAREALIGNMENTS:
366 //______________________________________________________________________________
368 AliMUONMchViewApplication::Open()
374 fileInfo.fFileTypes = fgkFileTypes;
376 delete[] fileInfo.fIniDir;
378 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
380 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
382 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
385 env->Set("LastOpenDir",fileInfo.fIniDir);
388 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
391 //______________________________________________________________________________
393 AliMUONMchViewApplication::Open(const char* filename)
395 /// Open a given file containing saved VTrackerDataMaker objects
397 TString sfilename(gSystem->ExpandPathName(filename));
399 if ( sfilename.Contains(TRegexp("^alien")) )
401 // insure we've initialized the grid...
404 TGrid::Connect("alien://");
408 TFile* f = TFile::Open(filename);
415 //______________________________________________________________________________
417 AliMUONMchViewApplication::ReadDir(TDirectory& dir)
419 /// Read the given directory and import VTrackerData objects found
421 TList* keys = dir.GetListOfKeys();
426 while ( ( k = static_cast<TKey*>(next()) ) )
428 TObject* object = k->ReadObj();
430 if ( object->InheritsFrom("TDirectory") )
432 TDirectory* d = static_cast<TDirectory*>(object);
437 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
439 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
442 AliMUONPainterDataRegistry::Instance()->Register(maker);
446 if ( object->InheritsFrom("AliMUONVTrackerData") )
448 // this is for backward compatibility. Early versions of mchview
449 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
451 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
454 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
455 AliMUONPainterDataRegistry::Instance()->Register(maker);
462 //______________________________________________________________________________
464 AliMUONMchViewApplication::PrintAs()
470 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
473 TIter next(fPainterMasterFrameList);
474 AliMUONPainterMasterFrame* pmf;
477 while ( ( pmf = static_cast<AliMUONPainterMasterFrame*>(next()) ) )
479 pmf->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)),
480 first ? "RECREATE" : "UPDATE");
485 //______________________________________________________________________________
487 AliMUONMchViewApplication::ReleaseNotes()
489 /// Display release notes
494 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
496 TGTextView* rn = new TGTextView(t);
500 rn->AddLine("Adding [Compare alignments] in the Tools menu + make default OCDB be 2012's version");
505 rn->AddLine("Make the raw OCDB more obvious in the data source tab");
510 rn->AddLine("Changed the default OCDB to 2011 version");
515 rn->AddLine("Added the RejectList as a possible OCDB data source");
520 rn->AddLine("Changed a bit the HV display. Now a trip is indicated with a value of -1");
525 rn->AddLine("Added the possibility to select an event range when reading raw data");
526 rn->AddLine("Usefull e.g. to look at a single suspect event...");
531 rn->AddLine("Changed the default OCDB to 2010 version");
536 rn->AddLine("Add Print buttons");
537 rn->AddLine("Add the automatic creation of often used canvases when using pedestal source");
538 // Internal reorganization to allow several independent tabs to be created to
539 // show different master frames (not used yet). Important for the moment
540 // is the ability to create a PainterMatrix and pass it to the PainterMasterFrame
545 rn->AddLine("Internal change (merging of AliMUONTrackerACFDataMaker and AliMUONTrackerOCDBDataMaker into AliMUONTrackerConditionDataMaker)");
546 rn->AddLine("Added --ocdb option");
547 rn->AddLine("Corrected the display of the configuration");
548 rn->AddLine("Corrected the interpretation of the switches for the HV display");
553 rn->AddLine("Added the configuration as a possible OCDB data source");
558 rn->AddLine("Added the Status and StatusMap as a possible OCDB data source");
560 rn->AddLine("Added one (computed) dimension to the Gains data source = 1/a1/0.2 (mV/fC)");
563 rn->AddLine("0.99a");
565 rn->AddLine("Added the --de and --chamber options");
570 rn->AddLine("The chamberid in the label (top right of panel) is now starting at 1 as in common usage");
575 rn->AddLine("Added --asciimapping option");
580 rn->AddLine("Adding calibration option with Emelec (aka injection) gain");
583 rn->AddLine("0.96a");
585 rn->AddLine("Internal reorganization of the contour computations, that lead to improved performance. ");
586 rn->AddLine("Improved enough to be able to remove completely the usage of the padstore.root file with precomputed contours.");
591 rn->AddLine("New features");
593 rn->AddLine("- Can now read raw data from memory (using the mem://@gdc: syntax)");
594 rn->AddLine("- Raw data decoder now automatically skips buspatches with parity errors");
599 rn->AddLine("New features");
601 rn->AddLine("- Can now read and display HV values from OCDB");
602 rn->AddLine("- New program option --geometry to force geometry of the window");
603 rn->AddLine("- Added possibility, in painters' context menu, to include or exclude part of the detector");
604 rn->AddLine(" (which will be used later on to communicate with LC2 which parts should be read out or not)");
606 rn->AddLine("Improvement");
608 rn->AddLine("- When displaying Gains, the quality information is now decoded");
613 rn->AddLine("New features");
615 rn->AddLine("Can now read ASCII calibration files produced by the DA");
620 rn->AddLine("New features");
622 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
623 rn->AddLine(" when switching between views");
624 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
625 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
626 rn->AddLine(" clicking on it will display an histo");
627 rn->AddLine("- Right-click on a painter will now display several histogram options");
628 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
629 rn->AddLine(" and sigma");
630 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
631 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
632 rn->AddLine(" in order to compare data.");
633 rn->AddLine(" - The --use option can now reference alien files");
635 rn->AddLine("Bug fixes");
637 rn->AddLine("- Can now read Capacitances from OCDB");
639 rn->Resize(width,height);
641 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
650 t->SetWindowName("mchview release notes");
651 t->SetIconName("mchview release notes");
653 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
654 // kMWMDecorMinimize | kMWMDecorMenu,
655 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
657 // kMWMInputModeless);
660 // gClient->WaitFor(t);
663 //______________________________________________________________________________
665 AliMUONMchViewApplication::Save()
667 /// Open "Save VTrackerData objects to file" dialog
671 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
674 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
677 //______________________________________________________________________________
679 AliMUONMchViewApplication::Save(const char* filename)
681 /// Save VTrackerDataMaker objects into file of given name
683 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
685 TFile f(filename,"RECREATE");
687 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
689 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);