]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONSt345SlatSegmentation.cxx
Minor fixes in the event tag to take into account the new way of storing the trigger...
[u/mrichter/AliRoot.git] / MUON / AliMUONSt345SlatSegmentation.cxx
index b6b20489e7a1c13fd61dd3835b1a4f957a7a370c..ff892e860e05dc8453eb5a5b78bd9fba7543e89c 100644 (file)
 #include <TArrayI.h>
 #include <TArrayF.h>
 #include "AliMUONSt345SlatSegmentation.h"
-#include "AliMUONSegmentationDetectionElement.h"
-#include "AliMUONSegmentManuIndex.h"
-#include "AliMUONSegmentIndex.h"
-
 #include "AliLog.h"
 
 ClassImp(AliMUONSt345SlatSegmentation)
@@ -62,11 +58,10 @@ AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation()
        fIxmax(0),
        fIymin(0),
         fIymax(0),
-       fInitDone(kFALSE),
-       fSegmentationDetectionElement(0x0)
+       fInitDone(kFALSE)
 {
   // default constructor
-
+       AliDebug(1,Form("this=%p default (empty) ctor",this));
 }
 
 //___________________________________________
@@ -93,9 +88,7 @@ AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(Bool_t bending)
        fIxmax(0),
        fIymin(0),
        fIymax(0),
-       fInitDone(kFALSE),
-       fSegmentationDetectionElement(0x0)
-
+       fInitDone(kFALSE)
 
 {
   // Non default constructor
@@ -106,7 +99,7 @@ AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(Bool_t bending)
   (*fNDiv)[0]=(*fNDiv)[1]=(*fNDiv)[2]=(*fNDiv)[3]=0;     
   (*fDpxD)[0]=(*fDpxD)[1]=(*fDpxD)[2]=(*fDpxD)[3]=0;       
   (*fDpyD)[0]=(*fDpyD)[1]=(*fDpyD)[2]=(*fDpyD)[3]=0;   
-
+  AliDebug(1,Form("this=%p ctor for bending=%d",this,fBending)); 
 
 }
 //----------------------------------------------------------------------
@@ -128,19 +121,21 @@ AliMUONSt345SlatSegmentation::AliMUONSt345SlatSegmentation(const AliMUONSt345Sla
        fIxmin(0),
        fIxmax(0),
        fIymin(0),
-       fIymax(0),
-       fSegmentationDetectionElement(0x0)
+       fIymax(0)
 {
-  // default constructor
+// Copy constructor
+               AliFatal("Not implemented");
 }
 //----------------------------------------------------------------------
 AliMUONSt345SlatSegmentation::~AliMUONSt345SlatSegmentation() 
 {
   // Destructor
-  if (fNDiv) delete fNDiv;
-  if (fDpxD) delete fDpxD;
-  if (fDpyD) delete fDpyD;
-  // if (fSegmentationDetectionElement) fSegmentationDetectionElement->Delete();
+
+  AliDebug(1, Form("dtor this = %p", this));
+
+  delete fNDiv;
+  delete fDpxD;
+  delete fDpyD;
 }
 //----------------------------------------------------------------------
 AliMUONSt345SlatSegmentation& AliMUONSt345SlatSegmentation::operator=(const AliMUONSt345SlatSegmentation& rhs)
@@ -182,23 +177,43 @@ Float_t AliMUONSt345SlatSegmentation::GetAnod(Float_t xhit) const
   return fWireD*wire;
 }
 
