Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ScoringProbe.cc
Go to the documentation of this file.
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//
27#include "G4ScoringProbe.hh"
28
29#include "G4Box.hh"
30#include "G4LogicalVolume.hh"
32#include "G4VPhysicalVolume.hh"
33#include "G4PVPlacement.hh"
34#include "G4Region.hh"
35#include "G4RegionStore.hh"
36#include "G4Threading.hh"
37#include "G4Material.hh"
38#include "G4NistManager.hh"
39
41#include "G4VPrimitiveScorer.hh"
42
43#include "G4ScoringManager.hh"
44#include "G4StatDouble.hh"
45
46#include "G4SystemOfUnits.hh"
47#include "G4VisAttributes.hh"
48
50 G4bool checkOverlap)
51 : G4VScoringMesh(lvName)
52 , chkOverlap(checkOverlap)
53 , layeredMaterialName("none")
54 , layeredMaterial(nullptr)
55{
57 logVolName = lvName;
58 probeSize = half_size;
59 G4double hs[] = { half_size, half_size, half_size };
60 SetSize(hs);
61 G4int nBin[] = { 1, 1, 1 };
63 regName = lvName + "_region";
65 {
66 new G4Region(regName);
67 }
68}
69
71{
72 G4cout << "G4ScoringProbe : " << logVolName << G4endl;
73 std::size_t np = posVec.size();
74 for(std::size_t i = 0; i < np; ++i)
75 {
76 G4cout << " >> probe #" << i << " at " << posVec[i] << G4endl;
77 }
79}
80
81#include "G4AutoLock.hh"
82namespace
83{
84 G4Mutex logvolmutex = G4MUTEX_INITIALIZER;
85}
86
88{
90 {
91 auto worldLog = worldPhys->GetLogicalVolume();
93 assert(region != nullptr);
94 region->AddRootLogicalVolume(worldLog);
95 region->SetWorld(worldPhys);
96
97 auto boxSolid =
98 new G4Box(logVolName + "_solid", probeSize, probeSize, probeSize);
100 new G4LogicalVolume(boxSolid, layeredMaterial, logVolName + "_log");
101
102 std::size_t np = posVec.size();
103 for(std::size_t i = 0; i < np; ++i)
104 {
105 new G4PVPlacement(nullptr, posVec[i], fMeshElementLogical, logVolName + "_phy",
106 worldLog, false, (G4int)i, chkOverlap);
107 }
108
109 auto wisatt = new G4VisAttributes(G4Colour(.5, .5, .5));
110 wisatt->SetVisibility(false);
111 worldLog->SetVisAttributes(wisatt);
112 auto visatt = new G4VisAttributes(G4Colour(.5, .5, .5));
113 visatt->SetVisibility(true);
115 }
116 else
117 {
118 G4AutoLock l(&logvolmutex);
121 assert(fMeshElementLogical != nullptr);
122 l.unlock();
123 }
124
126}
127
129{
131 {
132 if(val == "none")
133 {
135 layeredMassFlg = false;
136 layeredMaterial = nullptr;
137 }
138 else
139 {
141 if(mat == nullptr)
142 {
143 return false;
144 }
146 layeredMassFlg = true;
147 layeredMaterial = mat;
148 }
150 assert(region != nullptr);
151 region->UpdateMaterialList();
152 }
153 return true;
154}
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
std::mutex G4Mutex
Definition: G4Threading.hh:81
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
Definition: G4Box.hh:56
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true, G4bool reverseSearch=false) const
static G4LogicalVolumeStore * GetInstance()
void SetVisAttributes(const G4VisAttributes *pVA)
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
G4Material * FindOrBuildMaterial(const G4String &name, G4bool isotopes=true, G4bool warning=false)
static G4NistManager * Instance()
static G4RegionStore * GetInstance()
G4Region * GetRegion(const G4String &name, G4bool verbose=true) const
void SetupGeometry(G4VPhysicalVolume *) override
G4double probeSize
void List() const override
G4String logVolName
G4String layeredMaterialName
G4ScoringProbe(G4String lvName, G4double half_size, G4bool checkOverlap=false)
std::vector< G4ThreeVector > posVec
G4bool SetMaterial(G4String val)
G4Material * layeredMaterial
G4LogicalVolume * GetLogicalVolume() const
virtual void List() const
G4MultiFunctionalDetector * fMFD
G4LogicalVolume * fMeshElementLogical
void SetNumberOfSegments(G4int nSegment[3])
void SetSize(G4double size[3])
G4bool IsMasterThread()
Definition: G4Threading.cc:124