Taking advantage of new overlap check funtionality of TGeoPhysicalNode::Align
authorrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 Aug 2008 08:46:03 +0000 (08:46 +0000)
committerrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 14 Aug 2008 08:46:03 +0000 (08:46 +0000)
STEER/AliAlignObj.cxx
STEER/AliGeomManager.cxx
STEER/AliGeomManager.h

index b95b253..e5f5581 100644 (file)
@@ -25,6 +25,7 @@
 #include <TGeoManager.h>
 #include <TGeoMatrix.h>
 #include <TGeoPhysicalNode.h>
+#include <TGeoOverlap.h>
 #include <TMath.h>
 #include <TMatrixDSym.h>
 
@@ -694,17 +695,8 @@ Bool_t AliAlignObj::ApplyToGeometry(Bool_t ovlpcheck)
     return kFALSE;
   }
 
-  Int_t nOvlpBefore = 0, nOvlpAfter = 0;
-  Double_t threshold = 0.01;
+  Double_t threshold = 0.001;
   
-  if(ovlpcheck)
-  {
-    gGeoManager->cd(path);
-    gGeoManager->CdUp();
-    TGeoNode* start = gGeoManager->GetCurrentNode();
-    nOvlpBefore = AliGeomManager::CheckOverlapsExtrusions(start, threshold);
-  }
-
   TGeoHMatrix align,gprime;
   gprime = *node->GetMatrix();
   GetMatrix(align);
@@ -717,20 +709,23 @@ Bool_t AliAlignObj::ApplyToGeometry(Bool_t ovlpcheck)
   Int_t modId; // unique identity for volume inside layer in the alobj
   GetVolUID(layerId, modId);
   AliDebug(2,Form("Aligning volume %s of detector layer %d with local ID %d",symname,layerId,modId));
-  node->Align(ginv,0);
-
-  
   if(ovlpcheck){
-    TGeoNode* start = node->GetNode();
-    nOvlpAfter = AliGeomManager::CheckOverlapsExtrusions(start, threshold);
-    if(nOvlpBefore < nOvlpAfter){
-      TString error(Form("The alignment of volume %s introduced %d new overlap",GetSymName(), nOvlpAfter-nOvlpBefore));
-      if(nOvlpAfter-nOvlpBefore > 1) error+="s";
-      AliError(error.Data());
-      //return kFALSE;
+    node->Align(ginv,0,kTRUE); //(trunk of root takes threshold as additional argument)
+  }else{
+    node->Align(ginv,0,kFALSE);
+  }
+  if(ovlpcheck)
+  {
+    TObjArray* ovlpArray =  gGeoManager->GetListOfOverlaps();
+    Int_t nOvlp = ovlpArray->GetEntriesFast();
+    if(nOvlp)
+    {
+      AliInfo(Form("Misalignment of node %s generated the following overlaps/extrusions:",node->GetName()));
+      for(Int_t i=0; i<nOvlp; i++)
+       ((TGeoOverlap*)ovlpArray->UncheckedAt(i))->PrintInfo();
     }
   }
-
+      
   return kTRUE;
 }
 
index 2ff8fdc..4613ec5 100644 (file)
@@ -1688,30 +1688,4 @@ Bool_t AliGeomManager::ApplyAlignObjsToGeom(const char* detName, Int_t runnum, I
   return ApplyAlignObjsToGeom(*alignObjArray);
 }
 
-//_____________________________________________________________________________
-Int_t AliGeomManager::CheckOverlapsExtrusions(TGeoNode* start, Double_t threshold)
-{
-  // For the given node check for overlaps and extrusions within threshold by means
-  // both of the standard checker and of the checker by sampling.
-  // Returns the total number of overlaps for the given node.
-  //
-  TGeoVolume* vol = start->GetVolume();
-  gGeoManager->ClearOverlaps();
-  gGeoManager->SetCheckingOverlaps();
-  AliDebugClass(2,Form("Checking overlaps for volume %s",vol->GetName()));
-  vol->CheckOverlaps(threshold); 
-  AliDebugClass(2,Form("Checking overlaps by sampling for node %s",start->GetName()));
-  start->CheckOverlaps(threshold,"s");  
-
-  TObjArray* ovexArray = (TObjArray*)gGeoManager->GetListOfOverlaps();
-  Int_t nOvEx = ovexArray->GetEntriesFast();
-  AliDebugClass(2,Form("Number of overlaps/extrusions: %d", nOvEx));
-  if(AliLog::GetDebugLevel("","AliGeomManager")>2) gGeoManager->PrintOverlaps();
-  ovexArray->Delete();
-  delete ovexArray;
-
-  gGeoManager->SetCheckingOverlaps(kFALSE);
-
-  return nOvEx;
-}
 
index 7ae62f2..4b23dbd 100644 (file)
@@ -19,7 +19,6 @@
 class TGeoManager;
 class TGeoPNEntry;
 class TGeoHMatrix;
-class TGeoNode;
 class TObjArray;
 
 class AliAlignObj;
@@ -97,7 +96,6 @@ public:
   static Bool_t         ApplyAlignObjsFromCDB(const char* AlDetsList);
   static Bool_t         LoadAlignObjsFromCDBSingleDet(const char* detName, TObjArray& alignObjArray);
   static Bool_t         CheckSymNamesLUT(const char* detsToBeChecked);
-  static Int_t          CheckOverlapsExtrusions(TGeoNode* start, Double_t threshold=0.01);
 
   ~AliGeomManager();