]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSegmentationSlat.cxx
get tables from the aliroot directory if they are not in the current one
[u/mrichter/AliRoot.git] / MUON / AliMUONSegmentationSlat.cxx
index aa2433a3f809cee4eba44cb7c13cc72256f9333f..9e81968159293b09208003d15428629d5909a52e 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.7  2000/11/08 13:01:40  morsch
-Chamber half-planes of stations 3-5 at different z-positions.
-
-Revision 1.6  2000/11/06 09:20:43  morsch
-AliMUON delegates part of BuildGeometry() to AliMUONSegmentation using the
-Draw() method. This avoids code and parameter replication.
-
-Revision 1.5  2000/10/23 13:37:40  morsch
-Correct z-position of slat planes.
-
-Revision 1.4  2000/10/22 16:55:43  morsch
-Use only x-symmetry in global to local transformations and delegation.
-
-Revision 1.3  2000/10/18 11:42:06  morsch
-- AliMUONRawCluster contains z-position.
-- Some clean-up of useless print statements during initialisations.
-
-Revision 1.2  2000/10/09 14:06:18  morsch
-Some type cast problems of type  (TMath::Sign((Float_t)1.,x)) corrected (P.H.)
-
-Revision 1.1  2000/10/06 09:00:47  morsch
-Segmentation class for chambers built out of slats.
-
-*/
+/* $Id$ */
 
 #include "AliMUONSegmentationSlat.h"
 #include "AliMUONSegmentationSlatModule.h"
@@ -51,7 +26,7 @@ Segmentation class for chambers built out of slats.
 #include <TBRIK.h>
 #include <TNode.h>
 #include <TGeometry.h>
-#include <iostream.h>
+#include <Riostream.h>
 
 //___________________________________________
 ClassImp(AliMUONSegmentationSlat)
@@ -59,10 +34,34 @@ ClassImp(AliMUONSegmentationSlat)
 AliMUONSegmentationSlat::AliMUONSegmentationSlat() 
 {
 // Default constructor
+  fChamber = 0;
+  fNDiv = 0;
+  fSlats = 0;
+  fCurrentSlat = 0;
+}
+
+AliMUONSegmentationSlat::AliMUONSegmentationSlat(Int_t /*nsec*/) 
+{
+// Non default constructor
     fSlats=0;            
-    fNDiv = new TArrayI(4);   
+    fNDiv = new TArrayI(4);
+    fChamber = 0;
+    fCurrentSlat = 0;
 }
 
+AliMUONSegmentationSlat::~AliMUONSegmentationSlat(){
+  //PH Delete TObjArrays
+  if (fSlats) {
+    fSlats->Delete();
+    delete fSlats;
+  }
+
+  if (fNDiv) {
+    delete fNDiv;
+  }
+
+}
+//-----------------------------------------------------------
 void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
 {
 //  Sets the pad (strip) size 
@@ -70,14 +69,28 @@ void AliMUONSegmentationSlat::SetPadSize(Float_t p1, Float_t p2)
     fDpx=p1;
     fDpy=p2;
 }
-
+//-----------------------------------------------------------
 Float_t AliMUONSegmentationSlat::GetAnod(Float_t xhit) const
 {
 // Returns for a hit position xhit the position of the nearest anode wire    
     Float_t wire= (xhit>0)? Int_t(xhit/fWireD)+0.5:Int_t(xhit/fWireD)-0.5;
     return fWireD*wire;
 }
-
+//-----------------------------------------------------------
+void AliMUONSegmentationSlat::GetNParallelAndOffset(Int_t /*iX*/, Int_t /*iY*/, Int_t *Nparallel, Int_t *Offset) 
+{
+  *Nparallel=1;
+  *Offset=0;
+}
+//-----------------------------------------------------------
+void AliMUONSegmentationSlat::GiveTestPoints(Int_t & /*n*/, Float_t */*x*/, Float_t */*y*/)  const 
+{;}
+//-----------------------------------------------------------
+Float_t AliMUONSegmentationSlat::Distance2AndOffset(Int_t /*iX*/, Int_t /*iY*/, Float_t /*X*/, Float_t /*Y*/, Int_t * /*dummy*/) 
+{
+  return 0.;
+}
+//-----------------------------------------------------------
 Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
 {
 //
@@ -90,7 +103,7 @@ Float_t AliMUONSegmentationSlat::Dpx(Int_t isec) const
     return Slat(islat)->Dpx(iregion);
 }
 
