]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/STEER/AliCluster.cxx
Possibility to get the rotation angle of cluster's reference plane
[u/mrichter/AliRoot.git] / STEER / STEER / AliCluster.cxx
index 4dca16064af20d8d43a54cd94a755545f519da53..7206d4a3f445e4b2bd5ffdc90e0d296564c1962f 100644 (file)
@@ -29,6 +29,7 @@
 #include <TGeoManager.h>
 #include <TGeoMatrix.h>
 #include <TGeoPhysicalNode.h>
+#include <TMath.h>
 
 #include "AliCluster.h"
 #include "AliLog.h"
@@ -240,6 +241,34 @@ Bool_t AliCluster::GetXRefPlane(Float_t &xref) const
   return kTRUE;
 }
 
+//______________________________________________________________________________
+Bool_t AliCluster::GetXAlphaRefPlane(Float_t &x, Float_t &alpha) const
+{
+  // Get the distance between the origin and the ref. plane together with
+  // the rotation anlge of the ref. plane.
+  // All the needed information is taken only
+  // from TGeo.
+  const TGeoHMatrix *mt = GetTracking2LocalMatrix();
+  if (!mt) return kFALSE;
+
+  const TGeoHMatrix *ml = GetMatrix();
+  if (!ml) return kFALSE;
+
+  TGeoHMatrix m(*ml);
+  m.Multiply(mt);
+  const Double_t txyz[3]={0.}; Double_t xyz[3]={0.};
+  m.LocalToMaster(txyz,xyz);
+    
+  x=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+    
+  Double_t a=TMath::ATan2(xyz[1],xyz[0]);
+  if (a<0) a+=TMath::TwoPi();
+  else if (a>=TMath::TwoPi()) a-=TMath::TwoPi();
+  alpha=a;
+
+  return kTRUE;
+}
+
 //______________________________________________________________________________
 Bool_t AliCluster::Misalign()
 {