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