Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:56:40

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      const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>&
0065        foundBasePVPath = std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
0066      const std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>&
0067        foundFullPVPath = std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
0068      const G4Transform3D& foundObjectTransformation = G4Transform3D())
0069     : fpSearchPV(pSearchPV)
0070     , fpFoundPV(pFoundPV)
0071     , fFoundPVCopyNo(foundPVCopyNo)
0072     , fFoundDepth(foundDepth)
0073     , fFoundBasePVPath(foundBasePVPath)
0074     , fFoundFullPVPath(foundFullPVPath)
0075     , fFoundObjectTransformation(foundObjectTransformation) {}
0076     Findings(const G4PhysicalVolumeModel::TouchableProperties& tp)
0077     : fpSearchPV(nullptr)
0078     , fpFoundPV(tp.fpTouchablePV)
0079     , fFoundPVCopyNo(tp.fCopyNo)
0080     , fFoundDepth(0)
0081     , fFoundBasePVPath(tp.fTouchableBaseFullPVPath)
0082     , fFoundFullPVPath(tp.fTouchableFullPVPath)
0083     , fFoundObjectTransformation(tp.fTouchableGlobalTransform) {}
0084     G4VPhysicalVolume*   fpSearchPV;   // Searched physical volume.
0085     G4VPhysicalVolume*   fpFoundPV;    // Found physical volume.
0086     G4int                fFoundPVCopyNo;  // Found Copy number.
0087     G4int                fFoundDepth;  // Found depth.
0088     std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
0089     fFoundBasePVPath;    // Base path (e.g., empty for world volume)
0090     std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
0091     fFoundFullPVPath;    // Full path of found volume
0092     G4Transform3D        fFoundObjectTransformation;  // Found transformation.
0093   };
0094 
0095   const std::vector<Findings>& GetFindings() const
0096   {return fFindings;}
0097 
0098 private:
0099 
0100   class Matcher {
0101   public:
0102     Matcher(const G4String& requiredMatch);
0103     G4bool Match(const G4String&);
0104     // Match the string with the required match. The latter can be of the form
0105     // "/regexp/", where regexp is a regular expression (see C++ regex),
0106     // or a plain string, in which case there must be an exact match.
0107   private:
0108     G4bool   fRegexFlag;  // True if fRequiredMatch is of the form "/.../".
0109     G4String fRequiredMatch;
0110   };
0111 
0112   void ProcessVolume(const G4VSolid&);
0113   
0114   const G4PhysicalVolumeModel* fpSearchVolumesModel;
0115   Matcher                      fMatcher;
0116   G4int                        fRequiredCopyNo;
0117   std::vector<Findings>        fFindings;
0118 };
0119 
0120 #endif