]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/AliFMDDetector.cxx
Corrected treatment of signals with multiple banches
[u/mrichter/AliRoot.git] / FMD / AliFMDDetector.cxx
index e6831799ef089cc4b7b5664f9167136b981c6709..020b077c4bc79c55e5322b39edcec830bc12267e 100644 (file)
@@ -36,6 +36,7 @@
 //
 
 #include <TGeoManager.h>       // ROOT_TGeoManager 
+#include <TGeoPhysicalNode.h>   // ROOT_TGeoPhysicalNode
 #include <TGeoMatrix.h>                // ROOT_TGeoMatrix 
 #include <TMath.h>              // ROOT_TMath
 
@@ -55,8 +56,6 @@ AliFMDDetector::AliFMDDetector(Int_t id, AliFMDRing* inner, AliFMDRing* outer)
     fId(id), 
     fInnerZ(0.),
     fOuterZ(0.),
-    fHoneycombThickness(0.),
-    fAlThickness(0.),
     fInnerHoneyLowR(0.),
     fInnerHoneyHighR(0.),
     fOuterHoneyLowR(0.),
@@ -72,8 +71,6 @@ AliFMDDetector::AliFMDDetector(Int_t id, AliFMDRing* inner, AliFMDRing* outer)
   //   INNER      Inner ring geometry 
   //   OUTER      Outer ring geometry (if any)
   // 
-  SetHoneycombThickness();
-  SetAlThickness();
   SetInnerHoneyLowR(0);
   SetInnerHoneyHighR(0);
   SetInnerZ(0);
@@ -88,8 +85,6 @@ AliFMDDetector::AliFMDDetector(const AliFMDDetector& other)
     fId(other.fId),
     fInnerZ(0.),
     fOuterZ(0.),
-    fHoneycombThickness(0.),
-    fAlThickness(0.),
     fInnerHoneyLowR(0.),
     fInnerHoneyHighR(0.),
     fOuterHoneyLowR(0.),
@@ -100,8 +95,6 @@ AliFMDDetector::AliFMDDetector(const AliFMDDetector& other)
     fOuterTransforms(other.fOuterTransforms)
 {
   // Copy constructor 
-  SetHoneycombThickness(other.GetHoneycombThickness());
-  SetAlThickness(other.GetAlThickness());
   SetInnerHoneyLowR(other.GetInnerHoneyLowR());
   SetInnerHoneyHighR(other.GetInnerHoneyHighR());
   SetInnerZ(other.GetInnerZ());
@@ -122,8 +115,6 @@ AliFMDDetector::operator=(const AliFMDDetector& other)
   fOuter           = other.fOuter;
   fInnerTransforms = other.fInnerTransforms;
   fOuterTransforms = other.fOuterTransforms;
-  SetHoneycombThickness(other.GetHoneycombThickness());
-  SetAlThickness(other.GetAlThickness());
   SetInnerHoneyLowR(other.GetInnerHoneyLowR());
   SetInnerHoneyHighR(other.GetInnerHoneyHighR());
   SetInnerZ(other.GetInnerZ());
@@ -165,10 +156,14 @@ AliFMDDetector::HasAllTransforms(Char_t ring) const
 #define IS_NODE_THIS(name) \
   (name[0] == 'F' && name[2] == 'M' && name[1] == Char_t(48+fId) && \
    (name[3] == 'T' || name[3] == 'B'))
-#define IS_NODE_SENSOR(name) \
-  (name[0] == 'F' && name[2] == 'S' && name[3] == 'E')
+#define IS_NODE_SENSOR(name)                           \
+  (name[0] == 'F' && (name[2] == 'B' || name[2] == 'F') && name[3] == 'H')
+//#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'))
+#define HALF_FORMAT   "FMD/FMD%d_%c"
+#define SENSOR_FORMAT "FMD/FMD%d_%c/FMD%c_%02d"
 
 //____________________________________________________________________
 void
@@ -185,17 +180,94 @@ AliFMDDetector::InitTransformations()
     AliFatal("No TGeoManager defined");
     return;
   }
-  TGeoVolume* topVolume = gGeoManager->GetTopVolume();
-  if (!topVolume) {
-    AliFatal("No top-level volume defined");
-    return;
-  }
+
+  // Implementation using alignable volume names. 
   // Make container of transforms 
   if (fInner && !fInnerTransforms) 
     fInnerTransforms = new TObjArray(fInner->GetNModules());
   if (fOuter && !fOuterTransforms) 
     fOuterTransforms = new TObjArray(fOuter->GetNModules());
   
