]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONTest.cxx
New versions of GDC and CDH raw data headers. Some CDH getters are added
[u/mrichter/AliRoot.git] / MUON / AliMUONTest.cxx
CommitLineData
e118b27e 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16// $Id$
17//
f7006443 18// -----------------
e118b27e 19// Class AliMUONTest
20// -----------------
f7006443 21// Class with functions for testing segmentations
e118b27e 22// Author: Ivana Hrivnacova, IPN Orsay
23
e118b27e 24#include "AliMUONTest.h"
25#include "AliMUON.h"
26#include "AliMUONConstants.h"
40afd6cd 27#include "AliMUONSegFactory.h"
8b7981ce 28#include "AliMUONGeometryTransformer.h"
19e9826b 29#include "AliMUONGeometryModuleTransformer.h"
30#include "AliMUONGeometryDetElement.h"
8b7981ce 31#include "AliMUONSegmentation.h"
e118b27e 32#include "AliMUONGeometrySegmentation.h"
e118b27e 33
19e9826b 34#include "AliMpDEIterator.h"
35#include "AliMpDEManager.h"
36#include "AliMpVSegmentation.h"
37#include "AliMpPad.h"
38
a3953bc5 39#include "AliRun.h"
40#include "AliLog.h"
41
42#include <TStopwatch.h>
43#include <Riostream.h>
44#include <TH2F.h>
45#include <TPave.h>
46#include <TCanvas.h>
47#include <TGeoMatrix.h>
48
e118b27e 49ClassImp(AliMUONTest)
50
8b7981ce 51//_____________________________________________________________________________
52 AliMUONTest::AliMUONTest(const TString& option)
152d6f4e 53 : TObject(),
8b7981ce 54 fkTransformer(0),
55 fSegmentation(0),
152d6f4e 56 fCanvas(0)
e118b27e 57{
19e9826b 58/// Standard Constructor
8b7981ce 59
60 if ( option != "default" &&
40afd6cd 61 option != "FactoryV2" &&
62 option != "FactoryV3" &&
63 option != "FactoryV4" &&
64 option != "new" )
8b7981ce 65 {
66 BuildWithMUON(option);
67 }
68 else
69 BuildWithoutMUON(option);
19e9826b 70
71 // Create canvas
72 fCanvas = new TCanvas("c1","c1", 0, 0, 800, 800);
73 fCanvas->Range(-400,-400, 400, 400);
74 fCanvas->cd();
e118b27e 75}
76
8b7981ce 77//_____________________________________________________________________________
e118b27e 78AliMUONTest::AliMUONTest()
152d6f4e 79 : TObject(),
8b7981ce 80 fkTransformer(0),
81 fSegmentation(0),
152d6f4e 82 fCanvas(0)
e118b27e 83{
19e9826b 84/// Default Constructor
e118b27e 85}
86
8b7981ce 87//_____________________________________________________________________________
e118b27e 88AliMUONTest::AliMUONTest(const AliMUONTest& rhs)
89 : TObject(rhs)
90{
19e9826b 91/// Protected copy constructor
e118b27e 92
93 AliFatal("Not implemented.");
94}
95
8b7981ce 96//_____________________________________________________________________________
e118b27e 97AliMUONTest::~AliMUONTest()
98{
19e9826b 99/// Destructor
152d6f4e 100
101 delete fCanvas;
e118b27e 102}
103
8b7981ce 104//_____________________________________________________________________________
e118b27e 105AliMUONTest& AliMUONTest::operator = (const AliMUONTest& rhs)
106{
19e9826b 107/// Protected assignement operator
e118b27e 108
109 if (this == &rhs) return *this;
110
111 AliFatal("Not implemented.");
112
113 return *this;
114}
115
116//
152d6f4e 117// private methods
e118b27e 118//
24def874 119//_____________________________________________________________________________
8b7981ce 120void AliMUONTest::BuildWithMUON(const TString& configMacro)
24def874 121{
19e9826b 122/// Build segmentation via AliMUON initialisation
24def874 123
8b7981ce 124 gAlice->Init(configMacro.Data());
24def874 125 AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
126 if (!muon) {
127 AliFatal("MUON detector not defined.");
8b7981ce 128 return;
24def874 129 }
8b7981ce 130 fkTransformer = muon->GetGeometryTransformer();
131 fSegmentation = muon->GetSegmentation();
132}
24def874 133
58d53b65 134//_____________________________________________________________________________
8b7981ce 135void AliMUONTest::BuildWithoutMUON(const TString& option)
58d53b65 136{
19e9826b 137/// Fill geometry from transform*.dat files and build segmentation via
138/// SegFactory
58d53b65 139
a3953bc5 140 AliMUONSegFactory segFactory("volpaths.dat", "transform.dat");
40afd6cd 141 fSegmentation = segFactory.CreateSegmentation(option);
8b7981ce 142}
58d53b65 143
58d53b65 144
152d6f4e 145//
146// public methods
147//
148
8b7981ce 149//_____________________________________________________________________________
19e9826b 150void AliMUONTest::PrintPadsForAll() const
152d6f4e 151{
19e9826b 152/// Print pads for all chambers and first cathod
152d6f4e 153
152d6f4e 154 TStopwatch timer;
155 timer.Start();
156
157 // Loop over chambers
580c28fd 158 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
152d6f4e 159
160 // Loop over cathods
d640924e 161 //for (Int_t cath=0; cath<2; cath++) {
162 for (Int_t cath=0; cath<1; cath++) {
152d6f4e 163
152d6f4e 164 cout << setw(6) << "Pads in chamber " << iChamber
165 << " cathod " << cath << endl;
166 cout << "===================================" << endl;
167
19e9826b 168 PrintPadsForSegmentation(iChamber, cath);
152d6f4e 169 }
170 }
171 timer.Stop();
172 timer.Print();
173}
174
8b7981ce 175//_____________________________________________________________________________
19e9826b 176void AliMUONTest::PrintPadsForSegmentation(Int_t moduleId, Int_t cath) const
152d6f4e 177{
19e9826b 178/// Print pads for the given segmentation
152d6f4e 179
180 TStopwatch timer;
181 timer.Start();
182
152d6f4e 183 // Loop over detection elements
184 //
19e9826b 185 AliMpDEIterator it;
186 for ( it.First(moduleId); ! it.IsDone(); it.Next()) {
152d6f4e 187
19e9826b 188 Int_t detElemId = it.CurrentDE();
152d6f4e 189 cout << "Detection element id: " << detElemId << endl;
190
19e9826b 191 PrintPadsForDetElement(detElemId, cath);
152d6f4e 192 }
193
152d6f4e 194 timer.Stop();
195 timer.Print();
24def874 196}
152d6f4e 197
8b7981ce 198//_____________________________________________________________________________
19e9826b 199void AliMUONTest::PrintPadsForDetElement(Int_t detElemId, Int_t cath) const
152d6f4e 200{
19e9826b 201/// Print global pad positions for the given detection element
152d6f4e 202
203
19e9826b 204 // Get geometry segmentation
205 //
206 AliMUONGeometrySegmentation* segmentation
207 = fSegmentation->GetModuleSegmentationByDEId(detElemId, cath);
208 if (!segmentation) {
209 AliErrorStream()
210 << "Segmentation for detElemId = " << detElemId << ", cath = " << cath
211 << " not defined." << endl;
212 return;
213 }
214
152d6f4e 215 Int_t counter = 0;
216
217 // Loop over pads in a detection element
218 //
19e9826b 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);
152d6f4e 222}
223
8b7981ce 224//_____________________________________________________________________________
152d6f4e 225void AliMUONTest::PrintPad(Int_t& counter,
226 Int_t detElemId, Int_t ix, Int_t iy,
19e9826b 227 AliMUONGeometrySegmentation* segmentation) const
152d6f4e 228{
19e9826b 229/// Print global pad position for the given pad
152d6f4e 230
231 Float_t x, y, z;
232 Bool_t success
233 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
234
152d6f4e 235 cout << setw(6) << "counter " << counter++ << " ";
236 cout << "Pad indices: ( " << detElemId << "; " << ix << ", " << iy << " ) " ;
580c28fd 237
238 if (success) {
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;
244 }
245 else {
246 counter--;
247 cout << "... no pad " << endl;
248 }
152d6f4e 249}
250
19e9826b 251//_____________________________________________________________________________
252void AliMUONTest::DrawPadsForAll() const
253{
254/// Draw pad for all chambers and first cathod
255
256 TStopwatch timer;
257 timer.Start();
258
259 // Loop over chambers
260 for (Int_t iChamber=0; iChamber<AliMUONConstants::NCh(); iChamber++) {
261
262 // Loop over cathods
263 //for (Int_t cath=0; cath<2; cath++) {
264 for (Int_t cath=0; cath<1; cath++) {
265
266 cout << setw(6) << "Pads in chamber " << iChamber
267 << " cathod " << cath << endl;
268 cout << "===================================" << endl;
269
270 DrawPadsForSegmentation(iChamber, cath);
271 }
272 }
273 timer.Stop();
274 timer.Print();
275}
276
277//_____________________________________________________________________________
278void AliMUONTest::DrawPadsForSegmentation(Int_t moduleId, Int_t cath) const
279{
280/// Draw pads for the given segmentation
281
282 TStopwatch timer;
283 timer.Start();
284
285 // Loop over detection elements
286 //
287 AliMpDEIterator it;
288 for ( it.First(moduleId); ! it.IsDone(); it.Next()) {
289
290 Int_t detElemId = it.CurrentDE();
291 cout << "Detection element id: " << detElemId << endl;
292
293 DrawPadsForDetElement(detElemId, cath);
294 }
295
296 fCanvas->Update();
297 cout << "Print any key + enter to continue ..." << endl;
298 char c;
299 cin >> c;
300 fCanvas->Clear();
301
302 timer.Stop();
303 timer.Print();
304}
305
306//_____________________________________________________________________________
307void AliMUONTest::DrawPadsForDetElement(Int_t detElemId, Int_t cath) const
308{
309/// Draw pads for the given detection element
310
311 // Get geometry segmentation
312 //
313 AliMUONGeometrySegmentation* segmentation
314 = fSegmentation->GetModuleSegmentationByDEId(detElemId, cath);
315 if (!segmentation) {
316 AliErrorStream()
317 << "Segmentation for detElemId = " << detElemId << ", cath = " << cath
318 << " not defined." << endl;
319 return;
320 }
321
322 Int_t counter = 0;
323
324 // Loop over pads in a detection element
325 //
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);
329}
330
8b7981ce 331//_____________________________________________________________________________
152d6f4e 332void AliMUONTest::DrawPad(Int_t& counter,
333 Int_t detElemId, Int_t ix, Int_t iy,
19e9826b 334 AliMUONGeometrySegmentation* segmentation) const
152d6f4e 335{
19e9826b 336/// Draw the given pad
152d6f4e 337
338 Float_t x, y, z;
339 Bool_t success
340 = segmentation->GetPadC(detElemId, ix, iy, x, y, z);
341
342 if (!success) return;
343
344 // PrintPad(counter,detElemId, ix, iy, segmentation);
345
346 counter++;
347
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
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);
354
355 fCanvas->cd();
356 TPave* pave = new TPave(x-dpx/2., y-dpy/2., x+dpx/2., y+dpy/2., 1);
357 pave->Draw();
358}
19e9826b 359
8b7981ce 360//_____________________________________________________________________________
19e9826b 361void AliMUONTest::DetElemTransforms() const
152d6f4e 362{
19e9826b 363/// Print detection elements transformations
152d6f4e 364
19e9826b 365 // Loop over chambers
366 for (Int_t i=0; i<AliMUONConstants::NCh(); i++) {
367
368 const AliMUONGeometryModuleTransformer* kModuleTransformer
369 = fkTransformer->GetModuleTransformer(i);
f48459ab 370
19e9826b 371 // Loop over detection elements
372 AliMpDEIterator it;
373 for ( it.First(i); ! it.IsDone(); it.Next()) {
374
375 Int_t detElemId = it.CurrentDE();
376 cout << "Detection element id: " << detElemId << endl;
377
378 Double_t x, y, z;
379 kModuleTransformer->Local2Global(detElemId, 0., 0., 0., x, y, z);
380 cout << " Global DE position: "
381 << x << ", " << y << ", " << z << endl;
152d6f4e 382
19e9826b 383 Double_t x2, y2, z2;
384 kModuleTransformer->Global2Local(detElemId, 0., 0., 0., x2, y2, z2);
385 cout << " ALIC center in the local frame: "
386 << x2 << ", " << y2 << ", " << z2 << endl;
387
388 Double_t x3, y3, z3;
389 kModuleTransformer->Global2Local(detElemId, x, y, z, x3, y3, z3);
390 cout << " Back in the local frame: "
391 << x3 << ", " << y3 << ", " << z3 << endl;
392 cout << endl;
58d53b65 393
19e9826b 394 AliMUONGeometryDetElement* detElem =
395 kModuleTransformer->GetDetElement(detElemId);
396 detElem->PrintGlobalTransform();
397 }
398 }
399}
58d53b65 400