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