]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDDetector.cxx
Inserting TMath.h where required by the new version of ROOT
[u/mrichter/AliRoot.git] / FMD / AliFMDDetector.cxx
index d23cf2d1fba0df881a1a5ea191102f7cdc7bae79..ec64734b0b4867c5bde91f1e695018e67ee38c69 100644 (file)
 
 //____________________________________________________________________
 //
+// AliFMDDetector.   
+//
+// Base class for concrete FMD detectors, like AliFMD1, AliFMD2,
+// AliFMD3. 
 // Utility class to help implement the FMD geometry.  This provides
 // the interface for the concrete geometry implementations of the FMD
 // sub-detectors. 
 //
 // Latest changes by Christian Holm Christensen
 //
+
+#include <TGeoManager.h>       // ROOT_TGeoManager 
+#include <TGeoMatrix.h>                // ROOT_TGeoMatrix 
+#include <TMath.h>              // ROOT_TMath
+
 #include "AliFMDDetector.h"    // ALIFMDSUBDETECTOR_H
 #include "AliFMDRing.h"                // ALIFMDRING_H
 #include "AliLog.h"             // ALILOG_H
-#include <TGeoManager.h>       // ROOT_TGeoManager 
-#include <TGeoMatrix.h>                // ROOT_TGeoMatrix 
-// #include <TMath.h>              // ROOT_TMath
 
 //====================================================================
 ClassImp(AliFMDDetector)
@@ -47,6 +53,14 @@ ClassImp(AliFMDDetector)
 AliFMDDetector::AliFMDDetector(Int_t id, AliFMDRing* inner, AliFMDRing* outer) 
   : TNamed(Form("FMD%d", id), "Forward multiplicity ring"), 
     fId(id), 
+    fInnerZ(0.),
+    fOuterZ(0.),
+    fHoneycombThickness(0.),
+    fAlThickness(0.),
+    fInnerHoneyLowR(0.),
+    fInnerHoneyHighR(0.),
+    fOuterHoneyLowR(0.),
+    fOuterHoneyHighR(0.),
     fInner(inner),
     fOuter(outer), 
     fInnerTransforms(0),
@@ -72,6 +86,14 @@ AliFMDDetector::AliFMDDetector(Int_t id, AliFMDRing* inner, AliFMDRing* outer)
 AliFMDDetector::AliFMDDetector(const AliFMDDetector& other)
   : TNamed(other), 
     fId(other.fId),
+    fInnerZ(0.),
+    fOuterZ(0.),
+    fHoneycombThickness(0.),
+    fAlThickness(0.),
+    fInnerHoneyLowR(0.),
+    fInnerHoneyHighR(0.),
+    fOuterHoneyLowR(0.),
+    fOuterHoneyHighR(0.),
     fInner(other.fInner),
     fOuter(other.fOuter),
     fInnerTransforms(other.fInnerTransforms),
@@ -145,6 +167,8 @@ AliFMDDetector::HasAllTransforms(Char_t ring) const
    (name[3] == 'T' || name[3] == 'B'))
 #define IS_NODE_SENSOR(name) \
   (name[0] == 'F' && name[2] == 'S' && name[3] == 'E')
+#define IS_NODE_HALF(name) \
+  (name[0] == 'F' && name[2] == 'M' && (name[3] == 'B' || name[3] == 'T'))
 
 //____________________________________________________________________
 void
@@ -235,6 +259,141 @@ AliFMDDetector::InitTransformations()
   }
 }
 
