]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerCircuit.cxx
Coding convention (data member comments after the data member definition)
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerCircuit.cxx
index 113490de0546b7a949b7e8f88ad0e065889fb122..cb8d3505f66f555fecda860d992898e4c57b1d5e 100644 (file)
@@ -15,6 +15,7 @@
 
 /* $Id$ */
 
+//-----------------------------------------------------------------------------
 /// \class AliMUONTriggerCircuit
 /// Contains as data members the Y positions of the X declusturized strips and 
 /// the X positions of the (doubled or not) Y strips.
 /// local trigger output (see AliMUONTrackReconstructor::MakeTriggerTrack)
 ///
 /// \author Philippe Crochet (LPCCFd)
+//-----------------------------------------------------------------------------
 
 #include "AliMUONTriggerCircuit.h"
+#include "AliMUONConstants.h"
+#include "AliMUONGeometryTransformer.h"
 
-#include "AliMpTriggerSegmentation.h"
 #include "AliMpTrigger.h"
 #include "AliMpSlat.h"
 #include "AliMpPCB.h"
@@ -35,6 +38,8 @@
 #include "AliMpDDLStore.h"
 #include "AliMpLocalBoard.h"
 #include "AliMpConstants.h"
+#include "AliMpPad.h"
+#include "AliMpEncodePair.h"
 
 #include "AliRun.h"
 #include "AliLog.h"
@@ -49,8 +54,8 @@ ClassImp(AliMUONTriggerCircuit)
 //----------------------------------------------------------------------
 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONGeometryTransformer* transformer)
     : TObject(),
