00001
00002
00003
00004
00005
00006
00007
00008
00009
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
00021
00022
00023
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
00032
00033 }
00034
00035
00036 GeoCheckOverlaps::~GeoCheckOverlaps() {
00037
00038
00039 }
00040
00041
00042 bool GeoCheckOverlaps::TestCheckOverlaps() {
00043
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();
00064 }
00065
00066 return pass;
00067
00068 }
00069
00070
00071 bool GeoCheckOverlaps::RunAllTests() {
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
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
00113 fVldContext = VldContext(dettype[idet],simflag[isim],currentTime);
00114 }
00115 else {
00116
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
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