]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/mchview.cxx
b0debd5b0380f427a4dab4bb68387b2c9c75248d
[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
43 //______________________________________________________________________________
44 Int_t Usage()
45 {
46   /// Printout available options of the program
47   cout << "mchview " << endl;
48   cout << "  --version : shows the current version of the program" << endl;
49   cout << "  --use filename.root : reuse a previously saved (from this program) root file. Several --use can be used ;-)" << endl;
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;
52   cout << "  --asciimapping : load mapping from ASCII files instead of OCDB (for debug and experts only...)" << endl;
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;
55   return -1;
56 }
57
58 //______________________________________________________________________________
59 int main(int argc, char** argv)
60 {
61   /// Main function for the program
62   TObjArray args;
63   
64   for ( int i = 1; i < argc; ++i ) 
65   {
66     args.Add(new TObjString(argv[i]));
67   }
68   
69   Int_t nok(0);
70   
71   TObjArray filesToOpen;
72   Bool_t isGeometryFixed(kFALSE);
73   Int_t gix, giy;
74   Int_t gox,goy;
75   Bool_t ASCIImapping(kFALSE);
76   
77   for ( Int_t i = 0; i <= args.GetLast(); ++i ) 
78   {
79     TString a(static_cast<TObjString*>(args.At(i))->String());
80     if ( a == "--version" ) 
81     {
82       cout << "mchview Version " << AliMUONMchViewApplication::Version() << " ($Id$)" << endl;
83       ++nok;
84       return 0;
85     }
86     if ( a == "--use" && i < args.GetLast() )
87     {
88       filesToOpen.Add(args.At(i+1));
89       ++i;
90       nok += 2;
91     }
92     else if ( a == "--geometry" )
93     {
94       isGeometryFixed = kTRUE;
95       TString g(static_cast<TObjString*>(args.At(i+1))->String());
96       sscanf(g.Data(),"%dx%d+%d+%d",&gix,&giy,&gox,&goy);
97       nok += 2;
98       ++i;
99     }
100     else if ( a == "--asciimapping" )
101     {
102       ++nok;
103       ASCIImapping = kTRUE;
104     }
105     else if ( a == "--de" || a == "--chamber" )
106     {
107       // do nothing. Let AliMUONMchViewApplication handle that one. (and the next one as well).
108       nok += 2;
109       ++i;      
110     }
111     else
112     {
113       return Usage();
114     }
115   }
116   
117   if ( nok < args.GetLast() )
118   {
119     return Usage();
120   }
121   
122   AliWarningGeneral("main","FIXME ? Remove default storage and run number from here...");
123   
124   AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
125   AliCDBManager::Instance()->SetRun(0);
126  
127   if ( ASCIImapping ) 
128   {
129     AliMpDataProcessor mp;
130     {
131       AliMpDataMap* datamap = mp.CreateDataMap("data");
132       AliMpDataStreams dataStreams(datamap);
133       AliMpDDLStore::ReadData(dataStreams);
134     }
135     {
136       AliMpDataMap* datamap = mp.CreateDataMap("data_run");
137       AliMpDataStreams dataStreams(datamap);
138       AliMpManuStore::ReadData(dataStreams);
139     }
140     
141     AliCDBManager::Instance()->SetSpecificStorage("MUON/Calib/Neighbours","local://$ALICE_ROOT/OCDB");
142
143   }
144   
145   gROOT->SetStyle("Plain");  
146   gStyle->SetPalette(1);
147   Int_t n = gStyle->GetNumberOfColors();
148   Int_t* colors = new Int_t[n+2];
149   for ( Int_t i = 1; i <= n; ++i )
150   {
151     colors[i] = gStyle->GetColorPalette(i-1);
152   }
153   colors[0] = 0;
154   colors[n+1] = 1;
155   gStyle->SetPalette(n+2,colors);
156   delete[] colors;
157
158   UInt_t w(0);
159   UInt_t h(0);
160   UInt_t ox(0);
161   UInt_t oy(0);
162
163   if ( isGeometryFixed )
164   {
165     w = gix;
166     h = giy;
167     ox = gox;
168     oy = goy;
169   }
170   
171   AliMUONMchViewApplication* theApp = new AliMUONMchViewApplication("mchview", &argc, argv, w,h,gox,goy);
172    
173   AliCodeTimer::Instance()->Print();
174
175   TIter next(&filesToOpen);
176   TObjString* s;
177   while ( ( s = static_cast<TObjString*>(next()) ) )
178   {
179     theApp->Open(s->String().Data());
180   }
181   
182   // --- Start the event loop ---
183   theApp->Run(kTRUE);
184
185   delete AliMUONPainterHelper::Instance(); // important to trigger the saving of the env. file
186 }