-      fTransformer(transformer),
-      fCurrentSeg(0x0),
+      fkTransformer(transformer),
+      fkCurrentSeg(0x0),
       fCurrentDetElem(0x0),
       fCurrentLocalBoard(0x0)
 {
@@ -94,8 +99,8 @@ AliMUONTriggerCircuit::~AliMUONTriggerCircuit()
 //----------------------------------------------------------------------
 AliMUONTriggerCircuit::AliMUONTriggerCircuit(const AliMUONTriggerCircuit& circuit)
     :  TObject(circuit),
-       fTransformer(circuit.fTransformer), // do not copy, just pointed to
-       fCurrentSeg(circuit.fCurrentSeg),
+       fkTransformer(circuit.fkTransformer), // do not copy, just pointed to
+       fkCurrentSeg(circuit.fkCurrentSeg),
        fCurrentDetElem(circuit.fCurrentDetElem),
        fCurrentLocalBoard(circuit.fCurrentLocalBoard)
 {
@@ -115,8 +120,8 @@ AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCirc
 
   if (this == &circuit) return *this;
 
-  fTransformer       = circuit.fTransformer;
-  fCurrentSeg        = circuit.fCurrentSeg;
+  fkTransformer      = circuit.fkTransformer;
+  fkCurrentSeg       = circuit.fkCurrentSeg;
   fCurrentDetElem    = circuit.fCurrentDetElem;
   fCurrentLocalBoard = circuit.fCurrentLocalBoard;
 
@@ -131,7 +136,7 @@ AliMUONTriggerCircuit& AliMUONTriggerCircuit::operator=(const AliMUONTriggerCirc
 }
 
 //---------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
+void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* const localBoard)
 {
 /// fill fYpos11 and fYpos21 -> y position of X declusterized strips
   
@@ -142,15 +147,15 @@ void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
   Int_t zeroDown = localBoard->GetSwitch(AliMpLocalBoard::kZeroDown);
   Int_t zeroUp   = localBoard->GetSwitch(AliMpLocalBoard::kZeroUp);
  
-  Int_t iline = localBoard->GetPosition().GetFirst();
-  Int_t icol  = localBoard->GetPosition().GetSecond();
+  Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
+  Int_t icol  = AliMp::PairSecond(localBoard->GetPosition());
   if ( iline == 5 ) --icol;
 
   //--- first plane 
   ichamber = 10;
   fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
 
-  fCurrentSeg = AliMpSegmentation::Instance()
+  fkCurrentSeg = AliMpSegmentation::Instance()
         ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
 
   Int_t iFirstStrip = FirstStrip(localBoard);
@@ -164,7 +169,7 @@ void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
   ichamber = 12;
   fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
 
-  fCurrentSeg = AliMpSegmentation::Instance()
+  fkCurrentSeg = AliMpSegmentation::Instance()
         ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
 
   // second plane middle part
@@ -182,7 +187,7 @@ void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
     Int_t icolUp = icol;
 
     // check if we need to move to another detElemId
-    AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,iLastStripMiddle+1),kFALSE);
+    AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iLastStripMiddle+1,kFALSE);
 
     if (pad.IsValid()) { // upper strips within same detElemId
       iFirstStripUp = iLastStripMiddle;
@@ -192,7 +197,7 @@ void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
       fCurrentDetElem = AliMpDDLStore::Instance()->
                   GetNextDEfromLocalBoard(fCurrentLocalBoard, ichamber);
 
-      fCurrentSeg = AliMpSegmentation::Instance()
+      fkCurrentSeg = AliMpSegmentation::Instance()
             ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
 
       iFirstStripUp = 0;
@@ -212,7 +217,7 @@ void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
   
   // restore current detElemId & segmentation
   fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
-  fCurrentSeg = AliMpSegmentation::Instance()
+  fkCurrentSeg = AliMpSegmentation::Instance()
       ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
 
   // second plane lower part
@@ -222,7 +227,7 @@ void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
     Int_t icolDo = icol;
     
     // check if we need to move to another detElemId      
-    AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,iFirstStripMiddle-1),kFALSE);
+    AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,iFirstStripMiddle-1,kFALSE);
     if (pad.IsValid()) { // lower strips within same detElemId
       iFirstStripDo = iFirstStripMiddle - 8;
       iLastStripDo  = iFirstStripDo + 8;             
@@ -231,12 +236,11 @@ void AliMUONTriggerCircuit::LoadYPos(AliMpLocalBoard* localBoard)
       fCurrentDetElem = AliMpDDLStore::Instance()
          ->GetPreviousDEfromLocalBoard(fCurrentLocalBoard, ichamber);
 
-      fCurrentSeg = AliMpSegmentation::Instance()
+      fkCurrentSeg = AliMpSegmentation::Instance()
          ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
 
       // get iFirstStrip in this module 
-      const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(fCurrentSeg);
-      const AliMpTrigger* t = trig->Slat();
+      const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
       const AliMpSlat* slat = t->GetLayer(0);
 
       if (iline == 5) icolDo = icol + 1; // special case
@@ -267,14 +271,14 @@ void AliMUONTriggerCircuit::FillXstrips(const Int_t icol,
   Double_t xyGlobal[2] = {0.};
   for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
 
-    AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(icol-1,istrip),kTRUE);
+    AliMpPad pad = fkCurrentSeg->PadByIndices(icol-1,istrip,kTRUE);
     if ( !pad.IsValid() ) {
       StdoutToAliError(cout << "Pad not found in seg " << endl;
-                       fCurrentSeg->Print();
+                       fkCurrentSeg->Print();
                        cout << " ix,iy=" << icol-1 << "," << istrip << endl;
                        );
     }
-    Float_t yDim = pad.Dimensions().Y(); // half size! 
+    Float_t yDim = pad.GetDimensionY(); // half size! 
 
     XYGlobal(pad,xyGlobal);
     
@@ -286,7 +290,7 @@ void AliMUONTriggerCircuit::FillXstrips(const Int_t icol,
 
 
 //----------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* localBoard)
+void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* const localBoard)
 {
 /// fill fXpos11 -> x position of Y strips for the first plane only
 /// fXpos11 contains the x position of Y strip for the current circuit
@@ -308,13 +312,13 @@ void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* localBoard)
   Int_t  iLastStrip    = 0;
   Bool_t doubling      = kFALSE;
   
-  Int_t iline  = localBoard->GetPosition().GetFirst();
-  Int_t icol   = localBoard->GetPosition().GetSecond();
+  Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
+  Int_t icol  = AliMp::PairSecond(localBoard->GetPosition());
   if ( iline == 5 ) --icol;
 
   fCurrentDetElem = AliMpDDLStore::Instance()->GetDEfromLocalBoard(fCurrentLocalBoard, ichamber);
 
-  fCurrentSeg = AliMpSegmentation::Instance()
+  fkCurrentSeg = AliMpSegmentation::Instance()
         ->GetMpSegmentation(fCurrentDetElem, AliMp::GetCathodType(icathode));  
 
   // check if one needs a strip doubling or not
@@ -325,8 +329,7 @@ void AliMUONTriggerCircuit::LoadXPos(AliMpLocalBoard* localBoard)
   if (zeroAllYLSB) iStripCircuit = 8;
   
   // get iFirstStrip in this module 
-  const AliMpTriggerSegmentation* trig = (AliMpTriggerSegmentation*)(fCurrentSeg);
-  const AliMpTrigger* t = trig->Slat();
+  const AliMpTrigger* t = AliMpSegmentation::Instance()->GetTrigger(fkCurrentSeg);
   const AliMpSlat* slat = t->GetLayer(0);
   
   const AliMpPCB* pcb = slat->GetPCB(icol-1);
@@ -349,16 +352,16 @@ void AliMUONTriggerCircuit::FillYstrips(const Int_t iFirstStrip, const Int_t iLa
 
   for (Int_t istrip = iFirstStrip; istrip < iLastStrip; ++istrip) {
 
-    AliMpPad pad = fCurrentSeg->PadByIndices(AliMpIntPair(istrip,0),kTRUE);
+    AliMpPad pad = fkCurrentSeg->PadByIndices(istrip,0,kTRUE);
 
     if ( !pad.IsValid() )
     {
        StdoutToAliError(cout << "Pad not found in seg " << endl;
-                        fCurrentSeg->Print();
+                        fkCurrentSeg->Print();
                         cout << " ix,iy=" << istrip << "," << 0 << endl;
                         );
     }
-    Float_t xDim = pad.Dimensions().X(); // half size!
+    Float_t xDim = pad.GetDimensionX(); // half size!
 
     XYGlobal(pad,xyGlobal);
     
@@ -386,12 +389,12 @@ void AliMUONTriggerCircuit::XYGlobal(const AliMpPad& pad,
 /// note: no need for transformation for pad dimensions
   
   // get the pad position and dimensions
-  Double_t xl1 = pad.Position().X();
-  Double_t yl1 = pad.Position().Y();
+  Double_t xl1 = pad.GetPositionX();
+  Double_t yl1 = pad.GetPositionY();
   Double_t zg1 = 0;
   
   // positions from local to global 
-  fTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0, 
+  fkTransformer->Local2Global(fCurrentDetElem, xl1, yl1, 0, 
                                  xyGlobal[0], xyGlobal[1], zg1);
 }
 
@@ -425,8 +428,8 @@ Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
   Int_t iFirstStrip = -1;
   Int_t boardNumber = atoi(localBoard->GetName()+6);
 
-  Int_t iline = localBoard->GetPosition().GetFirst();
-  Int_t icol  = localBoard->GetPosition().GetSecond();
+  Int_t iline = AliMp::PairFirst(localBoard->GetPosition());
+  Int_t icol  = AliMp::PairSecond(localBoard->GetPosition());
   if ( iline == 5 ) --icol;
 
   switch (boardNumber)
@@ -448,3 +451,24 @@ Int_t AliMUONTriggerCircuit::FirstStrip(AliMpLocalBoard* localBoard)
   return iFirstStrip;
 }
 
+//----------------------------------------------------------------------
+Float_t AliMUONTriggerCircuit::PtCal(Int_t localBoardId, Int_t istripX, Int_t idev, Int_t istripY) const{
+/// returns calculated pt for circuit/istripX/idev/istripY according 
+/// to the formula of the TRD. Note : idev (input) is in [0+30]
+
+  //  Int_t jdev = idev - 15;        // jdev in [-15+15]
+  Int_t istripX2=istripX+idev+1; // find istripX2 using istripX and idev
+
+  Float_t yPosX1=fYpos11[localBoardId][istripX];
+  Float_t yPosX2=fYpos21[localBoardId][istripX2];
+  Float_t xPosY1=fXpos11[localBoardId][istripY];
+
+// Z distance between IP and center of dipole
+  Float_t zf= TMath::Abs(0.5 *(AliMUONConstants::CoilZ() + AliMUONConstants::YokeZ()));
+  Float_t z1=AliMUONConstants::DefaultChamberZ(10);
+  Float_t z2=AliMUONConstants::DefaultChamberZ(12);
+  Float_t thetaDev=(1./zf)*(yPosX1*z2-yPosX2*z1)/(z2-z1);
+  Float_t xf=xPosY1*zf/z1; 
+  Float_t yf=yPosX2-((yPosX2-yPosX1)*(z2-zf))/(z2-z1);
+  return (3.*0.3/TMath::Abs(thetaDev)) * TMath::Sqrt(xf*xf+yf*yf)/zf;
+}