]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Reco Interface: changed sensor mapping in the layer to account for multiple rows
authorshahoian <ruben.shahoyan@cern.ch>
Fri, 7 Mar 2014 20:29:32 +0000 (21:29 +0100)
committershahoian <ruben.shahoyan@cern.ch>
Fri, 7 Mar 2014 20:29:32 +0000 (21:29 +0100)
ITS/UPGRADE/AliITSUAux.h
ITS/UPGRADE/AliITSUGeomTGeo.cxx
ITS/UPGRADE/AliITSURecoLayer.cxx
ITS/UPGRADE/AliITSURecoLayer.h
ITS/UPGRADE/AliITSURecoSens.cxx
ITS/UPGRADE/AliITSURecoSens.h
ITS/UPGRADE/AliITSUTrackerGlo.cxx

index 39b548071e3891bf929808f6cc8cbba8c93d93c9..abad138c368c6db8d1b46c7493ecf8614a9cb637 100644 (file)
@@ -24,6 +24,8 @@ namespace AliITSUAux {
   void   BringTo02Pi(double &phi);
   Bool_t OKforPhiMin(double phiMin,double phi);
   Bool_t OKforPhiMax(double phiMax,double phi);
+  Double_t MeanPhiSmall(double phi0, double phi1);
+  Double_t DeltaPhiSmall(double phi0, double phi1);
   UInt_t PackCluster(Int_t lr, Int_t clID);
   Int_t  UnpackCluster(UInt_t p, Int_t &lr);
   Int_t  UnpackLayer(UInt_t p);
@@ -102,5 +104,26 @@ inline Int_t AliITSUAux::NumberOfBitsSet(UInt_t x) {
   return (((x + (x >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24;
 }
 
+//_________________________________________________________________________________
+inline Double_t AliITSUAux::MeanPhiSmall(double phi0, double phi1) {
+  // return mean phi, assume phis in 0:2pi
+  double phi;
+  if (!OKforPhiMin(phi0,phi1)) {phi=phi0; phi0=phi1; phi1=phi;}
+  if (phi0>phi1) phi = (phi1 - (TwoPi()-phi0))/2; // wrap
+  else           phi = (phi0+phi1)/2;
+  BringTo02Pi(phi);
+  return phi;
+}
+
+//_________________________________________________________________________________
+inline Double_t AliITSUAux::DeltaPhiSmall(double phi0, double phi1) {
+  // return delta phi, assume phis in 0:2pi
+  double del;
+  if (!OKforPhiMin(phi0,phi1)) {del=phi0; phi0=phi1; phi1=del;}
+  del = phi1 - phi0;
+  if (del<0) del += TwoPi();
+  return del;
+}
+
 
 #endif
index 3ed6532cc69ed68b49e342e41236443ab291d2ca..0fbd5386f9953df215a564a694096c819291aa7e 100644 (file)
@@ -951,7 +951,7 @@ void AliITSUGeomTGeo::Print(Option_t *) const
   printf("Geometry version %d, NLayers:%d NChips:%d\n",fVersion,fNLayers,fNChips);
   if (fVersion==kITSVNA) return;
   for (int i=0;i<fNLayers;i++) {
-    printf("Lr%2d\tNStav:%2d\tNChips:%2d (%dx%-2d)\tNMod:%d\tNSubSt:%d\tNSt:%3d\tChipType:%3d\tChip#:%4d:%4d\tWrapVol:%d\n",
+    printf("Lr%2d\tNStav:%2d\tNChips:%2d (%dx%-2d)\tNMod:%d\tNSubSt:%d\tNSt:%3d\tChipType:%3d\tChip#:%5d:%-5d\tWrapVol:%d\n",
           i,fNStaves[i],fNChipsPerModule[i],fNChipRowsPerModule[i],
           fNChipRowsPerModule[i] ? fNChipsPerModule[i]/fNChipRowsPerModule[i] : 0,
           fNModules[i],fNHalfStaves[i],fNStaves[i],
index c2f6f3a33e8cbcf1d49b5f71e1ed693ada6c00c7..69f1b16e872881957a3fc6fd44912547ac2ce2f2 100644 (file)
@@ -16,18 +16,17 @@ ClassImp(AliITSURecoLayer)
 AliITSURecoLayer::AliITSURecoLayer(const char* name)
   :fActiveID(-1)
   ,fNSensors(0)
-  ,fNSensInStave(0)
-  ,fNStaves(0)
+  ,fNSensorRows(0)
+  ,fNSensorsPerRow(0)
+  ,fSensVIDtoMatrixID(0)
   ,fR(0)
   ,fRMax(0)
   ,fRMin(0)
   ,fZMax(0)
   ,fZMin(0)
-  ,fPhiStaMax(0)
-  ,fPhiStaMin(0)
   ,fPhiOffs(0)
   ,fSensDZInv(0)
-  ,fDPhiStaInv(0)
+  ,fSensDPhiInv(0)
   ,fMaxStep(0.5)
   ,fSensors(0)
   ,fITSGeom(0)
@@ -41,18 +40,17 @@ AliITSURecoLayer::AliITSURecoLayer(const char* name)
 AliITSURecoLayer::AliITSURecoLayer(const char* name, Int_t activeID, AliITSUGeomTGeo* gm)
   :fActiveID(activeID)
   ,fNSensors(0)
-  ,fNSensInStave(0)
-  ,fNStaves(0)
+  ,fNSensorRows(0)
+  ,fNSensorsPerRow(0)
+  ,fSensVIDtoMatrixID(0)
   ,fR(0)
   ,fRMax(0)
   ,fRMin(0)
   ,fZMax(0)
   ,fZMin(0)
-  ,fPhiStaMax(0)
-  ,fPhiStaMin(0)
   ,fPhiOffs(0)
   ,fSensDZInv(0)
-  ,fDPhiStaInv(0)
+  ,fSensDPhiInv(0)
   ,fMaxStep(0.5)
   ,fSensors(0)
   ,fITSGeom(gm)
@@ -67,9 +65,8 @@ AliITSURecoLayer::AliITSURecoLayer(const char* name, Int_t activeID, AliITSUGeom
 AliITSURecoLayer::~AliITSURecoLayer()
 {
   // def. d-tor
-  delete[] fSensors;
-  delete[] fPhiStaMax;
-  delete[] fPhiStaMin;
+  delete fSensors;
+  delete[] fSensVIDtoMatrixID;
   if (GetOwnsClusterArray()) delete fClusters;
 }
 
@@ -77,8 +74,10 @@ AliITSURecoLayer::~AliITSURecoLayer()
 void AliITSURecoLayer::Print(Option_t* opt) const                            
 {
   //print 
-  printf("Lr %-15s %d (act:%+d), NSens: %4d | MaxStep:%.2f ",GetName(),GetID(),GetActiveID(),GetNSensors(),fMaxStep);
-  printf("%6.3f<R<%6.3f | %+8.3f<Z<%+8.3f dZ:%6.3f\n",fRMin,fRMax,fZMin,fZMax,fSensDZInv>0 ? 1/fSensDZInv : 0);
+  printf("Lr %-15s %d (act:%+d), NSens: %4d in %d rows| MaxStep:%.2f ",
+        GetName(),GetID(),GetActiveID(),GetNSensors(),GetNSensorRows(),fMaxStep);
+  printf("%6.3f<R<%6.3f | %+8.3f<Z<%+8.3f dZ:%6.3f dPhi:%6.3f\n",fRMin,fRMax,fZMin,fZMax,
+        fSensDZInv>0 ? 1/fSensDZInv : 0, fSensDPhiInv>0 ? 1/fSensDPhiInv : 0);
   TString opts = opt; opts.ToLower();
   if (opts.Contains("sn")) for (int i=0;i<GetNSensors();i++) GetSensor(i)->Print(opt);
 }
@@ -89,50 +88,50 @@ void AliITSURecoLayer::Build()
   // build internal structures
   const double kSafeR = 0.05; // safety margin for Rmin,Rmax of the layer
   if (fActiveID<0) return;
-  fNStaves = fITSGeom->GetNStaves(fActiveID);
-  fNSensInStave = fITSGeom->GetNChipsPerModule(fActiveID);
-  fNSensors = fNStaves*fNSensInStave;
-  fSensors = new AliITSURecoSens*[fNSensors];
+  //
+  int nStaves=fITSGeom->GetNStaves(fActiveID);
+  // determine number of sensor rows (sensors aligned at same phi and spanning the Z range of the layer)
+  fNSensorRows = nStaves;
+  //
+  // if the stave has susbtaves, each substave can have multiple rows of sensors (but just 1 row of modules)
+  if (fITSGeom->GetNHalfStaves(fActiveID)>0) fNSensorRows *= fITSGeom->GetNHalfStaves(fActiveID);
+  //
+  // if there are modules defined, the module may have multiple rows of sensors (though not spanning full Z)
+  if (fITSGeom->GetNModules(fActiveID)>0) fNSensorRows *= fITSGeom->GetNChipRowsPerModule(fActiveID);
+  //
+  fNSensors = fITSGeom->GetNChipsPerLayer(fActiveID);
+  fNSensorsPerRow = fNSensors/fNSensorRows;
+  //
+  fSensors = new TObjArray(fNSensors);
+  fSensVIDtoMatrixID = new Int_t[fNSensors];
   const AliITSsegmentation* kSegm = fITSGeom->GetSegmentation(fActiveID);
   //
-  // name layer according its active id, detector type and segmentation tyoe
   TGeoHMatrix mmod;
   const TGeoHMatrix* mt2l;
-  fRMin=fZMin=1e9;
-  fRMax=fZMax=-1e9;
   double phiTF,rTF, loc[3]={0,0,0},glo[3];
-  fNSensors = 0;
-  fPhiStaMin = new Double_t[fNStaves];
-  fPhiStaMax = new Double_t[fNStaves];
-  fSensDZInv = 0;
-  fDPhiStaInv = fNStaves/TwoPi();
-  //
-  for (int ild=0;ild<fNStaves;ild++) {
-    fPhiStaMin[ild] = 1e9;
-    fPhiStaMax[ild] = -1e9;
-    //
-    for (int idt=0;idt<fNSensInStave;idt++) {
-      AliITSURecoSens* sens = new AliITSURecoSens(fNSensors++);
-      fSensors[ild*fNSensInStave+idt] = sens;
-      //
+  //
+  int nSensPerStave = fITSGeom->GetNChipsPerStave(fActiveID);
+  for (int staveI=0;staveI<nStaves;staveI++) {
+    for (int sensI=0;sensI<nSensPerStave;sensI++) {
+      int sID = fITSGeom->GetChipIndex(fActiveID,staveI,sensI);
+      AliITSURecoSens* sens = new AliITSURecoSens( sID );
+      fSensors->AddLast(sens);
       double phiMin=1e9,phiMax=-1e9,zMin=1e9,zMax=-1e9;
-      mmod = *fITSGeom->GetMatrixSens(fActiveID,ild,idt);
-      for (int ix=0;ix<2;ix++) {
+      // this is NOT the sensor matrix, just the ideal chip matrix to get neighbors correct
+      fITSGeom->GetOrigMatrix(sID,mmod); 
+      //
+      for (int ix=0;ix<2;ix++) {       // determine sensor boundaries (ideal)
        loc[0] = (ix-0.5)*kSegm->Dx(); // +-DX/2
        for (int iy=0;iy<2;iy++) {
          loc[1] = (iy-0.5)*kSegm->Dy(); // +-DY/2
          for (int iz=0;iz<2;iz++) {
            loc[2] = (iz-0.5)*kSegm->Dz(); // +-DZ/2
-           //
            mmod.LocalToMaster(loc,glo);
            double phi = ATan2(glo[1],glo[0]);
-           double r   = glo[0]*glo[0] + glo[1]*glo[1];
-           if (fRMin>r) fRMin = r;
-           if (fRMax<r) fRMax = r;
            BringTo02Pi(phi);
-           if      (phiMin>1e8) phiMin=phi; 
+           if      (phiMin>1e8)  phiMin=phi;
            else if (!OKforPhiMin(phiMin,phi)) phiMin=phi;
-           if      (phiMax<-1e8) phiMax=phi;
+           if      (phiMax<-1e8) phiMax=phi; 
            else if (!OKforPhiMax(phiMax,phi)) phiMax=phi;            
            if (glo[2]>zMax) zMax=glo[2];
            if (glo[2]<zMin) zMin=glo[2];
@@ -140,107 +139,101 @@ void AliITSURecoLayer::Build()
        }
       }
       sens->SetBoundaries(phiMin,phiMax,zMin,zMax);
-      mt2l = fITSGeom->GetMatrixT2L(fActiveID,ild,idt);
-      mmod.Multiply(mt2l);     
-      loc[0]=loc[1]=loc[2]=0;
-      mmod.LocalToMaster(loc,glo);
-      rTF   = Sqrt(glo[0]*glo[0] + glo[1]*glo[1]);  //  tracking params (misaligned)
-      phiTF = ATan2(glo[1],glo[0]);
-      BringTo02Pi(phiTF);
-      //
-      sens->SetXTF(rTF);
-      sens->SetPhiTF(phiTF);
-      //
-      if      (fPhiStaMin[ild]>1e8)  fPhiStaMin[ild] = phiMin;
-      else if (!OKforPhiMin(fPhiStaMin[ild],phiMin)) fPhiStaMin[ild] = phiMin;
-      if      (fPhiStaMax[ild]<-1e8) fPhiStaMax[ild] = phiMax;
-      else if (!OKforPhiMax(fPhiStaMax[ild],phiMax)) fPhiStaMax[ild] = phiMax;
-      if (fZMin>zMin) fZMin = zMin;
-      if (fZMax<zMax) fZMax = zMax;
-      //
-      if (idt>0) fSensDZInv += zMax - GetSensor(ild,idt-1)->GetZMax(); // z interval to previous
     }
   }
+  fSensors->Sort(); // sort sensors to get the neighborhood correct
+  //
+  // now fill real sensor angles, Z's, accounting for misalignment
+  fRMin=fZMin=1e9;
+  fRMax=fZMax=-1e9;
+  //
+  fPhiOffs = 0;
+  int firstSensID = fITSGeom->GetFirstChipIndex(fActiveID);
+  for (int sensI=0;sensI<fNSensors;sensI++) {
+    AliITSURecoSens* sens = GetSensor(sensI);
+    mmod = *fITSGeom->GetMatrixSens(sens->GetID());
+    fSensVIDtoMatrixID[sens->GetID() - firstSensID] = sensI;
+    double phiMin=1e9,phiMax=-1e9,zMin=1e9,zMax=-1e9;
+    for (int ix=0;ix<2;ix++) {
+      loc[0] = (ix-0.5)*kSegm->Dx(); // +-DX/2
+      for (int iy=0;iy<2;iy++) {
+       loc[1] = (iy-0.5)*kSegm->Dy(); // +-DY/2
+       for (int iz=0;iz<2;iz++) {
+         loc[2] = (iz-0.5)*kSegm->Dz(); // +-DZ/2
+         //
+         mmod.LocalToMaster(loc,glo);
+         double phi = ATan2(glo[1],glo[0]);
+         double r   = glo[0]*glo[0] + glo[1]*glo[1];
+         if (fRMin>r) fRMin = r;
+         if (fRMax<r) fRMax = r;
+         BringTo02Pi(phi);
+         if      (phiMin>1e8) phiMin=phi; 
+         else if (!OKforPhiMin(phiMin,phi)) phiMin=phi;
+         if      (phiMax<-1e8) phiMax=phi;
+         else if (!OKforPhiMax(phiMax,phi)) phiMax=phi;              
+         if (glo[2]>zMax) zMax=glo[2];
+         if (glo[2]<zMin) zMin=glo[2];
+       }
+      }
+    }
+    mt2l = fITSGeom->GetMatrixT2L( sens->GetID() );
+    mmod.Multiply(mt2l);       
+    loc[0]=loc[1]=loc[2]=0;
+    mmod.LocalToMaster(loc,glo);
+    rTF   = Sqrt(glo[0]*glo[0] + glo[1]*glo[1]);  //  tracking params (misaligned)
+    phiTF = ATan2(glo[1],glo[0]);
+    BringTo02Pi(phiTF);
+    //
+    sens->SetXTF(rTF);
+    sens->SetPhiTF(phiTF);
+    sens->SetBoundaries(phiMin,phiMax,zMin,zMax);
+    if (fZMin>zMin) fZMin = zMin;
+    if (fZMax<zMax) fZMax = zMax;
+    //
+    if (sensI<fNSensorsPerRow) fPhiOffs += MeanPhiSmall(phiMax,phiMin);
+  }
+  //
+  fPhiOffs /= fNSensorsPerRow; // average phi of the 1st row
+  fSensDZInv = fNSensorsPerRow/(fZMax-fZMin);
+  fSensDPhiInv = fNSensorRows/(2*Pi());
   //
   fRMin = Sqrt(fRMin);
   fRMax = Sqrt(fRMax);
   fR = 0.5*(fRMin+fRMax);
   fRMin -= kSafeR;
   fRMax += kSafeR;
-  double dz = fNSensInStave>0 ? fSensDZInv/(fNSensInStave-1)/fNStaves : fZMax-fZMin;
-  fSensDZInv = 1./dz;
-
-  const int kNBId[3][3] = { 
-    {AliITSURecoSens::kNghbBL,AliITSURecoSens::kNghbB,AliITSURecoSens::kNghbBR},
-    {AliITSURecoSens::kNghbL,          -1            ,AliITSURecoSens::kNghbR },
-    {AliITSURecoSens::kNghbTL,AliITSURecoSens::kNghbT,AliITSURecoSens::kNghbTR}
-  };
-
-  // add neighbours info
-  double zTol = 0.45*dz, phiTol = 0.45*TwoPi()/fNStaves;
-  for (int ild=0;ild<fNStaves;ild++) {
-    for (int idt=0;idt<fNSensInStave;idt++) {
-      AliITSURecoSens* sens = GetSensor(ild,idt);
-      //
-      for (int ils=-1;ils<=1;ils++) {
-       int ildN = ild+ils;  // staves of neighbouring sensors
-       if (ildN<0) ildN = fNStaves-1; else if (ildN==fNStaves) ildN = 0;
-       for (int ids=-1;ids<=1;ids++) {
-         int idtN = idt+ids;
-         if (idtN<0 || idtN==fNSensInStave || (ids==0&&ils==0)) continue;
-         AliITSURecoSens* sensN = GetSensor(ildN,idtN); // potential neighbor
-         int neighbID = ildN*fNSensInStave+idtN;
-         //      
-         int zType = 1;  // side
-         if (sens->GetZMin()-zTol  > sensN->GetZMax()) continue; // too large distance
-         if (sensN->GetZMin()-zTol > sens->GetZMax() ) continue; // too large distance
-         if      (sens->GetZMin()-zTol>sensN->GetZMin()) zType =  0;     // bottom
-         else if (sensN->GetZMin()-zTol>sens->GetZMin()) zType =  2;     // top
-         //
-         int phiType = 1;
-
-         double phiTstMn = sensN->GetPhiMin()-phiTol;
-         BringTo02Pi(phiTstMn);
-         if (!OKforPhiMax(sens->GetPhiMax(),phiTstMn)) continue; // too large angle      
-         double phiTstMx = sensN->GetPhiMax()+phiTol;    
-         BringTo02Pi(phiTstMx);
-         if (!OKforPhiMin(sens->GetPhiMin(),phiTstMx)) continue; // too large angle
-         //
-         phiTstMn = sensN->GetPhiMin()+phiTol;
-         BringTo02Pi(phiTstMn);
-         phiTstMx = sensN->GetPhiMax()-phiTol;   
-         BringTo02Pi(phiTstMx);
-         if      (!OKforPhiMax(sens->GetPhiMax(),phiTstMx)) phiType = 0; // left
-         else if (!OKforPhiMin(sens->GetPhiMin(),phiTstMn)) phiType = 2; // right
-         //
-         sens->SetNeighborID(kNBId[zType][phiType], neighbID);
-       } // phi scan
-      } // z scan
-    } // sensors
-  } // staves
   //
 }
 
 //______________________________________________________
-Int_t AliITSURecoLayer::FindSensors(const double* impPar, AliITSURecoSens *sensors[AliITSURecoSens::kNNeighbors])
+Int_t AliITSURecoLayer::FindSensors(const double* impPar, AliITSURecoSens *sensors[kNNeighbors])
 {
   // find sensors having intersection with track
   // impPar contains: lab phi of track, dphi, labZ, dz
   //
+  return 0;
+  /*
   double z = impPar[2];
   if (z>fZMax+impPar[3]) return 0; // outside of Z coverage
   z -= fZMin;
   if (z<-impPar[3]) return 0; // outside of Z coverage
-  int sensInSta = int(z*fSensDZInv);
-  if      (sensInSta<0) sensInSta = 0;
-  else if (sensInSta>=fNSensInStave) sensInSta = fNSensInStave-1;
+  int sensInRow = int(z*fSensDZInv);
+  if      (sensInRow<0) sensInRow = 0;
+  else if (sensInRow>=fNSensorsPerRow) sensInRow = fNSensorsPerRow-1;
   //
   double phi = impPar[0] - fPhiOffs;
   BringTo02Pi(phi);
-  int staID = int(phi*fDPhiStaInv);  // stave id
+  int rowID = int(phi*fSensDPhiInv);  // stave id
+  //
+  int sensID = rowID*fNSensorsPerRow + sensInRow; // most probable candidate
   int nsens = 0;
   //
-  AliITSURecoSens* sensN,*sens = GetSensor(staID*fNSensInStave+sensInSta);
+  AliITSURecoSens* sensN,*sens = GetSensor(sesnID);
+  //
+  // make sure this is best matching sensor
+  if (sens->GetZMin()<impPar[2] && sens->GetZMax()>impPar[2] && 
+      OKforPhiMin(sens->GetPhiMin(),impPar[0]) && OKforPhiMax(sens->GetPhiMax(),impPar[0]) ) 
+
   sensors[nsens++] = sens;
   //
   // check neighbours
@@ -273,7 +266,9 @@ Int_t AliITSURecoLayer::FindSensors(const double* impPar, AliITSURecoSens *senso
   if (sensN && OKforPhiMin(phiMn,sensN->GetPhiMax()) && sensN->GetZMax()>zMn) sensors[nsens++] = sensN;
   //
   return nsens;
+  */
 }
+
 //*/
 /*
 Int_t AliITSURecoLayer::FindSensors(const double* impPar, AliITSURecoSens *sensors[AliITSURecoSens::kNNeighbors],int mcLab)
@@ -320,7 +315,7 @@ Int_t AliITSURecoLayer::FindSensors(const double* impPar, AliITSURecoSens *senso
   //
   double phi = impPar[0] - fPhiOffs;
   BringTo02Pi(phi);
-  int staID = int(phi*fDPhiStaInv);  // stave id
+  int staID = int(phi*fSensDPhiInv);  // stave id
   int nsens = 0;
   //
   AliITSURecoSens* sensN,*sens = GetSensor(staID*fNSensInStave+sensInSta);
@@ -425,5 +420,5 @@ AliITSURecoSens* AliITSURecoLayer::GetSensorFromID(Int_t i) const
   // get sensor from its global id
   i -= fITSGeom->GetFirstChipIndex(fActiveID);
   if (i<0||i>=fNSensors) AliFatal(Form("Sensor with id=%d is not in layer %d",i+fITSGeom->GetFirstChipIndex(fActiveID),fActiveID));
-  return (AliITSURecoSens*)fSensors[i];
+  return GetSensor(SensVIDtoMatrixID(i));
 }
index 23e933765fc48790001e145018bda512042b2b9e..7ac5c87d03d94d1ab178a4c93018ccd04ec2b053 100644 (file)
@@ -22,6 +22,8 @@ class AliCluster;
 class AliITSURecoLayer : public TNamed
 {
  public:
+  //
+  enum {kNghbR,kNghbTR,kNghbT,kNghbTL,kNghbL,kNghbBL,kNghbB,kNghbBR,kNNeighbors}; // neighbors: Top,Left etc
   //
   enum {kPassive=BIT(14)                 // layer is passive
        ,kOwnsClusterArray=BIT(15)       // owner of cluster array, delete in destructor
@@ -35,8 +37,8 @@ class AliITSURecoLayer : public TNamed
   Int_t              GetID()                       const {return (int)GetUniqueID();}
   Int_t              GetActiveID()                 const {return fActiveID;}
   Int_t              GetNSensors()                 const {return fNSensors;}
-  Int_t              GetNStaves()                 const {return fNStaves;}
-  Int_t              GetNSensInStave()            const {return fNSensInStave;}
+  Int_t              GetNSensorRows()              const {return fNSensorRows;}
+  Int_t              GetNSensorsPerRow()           const {return fNSensorsPerRow;}
   Double_t           GetRMin()                     const {return fRMin;}
   Double_t           GetRMax()                     const {return fRMax;}
   Double_t           GetDR()                       const {return fRMax-fRMin;}
@@ -60,8 +62,9 @@ class AliITSURecoLayer : public TNamed
   void               SetOwnsClusterArray(Bool_t v=kTRUE) {SetBit(kOwnsClusterArray,v);}
   void               SetMaxStep(Double_t st)             {fMaxStep = st>0 ? st : 0.1;}
   //
-  AliITSURecoSens*   GetSensor(Int_t i)            const {return i<0 ? 0:(AliITSURecoSens*)fSensors[i];}
-  AliITSURecoSens*   GetSensor(Int_t ld,Int_t is)  const {return GetSensor(ld*fNSensInStave+is);}
+  AliITSURecoSens*   GetSensor(Int_t i)            const {return (AliITSURecoSens*)fSensors->UncheckedAt(i);}
+  AliITSURecoSens*   GetSensor(Int_t row,Int_t sinrow)  const {return GetSensor(sinrow+row*fNSensorsPerRow);}
+  //
   AliITSURecoSens*   GetSensorFromID(Int_t i)      const;
   TClonesArray*      GetClusters()                 const {return (TClonesArray*)fClusters;}
   TClonesArray**     GetClustersAddress()                {return (TClonesArray**)&fClusters;}  
@@ -70,7 +73,7 @@ class AliITSURecoLayer : public TNamed
   void               SetClusters(TClonesArray* cl)       {fClusters = cl;}
   //
   //  Int_t              FindSensors(const double* impPar, AliITSURecoSens *sensors[AliITSURecoSens::kNNeighbors], int mcLab=-1);
-  Int_t              FindSensors(const double* impPar, AliITSURecoSens *sensors[AliITSURecoSens::kNNeighbors]);
+  Int_t              FindSensors(const double* impPar, AliITSURecoSens *sensors[kNNeighbors]);
   //
   virtual void       Print(Option_t* option = "")  const;
   virtual Bool_t     IsSortable()                  const {return kTRUE;}
@@ -79,24 +82,24 @@ class AliITSURecoLayer : public TNamed
   //
  protected:
   void               Build();
+  Int_t              SensVIDtoMatrixID(Int_t i)    const {return fSensVIDtoMatrixID[i];}
   //
  protected:
   Int_t              fActiveID;  // ID within active layers
   Int_t              fNSensors;  // N of chips
-  Int_t              fNSensInStave; // N sensors in the stave
-  Int_t              fNStaves;  // N stave
+  Int_t              fNSensorRows; // N of sensor rows (sensors aligned at same phi and spanning the Z range of the layer)
+  Int_t              fNSensorsPerRow; // number of sensors in a row
+  Int_t*             fSensVIDtoMatrixID; //[fNSensors]
   Double_t           fR;         // mean R
   Double_t           fRMax;      // max  R
   Double_t           fRMin;      // min  R
   Double_t           fZMax;      // max  Z
   Double_t           fZMin;      // min  Z
-  Double_t*          fPhiStaMax; // max lab phi of the stave
-  Double_t*          fPhiStaMin; // min lab phi of the stave
   Double_t           fPhiOffs;   // offset in phi for 1st stave
   Double_t           fSensDZInv; // inverse mean sensor Z span
-  Double_t           fDPhiStaInv;// inverse mean stave dphi
+  Double_t           fSensDPhiInv;// inverse mean sensor dphi
   Double_t           fMaxStep;   // max step in tracking X allowed within layer
-  AliITSURecoSens**  fSensors;   // sensors
+  TObjArray*         fSensors;   // sensors
   AliITSUGeomTGeo*   fITSGeom;   // geometry interface
   TClonesArray*      fClusters;  // clusters of the layer
   //
index a8770bb986a8be38f2f984be3a04e4b7bc525df1..91e916d9265409f016621f078951d934048dd623 100644 (file)
@@ -2,6 +2,11 @@
 #include "AliITSUGeomTGeo.h"
 #include "AliITSsegmentation.h"
 #include "AliExternalTrackParam.h"
+#include "AliITSUAux.h"
+#include "AliLog.h"
+
+using namespace AliITSUAux;
+using namespace TMath;
 
 ClassImp(AliITSURecoSens)
 
@@ -18,7 +23,6 @@ AliITSURecoSens::AliITSURecoSens(Int_t id)
 {
   // def. c-tor
   SetID(id);
-  for (int i=kNNeighbors;i--;) fNeighbors[i] = -1;
 }
 
 //______________________________________________________
@@ -34,7 +38,6 @@ AliITSURecoSens::AliITSURecoSens(const AliITSURecoSens &source)
   ,fZMax(source.fZMax)
 {
   // copy c-tor
-  for (int i=kNNeighbors;i--;) fNeighbors[i] = source.fNeighbors[i];
 }
 
 //______________________________________________________
@@ -52,7 +55,6 @@ AliITSURecoSens& AliITSURecoSens::operator=(const AliITSURecoSens &source)
   fZMin   = source.fZMin;
   fZMax   = source.fZMax;
   //
-  for (int i=kNNeighbors;i--;) fNeighbors[i] = source.fNeighbors[i];
   return *this;
 }
 
@@ -70,9 +72,8 @@ void AliITSURecoSens::SetBoundaries(double phiMn,double phiMx, double zMn, doubl
 void AliITSURecoSens::Print(Option_t*) const                         
 {
   //print 
-  printf("Sensor%4d xTF=%+.3e phiTF=%+.3e | Phi:[%5.3f:%5.3f] Z:[%+7.3f:%+7.3f]| Neighb.:",
+  printf("Sensor%4d xTF=%+.3e phiTF=%+.3e | Phi:[%5.3f:%5.3f] Z:[%+7.3f:%+7.3f]\n",
         GetID(),GetXTF(),GetPhiTF(), fPhiMin,fPhiMax, fZMin,fZMax);
-  for (int i=0;i<kNNeighbors;i++) printf(" %4d",fNeighbors[i]); printf("\n");
 }
 
 //______________________________________________________
@@ -90,3 +91,36 @@ void AliITSURecoSens::ProcessClusters(Int_t)
   //
   // to do
 }
+
+//______________________________________________________________________________
+Int_t AliITSURecoSens::Compare(const TObject* obj)  const
+{
+  // compare sensor positions
+  AliITSURecoSens* copy = (AliITSURecoSens*)obj;
+  double phi  = MeanPhiSmall(fPhiMin,fPhiMax);
+  double phiC = MeanPhiSmall(copy->fPhiMin,copy->fPhiMax);
+  double span = DeltaPhiSmall(fPhiMin,fPhiMax)/2;
+  double dPhi = DeltaPhiSmall(phi,phiC);
+  //
+  // special case to well define 1st raw (closest to 0 from above): wrap around 0/2pi
+  if (dPhi>span) return phi<phiC ? -1 : 1;
+  //
+  double phiT = phi+span;
+  BringTo02Pi(phiT);
+  //  if (phiT<phiC && OKforPhiMin(phiT,phiC)) return -1;
+  if (OKforPhiMin(phiT,phiC)) return -1;
+  phiT = phi-span;
+  BringTo02Pi(phiT);
+  //if (phiT>phiC && OKforPhiMax( phiT,phiC)) return 1;
+  if (OKforPhiMax( phiT,phiC)) return 1;
+  //
+  // sane phi range, check Z
+  double dz = (fZMax-fZMin)/2;
+  if (fZMax+dz < copy->fZMax) return -1;
+  if (fZMin-dz > copy->fZMin) return 1;
+  AliError(Form("Same chip compared? %d %d",GetID(),copy->GetID()));
+  Print();
+  copy->Print();
+  return 0;
+  //
+}
index 56ed68232fc05d31b26fa7988ce5ed0762c91a70..66ce21be15f3000ee5c73def1755591f500c93c4 100644 (file)
@@ -14,7 +14,6 @@
 class AliITSURecoSens : public TObject
 {
  public:
-  enum {kNghbR,kNghbTR,kNghbT,kNghbTL,kNghbL,kNghbBL,kNghbB,kNghbBR,kNNeighbors}; // neighbors: Top,Left etc
   //
   AliITSURecoSens(Int_t id);
   AliITSURecoSens(const AliITSURecoSens &source); 
@@ -29,15 +28,12 @@ class AliITSURecoSens : public TObject
   Double_t           GetZMin()                     const {return fZMin;}
   Double_t           GetZMax()                     const {return fZMax;}
   //
-  Int_t              GetNeighborID(int i)          const {return fNeighbors[i];}
-  //
   Int_t              GetNClusters()                const {return fNClusters;}
   Int_t              GetFirstClusterId()           const {return fFirstClusterId;}
   //
   void               SetID(Int_t i)                      {SetUniqueID(i);}
   void               SetXTF(double v)                    {fXTF = v;}
   void               SetPhiTF(double v)                  {fPhiTF = v;}
-  void               SetNeighborID(int i, int id)        {fNeighbors[i] = id;}
   void               SetBoundaries(double phiMn,double phiMx, double zMn, double zMx);
   //
   void               SetNClusters(Int_t ncl)             {fNClusters = ncl;}
@@ -47,9 +43,12 @@ class AliITSURecoSens : public TObject
   void               ProcessClusters(Int_t mode=0);
   //
   virtual void       Print(Option_t* option = "")  const;
-
+  //
+  virtual Bool_t     IsSortable()                 const {return kTRUE;}
+  virtual Int_t             Compare(const TObject* obj)  const;
+  virtual Bool_t     IsEqual(const TObject* obj)  const {return Compare(obj)==0;}
+  //
  protected:
-  Int_t              fNeighbors[kNNeighbors];      // id of neighbors  
   Int_t              fNClusters;                   // number of clusters
   Int_t              fFirstClusterId;              // index of the 1st cluster in the layer's clusters array
   Double_t           fXTF;                         // X in tracking frame
index 51bfc81c8fcc19bf79b7ac93f7fecad36528b9ba..ac51a7cc9d88c7ea5fee30e144d44ad01796298e 100644 (file)
@@ -507,7 +507,7 @@ void AliITSUTrackerGlo::FindTrack(AliESDtrack* esdTr, Int_t esdID)
   fCurrHyp = fWorkHyp;
   fCurrHyp->InitFrom(hypTr);
   //
-  AliITSURecoSens *hitSens[AliITSURecoSens::kNNeighbors+1];
+  AliITSURecoSens *hitSens[AliITSURecoLayer::kNNeighbors+1];
   //
   int ilaUp = fNLrActive;     // previous active layer really checked (some may be excluded!)
   //