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 **************************************************************************/
21 // Class with functions for testing segmentations
23 // Author: Ivana Hrivnacova, IPN Orsay
25 #include "AliMUONTest.h"
27 #include "AliMUONConstants.h"
28 #include "AliMUONGeometryBuilder.h"
29 #include "AliMUONSt1GeometryBuilderV2.h"
30 #include "AliMUONSt2GeometryBuilderV2.h"
31 #include "AliMUONSlatGeometryBuilder.h"
32 #include "AliMUONTriggerGeometryBuilder.h"
33 #include "AliMUONSegFactory.h"
34 #include "AliMUONGeometryTransformer.h"
35 #include "AliMUONGeometryModule.h"
36 #include "AliMUONGeometryStore.h"
37 #include "AliMUONGeometryTransformer.h"
38 #include "AliMUONSegmentation.h"
39 #include "AliMUONGeometrySegmentation.h"
44 #include <TStopwatch.h>
45 #include <Riostream.h>
49 #include <TGeoMatrix.h>
53 //_____________________________________________________________________________
54 AliMUONTest::AliMUONTest(const TString& option)
60 // Standard Constructor
63 if ( option != "default" &&
64 option != "FactoryV2" &&
65 option != "FactoryV3" &&
66 option != "FactoryV4" &&
69 BuildWithMUON(option);
72 BuildWithoutMUON(option);
75 //_____________________________________________________________________________
76 AliMUONTest::AliMUONTest()
82 // Default Constructor
86 //_____________________________________________________________________________
87 AliMUONTest::AliMUONTest(const AliMUONTest& rhs)
90 // Protected copy constructor
92 AliFatal("Not implemented.");
95 //_____________________________________________________________________________
96 AliMUONTest::~AliMUONTest()
103 //_____________________________________________________________________________
104 AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs)
106 // Protected assignement operator
108 if (this == &rhs) return *this;
110 AliFatal("Not implemented.");
118 //_____________________________________________________________________________
119 void AliMUONTest::BuildWithMUON(const TString& configMacro)
121 // Build segmentation via AliMUON initialisation
123 gAlice->Init(configMacro.Data());
124 AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
126 AliFatal("MUON detector not defined.");
129 fkTransformer = muon->GetGeometryTransformer();
130 fSegmentation = muon->GetSegmentation();
133 //_____________________________________________________________________________
134 void AliMUONTest::BuildWithoutMUON(const TString& option)
136 // Fill geometry from transform*.dat files and build segmentation via
139 AliMUONSegFactory segFactory("volpaths.dat", "transform.dat");
140 fSegmentation = segFactory.CreateSegmentation(option);
148 //_____________________________________________________________________________
149 AliMUONGeometrySegmentation*
150 AliMUONTest::GetSegmentation(Int_t chamberId, Int_t cath)
152 // Create geometry segmentation for the specified chamber and cathod
154 return fSegmentation->GetModuleSegmentation(chamberId, cath);
157 #include "AliMUONGeometryDetElement.h"
158 //_____________________________________________________________________________
159 void AliMUONTest::DetElemTransforms()
162 // Loop over chambers
163 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
165 const AliMUONGeometryModuleTransformer* kModuleTransformer
166 = fkTransformer->GetModuleTransformer(i);
168 AliMUONGeometryStore* detElements
169 = kModuleTransformer->GetDetElementStore();
171 // Loop over detection elements
172 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
174 //Int_t detElemId = kModuleTransformer->GetDetElemId(j);
175 Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();
176 cout << "Detection element Id: " << detElemId << endl;
179 kModuleTransformer->Local2Global(detElemId, 0., 0., 0., x, y, z);
180 cout << " Global DE position: "
181 << x << ", " << y << ", " << z << endl;
184 kModuleTransformer->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
185 cout << " ALIC center in the local frame: "
186 << x2 << ", " << y2 << ", " << z2 << endl;
189 kModuleTransformer->Global2Local(detElemId, x, y, z, x3, y3, z3);
190 cout << " Back in the local frame: "
191 << x3 << ", " << y3 << ", " << z3 << endl;
194 AliMUONGeometryDetElement* detElem =
195 (AliMUONGeometryDetElement*)detElements->GetEntry(j);
196 detElem->PrintGlobalTransform();
201 //_____________________________________________________________________________
202 void AliMUONTest::ForWhole(AliMUONTests testCase)
204 // Perform test for all chambers and first cathod
209 // Loop over chambers
210 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
213 //for (Int_t cath=0; cath<2; cath++) {
214 for (Int_t cath=0; cath<1; cath++) {
216 AliMUONGeometrySegmentation* segmentation
217 = GetSegmentation(iChamber, cath);
219 if (!segmentation) continue;
221 cout << setw(6) << "Pads in chamber " << iChamber
222 << " cathod " << cath << endl;
223 cout << "===================================" << endl;
225 ForSegmentation(testCase, segmentation);
232 //_____________________________________________________________________________
233 void AliMUONTest::ForSegmentation(AliMUONTests testCase,
234 AliMUONGeometrySegmentation *segmentation)
236 // Perform test for a given segmentation
243 // Loop over detection elements
245 AliMUONGeometryStore* detElements
246 = segmentation->GetTransformer()->GetDetElementStore();
248 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
250 Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();
251 cout << "Detection element id: " << detElemId << endl;
253 ForDetElement(testCase, detElemId, segmentation);
262 //_____________________________________________________________________________
263 void AliMUONTest::ForDetElement(AliMUONTests testCase,
265 AliMUONGeometrySegmentation *segmentation)
267 // Prints global pad positions for given detection element
268 // in a given geometry segmentation
273 // Loop over pads in a detection element
276 for(Int_t ix=1; ix<=segmentation->Npx(detElemId); ix++)
277 for(Int_t iy=1; iy<=segmentation->Npy(detElemId); iy++)
282 PrintPad(counter, detElemId, ix, iy, segmentation);
286 DrawPad(counter, detElemId, ix, iy, segmentation);
292 //_____________________________________________________________________________
293 void AliMUONTest::Before(AliMUONTests testCase)
295 // Do some initialization if necessary
304 fCanvas = new TCanvas("c1","c1", 0, 0, 600, 600);
305 fCanvas->Range(-300,-300, 300, 300);
312 //_____________________________________________________________________________
313 void AliMUONTest::After(AliMUONTests testCase)
315 // Do some cleanup if necessary
324 cout << "Print any key + enter to continue ..." << endl;
332 //_____________________________________________________________________________
333 void AliMUONTest::PrintPad(Int_t& counter,
334 Int_t detElemId, Int_t ix, Int_t iy,
335 AliMUONGeometrySegmentation* segmentation)
337 // Prints global pad positions for the given pad
341 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
343 cout << setw(6) << "counter " << counter++ << " ";
344 cout << "Pad indices: ( " << detElemId << "; " << ix << ", " << iy << " ) " ;
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;
355 cout << "... no pad " << endl;
359 //_____________________________________________________________________________
360 void AliMUONTest::DrawPad(Int_t& counter,
361 Int_t detElemId, Int_t ix, Int_t iy,
362 AliMUONGeometrySegmentation* segmentation)
364 // Prints global pad positions for the given pad
368 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
370 if (!success) return;
372 // PrintPad(counter,detElemId, ix, iy, segmentation);
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);
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);
383 if (!fCanvas) Before(kDrawPads);
386 TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1);
390 //_____________________________________________________________________________
391 void AliMUONTest::DrawSegmentation(AliMUONGeometrySegmentation *seg)
399 // TH2F * frame = new TH2F(" "," ",10,-10.,245.,10, -5., 45.);
400 // TH2F * frame = new TH2F(" "," ",10,-300.,300.,10, -300., 300.);
401 TH2F * frame = new TH2F(" "," ",10,-350.,350.,10, -350., 350.);
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();
410 // Loop over detection elements
412 AliMUONGeometryStore* detElements
413 = seg->GetTransformer()->GetDetElementStore();
415 for (Int_t iDE=0; iDE<detElements->GetNofEntries(); iDE++) {
417 deId = detElements->GetEntry(iDE)->GetUniqueID();
419 cout << "Detection element id: " << deId << endl;
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++) {
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);
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();