]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTest.cxx
- Test functions restructured to make possible to apply test
[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
43 ClassImp(AliMUONTest)
44
45 //__________________________________________________________________
46   AliMUONTest::AliMUONTest(const TString& configMacro)
47   : TObject(),
48     fCanvas(0)
49 {
50 // Standard Constructor
51 //
52   // Initialize AliRoot
53   gAlice->Init(configMacro.Data());
54 }
55
56 //__________________________________________________________________
57 AliMUONTest::AliMUONTest()
58   : TObject(),
59     fCanvas(0)
60 {
61 // Default Constructor
62 //
63 }
64
65 //____________________________________________________________________
66 AliMUONTest::AliMUONTest(const AliMUONTest& rhs)
67  : TObject(rhs)
68 {
69 // Protected copy constructor
70
71   AliFatal("Not implemented.");
72 }
73
74 //____________________________________________________________________
75 AliMUONTest::~AliMUONTest()
76 {
77 // Destructor
78
79   delete fCanvas;
80 }
81
82 //________________________________________________________________________
83 AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs)
84 {
85 // Protected assignement operator
86
87   if (this == &rhs) return *this;
88
89   AliFatal("Not implemented.");
90     
91   return *this;  
92 }
93
94 //
95 // private methods
96 //
97
98 //________________________________________________________________________
99 AliMUONGeometrySegmentation*     
100 AliMUONTest::CreateSt1Segmentation(Int_t chamberId, Int_t cathod)
101 {
102 // Create St1 geometry segmentation for given chamber and cathod
103
104   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
105   if (!muon) {
106     AliFatal("MUON detector not defined.");
107     return 0;   
108   }  
109
110   AliMUONGeometrySegmentation* segmentation
111     = new AliMUONGeometrySegmentation(muon->Chamber(chamberId).GetGeometry());
112     
113   // Quadrant segmentations:
114   AliMUONSt12QuadrantSegmentation* bendSt1
115     = new AliMUONSt12QuadrantSegmentation(kStation1, kBendingPlane);
116   AliMUONSt12QuadrantSegmentation* nonbendSt1
117     = new AliMUONSt12QuadrantSegmentation(kStation1, kNonBendingPlane);
118
119   // The same configuration for both chambers of Station 1
120   Int_t id0 = (chamberId+1)*100;
121
122   // Configure  St1 chamber segmentations
123   if (cathod == 0) {
124     // bending plane
125     segmentation->Add(id0,      bendSt1);
126     segmentation->Add(id0 +  1, nonbendSt1);
127     segmentation->Add(id0 + 50, bendSt1);
128     segmentation->Add(id0 + 51, nonbendSt1);
129   }
130   else if (cathod == 1) {
131     // non-bending plane
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    //Slats Segmentations
158   AliMUONSt345SlatSegmentation *slatseg[20]; // Types of segmentation for St3 in this framework
159   Int_t ndiv[4] ={ 4, 4, 2, 1};  // densities zones 
160   for(Int_t i=0; i<20;i++) {
161     slatseg[i] = new AliMUONSt345SlatSegmentation();
162     slatseg[i]->SetPadSize(10.,0.5);
163     slatseg[i]->SetPadDivision(ndiv);
164     slatseg[i]->SetId(1);
165     slatseg[i]->SetDAnod(0.25);
166   }
167   
168   //******************************************************************************************
169   // Station 3
170   //******************************************************************************************
171
172   // Type 112200 for 500, 501, 508, 509, 510, 517 in Ch5 (similar for Ch6) for the futur official numbering
173   // Type 112200 for 503, 504, 505, 555, 554, 553 in Ch5 (similar for Ch6) actual numbering in the code to be changed in jan05
174   Int_t n0[4] = { 0, 2, 2, 0 };
175   slatseg[0]->SetPcbBoards(n0);
176   slatseg[0]->Init(0);
177   
178   // Type 122200 for 502, 507, 511, 516 (similar in Ch6) for future official numbering of ALICE
179   // Type 122200 for 502, 506, 556, 552 (similiarin Ch6) for actual numbering in muon code to be changed in jan05
180   Int_t n1[4] = { 0, 1, 3, 0 }; 
181   slatseg[1]->SetPcbBoards(n1);
182   slatseg[1]->Init(0); 
183   
184   // Type 222000 for 503, 506, 512, 515 (similar in Ch6) for future official numbering of ALICE
185   // Type 222000 for 501, 507, 557, 551 (similiarin Ch6) for actual numbering in muon code to be changed in jan05
186   Int_t n2[4] = { 0, 0, 3, 0 };
187   slatseg[2]->SetPcbBoards(n2);
188   slatseg[2]->Init(0);
189   
190   // Type 220000 for 504, 505, 513, 514 (similar in Ch6) for future official numbering of ALICE
191   // Type 220000 for 500, 508, 558, 550 (similiarin Ch6) for actual numbering in muon code to be changed in jan05
192   Int_t n3[4] = { 0, 0, 2, 0 };
193   slatseg[3]->SetPcbBoards(n3);
194   slatseg[3]->Init(0); 
195
196   //******************************************************************************************
197   // Station 4 & 5
198   //****************************************************************************************
199   
200   // Type 122330 for 700, 713 in Ch7 (similar for Ch8) for the futur official numbering
201   // Type 122330 for 706, 756 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
202   // Type 122330 for 900, 913 in Ch9 (similar for Ch10) for the futur official numbering
203   // Type 122330 for 906, 956 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
204   
205   Int_t n4[4] = { 0, 1, 2, 2 };
206   slatseg[4]->SetPcbBoards(n4);
207   slatseg[4]->Init(0); // 0 detection element id
208
209   // Type 112233 for 701, 712, 714, 725 in Ch7 (similar for Ch8) for the futur official numbering
210   // Type 112233 for 705, 707, 755, 757 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
211   // Type 112233 for 901, 902, 911, 912, 914, 915, 924, 925 in Ch9 (similar for Ch10) for the futur official numbering
212   // 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
213   Int_t n5[4] = { 0, 2, 2, 2 };
214   slatseg[5]->SetPcbBoards(n5);
215   slatseg[5]->Init(0); // 0 detection element id
216
217   // Type 112230 for 702, 711, 715, 724 in Ch7 (similar for Ch8) for the futur official numbering
218   // Type 112230 for 704, 708, 754, 758 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
219   Int_t n6[4] = { 0, 2, 2, 1 };
220   slatseg[6]->SetPcbBoards(n6);
221   slatseg[6]->Init(0); // 0 detection element id
222
223   // Type 222330 for 703, 710, 716, 723 in Ch7 (similar for Ch8) for the futur official numbering
224   // Type 222330 for 703, 709, 753, 759 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
225   Int_t n7[4] = { 0, 0, 3, 2 };
226   slatseg[7]->SetPcbBoards(n7);
227   slatseg[7]->Init(0); // 0 detection element id
228
229   // Type 223300 for 704, 709, 717, 722 in Ch7 (similar for Ch8) for the futur official numbering
230   // Type 223300 for 702, 710, 752, 760 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
231   Int_t n8[4] = { 0, 0, 2, 2 };
232   slatseg[8]->SetPcbBoards(n8);
233   slatseg[8]->Init(0); // 0 detection element id
234
235   // Type 333000 for 705, 708, 718, 721 in Ch7 (similar for Ch8) for the futur official numbering
236   // Type 333000 for 701, 711, 751, 761 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
237   // Type 333000 for 906, 907, 919, 920 in Ch9 (similar for Ch10) for the futur official numbering
238   // Type 333000 for 900, 912, 950, 962 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
239    Int_t n9[4] = { 0, 0, 0, 3 };
240   slatseg[9]->SetPcbBoards(n9);
241   slatseg[9]->Init(0); // 0 detection element id
242
243   // Type 330000 for 706, 707, 719, 720 in Ch7 (similar for Ch8) for the futur official numbering
244   // Type 330000 for 700, 712, 750, 762 in Ch7 (similar for Ch8) actual numbering in the code to be changed in jan05
245   Int_t n10[4] = { 0, 0, 0, 2 };
246   slatseg[10]->SetPcbBoards(n10);
247   slatseg[10]->Init(0); // 0 detection element id
248
249   // Type 222333 for 903, 910, 916, 923 in Ch9 (similar for Ch10) for the futur official numbering
250   // Type 222333 for 903, 909, 953, 959 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
251   Int_t n11[4] = { 0, 0, 3, 3 };
252   slatseg[11]->SetPcbBoards(n11);
253   slatseg[11]->Init(0); // 0 detection element id
254          
255   // Type 223330 for 904, 909, 917, 922 in Ch9 (similar for Ch10) for the futur official numbering
256   // Type 223330 for 902, 910, 952, 960 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
257   Int_t n12[4] = { 0, 0, 2, 3 };
258   slatseg[12]->SetPcbBoards(n12);
259   slatseg[12]->Init(0); // 0 detection element id
260
261   // Type 333300 for 905, 908, 918, 921 in Ch9 (similar for Ch10) for the futur official numbering
262   // Type 333300 for 901, 911, 951, 961 in Ch9 (similar for Ch10) actual numbering in the code to be changed in jan05
263   Int_t n13[4] = { 0, 0, 0, 4 };
264   slatseg[13]->SetPcbBoards(n13);
265   slatseg[13]->Init(0); // 0 detection element id
266   
267  
268   //Loop for St3 (only segmentation for bending plane)
269   for (Int_t i=0; i<2; i++) {
270     // Create chamber segmentations  
271     Int_t chamber = i+4;
272     AliMUONGeometrySegmentation* 
273       st3seg = new AliMUONGeometrySegmentation(muon->Chamber(chamber).GetGeometry());
274     
275     Int_t id0=(chamber+1)*100;
276     // type 220000
277     st3seg->Add(id0, slatseg[3]);
278     st3seg->Add(id0+ 8, slatseg[3]);  
279     st3seg->Add(id0+50, slatseg[3]);  
280     st3seg->Add(id0+58, slatseg[3]);
281     // type 222000
282     st3seg->Add(id0+ 1, slatseg[2]);
283     st3seg->Add(id0+ 7, slatseg[2]);  
284     st3seg->Add(id0+51, slatseg[2]);  
285     st3seg->Add(id0+57, slatseg[2]);
286     // type 122200
287     st3seg->Add(id0+ 2, slatseg[1]);
288     st3seg->Add(id0+ 6, slatseg[1]);  
289     st3seg->Add(id0+52, slatseg[1]);  
290     st3seg->Add(id0+56, slatseg[1]);
291     // type 112200
292     st3seg->Add(id0+ 3, slatseg[0]);
293     st3seg->Add(id0+ 4, slatseg[0]);  
294     st3seg->Add(id0+ 5, slatseg[0]);  
295     st3seg->Add(id0+53, slatseg[0]);
296     st3seg->Add(id0+54, slatseg[0]);     
297     st3seg->Add(id0+55, slatseg[0]);
298     
299 //     if (i == 0) DrawSegmentation(chamber,st3seg);
300
301     if (chamberId == chamber) return st3seg;
302   }
303   
304   //Loop for St4 (only segmentation for bending plane)
305   for (Int_t i=0; i<2; i++) {
306     // Create chamber segmentations  
307     Int_t chamber = i+6;
308     AliMUONGeometrySegmentation* st4seg = new AliMUONGeometrySegmentation(muon->Chamber(chamber).GetGeometry());
309     
310     Int_t id0=(chamber+1)*100;
311     // type 122330
312     st4seg->Add(id0+ 6, slatseg[4]);
313     st4seg->Add(id0+56, slatseg[4]);
314     // type 112233
315     st4seg->Add(id0+ 5, slatseg[5]);
316     st4seg->Add(id0+ 7, slatseg[5]);  
317     st4seg->Add(id0+55, slatseg[5]);  
318     st4seg->Add(id0+57, slatseg[5]);
319     // type 112230
320     st4seg->Add(id0+ 4, slatseg[6]);
321     st4seg->Add(id0+ 8, slatseg[6]);  
322     st4seg->Add(id0+54, slatseg[6]);  
323     st4seg->Add(id0+58, slatseg[6]);
324     // type 222330 
325     st4seg->Add(id0+ 3, slatseg[7]);
326     st4seg->Add(id0+ 9, slatseg[7]);  
327     st4seg->Add(id0+53, slatseg[7]);
328     st4seg->Add(id0+59, slatseg[7]);
329     // type 223300 
330     st4seg->Add(id0+ 2, slatseg[8]);
331     st4seg->Add(id0+10, slatseg[8]);  
332     st4seg->Add(id0+52, slatseg[8]);
333     st4seg->Add(id0+60, slatseg[8]);
334     // type 333000 
335     st4seg->Add(id0+ 1, slatseg[9]);
336     st4seg->Add(id0+11, slatseg[9]);  
337     st4seg->Add(id0+51, slatseg[9]);
338     st4seg->Add(id0+61, slatseg[9]);
339     // type 330000 
340     st4seg->Add(id0   , slatseg[10]);
341     st4seg->Add(id0+12, slatseg[10]);  
342     st4seg->Add(id0+50, slatseg[10]);
343     st4seg->Add(id0+62, slatseg[10]);
344     
345 //     if (i == 0) DrawSegmentation(chamber,st4seg);
346
347     if (chamberId == chamber) return st4seg;
348   }
349
350   //Loop for St5 (only segmentation for bending plane)
351   for (Int_t i=0; i<2; i++) {
352     // Create chamber segmentations  
353     Int_t chamber = i+8;
354     AliMUONGeometrySegmentation* st5seg 
355       = new AliMUONGeometrySegmentation(muon->Chamber(chamber).GetGeometry());
356     
357     Int_t id0=(chamber+1)*100;
358     // type 122330
359     st5seg->Add(id0+ 6, slatseg[4]);
360     st5seg->Add(id0+56, slatseg[4]);
361     // type 112233
362     st5seg->Add(id0+ 4, slatseg[5]);
363     st5seg->Add(id0+ 5, slatseg[5]);
364     st5seg->Add(id0+ 7, slatseg[5]);  
365     st5seg->Add(id0+ 8, slatseg[5]);  
366     st5seg->Add(id0+54, slatseg[5]);  
367     st5seg->Add(id0+55, slatseg[5]);  
368     st5seg->Add(id0+57, slatseg[5]);
369     st5seg->Add(id0+58, slatseg[5]);
370     // type 222333 
371     st5seg->Add(id0+ 3, slatseg[11]);
372     st5seg->Add(id0+ 9, slatseg[11]);  
373     st5seg->Add(id0+53, slatseg[11]);
374     st5seg->Add(id0+59, slatseg[11]);
375     // type 223330 
376     st5seg->Add(id0+ 2, slatseg[12]);
377     st5seg->Add(id0+10, slatseg[12]);  
378     st5seg->Add(id0+52, slatseg[12]);
379     st5seg->Add(id0+60, slatseg[12]);
380     // type 333300 
381     st5seg->Add(id0+ 1, slatseg[13]);
382     st5seg->Add(id0+11, slatseg[13]);  
383     st5seg->Add(id0+51, slatseg[13]);
384     st5seg->Add(id0+61, slatseg[13]);
385     // type 333000 
386     st5seg->Add(id0   , slatseg[9]);
387     st5seg->Add(id0+12, slatseg[9]);  
388     st5seg->Add(id0+50, slatseg[9]);
389     st5seg->Add(id0+62, slatseg[9]);
390     
391     // if (i == 0) DrawSegmentation(chamber,st5seg);
392
393     if (chamberId == chamber) return st5seg;
394   }
395
396   AliWarning(Form("Segmentation for chamber %d , cathod %d is not yet defined",
397               chamberId, cathod));
398   return 0;
399
400
401 //
402 // public methods
403 //
404
405 //______________________________________________________________________________
406 AliMUONGeometrySegmentation* 
407 AliMUONTest::CreateSegmentation(Int_t chamberId, Int_t cath)
408 {
409 // Create geometry segmentation for the specified chamber and cathod
410
411   switch (chamberId) {
412
413     // Station1
414     case 0: 
415     case 1:
416         return CreateSt1Segmentation(chamberId, cath);
417         break;
418
419     // Station2
420     case 2: 
421     case 3:
422         AliWarning("Not yet implemented");
423         return 0;
424         break;
425
426     // Slat stations
427     case 4: 
428     case 5: 
429     case 6: 
430     case 7: 
431     case 8: 
432     case 9:
433         return CreateSlatSegmentation(chamberId, cath);
434         break;
435                 
436     // Trigger stations
437     case 10: 
438     case 11: 
439     case 12: 
440     case 13:
441         //return CreateTriggerSegmentation(chamberId, cath);
442         AliWarning("Not yet implemented");
443         return 0;
444         break;
445
446     default:
447         AliWarning("Wrong chamber Id");
448         return 0;
449         break;
450   }     
451 }               
452
453 //______________________________________________________________________________
454 void  AliMUONTest::DetElemTransforms()
455 {
456 // 
457   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
458   if (!muon) {
459     AliFatal("MUON detector not defined.");
460     return;
461   }  
462   
463   // Loop over chambers
464   for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
465
466     AliMUONGeometryModule* geometry = muon->Chamber(i).GetGeometry();
467     AliMUONGeometryStore* detElements = geometry->GetDetElementStore();
468     
469     // Loop over detection elements
470     for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
471        
472       //Int_t detElemId = geometry->GetDetElemId(j);       
473       Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();       
474       cout << "Detection element Id: " << detElemId << endl;
475         
476       Double_t x, y, z;
477       geometry->Local2Global(detElemId, 0., 0., 0., x, y, z);
478       cout << "  Global DE position:            " 
479            <<  x << ",  " << y << ",  " << z << endl; 
480
481       Double_t x2, y2, z2;
482       geometry->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
483       cout << "  ALIC center in the local frame: " 
484            <<  x2 << ",  " << y2 << ",  " << z2 << endl; 
485              
486       Double_t x3, y3, z3;
487       geometry->Global2Local(detElemId, x, y, z, x3, y3, z3);
488       cout << "  Back in the local frame: " 
489            <<  x3 << ",  " << y3 << ",  " << z3 << endl;        
490       cout << endl;          
491     }
492   }
493 }        
494
495 //________________________________________________________________________
496 void AliMUONTest::PrintPadPositionsOld()
497 {
498 // Iterate over all old chamber segmentations and prints
499 // global pad positions
500
501   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
502   if (!muon) {
503     AliFatal("MUON detector not defined.");
504     return;
505   }  
506
507   // Loop over chambers
508   for (Int_t i=0; i<1; i++) {
509
510     // Create chamber segmentations
511     AliSegmentation* seg[2];
512     seg[0] = muon->Chamber(i).SegmentationModel(0);
513     seg[1] = muon->Chamber(i).SegmentationModel(1);
514
515     // Iterate over the whole plane and return pad indices and 
516     // global/local positions
517     cout << "Go to loop over pads" << endl;
518     for (Int_t cath=0; cath<2; cath++) {
519       
520       cout << setw(6) << "Pads in chamber " << i << " cathod " << cath << endl;
521       cout << "===================================" << endl;  
522       TStopwatch timer;
523       timer.Start();  
524
525       Int_t counter = 0;
526       for ( seg[cath]->FirstPad(70., 70., 0., 80., 80.);
527             seg[cath]->MorePads(); 
528             seg[cath]->NextPad() )
529       {
530         cout << setw(6) << "counter " << counter++ << "   ";
531   
532         Int_t ix = seg[cath]->Ix();
533         Int_t iy = seg[cath]->Iy();
534         cout << "Pad indices:  ( " << ix << ", " << iy << " )  " ;
535
536         Float_t x, y, z;
537         seg[cath]->GetPadC(ix, iy, x, y, z);
538         cout << "Pad position: ( " << x << ", " << y << ", " << z << " )" << endl;
539       }
540       timer.Stop();
541       timer.Print();
542     }  
543   }  
544 }
545
546 //______________________________________________________________________________
547 void AliMUONTest::ForWhole(AliMUONTests testCase)
548 {
549 // Perform test for all chambers and first cathod
550
551   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
552   if (!muon) {
553     AliFatal("MUON detector not defined.");
554     return;
555   }  
556
557   TStopwatch timer;
558   timer.Start();  
559
560   // Loop over chambers
561   for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
562
563     // Loop over cathods
564     //for (Int_t cath=0; cath<2; cath++) {
565     for (Int_t cath=0; cath<1; cath++) {
566
567       AliMUONGeometrySegmentation* segmentation 
568         = CreateSegmentation(iChamber, cath);
569         
570       if (!segmentation) continue;
571         
572       cout << setw(6) << "Pads in chamber " << iChamber 
573            << " cathod " << cath << endl;
574       cout << "===================================" << endl;  
575
576       ForSegmentation(testCase, segmentation);
577            
578       //if (testCase == kDrawPads) {
579       //}       
580     }  
581   }     
582   timer.Stop();
583   timer.Print();
584 }    
585
586 //______________________________________________________________________________
587 void AliMUONTest::ForSegmentation(AliMUONTests testCase,
588                                   AliMUONGeometrySegmentation *segmentation)
589 {
590 // Perform test for a given segmentation
591   
592   TStopwatch timer;
593   timer.Start();  
594
595   Before(testCase);
596
597   // Loop over detection elements
598   //
599   AliMUONGeometryStore* detElements 
600     = segmentation->GetGeometry()->GetDetElementStore();
601     
602   for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
603        
604     Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();       
605     cout << "Detection element id: " << detElemId << endl;
606     
607     ForDetElement(testCase, detElemId, segmentation);
608   }  
609
610   After(testCase);
611
612   timer.Stop();
613   timer.Print();
614
615    
616 //______________________________________________________________________________
617 void AliMUONTest::ForDetElement(AliMUONTests testCase,
618                                 Int_t detElemId,
619                                 AliMUONGeometrySegmentation *segmentation)
620 {
621 // Prints global pad positions for given detection element
622 // in a given geometry segmentation
623   
624   
625   Int_t counter = 0;
626
627   // Loop over pads in a detection element
628   //
629
630   for(Int_t ix=1; ix<=segmentation->Npx(detElemId); ix++)
631     for(Int_t iy=1; iy<=segmentation->Npy(detElemId); iy++) 
632     {
633        switch (testCase) {
634      
635          case kPrintPads:
636            PrintPad(counter, detElemId, ix, iy, segmentation);
637            break;
638      
639          case kDrawPads:
640            DrawPad(counter, detElemId, ix, iy, segmentation);
641            break;
642       }
643     }    
644
645    
646 //______________________________________________________________________________
647 void AliMUONTest::Before(AliMUONTests testCase)
648 {
649 // Do some initialization if necessary
650
651   switch (testCase) {
652   
653     case kPrintPads:
654       break;
655
656     case kDrawPads:
657       if (!fCanvas) {
658         fCanvas = new TCanvas("c1","c1", 0, 0, 600, 600);
659         fCanvas->Range(-300,-300, 300, 300);
660         fCanvas->cd();
661       }  
662       break;
663   }        
664 }
665
666 //______________________________________________________________________________
667 void AliMUONTest::After(AliMUONTests testCase)
668 {
669 // Do some cleanup if necessary
670
671   switch (testCase) {
672   
673     case kPrintPads:
674       break;
675
676     case kDrawPads:
677       fCanvas->Update();
678       cout << "Print any key + enter to continue ..." << endl;
679       char c;
680       cin >> c;
681       fCanvas->Clear();
682       break;
683   }        
684 }
685
686 //______________________________________________________________________________
687 void AliMUONTest::PrintPad(Int_t& counter,
688                            Int_t detElemId, Int_t ix, Int_t iy,
689                            AliMUONGeometrySegmentation* segmentation)
690 {
691 // Prints global pad positions for the given pad
692   
693   Float_t x, y, z;
694   Bool_t success
695     = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
696   
697   if (!success) return;  
698
699   cout << setw(6) << "counter " << counter++ << "   ";
700   cout << "Pad indices:  ( " << detElemId << "; " << ix << ", " << iy << " )  " ;
701   cout << "Pad position: ( " << x << ", " << y << ", " << z << " )" << endl;
702
703    
704 //______________________________________________________________________________
705 void AliMUONTest::DrawPad(Int_t& counter,
706                           Int_t detElemId, Int_t ix, Int_t iy,
707                           AliMUONGeometrySegmentation* segmentation)
708 {
709 // Prints global pad positions for the given pad
710   
711   Float_t x, y, z;
712   Bool_t success
713     = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
714
715   if (!success) return;  
716   
717   // PrintPad(counter,detElemId, ix, iy, segmentation); 
718
719   counter++;
720   
721   Int_t sector = segmentation->Sector(detElemId, ix, iy);
722   Float_t dpx = segmentation->Dpx(detElemId, sector);
723   Float_t dpy = segmentation->Dpy(detElemId, sector);
724
725   //printf(" ***** Pad position is ix: %d iy: %d x: %f y: %f sector: %d dpx: %f dpy: %f \n",
726   //       ix, iy, x, y, sector, dpx, dpy);
727
728   fCanvas->cd();
729   TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1);
730   pave->Draw();
731
732    
733 //______________________________________________________________________________
734 void AliMUONTest::DrawSegmentation(Int_t chamber, AliMUONGeometrySegmentation *seg)
735 {
736 // TBR
737
738   // Drawing slat504
739   Int_t ix, iy, deId;
740   Float_t x, y, z;
741   Float_t dpx, dpy;
742 //   TH2F * frame = new TH2F(" "," ",10,-10.,245.,10, -5., 45.);
743   TH2F * frame = new TH2F(" "," ",10,-300.,300.,10, -300., 300.);
744 //   TH2F * frame = new TH2F(" "," ",10,-300.,300.,10, -25., 25.);
745   frame->Draw();
746 //   (new TPave(  0.,  0., 40., 40.,2))->Draw();
747 //   (new TPave( 40.,  0., 80., 40.,2))->Draw();
748 //   (new TPave( 80.,  0.,120., 40.,2))->Draw();
749 //   (new TPave(120.,  0.,160., 40.,2))->Draw();
750 //   (new TPave(160.,  0.,200., 40.,2))->Draw();
751 //   (new TPave(200.,  0.,240., 40.,2))->Draw();
752   
753   for (Int_t iDE = 0; iDE < 13; iDE++) {
754     
755     for (Int_t side = 0; side < 2; side++) {
756       if (side == 0)
757         deId = (chamber+1)*100+iDE;
758       else 
759         deId = (chamber+1)*100+50+iDE;
760         
761       
762       //   for ( seg->FirstPad(detElementId,  0., 0., 0., 100., 100.);
763       //        seg->MorePads(detElementId); 
764       //        seg->NextPad(detElementId) ) {
765       for(ix=1; ix<=seg->Npx(deId); ix++) {
766         for(iy=1; iy<=seg->Npy(deId); iy++) {
767         
768           seg->GetPadC(deId, ix, iy, x, y, z);
769           Int_t sector = seg->Sector(deId, ix, iy);
770           dpx = seg->Dpx(deId,sector);
771           dpy = seg->Dpy(deId,sector);
772
773                  //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);
774           (new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1))->Draw();
775         }
776       }
777     }
778   }
779 }
780