-
+//_____________________________________________________________________________
+Bool_t AliMUONSt345SlatSegmentation::HasPad(Int_t ix, Int_t iy)
+{
+// Return true if pas with given indices exists
+
+       if ( ix < 1 || ix > Npx() || iy < 1 || iy > Npy() )
+       {
+               return kFALSE;
+       }
+       Int_t isec = Sector(ix,iy);
+       if ( isec == -1 )
+       {
+               return kFALSE;
+       }
+       if ( iy > fNpyS[isec] )
+       {
+               return kFALSE;
+       }
+       return kTRUE;
+}
 
 //--------------------------------------------------------------------------------
 void AliMUONSt345SlatSegmentation::GetPadC(Int_t ix, Int_t iy, Float_t &x, Float_t &y) 
 {
+    //  Returns real coordinates (x,y) for given pad coordinates (ix,iy)
+
   if (ix < 1 || ix > Npx() || iy < 1 || iy > Npy() ){
     AliWarning(Form("ix %d or iy %d out of boundaries: Npx=%d and Npy=%d",ix, iy, Npx(), Npy()));
-    x=-99999.; y=-99999.;
+    x = y= 0.;
 
   } else { 
 
-    //  Returns real coordinates (x,y) for given pad coordinates (ix,iy)
     //  Find sector isec
     Int_t isec = Sector(ix,iy);
     if (isec == -1) AliWarning(Form("isector = %d  with ix %d, iy %d", isec, ix, iy));
     if (iy > fNpyS[isec]) {
-      x=-99999.; y=-99999.;
+      x = y = 0.;
       return;
     }
     if (isec>0) {
@@ -222,7 +237,7 @@ void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_
   for (Int_t i=fNsec-1; i > 0; i--) {
     if (x >= fCx[i-1]) {
       isec=i;
-      if (fCx[isec] == fCx[isec-1]  && isec > 1) isec--;
+      if (TMath::Abs(fCx[isec] - fCx[isec-1]) <0.1  && isec > 1) isec--;
       break;
     }
   }
@@ -242,46 +257,11 @@ void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y, Int_t &ix, Int_
 //-------------------------------------------------------------------------
 void AliMUONSt345SlatSegmentation::GetPadI(Float_t x, Float_t y , Float_t /*z*/, Int_t &ix, Int_t &iy)
 {
-  GetPadI(x, y, ix, iy);
-}
-
-//-------------------------------------------------------------------------
-void AliMUONSt345SlatSegmentation::GetPadE(Int_t &ix, Int_t &iy,  AliMUONSegmentManuIndex* manuIndex)
-{
-  //
-  // return Padx and Pady
-  // input value: electronic connection number
-
-  Int_t icathode = (fBending == 1) ? 0 : 1; // cathode 0 == bending
-
-  //  Int_t busPatchId     = manuIndex->GetBusPatchId(); //
-  Int_t manuId         = manuIndex->GetManuId();
-  Int_t manuChannelId  = manuIndex->GetManuChannelId();
-  //  Int_t channelId      = manuIndex->GetChannelId();
-
-  AliMUONSegmentIndex* index = fSegmentationDetectionElement->GetIndex(manuId,  manuChannelId);
-
-  ix = index->GetPadX();
-  iy = index->GetPadY();
-  swap(ix,iy); // swap cos origin in segmentation and mapping file are different for iy (temporary solution)
-
-  if (index->GetCathode() != icathode)
-    AliWarning("Wrong cathode number !");
+//  Returns pad coordinates (ix,iy) for given real coordinates (x,y)
 
+  GetPadI(x, y, ix, iy);
 }
 
-//-------------------------------------------------------------------------
- AliMUONSegmentManuIndex* AliMUONSt345SlatSegmentation::GetMpConnection(Int_t ix, Int_t iy)
-{
-  //
-  // return electronic connection number
-  // input value: Padx and Pady
-
-  Int_t icathode = (fBending == 1) ? 0 : 1; // cathode 0 == bending
-
-  return fSegmentationDetectionElement->GetManuIndex(ix, iy, icathode);
-  
-}
 
 //_______________________________________________________________
 void AliMUONSt345SlatSegmentation::SetPadDivision(Int_t ndiv[4])
@@ -342,6 +322,8 @@ void AliMUONSt345SlatSegmentation::SetHit(Float_t x, Float_t y)
 //----------------------------------------------------------------------------
 void AliMUONSt345SlatSegmentation::SetHit(Float_t xhit, Float_t yhit, Float_t /*zhit*/)
 {
+  // Set current hit 
+
   SetHit(xhit, yhit);
 }
 
@@ -367,19 +349,19 @@ void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t
     if (y01 < -fDyPCB/2) y01 = -fDyPCB/2;
 
     if (x02 >= fCx[fNsec-1]) x02 = fCx[fNsec-1]; // still ok ? (CF)
+    if (y02 >= fDyPCB/2.) y02 = fDyPCB/2.;
 
    
     Int_t isec=-1;
     for (Int_t i=fNsec-1; i > 0; i--) {
       if (x02 >= fCx[i-1]) {
        isec=i;
-       if (fCx[isec] == fCx[isec-1] && isec > 1) isec--;
+       if (TMath::Abs(fCx[isec] - fCx[isec-1]) < 0.1 && isec > 1) isec--;
        break;
       }
     }
 
-    y02 += Dpy(isec);// why ? (CF)
-    if (y02 >= fDyPCB/2.) y02 = fDyPCB/2;
+    //    y02 += Dpy(isec);// why ? (CF)
    
     //
     // find the pads over which the charge distributes
@@ -405,19 +387,16 @@ void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t
     
     GetPadC(fIx,fIy,fX,fY);
     fSector = Sector(fIx,fIy);
-/*
-    printf("\n \n First Pad: %d %d %f %f %d %d %d %f" , 
-          fIxmin, fIxmax, fXmin, fXmax, fNpx, fId, isec, Dpy(isec));    
-    printf("\n \n First Pad: %d %d %f %f %d %d %d %f",
-          fIymin, fIymax, fYmin, fYmax,  fNpyS[isec], fId, isec, Dpy(isec));
-*/
+    AliDebug(4,Form("xhit,yhit,dx,dy=%e,%e,%e,%e ix,iy=%3d,%3d",
+                   xhit,yhit,dx,dy,fIx,fIy));
 }
 
-
-
 //----------------------------------------------------------------------
 void AliMUONSt345SlatSegmentation::FirstPad(Float_t xhit, Float_t yhit, Float_t /*zhit*/, Float_t dx, Float_t dy)
 {
+// Initialises iteration over pads for charge distribution algorithm
+
   FirstPad(xhit, yhit, dx, dy);
 }
 //----------------------------------------------------------------------
@@ -437,7 +416,6 @@ void AliMUONSt345SlatSegmentation::NextPad()
     fIy++;
     GetPadC(fIx,fIy,fX,fY);
     fSector=Sector(fIx,fIy);
-
   } else {
     fIx=-999;
     fIy=-999;
@@ -481,7 +459,8 @@ IntegrationLimits(Float_t& x1,Float_t& x2,Float_t& y1, Float_t& y2)
   x2=x1+Dpx(fSector);
   y1=fYhit-fY-Dpy(fSector)/2.;
   y2=y1+Dpy(fSector);    
-  //  printf("\n Integration Limits %f %f %f %f %d %f", x1, x2, y1, y2, fSector, Dpx(fSector));
+
+  AliDebug(4,Form("xhit,yhit=%e,%e x,y=%e,%e, x1,x2,y1,y2=%e,%e,%e,%e",fXhit,fYhit,fX,fY,x1,x2,y1,y2));
 
 }
 //-----------------------------------------------------------------------------
@@ -564,8 +543,8 @@ void AliMUONSt345SlatSegmentation::Init(Int_t detectionElementId)
       fNpyS[0] = 0;
       fCx[0]   = -totalLength/2;
     } else {
-      fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]); 
-      fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]);
+      fNpxS[isec] = fNpxS[isec-1] + fPcbBoards[isec]*Int_t(fDxPCB/(*fDpxD)[isec]+0.5); 
+      fNpyS[isec] = Int_t(fDyPCB/(*fDpyD)[isec]+0.5);
       if (fNpyS[isec] >= fNpy) fNpy = fNpyS[isec]; 
       fCx[isec]= fCx[isec-1] + fPcbBoards[isec]*fDxPCB;
     }
