Combining standard and sampling TGeo overlap checking in one AliGeomManager method...
authorrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Jun 2008 13:49:00 +0000 (13:49 +0000)
committerrgrosso <rgrosso@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Jun 2008 13:49:00 +0000 (13:49 +0000)
STEER/AliAlignObj.cxx
STEER/AliGeomManager.cxx
STEER/AliGeomManager.h

index c98fa98..b95b253 100644 (file)
@@ -662,7 +662,7 @@ Bool_t AliAlignObj::ApplyToGeometry(Bool_t ovlpcheck)
     AliError("Can't apply the alignment object! gGeoManager doesn't exist or it is still open!");
     return kFALSE;
   }
-  
+
   if (gGeoManager->IsLocked()){
     AliError("Can't apply the alignment object! Geometry is locked!");
     return kFALSE;
@@ -694,6 +694,17 @@ Bool_t AliAlignObj::ApplyToGeometry(Bool_t ovlpcheck)
     return kFALSE;
   }
 
+  Int_t nOvlpBefore = 0, nOvlpAfter = 0;
+  Double_t threshold = 0.01;
+  
+  if(ovlpcheck)
+  {
+    gGeoManager->cd(path);
+    gGeoManager->CdUp();
+    TGeoNode* start = gGeoManager->GetCurrentNode();
+    nOvlpBefore = AliGeomManager::CheckOverlapsExtrusions(start, threshold);
+  }
+
   TGeoHMatrix align,gprime;
   gprime = *node->GetMatrix();
   GetMatrix(align);
@@ -706,17 +717,21 @@ 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,ovlpcheck);
+  node->Align(ginv,0);
+
+  
   if(ovlpcheck){
-    Int_t novex=((TObjArray*)gGeoManager->GetListOfOverlaps())->GetEntriesFast();
-    if(novex){
-      TString error(Form("The alignment of volume %s introduced %d new overlap",GetSymName(),novex));
-      if(novex>1) error+="s";
+    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;
+      //return kFALSE;
     }
   }
 
   return kTRUE;
 }
 
+
index cf2be55..31c3e35 100644 (file)
@@ -1687,3 +1687,27 @@ 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();
+  AliDebugClass(2,Form("Number of overlaps/extrusions: %d", ovexArray->GetEntriesFast()));
+  
+  gGeoManager->SetCheckingOverlaps(kFALSE);
+
+ return ovexArray->GetEntriesFast();
+}
+
index 3440225..7ae62f2 100644 (file)
@@ -19,7 +19,7 @@
 class TGeoManager;
 class TGeoPNEntry;
 class TGeoHMatrix;
-
+class TGeoNode;
 class TObjArray;
 
 class AliAlignObj;
@@ -97,6 +97,7 @@ 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();