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 "AliMUONTest.h"
26 #include "AliMUONConstants.h"
27 #include "AliMUONGeometryBuilder.h"
28 #include "AliMUONSt1GeometryBuilderV2.h"
29 #include "AliMUONSt2GeometryBuilderV2.h"
30 #include "AliMUONSlatGeometryBuilder.h"
31 #include "AliMUONTriggerGeometryBuilder.h"
32 #include "AliMUONSegFactory.h"
33 #include "AliMUONGeometryTransformer.h"
34 #include "AliMUONGeometryModule.h"
35 #include "AliMUONGeometryStore.h"
36 #include "AliMUONGeometryTransformer.h"
37 #include "AliMUONSegmentation.h"
38 #include "AliMUONGeometrySegmentation.h"
43 #include <TStopwatch.h>
44 #include <Riostream.h>
48 #include <TGeoMatrix.h>
52 //_____________________________________________________________________________
53 AliMUONTest::AliMUONTest(const TString& option)
59 // Standard Constructor
62 if ( option != "default" &&
63 option != "FactoryV2" &&
64 option != "FactoryV3" &&
65 option != "FactoryV4" &&
68 BuildWithMUON(option);
71 BuildWithoutMUON(option);
74 //_____________________________________________________________________________
75 AliMUONTest::AliMUONTest()
81 // Default Constructor
85 //_____________________________________________________________________________
86 AliMUONTest::AliMUONTest(const AliMUONTest& rhs)
89 // Protected copy constructor
91 AliFatal("Not implemented.");
94 //_____________________________________________________________________________
95 AliMUONTest::~AliMUONTest()
102 //_____________________________________________________________________________
103 AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs)
105 // Protected assignement operator
107 if (this == &rhs) return *this;
109 AliFatal("Not implemented.");
117 //_____________________________________________________________________________
118 void AliMUONTest::BuildWithMUON(const TString& configMacro)
120 // Build segmentation via AliMUON initialisation
122 gAlice->Init(configMacro.Data());
123 AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
125 AliFatal("MUON detector not defined.");
128 fkTransformer = muon->GetGeometryTransformer();
129 fSegmentation = muon->GetSegmentation();
132 //_____________________________________________________________________________
133 void AliMUONTest::BuildWithoutMUON(const TString& option)
135 // Fill geometry from transform*.dat files and build segmentation via
138 AliMUONSegFactory segFactory("volpaths.dat", "transform.dat");
139 fSegmentation = segFactory.CreateSegmentation(option);
147 //_____________________________________________________________________________
148 AliMUONGeometrySegmentation*
149 AliMUONTest::GetSegmentation(Int_t chamberId, Int_t cath)
151 // Create geometry segmentation for the specified chamber and cathod
153 return fSegmentation->GetModuleSegmentation(chamberId, cath);
156 #include "AliMUONGeometryDetElement.h"
157 //_____________________________________________________________________________
158 void AliMUONTest::DetElemTransforms()
161 // Loop over chambers
162 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
164 const AliMUONGeometryModuleTransformer* kModuleTransformer
165 = fkTransformer->GetModuleTransformer(i);
167 AliMUONGeometryStore* detElements
168 = kModuleTransformer->GetDetElementStore();
170 // Loop over detection elements
171 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
173 //Int_t detElemId = kModuleTransformer->GetDetElemId(j);
174 Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();
175 cout << "Detection element Id: " << detElemId << endl;
178 kModuleTransformer->Local2Global(detElemId, 0., 0., 0., x, y, z);
179 cout << " Global DE position: "
180 << x << ", " << y << ", " << z << endl;
183 kModuleTransformer->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
184 cout << " ALIC center in the local frame: "
185 << x2 << ", " << y2 << ", " << z2 << endl;
188 kModuleTransformer->Global2Local(detElemId, x, y, z, x3, y3, z3);
189 cout << " Back in the local frame: "
190 << x3 << ", " << y3 << ", " << z3 << endl;
193 AliMUONGeometryDetElement* detElem =
194 (AliMUONGeometryDetElement*)detElements->GetEntry(j);
195 detElem->PrintGlobalTransform();
200 //_____________________________________________________________________________
201 void AliMUONTest::ForWhole(AliMUONTests testCase)
203 // Perform test for all chambers and first cathod
208 // Loop over chambers
209 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
212 //for (Int_t cath=0; cath<2; cath++) {
213 for (Int_t cath=0; cath<1; cath++) {
215 AliMUONGeometrySegmentation* segmentation
216 = GetSegmentation(iChamber, cath);
218 if (!segmentation) continue;
220 cout << setw(6) << "Pads in chamber " << iChamber
221 << " cathod " << cath << endl;
222 cout << "===================================" << endl;
224 ForSegmentation(testCase, segmentation);
231 //_____________________________________________________________________________
232 void AliMUONTest::ForSegmentation(AliMUONTests testCase,
233 AliMUONGeometrySegmentation *segmentation)
235 // Perform test for a given segmentation
242 // Loop over detection elements
244 AliMUONGeometryStore* detElements
245 = segmentation->GetTransformer()->GetDetElementStore();
247 for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
249 Int_t detElemId = detElements->GetEntry(j)->GetUniqueID();
250 cout << "Detection element id: " << detElemId << endl;
252 ForDetElement(testCase, detElemId, segmentation);
261 //_____________________________________________________________________________
262 void AliMUONTest::ForDetElement(AliMUONTests testCase,
264 AliMUONGeometrySegmentation *segmentation)
266 // Prints global pad positions for given detection element
267 // in a given geometry segmentation
272 // Loop over pads in a detection element
275 for(Int_t ix=1; ix<=segmentation->Npx(detElemId); ix++)
276 for(Int_t iy=1; iy<=segmentation->Npy(detElemId); iy++)
281 PrintPad(counter, detElemId, ix, iy, segmentation);
285 DrawPad(counter, detElemId, ix, iy, segmentation);
291 //_____________________________________________________________________________
292 void AliMUONTest::Before(AliMUONTests testCase)
294 // Do some initialization if necessary
303 fCanvas = new TCanvas("c1","c1", 0, 0, 600, 600);
304 fCanvas->Range(-300,-300, 300, 300);
311 //_____________________________________________________________________________
312 void AliMUONTest::After(AliMUONTests testCase)
314 // Do some cleanup if necessary
323 cout << "Print any key + enter to continue ..." << endl;
331 //_____________________________________________________________________________
332 void AliMUONTest::PrintPad(Int_t& counter,
333 Int_t detElemId, Int_t ix, Int_t iy,
334 AliMUONGeometrySegmentation* segmentation)
336 // Prints global pad positions for the given pad
340 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
342 cout << setw(6) << "counter " << counter++ << " ";
343 cout << "Pad indices: ( " << detElemId << "; " << ix << ", " << iy << " ) " ;
346 cout << "Pad position: ( " << x << ", " << y << ", " << z << " ); ";
347 Int_t sector = segmentation->Sector(detElemId, ix, iy);
348 Float_t dpx = segmentation->Dpx(detElemId, sector);
349 Float_t dpy = segmentation->Dpy(detElemId, sector);
350 cout << " dimensions: ( " << dpx << ", " << dpy << " )" << endl;
354 cout << "... no pad " << endl;
358 //_____________________________________________________________________________
359 void AliMUONTest::DrawPad(Int_t& counter,
360 Int_t detElemId, Int_t ix, Int_t iy,
361 AliMUONGeometrySegmentation* segmentation)
363 // Prints global pad positions for the given pad
367 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
369 if (!success) return;
371 // PrintPad(counter,detElemId, ix, iy, segmentation);
375 Int_t sector = segmentation->Sector(detElemId, ix, iy);
376 Float_t dpx = segmentation->Dpx(detElemId, sector);
377 Float_t dpy = segmentation->Dpy(detElemId, sector);
379 //printf(" ***** Pad position is ix: %d iy: %d x: %f y: %f sector: %d dpx: %f dpy: %f \n",
380 // ix, iy, x, y, sector, dpx, dpy);
382 if (!fCanvas) Before(kDrawPads);
385 TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1);
389 //_____________________________________________________________________________
390 void AliMUONTest::DrawSegmentation(AliMUONGeometrySegmentation *seg)
398 // TH2F * frame = new TH2F(" "," ",10,-10.,245.,10, -5., 45.);
399 // TH2F * frame = new TH2F(" "," ",10,-300.,300.,10, -300., 300.);
400 TH2F * frame = new TH2F(" "," ",10,-350.,350.,10, -350., 350.);
402 // (new TPave( 0., 0., 40., 40.,2))->Draw();
403 // (new TPave( 40., 0., 80., 40.,2))->Draw();
404 // (new TPave( 80., 0.,120., 40.,2))->Draw();
405 // (new TPave(120., 0.,160., 40.,2))->Draw();
406 // (new TPave(160., 0.,200., 40.,2))->Draw();
407 // (new TPave(200., 0.,240., 40.,2))->Draw();
409 // Loop over detection elements
411 AliMUONGeometryStore* detElements
412 = seg->GetTransformer()->GetDetElementStore();
414 for (Int_t iDE=0; iDE<detElements->GetNofEntries(); iDE++) {
416 deId = detElements->GetEntry(iDE)->GetUniqueID();
418 cout << "Detection element id: " << deId << endl;
421 // for ( seg->FirstPad(detElementId, 0., 0., 0., 100., 100.);
422 // seg->MorePads(detElementId);
423 // seg->NextPad(detElementId) ) {
424 for(ix=1; ix<=seg->Npx(deId); ix++) {
425 for(iy=1; iy<=seg->Npy(deId); iy++) {
427 seg->GetPadC(deId, ix, iy, x, y, z);
428 Int_t sector = seg->Sector(deId, ix, iy);
429 dpx = seg->Dpx(deId,sector);
430 dpy = seg->Dpy(deId,sector);
432 //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);
433 (new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1))->Draw();