]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mchview.cxx
Adding include path to allow compilation of CleanGeom task
[u/mrichter/AliRoot.git] / MUON / mchview.cxx
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
25 #include "AliMUONMchViewApplication.h"
26
27 #include "AliCDBManager.h"
28 #include "AliCodeTimer.h"
29 #include "AliLog.h"
30 #include "AliMUONPainterHelper.h"
31 #include <Riostream.h>
32 #include <TObjArray.h>
33 #include <TObjString.h>
34 #include <TROOT.h>
35 #include <TStyle.h>
36
37 #include "AliMpDataProcessor.h"
38 #include "AliMpDataMap.h"
39 #include "AliMpDataStreams.h"
40 #include "AliMpDDLStore.h"
41 #include "AliMpManuStore.h"
42 #include "TEnv.h"
43
44 //______________________________________________________________________________
45 Int_t Usage()
46 {
47   /// Printout available options of the program
48   cout << "mchview " << endl;
49   cout << "  --version : shows the current version of the program" << endl;
50   cout << "  --use filename.root : reuse a previously saved (from this program) root file. Several --use can be used ;-)" << endl;
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;
53   cout << "  --asciimapping : load mapping from ASCII files instead of OCDB (for debug and experts only...)" << endl;
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;
56   cout << "  --ocdb ocdbPath : read the mapping from the given OCDB" << endl;
57   return -1;
58 }
59
60 //______________________________________________________________________________
61 int main(int argc, char** argv)
62 {
63   /// Main function for the program
64   
65   gEnv->SetValue("Cocoa.EnableAntiAliasing","auto");
66
67   TObjArray args;
68   
69   for ( int i = 1; i < argc; ++i ) 
70   {
71     args.Add(new TObjString(argv[i]));
72   }
73   
74   Int_t nok(0);
75   
76   TObjArray filesToOpen;
77   Bool_t isGeometryFixed(kFALSE);
78   Int_t gix(0),giy(0);
79   Int_t gox(0),goy(0);
80   Bool_t ASCIImapping(kFALSE);
81   TString defaultOCDB("local://$ALICE_ROOT/OCDB");
82   
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     }
92     if ( a == "--use" && i < args.GetLast() )
93     {
94       filesToOpen.Add(args.At(i+1));
95       ++i;
96       nok += 2;
97     }
98     else if ( a == "--geometry" )
99     {
100       isGeometryFixed = kTRUE;
101       TString g(static_cast<TObjString*>(args.At(i+1))->String());
102       sscanf(g.Data(),"%10dx%10d+%10d+%10d",&gix,&giy,&gox,&goy);
103       nok += 2;
104       ++i;
105     }
106     else if ( a == "--asciimapping" )
107     {
108       ++nok;
109       ASCIImapping = kTRUE;
110     }
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     }
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     }
124     else
125     {
126       return Usage();
127     }
128   }
129   
130   if ( nok < args.GetLast() )
131   {
132     return Usage();
133   }
134   
135   AliCDBManager::Instance()->SetDefaultStorage(defaultOCDB.Data());
136   AliCDBManager::Instance()->SetRun(0);
137  
138   if ( ASCIImapping ) 
139   {
140     AliMpDataProcessor mp;
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
154   }
155   
156   gROOT->SetStyle("Plain");  
157   gStyle->SetPalette(1);
158   Int_t n = gStyle->GetNumberOfColors();
159   Int_t* colors = new Int_t[n+2];
160   for ( Int_t i = 1; i <= n; ++i )
161   {
162     colors[i] = gStyle->GetColorPalette(i-1);
163   }
164   colors[0] = 0;
165   colors[n+1] = 1;
166   gStyle->SetPalette(n+2,colors);
167   delete[] colors;
168
169   AliMUONMchViewApplication* theApp(0x0);
170
171   if ( isGeometryFixed )
172   {
173     theApp = new AliMUONMchViewApplication("mchview", &argc, argv,gix,giy,gox,goy);
174   }
175   else
176   {
177     theApp = new AliMUONMchViewApplication("mchview",&argc,argv);
178   }
179    
180   TIter next(&filesToOpen);
181   TObjString* s;
182   while ( ( s = static_cast<TObjString*>(next()) ) )
183   {
184     theApp->Open(s->String().Data());
185   }
186   
187   // --- Start the event loop ---
188   theApp->Run(kTRUE);
189
190   delete AliMUONPainterHelper::Instance(); // important to trigger the saving of the env. file
191 }