]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New method to get the global ideal transfromation matrix for an anlignable volume...
authorcvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Jan 2007 13:29:42 +0000 (13:29 +0000)
committercvetan <cvetan@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 25 Jan 2007 13:29:42 +0000 (13:29 +0000)
STEER/AliAlignObj.cxx
STEER/AliAlignObj.h

index 169ee7cc3366f1ff33c813f368ec9d53522a0191..cc3cd17a457706f3083144d3f0407ccd9767f4f9 100644 (file)
@@ -24,6 +24,7 @@
 #include <TGeoManager.h>
 #include <TGeoPhysicalNode.h>
 #include <TMath.h>
+#include "TObjString.h"
 
 #include "AliAlignObj.h"
 #include "AliTrackPointArray.h"
@@ -767,6 +768,76 @@ 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;
+  }
+
+  TString pathStr = path;
+  TObjArray *pathArr = pathStr.Tokenize('/');
+  TIter iter(pathArr);
+  TString nodeStr = "";
+  m.Clear();
+
+  TObjString *str = NULL;
+  while((str = (TObjString*) iter.Next())){
+    nodeStr.Append("/");
+    nodeStr.Append(str->String());
+
+    TGeoMatrix *lm = NULL;
+    if (TGeoPhysicalNode *physNode = (TGeoPhysicalNode *)gGeoManager->GetListOfPhysicalNodes()->FindObject(nodeStr.Data())) {
+        lm = physNode->GetOriginalMatrix();
+       if (!lm) lm = physNode->GetNode()->GetMatrix();
+    }
+    else {
+      gGeoManager->cd(nodeStr.Data());
+      TGeoNode *node = gGeoManager->GetCurrentNode();
+      lm = node->GetMatrix();
+    }
+    m.Multiply(lm);
+  }
+
+  delete pathArr;
+
+  return kTRUE;
+}
+
 //_____________________________________________________________________________
 void  AliAlignObj::InitAlignObjFromGeometry()
 {
index 7a6bd38a419958483bdd258ef82b5c09a04c78bd..26ae489d0bb0cf3bbea288e99abb7a2da7f8c28e 100644 (file)
@@ -102,6 +102,8 @@ class AliAlignObj : public TObject {
   static AliAlignObj* GetAlignObj(UShort_t voluid);
   static AliAlignObj* GetAlignObj(ELayerID layerId, Int_t modId);
 
+  static Bool_t   GetOrigGlobalMatrix(const char *symname, TGeoHMatrix &m);
+
  protected:
 
   void AnglesToMatrix(const Double_t *angles, Double_t *rot) const;