]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONResponseTriggerV1.cxx
Fixing minor bug recognizing diffractive events in simulation
[u/mrichter/AliRoot.git] / MUON / AliMUONResponseTriggerV1.cxx
index b4d9836220b66f9d12170c086280950814a93d66..15cc735911bf8130f57933bf0143c2af24302a89 100644 (file)
 
 /* $Id$ */
 
-// ------------------
+//-----------------------------------------------------------------------------
 // Class AliMUONTriggerResponseV1
 // ------------------
 // Trigger chamber response 
 // with cluster size activated
+//-----------------------------------------------------------------------------
 
 #include "AliMUONResponseTriggerV1.h"
-#include "AliMUONGeometrySegmentation.h"
 #include "AliMUON.h"
 #include "AliMUONDigit.h"
 #include "AliMUONGeometryTransformer.h"
-#include "AliMUONSegmentation.h"
 #include "AliMUONConstants.h"
 
 #include "AliMpPad.h"
 #include "AliMpSegmentation.h"
 #include "AliMpVSegmentation.h"
+#include "AliMpCathodType.h"
 
 #include "AliRun.h"
 
@@ -62,11 +62,6 @@ namespace
     transformer->Global2Local(detElemId,xg,yg,zg,xl,yl,zl);
   }
 
-  AliMUONSegmentation* Segmentation()
-  {
-    static AliMUONSegmentation* segmentation = muon()->GetSegmentation();
-    return segmentation;
-  }
 }
 
 //------------------------------------------------------------------   
