Geant4 10.7.0
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 "G4SDParticleFilter.hh"
42#include "G4VPrimitiveScorer.hh"
43
44#include "G4ScoringManager.hh"
45#include "G4StatDouble.hh"
46
47#include "G4SystemOfUnits.hh"
48#include "G4VisAttributes.hh"
49
51 :G4VScoringMesh(lvName), chkOverlap(checkOverlap),
52 layeredMaterialName("none"), layeredMaterial(nullptr)
53{
55 logVolName = lvName;
56 probeSize = half_size;
57 G4double hs[] = {half_size,half_size,half_size};
58 SetSize(hs);
59 G4int nBin[] = {1,1,1};
61 regName = lvName + "_region";
63 { new G4Region(regName); }
64}
65
67{
68}
69
71{
72 G4cout << "G4ScoringProbe : " << logVolName << G4endl;
73 G4int np = posVec.size();
74 for(G4int i=0;i<np;i++)
75 { G4cout << " >> probe #" << i << " at " << posVec[i] << G4endl; }
77}
78
79#include "G4AutoLock.hh"
80namespace { G4Mutex logvolmutex = G4MUTEX_INITIALIZER; }
81
83{
85 {
86 auto worldLog = worldPhys->GetLogicalVolume();
88 assert(region!=nullptr);
89 region->AddRootLogicalVolume(worldLog);
90 region->SetWorld(worldPhys);
91
92 auto boxSolid = new G4Box(logVolName+"_solid",probeSize,probeSize,probeSize);
94
95 G4int np = posVec.size();
96 for(G4int i=0;i<np;i++)
97 { new G4PVPlacement(0,posVec[i],fMeshElementLogical,logVolName+"_phy",worldLog,false,i,chkOverlap); }
98
99 G4VisAttributes* wisatt = new G4VisAttributes(G4Colour(.5,.5,.5));
100 wisatt->SetVisibility(false);
101 worldLog->SetVisAttributes(wisatt);
102 G4VisAttributes* visatt = new G4VisAttributes(G4Colour(.5,.5,.5));
103 visatt->SetVisibility(true);
105 }
106 else
107 {
108 G4AutoLock l(&logvolmutex);
110 assert(fMeshElementLogical!=nullptr);
111 l.unlock();
112 }
113
115
116}
117
119{
120 G4AutoLock l(&logvolmutex);
121 if(val == "none")
122 {
124 layeredMassFlg = false;
125 layeredMaterial = nullptr;
126 }
127 else
128 {
130 if(!mat)
131 { return false; }
133 layeredMassFlg = true;
134 layeredMaterial = mat;
135 }
137 assert(region!=nullptr);
138 region->UpdateMaterialList();
139 return true;
140}
141
#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) 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
virtual void List() const
G4double probeSize
virtual void SetupGeometry(G4VPhysicalVolume *)
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])
void SetVisibility(G4bool=true)
G4bool IsMasterThread()
Definition: G4Threading.cc:124