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

UgliDbiStructHash.cxx

Go to the documentation of this file.
00001 
00002 // $Id: UgliDbiStructHash.cxx,v 1.6 2005/08/26 19:00:02 rhatcher Exp $
00003 //
00004 // UgliDbiStructHash
00005 //
00006 // Package: UgliGeometry
00007 //
00008 // R. Hatcher  2002-08-02
00009 //
00010 // Concept:
00011 //   
00012 // Purpose:
00013 //
00015 
00016 #include "UgliGeometry/UgliDbiStructHash.h"
00017 #include "MessageService/MsgService.h"
00018 
00019 ClassImp(UgliDbiStructHash)
00020 
00021 //   Definition of static data members
00022 //   *********************************
00023 
00024 CVSID("$Id: UgliDbiStructHash.cxx,v 1.6 2005/08/26 19:00:02 rhatcher Exp $ CVSID_DBIRESULTPTR ");
00025 
00026 UInt_t arbitraryPln(Detector::Detector_t det,
00027                     PlaneView::PlaneView_t view,
00028                     PlaneCoverage::PlaneCoverage_t cover) {
00029   // return an arbitrary plane ... execpt in case of veto stuff
00030   if (Detector::kFar != det) return 0;
00031   // more work if far
00032   if (view < PlaneView::kVSTopFlat && cover < PlaneCoverage::kVScN) return 0;
00033   // should check that both view,cover are veto related
00034   return 512;
00035 }
00036 
00037 
00038 //.....................................................................
00039 
00040 bool operator==(const UgliDbiStructHash::viewcover_t& vc1, 
00041                 const UgliDbiStructHash::viewcover_t& vc2) {
00042   if ( vc1.view  != vc2.view  ) return false;
00043   if ( vc1.cover != vc2.cover ) return false;
00044   return true;
00045 }
00046 
00047 //.....................................................................
00048 
00049 // Definition of member functions (alphabetical order)
00050 // ***************************************************
00051 
00052 UInt_t UgliDbiStructHash::HashAsPlane() const
00053 { UShort_t maxpart = 0; return HashToIndex(maxpart); }
00054 
00055 UInt_t UgliDbiStructHash::HashAsScintMdl() const
00056 { 
00057   UInt_t apln = arbitraryPln(fDetector,fPlaneView,fPlaneCoverage);
00058   PlexPlaneId plnid(fDetector,apln,false,fPlaneView,fPlaneCoverage);
00059   UShort_t maxpart = plnid.GetNumScintMdls();
00060   return HashToIndex(maxpart); 
00061 }
00062 
00063 UInt_t UgliDbiStructHash::HashAsStrip() const
00064 { 
00065   UInt_t apln = arbitraryPln(fDetector,fPlaneView,fPlaneCoverage);
00066   PlexPlaneId plnid(fDetector,apln,false,fPlaneView,fPlaneCoverage);
00067   UShort_t maxpart = plnid.GetNumStrips();
00068   return HashToIndex(maxpart); 
00069 }
00070 
00071 UInt_t UgliDbiStructHash::HashToIndex(UShort_t maxpart) const
00072 {
00073    // make a natural index where the "part" takes on values [0..maxpart]
00074 
00075    // Different hashes based on detector
00076 
00077   static viewcover_t gNearCombos[] = {
00078     {PlaneView::kUnknown,PlaneCoverage::kNoActive},
00079     {PlaneView::kUnknown,PlaneCoverage::kUnknown},
00080     {PlaneView::kU,PlaneCoverage::kNearPartial},
00081     {PlaneView::kU,PlaneCoverage::kNearFull},
00082     {PlaneView::kV,PlaneCoverage::kNearPartial},
00083     {PlaneView::kV,PlaneCoverage::kNearFull}
00084   };
00085   static unsigned int gNumNearCombos =
00086     sizeof(gNearCombos)/sizeof(viewcover_t);
00087 
00088   static viewcover_t gFarCombos[] = {
00089     {PlaneView::kUnknown,PlaneCoverage::kNoActive},
00090     {PlaneView::kUnknown,PlaneCoverage::kUnknown},
00091     {PlaneView::kU,PlaneCoverage::kComplete},
00092     {PlaneView::kV,PlaneCoverage::kComplete},
00093 
00094     // veto shield top (C/c-N, E/e-S)
00095 
00096     {PlaneView::kVSTopFlat,       PlaneCoverage::kVScN},
00097     {PlaneView::kVSTopEastSlant,  PlaneCoverage::kVScN},
00098     {PlaneView::kVSTopWestSlant,  PlaneCoverage::kVScN},
00099 
00100     {PlaneView::kVSTopFlat,       PlaneCoverage::kVSCN},
00101     {PlaneView::kVSTopEastSlant,  PlaneCoverage::kVSCN},
00102     {PlaneView::kVSTopWestSlant,  PlaneCoverage::kVSCN},
00103 
00104     {PlaneView::kVSTopFlat,       PlaneCoverage::kVSeS},
00105     {PlaneView::kVSTopEastSlant,  PlaneCoverage::kVSeS},
00106     {PlaneView::kVSTopWestSlant,  PlaneCoverage::kVSeS},
00107 
00108     {PlaneView::kVSTopFlat,       PlaneCoverage::kVSES},
00109     {PlaneView::kVSTopEastSlant,  PlaneCoverage::kVSES},
00110     {PlaneView::kVSTopWestSlant,  PlaneCoverage::kVSES},
00111 
00112     // veto shield walls (C/c-N, E/e-S)
00113 
00114     {PlaneView::kVSWallOnEdge,    PlaneCoverage::kVScN},
00115     {PlaneView::kVSWallEastSlant, PlaneCoverage::kVScN},
00116     {PlaneView::kVSWallWestSlant, PlaneCoverage::kVScN},
00117 
00118     {PlaneView::kVSWallOnEdge,    PlaneCoverage::kVSCN},
00119     {PlaneView::kVSWallEastSlant, PlaneCoverage::kVSCN},
00120     {PlaneView::kVSWallWestSlant, PlaneCoverage::kVSCN},
00121 
00122     {PlaneView::kVSWallOnEdge,    PlaneCoverage::kVSeS},
00123     {PlaneView::kVSWallEastSlant, PlaneCoverage::kVSeS},
00124     {PlaneView::kVSWallWestSlant, PlaneCoverage::kVSeS},
00125 
00126     {PlaneView::kVSWallOnEdge,    PlaneCoverage::kVSES},
00127     {PlaneView::kVSWallEastSlant, PlaneCoverage::kVSES},
00128     {PlaneView::kVSWallWestSlant, PlaneCoverage::kVSES},
00129 
00130     // veto shield top (C/c-S, E/e-N)
00131 
00132     {PlaneView::kVSTopFlat,       PlaneCoverage::kVScS},
00133     {PlaneView::kVSTopEastSlant,  PlaneCoverage::kVScS},
00134     {PlaneView::kVSTopWestSlant,  PlaneCoverage::kVScS},
00135 
00136     {PlaneView::kVSTopFlat,       PlaneCoverage::kVSCS},
00137     {PlaneView::kVSTopEastSlant,  PlaneCoverage::kVSCS},
00138     {PlaneView::kVSTopWestSlant,  PlaneCoverage::kVSCS},
00139 
00140     {PlaneView::kVSTopFlat,       PlaneCoverage::kVSeN},
00141     {PlaneView::kVSTopEastSlant,  PlaneCoverage::kVSeN},
00142     {PlaneView::kVSTopWestSlant,  PlaneCoverage::kVSeN},
00143 
00144     {PlaneView::kVSTopFlat,       PlaneCoverage::kVSEN},
00145     {PlaneView::kVSTopEastSlant,  PlaneCoverage::kVSEN},
00146     {PlaneView::kVSTopWestSlant,  PlaneCoverage::kVSEN},
00147 
00148     // veto shield walls (C/c-S, E/e-N)
00149 
00150     {PlaneView::kVSWallOnEdge,    PlaneCoverage::kVScS},
00151     {PlaneView::kVSWallEastSlant, PlaneCoverage::kVScS},
00152     {PlaneView::kVSWallWestSlant, PlaneCoverage::kVScS},
00153 
00154     {PlaneView::kVSWallOnEdge,    PlaneCoverage::kVSCS},
00155     {PlaneView::kVSWallEastSlant, PlaneCoverage::kVSCS},
00156     {PlaneView::kVSWallWestSlant, PlaneCoverage::kVSCS},
00157 
00158     {PlaneView::kVSWallOnEdge,    PlaneCoverage::kVSeN},
00159     {PlaneView::kVSWallEastSlant, PlaneCoverage::kVSeN},
00160     {PlaneView::kVSWallWestSlant, PlaneCoverage::kVSeN},
00161 
00162     {PlaneView::kVSWallOnEdge,    PlaneCoverage::kVSEN},
00163     {PlaneView::kVSWallEastSlant, PlaneCoverage::kVSEN},
00164     {PlaneView::kVSWallWestSlant, PlaneCoverage::kVSEN},
00165 
00166 
00167   };
00168   static unsigned int gNumFarCombos =
00169     sizeof(gFarCombos)/sizeof(viewcover_t);
00170 
00171 
00172   static viewcover_t gCalDetCombos[] = {
00173     {PlaneView::kUnknown,PlaneCoverage::kNoActive},
00174     {PlaneView::kUnknown,PlaneCoverage::kUnknown},
00175     {PlaneView::kU,PlaneCoverage::kComplete},
00176     {PlaneView::kV,PlaneCoverage::kComplete},
00177     {PlaneView::kA,PlaneCoverage::kComplete},
00178     {PlaneView::kB,PlaneCoverage::kComplete}
00179   };
00180   static unsigned int gNumCalDetCombos =
00181     sizeof(gCalDetCombos)/sizeof(viewcover_t);
00182 
00183 
00184   static viewcover_t gAllCombos[] = {
00185     {PlaneView::kUnknown,PlaneCoverage::kNoActive},
00186     {PlaneView::kUnknown,PlaneCoverage::kUnknown},
00187     {PlaneView::kU,PlaneCoverage::kComplete},
00188     {PlaneView::kV,PlaneCoverage::kComplete},
00189     {PlaneView::kA,PlaneCoverage::kComplete},
00190     {PlaneView::kB,PlaneCoverage::kComplete}
00191   };
00192   static unsigned int gNumAllCombos =
00193     sizeof(gAllCombos)/sizeof(viewcover_t);
00194 
00195    switch (fDetector) {
00196    case (Detector::kNear):   
00197      return HashToIndex(gNearCombos,
00198                         gNumNearCombos,
00199                         maxpart);
00200    case (Detector::kFar):    
00201      return HashToIndex(gFarCombos,
00202                         gNumFarCombos,
00203                         maxpart);
00204    case (Detector::kCalDet): 
00205      return HashToIndex(gCalDetCombos,
00206                         gNumCalDetCombos,
00207                         maxpart);
00208    default:                 
00209      return HashToIndex(gAllCombos,
00210                         gNumAllCombos,
00211                         maxpart);
00212    }
00213 }
00214 
00215 UInt_t UgliDbiStructHash::HashToIndex(viewcover_t* vclist, UShort_t nlist, 
00216                                       UShort_t /* maxpart */ ) const
00217 {
00218 
00219   viewcover_t thisvc;
00220   thisvc.view  = fPlaneView;
00221   thisvc.cover = fPlaneCoverage;
00222 
00223   int indx_fnd = -1;
00224   for (unsigned int indx = 0; indx<nlist; ++indx) {
00225     if (thisvc == vclist[indx]) 
00226       { indx_fnd = indx; break; }
00227   }
00228   if (indx_fnd == -1) {
00229      MSG("Ugli",Msg::kWarning)
00230        << "Hash det " << Detector::AsString(fDetector) 
00231        << " view " << PlaneView::AsString(fPlaneView)
00232        << " cover " << PlaneCoverage::AsString(fPlaneCoverage)
00233        << " breaks hashing scheme" << endl;
00234      indx_fnd = 0;
00235   }
00236 
00237   UInt_t hvalue = fPart*nlist + indx_fnd;
00238   return hvalue;
00239 
00240 }
00241 
00242 //.....................................................................

Generated on Mon Feb 15 11:07:48 2010 for loon by  doxygen 1.3.9.1