]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
More rubust way of defining the Tracking2Local matrix (Stefan)
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 4 Nov 2012 20:38:24 +0000 (20:38 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 4 Nov 2012 20:38:24 +0000 (20:38 +0000)
ITS/UPGRADE/AliITSUv11.cxx
ITS/UPGRADE/AliITSUv11.h

index 558b99e3eb1110ce069c7b31634b1c65c34e2285..c07ad35188b499397260e07f25ea8cf578816585 100644 (file)
@@ -161,49 +161,69 @@ AliITSUv11::~AliITSUv11() {
 }
 
 //______________________________________________________________________
-void AliITSUv11::SetT2Lmatrix(Int_t uid, Double_t yShift, 
-                                 Bool_t yFlip, Bool_t yRot180) const {
-
+void AliITSUv11::SetT2Lmatrix(Int_t lay,Int_t lad,Int_t detInLad) const
+{
   //
-  // Creates the TGeo Local to Tracking transformation matrix
+  // Creates the TGeo Local (sensor!) to Tracking transformation matrix
   // and sends it to the corresponding TGeoPNEntry 
   //
   // This function is used in AddAlignableVolumes()
+  const TString kPathBase = Form("/ALIC_1/%s_2/",AliITSUGeomTGeo::GetITSVolPattern());
+  const TString kNames = Form("%%s%s%%d_1/%s%%d_%%d/%s%%d_%%d/%s%%d_%%d"
+                             ,AliITSUGeomTGeo::GetITSLayerPattern()
+                             ,AliITSUGeomTGeo::GetITSLadderPattern()
+                             ,AliITSUGeomTGeo::GetITSModulePattern()
+                             ,AliITSUGeomTGeo::GetITSSensorPattern());  
+  //  
+  TString path;
+  path.Form(kNames.Data(),kPathBase.Data(),lay,lay,lad,lay,detInLad,lay,1);
+  gGeoManager->PushPath();
+  if (!gGeoManager->cd(path.Data())) {
+    gGeoManager->PopPath();
+    AliError(Form("Error in cd-ing to %s",path.Data()));
+    return;
+  } // end if !gGeoManager
+  TGeoHMatrix* matSens = gGeoManager->GetCurrentMatrix();
+  // Retstore the modeler state.
+  gGeoManager->PopPath();
+  //
+  Double_t *gtrans = matSens->GetTranslation(), rotMatrix[9];
+  memcpy(&rotMatrix[0], matSens->GetRotationMatrix(), 9*sizeof(Double_t));
+  Double_t al = -TMath::ATan2(rotMatrix[1],rotMatrix[0]);
+  Double_t rSens = TMath::Sqrt(gtrans[0]*gtrans[0] + gtrans[1]*gtrans[1]);
+
+  Double_t tanAl = TMath::ATan2(gtrans[1],gtrans[0]) -TMath::Pi()/2; //angle of tangente
 
-  TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntryByUID(uid);
-  TGeoHMatrix* globMatrix = alignableEntry->GetGlobalOrig();
-  Double_t *gtrans = globMatrix->GetTranslation(), rotMatrix[9];
-  memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
-  Double_t al = ATan2(rotMatrix[1], yRot180 ? -rotMatrix[0] : rotMatrix[0]);
-  Double_t xShift = gtrans[0]*Cos(al)+gtrans[1]*Sin(al);
+  //  if (tanAl<TMath::Pi()) 
+  Double_t alTr = tanAl - al;
+  Double_t rTr = rSens*TMath::Cos(alTr);
+
+  // Transformation matrix
+  Double_t xShift = rTr;
+  Double_t yShift = rSens*TMath::Sin(alTr);
   Double_t zShift = -gtrans[2];
   TGeoHMatrix *matLtoT = new TGeoHMatrix;
   matLtoT->SetDx( xShift ); // translation
   matLtoT->SetDy( yShift );
   matLtoT->SetDz( zShift );
+
+  // Rotation matrix
   rotMatrix[0]= 0;  rotMatrix[1]= 1;  rotMatrix[2]= 0; // + rotation
   rotMatrix[3]= 1;  rotMatrix[4]= 0;  rotMatrix[5]= 0;
   rotMatrix[6]= 0;  rotMatrix[7]= 0;  rotMatrix[8]=-1;
-  if (yFlip) rotMatrix[3] = rotMatrix[1] = -1;  // flipping in y
-  //
-  if (yRot180) { // rotation of pi around the axis perpendicular to the wafer
-    if (yFlip) matLtoT->SetDx( -xShift ); // flipping in y  (for SPD1)
-    matLtoT->SetDy( -yShift );
-    matLtoT->SetDz( -zShift );
-    rotMatrix[8]=1;
-    rotMatrix[3] = -1;
-    if (yFlip) rotMatrix[3] = 1;  // flipping in y  (for SPD1)
-  }
-  //  printf("UID:%d xS:%f ZS:%f\n",uid,xShift,zShift);
-  //  globMatrix->Print();
-
 
   TGeoRotation rot;
   rot.SetMatrix(rotMatrix);
   matLtoT->MultiplyLeft(&rot);
+
+  // Inverse transformation Matrix
   TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
   delete matLtoT;
+  //
+  path = AliITSUGeomTGeo::ComposeSymNameModule(lay,lad,detInLad);
+  TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(path.Data());
   alignableEntry->SetMatrix(matTtoL);
+  //
 }
 
 //______________________________________________________________________
@@ -258,13 +278,7 @@ void AliITSUv11::AddAlignableVolumes() const{
        // 
        gGeoManager->SetAlignableEntry(AliITSUGeomTGeo::ComposeSymNameModule(lr,ld,md),pthM.Data(),modUID);
        //
-       double yshift = -(fUpGeom[lr]->GetSensorThick()-fUpGeom[lr]->GetLadderThick())/2;
-       //      SetT2Lmatrix(modUID,yshift, kTRUE,kTRUE); // RS: do we need here special matrix, ask MS
-       //      SetT2Lmatrix(modUID,yshift, kTRUE,kFALSE); // RS: do we need here special matrix, ask MS
-       //
-       // RS: to clarify: in order to get reasonable tracking frame X,phi with STANDARD SetT2Lmatrix
-       // the yRot180 must be true. 
-       SetT2Lmatrix(modUID,yshift, kTRUE,kTRUE); // RS: do we need here special matrix, ask MS 
+       SetT2Lmatrix(lr,ld,md);
        //
       }
     }
index 7660afa263f98911fc088fe8f86d53e57e9937b2..12cf8bf13c8ac9195470fd0bf6d4cd1288cf834d 100644 (file)
@@ -49,7 +49,7 @@ class AliITSUv11 : public AliITSU {
   virtual Int_t  GetLayerDetTypeID(Int_t lr);
   //
  protected:
-  void SetT2Lmatrix(Int_t uid, Double_t yShift,Bool_t yFlip, Bool_t yRot180=kFALSE) const; // Set T2L matrix in TGeoPNEntries
+  void SetT2Lmatrix(Int_t lr,Int_t ld,Int_t modInLd) const; // Set T2L matrix in TGeoPNEntries
   
  private:
   AliITSUv11(const AliITSUv11 &source); // copy constructor