Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:55

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 //
0028 // 
0029 // John Allison  5th September 2018
0030 // Originally G4PhysicalVolumeSearchScene, 10th August 1998, which only
0031 // found the first occurrence of a volume.
0032 // This class (note the extra 's' in the name) produces a vector of all
0033 // occurrences. It can match a physical volume name with the required
0034 // match. The latter can be of the form "/regexp/", where regexp is a
0035 // regular expression (see C++ regex), or a plain string, in which case
0036 // there must be an exact match.
0037 
0038 #ifndef G4PHYSICALVOLUMESSEARCHSCENE_HH
0039 #define G4PHYSICALVOLUMESSEARCHSCENE_HH
0040 
0041 #include "G4PseudoScene.hh"
0042 
0043 #include "G4VPhysicalVolume.hh"
0044 #include "G4PhysicalVolumeModel.hh"
0045 
0046 class G4PhysicalVolumesSearchScene: public G4PseudoScene
0047 {
0048 public:
0049 
0050   G4PhysicalVolumesSearchScene
0051   (G4PhysicalVolumeModel* pSearchVolumeModel,    // usually a world
0052    const G4String&        requiredPhysicalVolumeName,
0053    G4int                  requiredCopyNo = -1); // -1 means any copy no
0054 
0055   virtual ~G4PhysicalVolumesSearchScene () {}
0056 
0057   struct Findings
0058   {
0059     Findings
0060     (G4VPhysicalVolume* pSearchPV,
0061      G4VPhysicalVolume* pFoundPV,
0062      G4int foundPVCopyNo = 0,
0063      G4int foundDepth = 0,
0064      std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
0065      foundBasePVPath =
0066      std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
0067      std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
0068      foundFullPVPath =
0069      std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
0070      G4Transform3D foundObjectTransformation = G4Transform3D())
0071     : fpSearchPV(pSearchPV)
0072     , fpFoundPV(pFoundPV)
0073     , fFoundPVCopyNo(foundPVCopyNo)
0074     , fFoundDepth(foundDepth)
0075     , fFoundBasePVPath(foundBasePVPath)
0076     , fFoundFullPVPath(foundFullPVPath)
0077     , fFoundObjectTransformation(foundObjectTransformation) {}
0078     Findings(const G4PhysicalVolumeModel::TouchableProperties& tp)
0079     : fpSearchPV(nullptr)
0080     , fpFoundPV(tp.fpTouchablePV)
0081     , fFoundPVCopyNo(tp.fCopyNo)
0082     , fFoundDepth(0)
0083     , fFoundBasePVPath(tp.fTouchableBaseFullPVPath)
0084     , fFoundFullPVPath(tp.fTouchableFullPVPath)
0085     , fFoundObjectTransformation(tp.fTouchableGlobalTransform) {}
0086     G4VPhysicalVolume*   fpSearchPV;   // Searched physical volume.
0087     G4VPhysicalVolume*   fpFoundPV;    // Found physical volume.
0088     G4int                fFoundPVCopyNo;  // Found Copy number.
0089     G4int                fFoundDepth;  // Found depth.
0090     std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
0091     fFoundBasePVPath;    // Base path (e.g., empty for world volume)
0092     std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
0093     fFoundFullPVPath;    // Full path of found volume
0094     G4Transform3D        fFoundObjectTransformation;  // Found transformation.
0095   };
0096 
0097   const std::vector<Findings>& GetFindings() const
0098   {return fFindings;}
0099 
0100 private:
0101 
0102   class Matcher {
0103   public:
0104     Matcher(const G4String& requiredMatch);
0105     G4bool Match(const G4String&);
0106     // Match the string with the required match. The latter can be of the form
0107     // "/regexp/", where regexp is a regular expression (see C++ regex),
0108     // or a plain string, in which case there must be an exact match.
0109   private:
0110     G4bool   fRegexFlag;  // True if fRequiredMatch is of the form "/.../".
0111     G4String fRequiredMatch;
0112   };
0113 
0114   void ProcessVolume(const G4VSolid&);
0115   
0116   const G4PhysicalVolumeModel* fpSearchVolumesModel;
0117   Matcher                      fMatcher;
0118   G4int                        fRequiredCopyNo;
0119   std::vector<Findings>        fFindings;
0120 };
0121 
0122 #endif