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);
141 // fMainFrame->SetWMSizeHints(w,h,w,h,10,10);
143 cout << "***************************************************" << endl;
144 cout << " Welcome to mchview" << endl;
145 cout << " " << FullVersion() << endl;
146 cout << "***************************************************" << endl;
148 // Trying to see if we're requested to draw something specific instead
149 // of the global view of all the chambers
151 AliMUONVPainter* painter(0x0);
153 args.SetOwner(kTRUE);
155 for ( int i = 1; i < argc[0]; ++i )
157 args.Add(new TObjString(argv[i]));
160 for ( Int_t i = 0; i <= args.GetLast(); ++i )
162 TString a(static_cast<TObjString*>(args.At(i))->String());
164 AliMUONAttPainter att;
166 att.SetPlane(kTRUE,kFALSE);
167 att.SetCathode(kFALSE,kFALSE);
168 att.SetViewPoint(kTRUE,kFALSE);
172 Int_t detElemId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
174 painter = new AliMUONDEPainter(att,detElemId);
176 painter->SetOutlined("*",kFALSE);
177 painter->SetOutlined("BUSPATCH",kTRUE);
179 painter->SetLine(1,4,3);
183 if ( a == "--chamber" )
185 Int_t chamberId = static_cast<TObjString*>(args.At(i+1))->String().Atoi();
187 painter = new AliMUONChamberPainter(att,chamberId-1);
189 painter->SetOutlined("*",kFALSE);
190 painter->SetOutlined("DE",kTRUE);
192 painter->SetLine(1,4,3);
200 pmf->ShiftClicked(painter,0x0);
207 //______________________________________________________________________________
208 AliMUONMchViewApplication::~AliMUONMchViewApplication()
211 delete fPainterMasterFrameList;
214 //_____________________________________________________________________________
215 AliMUONPainterMatrix*
216 AliMUONMchViewApplication::GenerateStartupMatrix()
218 /// Kind of bootstrap method to trigger the generation of all contours
220 AliCodeTimerAuto("",0);
222 AliMUONAttPainter att;
224 att.SetViewPoint(kTRUE,kFALSE);
225 att.SetCathode(kFALSE,kFALSE);
226 att.SetPlane(kTRUE,kFALSE);
228 AliMUONPainterMatrix* matrix = new AliMUONPainterMatrix("Tracker",5,2);
230 for ( Int_t i = 0; i < 10; ++i )
232 AliMUONVPainter* painter = new AliMUONChamberPainter(att,i);
234 painter->SetResponder("Chamber");
236 painter->SetOutlined("*",kFALSE);
238 painter->SetOutlined("MANU",kTRUE);
240 for ( Int_t j = 0; j < 3; ++j )
242 painter->SetLine(j,1,4-j);
245 matrix->Adopt(painter);
247 AliMUONPainterRegistry::Instance()->Register(matrix);
251 //______________________________________________________________________________
253 AliMUONMchViewApplication::CompareData()
255 /// Launch compare data dialog
256 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
267 t->SetWindowName("mchview compare data tool");
268 t->SetIconName("mchview compare data tool");
273 //______________________________________________________________________________
275 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
277 /// Create the application menu bar
279 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
281 file->AddEntry("&Open...",fgkFILEOPEN);
282 file->AddEntry("&Save As...",fgkFILESAVEAS);
283 file->AddEntry("&Print As...",fgkFILEPRINTAS);
284 file->AddEntry("&Exit",fgkFILEEXIT);
286 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
288 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
289 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
291 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
292 about->AddEntry(FullVersion(),fgkABOUT);
294 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
295 about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
296 tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
298 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
299 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
300 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
302 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
304 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
307 //______________________________________________________________________________
309 AliMUONMchViewApplication::HandleMenu(Int_t i)
311 /// Handle the click of one menu item
338 //______________________________________________________________________________
340 AliMUONMchViewApplication::Open()
346 fileInfo.fFileTypes = fgkFileTypes;
348 delete[] fileInfo.fIniDir;
350 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
352 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
354 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
357 env->Set("LastOpenDir",fileInfo.fIniDir);
360 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
363 //______________________________________________________________________________
365 AliMUONMchViewApplication::Open(const char* filename)
367 /// Open a given file containing saved VTrackerDataMaker objects
369 TString sfilename(gSystem->ExpandPathName(filename));
371 if ( sfilename.Contains(TRegexp("^alien")) )
373 // insure we've initialized the grid...
376 TGrid::Connect("alien://");
380 TFile* f = TFile::Open(filename);
387 //______________________________________________________________________________
389 AliMUONMchViewApplication::ReadDir(TDirectory& dir)
391 /// Read the given directory and import VTrackerData objects found
393 TList* keys = dir.GetListOfKeys();
398 while ( ( k = static_cast<TKey*>(next()) ) )
400 TObject* object = k->ReadObj();
402 if ( object->InheritsFrom("TDirectory") )
404 TDirectory* d = static_cast<TDirectory*>(object);
409 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
411 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
414 AliMUONPainterDataRegistry::Instance()->Register(maker);
418 if ( object->InheritsFrom("AliMUONVTrackerData") )
420 // this is for backward compatibility. Early versions of mchview
421 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
423 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
426 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
427 AliMUONPainterDataRegistry::Instance()->Register(maker);
434 //______________________________________________________________________________
436 AliMUONMchViewApplication::PrintAs()
442 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
445 TIter next(fPainterMasterFrameList);
446 AliMUONPainterMasterFrame* pmf;
449 while ( ( pmf = static_cast<AliMUONPainterMasterFrame*>(next()) ) )
451 pmf->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)),
452 first ? "RECREATE" : "UPDATE");
457 //______________________________________________________________________________
459 AliMUONMchViewApplication::ReleaseNotes()
461 /// Display release notes
466 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
468 TGTextView* rn = new TGTextView(t);
472 rn->AddLine("Make the raw OCDB more obvious in the data source tab");
477 rn->AddLine("Changed the default OCDB to 2011 version");
482 rn->AddLine("Added the RejectList as a possible OCDB data source");
487 rn->AddLine("Changed a bit the HV display. Now a trip is indicated with a value of -1");
492 rn->AddLine("Added the possibility to select an event range when reading raw data");
493 rn->AddLine("Usefull e.g. to look at a single suspect event...");
498 rn->AddLine("Changed the default OCDB to 2010 version");
503 rn->AddLine("Add Print buttons");
504 rn->AddLine("Add the automatic creation of often used canvases when using pedestal source");
505 // Internal reorganization to allow several independent tabs to be created to
506 // show different master frames (not used yet). Important for the moment
507 // is the ability to create a PainterMatrix and pass it to the PainterMasterFrame
512 rn->AddLine("Internal change (merging of AliMUONTrackerACFDataMaker and AliMUONTrackerOCDBDataMaker into AliMUONTrackerConditionDataMaker)");
513 rn->AddLine("Added --ocdb option");
514 rn->AddLine("Corrected the display of the configuration");
515 rn->AddLine("Corrected the interpretation of the switches for the HV display");
520 rn->AddLine("Added the configuration as a possible OCDB data source");
525 rn->AddLine("Added the Status and StatusMap as a possible OCDB data source");
527 rn->AddLine("Added one (computed) dimension to the Gains data source = 1/a1/0.2 (mV/fC)");
530 rn->AddLine("0.99a");
532 rn->AddLine("Added the --de and --chamber options");
537 rn->AddLine("The chamberid in the label (top right of panel) is now starting at 1 as in common usage");
542 rn->AddLine("Added --asciimapping option");
547 rn->AddLine("Adding calibration option with Emelec (aka injection) gain");
550 rn->AddLine("0.96a");
552 rn->AddLine("Internal reorganization of the contour computations, that lead to improved performance. ");
553 rn->AddLine("Improved enough to be able to remove completely the usage of the padstore.root file with precomputed contours.");
558 rn->AddLine("New features");
560 rn->AddLine("- Can now read raw data from memory (using the mem://@gdc: syntax)");
561 rn->AddLine("- Raw data decoder now automatically skips buspatches with parity errors");
566 rn->AddLine("New features");
568 rn->AddLine("- Can now read and display HV values from OCDB");
569 rn->AddLine("- New program option --geometry to force geometry of the window");
570 rn->AddLine("- Added possibility, in painters' context menu, to include or exclude part of the detector");
571 rn->AddLine(" (which will be used later on to communicate with LC2 which parts should be read out or not)");
573 rn->AddLine("Improvement");
575 rn->AddLine("- When displaying Gains, the quality information is now decoded");
580 rn->AddLine("New features");
582 rn->AddLine("Can now read ASCII calibration files produced by the DA");
587 rn->AddLine("New features");
589 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
590 rn->AddLine(" when switching between views");
591 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
592 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
593 rn->AddLine(" clicking on it will display an histo");
594 rn->AddLine("- Right-click on a painter will now display several histogram options");
595 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
596 rn->AddLine(" and sigma");
597 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
598 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
599 rn->AddLine(" in order to compare data.");
600 rn->AddLine(" - The --use option can now reference alien files");
602 rn->AddLine("Bug fixes");
604 rn->AddLine("- Can now read Capacitances from OCDB");
606 rn->Resize(width,height);
608 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
617 t->SetWindowName("mchview release notes");
618 t->SetIconName("mchview release notes");
620 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
621 // kMWMDecorMinimize | kMWMDecorMenu,
622 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
624 // kMWMInputModeless);
627 // gClient->WaitFor(t);
630 //______________________________________________________________________________
632 AliMUONMchViewApplication::Save()
634 /// Open "Save VTrackerData objects to file" dialog
638 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
641 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
644 //______________________________________________________________________________
646 AliMUONMchViewApplication::Save(const char* filename)
648 /// Save VTrackerDataMaker objects into file of given name
650 AliMUONPainterDataRegistry* reg = AliMUONPainterDataRegistry::Instance();
652 TFile f(filename,"RECREATE");
654 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
656 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);