Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ScoringRealWorld.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#include "G4ScoringRealWorld.hh"
27
28#include "G4LogicalVolume.hh"
30#include "G4VPhysicalVolume.hh"
32#include "G4Region.hh"
33
35#include "G4VPrimitiveScorer.hh"
36
37#include "G4ScoringManager.hh"
38#include "G4StatDouble.hh"
39
40#include "G4SystemOfUnits.hh"
41
43 : G4VScoringMesh(lvName)
44{
46 logVolName = lvName;
47 G4double size[] = { 0., 0., 0. };
48 SetSize(size);
49 G4int nBin[] = { 1, 1, 1 };
51}
52
54{
55 G4cout << "G4ScoringRealWorld : " << logVolName << G4endl;
57}
58
59#include "G4AutoLock.hh"
60namespace
61{
62 G4Mutex logvolmutex = G4MUTEX_INITIALIZER;
63}
65{
66 G4AutoLock l(&logvolmutex);
68 auto itr = store->begin();
69 for(; itr != store->end(); itr++)
70 {
71 if((*itr)->GetName() == logVolName)
72 {
73 fMeshElementLogical = (*itr); // Logical volume to score
74 G4int nb = 0;
76 auto pvItr = pvStore->begin();
77 for(; pvItr != pvStore->end(); pvItr++)
78 {
79 if((*pvItr)->GetLogicalVolume() == (*itr))
80 {
81 nb += (*pvItr)->GetMultiplicity();
82 }
83 }
84 G4int nBin[] = { nb, 1, 1 };
86 // check if this logical volume belongs to the real world
87 auto region = (*itr)->GetRegion();
88 if((region != nullptr) && !(region->IsInMassGeometry()))
89 {
91 ed << "Logical Volume with name <" << logVolName
92 << "> is not used in the mass world.";
93 G4Exception("G4ScoringRealWorld", "SWV0001", FatalException, ed);
94 }
95 // set the sensitive detector
97 return;
98 }
99 }
101 ed << "Logical Volume with name <" << logVolName << "> is not found";
102 G4Exception("G4ScoringRealWorld", "SWV0000", FatalException, ed);
103}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4MUTEX_INITIALIZER
Definition: G4Threading.hh:85
std::mutex G4Mutex
Definition: G4Threading.hh:81
double G4double
Definition: G4Types.hh:83
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
static G4LogicalVolumeStore * GetInstance()
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
static G4PhysicalVolumeStore * GetInstance()
void SetupGeometry(G4VPhysicalVolume *) override
G4ScoringRealWorld(G4String lvName)
void List() const override
virtual void List() const
G4MultiFunctionalDetector * fMFD
G4LogicalVolume * fMeshElementLogical
void SetNumberOfSegments(G4int nSegment[3])
void SetSize(G4double size[3])