]>
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 | // | |
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> | |
24def874 | 26 | #include <TH2F.h> |
27 | #include <TPave.h> | |
152d6f4e | 28 | #include <TCanvas.h> |
8b7981ce | 29 | #include <TGeoMatrix.h> |
e118b27e | 30 | |
31 | #include "AliRun.h" | |
e118b27e | 32 | #include "AliLog.h" |
33 | ||
34 | #include "AliMUONTest.h" | |
35 | #include "AliMUON.h" | |
36 | #include "AliMUONConstants.h" | |
8b7981ce | 37 | #include "AliMUONGeometryBuilder.h" |
38 | #include "AliMUONSt1GeometryBuilderV2.h" | |
39 | #include "AliMUONSt2GeometryBuilderV2.h" | |
40 | #include "AliMUONSlatGeometryBuilder.h" | |
41 | #include "AliMUONTriggerGeometryBuilder.h" | |
42 | #include "AliMUONSegFactoryV2.h" | |
43 | #include "AliMUONSegFactoryV3.h" | |
44 | #include "AliMUONSegFactoryV4.h" | |
45 | #include "AliMUONGeometryTransformer.h" | |
e118b27e | 46 | #include "AliMUONGeometryModule.h" |
47 | #include "AliMUONGeometryStore.h" | |
8b7981ce | 48 | #include "AliMUONGeometryTransformer.h" |
49 | #include "AliMUONSegmentation.h" | |
e118b27e | 50 | #include "AliMUONGeometrySegmentation.h" |
e118b27e | 51 | |
52 | ClassImp(AliMUONTest) | |
53 | ||
8b7981ce | 54 | //_____________________________________________________________________________ |
55 | AliMUONTest::AliMUONTest(const TString& option) | |
152d6f4e | 56 | : TObject(), |
8b7981ce | 57 | fkTransformer(0), |
58 | fSegmentation(0), | |
152d6f4e | 59 | fCanvas(0) |
e118b27e | 60 | { |
61 | // Standard Constructor | |
62 | // | |
8b7981ce | 63 | |
64 | if ( option != "default" && | |
65 | option != "FactoryV2" && option != "FactoryV3" && option != "FactoryV4") | |
66 | { | |
67 | BuildWithMUON(option); | |
68 | } | |
69 | else | |
70 | BuildWithoutMUON(option); | |
e118b27e | 71 | } |
72 | ||
8b7981ce | 73 | //_____________________________________________________________________________ |
e118b27e | 74 | AliMUONTest::AliMUONTest() |
152d6f4e | 75 | : TObject(), |
8b7981ce | 76 | fkTransformer(0), |
77 | fSegmentation(0), | |
152d6f4e | 78 | fCanvas(0) |
e118b27e | 79 | { |
80 | // Default Constructor | |
81 | // | |
82 | } | |
83 | ||
8b7981ce | 84 | //_____________________________________________________________________________ |
e118b27e | 85 | AliMUONTest::AliMUONTest(const AliMUONTest& rhs) |
86 | : TObject(rhs) | |
87 | { | |
88 | // Protected copy constructor | |
89 | ||
90 | AliFatal("Not implemented."); | |
91 | } | |
92 | ||
8b7981ce | 93 | //_____________________________________________________________________________ |
e118b27e | 94 | AliMUONTest::~AliMUONTest() |
95 | { | |
96 | // Destructor | |
152d6f4e | 97 | |
98 | delete fCanvas; | |
e118b27e | 99 | } |
100 | ||
8b7981ce | 101 | //_____________________________________________________________________________ |
e118b27e | 102 | AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs) |
103 | { | |
104 | // Protected assignement operator | |
105 | ||
106 | if (this == &rhs) return *this; | |
107 | ||
108 | AliFatal("Not implemented."); | |
109 | ||
110 | return *this; | |
111 | } | |
112 | ||
113 | // | |
152d6f4e | 114 | // private methods |
e118b27e | 115 | // |
24def874 | 116 | //_____________________________________________________________________________ |
8b7981ce | 117 | void AliMUONTest::BuildWithMUON(const TString& configMacro) |
24def874 | 118 | { |
8b7981ce | 119 | // Build segmentation via AliMUON initialisation |
24def874 | 120 | |
8b7981ce | 121 | gAlice->Init(configMacro.Data()); |
24def874 | 122 | AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON"); |
123 | if (!muon) { | |
124 | AliFatal("MUON detector not defined."); | |
8b7981ce | 125 | return; |
24def874 | 126 | } |
8b7981ce | 127 | fkTransformer = muon->GetGeometryTransformer(); |
128 | fSegmentation = muon->GetSegmentation(); | |
129 | } | |
24def874 | 130 | |
58d53b65 | 131 | //_____________________________________________________________________________ |
8b7981ce | 132 | void AliMUONTest::BuildWithoutMUON(const TString& option) |
58d53b65 | 133 | { |
8b7981ce | 134 | // Fill geometry from transform*.dat files and build segmentation via |
135 | // SegFactory | |
58d53b65 | 136 | |
8b7981ce | 137 | AliMUONGeometryTransformer* transformer |
138 | = new AliMUONGeometryTransformer(true); | |
139 | transformer->ReadTransformations("transform.dat"); | |
140 | fkTransformer = transformer; | |
141 | ||
142 | // Build segmentation | |
143 | if ( option == "default" || option == "FactoryV2") { | |
144 | AliMUONSegFactoryV2 segFactory("default"); | |
145 | segFactory.Build(fkTransformer); | |
146 | fSegmentation = segFactory.GetSegmentation(); | |
147 | } | |
148 | else if ( option == "FactoryV3" ) { | |
149 | AliMUONSegFactoryV3 segFactory("default"); | |
150 | segFactory.Build(fkTransformer); | |
151 | fSegmentation = segFactory.GetSegmentation(); | |
58d53b65 | 152 | } |
8b7981ce | 153 | else if ( option == "FactoryV4" ) { |
154 | AliMUONSegFactoryV4 segFactory("default"); | |
155 | segFactory.Build(fkTransformer); | |
156 | fSegmentation = segFactory.GetSegmentation(); | |
58d53b65 | 157 | } |
8b7981ce | 158 | else { |
159 | AliFatal(Form("Wrong factory type : %s",option.Data())); | |
58d53b65 | 160 | } |
8b7981ce | 161 | } |
58d53b65 | 162 | |
58d53b65 | 163 | |
152d6f4e | 164 | // |
165 | // public methods | |
166 | // | |
167 | ||
8b7981ce | 168 | //_____________________________________________________________________________ |
152d6f4e | 169 | AliMUONGeometrySegmentation* |
8b7981ce | 170 | AliMUONTest::GetSegmentation(Int_t chamberId, Int_t cath) |
152d6f4e | 171 | { |
172 | // Create geometry segmentation for the specified chamber and cathod | |
173 | ||
8b7981ce | 174 | return fSegmentation->GetModuleSegmentation(chamberId, cath); |
152d6f4e | 175 | } |
8b7981ce | 176 | |
177 | #include "AliMUONGeometryDetElement.h" | |
178 | //_____________________________________________________________________________ | |
152d6f4e | 179 | void AliMUONTest::DetElemTransforms() |
180 | { | |
181 | // | |
152d6f4e | 182 | // Loop over chambers |
183 | for (Int_t i=0; i<AliMUONConstants::NCh(); i++) { | |
184 | ||
8b7981ce | 185 | const AliMUONGeometryModuleTransformer* kModuleTransformer |
186 | = fkTransformer->GetModuleTransformer(i); | |
187 | ||
188 | AliMUONGeometryStore* detElements | |
189 | = kModuleTransformer->GetDetElementStore(); | |
152d6f4e | 190 | |
191 | // Loop over detection elements | |
192 | for (Int_t j=0; j<detElements->GetNofEntries(); j++) { | |
193 | ||
8b7981ce | 194 | //Int_t detElemId = kModuleTransformer->GetDetElemId(j); |
152d6f4e | 195 | Int_t detElemId = detElements->GetEntry(j)->GetUniqueID(); |
196 | cout << "Detection element Id: " << detElemId << endl; | |
197 | ||
198 | Double_t x, y, z; | |
8b7981ce | 199 | kModuleTransformer->Local2Global(detElemId, 0., 0., 0., x, y, z); |
152d6f4e | 200 | cout << " Global DE position: " |
201 | << x << ", " << y << ", " << z << endl; | |
202 | ||
203 | Double_t x2, y2, z2; | |
8b7981ce | 204 | kModuleTransformer->Global2Local(detElemId, 0., 0., 0., x2, y2, z2); |
152d6f4e | 205 | cout << " ALIC center in the local frame: " |
206 | << x2 << ", " << y2 << ", " << z2 << endl; | |
207 | ||
208 | Double_t x3, y3, z3; | |
8b7981ce | 209 | kModuleTransformer->Global2Local(detElemId, x, y, z, x3, y3, z3); |
152d6f4e | 210 | cout << " Back in the local frame: " |
211 | << x3 << ", " << y3 << ", " << z3 << endl; | |
212 | cout << endl; | |
8b7981ce | 213 | |
214 | AliMUONGeometryDetElement* detElem = | |
215 | (AliMUONGeometryDetElement*)detElements->GetEntry(j); | |
216 | detElem->PrintGlobalTransform(); | |
152d6f4e | 217 | } |
24def874 | 218 | } |
152d6f4e | 219 | } |
220 | ||
8b7981ce | 221 | //_____________________________________________________________________________ |
152d6f4e | 222 | void AliMUONTest::ForWhole(AliMUONTests testCase) |
223 | { | |
224 | // Perform test for all chambers and first cathod | |
225 | ||
152d6f4e | 226 | TStopwatch timer; |
227 | timer.Start(); | |
228 | ||
229 | // Loop over chambers | |
580c28fd | 230 | for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) { |
152d6f4e | 231 | |
232 | // Loop over cathods | |
d640924e | 233 | //for (Int_t cath=0; cath<2; cath++) { |
234 | for (Int_t cath=0; cath<1; cath++) { | |
152d6f4e | 235 | |
236 | AliMUONGeometrySegmentation* segmentation | |
8b7981ce | 237 | = GetSegmentation(iChamber, cath); |
152d6f4e | 238 | |
239 | if (!segmentation) continue; | |
240 | ||
241 | cout << setw(6) << "Pads in chamber " << iChamber | |
242 | << " cathod " << cath << endl; | |
243 | cout << "===================================" << endl; | |
244 | ||
245 | ForSegmentation(testCase, segmentation); | |
152d6f4e | 246 | } |
247 | } | |
248 | timer.Stop(); | |
249 | timer.Print(); | |
250 | } | |
251 | ||
8b7981ce | 252 | //_____________________________________________________________________________ |
152d6f4e | 253 | void AliMUONTest::ForSegmentation(AliMUONTests testCase, |
254 | AliMUONGeometrySegmentation *segmentation) | |
255 | { | |
256 | // Perform test for a given segmentation | |
257 | ||
258 | TStopwatch timer; | |
259 | timer.Start(); | |
260 | ||
261 | Before(testCase); | |
262 | ||
263 | // Loop over detection elements | |
264 | // | |
265 | AliMUONGeometryStore* detElements | |
8b7981ce | 266 | = segmentation->GetTransformer()->GetDetElementStore(); |
152d6f4e | 267 | |
268 | for (Int_t j=0; j<detElements->GetNofEntries(); j++) { | |
269 | ||
270 | Int_t detElemId = detElements->GetEntry(j)->GetUniqueID(); | |
271 | cout << "Detection element id: " << detElemId << endl; | |
272 | ||
273 | ForDetElement(testCase, detElemId, segmentation); | |
274 | } | |
275 | ||
276 | After(testCase); | |
277 | ||
278 | timer.Stop(); | |
279 | timer.Print(); | |
24def874 | 280 | } |
152d6f4e | 281 | |
8b7981ce | 282 | //_____________________________________________________________________________ |
152d6f4e | 283 | void AliMUONTest::ForDetElement(AliMUONTests testCase, |
284 | Int_t detElemId, | |
285 | AliMUONGeometrySegmentation *segmentation) | |
286 | { | |
287 | // Prints global pad positions for given detection element | |
288 | // in a given geometry segmentation | |
289 | ||
290 | ||
291 | Int_t counter = 0; | |
292 | ||
293 | // Loop over pads in a detection element | |
294 | // | |
295 | ||
296 | for(Int_t ix=1; ix<=segmentation->Npx(detElemId); ix++) | |
297 | for(Int_t iy=1; iy<=segmentation->Npy(detElemId); iy++) | |
298 | { | |
299 | switch (testCase) { | |
300 | ||
301 | case kPrintPads: | |
302 | PrintPad(counter, detElemId, ix, iy, segmentation); | |
303 | break; | |
304 | ||
305 | case kDrawPads: | |
306 | DrawPad(counter, detElemId, ix, iy, segmentation); | |
307 | break; | |
308 | } | |
309 | } | |
310 | } | |
311 | ||
8b7981ce | 312 | //_____________________________________________________________________________ |
152d6f4e | 313 | void AliMUONTest::Before(AliMUONTests testCase) |
314 | { | |
315 | // Do some initialization if necessary | |
316 | ||
317 | switch (testCase) { | |
318 | ||
319 | case kPrintPads: | |
320 | break; | |
321 | ||
322 | case kDrawPads: | |
323 | if (!fCanvas) { | |
324 | fCanvas = new TCanvas("c1","c1", 0, 0, 600, 600); | |
325 | fCanvas->Range(-300,-300, 300, 300); | |
326 | fCanvas->cd(); | |
327 | } | |
328 | break; | |
329 | } | |
330 | } | |
331 | ||
8b7981ce | 332 | //_____________________________________________________________________________ |
152d6f4e | 333 | void AliMUONTest::After(AliMUONTests testCase) |
334 | { | |
335 | // Do some cleanup if necessary | |
336 | ||
337 | switch (testCase) { | |
338 | ||
339 | case kPrintPads: | |
340 | break; | |
341 | ||
342 | case kDrawPads: | |
343 | fCanvas->Update(); | |
344 | cout << "Print any key + enter to continue ..." << endl; | |
345 | char c; | |
346 | cin >> c; | |
347 | fCanvas->Clear(); | |
348 | break; | |
349 | } | |
350 | } | |
351 | ||
8b7981ce | 352 | //_____________________________________________________________________________ |
152d6f4e | 353 | void AliMUONTest::PrintPad(Int_t& counter, |
354 | Int_t detElemId, Int_t ix, Int_t iy, | |
355 | AliMUONGeometrySegmentation* segmentation) | |
356 | { | |
357 | // Prints global pad positions for the given pad | |
358 | ||
359 | Float_t x, y, z; | |
360 | Bool_t success | |
361 | = segmentation->GetPadC(detElemId, ix, iy, x, y, z); | |
362 | ||
152d6f4e | 363 | cout << setw(6) << "counter " << counter++ << " "; |
364 | cout << "Pad indices: ( " << detElemId << "; " << ix << ", " << iy << " ) " ; | |
580c28fd | 365 | |
366 | if (success) { | |
367 | cout << "Pad position: ( " << x << ", " << y << ", " << z << " ); "; | |
368 | Int_t sector = segmentation->Sector(detElemId, ix, iy); | |
369 | Float_t dpx = segmentation->Dpx(detElemId, sector); | |
370 | Float_t dpy = segmentation->Dpy(detElemId, sector); | |
371 | cout << " dimensions: ( " << dpx << ", " << dpy << " )" << endl; | |
372 | } | |
373 | else { | |
374 | counter--; | |
375 | cout << "... no pad " << endl; | |
376 | } | |
152d6f4e | 377 | } |
378 | ||
8b7981ce | 379 | //_____________________________________________________________________________ |
152d6f4e | 380 | void AliMUONTest::DrawPad(Int_t& counter, |
381 | Int_t detElemId, Int_t ix, Int_t iy, | |
382 | AliMUONGeometrySegmentation* segmentation) | |
383 | { | |
384 | // Prints global pad positions for the given pad | |
385 | ||
386 | Float_t x, y, z; | |
387 | Bool_t success | |
388 | = segmentation->GetPadC(detElemId, ix, iy, x, y, z); | |
389 | ||
390 | if (!success) return; | |
391 | ||
392 | // PrintPad(counter,detElemId, ix, iy, segmentation); | |
393 | ||
394 | counter++; | |
395 | ||
396 | Int_t sector = segmentation->Sector(detElemId, ix, iy); | |
397 | Float_t dpx = segmentation->Dpx(detElemId, sector); | |
398 | Float_t dpy = segmentation->Dpy(detElemId, sector); | |
399 | ||
400 | //printf(" ***** Pad position is ix: %d iy: %d x: %f y: %f sector: %d dpx: %f dpy: %f \n", | |
401 | // ix, iy, x, y, sector, dpx, dpy); | |
402 | ||
6b1e4b22 | 403 | if (!fCanvas) Before(kDrawPads); |
404 | ||
152d6f4e | 405 | fCanvas->cd(); |
406 | TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1); | |
407 | pave->Draw(); | |
408 | } | |
409 | ||
8b7981ce | 410 | //_____________________________________________________________________________ |
f48459ab | 411 | void AliMUONTest::DrawSegmentation(AliMUONGeometrySegmentation *seg) |
152d6f4e | 412 | { |
413 | // TBR | |
414 | ||
415 | // Drawing slat504 | |
416 | Int_t ix, iy, deId; | |
417 | Float_t x, y, z; | |
418 | Float_t dpx, dpy; | |
419 | // TH2F * frame = new TH2F(" "," ",10,-10.,245.,10, -5., 45.); | |
f48459ab | 420 | // TH2F * frame = new TH2F(" "," ",10,-300.,300.,10, -300., 300.); |
65bcb249 | 421 | TH2F * frame = new TH2F(" "," ",10,-350.,350.,10, -350., 350.); |
152d6f4e | 422 | frame->Draw(); |
423 | // (new TPave( 0., 0., 40., 40.,2))->Draw(); | |
424 | // (new TPave( 40., 0., 80., 40.,2))->Draw(); | |
425 | // (new TPave( 80., 0.,120., 40.,2))->Draw(); | |
426 | // (new TPave(120., 0.,160., 40.,2))->Draw(); | |
427 | // (new TPave(160., 0.,200., 40.,2))->Draw(); | |
428 | // (new TPave(200., 0.,240., 40.,2))->Draw(); | |
429 | ||
f48459ab | 430 | // Loop over detection elements |
431 | // | |
432 | AliMUONGeometryStore* detElements | |
8b7981ce | 433 | = seg->GetTransformer()->GetDetElementStore(); |
f48459ab | 434 | |
435 | for (Int_t iDE=0; iDE<detElements->GetNofEntries(); iDE++) { | |
152d6f4e | 436 | |
f48459ab | 437 | deId = detElements->GetEntry(iDE)->GetUniqueID(); |
65bcb249 | 438 | |
f48459ab | 439 | cout << "Detection element id: " << deId << endl; |
440 | ||
441 | ||
442 | // for ( seg->FirstPad(detElementId, 0., 0., 0., 100., 100.); | |
443 | // seg->MorePads(detElementId); | |
444 | // seg->NextPad(detElementId) ) { | |
445 | for(ix=1; ix<=seg->Npx(deId); ix++) { | |
446 | for(iy=1; iy<=seg->Npy(deId); iy++) { | |
152d6f4e | 447 | |
f48459ab | 448 | seg->GetPadC(deId, ix, iy, x, y, z); |
449 | Int_t sector = seg->Sector(deId, ix, iy); | |
450 | dpx = seg->Dpx(deId,sector); | |
451 | dpy = seg->Dpy(deId,sector); | |
152d6f4e | 452 | |
f48459ab | 453 | //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); |
454 | (new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1))->Draw(); | |
152d6f4e | 455 | } |
f48459ab | 456 | |
152d6f4e | 457 | } |
458 | } | |
459 | } | |
460 | ||
58d53b65 | 461 | |
462 |