Converting mchview to native cmake
[u/mrichter/AliRoot.git] / MUON / mchview / mchview.cxx
CommitLineData
0145e89a 1/**************************************************************************
2* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
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**************************************************************************/
15
16// $Id$
17
18/// \ingroup graphics
19/// \file mchview.cxx
20/// \brief Tracker visualization program
21///
22/// \author Laurent Aphecetche, Subatech
23
24
90037e4e 25#include "AliMUONMchViewApplication.h"
1ffbeb9d 26
0145e89a 27#include "AliCDBManager.h"
28#include "AliCodeTimer.h"
29#include "AliLog.h"
1ffbeb9d 30#include "AliMUONPainterHelper.h"
31#include <Riostream.h>
90037e4e 32#include <TObjArray.h>
33#include <TObjString.h>
1ffbeb9d 34#include <TROOT.h>
35#include <TStyle.h>
0145e89a 36
3f979838 37#include "AliMpDataProcessor.h"
38#include "AliMpDataMap.h"
39#include "AliMpDataStreams.h"
40#include "AliMpDDLStore.h"
fef32488 41#include "AliMpManuStore.h"
065e62e4 42#include "TEnv.h"
3f979838 43
90037e4e 44//______________________________________________________________________________
45Int_t Usage()
0145e89a 46{
90037e4e 47 /// Printout available options of the program
48 cout << "mchview " << endl;
49 cout << " --version : shows the current version of the program" << endl;
49419555 50 cout << " --use filename.root : reuse a previously saved (from this program) root file. Several --use can be used ;-)" << endl;
1ffbeb9d 51 cout << " --geometry #x#+#+# : manually specify the geometry of the window, ala X11..., e.g. --geometry 1280x900+1600+0 will" << endl;
52 cout << " get a window of size 1280x900, located at (1600,0) from the top-left of the (multihead) display " << endl;
3f979838 53 cout << " --asciimapping : load mapping from ASCII files instead of OCDB (for debug and experts only...)" << endl;
fef32488 54 cout << " --de detElemId : start by displaying the given detection element instead of the default view (which is all the chambers)" << endl;
55 cout << " --chamber chamberId (from 1 to 10) : start by displaying the given chamber instead of the default view (which is all the chambers)" << endl;
ca913045 56 cout << " --ocdb ocdbPath : read the mapping from the given OCDB" << endl;
90037e4e 57 return -1;
58}
0145e89a 59
90037e4e 60//______________________________________________________________________________
61int main(int argc, char** argv)
62{
63 /// Main function for the program
065e62e4 64
65 gEnv->SetValue("Cocoa.EnableAntiAliasing","auto");
66
90037e4e 67 TObjArray args;
0145e89a 68
90037e4e 69 for ( int i = 1; i < argc; ++i )
70 {
71 args.Add(new TObjString(argv[i]));
72 }
0145e89a 73
90037e4e 74 Int_t nok(0);
0145e89a 75
49419555 76 TObjArray filesToOpen;
1ffbeb9d 77 Bool_t isGeometryFixed(kFALSE);
d2b2e698 78 Int_t gix(0),giy(0);
79 Int_t gox(0),goy(0);
3f979838 80 Bool_t ASCIImapping(kFALSE);
ca913045 81 TString defaultOCDB("local://$ALICE_ROOT/OCDB");
3f979838 82
90037e4e 83 for ( Int_t i = 0; i <= args.GetLast(); ++i )
84 {
85 TString a(static_cast<TObjString*>(args.At(i))->String());
86 if ( a == "--version" )
87 {
88 cout << "mchview Version " << AliMUONMchViewApplication::Version() << " ($Id$)" << endl;
89 ++nok;
90 return 0;
91 }
10eb3d17 92 if ( a == "--use" && i < args.GetLast() )
93 {
49419555 94 filesToOpen.Add(args.At(i+1));
10eb3d17 95 ++i;
96 nok += 2;
97 }
1ffbeb9d 98 else if ( a == "--geometry" )
99 {
100 isGeometryFixed = kTRUE;
101 TString g(static_cast<TObjString*>(args.At(i+1))->String());
2a87e9b1 102 sscanf(g.Data(),"%10dx%10d+%10d+%10d",&gix,&giy,&gox,&goy);
1ffbeb9d 103 nok += 2;
104 ++i;
105 }
3f979838 106 else if ( a == "--asciimapping" )
107 {
fef32488 108 ++nok;
3f979838 109 ASCIImapping = kTRUE;
110 }
fef32488 111 else if ( a == "--de" || a == "--chamber" )
112 {
113 // do nothing. Let AliMUONMchViewApplication handle that one. (and the next one as well).
114 nok += 2;
115 ++i;
116 }
ca913045 117 else if ( a == "--ocdb" )
118 {
119 defaultOCDB = static_cast<TObjString*>(args.At(i+1))->String();
120 cout << "Using default storage = " << defaultOCDB.Data() << endl;
121 nok += 2;
122 ++i;
123 }
10eb3d17 124 else
125 {
126 return Usage();
127 }
90037e4e 128 }
0145e89a 129
90037e4e 130 if ( nok < args.GetLast() )
131 {
132 return Usage();
133 }
0145e89a 134
ca913045 135 AliCDBManager::Instance()->SetDefaultStorage(defaultOCDB.Data());
0145e89a 136 AliCDBManager::Instance()->SetRun(0);
90037e4e 137
3f979838 138 if ( ASCIImapping )
139 {
140 AliMpDataProcessor mp;
fef32488 141 {
142 AliMpDataMap* datamap = mp.CreateDataMap("data");
143 AliMpDataStreams dataStreams(datamap);
144 AliMpDDLStore::ReadData(dataStreams);
145 }
146 {
147 AliMpDataMap* datamap = mp.CreateDataMap("data_run");
148 AliMpDataStreams dataStreams(datamap);
149 AliMpManuStore::ReadData(dataStreams);
150 }
151
152 AliCDBManager::Instance()->SetSpecificStorage("MUON/Calib/Neighbours","local://$ALICE_ROOT/OCDB");
153
3f979838 154 }
155
90037e4e 156 gROOT->SetStyle("Plain");
0145e89a 157 gStyle->SetPalette(1);
0145e89a 158 Int_t n = gStyle->GetNumberOfColors();
0145e89a 159 Int_t* colors = new Int_t[n+2];
0145e89a 160 for ( Int_t i = 1; i <= n; ++i )
161 {
162 colors[i] = gStyle->GetColorPalette(i-1);
163 }
0145e89a 164 colors[0] = 0;
165 colors[n+1] = 1;
0145e89a 166 gStyle->SetPalette(n+2,colors);
0145e89a 167 delete[] colors;
1ffbeb9d 168
d2b2e698 169 AliMUONMchViewApplication* theApp(0x0);
1ffbeb9d 170
171 if ( isGeometryFixed )
172 {
d2b2e698 173 theApp = new AliMUONMchViewApplication("mchview", &argc, argv,gix,giy,gox,goy);
174 }
175 else
176 {
177 theApp = new AliMUONMchViewApplication("mchview",&argc,argv);
1ffbeb9d 178 }
90037e4e 179
49419555 180 TIter next(&filesToOpen);
181 TObjString* s;
182 while ( ( s = static_cast<TObjString*>(next()) ) )
183 {
184 theApp->Open(s->String().Data());
185 }
10eb3d17 186
0145e89a 187 // --- Start the event loop ---
188 theApp->Run(kTRUE);
189
8f0acce4 190 delete AliMUONPainterHelper::Instance(); // important to trigger the saving of the env. file
0145e89a 191}