| [834] | 1 | //
|
|---|
| 2 | // ********************************************************************
|
|---|
| 3 | // * License and Disclaimer *
|
|---|
| 4 | // * *
|
|---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of *
|
|---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and *
|
|---|
| 7 | // * conditions of the Geant4 Software License, included in the file *
|
|---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These *
|
|---|
| 9 | // * include a list of copyright holders. *
|
|---|
| 10 | // * *
|
|---|
| 11 | // * Neither the authors of this software system, nor their employing *
|
|---|
| 12 | // * institutes,nor the agencies providing financial support for this *
|
|---|
| 13 | // * work make any representation or warranty, express or implied, *
|
|---|
| 14 | // * regarding this software system or assume any liability for its *
|
|---|
| 15 | // * use. Please see the license in the file LICENSE and URL above *
|
|---|
| 16 | // * for the full disclaimer and the limitation of liability. *
|
|---|
| 17 | // * *
|
|---|
| 18 | // * This code implementation is the result of the scientific and *
|
|---|
| 19 | // * technical work of the GEANT4 collaboration. *
|
|---|
| 20 | // * By using, copying, modifying or distributing the software (or *
|
|---|
| 21 | // * any work based on the software) you agree to acknowledge its *
|
|---|
| 22 | // * use in resulting scientific publications, and indicate your *
|
|---|
| 23 | // * acceptance of all terms of the Geant4 Software license. *
|
|---|
| 24 | // ********************************************************************
|
|---|
| 25 | //
|
|---|
| 26 | //
|
|---|
| [850] | 27 | // $Id: G4PhysicalVolumeSearchScene.cc,v 1.14 2008/07/27 10:49:24 allison Exp $
|
|---|
| 28 | // GEANT4 tag $Name: HEAD $
|
|---|
| [834] | 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // John Allison 10th August 1998.
|
|---|
| 32 | // An artificial scene to find physical volumes.
|
|---|
| 33 |
|
|---|
| 34 | #include "G4PhysicalVolumeSearchScene.hh"
|
|---|
| 35 |
|
|---|
| 36 | #include "G4VSolid.hh"
|
|---|
| 37 | #include "G4Vector3D.hh"
|
|---|
| 38 | #include "G4PhysicalVolumeModel.hh"
|
|---|
| 39 |
|
|---|
| 40 | G4PhysicalVolumeSearchScene::G4PhysicalVolumeSearchScene
|
|---|
| 41 | (G4PhysicalVolumeModel* pPVModel,
|
|---|
| 42 | const G4String& requiredPhysicalVolumeName,
|
|---|
| 43 | G4int requiredCopyNo):
|
|---|
| 44 | fpPVModel (pPVModel),
|
|---|
| 45 | fRequiredPhysicalVolumeName (requiredPhysicalVolumeName),
|
|---|
| 46 | fRequiredCopyNo (requiredCopyNo),
|
|---|
| 47 | fpCurrentObjectTransformation (0),
|
|---|
| 48 | fFoundDepth (0),
|
|---|
| 49 | fpFoundPV (0),
|
|---|
| 50 | fpFoundLV (0),
|
|---|
| 51 | fMultipleOccurrence (false)
|
|---|
| 52 | {}
|
|---|
| 53 |
|
|---|
| 54 | G4PhysicalVolumeSearchScene::~G4PhysicalVolumeSearchScene () {}
|
|---|
| 55 |
|
|---|
| 56 | void G4PhysicalVolumeSearchScene::FindVolume (const G4VSolid&) {
|
|---|
| 57 |
|
|---|
| 58 | G4int currentDepth = fpPVModel->GetCurrentDepth();
|
|---|
| 59 | G4VPhysicalVolume* pCurrentPV = fpPVModel->GetCurrentPV();
|
|---|
| 60 | G4LogicalVolume* pCurrentLV = fpPVModel->GetCurrentLV();
|
|---|
| 61 | //G4Material* pCurrentMaterial = fpPVModel->GetCurrentMaterial();
|
|---|
| 62 | // Note: pCurrentMaterial may be zero (parallel world).
|
|---|
| 63 |
|
|---|
| 64 | /**************************************************
|
|---|
| 65 | G4cout << "Required volume: \"" << fRequiredPhysicalVolumeName
|
|---|
| 66 | << "\", copy no. " << fRequiredCopyNo << G4endl;
|
|---|
| 67 | G4cout << "PhysicalVolume: \"" << pCurrentPV -> GetName ()
|
|---|
| 68 | << "\", copy no. " << pCurrentPV -> GetCopyNo () << G4endl;
|
|---|
| 69 | *******************************************/
|
|---|
| 70 |
|
|---|
| 71 | if (fRequiredPhysicalVolumeName == pCurrentPV -> GetName () &&
|
|---|
| 72 | (fRequiredCopyNo < 0 || // I.e., ignore negative request.
|
|---|
| 73 | fRequiredCopyNo == pCurrentPV -> GetCopyNo ())) {
|
|---|
| 74 | // Current policy - take first one found!!
|
|---|
| 75 | if (!fpFoundPV) { // i.e., if not already found.
|
|---|
| 76 | fFoundDepth = currentDepth;
|
|---|
| 77 | fpFoundPV = pCurrentPV;
|
|---|
| 78 | fpFoundLV = pCurrentLV;
|
|---|
| 79 | fFoundObjectTransformation = *fpCurrentObjectTransformation;
|
|---|
| 80 | }
|
|---|
| 81 | else {
|
|---|
| 82 | if (!fMultipleOccurrence) {
|
|---|
| 83 | fMultipleOccurrence = true;
|
|---|
| 84 | G4cout << "G4PhysicalVolumeSearchScene::FindVolume:"
|
|---|
| [850] | 85 | << "\n Required volume \""
|
|---|
| [834] | 86 | << fRequiredPhysicalVolumeName
|
|---|
| 87 | << "\"";
|
|---|
| 88 | if (fRequiredCopyNo >= 0) {
|
|---|
| 89 | G4cout << ", copy no. " << fRequiredCopyNo << ",";
|
|---|
| 90 | }
|
|---|
| 91 | G4cout << " found more than once."
|
|---|
| 92 | "\n This function is not smart enough to distinguish identical"
|
|---|
| 93 | "\n physical volumes which have different parentage. It is"
|
|---|
| 94 | "\n tricky to specify in general. This function gives you access"
|
|---|
| 95 | "\n to the first occurrence only."
|
|---|
| 96 | << G4endl;
|
|---|
| 97 | }
|
|---|
| 98 | }
|
|---|
| 99 | }
|
|---|
| 100 | }
|
|---|