]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSt12QuadrantSegmentation.cxx
From Laurent:
[u/mrichter/AliRoot.git] / MUON / AliMUONSt12QuadrantSegmentation.cxx
index 98a3a9c58e3c5ca22fb9161f08d163397bb923d0..201fb3ec578620c74481d2ea1d157bce1b2c3b0b 100644 (file)
@@ -21,7 +21,7 @@
 // the mapping package
 //
 // Author: Ivana Hrivnacova, IPN Orsay
-
 #include <TError.h>
 #include <TF1.h>
 #include <TObjArray.h>
@@ -29,7 +29,7 @@
 
 #include "AliMpPad.h"
 #include "AliMpArea.h"
-#include "AliMpReader.h"
+#include "AliMpSectorReader.h"
 #include "AliMpSector.h"
 #include "AliMpVPadIterator.h"
 #include "AliMpSectorSegmentation.h"
 #include "AliMUON.h"
 #include "AliMUONChamber.h"
 #include "AliLog.h"
+#include "AliMpFiles.h"
+#include "AliMpNeighboursPadIterator.h"
+#include <TSystem.h>
 
 ClassImp(AliMUONSt12QuadrantSegmentation)
 
-const Float_t  AliMUONSt12QuadrantSegmentation::fgkWireD = 0.20
+const Float_t  AliMUONSt12QuadrantSegmentation::fgkWireD = 0.21
 const Float_t  AliMUONSt12QuadrantSegmentation::fgkLengthUnit = 0.1; 
 
 //______________________________________________________________________________
 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
                                        AliMpStationType stationType,
                                       AliMpPlaneType planeType) 
-: AliSegmentation(),
+: AliMUONVGeometryDESegmentation(),
+  fStationType(stationType),
+  fPlaneType(planeType),
   fSector(0),
   fSectorSegmentation(0),
   fSectorIterator(0),
@@ -74,10 +79,8 @@ AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
   fCorrA(0)
 {
 // Normal constructor
-  
-  AliMpReader r(stationType, planeType);
-  fSector = r.BuildSector();
-  fSectorSegmentation = new AliMpSectorSegmentation(fSector);
+
+  ReadMappingData();
 
   fCorrA = new TObjArray(3);
   fCorrA->AddAt(0,0);
@@ -87,7 +90,9 @@ AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
 
 //______________________________________________________________________________
 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation() 
-: AliSegmentation(),
+: AliMUONVGeometryDESegmentation(),
+  fStationType(kStation1),
+  fPlaneType(kBendingPlane),
   fSector(0),
   fSectorSegmentation(0),
   fSectorIterator(0),
@@ -115,7 +120,7 @@ AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation()
 
 //______________________________________________________________________________
 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(const AliMUONSt12QuadrantSegmentation& rhs) 
-  : AliSegmentation(rhs)
+  : AliMUONVGeometryDESegmentation(rhs)
 {
 // Copy constructor
   AliFatal("Copy constructor is not implemented.");
@@ -165,6 +170,27 @@ void AliMUONSt12QuadrantSegmentation::UpdateCurrentPadValues(const AliMpPad& pad
   fZone = fSectorSegmentation->Zone(pad);
 }  
 
+
+//______________________________________________________________________________
+void AliMUONSt12QuadrantSegmentation::ReadMappingData()
+{
+// Reads mapping data
+// ---
+
+  // set path to mapping data files
+   if (!gSystem->Getenv("MINSTALL")) {    
+     TString dirPath = gSystem->Getenv("ALICE_ROOT");
+     dirPath += "/MUON/mapping"; 
+     AliMpFiles::Instance()->SetTopPath(dirPath);
+     gSystem->Setenv("MINSTALL", dirPath.Data());
+     //cout << "AliMpFiles top path set to " << dirPath << endl;         
+   }
+  
+  AliMpSectorReader r(fStationType, fPlaneType);
+  fSector = r.BuildSector();
+  fSectorSegmentation = new AliMpSectorSegmentation(fSector);
+}
+
 //
 // public methods
 //
@@ -187,6 +213,55 @@ void AliMUONSt12QuadrantSegmentation::SetDAnod(Float_t d)
   fWireD = d;
 }
 
+#include "AliMpMotifMap.h"
+//______________________________________________________________________________
+Bool_t  AliMUONSt12QuadrantSegmentation::HasPad(Float_t x, Float_t y, Float_t /*z*/)
+{ 
+// Returns true if a pad exists in the given position
+
+  // fSector->GetMotifMap()->Print();
+
+  AliMpPad pad = fSectorSegmentation
+               ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
+
+  return pad.IsValid();
+}  
+
+
+//______________________________________________________________________________
+Bool_t  AliMUONSt12QuadrantSegmentation::HasPad(Int_t ix, Int_t iy)
+{
+// Returns true if a pad with given indices exists
+
+  AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), false);
+
+  return pad.IsValid();
+}  
+
+
+//______________________________________________________________________________
+AliMUONGeometryDirection  AliMUONSt12QuadrantSegmentation::GetDirection()
+{
+// Returns the direction with a constant pad size  
+// (Direction or coordinate where the resolution is the best)
+
+  switch ( fSector->GetDirection() ) {
+    case kX: return kDirX;
+    case kY: return kDirY;
+    default: return kDirUndefined;
+  }  
+}  
+
+//______________________________________________________________________________
+const AliMpSectorSegmentation*  
+AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
+{
+// Returns the mapping segmentation
+// (provides access to electronics info)
+
+  return fSectorSegmentation;
+}  
+
 //______________________________________________________________________________
 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
 {
@@ -220,7 +295,7 @@ void  AliMUONSt12QuadrantSegmentation::GetPadI(Float_t x, Float_t y,
 // ---
 
   AliMpPad pad = fSectorSegmentation
-               ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), false);
+               ->PadByPosition(TVector2(x/fgkLengthUnit, y/fgkLengthUnit), true);
 
   ix = pad.GetIndices().GetFirst();
   iy = pad.GetIndices().GetSecond();
