]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTest.cxx
Go on with new segmentation (Ch. Finck)
[u/mrichter/AliRoot.git] / MUON / AliMUONTest.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 // Class AliMUONTest
19 // -----------------
20 // Class with functions for testing
21 //
22 // Author: Ivana Hrivnacova, IPN Orsay
23
24 #include <TStopwatch.h>
25 #include <Riostream.h>
26 #include <TH2F.h>
27 #include <TPave.h>
28 #include <TCanvas.h>
29
30 #include "AliRun.h"
31 #include "AliSegmentation.h"
32 #include "AliLog.h"
33
34 #include "AliMUONTest.h"
35 #include "AliMUON.h"
36 #include "AliMUONConstants.h"
37 #include "AliMUONGeometryModule.h"
38 #include "AliMUONGeometryStore.h"
39 #include "AliMUONGeometrySegmentation.h"
40 #include "AliMUONSt12QuadrantSegmentation.h"
41 #include "AliMUONSt345SlatSegmentation.h"
42 #include "AliMUONTriggerSegmentation.h"
43 #include "AliMUONTriggerConstants.h"
44
45 ClassImp(AliMUONTest)
46
47 //__________________________________________________________________
48   AliMUONTest::AliMUONTest(const TString& configMacro)
49   : TObject(),
50     fCanvas(0)
51 {
52 // Standard Constructor
53 //
54   // Initialize AliRoot
55   gAlice->Init(configMacro.Data());
56 }
57
58 //__________________________________________________________________
59 AliMUONTest::AliMUONTest()
60   : TObject(),
61     fCanvas(0)
62 {
63 // Default Constructor
64 //
65 }
66
67 //____________________________________________________________________
68 AliMUONTest::AliMUONTest(const AliMUONTest& rhs)
69  : TObject(rhs)
70 {
71 // Protected copy constructor
72
73   AliFatal("Not implemented.");
74 }
75
76 //____________________________________________________________________
77 AliMUONTest::~AliMUONTest()
78 {
79 // Destructor
80
81   delete fCanvas;
82 }
83
84 //________________________________________________________________________
85 AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs)
86 {
87 // Protected assignement operator
88
89   if (this == &rhs) return *this;
90
91   AliFatal("Not implemented.");
92     
93   return *this;  
94 }
95
96 //
97 // private methods
98 //
99
100 //________________________________________________________________________
101 AliMUONGeometrySegmentation*     
102 AliMUONTest::CreateSt1Segmentation(Int_t chamberId, Int_t cathod)
103 {
104 // Create St1 geometry segmentation for given chamber and cathod
105
106   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
107   if (!muon) {
108     AliFatal("MUON detector not defined.");
109     return 0;   
110   }  
111
112   AliMUONGeometrySegmentation* segmentation
113     = new AliMUONGeometrySegmentation(muon->Chamber(chamberId).GetGeometry());
114     
115   // Quadrant segmentations:
116   AliMUONSt12QuadrantSegmentation* bendSt1
117     = new AliMUONSt12QuadrantSegmentation(kStation1, kBendingPlane);
118   AliMUONSt12QuadrantSegmentation* nonbendSt1
119     = new AliMUONSt12QuadrantSegmentation(kStation1, kNonBendingPlane);
120
121   // The same configuration for both chambers of Station 1
122   Int_t id0 = (chamberId+1)*100;
123
124   // Configure  St1 chamber segmentations
125   if (cathod == 0) {
126     segmentation->Add(id0,      bendSt1);
127     segmentation->Add(id0 +  1, nonbendSt1);
128     segmentation->Add(id0 + 50, bendSt1);
129     segmentation->Add(id0 + 51, nonbendSt1);
130   }
131   else if (cathod == 1) {
132     segmentation->Add(id0,      nonbendSt1);
133     segmentation->Add(id0 +  1, bendSt1);
134     segmentation->Add(id0 + 50, nonbendSt1);
135     segmentation->Add(id0 + 51, bendSt1);
136   }
137   else {
138     AliError("Wrong cathod number");
139     return 0;
140   }
141   
142   return segmentation;
143 }      
144
145 //_____________________________________________________________________________
146 AliMUONGeometrySegmentation*     
147 AliMUONTest::CreateSlatSegmentation(Int_t chamberId, Int_t cathod)
148 {
149 // Create St1 geometry segmentation for given chamber and cathod
150
151   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
152   if (!muon) {
153     AliFatal("MUON detector not defined.");
154     return 0;
155   }  
156
157   AliMUONGeometrySegmentation *chamberSeg = new AliMUONGeometrySegmentation(muon->Chamber(chamberId).GetGeometry());
158
159    //Slats Segmentations
160   AliMUONSt345SlatSegmentation *slatsegB[14]; // Types of segmentation for St3 in this framework
161   AliMUONSt345SlatSegmentation *slatsegNB[14]; // Types of segmentation for St3 in this framework
162                                                // Bending
163   Int_t ndiv[4] ={ 4, 4, 2, 1};  // densities zones 
164   for(Int_t i=0; i<14; i++) {
165     slatsegB[i] = new AliMUONSt345SlatSegmentation(1);
166     slatsegB[i]->SetPadSize(10.,0.5);
167     slatsegB[i]->SetPadDivision(ndiv);
168     slatsegB[i]->SetId(1);
169     slatsegB[i]->SetDAnod(0.25);
170     slatsegNB[i] = new AliMUONSt345SlatSegmentation(0);
171     slatsegNB[i]->SetPadSize(1.,10.); // must be 0.713 !!!
172     slatsegNB[i]->SetPadDivision(ndiv);
173     slatsegNB[i]->SetId(1);
174     slatsegNB[i]->SetDAnod(0.25);
175   }
176   
177   
178   //******************************************************************************************
179   // Station 3
180   //******************************************************************************************
181
182   if (chamberId == 4 || chamberId == 5) {
183     // Type 112200 for 500, 501, 508, 509, 510, 517 in Ch5 (similar for Ch6) for the futur official numbering
184     // Type 112200 for 503, 504, 505, 555, 554, 553 in Ch5 (similar for Ch6) actual numbering in the code to be changed in jan05
185     Int_t n0[4] = { 0, 2, 2, 0 };
186     slatsegB[0]->SetPcbBoards(n0);
187     slatsegB[0]->Init(0);
188     slatsegNB[0]->SetPcbBoards(n0);
189     slatsegNB[0]->Init(0);
190     
191     // Type 122200 for 502, 507, 511, 516 (similar in Ch6) for future official numbering of ALICE
192     // Type 122200 for 502, 506, 556, 552 (similiarin Ch6) for actual numbering in muon code to be changed in jan05
193     Int_t n1[4] = { 0, 1, 3, 0 }; 
194     slatsegB[1]->SetPcbBoards(n1);
195     slatsegB[1]->Init(0); 
196     slatsegNB[1]->SetPcbBoards(n1);
197     slatsegNB[1]->Init(0); 
198     
199     // Type 222000 for 503, 506, 512, 515 (similar in Ch6) for future official numbering of ALICE
200     // Type 222000 for 501, 507, 557, 551 (similiarin Ch6) for actual numbering in muon code to be changed in jan05
201     Int_t n2[4] = { 0, 0, 3, 0 };
202     slatsegB[2]->SetPcbBoards(n2);
203     slatsegB[2]->Init(0);
204     slatsegNB[2]->SetPcbBoards(n2);
205     slatsegNB[2]->Init(0);
206     
207     // Type 220000 for 504, 505, 513, 514 (similar in Ch6) for future official numbering of ALICE
208     // Type 220000 for 500, 508, 558, 550 (similiarin Ch6) for actual numbering in muon code to be changed in jan05
209     Int_t n3[4] = { 0, 0, 2, 0 };
210     slatsegB[3]->SetPcbBoards(n3);
211     slatsegB[3]->Init(0); 
212     slatsegNB[3]->SetPcbBoards(n3);
213     slatsegNB[3]->Init(0); 
214   }
215   
216   
217   //***************************************************************************************
218   // Station 4 & 5
219   //****************************************************************************************
220   
221   if (chamberId >= 6 && chamberId <= 9) {
222     // Type 122330 for 700, 713 in Ch7 (similar for Ch8) for the futur official numbering
223     // Type 122330 for 706, 756 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
224     // Type 122330 for 900, 913 in Ch9 (similar for Ch10) for the futur official numbering
225     // Type 122330 for 906, 956 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
226     
227     Int_t n4[4] = { 0, 1, 2, 2 };
228     slatsegB[4]->SetPcbBoards(n4);
229     slatsegB[4]->Init(0); // 0 detection element id
230     slatsegNB[4]->SetPcbBoards(n4);
231     slatsegNB[4]->Init(0); // 0 detection element id
232     
233     // Type 112233 for 701, 712, 714, 725 in Ch7 (similar for Ch8) for the futur official numbering
234     // Type 112233 for 705, 707, 755, 757 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
235     // Type 112233 for 901, 902, 911, 912, 914, 915, 924, 925 in Ch9 (similar for Ch10) for the futur official numbering
236     // Type 112233 for 904, 905, 907, 908, 954, 955, 957, 958 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
237     Int_t n5[4] = { 0, 2, 2, 2 };
238     slatsegB[5]->SetPcbBoards(n5);
239     slatsegB[5]->Init(0); // 0 detection element id
240     slatsegNB[5]->SetPcbBoards(n5);
241     slatsegNB[5]->Init(0); // 0 detection element id
242     
243     // Type 112230 for 702, 711, 715, 724 in Ch7 (similar for Ch8) for the futur official numbering
244     // Type 112230 for 704, 708, 754, 758 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
245     Int_t n6[4] = { 0, 2, 2, 1 };
246     slatsegB[6]->SetPcbBoards(n6);
247     slatsegB[6]->Init(0); // 0 detection element id
248     slatsegNB[6]->SetPcbBoards(n6);
249     slatsegNB[6]->Init(0); // 0 detection element id
250     
251     // Type 222330 for 703, 710, 716, 723 in Ch7 (similar for Ch8) for the futur official numbering
252     // Type 222330 for 703, 709, 753, 759 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
253     Int_t n7[4] = { 0, 0, 3, 2 };
254     slatsegB[7]->SetPcbBoards(n7);
255     slatsegB[7]->Init(0); // 0 detection element id
256     slatsegNB[7]->SetPcbBoards(n7);
257     slatsegNB[7]->Init(0); // 0 detection element id
258     
259     // Type 223300 for 704, 709, 717, 722 in Ch7 (similar for Ch8) for the futur official numbering
260     // Type 223300 for 702, 710, 752, 760 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
261     Int_t n8[4] = { 0, 0, 2, 2 };
262     slatsegB[8]->SetPcbBoards(n8);
263     slatsegB[8]->Init(0); // 0 detection element id
264     slatsegNB[8]->SetPcbBoards(n8);
265     slatsegNB[8]->Init(0); // 0 detection element id
266     
267     // Type 333000 for 705, 708, 718, 721 in Ch7 (similar for Ch8) for the futur official numbering
268     // Type 333000 for 701, 711, 751, 761 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
269     // Type 333000 for 906, 907, 919, 920 in Ch9 (similar for Ch10) for the futur official numbering
270     // Type 333000 for 900, 912, 950, 962 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
271     Int_t n9[4] = { 0, 0, 0, 3 };
272     slatsegB[9]->SetPcbBoards(n9);
273     slatsegB[9]->Init(0); // 0 detection element id
274     slatsegNB[9]->SetPcbBoards(n9);
275     slatsegNB[9]->Init(0); // 0 detection element id
276     
277     // Type 330000 for 706, 707, 719, 720 in Ch7 (similar for Ch8) for the futur official numbering
278     // Type 330000 for 700, 712, 750, 762 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
279     Int_t n10[4] = { 0, 0, 0, 2 };
280     slatsegB[10]->SetPcbBoards(n10);
281     slatsegB[10]->Init(0); // 0 detection element id
282     slatsegNB[10]->SetPcbBoards(n10);
283     slatsegNB[10]->Init(0); // 0 detection element id
284     
285     // Type 222333 for 903, 910, 916, 923 in Ch9 (similar for Ch10) for the futur official numbering
286     // Type 222333 for 903, 909, 953, 959 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
287     Int_t n11[4] = { 0, 0, 3, 3 };
288     slatsegB[11]->SetPcbBoards(n11);
289     slatsegB[11]->Init(0); // 0 detection element id
290     slatsegNB[11]->SetPcbBoards(n11);
291     slatsegNB[11]->Init(0); // 0 detection element id
292   
293     // Type 223330 for 904, 909, 917, 922 in Ch9 (similar for Ch10) for the futur official numbering
294     // Type 223330 for 902, 910, 952, 960 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
295     Int_t n12[4] = { 0, 0, 2, 3 };
296     slatsegB[12]->SetPcbBoards(n12);
297     slatsegB[12]->Init(0); // 0 detection element id
298     slatsegNB[12]->SetPcbBoards(n12);
299     slatsegNB[12]->Init(0); // 0 detection element id
300     
301     // Type 333300 for 905, 908, 918, 921 in Ch9 (similar for Ch10) for the futur official numbering
302     // Type 333300 for 901, 911, 951, 961 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
303     Int_t n13[4] = { 0, 0, 0, 4 };
304     slatsegB[13]->SetPcbBoards(n13);
305     slatsegB[13]->Init(0); // 0 detection element id
306     slatsegNB[13]->SetPcbBoards(n13);
307     slatsegNB[13]->Init(0); // 0 detection element id
308     
309   }
310
311   Int_t id0 = 0;
312
313   // For St3 
314   if (chamberId == 4 || chamberId == 5) {
315     // Create chamber segmentations  
316
317     id0=(chamberId+1)*100;
318     // type 220000
319     if (cathod == 0) {
320       chamberSeg->Add(id0, slatsegB[3]);
321       chamberSeg->Add(id0+ 8, slatsegB[3]);  
322       chamberSeg->Add(id0+50, slatsegB[3]);  
323       chamberSeg->Add(id0+58, slatsegB[3]);
324     } else {
325       chamberSeg->Add(id0, slatsegNB[3]);
326       chamberSeg->Add(id0+ 8, slatsegNB[3]);  
327       chamberSeg->Add(id0+50, slatsegNB[3]);  
328       chamberSeg->Add(id0+58, slatsegNB[3]);
329     }
330     // type 222000
331     if (cathod == 0) {
332       chamberSeg->Add(id0+ 1, slatsegB[2]);
333       chamberSeg->Add(id0+ 7, slatsegB[2]);  
334       chamberSeg->Add(id0+51, slatsegB[2]);  
335       chamberSeg->Add(id0+57, slatsegB[2]);
336     } else {
337       chamberSeg->Add(id0+ 1, slatsegNB[2]);
338       chamberSeg->Add(id0+ 7, slatsegNB[2]);  
339       chamberSeg->Add(id0+51, slatsegNB[2]);  
340       chamberSeg->Add(id0+57, slatsegNB[2]);
341     }
342     // type 122200
343     if (cathod == 0) {
344       chamberSeg->Add(id0+ 2, slatsegB[1]);
345       chamberSeg->Add(id0+ 6, slatsegB[1]);  
346       chamberSeg->Add(id0+52, slatsegB[1]);  
347       chamberSeg->Add(id0+56, slatsegB[1]);
348     } else {
349       chamberSeg->Add(id0+ 2, slatsegNB[1]);
350       chamberSeg->Add(id0+ 6, slatsegNB[1]);  
351       chamberSeg->Add(id0+52, slatsegNB[1]);  
352       chamberSeg->Add(id0+56, slatsegNB[1]);
353     }
354     // type 112200
355     if (cathod == 0) {
356       chamberSeg->Add(id0+ 3, slatsegB[0]);
357       chamberSeg->Add(id0+ 4, slatsegB[0]);  
358       chamberSeg->Add(id0+ 5, slatsegB[0]);  
359       chamberSeg->Add(id0+53, slatsegB[0]);
360       chamberSeg->Add(id0+54, slatsegB[0]);     
361       chamberSeg->Add(id0+55, slatsegB[0]);
362     } else {
363       chamberSeg->Add(id0+ 3, slatsegNB[0]);
364       chamberSeg->Add(id0+ 4, slatsegNB[0]);  
365       chamberSeg->Add(id0+ 5, slatsegNB[0]);  
366       chamberSeg->Add(id0+53, slatsegNB[0]);
367       chamberSeg->Add(id0+54, slatsegNB[0]);     
368       chamberSeg->Add(id0+55, slatsegNB[0]);
369     }
370
371   }
372   
373   // For St4 
374   if (chamberId == 6 || chamberId == 7) {
375     // Create chamber segmentations  
376     id0=(chamberId+1)*100;
377     // type 122330
378     if (cathod == 0) {
379       chamberSeg->Add(id0+ 6, slatsegB[4]);
380       chamberSeg->Add(id0+56, slatsegB[4]);
381     } else {
382       chamberSeg->Add(id0+ 6, slatsegNB[4]);
383       chamberSeg->Add(id0+56, slatsegNB[4]);
384     }
385     // type 112233
386     if (cathod == 0) {
387       chamberSeg->Add(id0+ 5, slatsegB[5]);
388       chamberSeg->Add(id0+ 7, slatsegB[5]);  
389       chamberSeg->Add(id0+55, slatsegB[5]);  
390       chamberSeg->Add(id0+57, slatsegB[5]);
391     } else {
392       chamberSeg->Add(id0+ 5, slatsegNB[5]);
393       chamberSeg->Add(id0+ 7, slatsegNB[5]);  
394       chamberSeg->Add(id0+55, slatsegNB[5]);  
395       chamberSeg->Add(id0+57, slatsegNB[5]);
396     }
397     // type 112230
398     if (cathod == 0) {
399       chamberSeg->Add(id0+ 4, slatsegB[6]);
400       chamberSeg->Add(id0+ 8, slatsegB[6]);  
401       chamberSeg->Add(id0+54, slatsegB[6]);  
402       chamberSeg->Add(id0+58, slatsegB[6]);
403     } else {
404       chamberSeg->Add(id0+ 4, slatsegNB[6]);
405       chamberSeg->Add(id0+ 8, slatsegNB[6]);  
406       chamberSeg->Add(id0+54, slatsegNB[6]);  
407       chamberSeg->Add(id0+58, slatsegNB[6]);
408     }
409     // type 222330 
410     if (cathod == 0) {
411       chamberSeg->Add(id0+ 3, slatsegB[7]);
412       chamberSeg->Add(id0+ 9, slatsegB[7]);  
413       chamberSeg->Add(id0+53, slatsegB[7]);
414       chamberSeg->Add(id0+59, slatsegB[7]);
415     } else {
416       chamberSeg->Add(id0+ 3, slatsegNB[7]);
417       chamberSeg->Add(id0+ 9, slatsegNB[7]);  
418       chamberSeg->Add(id0+53, slatsegNB[7]);
419       chamberSeg->Add(id0+59, slatsegNB[7]);
420     }
421     // type 223300 
422     if (cathod == 0) {
423       chamberSeg->Add(id0+ 2, slatsegB[8]);
424       chamberSeg->Add(id0+10, slatsegB[8]);  
425       chamberSeg->Add(id0+52, slatsegB[8]);
426       chamberSeg->Add(id0+60, slatsegB[8]);
427     } else {
428       chamberSeg->Add(id0+ 2, slatsegNB[8]);
429       chamberSeg->Add(id0+10, slatsegNB[8]);  
430       chamberSeg->Add(id0+52, slatsegNB[8]);
431       chamberSeg->Add(id0+60, slatsegNB[8]);
432     }
433     // type 333000 
434     if (cathod == 0) {
435       chamberSeg->Add(id0+ 1, slatsegB[9]);
436       chamberSeg->Add(id0+11, slatsegB[9]);  
437       chamberSeg->Add(id0+51, slatsegB[9]);
438       chamberSeg->Add(id0+61, slatsegB[9]);
439     } else {
440       chamberSeg->Add(id0+ 1, slatsegNB[9]);
441       chamberSeg->Add(id0+11, slatsegNB[9]);  
442       chamberSeg->Add(id0+51, slatsegNB[9]);
443       chamberSeg->Add(id0+61, slatsegNB[9]);
444     }
445     // type 330000 
446     if (cathod == 0) {
447       chamberSeg->Add(id0   , slatsegB[10]);
448       chamberSeg->Add(id0+12, slatsegB[10]);  
449       chamberSeg->Add(id0+50, slatsegB[10]);
450       chamberSeg->Add(id0+62, slatsegB[10]);
451     } else {
452       chamberSeg->Add(id0   , slatsegNB[10]);
453       chamberSeg->Add(id0+12, slatsegNB[10]);  
454       chamberSeg->Add(id0+50, slatsegNB[10]);
455       chamberSeg->Add(id0+62, slatsegNB[10]);
456     }
457   }
458
459   // For St5 
460   if (chamberId == 8 || chamberId == 9) {
461     // Create chamber segmentations      
462     id0=(chamberId+1)*100;
463     // type 122330
464     if (cathod == 0) {
465       chamberSeg->Add(id0+ 6, slatsegB[4]);
466       chamberSeg->Add(id0+56, slatsegB[4]);
467     } else {
468       chamberSeg->Add(id0+ 6, slatsegNB[4]);
469       chamberSeg->Add(id0+56, slatsegNB[4]);
470     }
471     // type 112233
472     if (cathod == 0) {
473       chamberSeg->Add(id0+ 4, slatsegB[5]);
474       chamberSeg->Add(id0+ 5, slatsegB[5]);
475       chamberSeg->Add(id0+ 7, slatsegB[5]);  
476       chamberSeg->Add(id0+ 8, slatsegB[5]);  
477       chamberSeg->Add(id0+54, slatsegB[5]);  
478       chamberSeg->Add(id0+55, slatsegB[5]);  
479       chamberSeg->Add(id0+57, slatsegB[5]);
480       chamberSeg->Add(id0+58, slatsegB[5]);
481     } else {
482       chamberSeg->Add(id0+ 4, slatsegNB[5]);
483       chamberSeg->Add(id0+ 5, slatsegNB[5]);
484       chamberSeg->Add(id0+ 7, slatsegNB[5]);  
485       chamberSeg->Add(id0+ 8, slatsegNB[5]);  
486       chamberSeg->Add(id0+54, slatsegNB[5]);  
487       chamberSeg->Add(id0+55, slatsegNB[5]);  
488       chamberSeg->Add(id0+57, slatsegNB[5]);
489       chamberSeg->Add(id0+58, slatsegNB[5]);
490     }
491     // type 222333 
492     if (cathod == 0) {
493       chamberSeg->Add(id0+ 3, slatsegB[11]);
494       chamberSeg->Add(id0+ 9, slatsegB[11]);  
495       chamberSeg->Add(id0+53, slatsegB[11]);
496       chamberSeg->Add(id0+59, slatsegB[11]);
497     } else {
498       chamberSeg->Add(id0+ 3, slatsegNB[11]);
499       chamberSeg->Add(id0+ 9, slatsegNB[11]);  
500       chamberSeg->Add(id0+53, slatsegNB[11]);
501       chamberSeg->Add(id0+59, slatsegNB[11]);
502     }
503     // type 223330 
504     if (cathod == 0) {
505       chamberSeg->Add(id0+ 2, slatsegB[12]);
506       chamberSeg->Add(id0+10, slatsegB[12]);  
507       chamberSeg->Add(id0+52, slatsegB[12]);
508       chamberSeg->Add(id0+60, slatsegB[12]);
509     } else {
510       chamberSeg->Add(id0+ 2, slatsegNB[12]);
511       chamberSeg->Add(id0+10, slatsegNB[12]);  
512       chamberSeg->Add(id0+52, slatsegNB[12]);
513       chamberSeg->Add(id0+60, slatsegNB[12]);
514     }
515     // type 333300 
516     if (cathod == 0) {
517       chamberSeg->Add(id0+ 1, slatsegB[13]);
518       chamberSeg->Add(id0+11, slatsegB[13]);  
519       chamberSeg->Add(id0+51, slatsegB[13]);
520       chamberSeg->Add(id0+61, slatsegB[13]);
521     } else {
522       chamberSeg->Add(id0+ 1, slatsegNB[13]);
523       chamberSeg->Add(id0+11, slatsegNB[13]);  
524       chamberSeg->Add(id0+51, slatsegNB[13]);
525       chamberSeg->Add(id0+61, slatsegNB[13]);
526     }
527     // type 333000 
528     if (cathod == 0) {
529       chamberSeg->Add(id0   , slatsegB[9]);
530       chamberSeg->Add(id0+12, slatsegB[9]);  
531       chamberSeg->Add(id0+50, slatsegB[9]);
532       chamberSeg->Add(id0+62, slatsegB[9]);
533     } else {
534       chamberSeg->Add(id0   , slatsegNB[9]);
535       chamberSeg->Add(id0+12, slatsegNB[9]);  
536       chamberSeg->Add(id0+50, slatsegNB[9]);
537       chamberSeg->Add(id0+62, slatsegNB[9]);
538     }
539   }  
540   
541  
542   if (!id0) {
543     AliWarning(Form("Segmentation for chamber %d , cathod %d is not yet defined",
544                     chamberId, cathod));
545     return 0;
546     
547   }
548   
549   DrawSegmentation(chamberSeg);
550   return chamberSeg;
551   
552
553 //_____________________________________________________________________________
554 AliMUONGeometrySegmentation*     
555 AliMUONTest::CreateTriggerSegmentation(Int_t chamberId, Int_t cathod)
556 {
557 // Create Trigger geometry segmentation for given chamber and cathod
558
559     printf("in CreateTriggerSegmentation chamber=%d cathode=%d\n",
560            chamberId,cathod);
561   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
562   if (!muon) {
563     AliFatal("MUON detector not defined.");
564     return 0;
565   }  
566
567   AliMUONGeometrySegmentation *chamberSeg = new AliMUONGeometrySegmentation(muon->Chamber(chamberId).GetGeometry());
568
569    //Trigger Segmentations
570   AliMUONTriggerSegmentation *trigSegX[9]; 
571   AliMUONTriggerSegmentation *trigSegY[9]; 
572   for(Int_t i=0; i<9; i++) {
573     trigSegX[i] = new AliMUONTriggerSegmentation(0);
574     trigSegY[i] = new AliMUONTriggerSegmentation(1);
575   }
576
577   AliMUONChamber *iChamber, *iChamber1;
578   iChamber1 = &muon->Chamber(10);
579   iChamber  = &muon->Chamber(chamberId);
580   Float_t zpos1= - iChamber1->Z();  
581   Float_t zpos = - iChamber->Z();            
582   Float_t zRatio = zpos / zpos1;
583
584 // init
585   Int_t nStrip[7]={0,0,0,0,0,0,0};        
586   Float_t stripYsize[7]={0.,0.,0.,0.,0.,0.,0.};
587   Float_t stripXsize[7]={0.,0.,0.,0.,0.,0.,0.};
588
589 // chamber 8 cathode 0
590   for (Int_t i=0; i<7; i++) nStrip[i]=16;
591   for (Int_t i=0; i<7; i++) 
592       stripYsize[i]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
593   for (Int_t i=0; i<6; i++) 
594       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
595   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio; 
596   trigSegX[8]->Init(0,1,nStrip,stripYsize,stripXsize,0.);  
597  
598 // chamber 8 cathode 1
599   for (Int_t i=0; i<6; i++) nStrip[i]=8;
600   nStrip[6]=16;
601   for (Int_t i=0; i<7; i++) 
602       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;
603   for (Int_t i=0; i<7; i++) 
604       stripXsize[i]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
605   trigSegY[8]->Init(0,1,nStrip,stripYsize,stripXsize,0.);  
606  
607 // chamber 7 cathode 0
608   for (Int_t i=0; i<6; i++) nStrip[i]=32;
609   nStrip[7]=16;  
610   for (Int_t i=0; i<6; i++) 
611       stripYsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
612   stripYsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
613   for (Int_t i=0; i<6; i++) 
614       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
615   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio;
616   trigSegX[7]->Init(0,2,nStrip,stripYsize,stripXsize,0.);  
617
618 // chamber 7 cathode 1
619   for (Int_t i=0; i<6; i++) nStrip[i]=8;
620   nStrip[6]=16;
621   for (Int_t i=0; i<7; i++) 
622       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;
623   for (Int_t i=0; i<7; i++) 
624       stripXsize[i]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
625   trigSegY[7]->Init(0,2,nStrip,stripYsize,stripXsize,0.);  
626  
627 // chamber 6 cathode 0
628   for (Int_t i=0; i<6; i++) nStrip[i]=32;
629   nStrip[7]=16;  
630   for (Int_t i=0; i<6; i++) 
631       stripYsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
632   stripYsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
633   for (Int_t i=0; i<6; i++) 
634       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
635   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio;
636   trigSegX[6]->Init(0,3,nStrip,stripYsize,stripXsize,0.);  
637
638 // chamber 6 cathode 1
639   for (Int_t i=0; i<5; i++) nStrip[i]=16;
640   nStrip[5]=8;
641   nStrip[6]=16;  
642   for (Int_t i=0; i<7; i++) 
643       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;  
644   for (Int_t i=0; i<5; i++) 
645       stripXsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
646   stripXsize[5]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
647   stripXsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
648   trigSegY[6]->Init(0,3,nStrip,stripYsize,stripXsize,0.);  
649
650 // chamber 5 cathode 0
651   nStrip[0]=48;
652   for (Int_t i=1; i<3; i++) nStrip[i]=64;  
653   for (Int_t i=3; i<6; i++) nStrip[i]=32;
654   nStrip[6]=16;
655   for (Int_t i=0; i<3; i++) 
656       stripYsize[i]=AliMUONTriggerConstants::StripWidth(0)*zRatio;
657   for (Int_t i=3; i<6; i++) 
658   stripYsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
659   stripYsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
660   for (Int_t i=0; i<6; i++) 
661       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
662   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio;
663   trigSegX[5]->Init(0,4,nStrip,stripYsize,stripXsize,AliMUONTriggerConstants::StripLength(0)*zRatio);  
664
665 // chamber 5 cathode 1
666   for (Int_t i=0; i<5; i++) nStrip[i]=16;
667   nStrip[5]=8;  
668   nStrip[6]=16;
669   stripYsize[0]=AliMUONTriggerConstants::StripLength(2)*zRatio;
670   for (Int_t i=1; i<7; i++) 
671       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;
672   for (Int_t i=0; i<5; i++) 
673       stripXsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
674   stripXsize[5]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
675   stripXsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
676   trigSegY[5]->Init(0,4,nStrip,stripYsize,stripXsize,AliMUONTriggerConstants::StripLength(0)*zRatio);  
677
678 // chamber 4 cathode 0
679   nStrip[0]=0;
680   for (Int_t i=1; i<3; i++) nStrip[i]=64;  
681   for (Int_t i=3; i<6; i++) nStrip[i]=32;  
682   nStrip[6]=16;
683   stripYsize[0]=0.;
684   for (Int_t i=1; i<3; i++) 
685       stripYsize[i]=AliMUONTriggerConstants::StripWidth(0)*zRatio;
686   for (Int_t i=3; i<6; i++) 
687       stripYsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
688   stripYsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
689   stripXsize[0]=0;  
690   stripXsize[1]=AliMUONTriggerConstants::StripLength(0)*zRatio;
691   for (Int_t i=2; i<6; i++) 
692       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
693   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio;
694   trigSegX[4]->Init(0,5,nStrip,stripYsize,stripXsize,0.);  
695
696 // chamber 4 cathode 1
697   nStrip[0]=0;  
698   nStrip[1]=8;  
699   for (Int_t i=2; i<5; i++) nStrip[i]=16;
700   nStrip[5]=8;
701   nStrip[6]=16;  
702   stripYsize[0]=0.;  
703   for (Int_t i=1; i<7; i++) 
704       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;
705   stripXsize[0]=0.;
706   for (Int_t i=1; i<5; i++) 
707       stripXsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
708   stripXsize[5]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
709   stripXsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
710   trigSegY[4]->Init(0,5,nStrip,stripYsize,stripXsize,0.);
711
712 // chamber 3 cathode 0
713   nStrip[0]=48;
714   for (Int_t i=1; i<3; i++) nStrip[i]=64;  
715   for (Int_t i=3; i<6; i++) nStrip[i]=32;
716   nStrip[6]=16;
717   for (Int_t i=0; i<3; i++) 
718       stripYsize[i]=AliMUONTriggerConstants::StripWidth(0)*zRatio;
719   for (Int_t i=3; i<6; i++) 
720   stripYsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
721   stripYsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
722   for (Int_t i=0; i<6; i++) 
723       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
724   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio;
725   trigSegX[3]->Init(0,6,nStrip,stripYsize,stripXsize,0.);  
726
727 // chamber 3 cathode 1
728   for (Int_t i=0; i<5; i++) nStrip[i]=16;
729   nStrip[5]=8;  
730   nStrip[6]=16;
731   stripYsize[0]=AliMUONTriggerConstants::StripLength(2)*zRatio;
732   for (Int_t i=1; i<7; i++) 
733       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;
734   for (Int_t i=0; i<5; i++) 
735       stripXsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
736   stripXsize[5]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
737   stripXsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
738   trigSegY[3]->Init(0,6,nStrip,stripYsize,stripXsize,0.);  
739
740 // chamber 2 cathode 0
741   for (Int_t i=0; i<6; i++) nStrip[i]=32;
742   nStrip[7]=16;  
743   for (Int_t i=0; i<6; i++) 
744       stripYsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
745   stripYsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
746   for (Int_t i=0; i<6; i++) 
747       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
748   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio;
749   trigSegX[2]->Init(0,7,nStrip,stripYsize,stripXsize,0.);  
750
751 // chamber 2 cathode 1
752   for (Int_t i=0; i<5; i++) nStrip[i]=16;
753   nStrip[5]=8;
754   nStrip[6]=16;  
755   for (Int_t i=0; i<7; i++) 
756       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;  
757   for (Int_t i=0; i<5; i++) 
758       stripXsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
759   stripXsize[5]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
760   stripXsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
761   trigSegY[2]->Init(0,7,nStrip,stripYsize,stripXsize,0.);  
762
763 // chamber 1 cathode 0
764   for (Int_t i=0; i<6; i++) nStrip[i]=32;
765   nStrip[7]=16;  
766   for (Int_t i=0; i<6; i++) 
767       stripYsize[i]=AliMUONTriggerConstants::StripWidth(1)*zRatio;
768   stripYsize[6]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
769   for (Int_t i=0; i<6; i++) 
770       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
771   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio;
772   trigSegX[1]->Init(0,8,nStrip,stripYsize,stripXsize,0.);  
773
774 // chamber 1 cathode 1
775   for (Int_t i=0; i<6; i++) nStrip[i]=8;
776   nStrip[6]=16;
777   for (Int_t i=0; i<7; i++) 
778       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;
779   for (Int_t i=0; i<7; i++) 
780       stripXsize[i]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
781   trigSegY[1]->Init(0,8,nStrip,stripYsize,stripXsize,0.);  
782
783 // chamber 0 cathode 0
784   for (Int_t i=0; i<7; i++) nStrip[i]=16;
785   for (Int_t i=0; i<7; i++) 
786       stripYsize[i]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
787   for (Int_t i=0; i<6; i++) 
788       stripXsize[i]=AliMUONTriggerConstants::StripLength(1)*zRatio;
789   stripXsize[6]=AliMUONTriggerConstants::StripLength(2)*zRatio; 
790   trigSegX[0]->Init(0,9,nStrip,stripYsize,stripXsize,0.);  
791  
792 // chamber 0 cathode 1
793   for (Int_t i=0; i<6; i++) nStrip[i]=8;
794   nStrip[6]=16;
795   for (Int_t i=0; i<7; i++) 
796       stripYsize[i]=AliMUONTriggerConstants::StripLength(3)*zRatio;
797   for (Int_t i=0; i<7; i++) 
798       stripXsize[i]=AliMUONTriggerConstants::StripWidth(2)*zRatio;
799   trigSegY[0]->Init(0,9,nStrip,stripYsize,stripXsize,0.);
800
801   Int_t icount=chamberId-10;  // chamber counter (0 1 2 3)
802   Int_t id0=(10+icount+1)*100;
803
804   printf("in CreateTriggerSegmentation here 0 id0=%i \n",id0);  
805
806   for (Int_t i=0; i<9; i++) {      
807       if (cathod==0) {    
808           chamberSeg->Add(id0+i,     trigSegX[i]);
809           chamberSeg->Add(id0+50+i,  trigSegX[i]);
810       } else if (cathod==1) {       
811           chamberSeg->Add(id0+i,     trigSegY[i]);
812           chamberSeg->Add(id0+50+i,  trigSegY[i]);
813       }
814   }
815
816   printf("in CreateTriggerSegmentation here 1\n");  
817
818   if (!id0) {
819       AliWarning(Form("Segmentation for chamber %d , cathod %d is not yet defined",chamberId, cathod));
820       return 0;      
821   }
822
823   DrawSegmentation(chamberSeg);  
824   return chamberSeg;
825 }
826
827
828 //
829 // public methods
830 //
831
832 //______________________________________________________________________________
833 AliMUONGeometrySegmentation* 
834 AliMUONTest::CreateSegmentation(Int_t chamberId, Int_t cath)
835 {
836 // Create geometry segmentation for the specified chamber and cathod
837
838   switch (chamberId) {
839
840     // Station1
841     case 0: 
842     case 1:
843         return CreateSt1Segmentation(chamberId, cath);
844         break;
845
846     // Station2
847     case 2: 
848     case 3:
849         AliWarning("Not yet implemented");
850         return 0;
851         break;
852
853     // Slat stations
854     case 4: 
855     case 5: 
856     case 6: 
857     case 7: 
858     case 8: 
859     case 9:
860         return CreateSlatSegmentation(chamberId, cath);
861         break;
862                 
863     // Trigger stations
864     case 10: 
865     case 11: 
866     case 12: 
867     case 13:
868         return CreateTriggerSegmentation(chamberId, cath);
869         break;
870
871     default:
872         AliWarning("Wrong chamber Id");
873         return 0;
874         break;
875   }     
876 }               
877 //______________________________________________________________________________
878 void  AliMUONTest::DetElemTransforms()
879 {
880 // 
881   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
882   if (!muon) {
883     AliFatal("MUON detector not defined.");
884     return;
885   }  
886   
887   // Loop over chambers
888   for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
889
890     AliMUONGeometryModule* geometry = muon->Chamber(i).GetGeometry();
891     AliMUONGeometryStore* detElements = geometry->GetDetElementStore();
892     
893     // Loop over detection elements
894     for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
895        
896       //Int_t detElemId = geometry->GetDetElemId(j);       
897       Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();       
898       cout << "Detection element Id: " << detElemId << endl;
899         
900       Double_t x, y, z;
901       geometry->Local2Global(detElemId, 0., 0., 0., x, y, z);
902       cout << "  Global DE position:            " 
903            <<  x << ",  " << y << ",  " << z << endl; 
904
905       Double_t x2, y2, z2;
906       geometry->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
907       cout << "  ALIC center in the local frame: " 
908            <<  x2 << ",  " << y2 << ",  " << z2 << endl; 
909              
910       Double_t x3, y3, z3;
911       geometry->Global2Local(detElemId, x, y, z, x3, y3, z3);
912       cout << "  Back in the local frame: " 
913            <<  x3 << ",  " << y3 << ",  " << z3 << endl;        
914       cout << endl;          
915     }
916   }
917 }        
918
919 //________________________________________________________________________
920 void AliMUONTest::PrintPadPositionsOld()
921 {
922 // Iterate over all old chamber segmentations and prints
923 // global pad positions
924
925   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
926   if (!muon) {
927     AliFatal("MUON detector not defined.");
928     return;
929   }  
930
931   // Loop over chambers
932   for (Int_t i=0; i<1; i++) {
933
934     // Create chamber segmentations
935     AliSegmentation* seg[2];
936     seg[0] = muon->Chamber(i).SegmentationModel(0);
937     seg[1] = muon->Chamber(i).SegmentationModel(1);
938
939     // Iterate over the whole plane and return pad indices and 
940     // global/local positions
941     cout << "Go to loop over pads" << endl;
942     for (Int_t cath=0; cath<2; cath++) {
943       
944       cout << setw(6) << "Pads in chamber " << i << " cathod " << cath << endl;
945       cout << "===================================" << endl;  
946       TStopwatch timer;
947       timer.Start();  
948
949       Int_t counter = 0;
950       for ( seg[cath]->FirstPad(70., 70., 0., 80., 80.);
951             seg[cath]->MorePads(); 
952             seg[cath]->NextPad() )
953       {
954         cout << setw(6) << "counter " << counter++ << "   ";
955   
956         Int_t ix = seg[cath]->Ix();
957         Int_t iy = seg[cath]->Iy();
958         cout << "Pad indices:  ( " << ix << ", " << iy << " )  " ;
959
960         Float_t x, y, z;
961         seg[cath]->GetPadC(ix, iy, x, y, z);
962         cout << "Pad position: ( " << x << ", " << y << ", " << z << " )" << endl;
963       }
964       timer.Stop();
965       timer.Print();
966     }  
967   }  
968 }
969
970 //______________________________________________________________________________
971 void AliMUONTest::ForWhole(AliMUONTests testCase)
972 {
973 // Perform test for all chambers and first cathod
974
975   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
976   if (!muon) {
977     AliFatal("MUON detector not defined.");
978     return;
979   }  
980
981   TStopwatch timer;
982   timer.Start();  
983
984   // Loop over chambers
985 //  for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
986   for (Int_t iChamber=10; iChamber<14; iChamber++) {
987
988     // Loop over cathods
989     //for (Int_t cath=0; cath<2; cath++) {
990     for (Int_t cath=0; cath<1; cath++) {
991
992       AliMUONGeometrySegmentation* segmentation 
993         = CreateSegmentation(iChamber, cath);
994         
995       if (!segmentation) continue;
996         
997       cout << setw(6) << "Pads in chamber " << iChamber 
998            << " cathod " << cath << endl;
999       cout << "===================================" << endl;  
1000
1001       ForSegmentation(testCase, segmentation);
1002            
1003       //if (testCase == kDrawPads) {
1004       //}       
1005     }  
1006   }     
1007   timer.Stop();
1008   timer.Print();
1009 }    
1010
1011 //______________________________________________________________________________
1012 void AliMUONTest::ForSegmentation(AliMUONTests testCase,
1013                                   AliMUONGeometrySegmentation *segmentation)
1014 {
1015 // Perform test for a given segmentation
1016   
1017   TStopwatch timer;
1018   timer.Start();  
1019
1020   Before(testCase);
1021
1022   // Loop over detection elements
1023   //
1024   AliMUONGeometryStore* detElements 
1025     = segmentation->GetGeometry()->GetDetElementStore();
1026     
1027   for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
1028        
1029     Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();       
1030     cout << "Detection element id: " << detElemId << endl;
1031     
1032     ForDetElement(testCase, detElemId, segmentation);
1033   }  
1034
1035   After(testCase);
1036
1037   timer.Stop();
1038   timer.Print();
1039
1040    
1041 //______________________________________________________________________________
1042 void AliMUONTest::ForDetElement(AliMUONTests testCase,
1043                                 Int_t detElemId,
1044                                 AliMUONGeometrySegmentation *segmentation)
1045 {
1046 // Prints global pad positions for given detection element
1047 // in a given geometry segmentation
1048   
1049   
1050   Int_t counter = 0;
1051
1052   // Loop over pads in a detection element
1053   //
1054
1055   for(Int_t ix=1; ix<=segmentation->Npx(detElemId); ix++)
1056     for(Int_t iy=1; iy<=segmentation->Npy(detElemId); iy++) 
1057     {
1058        switch (testCase) {
1059      
1060          case kPrintPads:
1061            PrintPad(counter, detElemId, ix, iy, segmentation);
1062            break;
1063      
1064          case kDrawPads:
1065            DrawPad(counter, detElemId, ix, iy, segmentation);
1066            break;
1067       }
1068     }    
1069
1070    
1071 //______________________________________________________________________________
1072 void AliMUONTest::Before(AliMUONTests testCase)
1073 {
1074 // Do some initialization if necessary
1075
1076   switch (testCase) {
1077   
1078     case kPrintPads:
1079       break;
1080
1081     case kDrawPads:
1082       if (!fCanvas) {
1083         fCanvas = new TCanvas("c1","c1", 0, 0, 600, 600);
1084         fCanvas->Range(-300,-300, 300, 300);
1085         fCanvas->cd();
1086       }  
1087       break;
1088   }        
1089 }
1090
1091 //______________________________________________________________________________
1092 void AliMUONTest::After(AliMUONTests testCase)
1093 {
1094 // Do some cleanup if necessary
1095
1096   switch (testCase) {
1097   
1098     case kPrintPads:
1099       break;
1100
1101     case kDrawPads:
1102       fCanvas->Update();
1103       cout << "Print any key + enter to continue ..." << endl;
1104       char c;
1105       cin >> c;
1106       fCanvas->Clear();
1107       break;
1108   }        
1109 }
1110
1111 //______________________________________________________________________________
1112 void AliMUONTest::PrintPad(Int_t& counter,
1113                            Int_t detElemId, Int_t ix, Int_t iy,
1114                            AliMUONGeometrySegmentation* segmentation)
1115 {
1116 // Prints global pad positions for the given pad
1117   
1118   Float_t x, y, z;
1119   Bool_t success
1120     = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
1121   
1122   if (!success) return;  
1123
1124   cout << setw(6) << "counter " << counter++ << "   ";
1125   cout << "Pad indices:  ( " << detElemId << "; " << ix << ", " << iy << " )  " ;
1126   cout << "Pad position: ( " << x << ", " << y << ", " << z << " )" << endl;
1127
1128    
1129 //______________________________________________________________________________
1130 void AliMUONTest::DrawPad(Int_t& counter,
1131                           Int_t detElemId, Int_t ix, Int_t iy,
1132                           AliMUONGeometrySegmentation* segmentation)
1133 {
1134 // Prints global pad positions for the given pad
1135   
1136   Float_t x, y, z;
1137   Bool_t success
1138     = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
1139
1140   if (!success) return;  
1141   
1142   // PrintPad(counter,detElemId, ix, iy, segmentation); 
1143
1144   counter++;
1145   
1146   Int_t sector = segmentation->Sector(detElemId, ix, iy);
1147   Float_t dpx = segmentation->Dpx(detElemId, sector);
1148   Float_t dpy = segmentation->Dpy(detElemId, sector);
1149
1150   //printf(" ***** Pad position is ix: %d iy: %d x: %f y: %f sector: %d dpx: %f dpy: %f \n",
1151   //       ix, iy, x, y, sector, dpx, dpy);
1152
1153   if (!fCanvas) Before(kDrawPads);
1154
1155   fCanvas->cd();
1156   TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1);
1157   pave->Draw();
1158
1159    
1160 //______________________________________________________________________________
1161 void AliMUONTest::DrawSegmentation(AliMUONGeometrySegmentation *seg)
1162 {
1163 // TBR
1164
1165   // Drawing slat504
1166   Int_t ix, iy, deId;
1167   Float_t x, y, z;
1168   Float_t dpx, dpy;
1169 //   TH2F * frame = new TH2F(" "," ",10,-10.,245.,10, -5., 45.);
1170 //   TH2F * frame = new TH2F(" "," ",10,-300.,300.,10, -300., 300.);
1171   TH2F * frame = new TH2F(" "," ",10,-200.,200.,10, -200., 200.);
1172   frame->Draw();
1173 //   (new TPave(  0.,  0., 40., 40.,2))->Draw();
1174 //   (new TPave( 40.,  0., 80., 40.,2))->Draw();
1175 //   (new TPave( 80.,  0.,120., 40.,2))->Draw();
1176 //   (new TPave(120.,  0.,160., 40.,2))->Draw();
1177 //   (new TPave(160.,  0.,200., 40.,2))->Draw();
1178 //   (new TPave(200.,  0.,240., 40.,2))->Draw();
1179   
1180   // Loop over detection elements
1181   //
1182   AliMUONGeometryStore* detElements 
1183     = seg->GetGeometry()->GetDetElementStore();
1184     
1185   for (Int_t iDE=0; iDE<detElements->GetNofEntries(); iDE++) {
1186     
1187     deId = detElements->GetEntry(iDE)->GetUniqueID();       
1188     cout << "Detection element id: " << deId << endl;
1189     
1190     
1191     //   for ( seg->FirstPad(detElementId,  0., 0., 0., 100., 100.);
1192     //  seg->MorePads(detElementId); 
1193     //  seg->NextPad(detElementId) ) {
1194     for(ix=1; ix<=seg->Npx(deId); ix++) {
1195       for(iy=1; iy<=seg->Npy(deId); iy++) {
1196         
1197         seg->GetPadC(deId, ix, iy, x, y, z);
1198         Int_t sector = seg->Sector(deId, ix, iy);
1199         dpx = seg->Dpx(deId,sector);
1200         dpy = seg->Dpy(deId,sector);
1201         
1202         //printf(" ***** Pad position is ix: %d iy: %d x: %f y: %f sector: %d dpx: %f dpy: %f \n",ix, iy, x, y, sector, dpx, dpy);
1203         (new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1))->Draw();
1204       }
1205       
1206     }
1207   }
1208 }
1209
1210
1211