1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
20 // Class with functions for testing
22 // Author: Ivana Hrivnacova, IPN Orsay
24 #include <TStopwatch.h>
25 #include <Riostream.h>
29 #include <TGeoMatrix.h>
34 #include "AliMUONTest.h"
36 #include "AliMUONConstants.h"
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"
46 #include "AliMUONGeometryModule.h"
47 #include "AliMUONGeometryStore.h"
48 #include "AliMUONGeometryTransformer.h"
49 #include "AliMUONSegmentation.h"
50 #include "AliMUONGeometrySegmentation.h"
54 //_____________________________________________________________________________
55 AliMUONTest::AliMUONTest(const TString& option)
61 // Standard Constructor
64 if ( option != "default" &&
65 option != "FactoryV2" && option != "FactoryV3" && option != "FactoryV4")
67 BuildWithMUON(option);
70 BuildWithoutMUON(option);
73 //_____________________________________________________________________________
74 AliMUONTest::AliMUONTest()
80 // Default Constructor
84 //_____________________________________________________________________________
85 AliMUONTest::AliMUONTest(const AliMUONTest& rhs)
88 // Protected copy constructor
90 AliFatal("Not implemented.");
93 //_____________________________________________________________________________
94 AliMUONTest::~AliMUONTest()
101 //_____________________________________________________________________________
102 AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs)
104 // Protected assignement operator
106 if (this == &rhs) return *this;
108 AliFatal("Not implemented.");
116 //_____________________________________________________________________________
117 void AliMUONTest::BuildWithMUON(const TString& configMacro)
119 // Build segmentation via AliMUON initialisation
121 gAlice->Init(configMacro.Data());
122 AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
124 AliFatal("MUON detector not defined.");
127 fkTransformer = muon->GetGeometryTransformer();
128 fSegmentation = muon->GetSegmentation();
131 //_____________________________________________________________________________
132 void AliMUONTest::BuildWithoutMUON(const TString& option)
134 // Fill geometry from transform*.dat files and build segmentation via
137 AliMUONGeometryTransformer* transformer
138 = new AliMUONGeometryTransformer(true);
139 transformer->ReadTransformations("transform.dat");
140 fkTransformer = transformer;
142 // Build segmentation
143 if ( option == "default" || option == "FactoryV2") {
144 AliMUONSegFactoryV2 segFactory("default");
145 segFactory.Build(fkTransformer);
146 fSegmentation = segFactory.GetSegmentation();
148 else if ( option == "FactoryV3" ) {
149 AliMUONSegFactoryV3 segFactory("default");
150 segFactory.Build(fkTransformer);
151 fSegmentation = segFactory.GetSegmentation();
153 else if ( option == "FactoryV4" ) {
154 AliMUONSegFactoryV4 segFactory("default");
155 segFactory.Build(fkTransformer);
156 fSegmentation = segFactory.GetSegmentation();
159 AliFatal(Form("Wrong factory type : %s",option.Data()));
168 //_____________________________________________________________________________
169 AliMUONGeometrySegmentation*
170 AliMUONTest::GetSegmentation(Int_t chamberId, Int_t cath)
172 // Create geometry segmentation for the specified chamber and cathod
174 return fSegmentation->GetModuleSegmentation(chamberId, cath);
177 #include "AliMUONGeometryDetElement.h"
178 //_____________________________________________________________________________
179 void AliMUONTest::DetElemTransforms()
182 // Loop over chambers
183 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
185 const AliMUONGeometryModuleTransformer* kModuleTransformer
186 = fkTransformer->GetModuleTransformer(i);
188 AliMUONGeometryStore* detElements
189 = kModuleTransformer->GetDetElementStore();
191 // Loop over detection elements
192 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
194 //Int_t detElemId = kModuleTransformer->GetDetElemId(j);
195 Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();
196 cout << "Detection element Id: " << detElemId << endl;
199 kModuleTransformer->Local2Global(detElemId, 0., 0., 0., x, y, z);
200 cout << " Global DE position: "
201 << x << ", " << y << ", " << z << endl;
204 kModuleTransformer->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
205 cout << " ALIC center in the local frame: "
206 << x2 << ", " << y2 << ", " << z2 << endl;
209 kModuleTransformer->Global2Local(detElemId, x, y, z, x3, y3, z3);
210 cout << " Back in the local frame: "
211 << x3 << ", " << y3 << ", " << z3 << endl;
214 AliMUONGeometryDetElement* detElem =
215 (AliMUONGeometryDetElement*)detElements->GetEntry(j);
216 detElem->PrintGlobalTransform();
221 //_____________________________________________________________________________
222 void AliMUONTest::ForWhole(AliMUONTests testCase)
224 // Perform test for all chambers and first cathod
229 // Loop over chambers
230 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
233 //for (Int_t cath=0; cath<2; cath++) {
234 for (Int_t cath=0; cath<1; cath++) {
236 AliMUONGeometrySegmentation* segmentation
237 = GetSegmentation(iChamber, cath);
239 if (!segmentation) continue;
241 cout << setw(6) << "Pads in chamber " << iChamber
242 << " cathod " << cath << endl;
243 cout << "===================================" << endl;
245 ForSegmentation(testCase, segmentation);
252 //_____________________________________________________________________________
253 void AliMUONTest::ForSegmentation(AliMUONTests testCase,
254 AliMUONGeometrySegmentation *segmentation)
256 // Perform test for a given segmentation
263 // Loop over detection elements
265 AliMUONGeometryStore* detElements
266 = segmentation->GetTransformer()->GetDetElementStore();
268 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
270 Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();
271 cout << "Detection element id: " << detElemId << endl;
273 ForDetElement(testCase, detElemId, segmentation);
282 //_____________________________________________________________________________
283 void AliMUONTest::ForDetElement(AliMUONTests testCase,
285 AliMUONGeometrySegmentation *segmentation)
287 // Prints global pad positions for given detection element
288 // in a given geometry segmentation
293 // Loop over pads in a detection element
296 for(Int_t ix=1; ix<=segmentation->Npx(detElemId); ix++)
297 for(Int_t iy=1; iy<=segmentation->Npy(detElemId); iy++)
302 PrintPad(counter, detElemId, ix, iy, segmentation);
306 DrawPad(counter, detElemId, ix, iy, segmentation);
312 //_____________________________________________________________________________
313 void AliMUONTest::Before(AliMUONTests testCase)
315 // Do some initialization if necessary
324 fCanvas = new TCanvas("c1","c1", 0, 0, 600, 600);
325 fCanvas->Range(-300,-300, 300, 300);
332 //_____________________________________________________________________________
333 void AliMUONTest::After(AliMUONTests testCase)
335 // Do some cleanup if necessary
344 cout << "Print any key + enter to continue ..." << endl;
352 //_____________________________________________________________________________
353 void AliMUONTest::PrintPad(Int_t& counter,
354 Int_t detElemId, Int_t ix, Int_t iy,
355 AliMUONGeometrySegmentation* segmentation)
357 // Prints global pad positions for the given pad
361 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
363 cout << setw(6) << "counter " << counter++ << " ";
364 cout << "Pad indices: ( " << detElemId << "; " << ix << ", " << iy << " ) " ;
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;
375 cout << "... no pad " << endl;
379 //_____________________________________________________________________________
380 void AliMUONTest::DrawPad(Int_t& counter,
381 Int_t detElemId, Int_t ix, Int_t iy,
382 AliMUONGeometrySegmentation* segmentation)
384 // Prints global pad positions for the given pad
388 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
390 if (!success) return;
392 // PrintPad(counter,detElemId, ix, iy, segmentation);
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);
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);
403 if (!fCanvas) Before(kDrawPads);
406 TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1);
410 //_____________________________________________________________________________
411 void AliMUONTest::DrawSegmentation(AliMUONGeometrySegmentation *seg)
419 // TH2F * frame = new TH2F(" "," ",10,-10.,245.,10, -5., 45.);
420 // TH2F * frame = new TH2F(" "," ",10,-300.,300.,10, -300., 300.);
421 TH2F * frame = new TH2F(" "," ",10,-350.,350.,10, -350., 350.);
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();
430 // Loop over detection elements
432 AliMUONGeometryStore* detElements
433 = seg->GetTransformer()->GetDetElementStore();
435 for (Int_t iDE=0; iDE<detElements->GetNofEntries(); iDE++) {
437 deId = detElements->GetEntry(iDE)->GetUniqueID();
439 cout << "Detection element id: " << deId << endl;
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++) {
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);
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();