]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSt12QuadrantSegmentation.cxx
From Laurent:
[u/mrichter/AliRoot.git] / MUON / AliMUONSt12QuadrantSegmentation.cxx
index ecc2ef59908f61d209859c4c797b948dfbcb95ff..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 "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; 
 
 //______________________________________________________________________________
@@ -52,6 +53,8 @@ AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
                                        AliMpStationType stationType,
                                       AliMpPlaneType planeType) 
 : AliMUONVGeometryDESegmentation(),
+  fStationType(stationType),
+  fPlaneType(planeType),
   fSector(0),
   fSectorSegmentation(0),
   fSectorIterator(0),
@@ -77,18 +80,7 @@ AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
 {
 // Normal constructor
 
-  // 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;         
-   }
-  
-  AliMpReader r(stationType, planeType);
-  fSector = r.BuildSector();
-  fSectorSegmentation = new AliMpSectorSegmentation(fSector);
+  ReadMappingData();
 
   fCorrA = new TObjArray(3);
   fCorrA->AddAt(0,0);
@@ -99,6 +91,8 @@ AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation(
 //______________________________________________________________________________
 AliMUONSt12QuadrantSegmentation::AliMUONSt12QuadrantSegmentation() 
 : AliMUONVGeometryDESegmentation(),
+  fStationType(kStation1),
+  fPlaneType(kBendingPlane),
   fSector(0),
   fSectorSegmentation(0),
   fSectorIterator(0),
@@ -176,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
 //
@@ -198,11 +213,14 @@ 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);
 
@@ -234,6 +252,16 @@ AliMUONGeometryDirection  AliMUONSt12QuadrantSegmentation::GetDirection()
   }  
 }  
 
+//______________________________________________________________________________
+const AliMpSectorSegmentation*  
+AliMUONSt12QuadrantSegmentation::GetMpSegmentation() const
+{
+// Returns the mapping segmentation
+// (provides access to electronics info)
+
+  return fSectorSegmentation;
+}  
+
 //______________________________________________________________________________
 Float_t AliMUONSt12QuadrantSegmentation::GetAnod(Float_t xhit) const
 {
@@ -305,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");
@@ -361,16 +389,7 @@ Int_t AliMUONSt12QuadrantSegmentation::Npx() const
 // hard coded for the time being
 // ---
 
-  //Fatal("Npx", "Not yet implemented.");
-  switch (fSector->GetDirection()) {
-    case kX:
-      return 142;
-    case kY:
-      return 108;
-    default:
-      AliError("Unknown sector direction");
-      return 0;  
-  }      
+  return fSectorSegmentation->MaxPadIndexX();
 }
 
 //______________________________________________________________________________
@@ -380,16 +399,7 @@ Int_t AliMUONSt12QuadrantSegmentation::Npy() const
 // hard coded for the time being
 // ---
 
-  //Fatal("Npy", "Not yet implemented.");
-  switch (fSector->GetDirection()) {
-    case kX:
-      return 160;
-    case kY:
-      return 213;
-    default:
-      AliError("Unknown sector direction");
-      return 0;  
-  }    
+  return fSectorSegmentation->MaxPadIndexY();
 }
 
 //______________________________________________________________________________
@@ -506,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()
 {
@@ -614,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*/)
 {
@@ -673,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);
+  }
+}
+
+