Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4MultiFunctionalDetector.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//
28// G4MultiFunctionalDetector
29//
30// 2010-07-23 T.Aso Call PS if the step length or energy deposit is not zero.
31//
32//
34#include "G4SDManager.hh"
35#include "G4VPrimitiveScorer.hh"
36
39{
40 ;
41}
42
44{
45 for(auto pr : primitives)
46 delete pr;
47 primitives.clear();
48}
49
52{
53 if(aStep->GetStepLength() > 0. || aStep->GetTotalEnergyDeposit() > 0.)
54 {
55 for(auto pr : primitives)
56 {
57 pr->HitPrimitive(aStep, aTH);
58 }
59 }
60 return true;
61}
62
64{
65 for(auto pr : primitives)
66 {
67 if(pr == aPS)
68 {
70 ED << "Primitive <" << aPS->GetName() << "> is already defined in <"
71 << SensitiveDetectorName << ">." << G4endl
72 << "Method RegisterPrimitive() is ignored." << G4endl;
73 G4Exception("G4MultiFunctionalDetector::RegisterPrimitive", "Det0101",
74 JustWarning, ED);
75 return false;
76 }
77 }
78 primitives.push_back(aPS);
81 if(G4SDManager::GetSDMpointer()->FindSensitiveDetector(SensitiveDetectorName,
82 false))
83 {
84 // This G4MultiFunctionalDetector has already been registered to
85 // G4SDManager. Make sure this new primitive is registered as well.
87 aPS->GetName());
88 }
89 return true;
90}
91
93{
94 auto pr = std::find(primitives.begin(), primitives.end(), aPS);
95 if(pr != primitives.end())
96 {
97 primitives.erase(pr);
98 aPS->SetMultiFunctionalDetector(nullptr);
99 return true;
100 }
101 G4cerr << "Primitive <" << aPS->GetName() << "> is not defined in <"
102 << SensitiveDetectorName << ">." << G4endl
103 << "Method RemovePrimitive() is ignored." << G4endl;
104 return false;
105}
106
108{
109 for(auto pr : primitives)
110 {
111 pr->Initialize(HC);
112 }
113}
114
116{
117 for(auto pr : primitives)
118 {
119 pr->EndOfEvent(HC);
120 }
121}
122
124{
125 for(auto pr : primitives)
126 {
127 pr->clear();
128 }
129}
130
132{
133 for(auto pr : primitives)
134 {
135 pr->DrawAll();
136 }
137}
138
140{
141 for(auto pr : primitives)
142 {
143 pr->PrintAll();
144 }
145}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
bool G4bool
Definition: G4Types.hh:86
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition: G4ios.hh:57
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
virtual void Initialize(G4HCofThisEvent *)
virtual void EndOfEvent(G4HCofThisEvent *)
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
std::vector< G4VPrimitiveScorer * > primitives
G4bool RemovePrimitive(G4VPrimitiveScorer *)
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:38
void AddNewCollection(G4String SDname, G4String DCname)
Definition: G4SDManager.cc:94
Definition: G4Step.hh:62
G4double GetStepLength() const
G4double GetTotalEnergyDeposit() const
void SetMultiFunctionalDetector(G4MultiFunctionalDetector *d)
G4String GetName() const
G4CollectionNameVector collectionName