]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONSt12QuadrantSegmentation.cxx
Added <assert.h> include
[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
9afdc733 24
e118b27e 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"
ab126d0a 32#include "AliMpSectorReader.h"
e118b27e 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
10bb087f 48const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.21;
e118b27e 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
ab126d0a 189 AliMpSectorReader r(fStationType, fPlaneType);
59090931 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
9eeaee6f 445 // Delete previous iterator
446 delete fSectorIterator;
447
e118b27e 448 fSectorIterator
449 = fSectorSegmentation
450 ->CreateIterator(AliMpArea(TVector2(fXhit/fgkLengthUnit, fYhit/fgkLengthUnit),
451 TVector2(dx/fgkLengthUnit, dy/fgkLengthUnit)));
452
453 fSectorIterator->First();
454
455 if (! fSectorIterator->IsDone())
456 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
457}
458
459//______________________________________________________________________________
460void AliMUONSt12QuadrantSegmentation::NextPad()
461{
462// Iterate over pads - stepper
463// ---
464
465 fSectorIterator->Next();
466
467 if (! fSectorIterator->IsDone())
468 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
469}
470
471//______________________________________________________________________________
472Int_t AliMUONSt12QuadrantSegmentation::MorePads()
473{
474// Iterate over pads - condition
475// ---
476
477 if (fSectorIterator->IsDone())
478 return 0;
479 else
480 return 1;
481}
482
483//______________________________________________________________________________
484Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
485 Float_t x, Float_t y, Int_t* /*dummy*/)
486{
487// Returns the square of the distance between 1 pad
488// labelled by its channel numbers and a coordinate
489// ---
490
491 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
492
493 if (!pad.IsValid())
494 AliFatal("Cannot locate pad.");
495
496 return (pad.Position()*fgkLengthUnit - TVector2(x, y)).Mod2();
497}
498
499//______________________________________________________________________________
500void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
501 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
502{
503// Number of pads read in parallel and offset to add to x
504// (specific to LYON, but mandatory for display)
505// ---
506
507 AliFatal( "Not yet implemented.");
508}
509
510
511//______________________________________________________________________________
512void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
513 Int_t* Nlist,
514 Int_t Xlist[10], Int_t Ylist[10])
515{
516// Get next neighbours
517// ---
518
519 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
520 Int_t &i = *Nlist;
521 i=0;
ddde88da 522 AliMpNeighboursPadIterator iter
523 = AliMpNeighboursPadIterator(fSectorSegmentation, pad, kFALSE);
e118b27e 524
ddde88da 525 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
526 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
527 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
e118b27e 528 i++;
529 }
e118b27e 530}
ddde88da 531
e118b27e 532//______________________________________________________________________________
533Int_t AliMUONSt12QuadrantSegmentation::Ix()
534{
535// Current pad cursor during disintegration
536// x, y-coordinate
537// ---
538
539 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
540}
541
542//______________________________________________________________________________
543Int_t AliMUONSt12QuadrantSegmentation::Iy()
544{
545// Current pad cursor during disintegration
546// x, y-coordinate
547// ---
548
549 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
550}
551
552//______________________________________________________________________________
553Int_t AliMUONSt12QuadrantSegmentation::ISector()
554{
555// Current sector
556// ---
557
558 return fZone;
559}
560
561//______________________________________________________________________________
562Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
563{
564// Calculate sector from pad coordinates
565// ---
566
567 return fSectorSegmentation
568 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
569}
570
571//______________________________________________________________________________
572Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
573{
574// Calculate sector from pad coordinates
575// ---
576
577 return fSectorSegmentation
578 ->Zone(fSectorSegmentation
579 ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit)));
580}
581
582//______________________________________________________________________________
583void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
584 Float_t& y1, Float_t& y2)
585{
586// Current integration limits
587// ---
588
589 x1 = fXhit - fX - Dpx(fZone)/2.;
590 x2 = x1 + Dpx(fZone);
591
592 y1 = fYhit - fY - Dpy(fZone)/2.;
593 y2 = y1 + Dpy(fZone);
594}
595
596//______________________________________________________________________________
597Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
598{
599// Signal Generation Condition during Stepping
600// 0: don't generate signal
601// 1: generate signal
602// Comments:
603//
604// Crossing of pad boundary and mid plane between neighbouring wires is checked.
605// To correctly simulate the dependence of the spatial resolution on the angle
606// of incidence signal must be generated for constant steps on
607// the projection of the trajectory along the anode wire.
608//
609// Signal will be generated if particle crosses pad boundary or
610// boundary between two wires.
611//
612// From AliMUONSegmentationV01
613// ---
614
615 Int_t ixt, iyt;
616 GetPadI(x, y, ixt, iyt);
617 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
618
619 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
620 return 1;
621 }
622 else {
623 return 0;
624 }
625}
626
e118b27e 627//______________________________________________________________________________
628void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
629{
630// Initialise signal generation at coord (x,y,z)
631// Initialises pad and wire position during stepping.
632// From AliMUONSegmentationV01
633// ---
634
635 fXt = x;
636 fYt = y;
637 GetPadI(x, y, fIxt, fIyt);
638 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
639}
640
641//______________________________________________________________________________
642void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
643{
644// Test points for auto calibration
645// Returns test point on the pad plane.
646// Used during determination of the segmoid correction of the COG-method
647// From AliMUONSegmentationV01
648// ---
649
650 n=1;
651 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
652 y[0] = x[0];
653}
654
655//______________________________________________________________________________
656void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
657{
658// Draw the segmentation zones.
659// (Called from AliMUON::BuildGeometry)
660// ---
661
662 AliWarning("Not yet implemented.");
663}
664
665//______________________________________________________________________________
666void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
667{
668// Set the correction function.
669// From AliMUONSegmentationV01
670// ---
671
672 fCorrA->AddAt(func, isec);
673}
674
675//______________________________________________________________________________
676TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
677{
678// Get the correction Function.
679// From AliMUONSegmentationV01
680// ---
681
682 return (TF1*) fCorrA->At(isec);
683}
684
59090931 685//______________________________________________________________________________
686void AliMUONSt12QuadrantSegmentation::Streamer(TBuffer &R__b)
687{
688// Stream an object of class AliMUONSt12QuadrantSegmentation.
689
690 if (R__b.IsReading()) {
691 AliMUONSt12QuadrantSegmentation::Class()->ReadBuffer(R__b, this);
692 ReadMappingData();
693 }
694 else {
695 AliMUONSt12QuadrantSegmentation::Class()->WriteBuffer(R__b, this);
696 }
697}
698
699