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