Geant4 10.7.0
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 ) if ( vl<=verboseLevel ) G4cout<<msg<<G4endl
39
42{
43#ifdef MSDDEBUG
44 verboseLevel = 3;
45#endif
46 VDBG(1,"Creating G4MultiSenstiveDetector with name: "<<name);
47}
48
50{
51 VDBG(2,GetName()<<" : Destructing G4MultiSensitiveDetector");
52 ClearSDs();
53}
54
57 fSensitiveDetectors(rhs.fSensitiveDetectors)
58{
59 VDBG(3,GetName()<<" : Copy constructor called.");
60}
61
64{
65 if ( this != &rhs ) {
66 //G4VSensitiveDetector::operator=(static_cast<const G4VSensitiveDetector&>(rhs));
68 fSensitiveDetectors = rhs.fSensitiveDetectors;
69 }
70 return *this;
71}
72
73void
75{
76 //SDManager is resposnsible for calling this since the granular SDs
77 // are also registered
78 //for ( auto sd : fSensitiveDetectors ) sd->Initialize(hcte);
79}
80
81void
83{
84 //SDManager is resposnsible for calling this since the granular SDs
85// are also registered
86 //for ( auto sd : fSensitiveDetectors ) sd->EndOfEvent(hcte);
87}
88
89void
91{
92 for ( auto sd : fSensitiveDetectors ) sd->clear();
93}
94
95void
97{
98 for ( auto sd : fSensitiveDetectors ) sd->DrawAll();
99}
100
101void
103{
104 for ( auto sd : fSensitiveDetectors ) sd->PrintAll();
105}
106
107G4bool
109{
110 VDBG(2,GetName()<<" : Called processHits: "<<aStep<<" with Edep: "<<aStep->GetTotalEnergyDeposit());
111 G4bool result = true;
112 for (auto sd : fSensitiveDetectors )
113 result &= sd->Hit(aStep);
114 return result;
115}
116
118{
120 msg << GetName()<<" : This method cannot be called for an instance of type G4MultiSensitiveDetector."
121 << " First retrieve a contained G4VSensitiveDetector with. i.e. GetSD and then "
122 << " call this method.";
123 G4Exception("G4MultiSensitiveDetector::GetCollectionID","Det0011",FatalException,msg);
124 return -1;
125}
126
127//This method requires all contained SD to be clonable
129{
130 VDBG(2,GetName()<<"Cloning an instance of G4MultiSensitiveDetector");
132 for ( auto sd : fSensitiveDetectors )
133 newInst->AddSD( sd->Clone() );
134 return newInst;
135}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
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)