]>
Commit | Line | Data |
---|---|---|
e118b27e | 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 | // | |
f7006443 | 18 | // ----------------- |
e118b27e | 19 | // Class AliMUONTest |
20 | // ----------------- | |
f7006443 | 21 | // Class with functions for testing segmentations |
e118b27e | 22 | // Author: Ivana Hrivnacova, IPN Orsay |
23 | ||
e118b27e | 24 | #include "AliMUONTest.h" |
25 | #include "AliMUON.h" | |
26 | #include "AliMUONConstants.h" | |
40afd6cd | 27 | #include "AliMUONSegFactory.h" |
8b7981ce | 28 | #include "AliMUONGeometryTransformer.h" |
19e9826b | 29 | #include "AliMUONGeometryModuleTransformer.h" |
30 | #include "AliMUONGeometryDetElement.h" | |
8b7981ce | 31 | #include "AliMUONSegmentation.h" |
e118b27e | 32 | #include "AliMUONGeometrySegmentation.h" |
e118b27e | 33 | |
19e9826b | 34 | #include "AliMpDEIterator.h" |
35 | #include "AliMpDEManager.h" | |
36 | #include "AliMpVSegmentation.h" | |
37 | #include "AliMpPad.h" | |
38 | ||
a3953bc5 | 39 | #include "AliRun.h" |
40 | #include "AliLog.h" | |
41 | ||
42 | #include <TStopwatch.h> | |
43 | #include <Riostream.h> | |
44 | #include <TH2F.h> | |
45 | #include <TPave.h> | |
46 | #include <TCanvas.h> | |
47 | #include <TGeoMatrix.h> | |
48 | ||
e118b27e | 49 | ClassImp(AliMUONTest) |
50 | ||
8b7981ce | 51 | //_____________________________________________________________________________ |
52 | AliMUONTest::AliMUONTest(const TString& option) | |
152d6f4e | 53 | : TObject(), |
8b7981ce | 54 | fkTransformer(0), |
55 | fSegmentation(0), | |
152d6f4e | 56 | fCanvas(0) |
e118b27e | 57 | { |
19e9826b | 58 | /// Standard Constructor |
8b7981ce | 59 | |
60 | if ( option != "default" && | |
40afd6cd | 61 | option != "FactoryV2" && |
62 | option != "FactoryV3" && | |
63 | option != "FactoryV4" && | |
64 | option != "new" ) | |
8b7981ce | 65 | { |
66 | BuildWithMUON(option); | |
67 | } | |
68 | else | |
69 | BuildWithoutMUON(option); | |
19e9826b | 70 | |
71 | // Create canvas | |
72 | fCanvas = new TCanvas("c1","c1", 0, 0, 800, 800); | |
73 | fCanvas->Range(-400,-400, 400, 400); | |
74 | fCanvas->cd(); | |
e118b27e | 75 | } |
76 | ||
8b7981ce | 77 | //_____________________________________________________________________________ |
e118b27e | 78 | AliMUONTest::AliMUONTest() |
152d6f4e | 79 | : TObject(), |
8b7981ce | 80 | fkTransformer(0), |
81 | fSegmentation(0), | |
152d6f4e | 82 | fCanvas(0) |
e118b27e | 83 | { |
19e9826b | 84 | /// Default Constructor |
e118b27e | 85 | } |
86 | ||
8b7981ce | 87 | //_____________________________________________________________________________ |
e118b27e | 88 | AliMUONTest::~AliMUONTest() |
89 | { | |
19e9826b | 90 | /// Destructor |
152d6f4e | 91 | |
92 | delete fCanvas; | |
e118b27e | 93 | } |
94 | ||
e118b27e | 95 | // |
152d6f4e | 96 | // private methods |
e118b27e | 97 | // |
24def874 | 98 | //_____________________________________________________________________________ |
8b7981ce | 99 | void AliMUONTest::BuildWithMUON(const TString& configMacro) |
24def874 | 100 | { |
19e9826b | 101 | /// Build segmentation via AliMUON initialisation |
24def874 | 102 | |
8b7981ce | 103 | gAlice->Init(configMacro.Data()); |
24def874 | 104 | AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON"); |
105 | if (!muon) { | |
106 | AliFatal("MUON detector not defined."); | |
8b7981ce | 107 | return; |
24def874 | 108 | } |
8b7981ce | 109 | fkTransformer = muon->GetGeometryTransformer(); |
110 | fSegmentation = muon->GetSegmentation(); | |
111 | } | |
24def874 | 112 | |
58d53b65 | 113 | //_____________________________________________________________________________ |
8b7981ce | 114 | void AliMUONTest::BuildWithoutMUON(const TString& option) |
58d53b65 | 115 | { |
19e9826b | 116 | /// Fill geometry from transform*.dat files and build segmentation via |
117 | /// SegFactory | |
58d53b65 | 118 | |
a3953bc5 | 119 | AliMUONSegFactory segFactory("volpaths.dat", "transform.dat"); |
40afd6cd | 120 | fSegmentation = segFactory.CreateSegmentation(option); |
8b7981ce | 121 | } |
58d53b65 | 122 | |
58d53b65 | 123 | |
152d6f4e | 124 | // |
125 | // public methods | |
126 | // | |
127 | ||
8b7981ce | 128 | //_____________________________________________________________________________ |
19e9826b | 129 | void AliMUONTest::PrintPadsForAll() const |
152d6f4e | 130 | { |
19e9826b | 131 | /// Print pads for all chambers and first cathod |
152d6f4e | 132 | |
152d6f4e | 133 | TStopwatch timer; |
134 | timer.Start(); | |
135 | ||
136 | // Loop over chambers | |
580c28fd | 137 | for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) { |
152d6f4e | 138 | |
139 | // Loop over cathods | |
d640924e | 140 | //for (Int_t cath=0; cath<2; cath++) { |
141 | for (Int_t cath=0; cath<1; cath++) { | |
152d6f4e | 142 | |
152d6f4e | 143 | cout << setw(6) << "Pads in chamber " << iChamber |
144 | << " cathod " << cath << endl; | |
145 | cout << "===================================" << endl; | |
146 | ||
19e9826b | 147 | PrintPadsForSegmentation(iChamber, cath); |
152d6f4e | 148 | } |
149 | } | |
150 | timer.Stop(); | |
151 | timer.Print(); | |
152 | } | |
153 | ||
8b7981ce | 154 | //_____________________________________________________________________________ |
19e9826b | 155 | void AliMUONTest::PrintPadsForSegmentation(Int_t moduleId, Int_t cath) const |
152d6f4e | 156 | { |
19e9826b | 157 | /// Print pads for the given segmentation |
152d6f4e | 158 | |
159 | TStopwatch timer; | |
160 | timer.Start(); | |
161 | ||
152d6f4e | 162 | // Loop over detection elements |
163 | // | |
19e9826b | 164 | AliMpDEIterator it; |
165 | for ( it.First(moduleId); ! it.IsDone(); it.Next()) { | |
152d6f4e | 166 | |
19e9826b | 167 | Int_t detElemId = it.CurrentDE(); |
152d6f4e | 168 | cout << "Detection element id: " << detElemId << endl; |
169 | ||
19e9826b | 170 | PrintPadsForDetElement(detElemId, cath); |
152d6f4e | 171 | } |
172 | ||
152d6f4e | 173 | timer.Stop(); |
174 | timer.Print(); | |
24def874 | 175 | } |
152d6f4e | 176 | |
8b7981ce | 177 | //_____________________________________________________________________________ |
19e9826b | 178 | void AliMUONTest::PrintPadsForDetElement(Int_t detElemId, Int_t cath) const |
152d6f4e | 179 | { |
19e9826b | 180 | /// Print global pad positions for the given detection element |
152d6f4e | 181 | |
182 | ||
19e9826b | 183 | // Get geometry segmentation |
184 | // | |
185 | AliMUONGeometrySegmentation* segmentation | |
186 | = fSegmentation->GetModuleSegmentationByDEId(detElemId, cath); | |
187 | if (!segmentation) { | |
188 | AliErrorStream() | |
189 | << "Segmentation for detElemId = " << detElemId << ", cath = " << cath | |
190 | << " not defined." << endl; | |
191 | return; | |
192 | } | |
193 | ||
152d6f4e | 194 | Int_t counter = 0; |
195 | ||
196 | // Loop over pads in a detection element | |
197 | // | |
19e9826b | 198 | for(Int_t ix=0; ix<=segmentation->Npx(detElemId); ix++) |
199 | for(Int_t iy=0; iy<=segmentation->Npy(detElemId); iy++) | |
200 | PrintPad(counter, detElemId, ix, iy, segmentation); | |
152d6f4e | 201 | } |
202 | ||
8b7981ce | 203 | //_____________________________________________________________________________ |
152d6f4e | 204 | void AliMUONTest::PrintPad(Int_t& counter, |
205 | Int_t detElemId, Int_t ix, Int_t iy, | |
19e9826b | 206 | AliMUONGeometrySegmentation* segmentation) const |
152d6f4e | 207 | { |
19e9826b | 208 | /// Print global pad position for the given pad |
152d6f4e | 209 | |
210 | Float_t x, y, z; | |
211 | Bool_t success | |
212 | = segmentation->GetPadC(detElemId, ix, iy, x, y, z); | |
213 | ||
152d6f4e | 214 | cout << setw(6) << "counter " << counter++ << " "; |
215 | cout << "Pad indices: ( " << detElemId << "; " << ix << ", " << iy << " ) " ; | |
580c28fd | 216 | |
217 | if (success) { | |
218 | cout << "Pad position: ( " << x << ", " << y << ", " << z << " ); "; | |
219 | Int_t sector = segmentation->Sector(detElemId, ix, iy); | |
220 | Float_t dpx = segmentation->Dpx(detElemId, sector); | |
221 | Float_t dpy = segmentation->Dpy(detElemId, sector); | |
222 | cout << " dimensions: ( " << dpx << ", " << dpy << " )" << endl; | |
223 | } | |
224 | else { | |
225 | counter--; | |
226 | cout << "... no pad " << endl; | |
227 | } | |
152d6f4e | 228 | } |
229 | ||
19e9826b | 230 | //_____________________________________________________________________________ |
231 | void AliMUONTest::DrawPadsForAll() const | |
232 | { | |
233 | /// Draw pad for all chambers and first cathod | |
234 | ||
235 | TStopwatch timer; | |
236 | timer.Start(); | |
237 | ||
238 | // Loop over chambers | |
239 | for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) { | |
240 | ||
241 | // Loop over cathods | |
242 | //for (Int_t cath=0; cath<2; cath++) { | |
243 | for (Int_t cath=0; cath<1; cath++) { | |
244 | ||
245 | cout << setw(6) << "Pads in chamber " << iChamber | |
246 | << " cathod " << cath << endl; | |
247 | cout << "===================================" << endl; | |
248 | ||
249 | DrawPadsForSegmentation(iChamber, cath); | |
250 | } | |
251 | } | |
252 | timer.Stop(); | |
253 | timer.Print(); | |
254 | } | |
255 | ||
256 | //_____________________________________________________________________________ | |
257 | void AliMUONTest::DrawPadsForSegmentation(Int_t moduleId, Int_t cath) const | |
258 | { | |
259 | /// Draw pads for the given segmentation | |
260 | ||
261 | TStopwatch timer; | |
262 | timer.Start(); | |
263 | ||
264 | // Loop over detection elements | |
265 | // | |
266 | AliMpDEIterator it; | |
267 | for ( it.First(moduleId); ! it.IsDone(); it.Next()) { | |
268 | ||
269 | Int_t detElemId = it.CurrentDE(); | |
270 | cout << "Detection element id: " << detElemId << endl; | |
271 | ||
272 | DrawPadsForDetElement(detElemId, cath); | |
273 | } | |
274 | ||
275 | fCanvas->Update(); | |
276 | cout << "Print any key + enter to continue ..." << endl; | |
277 | char c; | |
278 | cin >> c; | |
279 | fCanvas->Clear(); | |
280 | ||
281 | timer.Stop(); | |
282 | timer.Print(); | |
283 | } | |
284 | ||
285 | //_____________________________________________________________________________ | |
286 | void AliMUONTest::DrawPadsForDetElement(Int_t detElemId, Int_t cath) const | |
287 | { | |
288 | /// Draw pads for the given detection element | |
289 | ||
290 | // Get geometry segmentation | |
291 | // | |
292 | AliMUONGeometrySegmentation* segmentation | |
293 | = fSegmentation->GetModuleSegmentationByDEId(detElemId, cath); | |
294 | if (!segmentation) { | |
295 | AliErrorStream() | |
296 | << "Segmentation for detElemId = " << detElemId << ", cath = " << cath | |
297 | << " not defined." << endl; | |
298 | return; | |
299 | } | |
300 | ||
301 | Int_t counter = 0; | |
302 | ||
303 | // Loop over pads in a detection element | |
304 | // | |
305 | for(Int_t ix=0; ix<=segmentation->Npx(detElemId); ix++) | |
306 | for(Int_t iy=0; iy<=segmentation->Npy(detElemId); iy++) | |
307 | DrawPad(counter, detElemId, ix, iy, segmentation); | |
308 | } | |
309 | ||
8b7981ce | 310 | //_____________________________________________________________________________ |
152d6f4e | 311 | void AliMUONTest::DrawPad(Int_t& counter, |
312 | Int_t detElemId, Int_t ix, Int_t iy, | |
19e9826b | 313 | AliMUONGeometrySegmentation* segmentation) const |
152d6f4e | 314 | { |
19e9826b | 315 | /// Draw the given pad |
152d6f4e | 316 | |
317 | Float_t x, y, z; | |
318 | Bool_t success | |
319 | = segmentation->GetPadC(detElemId, ix, iy, x, y, z); | |
320 | ||
321 | if (!success) return; | |
322 | ||
323 | // PrintPad(counter,detElemId, ix, iy, segmentation); | |
324 | ||
325 | counter++; | |
326 | ||
327 | Int_t sector = segmentation->Sector(detElemId, ix, iy); | |
328 | Float_t dpx = segmentation->Dpx(detElemId, sector); | |
329 | Float_t dpy = segmentation->Dpy(detElemId, sector); | |
330 | ||
331 | //printf(" ***** Pad position is ix: %d iy: %d x: %f y: %f sector: %d dpx: %f dpy: %f \n", | |
332 | // ix, iy, x, y, sector, dpx, dpy); | |
333 | ||
334 | fCanvas->cd(); | |
335 | TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1); | |
336 | pave->Draw(); | |
337 | } | |
19e9826b | 338 | |
8b7981ce | 339 | //_____________________________________________________________________________ |
19e9826b | 340 | void AliMUONTest::DetElemTransforms() const |
152d6f4e | 341 | { |
19e9826b | 342 | /// Print detection elements transformations |
152d6f4e | 343 | |
19e9826b | 344 | // Loop over chambers |
345 | for (Int_t i=0; i<AliMUONConstants::NCh(); i++) { | |
346 | ||
347 | const AliMUONGeometryModuleTransformer* kModuleTransformer | |
348 | = fkTransformer->GetModuleTransformer(i); | |
f48459ab | 349 | |
19e9826b | 350 | // Loop over detection elements |
351 | AliMpDEIterator it; | |
352 | for ( it.First(i); ! it.IsDone(); it.Next()) { | |
353 | ||
354 | Int_t detElemId = it.CurrentDE(); | |
355 | cout << "Detection element id: " << detElemId << endl; | |
356 | ||
357 | Double_t x, y, z; | |
358 | kModuleTransformer->Local2Global(detElemId, 0., 0., 0., x, y, z); | |
359 | cout << " Global DE position: " | |
360 | << x << ", " << y << ", " << z << endl; | |
152d6f4e | 361 | |
19e9826b | 362 | Double_t x2, y2, z2; |
363 | kModuleTransformer->Global2Local(detElemId, 0., 0., 0., x2, y2, z2); | |
364 | cout << " ALIC center in the local frame: " | |
365 | << x2 << ", " << y2 << ", " << z2 << endl; | |
366 | ||
367 | Double_t x3, y3, z3; | |
368 | kModuleTransformer->Global2Local(detElemId, x, y, z, x3, y3, z3); | |
369 | cout << " Back in the local frame: " | |
370 | << x3 << ", " << y3 << ", " << z3 << endl; | |
371 | cout << endl; | |
58d53b65 | 372 | |
19e9826b | 373 | AliMUONGeometryDetElement* detElem = |
374 | kModuleTransformer->GetDetElement(detElemId); | |
375 | detElem->PrintGlobalTransform(); | |
376 | } | |
377 | } | |
378 | } | |
58d53b65 | 379 |