+//____________________________________________________________________
+void
+AliFMDDetector::SetAlignableVolumes() const
+{
+  AliDebug(10, Form("Making alignable volumes for FMD%d", fId));
+  if (!gGeoManager) {
+    AliFatal("No TGeoManager defined");
+    return;
+  }
+  TGeoVolume* topVolume = gGeoManager->GetTopVolume();
+  if (!topVolume) {
+    AliFatal("No top-level volume defined");
+    return;
+  }
+
+  // Make an iterator
+  TGeoIterator next(topVolume);
+  next.Reset(topVolume);
+  next.SetTopName(Form("/%s_1", topVolume->GetName()));
+  TGeoNode* node = 0;
+  
+  Int_t nInnerSensor = (fInner ? fInner->GetNModules() : 0);
+  Int_t nOuterSensor = (fOuter ? fOuter->GetNModules() : 0);
+  // Find the node corresponding to this detector, and then find the
+  // sensor volumes 
+  Bool_t thisNodeFound = kFALSE;
+  Char_t thisHalf      = '\0';
+  Int_t  iInnerSensor  = 0;
+  Int_t  iOuterSensor  = 0;
+  Bool_t hasTop        = false;
+  Bool_t hasBottom     = false;
+  
+  TString path, align;
+  while ((node = static_cast<TGeoNode*>(next())) 
+        && (iInnerSensor < nInnerSensor || iOuterSensor < nOuterSensor
+            || !hasBottom || !hasTop)) {
+    // Get nodes names 
+    const Char_t* name = node->GetName();
+    if (!name) continue;
+    AliDebug((name[0] == 'F' ? 40 : 50), Form("Got volume %s", name));
+    // Check if this node is this detector 
+    // The base offset for numbers in the ASCII table is 48
+    if (IS_NODE_THIS(name)) {
+      AliDebug(20, Form("Found detector node '%s' for FMD%d", name, fId));
+      thisNodeFound = kTRUE;
+    }
+
+    // if a half ring is found, then we're on that branch, and we
+    // check if this node represents a half ring on that branch 
+    if (thisNodeFound && IS_NODE_HALF(name)) {
+      AliDebug(30, Form("Found half node '%s' for FMD%d", name, fId));
+      // Get the half Id.
+      thisHalf = name[3];
+
+      // Check if we're done 
+      Bool_t done = (thisHalf == 'T' ? hasTop : hasBottom);
+      if (done) {
+       AliDebug(20,Form("Already has all halves for detector %c",name[1]));
+       continue;
+      }
+
+      switch (thisHalf) {
+      case 'T': hasTop = true; break;
+      case 'B': hasBottom = true; break;
+      default:  
+       AliWarning(Form("Unknown part '%c' of FMD%d", fId));
+       continue; // because the node is unknown. 
+      }
+      
+      // Get the node path 
+      next.GetPath(path);
+      align = Form("FMD/FMD%d_%c", fId, thisHalf);
+    }
+    
+    // if the detector was found, then we're on that branch, and we
+    // check if this node represents a module in that branch.
+    if (thisNodeFound && thisHalf && IS_NODE_SENSOR(name)) {
+      AliDebug(30, Form("Found sensor node '%s' for FMD%d", name, fId));
+      // Get the ring Id.
+      Char_t ringid = name[1];
+
+      // check that the ring is valid 
+      if (!GetRing(ringid)) {
+       AliWarning(Form("Invalid ring %c for FMD%d", ringid, fId));
+       continue;
+      }
+
+      // Check if we're done
+      Bool_t done = false;
+      switch (ringid) {
+      case 'I': done = iInnerSensor >= nInnerSensor; break;
+      case 'O': done = iOuterSensor >= nOuterSensor; break;
+      default: continue;
+      }
+      if (done) {
+       AliDebug(20,Form("Already has all sensor volumes for ring %c",ringid));
+       continue;
+      }
+      // Get the copy (module) number, and check that it hasn't
+      // already been added to the container. 
+      Int_t copy  = node->GetNumber();
+      next.GetPath(path);
+      // path.Replace("ALIC", "/ALIC_1");
+      align = Form("FMD/FMD%d_%c/FMD%c_%02d", fId, thisHalf, ringid, copy);
+      
+      switch (ringid) {
+      case 'I': iInnerSensor++; break;
+      case 'O': iOuterSensor++; break;
+      }
+    }
+    if (!align.IsNull() && !path.IsNull()) {
+      AliDebug(20, Form("Got %s -> %s", path.Data(), align.Data()));
+      TGeoPNEntry* entry = 
+       gGeoManager->SetAlignableEntry(align.Data(),path.Data());
+      if(!entry)
+       AliFatal(Form("Alignable entry %s not created. "
+                     "Volume path %s not valid", 
+                       align.Data(),path.Data()));
+#ifdef MAKE_ALIGNABLE_PHYSICAL
+      TGeoPhysicalNode* phys = gGeoManager->MakeAlignablePN(entry);
+      if (!phys) 
+       AliWarning(Form("Physical node entry %s not created. "
+                       "Volume path %s not valid", 
+                       align.Data(),path.Data()));
+#endif
+      align = "";
+    }
+    AliDebug(20, Form("FMD%d: top: %d bottom: %d Inner: %d/%d Outer %d/%d", 
+                     fId, hasTop, hasBottom, iInnerSensor,  nInnerSensor, 
+                     iOuterSensor, nOuterSensor));
+  }
+}
+
+  
+
 //____________________________________________________________________
 AliFMDRing*
 AliFMDDetector::GetRing(Char_t id) const
@@ -308,7 +467,6 @@ AliFMDDetector::Detector2XYZ(Char_t   ring,
   // (x,y,z) coordinates (in global reference frame)
   AliFMDRing* r = GetRing(ring);
   if (!r) return;
-#if 1
   TGeoMatrix* m = FindTransform(ring, sector);
   if (!m) return;
   Double_t rho      = r->GetStripRadius(strip);
@@ -319,23 +477,19 @@ AliFMDDetector::Detector2XYZ(Char_t   ring,
                       + r->GetCopperThickness()
                       + r->GetChipThickness()
                       + r->GetSpacing());
-  AliDebug(10,Form("Rho %7.3f, angle %7.3f", rho, phi));
+  AliDebug(30,Form("Rho %7.3f, angle %7.3f", rho, phi));
 # define DEGRAD TMath::Pi() / 180. 
   Double_t local[]  = { rho * TMath::Cos(phi * DEGRAD), 
                        rho * TMath::Sin(phi * DEGRAD), 
                        -modThick + siThick / 2 };
   Double_t master[3];
-  AliDebug(10, Form("Local (%7.3f,%7.3f,%7.3f)",local[0], local[1], local[2]));
+  AliDebug(30, Form("Local (%7.3f,%7.3f,%7.3f)",local[0], local[1], local[2]));
   m->LocalToMaster(local, master);
-  AliDebug(10, Form("Master (%7.3f,%7.3f,%7.3f)",
+  AliDebug(30, Form("Master (%7.3f,%7.3f,%7.3f)",
                    master[0],master[1],master[2]));
   x = master[0];
   y = master[1];
   z = master[2];
-#else
-  z = GetRingZ(ring);
-  r->Detector2XYZ(sector, strip, x, y, z);
-#endif
 }
 
 //____________________________________________________________________