Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4MultiSensitiveDetector.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// G4MultiSensitiveDetector
27
29#include "G4SDManager.hh"
30#include <sstream>
31
32//#define MSDDEBUG
33#ifdef MSDDEBUG
34# define DBG(msg) G4cout << msg << G4endl
35#else
36# define DBG(msg)
37#endif
38#define VDBG(vl, msg) \
39 if(vl <= verboseLevel) \
40 G4cout << msg << G4endl
41
44{
45#ifdef MSDDEBUG
46 verboseLevel = 3;
47#endif
48 VDBG(1, "Creating G4MultiSenstiveDetector with name: " << name);
49}
50
52{
53 VDBG(2, GetName() << " : Destructing G4MultiSensitiveDetector");
54 ClearSDs();
55}
56
58 const G4MultiSensitiveDetector& rhs)
60 , fSensitiveDetectors(rhs.fSensitiveDetectors)
61{
62 VDBG(3, GetName() << " : Copy constructor called.");
63}
64
66 const G4MultiSensitiveDetector& rhs)
67{
68 if(this != &rhs)
69 {
70 // G4VSensitiveDetector::operator=(static_cast<const
71 // G4VSensitiveDetector&>(rhs));
73 static_cast<const G4VSensitiveDetector&>(rhs));
74 fSensitiveDetectors = rhs.fSensitiveDetectors;
75 }
76 return *this;
77}
78
80{
81 // SDManager is resposnsible for calling this since the granular SDs
82 // are also registered
83 // for ( auto sd : fSensitiveDetectors ) sd->Initialize(hcte);
84}
85
87{
88 // SDManager is resposnsible for calling this since the granular SDs
89 // are also registered
90 // for ( auto sd : fSensitiveDetectors ) sd->EndOfEvent(hcte);
91}
92
94{
95 for(auto sd : fSensitiveDetectors)
96 sd->clear();
97}
98
100{
101 for(auto sd : fSensitiveDetectors)
102 sd->DrawAll();
103}
104
106{
107 for(auto sd : fSensitiveDetectors)
108 sd->PrintAll();
109}
110
112{
113 VDBG(2, GetName() << " : Called processHits: " << aStep
114 << " with Edep: " << aStep->GetTotalEnergyDeposit());
115 G4bool result = true;
116 for(auto sd : fSensitiveDetectors)
117 result &= sd->Hit(aStep);
118 return result;
119}
120
122{
124 msg << GetName()
125 << " : This method cannot be called for an instance of type "
126 "G4MultiSensitiveDetector."
127 << " First retrieve a contained G4VSensitiveDetector with. i.e. GetSD "
128 "and then "
129 << " call this method.";
130 G4Exception("G4MultiSensitiveDetector::GetCollectionID", "Det0011",
131 FatalException, msg);
132 return -1;
133}
134
135// This method requires all contained SD to be clonable
137{
138 VDBG(2, GetName() << "Cloning an instance of G4MultiSensitiveDetector");
139 G4MultiSensitiveDetector* newInst =
141 for(auto sd : fSensitiveDetectors)
142 newInst->AddSD(sd->Clone());
143 return newInst;
144}
@ 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 VDBG(vl, msg)
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4MultiSensitiveDetector & operator=(const G4MultiSensitiveDetector &rhs)
virtual G4int GetCollectionID(G4int i) final
void AddSD(G4VSensitiveDetector *sd)
virtual void Initialize(G4HCofThisEvent *)
virtual void EndOfEvent(G4HCofThisEvent *)
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
virtual G4VSensitiveDetector * Clone() const
Definition: G4Step.hh:62
G4double GetTotalEnergyDeposit() const
G4VSensitiveDetector & operator=(const G4VSensitiveDetector &right)