Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GeoCheckOverlaps.cc

Go to the documentation of this file.
00001 
00002 //
00003 // GeoCheckOverlaps
00004 //
00005 // Package: (Geo) GeoGeometry
00006 //
00007 // S. Kasahara 10/2005
00008 //
00009 // Purpose: Class for use in validating the GeoGeometry package.
00011 
00012 #include <iostream>
00013 using namespace std;
00014 
00015 #include "TGeoManager.h"
00016 #include "GeoGeometry/test/GeoCheckOverlaps.h"
00017 #include "UgliGeometry/UgliLoanPool.h"
00018 #include "UgliGeometry/UgliGeomHandle.h"
00019 
00020 // Definition of static data members
00021 // *********************************
00022 
00023 // Definition of methods (alphabetical order)
00024 // ***************************************************
00025 
00026 //_____________________________________________________________________________
00027 GeoCheckOverlaps::GeoCheckOverlaps(float precision, Int_t detmask, 
00028                                                     Int_t simmask) : 
00029                        fVldContext(),fGeoManager(0),fPrecision(precision),
00030                        fDetMask(detmask),fSimMask(simmask) {
00031   // Default constructor
00032 
00033 }
00034 
00035 //_____________________________________________________________________________
00036 GeoCheckOverlaps::~GeoCheckOverlaps() {
00037   // Destructor
00038   // fGeoManager is not owned  
00039 }
00040 
00041 //_____________________________________________________________________________
00042 bool GeoCheckOverlaps::TestCheckOverlaps() {
00043   //  Run CheckOverlaps on all volumes in detector
00044   bool pass = true;
00045   
00046   if ( !fGeoManager ) {
00047     cerr << "GeoCheckOverlaps::TestCheckOverlaps Error! fGeoManager is Null!" 
00048          << endl;
00049     pass = false;
00050     return pass;
00051   }
00052     
00053   fGeoManager->CheckOverlaps(fPrecision);
00054   
00055   TObjArray* overlaps = fGeoManager->GetListOfOverlaps();
00056   if ( overlaps ) {
00057     if ( overlaps -> GetEntriesFast() > 0 ) {
00058       cout << "Found " << overlaps->GetEntriesFast() 
00059            << " overlaps/extrusions." << endl;
00060       fGeoManager->PrintOverlaps();
00061       pass = false;
00062     }
00063     fGeoManager->ClearOverlaps(); // reset before next call
00064   }
00065    
00066   return pass;
00067 
00068 }
00069 
00070 //_____________________________________________________________________________
00071 bool GeoCheckOverlaps::RunAllTests() {
00072   //
00073   //  Purpose:  Run sequence of GeoGeometry package validity tests.
00074   //
00075   //  Arguments: none.
00076   //
00077   //  Return:    pass (if all tests successful) or fail
00078   //
00079   //  Contact:   S. Kasahara
00080   // 
00081 
00082   // Test 3 detector types in sequence, with kData DB values
00083   const int ndet = 3;
00084   Detector::Detector_t dettype[ndet] = {Detector::kFar,
00085                                         Detector::kNear,
00086                                         Detector::kCalDet};
00087 
00088   const int nsim = 2;
00089   SimFlag::SimFlag_t simflag[nsim] = { SimFlag::kMC, SimFlag::kData };
00090       
00091   VldTimeStamp currentTime;
00092   
00093   cout << "*** GeoValidate::RunAllTests ***" << endl;
00094   cout << "*** CheckOverlaps w/Precision  = "
00095        << fPrecision << "(cm), Detector: "
00096        << Detector::MaskToString(fDetMask) 
00097        << ", SimFlag: " << SimFlag::MaskToString(fSimMask)
00098        << " ***" << endl;
00099   
00100  
00101   Bool_t passed[ndet][nsim];
00102   VldContext vldc[ndet][nsim];
00103 
00104   for ( int isim = 0; isim < nsim; isim++ ) {
00105     if ( !(simflag[isim] & fSimMask ) ) continue;
00106     for ( int idet = 0; idet < ndet; idet++ ) {
00107       if ( !(dettype[idet] & fDetMask) ) continue;
00108     
00109       passed[idet][isim] = true;
00110       
00111       if (dettype[idet] != Detector::kCalDet) {
00112         // Build vldc using current time
00113         fVldContext = VldContext(dettype[idet],simflag[isim],currentTime);
00114       }
00115       else {
00116         // Current time isn't valid for caldet
00117         fVldContext = VldContext(dettype[idet],simflag[isim],
00118                                  VldTimeStamp(2003,9,15,0,0,0));
00119       }
00120       vldc[idet][isim] = fVldContext; 
00121     
00122       cout << "\n*** Testing geometry with vld " 
00123            << fVldContext << " ***" << endl;
00124     
00125       UgliLoanPool::Instance()->SetUseGeo(true);
00126       UgliGeomHandle geo(fVldContext);
00127       fGeoManager = gGeoManager;
00128     
00129       // Run test methods
00130       cout << "*** TestCheckOverlaps ***" << endl;
00131       if ( TestCheckOverlaps() ) {
00132         cout << "*** All CheckOverlaps tests Passed ***" << endl;
00133       }
00134       else {
00135         cout << "*** At least one CheckOverlaps test FAILED ***" << endl;
00136         passed[idet][isim] = false;
00137       }
00138     
00139       std::string detstatus = " Passed all Tests ***";
00140       if ( !passed[idet][isim] ) detstatus = " FAILED at least one Test ***";
00141     
00142       cout << "\n*** Detector w/vld " << fVldContext << detstatus.c_str() 
00143            << endl;
00144     }
00145   }
00146 
00147   cout << "\n*** Finished all tests:" << endl;
00148   Bool_t allPassed = kTRUE;
00149   for ( int isim = 0; isim < nsim; isim++ ) {
00150     if ( !(simflag[isim] & fSimMask ) ) continue;
00151     for ( int idet = 0; idet < ndet; idet++ ) {
00152       if ( !(dettype[idet] & fDetMask) ) continue;
00153 
00154       std::string detstatus = " Passed all Tests ***";
00155       if ( !passed[idet][isim] ) {
00156         detstatus = " FAILED at least one Test ***";
00157         allPassed = kFALSE;
00158       }
00159       cout << "*** Detector w/vld " << vldc[idet][isim] 
00160            << detstatus.c_str() << endl;
00161     }
00162   }
00163   
00164   return allPassed;
00165 
00166 }
00167 
00168 
00169 
00170 
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 
00179 
00180 
00181 
00182 
00183 
00184 

Generated on Mon Feb 15 11:06:45 2010 for loon by  doxygen 1.3.9.1