@@ -105,6 +100,7 @@ void AliMUONResponseTriggerV1::SetParameters(Float_t hv)
 {
 /// initialize parameters accoring to HV
 /// (see V.Barret B.Espagnon and P.Rosnet Alice/note xxx)
+/// this parametrisation is valid only for the "streamer" mode
   fA = 6.089 * hv - 52.70;
   fB = 2.966;
   fC = 4.3e-4 * hv - 3.5e-3;
@@ -122,9 +118,10 @@ Int_t AliMUONResponseTriggerV1::SetGenerCluster()
 Float_t AliMUONResponseTriggerV1::FireStripProb(Float_t x4, Float_t theta)
 const
 {
-// parametrisation of the probability that a strip neighbour of the main 
-// strip is fired (V.Barret B.Espagnon and P.Rosnet INT/DIM/01-04 (2001)
-// WARNING : need to convert x4 from cm to mm
+/// parametrisation of the probability that a strip neighbour of the main 
+/// strip is fired (V.Barret B.Espagnon and P.Rosnet INT/DIM/01-04 (2001)
+/// WARNING : need to convert x4 from cm to mm
+/// this parametrisation is valid only for the "streamer" mode
 
  return 
      (TMath::Cos(theta)*fA/(fA+TMath::Cos(theta)*TMath::Power(x4*10.,fB))+fC)/
@@ -132,7 +129,7 @@ const
 }
 
 //------------------------------------------------------------------  
-void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits)
+void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits, Float_t /*timeDif*/)
 {
   /// Generate digits (on each cathode) from 1 hit, with cluster-size
   /// generation.
@@ -141,7 +138,7 @@ void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits
   
   Float_t xhit = hit.X();
   Float_t yhit = hit.Y();
-  Float_t zhit = 0; // FIXME : should it be hit.Z() ?
+  Float_t zhit = hit.Z();
   Int_t detElemId = hit.DetElemId();  
   
   Double_t x,y,z;
@@ -153,25 +150,41 @@ void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits
   {
     twentyNano=1;
   }
+  
+  Int_t nboard = 0;
 
-  for ( Int_t cath = 0; cath < 2; ++cath )
+  for ( Int_t cath = AliMp::kCath0; cath <= AliMp::kCath1; ++cath )
   {
     const AliMpVSegmentation* seg 
-      = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,cath);
+      = AliMpSegmentation::Instance()
+        ->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
 
-    AliMpPad pad = seg->PadByPosition(TVector2(x,y),kFALSE);
-    Int_t ix = pad.GetIndices().GetFirst();
-    Int_t iy = pad.GetIndices().GetSecond();
+    AliMpPad pad = seg->PadByPosition(x,y,kFALSE);
+    Int_t ix = pad.GetIx();
+    Int_t iy = pad.GetIy();
+    
+    AliDebug(1,Form("xhit,yhit=%e,%e lx,ly,lz=%e,%e,%e ix,iy=%d,%d",
+                    xhit,yhit,x,y,z,ix,iy));
     
-    AliMUONDigit* d = new AliMUONDigit;
-    d->SetDetElemId(detElemId);
+    if ( !pad.IsValid() )
+    {
+      AliWarning(Form("hit w/o strip %d-%d xhit,yhit=%e,%e local x,y,z "
+                      "%e,%e,%e ix,iy=%d,%d",detElemId,
+                      cath,
+                      xhit,yhit,x,y,z,ix,iy));
+      continue;
+    }
+    
+    if ( cath == AliMp::kCath0 ) nboard = pad.GetLocalBoardId(0);
+        
+    AliMUONDigit* d = new AliMUONDigit(detElemId,nboard,
+                                       pad.GetLocalBoardChannel(0),
+                                       cath);
+    d->SetPadXY(ix,iy);
+
+    d->SetCharge(twentyNano);
 
-    d->SetPadX(ix);
-    d->SetPadY(iy);
 
-    d->SetSignal(twentyNano);
-    d->AddPhysicsSignal(d->Signal());
-    d->SetCathode(cath);
     digits.Add(d);
 
     SetGenerCluster(); // 1 randum number per cathode (to be checked)
@@ -192,16 +205,15 @@ void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits
            Int_t ixNeigh = ( cath == 0 ) ? ix : xList[i];
            Int_t iyNeigh = ( cath == 0 ) ? yList[i] : iy;
            
-           AliMpIntPair pairNeigh = AliMpIntPair(ixNeigh,iyNeigh);
-           AliMpPad padNeigh = seg->PadByIndices(pairNeigh,kFALSE);
+           AliMpPad padNeigh = seg->PadByIndices(ixNeigh,iyNeigh,kFALSE);
            if(padNeigh.IsValid()){ // existing neighbourg              
                
                Int_t dix=-(ixNeigh-ix);
                Int_t diy=-(iyNeigh-iy);
-               Float_t xlocalNeigh = padNeigh.Position().X();
-               Float_t ylocalNeigh = padNeigh.Position().Y();
-               Float_t dpx = padNeigh.Dimensions().X();
-               Float_t dpy = padNeigh.Dimensions().Y();
+               Float_t xlocalNeigh = padNeigh.GetPositionX();
+               Float_t ylocalNeigh = padNeigh.GetPositionY();
+               Float_t dpx = padNeigh.GetDimensionX();
+               Float_t dpy = padNeigh.GetDimensionY();
                Float_t distX = TMath::Abs((Float_t)dix) * ((Float_t)dix * dpx + xlocalNeigh - x);
                Float_t distY = TMath::Abs((Float_t)diy) * ((Float_t)diy * dpy + ylocalNeigh - y);
                Float_t dist = TMath::Sqrt(distX*distX+distY*distY);
@@ -212,15 +224,22 @@ void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits
                else qp = 0;
                
                if (qp == 1) { // this digit is fired    
-                   AliMUONDigit* dNeigh = new AliMUONDigit;
-                   dNeigh->SetDetElemId(detElemId);
+        Int_t neighBoard = 0;
+        if ( cath == AliMp::kCath0 ) neighBoard = padNeigh.GetLocalBoardId(0);
+        else {
+          const AliMpVSegmentation* seg0 
+            = AliMpSegmentation::Instance()
+              ->GetMpSegmentation(detElemId,AliMp::GetCathodType(AliMp::kCath0));
+          AliMpPad padNeigh0 = seg0->PadByPosition(xlocalNeigh, y, kFALSE);
+          if ( ! padNeigh0.IsValid() ) continue; // This can happen only on the cut RPC, at boards 25, 30, 142 and 147
+          neighBoard = padNeigh0.GetLocalBoardId(0);
+        }
+                   AliMUONDigit* dNeigh = new AliMUONDigit(detElemId,neighBoard,
+                                                padNeigh.GetLocalBoardChannel(0),
+                                                cath);
                    
-                   dNeigh->SetPadX(ixNeigh);
-                   dNeigh->SetPadY(iyNeigh);
-                   
-                   dNeigh->SetSignal(twentyNano);
-                   dNeigh->AddPhysicsSignal(dNeigh->Signal());
-                   dNeigh->SetCathode(cath);
+                   dNeigh->SetPadXY(ixNeigh,iyNeigh);      
+                   dNeigh->SetCharge(twentyNano);
                    digits.Add(dNeigh);
                } // digit fired                
            } // pad is valid
@@ -232,7 +251,7 @@ void AliMUONResponseTriggerV1::DisIntegrate(const AliMUONHit& hit, TList& digits
 //------------------------------------------------------------------  
 void AliMUONResponseTriggerV1::Neighbours(const Int_t cath, 
                                          const Int_t ix, const Int_t iy, 
-                                         Int_t Xlist[10], Int_t Ylist[10]) 
+                                         Int_t Xlist[10], Int_t Ylist[10]) const
 {
     ///-----------------BENDING-----------------------------------------      /n
     /// Returns list of 10 next neighbours for given X strip (ix, iy)         /n
@@ -251,7 +270,8 @@ void AliMUONResponseTriggerV1::Neighbours(const Int_t cath,
     ///-----------------NON-BENDING-------------------------------------      /n
     /// Returns list of 10 next neighbours for given Y strip (ix, iy)         /n 
     /// neighbour number 9 8 7 6 5 (Y strip (ix, iy)) 0 1 2 3 4 in the list   /n 
-    ///                  \_______/                    \_______/               /n 
+    ///                  |_______|                    |_______/               /n 
+
     ///                    left                         right                 /n
     
     for (Int_t i=0; i<10; i++) {