]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDGeometry.cxx
Bug fix in filling BB and BG flags in the ESD friend.
[u/mrichter/AliRoot.git] / FMD / AliFMDGeometry.cxx
index f9dadf432c1248e640fd27107cc426b3a31d8226..d7a2e62ce8fa177e5a8ce49e9ac5c6c1bb9b630f 100644 (file)
@@ -76,6 +76,7 @@
 #include <TGeoManager.h>
 #include <TGeoVolume.h>
 #include <TGeoNode.h>
+#include <TMath.h>
 static Int_t FindNodeDepth(const char* name, const char* volname);
 
 
@@ -359,6 +360,41 @@ AliFMDGeometry::XYZ2Detector(Double_t  x,
   return kFALSE;
 }
 
+//____________________________________________________________________
+Bool_t
+AliFMDGeometry::XYZ2REtaPhiTheta(Double_t  x,   Double_t y, 
+                                Double_t  z, 
+                                Double_t& r,   Double_t& eta, 
+                                Double_t& phi, Double_t& theta)
+{
+  
+  // Service function to convert Cartisean XYZ to r, eta, phi, and theta.   
+  // 
+  // Note, that the z input should be corrected for the vertex location 
+  // if needed.
+  //
+  //     x      Cartisean X coordinate
+  //     y      Cartisean Y coordinate 
+  //     z      Cartisean Z coordinate 
+  //     r      On return, the radius
+  //     eta    On return, the pseudo-rapidity
+  //     phi    On return, the azimuthal angle
+  //     theta  On return, the polar angle;
+  // 
+  // Return:
+  //     kFALSE in case of problems. 
+
+  if (x == 0 && y == 0 && z == 0) return kFALSE;
+  
+  // Correct for vertex offset. 
+  phi   =  TMath::ATan2(y, x);
+  r     =  TMath::Sqrt(y * y + x * x);
+  theta =  TMath::ATan2(r, z);
+  eta   = -TMath::Log(TMath::Tan(theta / 2));
+
+  return kTRUE;
+}
+
 
 //____________________________________________________________________
 void
@@ -428,10 +464,11 @@ AliFMDGeometry::ExtractGeomInfo()
   // and so on - that is, all the geometric information we need for
   // futher processing, such as simulation, digitization,
   // reconstruction, etc. 
-  Int_t detectorDepth = FindNodeDepth("FMD1_1", "ALIC");
-  Int_t ringDepth     = FindNodeDepth(Form("FMDI_%d", Int_t('I')), "ALIC");
-  Int_t moduleDepth   = FindNodeDepth("FIFV_0", "ALIC");
-  Int_t sectorDepth   = FindNodeDepth("FISE_1", "ALIC");
+  Int_t detectorDepth = FindNodeDepth("F1MT_1", "ALIC");
+  Int_t ringDepth     = FindNodeDepth(Form("FITV_%d", int('I')), "ALIC");
+  Int_t moduleDepth   = FindNodeDepth("FIBH_0", "ALIC");
+  Int_t sectorDepth   = FindNodeDepth("FISC_1", "ALIC");
+  fActive.Set(0);
   fActive.Reset(-1);
   AliFMDDebug(1, ("Geometry depths:\n"
                   "   Sector:     %d\n"
@@ -521,6 +558,19 @@ FindNodeDepth(const char* name, const char* volname)
     std::cerr << "No top volume defined" << std::endl;
     return -1;
   }
+
+  TGeoIterator next(vol);
+  TGeoNode*    node = 0;
+  TString      sName(name);
+  while ((node = next())) { 
+    if (sName == node->GetName()) { 
+      //std::cout << "Found node " << node->GetName() << " at level " 
+      //               << next.GetLevel() << std::endl;
+      return next.GetLevel();
+    }
+  }
+  return -1;
+#if 0
   TObjArray* nodes = vol->GetNodes();
   if (!nodes) { 
     std::cerr << "No nodes in top volume" << std::endl;
@@ -532,6 +582,7 @@ FindNodeDepth(const char* name, const char* volname)
   while ((node = static_cast<TGeoNode*>(next()))) 
     if (CheckNodes(node, name, lvl) >= 0) return lvl;
   return -1;
+#endif
 }
 
 //____________________________________________________________________