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

GeoShield.cxx

Go to the documentation of this file.
00001 
00002 //
00003 // GeoShield
00004 //
00005 // GeoShield is a helper class for associating shield planes into groups.
00006 //
00007 // Author:  S. Kasahara 10/05
00009 
00010 #include <iostream>
00011 using namespace std;
00012 
00013 #include "TGeoVolume.h"
00014 
00015 #include "GeoGeometry/GeoShield.h"
00016 #include "GeoGeometry/GeoShieldGroup.h"
00017 #include "Conventions/PlaneView.h"
00018 #include "UgliGeometry/UgliDbiSteelPln.h"
00019 #include "MessageService/MsgService.h"
00020 
00021 ClassImp(GeoShield)
00022 
00023 CVSID("$Id: GeoShield.cxx,v 1.2 2007/03/01 17:13:57 rhatcher Exp $");
00024 
00025 //_____________________________________________________________________________
00026 GeoShield::GeoShield(GeoGeometry* geo) : fGeoGeometry(geo) {
00027 
00028   // Normal constructor
00029   MSG("Geo",Msg::kDebug) << "GeoShield normal ctor @ " << this << endl;
00030 
00031 }
00032 
00033 //_____________________________________________________________________________
00034 GeoShield::~GeoShield() {
00035   // Destructor, delete all owned objects
00036   MSG("Geo",Msg::kDebug) << "GeoShield dtor @ " << this << endl;
00037 
00038   // reference geometry is not owned
00039 
00040   // Shield groups stored in map *are* owned
00041   GroupMapItr mapitr;
00042   for ( mapitr = fGroupMap.begin(); mapitr != fGroupMap.end(); mapitr++ ) {
00043     GeoShieldGroup* shieldgrp = mapitr -> second;
00044     // reclaim group memory before map is destructed
00045     if ( shieldgrp ) delete shieldgrp; shieldgrp = 0;
00046   }
00047 
00048 }
00049 
00050 //_____________________________________________________________________________
00051 void GeoShield::Print(Option_t* /* option */) const {
00052    // print to cout
00053 
00054   GroupMapConstItr mapitr;
00055   for ( mapitr=fGroupMap.begin(); mapitr != fGroupMap.end(); mapitr++ ) {
00056     GeoShieldGroup* shieldgrp = mapitr -> second;
00057     shieldgrp -> Print();
00058   }
00059   
00060 }
00061 
00062 //_____________________________________________________________________________
00063 std::list<const TGeoVolume*> 
00064                 GeoShield::GetListOfVolumes(EGroupType shieldgrp) const {
00065    // retrieve list of volumes in group from map
00066 
00067   GroupMapConstItr mapitr;
00068   std::list<const TGeoVolume*> vollist; // empty list
00069   
00070   mapitr = fGroupMap.find(shieldgrp);
00071   if ( mapitr != fGroupMap.end() ) {
00072     GeoShieldGroup* shieldgrp = mapitr->second;
00073     return (shieldgrp -> GetListOfVolumes()); // return a copy to the caller
00074   }
00075 
00076   return vollist; // retun empty list if group not found in map
00077   
00078 }
00079 
00080 //_____________________________________________________________________________
00081 const char* GeoShield::AsString(EGroupType shieldgrp) {
00082   // Convert enumerated shield group type to a string
00083 
00084   switch (shieldgrp ) {
00085   case kFarInnerE:
00086     return "FarInnerE";
00087     
00088   case kFarInnerW:
00089     return "FarInnerW";
00090 
00091   case kFarOuterE:
00092     return "FarOuterE";
00093 
00094   case kFarOuterW:
00095     return "FarOuterW";
00096 
00097   case kFarTop:
00098     return "FarTop";
00099 
00100   default:
00101     MSG("GeoShield",Msg::kWarning) 
00102     << "GeoShield::AsString called with unknown shield group type "
00103     << (int)shieldgrp << "." << endl;
00104     return "UNKNOWN";
00105 
00106   } // end of switch
00107   
00108 }
00109 
00110 //_____________________________________________________________________________
00111 GeoShield::EGroupType GeoShield::AddVolume(const TGeoVolume* vol,
00112                                            PlexPlaneId steelId, 
00113                                            const UgliDbiSteelPln* stRow) {
00114   // The stRow is used to extract positional information in order to
00115   // determine size of bounding box.  Return the shield group to which
00116   // this volume belongs.
00117 
00118   if ( !steelId.IsVetoShield() ) {
00119     MSG("Geo",Msg::kFatal) 
00120       << "GeoShield::AddVolume called with non-vetoshield volume!" << endl;
00121     abort();
00122   }
00123   // Determine the type of veto-shield plane from the placement and
00124   // db data
00125   GeoShield::EGroupType shieldgrp = kUnknown;
00126   switch ( steelId.GetPlaneView() ) {
00127 
00128   case PlaneView::kVSTopFlat:
00129   case PlaneView::kVSTopEastSlant:
00130   case PlaneView::kVSTopWestSlant:
00131     shieldgrp = kFarTop;
00132     break;
00133 
00134   case PlaneView::kVSWallEastSlant:
00135     shieldgrp = kFarOuterE;
00136     break;
00137 
00138   case PlaneView::kVSWallWestSlant:
00139     shieldgrp = kFarOuterW;
00140     break;
00141     
00142   case PlaneView::kVSWallOnEdge: 
00143     {
00144       Float_t x0 = stRow->GetX0(); // meters
00145       if ( TMath::Abs(x0) < 5. ) {
00146         // inner
00147         if ( x0 < 0. ) shieldgrp = kFarInnerE;
00148         else shieldgrp = kFarInnerW;
00149       }
00150       else {
00151         // outer
00152         if ( x0 < 0. ) shieldgrp = kFarOuterE;
00153         else shieldgrp = kFarOuterW;
00154       }
00155     }
00156     break;
00157     
00158   default:
00159     MSG("Geo",Msg::kFatal) << "PlaneView " 
00160                            << PlaneView::AsString(steelId.GetPlaneView())
00161                            << " unknown!. Abort." << endl;
00162     abort();
00163 
00164   } // end of plane view switch
00165 
00166   GeoShieldGroup* grp = fGroupMap[shieldgrp];
00167   if ( grp == 0 ) { 
00168     grp = new GeoShieldGroup(fGeoGeometry,shieldgrp);
00169     fGroupMap[shieldgrp] = grp;
00170   }
00171   grp -> AddVolume(vol,stRow);
00172   
00173   return shieldgrp;
00174   
00175 }
00176 
00177 //_____________________________________________________________________________
00178 void GeoShield::BuildGroupNodes(TGeoVolume* hallVol) {
00179   // Build shield group nodes.  Protected method called by GeoGeometry
00180   // when all shield volumes have been added with GeoShield::AddVolume()
00181   // Shield group nodes will be added to hall volume
00182 
00183   
00184   GroupMapConstItr mapitr;
00185   for ( mapitr=fGroupMap.begin(); mapitr!=fGroupMap.end(); mapitr++ ) {
00186     GeoShieldGroup* grp = mapitr -> second;
00187     grp -> BuildNode(hallVol);
00188   }
00189   
00190   return;
00191   
00192 }
00193 

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