/// \author Laurent Aphecetche, Subatech
-#include "AliMUONPainterDataSourceFrame.h"
-#include "AliMUONPainterHelper.h"
-#include "AliMUONPainterMasterFrame.h"
-#include "AliMUONPainterRegistry.h"
+#include "AliMUONMchViewApplication.h"
+
#include "AliCDBManager.h"
#include "AliCodeTimer.h"
#include "AliLog.h"
+#include "AliMUONPainterHelper.h"
#include <Riostream.h>
-#include <TCanvas.h>
-#include <TEnv.h>
-#include <TGMenu.h>
-#include <TGTab.h>
+#include <TObjArray.h>
+#include <TObjString.h>
#include <TROOT.h>
-#include <TRint.h>
-#include <TString.h>
#include <TStyle.h>
-//_____________________________________________________________________________
-void CreateMenuBar(TRint* app, TGMainFrame* mainFrame, UInt_t w)
+#include "AliMpDataProcessor.h"
+#include "AliMpDataMap.h"
+#include "AliMpDataStreams.h"
+#include "AliMpDDLStore.h"
+
+
+//______________________________________________________________________________
+Int_t Usage()
{
-///
+ /// Printout available options of the program
+ cout << "mchview " << endl;
+ cout << " --version : shows the current version of the program" << endl;
+ cout << " --use filename.root : reuse a previously saved (from this program) root file. Several --use can be used ;-)" << endl;
+ cout << " --geometry #x#+#+# : manually specify the geometry of the window, ala X11..., e.g. --geometry 1280x900+1600+0 will" << endl;
+ cout << " get a window of size 1280x900, located at (1600,0) from the top-left of the (multihead) display " << endl;
+ cout << " --asciimapping : load mapping from ASCII files instead of OCDB (for debug and experts only...)" << endl;
+ return -1;
+}
- TGPopupMenu* file = new TGPopupMenu(gClient->GetRoot());
+//______________________________________________________________________________
+int main(int argc, char** argv)
+{
+ /// Main function for the program
+ TObjArray args;
- file->AddEntry("&Exit",1);
+ for ( int i = 1; i < argc; ++i )
+ {
+ args.Add(new TObjString(argv[i]));
+ }
- file->Connect("Activated(Int_t)","TRint",app,"Terminate()");
-
- TGMenuBar* bar = new TGMenuBar(mainFrame,w);
+ Int_t nok(0);
- bar->AddPopup("&File",file,new TGLayoutHints(kLHintsLeft|kLHintsTop));
+ TObjArray filesToOpen;
+ Bool_t isGeometryFixed(kFALSE);
+ Int_t gix, giy;
+ Int_t gox,goy;
+ Bool_t ASCIImapping(kFALSE);
- mainFrame->AddFrame(bar,new TGLayoutHints(kLHintsLeft|kLHintsExpandX));
+ for ( Int_t i = 0; i <= args.GetLast(); ++i )
+ {
+ TString a(static_cast<TObjString*>(args.At(i))->String());
+ if ( a == "--version" )
+ {
+ cout << "mchview Version " << AliMUONMchViewApplication::Version() << " ($Id$)" << endl;
+ ++nok;
+ return 0;
+ }
+ if ( a == "--use" && i < args.GetLast() )
+ {
+ filesToOpen.Add(args.At(i+1));
+ ++i;
+ nok += 2;
+ }
+ else if ( a == "--geometry" )
+ {
+ isGeometryFixed = kTRUE;
+ TString g(static_cast<TObjString*>(args.At(i+1))->String());
+ sscanf(g.Data(),"%dx%d+%d+%d",&gix,&giy,&gox,&goy);
+ nok += 2;
+ ++i;
+ }
+ else if ( a == "--asciimapping" )
+ {
+ ASCIImapping = kTRUE;
+ }
+
+ else
+ {
+ return Usage();
+ }
+ }
- AliMUONPainterRegistry::Instance()->SetMenuBar(bar);
-}
-
-
-int main(int argc, char** argv)
-{
-///
-
- AliWarningGeneral("main","Remove default storage and run number from here...");
+ if ( nok < args.GetLast() )
+ {
+ return Usage();
+ }
- AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
- AliCDBManager::Instance()->SetRun(0);
+ AliWarningGeneral("main","FIXME ? Remove default storage and run number from here...");
- TRint *theApp = new TRint("mchview", &argc, argv);
-
- gROOT->SetStyle("Plain");
+ AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+ AliCDBManager::Instance()->SetRun(0);
+
+ if ( ASCIImapping )
+ {
+ AliMpDataProcessor mp;
+ AliMpDataMap* map = mp.CreateDataMap("data");
+ AliMpDataStreams dataStreams(map);
+ AliMpDDLStore::ReadData(dataStreams);
+ }
+ gROOT->SetStyle("Plain");
gStyle->SetPalette(1);
-
Int_t n = gStyle->GetNumberOfColors();
-
Int_t* colors = new Int_t[n+2];
-
for ( Int_t i = 1; i <= n; ++i )
{
colors[i] = gStyle->GetColorPalette(i-1);
}
-
colors[0] = 0;
colors[n+1] = 1;
-
gStyle->SetPalette(n+2,colors);
-
delete[] colors;
-
- UInt_t dw = gClient->GetDisplayWidth();
- UInt_t dh = gClient->GetDisplayHeight();
-
- UInt_t w = (UInt_t)(0.7*dw);
- UInt_t h = (UInt_t)(0.90*dh);
-
- TGMainFrame* mainFrame = new TGMainFrame(gClient->GetRoot(),w,h);
-
- const Int_t bs = 2;
-
- CreateMenuBar(theApp,mainFrame,w);
-
-// h -= 60; // menubar
-
- TGTab* tabs = new TGTab(mainFrame,w,h);
-
- TGCompositeFrame* t = tabs->AddTab("Painter Master Frame");
-
- AliMUONPainterMasterFrame* pf =
- new AliMUONPainterMasterFrame(t,t->GetWidth()-bs*2,t->GetHeight()-bs*2);
-
- t->AddFrame(pf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,bs,bs,bs,bs));
- t = tabs->AddTab("Data Sources");
-
- AliMUONPainterDataSourceFrame* dsf =
- new AliMUONPainterDataSourceFrame(t,t->GetWidth()-bs*2,t->GetHeight()-bs*2);
-
- t->AddFrame(dsf,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,bs,bs,bs,bs));
-
- mainFrame->AddFrame(tabs,new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,0,0,0,0));
+ UInt_t w(0);
+ UInt_t h(0);
+ UInt_t ox(0);
+ UInt_t oy(0);
- mainFrame->SetWindowName("mchview - Visualization of MUON Tracker detector");
-
- mainFrame->MapSubwindows();
- mainFrame->Resize();
- mainFrame->MapWindow();
-
- mainFrame->Connect("CloseWindow()","TRint",theApp,"Terminate()");
-
- UInt_t x = dw/2 - w/2;
- UInt_t y = 0;
-
- mainFrame->MoveResize(x, y, w, h);
- mainFrame->SetWMPosition(x, y);
+ if ( isGeometryFixed )
+ {
+ w = gix;
+ h = giy;
+ ox = gox;
+ oy = goy;
+ }
- mainFrame->SetWMSizeHints(w,h,w,h,0,0);
-
+ AliMUONMchViewApplication* theApp = new AliMUONMchViewApplication("mchview", &argc, argv, w,h,gox,goy);
+
AliCodeTimer::Instance()->Print();
+ TIter next(&filesToOpen);
+ TObjString* s;
+ while ( ( s = static_cast<TObjString*>(next()) ) )
+ {
+ theApp->Open(s->String().Data());
+ }
+
// --- Start the event loop ---
theApp->Run(kTRUE);
- AliMUONPainterHelper::Instance()->Save();
+ delete AliMUONPainterHelper::Instance(); // important to trigger the saving of the env. file
}