Geant4  10.02.p01
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 <sstream>
30 
31 //#define MSDDEBUG
32 #ifdef MSDDEBUG
33 #define DBG( msg ) G4cout<<msg<<G4endl
34 #else
35 #define DBG( msg )
36 #endif
37 #define VDBG( vl , msg ) if ( vl<=verboseLevel ) G4cout<<msg<<G4endl
38 
40  : G4VSensitiveDetector(name)
41 {
42 #ifdef MSDDEBUG
43  verboseLevel = 3;
44 #endif
45  VDBG(1,"Creating G4MultiSenstiveDetector with name: "<<name);
46 }
47 
49 {
50  VDBG(2,GetName()<<" : Destructing G4MultiSensitiveDetector");
51  ClearSDs();
52 }
53 
55 : G4VSensitiveDetector(rhs) ,
56  fSensitiveDetectors(rhs.fSensitiveDetectors)
57 {
58  VDBG(3,GetName()<<" : Copy constructor called.");
59 }
60 
63 {
64  if ( this != &rhs ) {
65  //G4VSensitiveDetector::operator=(static_cast<const G4VSensitiveDetector&>(rhs));
66  G4VSensitiveDetector::operator=(static_cast<const G4VSensitiveDetector&>(rhs));
68  }
69  return *this;
70 }
71 
72 void
74 {
75  //SDManager is resposnsible for calling this since the granular SDs
76  // are also registered
77  //for ( auto sd : fSensitiveDetectors ) sd->Initialize(hcte);
78 }
79 
80 void
82 {
83  //SDManager is resposnsible for calling this since the granular SDs
84 // are also registered
85  //for ( auto sd : fSensitiveDetectors ) sd->EndOfEvent(hcte);
86 }
87 
88 void
90 {
91  for ( auto sd : fSensitiveDetectors ) sd->clear();
92 }
93 
94 void
96 {
97  for ( auto sd : fSensitiveDetectors ) sd->DrawAll();
98 }
99 
100 void
102 {
103  for ( auto sd : fSensitiveDetectors ) sd->PrintAll();
104 }
105 
106 G4bool
108 {
109  VDBG(2,GetName()<<" : Called processHits: "<<aStep<<" with Edep: "<<aStep->GetTotalEnergyDeposit());
110  G4bool result = true;
111  for (auto sd : fSensitiveDetectors )
112  result &= sd->Hit(aStep);
113  return result;
114 }
115 
117 {
119  msg << GetName()<<" : This method cannot be called for an instance of type G4MultiSensitiveDetector."
120  << " First retrieve a contained G4VSensitiveDetector with. i.e. GetSD and then "
121  << " call this method.";
122  G4Exception("G4MultiSensitiveDetector::GetCollectionID","Det0011",FatalException,msg);
123  return -1;
124 }
125 
126 //This method requires all contained SD to be clonable
128 {
129  VDBG(2,GetName()<<"Cloning an instance of G4MultiSensitiveDetector");
131  for ( auto sd : fSensitiveDetectors )
132  newInst->AddSD( sd->Clone() );
133  return newInst;
134 }
135 
virtual G4int GetCollectionID(G4int i) final
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String name
Definition: TRTMaterials.hh:40
virtual G4VSensitiveDetector * Clone() const
virtual void Initialize(G4HCofThisEvent *)
virtual void EndOfEvent(G4HCofThisEvent *)
void AddSD(G4VSensitiveDetector *sd)
int G4int
Definition: G4Types.hh:78
virtual G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
bool G4bool
Definition: G4Types.hh:79
Definition: G4Step.hh:76
G4double GetTotalEnergyDeposit() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4VSensitiveDetector & operator=(const G4VSensitiveDetector &right)
G4MultiSensitiveDetector & operator=(const G4MultiSensitiveDetector &rhs)
#define VDBG(vl, msg)