G4PhysicalVolumeSearchScene.cc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // John Allison  10th August 1998.
00031 // An artificial scene to find physical volumes.
00032 
00033 #include "G4PhysicalVolumeSearchScene.hh"
00034 
00035 #include "G4VSolid.hh"
00036 #include "G4Vector3D.hh"
00037 #include "G4PhysicalVolumeModel.hh"
00038 
00039 G4PhysicalVolumeSearchScene::G4PhysicalVolumeSearchScene
00040 (G4PhysicalVolumeModel* pPVModel,
00041  const G4String& requiredPhysicalVolumeName,
00042  G4int requiredCopyNo):
00043   fpPVModel                     (pPVModel),
00044   fRequiredPhysicalVolumeName   (requiredPhysicalVolumeName),
00045   fRequiredCopyNo               (requiredCopyNo),
00046   fpCurrentObjectTransformation (0),
00047   fFoundDepth                   (0),
00048   fpFoundPV                     (0),
00049   fpFoundLV                     (0),
00050   fMultipleOccurrence           (false)
00051 {}
00052 
00053 G4PhysicalVolumeSearchScene::~G4PhysicalVolumeSearchScene () {}
00054 
00055 void G4PhysicalVolumeSearchScene::FindVolume (const G4VSolid&) {
00056 
00057   typedef G4PhysicalVolumeModel::G4PhysicalVolumeNodeID PVNodeID;
00058   typedef std::vector<PVNodeID> PVPath;
00059   const PVPath& fullPVPath = fpPVModel->GetFullPVPath();
00060   G4int currentDepth = fpPVModel->GetCurrentDepth();
00061   G4VPhysicalVolume* pCurrentPV = fpPVModel->GetCurrentPV();
00062   G4LogicalVolume* pCurrentLV = fpPVModel->GetCurrentLV();
00063   //G4Material* pCurrentMaterial = fpPVModel->GetCurrentMaterial();
00064   // Note: pCurrentMaterial may be zero (parallel world).
00065 
00066   /**************************************************
00067   G4cout << "Required volume: \"" << fRequiredPhysicalVolumeName
00068          << "\", copy no. " << fRequiredCopyNo << G4endl;
00069   G4cout << "PhysicalVolume:  \"" << pCurrentPV -> GetName ()
00070          << "\", copy no. " << pCurrentPV -> GetCopyNo () << G4endl;
00071   *******************************************/
00072 
00073   if (fRequiredPhysicalVolumeName == pCurrentPV -> GetName () &&
00074       (fRequiredCopyNo             < 0 ||  // I.e., ignore negative request.
00075        fRequiredCopyNo             == pCurrentPV -> GetCopyNo ())) {
00076     // Current policy - take first one found!!
00077     if (!fpFoundPV) {  // i.e., if not already found.
00078       fFoundFullPVPath           = fullPVPath;
00079       fFoundDepth                = currentDepth;
00080       fpFoundPV                  = pCurrentPV;
00081       fpFoundLV                  = pCurrentLV;
00082       fFoundObjectTransformation = *fpCurrentObjectTransformation;
00083     }
00084     else {
00085       if (!fMultipleOccurrence) {
00086         fMultipleOccurrence = true;
00087         G4cout << "G4PhysicalVolumeSearchScene::FindVolume:"
00088                << "\n  Required volume \""
00089                << fRequiredPhysicalVolumeName
00090                << "\"";
00091         if (fRequiredCopyNo >= 0) {
00092           G4cout << ", copy no. " << fRequiredCopyNo << ",";
00093         }
00094         G4cout << " found more than once."
00095           "\n  This function is not smart enough to distinguish identical"
00096           "\n  physical volumes which have different parentage.  It is"
00097           "\n  tricky to specify in general.  This function gives you access"
00098           "\n  to the first occurrence only."
00099                << G4endl;
00100       }
00101     }
00102   }      
00103 }

Generated on Mon May 27 17:49:19 2013 for Geant4 by  doxygen 1.4.7