1 #include "AliMUONMchViewApplication.h"
3 #include "AliCDBManager.h"
4 #include "AliCodeTimer.h"
6 #include "AliMUONPainterDataSourceFrame.h"
7 #include "AliMUONPainterEnv.h"
8 #include "AliMUONPainterHelper.h"
9 #include "AliMUONPainterMasterFrame.h"
10 #include "AliMUONPainterRegistry.h"
11 #include "AliMUONTrackerDataCompareDialog.h"
12 #include "AliMUONTrackerDataWrapper.h"
13 #include "AliMUONVTrackerData.h"
14 #include "AliMUONVTrackerDataMaker.h"
15 #include <Riostream.h>
20 #include <TGFileDialog.h>
23 #include <TGTextView.h>
31 /// \class AliMUONMchViewApplication
33 /// Main class for the mchview program
35 ///\author Laurent Aphecetche, Subatech
38 ClassImp(AliMUONMchViewApplication)
41 const Int_t AliMUONMchViewApplication::fgkFILESAVEAS(1);
42 const Int_t AliMUONMchViewApplication::fgkFILEOPEN(2);
43 const Int_t AliMUONMchViewApplication::fgkFILEEXIT(3);
44 const Int_t AliMUONMchViewApplication::fgkFILEPRINTAS(4);
45 const Int_t AliMUONMchViewApplication::fgkABOUT(5);
46 const Int_t AliMUONMchViewApplication::fgkCOMPAREDATA(6);
48 const char* AliMUONMchViewApplication::fgkFileTypes[] = {
49 "ROOT files", "*.root",
53 //______________________________________________________________________________
54 AliMUONMchViewApplication::AliMUONMchViewApplication(const char* name,
55 int* argc, char** argv,
58 : TRint(name,argc,argv),
60 fPainterMasterFrame(0x0)
64 /// wfraction,hfraction are the fractions of display width and height
65 /// we want to draw on
67 UInt_t dw = gClient->GetDisplayWidth();
68 UInt_t dh = gClient->GetDisplayHeight();
70 UInt_t w = (UInt_t)(wfraction*dw);
71 UInt_t h = (UInt_t)(hfraction*dh);
73 fMainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
79 // h -= 60; // menubar
81 TGTab* tabs = new TGTab(fMainFrame,w,h);
83 TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
86 new AliMUONPainterMasterFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
88 t->AddFrame(fPainterMasterFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
90 t = tabs->AddTab("Data Sources");
92 AliMUONPainterDataSourceFrame* dsf =
93 new AliMUONPainterDataSourceFrame(t,t->GetWidth()-kbs*2,t->GetHeight()-kbs*2);
95 t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,kbs,kbs,kbs,kbs));
97 fMainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
99 fMainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
101 fMainFrame->MapSubwindows();
102 fMainFrame->Resize();
104 fPainterMasterFrame->Update();
106 fMainFrame->MapWindow();
108 fMainFrame->Connect("CloseWindow()","AliMUONMchViewApplication",this,"Terminate()");
110 UInt_t x = dw/2 - w/2;
113 fMainFrame->MoveResize(x, y, w, h);
114 fMainFrame->SetWMPosition(x, y);
116 fMainFrame->SetWMSizeHints(w,h,w,h,0,0);
118 cout << "***************************************************" << endl;
119 cout << " Welcome to mchview" << endl;
120 cout << " " << FullVersion() << endl;
121 cout << "***************************************************" << endl;
125 //______________________________________________________________________________
126 AliMUONMchViewApplication::~AliMUONMchViewApplication()
131 //______________________________________________________________________________
133 AliMUONMchViewApplication::CompareData()
135 /// Launch compare data dialog
136 TGTransientFrame* t = new AliMUONTrackerDataCompareDialog(gClient->GetRoot(),
147 t->SetWindowName("mchview compare data tool");
148 t->SetIconName("mchview compare data tool");
154 //______________________________________________________________________________
156 AliMUONMchViewApplication::CreateMenuBar(UInt_t w)
158 /// Create the application menu bar
160 TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
162 file->AddEntry("&Open...",fgkFILEOPEN);
163 file->AddEntry("&Save As...",fgkFILESAVEAS);
164 file->AddEntry("&Print As...",fgkFILEPRINTAS);
165 file->AddEntry("&Exit",fgkFILEEXIT);
167 TGMenuBar* bar = new TGMenuBar(fMainFrame,w);
169 TGPopupMenu* tools = new TGPopupMenu(gClient->GetRoot());
170 tools->AddEntry("&Compare data",fgkCOMPAREDATA);
172 TGPopupMenu* about = new TGPopupMenu(gClient->GetRoot());
173 about->AddEntry(FullVersion(),fgkABOUT);
175 file->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
176 about->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
177 tools->Connect("Activated(Int_t)","AliMUONMchViewApplication",this,"HandleMenu(Int_t)");
179 bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
180 bar->AddPopup("&Tools",tools,new TGLayoutHints(kLHintsLeft|kLHintsTop));
181 bar->AddPopup("&About",about,new TGLayoutHints(kLHintsRight|kLHintsTop));
183 fMainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
185 AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
188 //______________________________________________________________________________
190 AliMUONMchViewApplication::HandleMenu(Int_t i)
192 /// Handle the click of one menu item
219 //______________________________________________________________________________
221 AliMUONMchViewApplication::Open()
227 fileInfo.fFileTypes = fgkFileTypes;
229 delete[] fileInfo.fIniDir;
231 AliMUONPainterEnv* env = AliMUONPainterHelper::Instance()->Env();
233 fileInfo.fIniDir = StrDup(env->String("LastOpenDir","."));
235 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
238 env->Set("LastOpenDir",fileInfo.fIniDir);
241 Open(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
244 //______________________________________________________________________________
246 AliMUONMchViewApplication::Open(const char* filename)
248 /// Open a given file containing saved VTrackerDataMaker objects
250 TString sfilename(gSystem->ExpandPathName(filename));
252 if ( sfilename.Contains(TRegexp("^alien")) )
254 // insure we've initialized the grid...
257 TGrid::Connect("alien://");
261 TFile* f = TFile::Open(filename);
263 TList* keys = f->GetListOfKeys();
268 while ( ( k = static_cast<TKey*>(next()) ) )
270 TObject* object = k->ReadObj();
272 if ( object->InheritsFrom("AliMUONVTrackerDataMaker") )
274 AliMUONVTrackerDataMaker* maker = dynamic_cast<AliMUONVTrackerDataMaker*>(object);
277 AliMUONPainterRegistry::Instance()->Register(maker);
281 if ( object->InheritsFrom("AliMUONVTrackerData") )
283 // this is for backward compatibility. Early versions of mchview
284 // wrote VTrackerData objects, and not VTrackerDataMaker ones.
286 AliMUONVTrackerData* data = dynamic_cast<AliMUONVTrackerData*>(object);
289 AliMUONVTrackerDataMaker* maker = new AliMUONTrackerDataWrapper(data);
290 AliMUONPainterRegistry::Instance()->Register(maker);
299 //______________________________________________________________________________
301 AliMUONMchViewApplication::PrintAs()
307 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
310 fPainterMasterFrame->SaveAs(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
313 //______________________________________________________________________________
315 AliMUONMchViewApplication::ReleaseNotes()
317 /// Display release notes
322 TGTransientFrame* t = new TGTransientFrame(gClient->GetRoot(),gClient->GetRoot(),width,height);
324 TGTextView* rn = new TGTextView(t);
328 rn->AddLine("New features");
330 rn->AddLine("- Adding a Lock button under the color slider to lock the range shown");
331 rn->AddLine(" when switching between views");
332 rn->AddLine("- Default display now shows bending plane (instead of cathode 0 before)");
333 rn->AddLine("- If pad is responder and there's some histo for that pad, ");
334 rn->AddLine(" clicking on it will display an histo");
335 rn->AddLine("- Right-click on a painter will now display several histogram options");
336 rn->AddLine(" (e.g. raw charge as before, but also simple distributions of mean");
337 rn->AddLine(" and sigma");
338 rn->AddLine("- In the Data Sources Tab, each data source can now be removed and saved");
339 rn->AddLine("- There's a new Tool menu which allow to produce a TrackerData from two others");
340 rn->AddLine(" in order to compare data.");
341 rn->AddLine(" - The --use option can now reference alien files");
343 rn->AddLine("Bug fixes");
345 rn->AddLine("- Can now read Capacitances from OCDB");
347 rn->Resize(width,height);
349 t->AddFrame(rn, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
358 t->SetWindowName("mchview release notes");
359 t->SetIconName("mchview release notes");
361 // t->SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
362 // kMWMDecorMinimize | kMWMDecorMenu,
363 // kMWMFuncAll | kMWMFuncResize | kMWMFuncMaximize |
365 // kMWMInputModeless);
368 // gClient->WaitFor(t);
371 //______________________________________________________________________________
373 AliMUONMchViewApplication::Save()
375 /// Open "Save VTrackerData objects to file" dialog
379 new TGFileDialog(gClient->GetRoot(),gClient->GetRoot(),
382 Save(gSystem->ExpandPathName(Form("%s",fileInfo.fFilename)));
385 //______________________________________________________________________________
387 AliMUONMchViewApplication::Save(const char* filename)
389 /// Save VTrackerDataMaker objects into file of given name
391 AliMUONPainterRegistry* reg = AliMUONPainterRegistry::Instance();
393 TFile f(filename,"RECREATE");
395 for ( Int_t i = 0; i < reg->NumberOfDataMakers(); ++i )
397 AliMUONVTrackerDataMaker* maker = reg->DataMaker(i);