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