]> 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 7740c2b9c26bcd3ca6ddaa44a571f384d1ec90ba..d7a2e62ce8fa177e5a8ce49e9ac5c6c1bb9b630f 100644 (file)
 #include "AliFMD2.h"           // ALIFMD2_H
 #include "AliFMD3.h"           // ALIFMD2_H
 #include "AliRecPoint.h"       // ALIRECPOINT_H
-#include "AliLog.h"            // ALIRECPOINT_H
+#include "AliFMDDebug.h"                  // ALILOG_H
 #include <TVector3.h>           // ROOT_TVector3
-#include <TMatrix.h>            // ROOT_TMatrix
-#include <TParticle.h>          // ROOT_TParticle
+// #include <TMatrix.h>            // ROOT_TMatrix
+// #include <TParticle.h>          // ROOT_TParticle
 #include <Riostream.h>
 #include "AliFMDGeometryBuilder.h"
-#include <TArrayI.h>
+// #include <TArrayI.h>
 #include <TGeoManager.h>
 #include <TGeoVolume.h>
 #include <TGeoNode.h>
+#include <TMath.h>
 static Int_t FindNodeDepth(const char* name, const char* volname);
 
 
@@ -100,7 +101,24 @@ AliFMDGeometry::Instance()
 //____________________________________________________________________
 AliFMDGeometry::AliFMDGeometry() 
   : AliGeometry("FMD", "Forward multiplicity"), 
-    fBuilder(0)
+    fIsInitialized(kFALSE), 
+    fInner(0),
+    fOuter(0),
+    fFMD1(0),
+    fFMD2(0),
+    fFMD3(0),
+    fUseFMD1(kFALSE),
+    fUseFMD2(kFALSE),
+    fUseFMD3(kFALSE),
+    fIsInitTrans(kFALSE),
+    fBuilder(0),
+    fDetectorOff(0),
+    fModuleOff(0),  
+    fRingOff(0),
+    fSectorOff(0),
+    fActive(2),
+    fDetailed(kFALSE),       
+    fUseAssembly(kFALSE)
 {
   // PROTECTED
   // Default constructor 
@@ -130,6 +148,12 @@ AliFMDGeometry::AliFMDGeometry(const AliFMDGeometry& other)
     fUseFMD1(other.fUseFMD1), 
     fUseFMD2(other.fUseFMD2), 
     fUseFMD3(other.fUseFMD3), 
+    fIsInitTrans(other.fIsInitTrans),
+    fBuilder(other.fBuilder),
+    fDetectorOff(other.fDetectorOff),
+    fModuleOff(other.fModuleOff),  
+    fRingOff(other.fRingOff),
+    fSectorOff(other.fSectorOff),
     fActive(other.fActive),
     fDetailed(other.fDetailed),
     fUseAssembly(other.fUseAssembly)
@@ -173,22 +197,27 @@ AliFMDGeometry::Init()
 
 //____________________________________________________________________
 void
-AliFMDGeometry::InitTransformations()
+AliFMDGeometry::InitTransformations(Bool_t force)
 {
+  // Find all local <-> global transforms 
+  if (force) fIsInitTrans = kFALSE;
+  if (fIsInitTrans) return; 
   if (!gGeoManager) {
     AliError("No TGeoManager defined");
     return;
   }
-  AliDebug(0, "Initialising transforms for FMD geometry");
+  AliFMDDebug(1, ("Initialising transforms for FMD geometry"));
   if (fFMD1) fFMD1->InitTransformations();
   if (fFMD2) fFMD2->InitTransformations();
   if (fFMD3) fFMD3->InitTransformations();
+  fIsInitTrans = kTRUE;
 }
 
 //____________________________________________________________________
 void
 AliFMDGeometry::Build()
 {
+  // Build the geometry 
   if (!fBuilder) fBuilder = new AliFMDGeometryBuilder(fDetailed);
   fBuilder->SetDetailed(fDetailed);
   fBuilder->UseAssembly(fUseAssembly);
@@ -199,9 +228,10 @@ AliFMDGeometry::Build()
 void
 AliFMDGeometry::SetActive(Int_t* active, Int_t n) 
 {
+  // Set active volumes 
   fActive.Set(n);
   for (Int_t i = 0; i < n; i++) { 
-    AliDebug(1, Form("Active vol id # %d: %d", i, active[i]));
+    AliFMDDebug(1, ("Active vol id # %d: %d", i, active[i]));
     fActive[i] = active[i];
   }
 }
@@ -210,6 +240,7 @@ AliFMDGeometry::SetActive(Int_t* active, Int_t n)
 void
 AliFMDGeometry::AddActive(Int_t active)
 {
+  // Add an active volume 
   Int_t n = fActive.fN;
   fActive.Set(n+1);
   fActive[n] = active;
@@ -219,6 +250,7 @@ AliFMDGeometry::AddActive(Int_t active)
 Bool_t
 AliFMDGeometry::IsActive(Int_t vol) const
 {
+  // Check if a volume is active 
   for (Int_t i = 0; i < fActive.fN; i++) 
     if (fActive[i] == vol) return kTRUE;
   return kFALSE;
@@ -328,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
@@ -374,6 +441,16 @@ AliFMDGeometry::Impact(const TParticle* /* particle */) const
   return kFALSE; 
 }
 
+//____________________________________________________________________ 
+void  
+AliFMDGeometry::SetAlignableVolumes() const
+{
+  // Declare alignable volumes
+  for (Int_t d = 1; d <= 3; d++) 
+    if (GetDetector(d)) GetDetector(d)->SetAlignableVolumes();
+}
+
+
 //____________________________________________________________________ 
 void  
 AliFMDGeometry::ExtractGeomInfo()
@@ -387,12 +464,13 @@ 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);
-  AliDebug(1, Form("Geometry depths:\n"
+  AliFMDDebug(1, ("Geometry depths:\n"
                   "   Sector:     %d\n"
                   "   Module:     %d\n"
                   "   Ring:       %d\n"
@@ -432,7 +510,7 @@ AliFMDGeometry::ExtractGeomInfo()
     if (striVol) AddActive(striVol->GetNumber());
     if (stroVol) AddActive(stroVol->GetNumber());
   }    
-  AliDebug(1, Form("Geometry offsets:\n"
+  AliFMDDebug(1, ("Geometry offsets:\n"
                   "   Sector:     %d\n"
                   "   Module:     %d\n"
                   "   Ring:       %d\n"
@@ -474,11 +552,25 @@ CheckNodes(TGeoNode* node, const char* name, Int_t& lvl)
 Int_t 
 FindNodeDepth(const char* name, const char* volname) 
 {
+  // Find the depth of a node 
   TGeoVolume* vol  = gGeoManager->GetVolume(volname);
   if (!vol) {
     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;
@@ -490,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
 }
 
 //____________________________________________________________________