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
22 // Author: Ivana Hrivnacova, IPN Orsay
24 #include "AliMUONTest.h"
26 #include "AliMUONConstants.h"
27 #include "AliMUONSegFactory.h"
28 #include "AliMUONGeometryTransformer.h"
29 #include "AliMUONGeometryModuleTransformer.h"
30 #include "AliMUONGeometryDetElement.h"
31 #include "AliMUONSegmentation.h"
32 #include "AliMUONGeometrySegmentation.h"
34 #include "AliMpDEIterator.h"
35 #include "AliMpDEManager.h"
36 #include "AliMpVSegmentation.h"
42 #include <TStopwatch.h>
43 #include <Riostream.h>
47 #include <TGeoMatrix.h>
51 //_____________________________________________________________________________
52 AliMUONTest::AliMUONTest(const TString& option)
58 /// Standard Constructor
60 if ( option != "default" &&
61 option != "FactoryV2" &&
62 option != "FactoryV3" &&
63 option != "FactoryV4" &&
66 BuildWithMUON(option);
69 BuildWithoutMUON(option);
72 fCanvas = new TCanvas("c1","c1", 0, 0, 800, 800);
73 fCanvas->Range(-400,-400, 400, 400);
77 //_____________________________________________________________________________
78 AliMUONTest::AliMUONTest()
84 /// Default Constructor
87 //_____________________________________________________________________________
88 AliMUONTest::~AliMUONTest()
98 //_____________________________________________________________________________
99 void AliMUONTest::BuildWithMUON(const TString& configMacro)
101 /// Build segmentation via AliMUON initialisation
103 gAlice->Init(configMacro.Data());
104 AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
106 AliFatal("MUON detector not defined.");
109 fkTransformer = muon->GetGeometryTransformer();
110 fSegmentation = muon->GetSegmentation();
113 //_____________________________________________________________________________
114 void AliMUONTest::BuildWithoutMUON(const TString& option)
116 /// Fill geometry from transform*.dat files and build segmentation via
119 AliMUONSegFactory segFactory("volpaths.dat", "transform.dat");
120 fSegmentation = segFactory.CreateSegmentation(option);
128 //_____________________________________________________________________________
129 void AliMUONTest::PrintPadsForAll() const
131 /// Print pads for all chambers and first cathod
136 // Loop over chambers
137 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
140 //for (Int_t cath=0; cath<2; cath++) {
141 for (Int_t cath=0; cath<1; cath++) {
143 cout << setw(6) << "Pads in chamber " << iChamber
144 << " cathod " << cath << endl;
145 cout << "===================================" << endl;
147 PrintPadsForSegmentation(iChamber, cath);
154 //_____________________________________________________________________________
155 void AliMUONTest::PrintPadsForSegmentation(Int_t moduleId, Int_t cath) const
157 /// Print pads for the given segmentation
162 // Loop over detection elements
165 for ( it.First(moduleId); ! it.IsDone(); it.Next()) {
167 Int_t detElemId = it.CurrentDE();
168 cout << "Detection element id: " << detElemId << endl;
170 PrintPadsForDetElement(detElemId, cath);
177 //_____________________________________________________________________________
178 void AliMUONTest::PrintPadsForDetElement(Int_t detElemId, Int_t cath) const
180 /// Print global pad positions for the given detection element
183 // Get geometry segmentation
185 AliMUONGeometrySegmentation* segmentation
186 = fSegmentation->GetModuleSegmentationByDEId(detElemId, cath);
189 << "Segmentation for detElemId = " << detElemId << ", cath = " << cath
190 << " not defined." << endl;
196 // Loop over pads in a detection element
198 for(Int_t ix=0; ix<=segmentation->Npx(detElemId); ix++)
199 for(Int_t iy=0; iy<=segmentation->Npy(detElemId); iy++)
200 PrintPad(counter, detElemId, ix, iy, segmentation);
203 //_____________________________________________________________________________
204 void AliMUONTest::PrintPad(Int_t& counter,
205 Int_t detElemId, Int_t ix, Int_t iy,
206 AliMUONGeometrySegmentation* segmentation) const
208 /// Print global pad position for the given pad
212 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
214 cout << setw(6) << "counter " << counter++ << " ";
215 cout << "Pad indices: ( " << detElemId << "; " << ix << ", " << iy << " ) " ;
218 cout << "Pad position: ( " << x << ", " << y << ", " << z << " ); ";
219 Int_t sector = segmentation->Sector(detElemId, ix, iy);
220 Float_t dpx = segmentation->Dpx(detElemId, sector);
221 Float_t dpy = segmentation->Dpy(detElemId, sector);
222 cout << " dimensions: ( " << dpx << ", " << dpy << " )" << endl;
226 cout << "... no pad " << endl;
230 //_____________________________________________________________________________
231 void AliMUONTest::DrawPadsForAll() const
233 /// Draw pad for all chambers and first cathod
238 // Loop over chambers
239 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
242 //for (Int_t cath=0; cath<2; cath++) {
243 for (Int_t cath=0; cath<1; cath++) {
245 cout << setw(6) << "Pads in chamber " << iChamber
246 << " cathod " << cath << endl;
247 cout << "===================================" << endl;
249 DrawPadsForSegmentation(iChamber, cath);
256 //_____________________________________________________________________________
257 void AliMUONTest::DrawPadsForSegmentation(Int_t moduleId, Int_t cath) const
259 /// Draw pads for the given segmentation
264 // Loop over detection elements
267 for ( it.First(moduleId); ! it.IsDone(); it.Next()) {
269 Int_t detElemId = it.CurrentDE();
270 cout << "Detection element id: " << detElemId << endl;
272 DrawPadsForDetElement(detElemId, cath);
276 cout << "Print any key + enter to continue ..." << endl;
285 //_____________________________________________________________________________
286 void AliMUONTest::DrawPadsForDetElement(Int_t detElemId, Int_t cath) const
288 /// Draw pads for the given detection element
290 // Get geometry segmentation
292 AliMUONGeometrySegmentation* segmentation
293 = fSegmentation->GetModuleSegmentationByDEId(detElemId, cath);
296 << "Segmentation for detElemId = " << detElemId << ", cath = " << cath
297 << " not defined." << endl;
303 // Loop over pads in a detection element
305 for(Int_t ix=0; ix<=segmentation->Npx(detElemId); ix++)
306 for(Int_t iy=0; iy<=segmentation->Npy(detElemId); iy++)
307 DrawPad(counter, detElemId, ix, iy, segmentation);
310 //_____________________________________________________________________________
311 void AliMUONTest::DrawPad(Int_t& counter,
312 Int_t detElemId, Int_t ix, Int_t iy,
313 AliMUONGeometrySegmentation* segmentation) const
315 /// Draw the given pad
319 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
321 if (!success) return;
323 // PrintPad(counter,detElemId, ix, iy, segmentation);
327 Int_t sector = segmentation->Sector(detElemId, ix, iy);
328 Float_t dpx = segmentation->Dpx(detElemId, sector);
329 Float_t dpy = segmentation->Dpy(detElemId, sector);
331 //printf(" ***** Pad position is ix: %d iy: %d x: %f y: %f sector: %d dpx: %f dpy: %f \n",
332 // ix, iy, x, y, sector, dpx, dpy);
335 TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1);
339 //_____________________________________________________________________________
340 void AliMUONTest::DetElemTransforms() const
342 /// Print detection elements transformations
344 // Loop over chambers
345 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
347 const AliMUONGeometryModuleTransformer* kModuleTransformer
348 = fkTransformer->GetModuleTransformer(i);
350 // Loop over detection elements
352 for ( it.First(i); ! it.IsDone(); it.Next()) {
354 Int_t detElemId = it.CurrentDE();
355 cout << "Detection element id: " << detElemId << endl;
358 kModuleTransformer->Local2Global(detElemId, 0., 0., 0., x, y, z);
359 cout << " Global DE position: "
360 << x << ", " << y << ", " << z << endl;
363 kModuleTransformer->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
364 cout << " ALIC center in the local frame: "
365 << x2 << ", " << y2 << ", " << z2 << endl;
368 kModuleTransformer->Global2Local(detElemId, x, y, z, x3, y3, z3);
369 cout << " Back in the local frame: "
370 << x3 << ", " << y3 << ", " << z3 << endl;
373 AliMUONGeometryDetElement* detElem =
374 kModuleTransformer->GetDetElement(detElemId);
375 detElem->PrintGlobalTransform();