+  // Loop over bottom/top 
+  for (size_t ihalf = 0; ihalf < 2; ihalf++) {
+    char  half = (ihalf == 0 ? 'T' : 'B');
+    TString path(Form(HALF_FORMAT, fId, half));
+    TGeoPNEntry* entry = gGeoManager->GetAlignableEntry(path.Data());
+    if (!entry) {
+      AliError(Form("Alignable entry for half-detector \"%s\" not found!", 
+                   path.Data()));
+      continue;
+    }
+    TGeoPhysicalNode* pn = entry->GetPhysicalNode();
+    if (!pn) {
+      AliWarning(Form("Making physical volume for \"%s\"", path.Data()));
+      pn = gGeoManager->MakeAlignablePN(entry);
+      if (!pn) {
+       AliError(Form("No physical node for \"%s\"", path.Data()));
+       continue;
+      }
+    }
+  }
+  
+  // Loop over rings 
+  for (size_t iring = 0; iring < 2; iring++) {
+    char ring = (iring == 0 ? 'I' : 'O');
+    TObjArray*  trans = 0;
+    AliFMDRing* r     = 0; 
+    switch (ring) {
+    case 'I': r = fInner; trans = fInnerTransforms; break;
+    case 'O': r = fOuter; trans = fOuterTransforms; break; 
+    }
+    if (!r || !trans) continue;
+
+    Int_t nModules = r->GetNModules();
+    if (nModules <= 0) continue;
+
+    // Loop over bottom/top 
+    for (size_t ihalf = 0; ihalf < 2; ihalf++) {
+      char  half = (ihalf == 0 ? 'T' : 'B');
+      Int_t base = (half == 'T' ? 0 : nModules / 2);
+      
+      // Loop over modules in this half ring 
+      for (Int_t imod = 0; imod < nModules / 2; imod++) {
+       // Find physical node entry
+       TString path(Form(SENSOR_FORMAT, fId, half, ring, base+imod));
+       TGeoPNEntry* entry = gGeoManager->GetAlignableEntry(path.Data());
+       if (!entry) {
+         AliError(Form("Alignable entry for sensor \"%s\" not found!", 
+                       path.Data()));
+         continue;
+       }
+       TGeoPhysicalNode* pn = entry->GetPhysicalNode();
+       if (!pn) {
+         AliWarning(Form("Making physical volume for \"%s\"", path.Data()));
+         pn = gGeoManager->MakeAlignablePN(entry);
+         if (!pn) {
+           AliError(Form("No physical node for \"%s\"", path.Data()));
+           continue;
+         }
+       }
+       
+       const TGeoMatrix* pm = pn->GetMatrix();
+       if (!pm) {
+         AliError(Form("No matrix for path \"%s\"", path.Data()));
+         continue;
+       }
+       // Get transformation matrix for this node, and store it. 
+       TGeoMatrix*  t = new TGeoHMatrix(*pm);
+       trans->AddAt(t, base+imod);
+       AliFMDDebug(5, ("Found matrix for path \"%s\": %p",path.Data(),pm));
+      }
+    }
+  }
+  if (HasAllTransforms('I') && HasAllTransforms('O')) return;
+
+  // Alternative implementation using TGeoIter. 
+  TGeoVolume* topVolume = gGeoManager->GetTopVolume();
+  if (!topVolume) {
+    AliFatal("No top-level volume defined");
+    return;
+  }
   // Make an iterator
   TGeoIterator next(topVolume);
   TGeoNode* node = 0;
@@ -263,6 +335,10 @@ AliFMDDetector::InitTransformations()
 void
 AliFMDDetector::SetAlignableVolumes() const
 {
+  // Set alignable volumes. 
+  // This will define the alignable volumes. 
+  // That is currently, the modules and the half-rings. 
+  
   AliFMDDebug(10, ("Making alignable volumes for FMD%d", fId));
   if (!gGeoManager) {
     AliFatal("No TGeoManager defined");
@@ -330,7 +406,7 @@ AliFMDDetector::SetAlignableVolumes() const
       
       // Get the node path 
       next.GetPath(path);
-      align = Form("FMD/FMD%d_%c", fId, thisHalf);
+      align = Form(HALF_FORMAT, fId, thisHalf);
     }
     
     // if the detector was found, then we're on that branch, and we
@@ -362,7 +438,7 @@ AliFMDDetector::SetAlignableVolumes() const
       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);
+      align = Form(SENSOR_FORMAT, fId, thisHalf, ringid, copy);
       
       switch (ringid) {
       case 'I': iInnerSensor++; break;
@@ -466,22 +542,30 @@ AliFMDDetector::Detector2XYZ(Char_t   ring,
   // Translate detector coordinates (this,ring,sector,strip) into
   // (x,y,z) coordinates (in global reference frame)
   AliFMDRing* r = GetRing(ring);
-  if (!r) return;
+  if (!r) { 
+    AliWarning(Form("No such ring FMD%d%c ", fId, ring));
+    return;
+  }
   TGeoMatrix* m = FindTransform(ring, sector);
-  if (!m) return;
+  if (!m) { 
+    AliWarning(Form("No transfrmation found for FMD%d%c[%02d]", 
+                   fId, ring, sector));
+    return;
+  }
   Double_t rho      = r->GetStripRadius(strip);
   Double_t phi      = ((sector % 2) - .5) * r->GetTheta();
   Double_t siThick  = r->GetSiThickness();
+#if 0 
   Double_t modThick = (siThick
                       + r->GetPrintboardThickness()
                       + r->GetCopperThickness()
                       + r->GetChipThickness()
                       + r->GetSpacing());
+#endif
   AliFMDDebug(30, ("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 local[]  = { rho * TMath::Cos(phi * TMath::DegToRad()), 
+                       rho * TMath::Sin(phi * TMath::DegToRad()), 
+                       /* -modThick + */ siThick / 2 };
   Double_t master[3];
   AliFMDDebug(30, ("Local (%7.3f,%7.3f,%7.3f)",local[0], local[1], local[2]));
   m->LocalToMaster(local, master);