-Float_t AliMUONSegmentationSlat::Dpy(Int_t isec) const
+Float_t AliMUONSegmentationSlat::Dpy(Int_t /*isec*/) const
 {
 //
 // Returns y-pad (strip)  size for given sector isec
@@ -118,31 +131,38 @@ void AliMUONSegmentationSlat::GlobalToLocal(
     Float_t zlocal;
     Int_t i;
     Int_t index=-1;
+    Float_t eps = 1.e-4;
+    
 // Transform According to slat plane z-position: negative side is shifted down 
 //                                                 positive side is shifted up
 // by half the overlap
     zlocal = z-fChamber->Z();
-    zlocal = (x>0) ? zlocal-2.*fDz : zlocal+2.*fDz;
+
+//     zlocal = (x>0) ? zlocal-2.*fDz : zlocal+2.*fDz;
+    zlocal = (x>0) ? zlocal+2.*fDz : zlocal-2.*fDz;      //Change?
+
 //  Set the signs for the symmetry transformation and transform to first quadrant
     SetSymmetry(x);
     Float_t xabs=TMath::Abs(x);
 
-    Int_t ifirst = (zlocal < Float_t(0))? 0:1;
-//
+
 // Find slat number                      
-    for (i=ifirst; i<fNSlats; i+=2) {
+    for (i=0; i<fNSlats; i+=1) {       //Loop on all slats (longuer but more secure)
        index=i;
-       if ((y >= fYPosition[i]) && (y < fYPosition[i]+fSlatY)) break;
+       if ((y >= fYPosition[i]-eps) && (y <= fYPosition[i]+fSlatY+eps)) break;
     }
     
 //
 // Transform to local coordinate system
 
     
-    ylocal = y   -fYPosition[index];
-    xlocal = xabs-fXPosition[index];
-    islat  = index;
-    if (i >= fNSlats) {islat = -1; x=-1; y = -1;}
+    if (index >= fNSlats || index < 0 ) {
+      islat = -1; xlocal=-1; ylocal = -1; }
+    else {
+      ylocal = y   -fYPosition[index];
+      xlocal = xabs-fXPosition[index];
+      islat  = index;
+    }
 }
 
 void AliMUONSegmentationSlat::GlobalToLocal(
@@ -185,7 +205,7 @@ LocalToGlobal(Int_t islat, Float_t  xlocal, Float_t  ylocal, Float_t  &x, Float_
     x = (xlocal+fXPosition[islat])*fSym;
     y=(ylocal+fYPosition[islat]);
 
-    z = (TMath::Even(islat)) ?     -fDz : fDz ; 
+    z = (TMath::Even(islat)) ?     fDz : -fDz ; //Change for new referential
     z = (x>0)                ? z+2.*fDz : z-2.*fDz ; 
 
     z+=fChamber->Z();
@@ -259,7 +279,7 @@ GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y, Float_t &z)
     x=x*TMath::Sign(1,ix);
 
 // z-position
-    z = (TMath::Even(islat)) ?      -fDz : fDz ; 
+    z = (TMath::Even(islat)) ?      fDz : -fDz ; //Change for new referential
     z = (x>0)                ?  z+2.*fDz : z-2.*fDz ; 
     z += fChamber->Z();
 }
@@ -325,13 +345,14 @@ FirstPad(Float_t xhit, Float_t yhit, Float_t zhit, Float_t dx, Float_t dy)
 //
 
 
-
     Int_t islat;
     Float_t xlocal, ylocal;
     GlobalToLocal(xhit, yhit, zhit, islat, xlocal, ylocal);
     fSlatIndex=islat;
-    fCurrentSlat=Slat(islat);
-    fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
+    if (islat>-1) {
+      fCurrentSlat=Slat(islat);
+      fCurrentSlat->FirstPad(xlocal, ylocal, dx, dy);
+    }
 
 }
 
@@ -439,7 +460,7 @@ void AliMUONSegmentationSlat::Init(Int_t chamber)
 // Initialize slat modules of quadrant +/+    
 // The other three quadrants are handled through symmetry transformations
 //
-    printf("\n Initialise Segmentation Slat \n");
+  //printf("\n Initialise Segmentation Slat \n");
 //
 
 // Initialize Slat modules
@@ -460,7 +481,7 @@ void AliMUONSegmentationSlat::Init(Int_t chamber)
     fNpx=0;
 // for each slat in the quadrant (+,+)    
     for (islat=0; islat<fNSlats; islat++) {
-       (*fSlats)[islat] = CreateSlatModule();
+        fSlats->AddAt(CreateSlatModule(),islat);
 
        AliMUONSegmentationSlatModule *slat =  Slat(islat);
        // Configure Slat
@@ -516,14 +537,15 @@ void  AliMUONSegmentationSlat::SetSlatXPositions(Float_t *xpos)
 }
 
 AliMUONSegmentationSlatModule*  AliMUONSegmentationSlat::Slat(Int_t index) const
-{ return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
+  //PH { return ((AliMUONSegmentationSlatModule*) (*fSlats)[index]);}
+{ return ((AliMUONSegmentationSlatModule*) fSlats->At(index));}
 
 
 AliMUONSegmentationSlatModule* AliMUONSegmentationSlat::
 CreateSlatModule()
 {
     // Factory method for slat module
-    return new AliMUONSegmentationSlatModule();
+    return new AliMUONSegmentationSlatModule(4);
 }