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
63 ClassImp(AliMUONMchViewApplication)
66 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
67 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
68 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
69 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
70 const Int_t AliMUONMchViewApplication::fgkABOUT(5);
71 const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
72 const Int_t AliMUONMchViewApplication::fgkCOMPAREALIGNMENTS(7);
74 const char* AliMUONMchViewApplication::fgkFileTypes[] = {
75 "ROOT files", "*.root",
79 //______________________________________________________________________________
80 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
81 int* argc, char** argv,
84 : TRint(name,argc,argv),
86 fPainterMasterFrameList(new TList),
91 /// (w,h) is the size in pixel (if 0,0 it will be computed as 70%,90% of display size)
92 /// (ox,oy) is the offset from the top-left of the display
96 w = (UInt_t)(gClient->GetDisplayWidth()*0.7);
97 h = (UInt_t)(gClient->GetDisplayHeight()*0.9);
100 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
106 // h -= 60; // menubar
108 fTabs = new TGTab(fMainFrame,w,h);
110 TGCompositeFrame* t = fTabs->AddTab("Painter Master Frame");
112 fPainterMasterFrameList->SetOwner(kTRUE);
115 AliMUONPainterMasterFrame* pmf = new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2,
116 GenerateStartupMatrix());
118 fPainterMasterFrameList->Add(pmf);
120 t->AddFrame(pmf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
122 t = fTabs->AddTab("Data Sources");
124 AliMUONPainterDataSourceFrame* dsf =
125 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
127 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
129 fMainFrame->AddFrame(fTabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
131 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
133 fMainFrame->MapSubwindows();
134 fMainFrame->Resize();
138 fMainFrame->MapWindow();
140 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
142 // fMainFrame->MoveResize(ox,oy, w, h);
143 fMainFrame->SetWMPosition(ox, oy);
144 // fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
145 // fMainFrame->SetWMSizeHints(w,h,w,h,10,10);
147 cout << "***************************************************" << endl;
148 cout << " Welcome to mchview" << endl;
149 cout << " " << FullVersion() << endl;
150 cout << "***************************************************" << endl;
152 // Trying to see if we're requested to draw something specific instead
153 // of the global view of all the chambers
155 AliMUONVPainter* painter(0x0);
157 args.SetOwner(kTRUE);
159 for ( int i = 1; i < argc[0]; ++i )
161 args.Add(new TObjString(argv[i]));
164 for ( Int_t i = 0; i <= args.GetLast(); ++i )
166 TString a(static_cast<TObjString*>(args.At(i))->String());
168 AliMUONAttPainter att;
170 att.SetPlane(kTRUE,kFALSE);
171 att.SetCathode(kFALSE,kFALSE);
172 att.SetViewPoint(kTRUE,kFALSE);
176 Int_t detElemId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
178 painter = new AliMUONDEPainter(att,detElemId);
180 painter->SetOutlined("*",kFALSE);
181 painter->SetOutlined("BUSPATCH",kTRUE);
183 painter->SetLine(1,4,3);
187 if ( a == "--chamber" )
189 Int_t chamberId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
191 painter = new AliMUONChamberPainter(att,chamberId-1);
193 painter->SetOutlined("*",kFALSE);
194 painter->SetOutlined("DE",kTRUE);
196 painter->SetLine(1,4,3);
204 pmf->ShiftClicked(painter,0x0);
211 //______________________________________________________________________________
212 AliMUONMchViewApplication::~AliMUONMchViewApplication()
215 delete fPainterMasterFrameList;
218 //_____________________________________________________________________________
219 AliMUONPainterMatrix*
220 AliMUONMchViewApplication::GenerateStartupMatrix()
222 /// Kind of bootstrap method to trigger the generation of all contours
224 AliCodeTimerAuto("",0);
226 AliMUONAttPainter att;
228 att.SetViewPoint(kTRUE,kFALSE);
229 att.SetCathode(kFALSE,kFALSE);
230 att.SetPlane(kTRUE,kFALSE);
232 AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix("Tracker",5,2);
234 for ( Int_t i = 0; i < 10; ++i )
236 AliMUONVPainter* painter = new AliMUONChamberPainter(att,i);
238 painter->SetResponder("Chamber");
240 painter->SetOutlined("*",kFALSE);
242 painter->SetOutlined("MANU",kTRUE);
244 for ( Int_t j = 0; j < 3; ++j )
246 painter->SetLine(j,1,4-j);
249 matrix->Adopt(painter);
251 AliMUONPainterRegistry::Instance()->Register(matrix);
255 //______________________________________________________________________________
257 AliMUONMchViewApplication::CompareAlignments()
259 /// Launch compare data dialog
260 TGTransientFrame* t = new AliMUONAlignmentCompareDialog(gClient->GetRoot(),
271 t->SetWindowName("mchview compare alignments tool");
272 t->SetIconName("mchview compare alignments tool");
277 //______________________________________________________________________________
279 AliMUONMchViewApplication::CompareData()
281 /// Launch compare data dialog
282 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
293 t->SetWindowName("mchview compare data tool");
294 t->SetIconName("mchview compare data tool");
299 //______________________________________________________________________________
301 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
303 /// Create the application menu bar
305 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
307 file->AddEntry("&Open...",fgkFILEOPEN);
308 file->AddEntry("&Save As...",fgkFILESAVEAS);
309 file->AddEntry("&Print As...",fgkFILEPRINTAS);
310 file->AddEntry("&Exit",fgkFILEEXIT);
312 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
314 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
315 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
316 tools->AddEntry("&Compare alignments",fgkCOMPAREALIGNMENTS);
318 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
319 about->AddEntry(FullVersion(),fgkABOUT);
321 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
322 about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
323 tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
325 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
326 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
327 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
329 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
331 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
334 //______________________________________________________________________________
336 AliMUONMchViewApplication::HandleMenu(Int_t i)
338 /// Handle the click of one menu item
360 case fgkCOMPAREALIGNMENTS:
368 //______________________________________________________________________________
370 AliMUONMchViewApplication::Open()
376 fileInfo.fFileTypes = fgkFileTypes;
378 delete[] fileInfo.fIniDir;
380 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
382 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
384 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
387 env->Set("LastOpenDir",fileInfo.fIniDir);
390 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
393 //______________________________________________________________________________
395 AliMUONMchViewApplication::Open(const char* filename)
397 /// Open a given file containing saved VTrackerDataMaker objects
399 TString sfilename(gSystem->ExpandPathName(filename));
401 if ( sfilename.Contains(TRegexp("^alien")) )
403 // insure we've initialized the grid...
406 TGrid::Connect("alien://");
410 TFile* f = TFile::Open(filename);
417 //______________________________________________________________________________
419 AliMUONMchViewApplication::ReadDir(TDirectory& dir)
421 /// Read the given directory and import VTrackerData objects found
423 TList* keys = dir.GetListOfKeys();
428 while ( ( k = static_cast<TKey*>(next()) ) )
430 TObject* object = k->ReadObj();
432 if ( object->InheritsFrom("TDirectory") )
434 TDirectory* d = static_cast<TDirectory*>(object);
439 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
441 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
444 AliMUONPainterDataRegistry::Instance()->Register(maker);
448 if ( object->InheritsFrom("AliMUONVTrackerData") )
450 // this is for backward compatibility. Early versions of mchview
451 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
453 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
456 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
457 AliMUONPainterDataRegistry::Instance()->Register(maker);
464 //______________________________________________________________________________
466 AliMUONMchViewApplication::PrintAs()
472 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
475 TIter next(fPainterMasterFrameList);
476 AliMUONPainterMasterFrame* pmf;
479 while ( ( pmf = static_cast<AliMUONPainterMasterFrame*>(next()) ) )
481 pmf->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)),
482 first ? "RECREATE" : "UPDATE");
487 //______________________________________________________________________________
489 AliMUONMchViewApplication::ReleaseNotes()
491 /// Display release notes
496 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
498 TGTextView* rn = new TGTextView(t);
502 rn->AddLine("Adding [Compare alignments] in the Tools menu + make default OCDB be 2012's version");
507 rn->AddLine("Make the raw OCDB more obvious in the data source tab");
512 rn->AddLine("Changed the default OCDB to 2011 version");
517 rn->AddLine("Added the RejectList as a possible OCDB data source");
522 rn->AddLine("Changed a bit the HV display. Now a trip is indicated with a value of -1");
527 rn->AddLine("Added the possibility to select an event range when reading raw data");
528 rn->AddLine("Usefull e.g. to look at a single suspect event...");
533 rn->AddLine("Changed the default OCDB to 2010 version");
538 rn->AddLine("Add Print buttons");
539 rn->AddLine("Add the automatic creation of often used canvases when using pedestal source");
540 // Internal reorganization to allow several independent tabs to be created to
541 // show different master frames (not used yet). Important for the moment
542 // is the ability to create a PainterMatrix and pass it to the PainterMasterFrame
547 rn->AddLine("Internal change (merging of AliMUONTrackerACFDataMaker and AliMUONTrackerOCDBDataMaker into AliMUONTrackerConditionDataMaker)");
548 rn->AddLine("Added --ocdb option");
549 rn->AddLine("Corrected the display of the configuration");
550 rn->AddLine("Corrected the interpretation of the switches for the HV display");
555 rn->AddLine("Added the configuration as a possible OCDB data source");
560 rn->AddLine("Added the Status and StatusMap as a possible OCDB data source");
562 rn->AddLine("Added one (computed) dimension to the Gains data source = 1/a1/0.2 (mV/fC)");
565 rn->AddLine("0.99a");
567 rn->AddLine("Added the --de and --chamber options");
572 rn->AddLine("The chamberid in the label (top right of panel) is now starting at 1 as in common usage");
577 rn->AddLine("Added --asciimapping option");
582 rn->AddLine("Adding calibration option with Emelec (aka injection) gain");
585 rn->AddLine("0.96a");
587 rn->AddLine("Internal reorganization of the contour computations, that lead to improved performance. ");
588 rn->AddLine("Improved enough to be able to remove completely the usage of the padstore.root file with precomputed contours.");
593 rn->AddLine("New features");
595 rn->AddLine("- Can now read raw data from memory (using the mem://@gdc: syntax)");
596 rn->AddLine("- Raw data decoder now automatically skips buspatches with parity errors");
601 rn->AddLine("New features");
603 rn->AddLine("- Can now read and display HV values from OCDB");
604 rn->AddLine("- New program option --geometry to force geometry of the window");
605 rn->AddLine("- Added possibility, in painters' context menu, to include or exclude part of the detector");
606 rn->AddLine(" (which will be used later on to communicate with LC2 which parts should be read out or not)");
608 rn->AddLine("Improvement");
610 rn->AddLine("- When displaying Gains, the quality information is now decoded");
615 rn->AddLine("New features");
617 rn->AddLine("Can now read ASCII calibration files produced by the DA");
622 rn->AddLine("New features");
624 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
625 rn->AddLine(" when switching between views");
626 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
627 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
628 rn->AddLine(" clicking on it will display an histo");
629 rn->AddLine("- Right-click on a painter will now display several histogram options");
630 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
631 rn->AddLine(" and sigma");
632 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
633 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
634 rn->AddLine(" in order to compare data.");
635 rn->AddLine(" - The --use option can now reference alien files");
637 rn->AddLine("Bug fixes");
639 rn->AddLine("- Can now read Capacitances from OCDB");
641 rn->Resize(width,height);
643 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
652 t->SetWindowName("mchview release notes");
653 t->SetIconName("mchview release notes");
655 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
656 // kMWMDecorMinimize | kMWMDecorMenu,
657 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
659 // kMWMInputModeless);
662 // gClient->WaitFor(t);
665 //______________________________________________________________________________
667 AliMUONMchViewApplication::Save()
669 /// Open "Save VTrackerData objects to file" dialog
673 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
676 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
679 //______________________________________________________________________________
681 AliMUONMchViewApplication::Save(const char* filename)
683 /// Save VTrackerDataMaker objects into file of given name
685 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
687 TFile f(filename,"RECREATE");
689 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
691 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);