]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt12QuadrantSegmentation.cxx
Right cathode numbering (Christian)
[u/mrichter/AliRoot.git] / MUON / AliMUONSt12QuadrantSegmentation.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
18// Class AliMUONSt12QuadrantSegmentation
19// -------------------------------------
20// Segmentation for MUON quadrants of stations 1 and 2 using
21// the mapping package
22//
23// Author: Ivana Hrivnacova, IPN Orsay
24
25#include <TError.h>
26#include <TF1.h>
27#include <TObjArray.h>
28#include <TVector2.h>
29
30#include "AliMpPad.h"
31#include "AliMpArea.h"
32#include "AliMpReader.h"
33#include "AliMpSector.h"
34#include "AliMpVPadIterator.h"
35#include "AliMpSectorSegmentation.h"
36
37#include "AliMUONSt12QuadrantSegmentation.h"
38#include "AliRun.h"
39#include "AliMUON.h"
40#include "AliMUONChamber.h"
41#include "AliLog.h"
a713db22 42#include "AliMpFiles.h"
43#include <TSystem.h>
e118b27e 44
45ClassImp(AliMUONSt12QuadrantSegmentation)
46
47const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.20;
48const Float_t AliMUONSt12QuadrantSegmentation::fgkLengthUnit = 0.1;
49
50//______________________________________________________________________________
51AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
52 AliMpStationType stationType,
53 AliMpPlaneType planeType)
e0a49962 54: AliMUONVGeometryDESegmentation(),
59090931 55 fStationType(stationType),
56 fPlaneType(planeType),
e118b27e 57 fSector(0),
58 fSectorSegmentation(0),
59 fSectorIterator(0),
60 fWireD(fgkWireD),
61 fChamber(0),
62 fId(0),
63 fRmin(0.),
64 fRmax(0.),
65 fZ(0.),
66 fIx(0),
67 fIy(0),
68 fX(0.),
69 fY(0.),
70 fZone(0),
71 fXhit(0.),
72 fYhit(0.),
73 fIxt(0),
74 fIyt(0),
75 fIwt(0),
76 fXt(0.),
77 fYt(0.),
78 fCorrA(0)
79{
80// Normal constructor
a713db22 81
59090931 82 ReadMappingData();
e118b27e 83
84 fCorrA = new TObjArray(3);
85 fCorrA->AddAt(0,0);
86 fCorrA->AddAt(0,1);
87 fCorrA->AddAt(0,2);
88}
89
90//______________________________________________________________________________
91AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
e0a49962 92: AliMUONVGeometryDESegmentation(),
59090931 93 fStationType(kStation1),
94 fPlaneType(kBendingPlane),
e118b27e 95 fSector(0),
96 fSectorSegmentation(0),
97 fSectorIterator(0),
98 fWireD(fgkWireD),
99 fChamber(0),
100 fId(0),
101 fRmin(0.),
102 fRmax(0.),
103 fZ(0.),
104 fIx(0),
105 fIy(0),
106 fX(0.),
107 fY(0.),
108 fZone(0),
109 fXhit(0.),
110 fYhit(0.),
111 fIxt(0),
112 fIyt(0),
113 fIwt(0),
114 fXt(0.),
115 fYt(0.),
116 fCorrA(0) {
117// Default Constructor
118}
119
120//______________________________________________________________________________
121AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs)
e0a49962 122 : AliMUONVGeometryDESegmentation(rhs)
e118b27e 123{
124// Copy constructor
125 AliFatal("Copy constructor is not implemented.");
126}
127
128//______________________________________________________________________________
129AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation() {
130// Destructor
131
132 delete fSector;
133 delete fSectorSegmentation;
134 delete fSectorIterator;
135}
136
137//
138// operators
139//
140
141//______________________________________________________________________________
142AliMUONSt12QuadrantSegmentation&
143AliMUONSt12QuadrantSegmentation::operator=(const AliMUONSt12QuadrantSegmentation& rhs)
144{
145// Copy operator
146
147 // check assignement to self
148 if (this == &rhs) return *this;
149
150 AliFatal("Assignment operator is not implemented.");
151
152 return *this;
153}
154
155//
156// private methods
157//
158
159//______________________________________________________________________________
160void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
161{
162// Updates current pad values.
163// ---
164
165 fIx = pad.GetIndices().GetFirst();
166 fIy = pad.GetIndices().GetSecond();
167 fX = pad.Position().X() * fgkLengthUnit;
168 fY = pad.Position().Y() * fgkLengthUnit;
169 fZone = fSectorSegmentation->Zone(pad);
170}
171
59090931 172
173//______________________________________________________________________________
174void AliMUONSt12QuadrantSegmentation::ReadMappingData()
175{
176// Reads mapping data
177// ---
178
179 // set path to mapping data files
180 if (!gSystem->Getenv("MINSTALL")) {
181 TString dirPath = gSystem->Getenv("ALICE_ROOT");
182 dirPath += "/MUON/mapping";
183 AliMpFiles::Instance()->SetTopPath(dirPath);
184 gSystem->Setenv("MINSTALL", dirPath.Data());
185 //cout << "AliMpFiles top path set to " << dirPath << endl;
186 }
187
188 AliMpReader r(fStationType, fPlaneType);
189 fSector = r.BuildSector();
190 fSectorSegmentation = new AliMpSectorSegmentation(fSector);
191}
192
e118b27e 193//
194// public methods
195//
196
197//______________________________________________________________________________
198void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
199{
200// Set pad size Dx*Dy
201// ---
202
203 AliFatal("Not uniform pad size.");
204}
205
206//______________________________________________________________________________
207void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
208{
209// Set anod pitch
210// ---
211
212 fWireD = d;
213}
214
59090931 215#include "AliMpMotifMap.h"
e0a49962 216//______________________________________________________________________________
217Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
218{
219// Returns true if a pad exists in the given position
220
59090931 221 // fSector->GetMotifMap()->Print();
222
e0a49962 223 AliMpPad pad = fSectorSegmentation
224 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
225
226 return pad.IsValid();
227}
228
229
230//______________________________________________________________________________
231Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
232{
233// Returns true if a pad with given indices exists
234
235 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
236
237 return pad.IsValid();
238}
239
240
6b1e4b22 241//______________________________________________________________________________
242AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
243{
e9981d13 244// Returns the direction with a constant pad size
245// (Direction or coordinate where the resolution is the best)
6b1e4b22 246
247 switch ( fSector->GetDirection() ) {
248 case kX: return kDirX;
249 case kY: return kDirY;
250 default: return kDirUndefined;
251 }
252}
253
e118b27e 254//______________________________________________________________________________
255Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
256{
257// Anod wire coordinate closest to xhit
258// Returns for a hit position xhit the position of the nearest anode wire
259// From AliMUONSegmentationV01.
260// ---
261
262 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
263 : Int_t(xhit/fWireD) - 0.5;
264 return fWireD*wire;
265
266}
267
268//______________________________________________________________________________
269void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
270 Int_t& ix, Int_t& iy)
271{
272// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
273// ---
274
275 GetPadI(x, y, ix, iy);
276}
277
278//______________________________________________________________________________
279void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
280 Int_t& ix, Int_t& iy)
281{
282// Returns pad coordinates (ix,iy) for given real coordinates (x,y)
283// If there is no pad, ix = 0, iy = 0 are returned.
284// ---
285
286 AliMpPad pad = fSectorSegmentation
e0a49962 287 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), true);
e118b27e 288
289 ix = pad.GetIndices().GetFirst();
290 iy = pad.GetIndices().GetSecond();
291}
292
293//______________________________________________________________________________
294void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
295 Float_t& x, Float_t& y, Float_t& z)
296{
297// Transform from pad to real coordinates
298// ---
299
300 z = fZ;
301 GetPadC(ix, iy, x , y);
302}
303
304//______________________________________________________________________________
305void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
306 Float_t& x, Float_t& y)
307{
308// Transform from pad to real coordinates
309// If there is no pad, x = 0., y = 0. are returned.
310// ---
311
e0a49962 312 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
e118b27e 313
314 x = pad.Position().X() * fgkLengthUnit;
315 y = pad.Position().Y() * fgkLengthUnit;
316}
317
318
319//______________________________________________________________________________
320void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
321{
322// Initialize segmentation
323// ---
324
59090931 325 // find Npx, Npy and save this info
e118b27e 326
327 // reference to chamber
328 AliMUON *pMUON = (AliMUON *) gAlice->GetModule("MUON");
329 fChamber = &(pMUON->Chamber(chamber));
330 fRmin=fChamber->RInner();
331 fRmax=fChamber->ROuter();
332 fZ = 0;
333 fId=chamber;
334}
335
336//______________________________________________________________________________
337Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
338{
339// Get pad size in x
340// ---
341
342 AliFatal( "Not uniform pad size.");
343 return 0.;
344}
345
346//______________________________________________________________________________
347Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
348{
349// Get pad size in y
350// ---
351
352 AliFatal("Not uniform pad size.");
353 return 0.;
354}
355
356//______________________________________________________________________________
357Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
358{
359// Pad size in x by sector
360// ---
361
362 return fSectorSegmentation->PadDimensions(isector).X()*2.*fgkLengthUnit;
363}
364
365//______________________________________________________________________________
366Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
367{
368// Pad size in x, y by Sector
369// ---
370
371 return fSectorSegmentation->PadDimensions(isector).Y()*2.*fgkLengthUnit;
372}
373
374//______________________________________________________________________________
375Int_t AliMUONSt12QuadrantSegmentation::Npx() const
376{
377// Maximum number of Pads in x
e0a49962 378// hard coded for the time being
e118b27e 379// ---
380
381 //Fatal("Npx", "Not yet implemented.");
e0a49962 382 switch (fSector->GetDirection()) {
383 case kX:
384 return 142;
385 case kY:
386 return 108;
387 default:
388 AliError("Unknown sector direction");
389 return 0;
390 }
e118b27e 391}
392
393//______________________________________________________________________________
394Int_t AliMUONSt12QuadrantSegmentation::Npy() const
395{
396// Maximum number of Pads in y
e0a49962 397// hard coded for the time being
e118b27e 398// ---
399
400 //Fatal("Npy", "Not yet implemented.");
e0a49962 401 switch (fSector->GetDirection()) {
402 case kX:
403 return 160;
404 case kY:
405 return 213;
406 default:
407 AliError("Unknown sector direction");
408 return 0;
409 }
e118b27e 410}
411
412//______________________________________________________________________________
413void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
414{
415// Set pad position.
416// Sets virtual pad coordinates, needed for evaluating pad response
417// outside the tracking program.
418// From AliMUONSegmentationV01.
419// ---
420
421 GetPadC(ix, iy, fX, fY);
422 fZone = Sector(ix, iy);
423}
424
425//______________________________________________________________________________
426void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
427{
428// Set hit position
429// Sets virtual hit position, needed for evaluating pad response
430// outside the tracking program
431// From AliMUONSegmentationV01.
432
433 fXhit = xhit;
434 fYhit = yhit;
435}
436
437//______________________________________________________________________________
438void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
439 Float_t dx, Float_t dy)
440{
441// Iterate over pads - initialiser
442// ---
443
444 // Sets the current pad to that located in the hit position
445
446 SetHit(GetAnod(xhit), yhit, 0.);
447
448 // Enable iterating in one dimension
449 if (dx == 0.) dx = 0.01;
450 if (dy == 0.) dy = 0.01;
451
452 fSectorIterator
453 = fSectorSegmentation
454 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
455 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
456
457 fSectorIterator->First();
458
459 if (! fSectorIterator->IsDone())
460 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
461}
462
463//______________________________________________________________________________
464void AliMUONSt12QuadrantSegmentation::NextPad()
465{
466// Iterate over pads - stepper
467// ---
468
469 fSectorIterator->Next();
470
471 if (! fSectorIterator->IsDone())
472 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
473}
474
475//______________________________________________________________________________
476Int_t AliMUONSt12QuadrantSegmentation::MorePads()
477{
478// Iterate over pads - condition
479// ---
480
481 if (fSectorIterator->IsDone())
482 return 0;
483 else
484 return 1;
485}
486
487//______________________________________________________________________________
488Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
489 Float_t x, Float_t y, Int_t* /*dummy*/)
490{
491// Returns the square of the distance between 1 pad
492// labelled by its channel numbers and a coordinate
493// ---
494
495 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
496
497 if (!pad.IsValid())
498 AliFatal("Cannot locate pad.");
499
500 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
501}
502
503//______________________________________________________________________________
504void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
505 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
506{
507// Number of pads read in parallel and offset to add to x
508// (specific to LYON, but mandatory for display)
509// ---
510
511 AliFatal( "Not yet implemented.");
512}
513
514
515//______________________________________________________________________________
516void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
517 Int_t* Nlist,
518 Int_t Xlist[10], Int_t Ylist[10])
519{
520// Get next neighbours
521// ---
522
523 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
524 Int_t &i = *Nlist;
525 i=0;
526 AliMpVPadIterator* iter
527 = fSectorSegmentation
528 ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
529
530 for( iter->First(); !iter->IsDone() && i<10; iter->Next()) {
531 Xlist[i] = iter->CurrentItem().GetIndices().GetFirst();
532 Ylist[i] = iter->CurrentItem().GetIndices().GetSecond();
533 i++;
534 }
535
536 delete iter;
537}
538
539//______________________________________________________________________________
540Int_t AliMUONSt12QuadrantSegmentation::Ix()
541{
542// Current pad cursor during disintegration
543// x, y-coordinate
544// ---
545
546 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
547}
548
549//______________________________________________________________________________
550Int_t AliMUONSt12QuadrantSegmentation::Iy()
551{
552// Current pad cursor during disintegration
553// x, y-coordinate
554// ---
555
556 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
557}
558
559//______________________________________________________________________________
560Int_t AliMUONSt12QuadrantSegmentation::ISector()
561{
562// Current sector
563// ---
564
565 return fZone;
566}
567
568//______________________________________________________________________________
569Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
570{
571// Calculate sector from pad coordinates
572// ---
573
574 return fSectorSegmentation
575 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
576}
577
578//______________________________________________________________________________
579Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
580{
581// Calculate sector from pad coordinates
582// ---
583
584 return fSectorSegmentation
585 ->Zone(fSectorSegmentation
586 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
587}
588
589//______________________________________________________________________________
590void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
591 Float_t& y1, Float_t& y2)
592{
593// Current integration limits
594// ---
595
596 x1 = fXhit - fX - Dpx(fZone)/2.;
597 x2 = x1 + Dpx(fZone);
598
599 y1 = fYhit - fY - Dpy(fZone)/2.;
600 y2 = y1 + Dpy(fZone);
601}
602
603//______________________________________________________________________________
604Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
605{
606// Signal Generation Condition during Stepping
607// 0: don't generate signal
608// 1: generate signal
609// Comments:
610//
611// Crossing of pad boundary and mid plane between neighbouring wires is checked.
612// To correctly simulate the dependence of the spatial resolution on the angle
613// of incidence signal must be generated for constant steps on
614// the projection of the trajectory along the anode wire.
615//
616// Signal will be generated if particle crosses pad boundary or
617// boundary between two wires.
618//
619// From AliMUONSegmentationV01
620// ---
621
622 Int_t ixt, iyt;
623 GetPadI(x, y, ixt, iyt);
624 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
625
626 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
627 return 1;
628 }
629 else {
630 return 0;
631 }
632}
633
e118b27e 634//______________________________________________________________________________
635void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
636{
637// Initialise signal generation at coord (x,y,z)
638// Initialises pad and wire position during stepping.
639// From AliMUONSegmentationV01
640// ---
641
642 fXt = x;
643 fYt = y;
644 GetPadI(x, y, fIxt, fIyt);
645 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
646}
647
648//______________________________________________________________________________
649void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
650{
651// Test points for auto calibration
652// Returns test point on the pad plane.
653// Used during determination of the segmoid correction of the COG-method
654// From AliMUONSegmentationV01
655// ---
656
657 n=1;
658 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
659 y[0] = x[0];
660}
661
662//______________________________________________________________________________
663void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
664{
665// Draw the segmentation zones.
666// (Called from AliMUON::BuildGeometry)
667// ---
668
669 AliWarning("Not yet implemented.");
670}
671
672//______________________________________________________________________________
673void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
674{
675// Set the correction function.
676// From AliMUONSegmentationV01
677// ---
678
679 fCorrA->AddAt(func, isec);
680}
681
682//______________________________________________________________________________
683TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
684{
685// Get the correction Function.
686// From AliMUONSegmentationV01
687// ---
688
689 return (TF1*) fCorrA->At(isec);
690}
691
59090931 692//______________________________________________________________________________
693void AliMUONSt12QuadrantSegmentation::Streamer(TBuffer &R__b)
694{
695// Stream an object of class AliMUONSt12QuadrantSegmentation.
696
697 if (R__b.IsReading()) {
698 AliMUONSt12QuadrantSegmentation::Class()->ReadBuffer(R__b, this);
699 ReadMappingData();
700 }
701 else {
702 AliMUONSt12QuadrantSegmentation::Class()->WriteBuffer(R__b, this);
703 }
704}
705
706