]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONTest.cxx
Geometry framework classes were made independent from the rest of MUON and linked...
[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
27 #include "AliRun.h"
28 #include "AliSegmentation.h"
29 #include "AliLog.h"
30
31 #include "AliMUONTest.h"
32 #include "AliMUON.h"
33 #include "AliMUONConstants.h"
34 #include "AliMUONGeometryModule.h"
35 #include "AliMUONGeometryStore.h"
36 #include "AliMUONGeometrySegmentation.h"
37 #include "AliMUONSt12QuadrantSegmentation.h"
38
39 ClassImp(AliMUONTest)
40
41 //__________________________________________________________________
42 AliMUONTest::AliMUONTest(const TString& configMacro)
43   : TObject()
44 {
45 // Standard Constructor
46 //
47   // Initialize AliRoot
48   gAlice->Init(configMacro.Data());
49 }
50
51 //__________________________________________________________________
52 AliMUONTest::AliMUONTest()
53   : TObject()
54 {
55 // Default Constructor
56 //
57 }
58
59 //____________________________________________________________________
60 AliMUONTest::AliMUONTest(const AliMUONTest& rhs)
61  : TObject(rhs)
62 {
63 // Protected copy constructor
64
65   AliFatal("Not implemented.");
66 }
67
68 //____________________________________________________________________
69 AliMUONTest::~AliMUONTest()
70 {
71 // Destructor
72 }
73
74 //________________________________________________________________________
75 AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs)
76 {
77 // Protected assignement operator
78
79   if (this == &rhs) return *this;
80
81   AliFatal("Not implemented.");
82     
83   return *this;  
84 }
85
86 //
87 // public methods
88 //
89
90 //______________________________________________________________________________
91 void  AliMUONTest::DetElemTransforms()
92 {
93 // 
94   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
95   if (!muon) {
96     AliFatal("MUON detector not defined.");
97     return;
98   }  
99   
100   // Loop over chambers
101   for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
102
103     AliMUONGeometryModule* geometry = muon->Chamber(i).GetGeometry();
104     AliMUONGeometryStore* detElements = geometry->GetDetElementStore();
105     
106     // Loop over detection elements
107     for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
108        
109       //Int_t detElemId = geometry->GetDetElemId(j);       
110       Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();       
111       cout << "Detection element Id: " << detElemId << endl;
112         
113       Double_t x, y, z;
114       geometry->Local2Global(detElemId, 0., 0., 0., x, y, z);
115       cout << "  Global DE position:            " 
116            <<  x << ",  " << y << ",  " << z << endl; 
117
118       Double_t x2, y2, z2;
119       geometry->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
120       cout << "  ALIC center in the local frame: " 
121            <<  x2 << ",  " << y2 << ",  " << z2 << endl; 
122              
123       Double_t x3, y3, z3;
124       geometry->Global2Local(detElemId, x, y, z, x3, y3, z3);
125       cout << "  Back in the local frame: " 
126            <<  x3 << ",  " << y3 << ",  " << z3 << endl;        
127       cout << endl;          
128     }
129   }
130 }        
131
132 //______________________________________________________________________________
133 void AliMUONTest::PrintPadPositions1()
134 {
135 // Build new segmentations (based on the  detection element local 
136 // segmentations), iterate over all segmentations and print global 
137 // pad positions
138
139   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
140   if (!muon) {
141     AliFatal("MUON detector not defined.");
142     return;
143   }  
144
145   // Loop over chambers
146   for (Int_t i=0; i<1; i++) {
147
148     // Create chamber segmentations
149     AliMUONGeometrySegmentation* seg[2];
150     seg[0] = new AliMUONGeometrySegmentation(muon->Chamber(i).GetGeometry());
151     seg[1] = new AliMUONGeometrySegmentation(muon->Chamber(i).GetGeometry());
152     
153     // Quadrant segmentations:
154     AliMUONSt12QuadrantSegmentation* bendSt1
155       = new AliMUONSt12QuadrantSegmentation(kStation1, kBendingPlane);
156     AliMUONSt12QuadrantSegmentation* nonbendSt1
157       = new AliMUONSt12QuadrantSegmentation(kStation1, kNonBendingPlane);
158
159     // The same configuration for both chambers of Station 1
160     Int_t id0 = (i+1)*100;
161
162     // Configure  St1 chamber segmentations
163     seg[0]->Add(id0,      bendSt1);
164     seg[0]->Add(id0 +  1, nonbendSt1);
165     seg[0]->Add(id0 + 50, nonbendSt1);
166     seg[0]->Add(id0 + 51, bendSt1);
167
168     seg[1]->Add(id0,      nonbendSt1);
169     seg[1]->Add(id0 +  1, bendSt1);
170     seg[1]->Add(id0 + 50, bendSt1);
171     seg[1]->Add(id0 + 51, nonbendSt1);
172
173     // Iterate over the whole plane and return pad indices and 
174     // global/local positions
175     cout << "Go to loop over pads" << endl;
176     for (Int_t cath=0; cath<2; cath++) {
177       
178       cout << setw(6) << "Pads in chamber " << i << " cathod " << cath << endl;
179       cout << "===================================" << endl;  
180       TStopwatch timer;
181       timer.Start();  
182
183       Int_t counter = 0;
184       for ( seg[cath]->FirstPad(100,  70., 70., 0., 80., 80.);
185             seg[cath]->MorePads(100); 
186             seg[cath]->NextPad(100) )
187       {
188         cout << setw(6) << "counter " << counter++ << "   ";
189   
190         Int_t ix = seg[cath]->Ix();
191         Int_t iy = seg[cath]->Iy();
192         Int_t deId = seg[cath]->DetElemId();
193         cout << "Pad indices:  ( " << deId << "; " << ix << ", " << iy << " )  " ;
194
195         Float_t x, y, z;
196         seg[cath]->GetPadC(deId, ix, iy, x, y, z);
197         cout << "Pad position: ( " << x << ", " << y << ", " << z << " )" << endl;
198       }
199       timer.Stop();
200       timer.Print();
201     }  
202   }  
203 }    
204
205 //________________________________________________________________________
206 void AliMUONTest::PrintPadPositions2()
207 {
208 // Iterate over all chamber segmentations and prints
209 // global pad positions
210
211   AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
212   if (!muon) {
213     AliFatal("MUON detector not defined.");
214     return;
215   }  
216
217   // Loop over chambers
218   for (Int_t i=0; i<1; i++) {
219
220     // Create chamber segmentations
221     AliSegmentation* seg[2];
222     seg[0] = muon->Chamber(i).SegmentationModel(0);
223     seg[1] = muon->Chamber(i).SegmentationModel(1);
224
225     // Iterate over the whole plane and return pad indices and 
226     // global/local positions
227     cout << "Go to loop over pads" << endl;
228     for (Int_t cath=0; cath<2; cath++) {
229       
230       cout << setw(6) << "Pads in chamber " << i << " cathod " << cath << endl;
231       cout << "===================================" << endl;  
232       TStopwatch timer;
233       timer.Start();  
234
235       Int_t counter = 0;
236       for ( seg[cath]->FirstPad(70., 70., 0., 80., 80.);
237             seg[cath]->MorePads(); 
238             seg[cath]->NextPad() )
239       {
240         cout << setw(6) << "counter " << counter++ << "   ";
241   
242         Int_t ix = seg[cath]->Ix();
243         Int_t iy = seg[cath]->Iy();
244         cout << "Pad indices:  ( " << ix << ", " << iy << " )  " ;
245
246         Float_t x, y, z;
247         seg[cath]->GetPadC(ix, iy, x, y, z);
248         cout << "Pad position: ( " << x << ", " << y << ", " << z << " )" << endl;
249       }
250       timer.Stop();
251       timer.Print();
252     }  
253   }  
254 }
255