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 **************************************************************************/
18 // Class AliMUONSt12QuadrantSegmentation
19 // -------------------------------------
20 // Segmentation for MUON quadrants of stations 1 and 2 using
21 // the mapping package
23 // Author: Ivana Hrivnacova, IPN Orsay
27 #include <TObjArray.h>
34 #include "AliMpArea.h"
35 #include "AliMpSectorReader.h"
36 #include "AliMpSector.h"
37 #include "AliMpVPadIterator.h"
38 #include "AliMpSectorSegmentation.h"
39 #include "AliMpFiles.h"
40 #include "AliMpNeighboursPadIterator.h"
42 #include "AliMUONSt12QuadrantSegmentation.h"
43 #include "AliMUONConstants.h"
45 ClassImp(AliMUONSt12QuadrantSegmentation)
47 const Float_t AliMUONSt12QuadrantSegmentation::fgkWireD = 0.21;
49 //______________________________________________________________________________
50 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
51 AliMpStationType stationType,
52 AliMpPlaneType planeType)
53 : AliMUONVGeometryDESegmentation(),
54 fStationType(stationType),
55 fPlaneType(planeType),
57 fSectorSegmentation(0),
83 fCorrA = new TObjArray(3);
88 AliDebug(1, Form("ctor this = %p", this) );
91 //______________________________________________________________________________
92 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
93 : AliMUONVGeometryDESegmentation(),
94 fStationType(kStation1),
95 fPlaneType(kBendingPlane),
97 fSectorSegmentation(0),
118 // Default Constructor
120 AliDebug(1, Form("default (empty) ctor this = %p", this));
123 //______________________________________________________________________________
124 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs)
125 : AliMUONVGeometryDESegmentation(rhs)
128 AliFatal("Copy constructor is not implemented.");
131 //______________________________________________________________________________
132 AliMUONSt12QuadrantSegmentation::~AliMUONSt12QuadrantSegmentation() {
135 AliDebug(1, Form("dtor this = %p", this));
138 delete fSectorSegmentation;
139 delete fSectorIterator;
146 //______________________________________________________________________________
147 AliMUONSt12QuadrantSegmentation&
148 AliMUONSt12QuadrantSegmentation::operator=(const AliMUONSt12QuadrantSegmentation& rhs)
152 // check assignement to self
153 if (this == &rhs) return *this;
155 AliFatal("Assignment operator is not implemented.");
164 //______________________________________________________________________________
165 void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad)
167 // Updates current pad values.
170 fIx = pad.GetIndices().GetFirst();
171 fIy = pad.GetIndices().GetSecond();
172 fX = pad.Position().X();
173 fY = pad.Position().Y();
174 fZone = fSectorSegmentation->Zone(pad);
178 //______________________________________________________________________________
179 void AliMUONSt12QuadrantSegmentation::ReadMappingData()
181 // Reads mapping data
184 // set path to mapping data files
185 if (!gSystem->Getenv("MINSTALL")) {
186 TString dirPath = gSystem->Getenv("ALICE_ROOT");
187 dirPath += "/MUON/mapping";
188 AliMpFiles::SetTopPath(dirPath);
189 gSystem->Setenv("MINSTALL", dirPath.Data());
190 //cout << "AliMpFiles top path set to " << dirPath << endl;
193 AliMpSectorReader r(fStationType, fPlaneType);
194 fSector = r.BuildSector();
195 fSectorSegmentation = new AliMpSectorSegmentation(fSector);
202 //______________________________________________________________________________
203 void AliMUONSt12QuadrantSegmentation::SetPadSize(Float_t /*p1*/, Float_t /*p2*/)
205 // Set pad size Dx*Dy
208 AliFatal("Not uniform pad size.");
211 //______________________________________________________________________________
212 void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
220 #include "AliMpMotifMap.h"
221 //______________________________________________________________________________
222 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
224 // Returns true if a pad exists in the given position
226 // fSector->GetMotifMap()->Print();
228 AliMpPad pad = fSectorSegmentation
229 ->PadByPosition(TVector2(x,y), false);
231 return pad.IsValid();
235 //______________________________________________________________________________
236 Bool_t AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
238 // Returns true if a pad with given indices exists
240 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
242 return pad.IsValid();
246 //______________________________________________________________________________
247 AliMUONGeometryDirection AliMUONSt12QuadrantSegmentation::GetDirection()
249 // Returns the direction with a constant pad size
250 // (Direction or coordinate where the resolution is the best)
252 switch ( fSector->GetDirection() ) {
253 case kX: return kDirX;
254 case kY: return kDirY;
255 default: return kDirUndefined;
259 //______________________________________________________________________________
260 const AliMpVSegmentation*
261 AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
263 // Returns the mapping segmentation
264 // (provides access to electronics info)
266 return fSectorSegmentation;
269 //______________________________________________________________________________
270 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
272 // Anod wire coordinate closest to xhit
273 // Returns for a hit position xhit the position of the nearest anode wire
274 // From AliMUONSegmentationV01.
277 Float_t wire= (xhit>0) ? Int_t(xhit/fWireD) + 0.5
278 : Int_t(xhit/fWireD) - 0.5;
283 //______________________________________________________________________________
284 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y, Float_t /*z*/,
285 Int_t& ix, Int_t& iy)
287 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
290 GetPadI(x, y, ix, iy);
293 //______________________________________________________________________________
294 void AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
295 Int_t& ix, Int_t& iy)
297 // Returns pad coordinates (ix,iy) for given real coordinates (x,y)
298 // If there is no pad, ix = 0, iy = 0 are returned.
301 AliMpPad pad = fSectorSegmentation->PadByPosition(TVector2(x,y), true);
303 ix = pad.GetIndices().GetFirst();
304 iy = pad.GetIndices().GetSecond();
307 //______________________________________________________________________________
308 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
309 Float_t& x, Float_t& y, Float_t& z)
311 // Transform from pad to real coordinates
315 GetPadC(ix, iy, x , y);
318 //______________________________________________________________________________
319 void AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
320 Float_t& x, Float_t& y)
322 // Transform from pad to real coordinates
323 // If there is no pad, x = 0., y = 0. are returned.
326 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
328 x = pad.Position().X();
329 y = pad.Position().Y();
333 //______________________________________________________________________________
334 void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
336 // Initialize segmentation
339 // find Npx, Npy and save this info
341 // reference to chamber
342 fRmin=AliMUONConstants::Rmin(0);
343 fRmax=AliMUONConstants::Rmax(0);
348 //______________________________________________________________________________
349 Float_t AliMUONSt12QuadrantSegmentation::Dpx() const
354 AliFatal( "Not uniform pad size.");
358 //______________________________________________________________________________
359 Float_t AliMUONSt12QuadrantSegmentation::Dpy() const
364 AliFatal("Not uniform pad size.");
368 //______________________________________________________________________________
369 Float_t AliMUONSt12QuadrantSegmentation::Dpx(Int_t isector) const
371 // Pad size in x by sector
374 return fSectorSegmentation->PadDimensions(isector).X()*2.0;
377 //______________________________________________________________________________
378 Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
380 // Pad size in x, y by Sector
383 return fSectorSegmentation->PadDimensions(isector).Y()*2.0;
386 //______________________________________________________________________________
387 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
389 // Maximum number of Pads in x
390 // hard coded for the time being
393 return fSectorSegmentation->MaxPadIndexX();
396 //______________________________________________________________________________
397 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
399 // Maximum number of Pads in y
400 // hard coded for the time being
403 return fSectorSegmentation->MaxPadIndexY();
406 //______________________________________________________________________________
407 void AliMUONSt12QuadrantSegmentation::SetPad(Int_t ix, Int_t iy)
410 // Sets virtual pad coordinates, needed for evaluating pad response
411 // outside the tracking program.
412 // From AliMUONSegmentationV01.
415 GetPadC(ix, iy, fX, fY);
416 fZone = Sector(ix, iy);
419 //______________________________________________________________________________
420 void AliMUONSt12QuadrantSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
423 // Sets virtual hit position, needed for evaluating pad response
424 // outside the tracking program
425 // From AliMUONSegmentationV01.
431 //______________________________________________________________________________
432 void AliMUONSt12QuadrantSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/,
433 Float_t dx, Float_t dy)
435 // Iterate over pads - initialiser
438 // Sets the current pad to that located in the hit position
440 SetHit(GetAnod(xhit), yhit, 0.);
442 // Enable iterating in one dimension
443 if (dx == 0.) dx = 0.01;
444 if (dy == 0.) dy = 0.01;
446 // Delete previous iterator
447 delete fSectorIterator;
450 = fSectorSegmentation
451 ->CreateIterator(AliMpArea(TVector2(fXhit,fYhit),TVector2(dx,dy)));
453 AliDebug(1,Form("CreateIterator area=%e,%e +- %e,%e %s",
454 fXhit,fYhit,dx,dy,PlaneTypeName(fPlaneType)));
456 fSectorIterator->First();
458 if (! fSectorIterator->IsDone())
459 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
462 //______________________________________________________________________________
463 void AliMUONSt12QuadrantSegmentation::NextPad()
465 // Iterate over pads - stepper
468 fSectorIterator->Next();
470 if (! fSectorIterator->IsDone())
471 UpdateCurrentPadValues(fSectorIterator->CurrentItem());
474 //______________________________________________________________________________
475 Int_t AliMUONSt12QuadrantSegmentation::MorePads()
477 // Iterate over pads - condition
480 if (fSectorIterator->IsDone())
486 //______________________________________________________________________________
487 Float_t AliMUONSt12QuadrantSegmentation::Distance2AndOffset(Int_t iX, Int_t iY,
488 Float_t x, Float_t y, Int_t* /*dummy*/)
490 // Returns the square of the distance between 1 pad
491 // labelled by its channel numbers and a coordinate
494 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX, iY));
497 AliFatal("Cannot locate pad.");
499 return (pad.Position() - TVector2(x, y)).Mod2();
502 //______________________________________________________________________________
503 void AliMUONSt12QuadrantSegmentation::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/,
504 Int_t* /*Nparallel*/, Int_t* /*Offset*/)
506 // Number of pads read in parallel and offset to add to x
507 // (specific to LYON, but mandatory for display)
510 AliFatal( "Not yet implemented.");
514 //______________________________________________________________________________
515 void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
517 Int_t Xlist[10], Int_t Ylist[10])
519 // Get next neighbours
522 AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
525 AliMpNeighboursPadIterator iter
526 = AliMpNeighboursPadIterator(fSectorSegmentation, pad, kFALSE);
528 for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
529 Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
530 Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
535 //______________________________________________________________________________
536 Int_t AliMUONSt12QuadrantSegmentation::Ix()
538 // Current pad cursor during disintegration
542 return fSectorIterator->CurrentItem().GetIndices().GetFirst();
545 //______________________________________________________________________________
546 Int_t AliMUONSt12QuadrantSegmentation::Iy()
548 // Current pad cursor during disintegration
552 return fSectorIterator->CurrentItem().GetIndices().GetSecond();
555 //______________________________________________________________________________
556 Int_t AliMUONSt12QuadrantSegmentation::ISector()
564 //______________________________________________________________________________
565 Int_t AliMUONSt12QuadrantSegmentation::Sector(Int_t ix, Int_t iy)
567 // Calculate sector from pad coordinates
570 return fSectorSegmentation
571 ->Zone(fSectorSegmentation->PadByIndices(AliMpIntPair(ix, iy)));
574 //______________________________________________________________________________
575 Int_t AliMUONSt12QuadrantSegmentation::Sector(Float_t x, Float_t y)
577 // Calculate sector from pad coordinates
580 return fSectorSegmentation
581 ->Zone(fSectorSegmentation
582 ->PadByPosition(TVector2(x,y)));
585 //______________________________________________________________________________
586 void AliMUONSt12QuadrantSegmentation::IntegrationLimits(Float_t& x1, Float_t& x2,
587 Float_t& y1, Float_t& y2)
589 // Current integration limits
592 x1 = fXhit - fX - Dpx(fZone)/2.;
593 x2 = x1 + Dpx(fZone);
595 y1 = fYhit - fY - Dpy(fZone)/2.;
596 y2 = y1 + Dpy(fZone);
599 //______________________________________________________________________________
600 Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t /*z*/)
602 // Signal Generation Condition during Stepping
603 // 0: don't generate signal
604 // 1: generate signal
607 // Crossing of pad boundary and mid plane between neighbouring wires is checked.
608 // To correctly simulate the dependence of the spatial resolution on the angle
609 // of incidence signal must be generated for constant steps on
610 // the projection of the trajectory along the anode wire.
612 // Signal will be generated if particle crosses pad boundary or
613 // boundary between two wires.
615 // From AliMUONSegmentationV01
619 GetPadI(x, y, ixt, iyt);
620 Int_t iwt=(x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1;
622 if ((ixt != fIxt) || (iyt !=fIyt) || (iwt != fIwt)) {
630 //______________________________________________________________________________
631 void AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
633 // Initialise signal generation at coord (x,y,z)
634 // Initialises pad and wire position during stepping.
635 // From AliMUONSegmentationV01
640 GetPadI(x, y, fIxt, fIyt);
641 fIwt = (x>0) ? Int_t(x/fWireD)+1 : Int_t(x/fWireD)-1 ;
644 //______________________________________________________________________________
645 void AliMUONSt12QuadrantSegmentation::GiveTestPoints(Int_t& n, Float_t* x, Float_t* y) const
647 // Test points for auto calibration
648 // Returns test point on the pad plane.
649 // Used during determination of the segmoid correction of the COG-method
650 // From AliMUONSegmentationV01
654 x[0] = (fRmax+fRmin)/2/TMath::Sqrt(2.);
658 //______________________________________________________________________________
659 void AliMUONSt12QuadrantSegmentation::Draw(const char * /*opt*/)
661 // Draw the segmentation zones.
662 // (Called from AliMUON::BuildGeometry)
665 AliWarning("Not yet implemented.");
668 //______________________________________________________________________________
669 void AliMUONSt12QuadrantSegmentation::SetCorrFunc(Int_t isec, TF1* func)
671 // Set the correction function.
672 // From AliMUONSegmentationV01
675 fCorrA->AddAt(func, isec);
678 //______________________________________________________________________________
679 TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
681 // Get the correction Function.
682 // From AliMUONSegmentationV01
685 return (TF1*) fCorrA->At(isec);
688 //______________________________________________________________________________
689 void AliMUONSt12QuadrantSegmentation::Streamer(TBuffer &R__b)
691 // Stream an object of class AliMUONSt12QuadrantSegmentation.
693 if (R__b.IsReading()) {
694 AliMUONSt12QuadrantSegmentation::Class()->ReadBuffer(R__b, this);
698 AliMUONSt12QuadrantSegmentation::Class()->WriteBuffer(R__b, this);