@@ -245,7 +320,7 @@ void  AliMUONSt12QuadrantSegmentation::GetPadC(Int_t ix, Int_t iy,
 // If there is no pad, x = 0., y = 0. are returned.
 // ---
 
-  AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy));
+  AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(ix,iy), true);
 
   x = pad.Position().X() * fgkLengthUnit;
   y = pad.Position().Y() * fgkLengthUnit;
@@ -258,7 +333,7 @@ void AliMUONSt12QuadrantSegmentation::Init(Int_t chamber)
 // Initialize segmentation
 // ---
 
 // find Npx, Npy and save this info
+ // find Npx, Npy and save this info
   
   // reference to chamber
  AliMUON *pMUON  = (AliMUON *) gAlice->GetModule("MUON");
@@ -311,20 +386,20 @@ Float_t AliMUONSt12QuadrantSegmentation::Dpy(Int_t isector) const
 Int_t AliMUONSt12QuadrantSegmentation::Npx() const
 {
 // Maximum number of Pads in x
+// hard coded for the time being
 // ---
 
-  //Fatal("Npx", "Not yet implemented.");
-  return 142; //hard coded for the time being
+  return fSectorSegmentation->MaxPadIndexX();
 }
 
 //______________________________________________________________________________
 Int_t AliMUONSt12QuadrantSegmentation::Npy() const
 {
 // Maximum number of Pads in y
+// hard coded for the time being
 // ---
 
-  //Fatal("Npy", "Not yet implemented.");
-  return 213; //hard coded for the time being
+  return fSectorSegmentation->MaxPadIndexY();
 }
 
 //______________________________________________________________________________
@@ -441,19 +516,16 @@ void AliMUONSt12QuadrantSegmentation::Neighbours(Int_t iX, Int_t iY,
   AliMpPad pad = fSectorSegmentation->PadByIndices(AliMpIntPair(iX,iY));
   Int_t &i = *Nlist;
   i=0;
-  AliMpVPadIterator* iter
-    = fSectorSegmentation
-      ->CreateIterator(AliMpArea(pad.Position(),2.*pad.Dimensions()*1.1));
+  AliMpNeighboursPadIterator iter
+    = AliMpNeighboursPadIterator(fSectorSegmentation, pad, kFALSE);
 
-  for( iter->First(); !iter->IsDone() && i<10; iter->Next()) {
-    Xlist[i] = iter->CurrentItem().GetIndices().GetFirst();
-    Ylist[i] = iter->CurrentItem().GetIndices().GetSecond();
+  for( iter.First(); !iter.IsDone() && i<10; iter.Next()) {
+    Xlist[i] = iter.CurrentItem().GetIndices().GetFirst();
+    Ylist[i] = iter.CurrentItem().GetIndices().GetSecond();
     i++;
   }
-  
-  delete iter;
 }
-
 //______________________________________________________________________________
 Int_t  AliMUONSt12QuadrantSegmentation::Ix()
 {
@@ -549,7 +621,6 @@ Int_t AliMUONSt12QuadrantSegmentation::SigGenCond(Float_t x, Float_t y, Float_t
   }
 }
 
-
 //______________________________________________________________________________
 void  AliMUONSt12QuadrantSegmentation::SigGenInit(Float_t x, Float_t y, Float_t /*z*/)
 {
@@ -608,3 +679,18 @@ TF1* AliMUONSt12QuadrantSegmentation::CorrFunc(Int_t isec) const
   return (TF1*) fCorrA->At(isec);
 } 
 
+//______________________________________________________________________________
+void AliMUONSt12QuadrantSegmentation::Streamer(TBuffer &R__b)
+{
+// Stream an object of class AliMUONSt12QuadrantSegmentation.
+
+  if (R__b.IsReading()) {
+    AliMUONSt12QuadrantSegmentation::Class()->ReadBuffer(R__b, this);
+    ReadMappingData();
+  } 
+  else {
+    AliMUONSt12QuadrantSegmentation::Class()->WriteBuffer(R__b, this);
+  }
+}
+
+