@@ -576,99 +555,5 @@ void AliMUONSt345SlatSegmentation::Init(Int_t detectionElementId)
   //
   fId = detectionElementId;
 
-  //
-  // initalize mapping
-  //
-//   Int_t icathode = (fBending == 1) ? 0 : 1; // cathode 0 == bending
-//   Char_t name[15];
-//   GetMpFileName(name);
-//   fSegmentationDetectionElement = new AliMUONSegmentationDetectionElement();
-//   fSegmentationDetectionElement->Init(name, icathode);
   fInitDone = kTRUE;
 }
-
-//--------------------------------------------------------------------------
-void AliMUONSt345SlatSegmentation::GetMpFileName(Char_t* name) const
-{
-  //
-  // Get mapping file name
-  //
-
-   strcpy(name,"slat");
-
-   for (Int_t isec = 1; isec < 4; isec++) {
-
-     switch(isec) {
-     case 1:
-       for (Int_t i = 0; i < fPcbBoards[isec]; i++)
-        strcat(name,"1");
-       break;
-     case 2 :
-       for (Int_t i = 0; i < fPcbBoards[isec]; i++)
-        strcat(name,"2");
-       break;
-     case 3:
-       for (Int_t i = 0; i < fPcbBoards[isec]; i++)
-        strcat(name,"3");
-       break;
-     }
-   }
-
-   while (strlen(name) < 10)
-     strcat(name,"0");
-   
-   switch(fRtype) {
-   case 0:
-     strcat(name, "N");
-     break;
-   case 1:
-     strcat(name, "NR1");
-     break;
-   case 2:
-     strcat(name, "NR2");
-     break;
-   case 3:
-     strcat(name, "NR3");
-     break;
-   case 4:
-     strcat(name, "S");
-     break;
-   case -1:
-     strcat(name, "SR1");
-     break;
-   case -2:
-     strcat(name, "SR2");
-     break;
-   case -3:
-     strcat(name, "SR3"); // should not exist
-     AliFatal("SR3 Slat type does not exist !!");
-     break;
-   }
-}
-
-//--------------------------------------------------------------------------
-void AliMUONSt345SlatSegmentation::Swap(Int_t padX, Int_t &padY)
-{
-
-  // swap the numbering between segmentation (i.e. pady = [0,40]) 
-  // and mapping file  (i.e. pady = [-20,20]) 
-
-
-  if (fBending == 1) {
-    if (padY < 0) 
-      padY += fNpy + 1; 
-    else
-      padY += fNpy; 
-  }
-
-
-  if (fBending == 0) {
-    if (padY < 0) 
-      padY += fNpyS[Sector(padX, padY)] + 1; 
-    else
-      padY += fNpyS[Sector(padX, padY)]; 
-  }
-
-}
-
-