Geant4-11
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 G4bool checkOverlap)
52 : G4VScoringMesh(lvName)
53 , chkOverlap(checkOverlap)
54 , layeredMaterialName("none")
55 , layeredMaterial(nullptr)
56{
58 logVolName = lvName;
59 probeSize = half_size;
60 G4double hs[] = { half_size, half_size, half_size };
61 SetSize(hs);
62 G4int nBin[] = { 1, 1, 1 };
64 regName = lvName + "_region";
66 {
67 new G4Region(regName);
68 }
69}
70
72
74{
75 G4cout << "G4ScoringProbe : " << logVolName << G4endl;
76 G4int np = posVec.size();
77 for(G4int i = 0; i < np; i++)
78 {
79 G4cout << " >> probe #" << i << " at " << posVec[i] << G4endl;
80 }
82}
83
84#include "G4AutoLock.hh"
85namespace
86{
88}
89
91{
93 {
94 auto worldLog = worldPhys->GetLogicalVolume();
96 assert(region != nullptr);
97 region->AddRootLogicalVolume(worldLog);
98 region->SetWorld(worldPhys);
99
100 auto boxSolid =
101 new G4Box(logVolName + "_solid", probeSize, probeSize, probeSize);
103 new G4LogicalVolume(boxSolid, layeredMaterial, logVolName + "_log");
104
105 G4int np = posVec.size();
106 for(G4int i = 0; i < np; i++)
107 {
109 worldLog, false, i, chkOverlap);
110 }
111
112 G4VisAttributes* wisatt = new G4VisAttributes(G4Colour(.5, .5, .5));
113 wisatt->SetVisibility(false);
114 worldLog->SetVisAttributes(wisatt);
115 G4VisAttributes* visatt = new G4VisAttributes(G4Colour(.5, .5, .5));
116 visatt->SetVisibility(true);
118 }
119 else
120 {
124 assert(fMeshElementLogical != nullptr);
125 l.unlock();
126 }
127
129}
130
132{
134 {
135 if(val == "none")
136 {
138 layeredMassFlg = false;
139 layeredMaterial = nullptr;
140 }
141 else
142 {
144 if(!mat)
145 {
146 return false;
147 }
149 layeredMassFlg = true;
150 layeredMaterial = mat;
151 }
153 assert(region != nullptr);
154 region->UpdateMaterialList();
155 }
156 return true;
157}
#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
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