ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4MultiSensitiveDetector.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4MultiSensitiveDetector.cc
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 
41  : G4VSensitiveDetector(name)
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 
56 : G4VSensitiveDetector(rhs) ,
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));
67  G4VSensitiveDetector::operator=(static_cast<const G4VSensitiveDetector&>(rhs));
69  }
70  return *this;
71 }
72 
73 void
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 
81 void
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 
89 void
91 {
92  for ( auto sd : fSensitiveDetectors ) sd->clear();
93 }
94 
95 void
97 {
98  for ( auto sd : fSensitiveDetectors ) sd->DrawAll();
99 }
100 
101 void
103 {
104  for ( auto sd : fSensitiveDetectors ) sd->PrintAll();
105 }
106 
107 G4bool
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 }