]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAlignObj.cxx
Moving AliDSCValue, AliDCSSensor And AliDCSSensorArray from CDB to STEER to avoud...
[u/mrichter/AliRoot.git] / STEER / AliAlignObj.cxx
index 169ee7cc3366f1ff33c813f368ec9d53522a0191..183e391d520ca54fa781586f95b8f25918964be8 100644 (file)
 //  From it two derived concrete representation of alignment object class
 //  (AliAlignObjAngles, AliAlignObjMatrix) are derived in separate files.
 //-----------------------------------------------------------------
+
+#include <TClass.h>
 #include <TGeoManager.h>
 #include <TGeoPhysicalNode.h>
 #include <TMath.h>
+#include "TObjString.h"
 
 #include "AliAlignObj.h"
 #include "AliTrackPointArray.h"
@@ -665,10 +668,10 @@ Bool_t AliAlignObj::ApplyToGeometry()
     path = pne->GetTitle();
     node = gGeoManager->MakeAlignablePN(pne);
   }else{
-    AliWarning(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
+    AliDebug(1,Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
     path=symname;
     if (!gGeoManager->CheckPath(path)) {
-      AliError(Form("Volume path %s not valid!",path));
+      AliDebug(1,Form("Volume path %s not valid!",path));
       return kFALSE;
     }
     if (gGeoManager->GetListOfPhysicalNodes()->FindObject(path)) {
@@ -767,6 +770,75 @@ Bool_t AliAlignObj::GetFromGeometry(const char *symname, AliAlignObj &alobj)
   return alobj.SetMatrix(align);
 }
 
+//_____________________________________________________________________________
+Bool_t AliAlignObj::GetOrigGlobalMatrix(const char *symname, TGeoHMatrix &m)
+{
+  // The method returns global matrix for the ideal detector geometry
+  // Symname identifies either the corresponding TGeoPNEntry or directly
+  // the volume path. The output global matrix is stored in 'm'.
+  // Returns kFALSE in case, TGeo has not been initialized or the symname
+  // is invalid.
+  //
+
+  if (!gGeoManager || !gGeoManager->IsClosed()) {
+    AliErrorClass("Can't get the original global matrix! gGeoManager doesn't exist or it is still opened!");
+    return kFALSE;
+  }
+  
+  if (!gGeoManager->GetListOfPhysicalNodes()) {
+    AliWarningClass("gGeoManager doesn't contain any aligned nodes!");
+    if (!gGeoManager->cd(symname)) {
+      AliErrorClass(Form("Volume path %s not valid!",symname));
+      return kFALSE;
+    }
+    else {
+      m = *gGeoManager->GetCurrentMatrix();
+      return kTRUE;
+    }
+  }
+
+  const char* path = NULL;
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+  if(pne){
+    path = pne->GetTitle();
+  }else{
+    AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
+    path=symname;
+  }
+
+  if (!gGeoManager->CheckPath(path)) {
+    AliErrorClass(Form("Volume path %s not valid!",path));
+    return kFALSE;
+  }
+
+  m.Clear();
+
+  TIter next(gGeoManager->GetListOfPhysicalNodes());
+  gGeoManager->cd(path);
+
+  while(gGeoManager->GetLevel()){
+
+    TGeoPhysicalNode *physNode = NULL;
+    next.Reset();
+    TGeoNode *node = gGeoManager->GetCurrentNode();
+    while ((physNode=(TGeoPhysicalNode*)next())) 
+      if (physNode->GetNode() == node) break;
+
+    TGeoMatrix *lm = NULL;
+    if (physNode) {
+        lm = physNode->GetOriginalMatrix();
+       if (!lm) lm = node->GetMatrix();
+    } else
+      lm = node->GetMatrix();
+
+    m.MultiplyLeft(lm);
+
+    gGeoManager->CdUp();
+  }
+
+  return kTRUE;
+}
+
 //_____________________________________________________________________________
 void  AliAlignObj::InitAlignObjFromGeometry()
 {
@@ -1064,7 +1136,6 @@ void AliAlignObj::InitSymNames()
   /*********************      HMPID layer   ***********************/
   {
     TString str = "/HMPID/Chamber";
-    TString symname;
 
     for (modnum=0; modnum < 7; modnum++) {
       symname = str;