]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSvPPRasymmFMD.cxx
Read digits via TBranch::GetEntry() instead of TTree::GetEntry() as SPD/SDD/SSD entri...
[u/mrichter/AliRoot.git] / ITS / AliITSvPPRasymmFMD.cxx
index d0e9b4960cd692e6e29b9659360e585a29b055b6..3e9e762879a2f005415152ada27e89945da07784 100644 (file)
@@ -33,6 +33,7 @@
 #include <TGeometry.h>
 #include <TLorentzVector.h>
 #include <TGeoMatrix.h>
+#include <TGeoPhysicalNode.h>
 #include <TArrayD.h>
 #include <TArrayF.h>
 #include <TString.h>
@@ -154,14 +155,19 @@ AliITSvPPRasymmFMD::~AliITSvPPRasymmFMD() {
     // Return:
     //   none.
 }
-
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::AddAlignableVolumes() const
 {
   //
-  // Create entries for alignable volumes associating the symbolic volume
+  // Creates entries for alignable volumes associating the symbolic volume
   // name with the corresponding volume path.
   // 
+  // Records in the alignable entries the transformation matrices converting
+  // TGeo local coordinates (in the RS of alignable volumes) to the tracking
+  // system
+  // For this, this function has to run before the misalignment because we
+  // are using the ideal positions in the AliITSgeom object.
+
   AliInfo("Add ITS alignable volumes");
 
   if (!gGeoManager) {
@@ -172,6 +178,8 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
   if( !gGeoManager->SetAlignableEntry("ITS","ALIC_1/ITSV_1") )
     AliFatal("Unable to set alignable entry!!");    
 
+  Double_t al, *gtrans, rotMatrix[9];
+
   TString strSPD = "ITS/SPD";
   TString strSDD = "ITS/SDD";
   TString strSSD = "ITS/SSD";
@@ -228,6 +236,35 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
          if(!gGeoManager->SetAlignableEntry(strEntryName3.Data(),module.Data()))
            AliFatal("Unable to set alignable entry!!");    
          //printf("%s   ==   %s\n",strEntryName3.Data(),module.Data());
+
+         // Creates the TGeo Local to Tracking transformation matrix ...
+         TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(strEntryName3.Data());
+         const char *path = alignableEntry->GetTitle();
+         if (!gGeoManager->cd(path))
+           AliFatal(Form("Volume path %s not valid!",path));
+         TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+         gtrans = globMatrix->GetTranslation();
+         memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+         al = TMath::ATan2(rotMatrix[1],rotMatrix[0]);
+         TGeoHMatrix *matLtoT = new TGeoHMatrix;
+         matLtoT->SetDx( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) ); // translation
+         al += TMath::Pi()/2;
+         //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+         // Not taking into account the shift w.r.t. sensitive volume
+         // correction with fChip1*0.0001/2. is due to the fact
+         // that the alignable volume is not the sensitive volume
+         //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) - fChip1*0.0001/2.);
+         matLtoT->SetDy(-fChip1*0.0001/2.);
+         matLtoT->SetDz(-gtrans[2]);
+         rotMatrix[0]= 0;  rotMatrix[1]= 1;  rotMatrix[2]= 0; // + rotation
+         rotMatrix[3]=-1;  rotMatrix[4]= 0;  rotMatrix[5]= 0; // ! flip in y for the SPD1 only
+         rotMatrix[6]= 0;  rotMatrix[7]= 0;  rotMatrix[8]=-1;
+         TGeoRotation rot;
+         rot.SetMatrix(rotMatrix);
+         matLtoT->MultiplyLeft(&rot);
+         TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+         delete matLtoT;
+         alignableEntry->SetMatrix(matTtoL);
        }
       }
     }
@@ -278,6 +315,33 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
          if(!gGeoManager->SetAlignableEntry(strEntryName3.Data(),module.Data()))
            AliFatal("Unable to set alignable entry!!");
          //printf("%s   ==   %s\n",strEntryName3.Data(),module.Data());
+
+         // Creates the TGeo Local to Tracking transformation matrix ...
+         TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(strEntryName3.Data());
+         const char *path = alignableEntry->GetTitle();
+         if (!gGeoManager->cd(path))
+           AliFatal(Form("Volume path %s not valid!",path));
+         TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+         gtrans = globMatrix->GetTranslation();
+         memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+         al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+         TGeoHMatrix *matLtoT = new TGeoHMatrix;
+         matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+         al += TMath::Pi()/2;
+         //matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+         // not taking into account the shift w.r.t. sensitive volume
+         //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) + fChip2*0.0001/2.);
+         matLtoT->SetDy(-fChip2*0.0001/2.);
+         matLtoT->SetDz(-gtrans[2]);
+         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;
+         TGeoRotation rot;
+         rot.SetMatrix(rotMatrix);
+         matLtoT->MultiplyLeft(&rot);
+         TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+         delete matLtoT;
+         alignableEntry->SetMatrix(matTtoL);
        }
       }
     }
@@ -315,6 +379,30 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
          AliFatal("Unable to set alignable entry!!");    
        //printf("%s    ==    %s\n",strEntryName2.Data(),wafer.Data());
 
