]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONTriggerCircuit.cxx
20-sep-2005 NvE Dummy values 0 set for KAPPA-ADC and KAPPA-TOT for OMs in IceCal2Root
[u/mrichter/AliRoot.git] / MUON / AliMUONTriggerCircuit.cxx
index 767dfc3909aa2341e261c069ca257b00200db61f..9b443d26c571e5b2d4d99ff9aaeb87c7302dfeb1 100644 (file)
@@ -21,7 +21,7 @@
 #include "AliRun.h"
 #include "AliMUON.h"
 #include "AliMUONTriggerConstants.h"
-#include "AliSegmentation.h"
+#include "AliMUONGeometrySegmentation.h"
 #include "AliMUONChamber.h"
 #include "AliMUONConstants.h"
 #include "AliLog.h"
@@ -30,13 +30,13 @@ ClassImp(AliMUONTriggerCircuit)
 
 //----------------------------------------------------------------------
 AliMUONTriggerCircuit::AliMUONTriggerCircuit()
-  : TObject() 
+  : TObject(),
+    fIdCircuit(0),
+    fX2m(0),
+    fX2ud(0)
 {
 // Constructor
-  fSegmentation=0;
-  fIdCircuit=0;
-  fX2m=0;
-  fX2ud=0;
+
   fOrMud[0]=fOrMud[1]=0;
   Int_t i;  
   for (i=0; i<4; i++) {
@@ -76,11 +76,14 @@ AliMUONTriggerCircuit::operator=(const AliMUONTriggerCircuit& rhs)
 void AliMUONTriggerCircuit::Init(Int_t iCircuit) {
 // initialize circuit characteristics
   fIdCircuit=AliMUONTriggerConstants::CircuitId(iCircuit);
+
   LoadX2();
   LoadXCode();
   LoadYCode();
-  LoadXPos();
-  LoadYPos();
+
+  LoadXPos2();
+  LoadYPos2();
+  
 }
 
 //----------------------------------------------------------------------
@@ -280,31 +283,61 @@ void AliMUONTriggerCircuit::LoadYCode(){
 }
 
 //----------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadYPos(){
+Float_t AliMUONTriggerCircuit::PtCal(Int_t istripX, Int_t idev, Int_t istripY){
+// 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[istripX];
+  Float_t yPosX2=fYpos21[istripX2];
+  Float_t xPosY1=fXpos11[istripY];
+  
+  Float_t zf=975.;
+  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;
+}
+//---------------------------------------------------------------------
+//----------------------- New Segmentation ----------------------------
+//---------------------------------------------------------------------
+
+//---------------------------------------------------------------------
+void AliMUONTriggerCircuit::LoadYPos2(){
 // fill fYpos11 and fYpos21 -> y position of X declusterized strips
 
   Int_t chamber, cathode;
   Int_t code, idModule, idStrip, idSector;
   Float_t x, y, z, width;
-  Int_t istrip;
+  Int_t istrip, idDE;
 
   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");  
   AliMUONChamber*  iChamber;
-  AliSegmentation*  segmentation;    
-
+  AliMUONGeometrySegmentation* segmentation;    
+  
 // first plane (11)
   chamber=11;
   cathode=1;
   iChamber = &(pMUON->Chamber(chamber-1));
-  segmentation=iChamber->SegmentationModel(cathode);
+  segmentation=iChamber->SegmentationModel2(cathode);
   
+  if (!segmentation) {
+    AliWarning("Segmentation not defined.");
+    return;
+  }  
+
   for (istrip=0; istrip<16; istrip++) {
     code=fXcode[0][istrip];           // decode current strip
     idModule=Int_t(code/100);           // corresponding module Id.
+    idDE = DetElemId(chamber, idModule);
     idStrip=TMath::Abs(code-idModule*100); // corresp. strip number in module
-    idSector=segmentation->Sector(idModule,idStrip); // corresponding sector
-    width=segmentation->Dpy(idSector);      // corresponding strip width
-    segmentation->GetPadC(idModule,idStrip,x,y,z); // get strip real position
+    idSector=segmentation->Sector(idDE, idModule, idStrip); // corresponding sector
+    width=segmentation->Dpy(idDE, idSector);      // corresponding strip width
+    segmentation->GetPadC(idDE, idModule,idStrip,x,y,z); // get strip real position
     
     fYpos11[2*istrip]=y;
     if (istrip!=15) fYpos11[2*istrip+1]=y+width/2.;
@@ -314,15 +347,17 @@ void AliMUONTriggerCircuit::LoadYPos(){
   chamber=13;
   cathode=1;
   iChamber = &(pMUON->Chamber(chamber-1));
-  segmentation=iChamber->SegmentationModel(cathode);
+  segmentation=iChamber->SegmentationModel2(cathode);
   
   for (istrip=0; istrip<32; istrip++) {
     code=fXcode[2][istrip];    // decode current strip
     idModule=Int_t(code/100);           // corresponding module Id.
+    idDE = DetElemId(chamber, idModule);
+    if (idModule == 0) continue;
     idStrip=TMath::Abs(code-idModule*100); // corresp. strip number in module
-    idSector=segmentation->Sector(idModule,idStrip); // corresponding sector
-    width=segmentation->Dpy(idSector);      // corresponding strip width
-    segmentation->GetPadC(idModule,idStrip,x,y,z); // get strip real position
+    idSector=segmentation->Sector(idDE, idModule, idStrip); // corresponding sector
+    width=segmentation->Dpy(idDE, idSector);      // corresponding strip width
+    segmentation->GetPadC(idDE, idModule,idStrip,x,y,z); // get strip real position
     
 // using idModule!=0 prevents to fill garbage in case of circuits 
 // in the first and last rows 
@@ -334,67 +369,53 @@ void AliMUONTriggerCircuit::LoadYPos(){
 }
 
 //----------------------------------------------------------------------
-void AliMUONTriggerCircuit::LoadXPos(){
+void AliMUONTriggerCircuit::LoadXPos2(){
 // fill fXpos11 -> x position of Y strips for the first plane only
 // fXpos11 contains the x position of Y strip for the current circuit
 // taking into account whether or nor not part(s) of the circuit
 // (middle, up or down) has(have) 16 strips
   
   Float_t x, y, z;
-  Int_t istrip;  
+  Int_t istrip, idDE;  
 
   Int_t chamber=11;
   Int_t cathode=2;
   AliMUON *pMUON  = (AliMUON*)gAlice->GetModule("MUON");  
   AliMUONChamber*  iChamber;
-  AliSegmentation*  segmentation; 
+  AliMUONGeometrySegmentation*  segmentation; 
   iChamber = &(pMUON->Chamber(chamber-1));
-  segmentation=iChamber->SegmentationModel(cathode);
+  segmentation=iChamber->SegmentationModel2(cathode);
+  
+  if (!segmentation) {
+    AliWarning("Segmentation not defined.");
+    return;
+  }  
   
   Int_t idModule=Module(fIdCircuit);        // corresponding module Id.  
 // number of Y strips
+  idDE = DetElemId(chamber, idModule);
+
   Int_t nStrY=AliMUONTriggerConstants::NstripY(ModuleNumber(idModule)); 
-  Int_t idSector=segmentation->Sector(idModule,0); // corresp. sector
-  Float_t width=segmentation->Dpx(idSector);      // corresponding strip width
+  Int_t idSector=segmentation->Sector(idDE, idModule,0); // corresp. sector
+  Float_t width=segmentation->Dpx(idDE, idSector);      // corresponding strip width
   
 // first case : up middle and down parts have all 8 or 16 strip 
   if ((nStrY==16)||(nStrY==8&&fX2m==0&&fX2ud==0)) { 
     for (istrip=0; istrip<nStrY; istrip++) {
-      segmentation->GetPadC(idModule,istrip,x,y,z); 
+      segmentation->GetPadC(idDE, idModule,istrip,x,y,z); 
       fXpos11[istrip]=x;
     }
 // second case : mixing 8 and 16 strips within same circuit      
   } else {
     for (istrip=0; istrip<nStrY; istrip++) {
       if (nStrY!=8) { printf(" bug in LoadXpos \n");}
-      segmentation->GetPadC(idModule,istrip,x,y,z); 
+      segmentation->GetPadC(idDE, idModule, istrip, x, y, z); 
       fXpos11[2*istrip]=x-width/4.;
       fXpos11[2*istrip+1]=fXpos11[2*istrip]+width/2.;
     }
   }   
 }
 
-//----------------------------------------------------------------------
-Float_t AliMUONTriggerCircuit::PtCal(Int_t istripX, Int_t idev, Int_t istripY){
-// 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[istripX];
-  Float_t yPosX2=fYpos21[istripX2];
-  Float_t xPosY1=fXpos11[istripY];
-  
-  Float_t zf=975.;
-  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;
-}
-
 //----------------------------------------------------------------------
 //--- methods which return member data related info
 //----------------------------------------------------------------------
@@ -500,7 +521,19 @@ Float_t AliMUONTriggerCircuit::GetX11Pos(Int_t istrip) const {
 //----------------------------------------------------------------------
 
 
-
+Int_t AliMUONTriggerCircuit::DetElemId(Int_t ichamber, Int_t idModule)
+{
+// 07/22/05 bug found by Christophe. 
+// due to the inversion right-left of detElemId somewhere in the code
+// (AliMUONTriggerGeometrybuilder is correct!!!)
+// fixed temporary here. to be changed with official numbering of DeElemId.
+//
+// returns the detection element Id for given chamber and module
+// ichamber (from 11 to 14), idModule (from 11 to 97)
+//    Int_t itmp = (idModule > 0) ? 0 : 50; // right=0, left=50   
+    Int_t itmp = (idModule > 0) ? 50 : 0; // right=50, left=0   
+    return (ichamber*100)+itmp+(9-Int_t(TMath::Abs(idModule)/10));
+}