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(const AliMUONTest& rhs)
91 /// Protected copy constructor
93 AliFatal("Not implemented.");
96 //_____________________________________________________________________________
97 AliMUONTest::~AliMUONTest()
104 //_____________________________________________________________________________
105 AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs)
107 /// Protected assignement operator
109 if (this == &rhs) return *this;
111 AliFatal("Not implemented.");
119 //_____________________________________________________________________________
120 void AliMUONTest::BuildWithMUON(const TString& configMacro)
122 /// Build segmentation via AliMUON initialisation
124 gAlice->Init(configMacro.Data());
125 AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
127 AliFatal("MUON detector not defined.");
130 fkTransformer = muon->GetGeometryTransformer();
131 fSegmentation = muon->GetSegmentation();
134 //_____________________________________________________________________________
135 void AliMUONTest::BuildWithoutMUON(const TString& option)
137 /// Fill geometry from transform*.dat files and build segmentation via
140 AliMUONSegFactory segFactory("volpaths.dat", "transform.dat");
141 fSegmentation = segFactory.CreateSegmentation(option);
149 //_____________________________________________________________________________
150 void AliMUONTest::PrintPadsForAll() const
152 /// Print pads for all chambers and first cathod
157 // Loop over chambers
158 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
161 //for (Int_t cath=0; cath<2; cath++) {
162 for (Int_t cath=0; cath<1; cath++) {
164 cout << setw(6) << "Pads in chamber " << iChamber
165 << " cathod " << cath << endl;
166 cout << "===================================" << endl;
168 PrintPadsForSegmentation(iChamber, cath);
175 //_____________________________________________________________________________
176 void AliMUONTest::PrintPadsForSegmentation(Int_t moduleId, Int_t cath) const
178 /// Print pads for the given segmentation
183 // Loop over detection elements
186 for ( it.First(moduleId); ! it.IsDone(); it.Next()) {
188 Int_t detElemId = it.CurrentDE();
189 cout << "Detection element id: " << detElemId << endl;
191 PrintPadsForDetElement(detElemId, cath);
198 //_____________________________________________________________________________
199 void AliMUONTest::PrintPadsForDetElement(Int_t detElemId, Int_t cath) const
201 /// Print global pad positions for the given detection element
204 // Get geometry segmentation
206 AliMUONGeometrySegmentation* segmentation
207 = fSegmentation->GetModuleSegmentationByDEId(detElemId, cath);
210 << "Segmentation for detElemId = " << detElemId << ", cath = " << cath
211 << " not defined." << endl;
217 // Loop over pads in a detection element
219 for(Int_t ix=0; ix<=segmentation->Npx(detElemId); ix++)
220 for(Int_t iy=0; iy<=segmentation->Npy(detElemId); iy++)
221 PrintPad(counter, detElemId, ix, iy, segmentation);
224 //_____________________________________________________________________________
225 void AliMUONTest::PrintPad(Int_t& counter,
226 Int_t detElemId, Int_t ix, Int_t iy,
227 AliMUONGeometrySegmentation* segmentation) const
229 /// Print global pad position for the given pad
233 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
235 cout << setw(6) << "counter " << counter++ << " ";
236 cout << "Pad indices: ( " << detElemId << "; " << ix << ", " << iy << " ) " ;
239 cout << "Pad position: ( " << x << ", " << y << ", " << z << " ); ";
240 Int_t sector = segmentation->Sector(detElemId, ix, iy);
241 Float_t dpx = segmentation->Dpx(detElemId, sector);
242 Float_t dpy = segmentation->Dpy(detElemId, sector);
243 cout << " dimensions: ( " << dpx << ", " << dpy << " )" << endl;
247 cout << "... no pad " << endl;
251 //_____________________________________________________________________________
252 void AliMUONTest::DrawPadsForAll() const
254 /// Draw pad for all chambers and first cathod
259 // Loop over chambers
260 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
263 //for (Int_t cath=0; cath<2; cath++) {
264 for (Int_t cath=0; cath<1; cath++) {
266 cout << setw(6) << "Pads in chamber " << iChamber
267 << " cathod " << cath << endl;
268 cout << "===================================" << endl;
270 DrawPadsForSegmentation(iChamber, cath);
277 //_____________________________________________________________________________
278 void AliMUONTest::DrawPadsForSegmentation(Int_t moduleId, Int_t cath) const
280 /// Draw pads for the given segmentation
285 // Loop over detection elements
288 for ( it.First(moduleId); ! it.IsDone(); it.Next()) {
290 Int_t detElemId = it.CurrentDE();
291 cout << "Detection element id: " << detElemId << endl;
293 DrawPadsForDetElement(detElemId, cath);
297 cout << "Print any key + enter to continue ..." << endl;
306 //_____________________________________________________________________________
307 void AliMUONTest::DrawPadsForDetElement(Int_t detElemId, Int_t cath) const
309 /// Draw pads for the given detection element
311 // Get geometry segmentation
313 AliMUONGeometrySegmentation* segmentation
314 = fSegmentation->GetModuleSegmentationByDEId(detElemId, cath);
317 << "Segmentation for detElemId = " << detElemId << ", cath = " << cath
318 << " not defined." << endl;
324 // Loop over pads in a detection element
326 for(Int_t ix=0; ix<=segmentation->Npx(detElemId); ix++)
327 for(Int_t iy=0; iy<=segmentation->Npy(detElemId); iy++)
328 DrawPad(counter, detElemId, ix, iy, segmentation);
331 //_____________________________________________________________________________
332 void AliMUONTest::DrawPad(Int_t& counter,
333 Int_t detElemId, Int_t ix, Int_t iy,
334 AliMUONGeometrySegmentation* segmentation) const
336 /// Draw the given pad
340 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
342 if (!success) return;
344 // PrintPad(counter,detElemId, ix, iy, segmentation);
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);
352 //printf(" ***** Pad position is ix: %d iy: %d x: %f y: %f sector: %d dpx: %f dpy: %f \n",
353 // ix, iy, x, y, sector, dpx, dpy);
356 TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1);
360 //_____________________________________________________________________________
361 void AliMUONTest::DetElemTransforms() const
363 /// Print detection elements transformations
365 // Loop over chambers
366 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
368 const AliMUONGeometryModuleTransformer* kModuleTransformer
369 = fkTransformer->GetModuleTransformer(i);
371 // Loop over detection elements
373 for ( it.First(i); ! it.IsDone(); it.Next()) {
375 Int_t detElemId = it.CurrentDE();
376 cout << "Detection element id: " << detElemId << endl;
379 kModuleTransformer->Local2Global(detElemId, 0., 0., 0., x, y, z);
380 cout << " Global DE position: "
381 << x << ", " << y << ", " << z << endl;
384 kModuleTransformer->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
385 cout << " ALIC center in the local frame: "
386 << x2 << ", " << y2 << ", " << z2 << endl;
389 kModuleTransformer->Global2Local(detElemId, x, y, z, x3, y3, z3);
390 cout << " Back in the local frame: "
391 << x3 << ", " << y3 << ", " << z3 << endl;
394 AliMUONGeometryDetElement* detElem =
395 kModuleTransformer->GetDetElement(detElemId);
396 detElem->PrintGlobalTransform();