+       // Creates the TGeo Local to Tracking transformation matrix ...
+       TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(strEntryName2.Data());
+       const char *path = alignableEntry->GetTitle();
+       if (!gGeoManager->cd(path))
+         AliFatal(Form("Volume path %s not valid!",path));
+       TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+       gtrans = globMatrix->GetTranslation();
+       memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+       al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+       TGeoHMatrix *matLtoT = new TGeoHMatrix;
+       matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+       al += TMath::Pi()/2;
+       //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+       matLtoT->SetDy( 0 );
+       matLtoT->SetDz(-gtrans[2]);
+       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;
+       TGeoRotation rot;
+       rot.SetMatrix(rotMatrix);
+       matLtoT->MultiplyLeft(&rot);
+       TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+       delete matLtoT;
+       alignableEntry->SetMatrix(matTtoL);
       }
     }
   }
@@ -350,6 +438,31 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
        if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data()))
          AliFatal("Unable to set alignable entry!!");    
        //printf("%s    ==    %s\n",strEntryName2.Data(),wafer.Data());
+
+       // Creates the TGeo Local to Tracking transformation matrix ...
+       TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(strEntryName2.Data());
+       const char *path = alignableEntry->GetTitle();
+       if (!gGeoManager->cd(path))
+         AliFatal(Form("Volume path %s not valid!",path));
+       TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+       gtrans = globMatrix->GetTranslation();
+       memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+       al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+       TGeoHMatrix *matLtoT = new TGeoHMatrix;
+       matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+       al += TMath::Pi()/2;
+       //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+       matLtoT->SetDy( 0 );
+       matLtoT->SetDz(-gtrans[2]);
+       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;
+       TGeoRotation rot;
+       rot.SetMatrix(rotMatrix);
+       matLtoT->MultiplyLeft(&rot);
+       TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+       delete matLtoT;
+       alignableEntry->SetMatrix(matTtoL);
       }
     }
   }
@@ -385,6 +498,31 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
        if(!gGeoManager->SetAlignableEntry(strEntryName2.Data(),wafer.Data()))
          AliFatal("Unable to set alignable entry!!");    
        //printf("%s    ==    %s\n",strEntryName2.Data(),wafer.Data());
+
+       // Creates the TGeo Local to Tracking transformation matrix ...
+       TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(strEntryName2.Data());
+       const char *path = alignableEntry->GetTitle();
+       if (!gGeoManager->cd(path))
+         AliFatal(Form("Volume path %s not valid!",path));
+       TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+       gtrans = globMatrix->GetTranslation();
+       memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+       al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+       TGeoHMatrix *matLtoT = new TGeoHMatrix;
+       matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+       al += TMath::Pi()/2;
+       //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+       matLtoT->SetDy( 0 );
+       matLtoT->SetDz(-gtrans[2]);
+       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;
+       TGeoRotation rot;
+       rot.SetMatrix(rotMatrix);
+       matLtoT->MultiplyLeft(&rot);
+       TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+       delete matLtoT;
+       alignableEntry->SetMatrix(matTtoL);
       }
     }
   }
@@ -421,11 +559,34 @@ void AliITSvPPRasymmFMD::AddAlignableVolumes() const
          AliFatal("Unable to set alignable entry!!");    
        //printf("%s    ==    %s\n",strEntryName2.Data(),wafer.Data());
 
+       // Creates the TGeo Local to Tracking transformation matrix ...
+       TGeoPNEntry *alignableEntry = gGeoManager->GetAlignableEntry(strEntryName2.Data());
+       const char *path = alignableEntry->GetTitle();
+       if (!gGeoManager->cd(path))
+         AliFatal(Form("Volume path %s not valid!",path));
+       TGeoHMatrix* globMatrix = gGeoManager->GetCurrentMatrix();
+       gtrans = globMatrix->GetTranslation();
+       memcpy(&rotMatrix[0], globMatrix->GetRotationMatrix(), 9*sizeof(Double_t));
+       al = TMath::ATan2(rotMatrix[1],rotMatrix[0]) + TMath::Pi();
+       TGeoHMatrix *matLtoT = new TGeoHMatrix;
+       matLtoT->SetDx(-gtrans[0]*TMath::Cos(al)-gtrans[1]*TMath::Sin(al) ); // translation
+       al += TMath::Pi()/2;
+       //      matLtoT->SetDy( gtrans[0]*TMath::Cos(al)+gtrans[1]*TMath::Sin(al) );
+       matLtoT->SetDy( 0 );
+       matLtoT->SetDz(-gtrans[2]);
+       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;
+       TGeoRotation rot;
+       rot.SetMatrix(rotMatrix);
+       matLtoT->MultiplyLeft(&rot);
+       TGeoHMatrix *matTtoL = new TGeoHMatrix(matLtoT->Inverse());
+       delete matLtoT;
+       alignableEntry->SetMatrix(matTtoL);
       }
     }
   }
-
-} 
+}
 //______________________________________________________________________
 void AliITSvPPRasymmFMD::BuildGeometry(){
     //    Geometry builder for the ITS version 10. Event Display geometry.