Commit of new FMD3 geometry and other geometry related issues.
[u/mrichter/AliRoot.git] / FMD / scripts / CheckOverlaps.C
1 void
2 CheckOverlaps(const char* file="geometry.root", 
3               Bool_t align=kFALSE, Bool_t sample=kTRUE)
4 {
5   TObjArray* checked = new TObjArray();
6   
7   AliGeomManager::LoadGeometry(file);
8   if (align)
9     AliGeomManager::ApplyAlignObjsToGeom("FMDfullMisalignment.root", 
10                                          "FMDAlignment");
11   TObjArray*        l = gGeoManager->GetListOfPhysicalNodes();
12   TIter             next(l);
13   TGeoPhysicalNode* pn = 0;
14   TGeoVolume*       v  = 0;
15   while ((pn = static_cast<TGeoPhysicalNode*>(next()))) { 
16     pn->cd();
17     gGeoManager->CdUp();
18     v = gGeoManager->GetCurrentVolume();
19     if (checked->FindObject(v)) continue;
20     
21     std::cout << "Checking " << v->GetName() << std::endl;
22     v->CheckOverlaps(0.01);
23     Int_t n = gGeoManager->GetListOfOverlaps()->GetEntriesFast();
24     if (n) { 
25       gGeoManager->GetListOfOverlaps()->ls();
26     }
27     checked->Add(v);
28     
29     if (!sample) continue;
30
31     // gGeoManager->ClearOverlaps();
32     gGeoManager->SetCheckingOverlaps();
33     TGeoNode*    start = gGeoManager->GetCurrentNode();
34     TGeoVolume*  vol   = start->GetVolume();
35     TGeoIterator gnext(vol);
36     TGeoNode*    node;
37     TString      path;
38     while ((node = gnext())) {
39       gnext.GetPath(path);
40       // std::cout << " Checking: " <<  path.Data() << std::endl;
41       node->GetVolume()->CheckOverlaps(0.01,"s");
42     }
43     gGeoManager->SetCheckingOverlaps(kFALSE);
44     n = gGeoManager->GetListOfOverlaps()->GetEntriesFast();
45     if (n) {
46       gGeoManager->GetListOfOverlaps()->ls();
47       pn->Print();
48     }
49   }
50 }
51