Geant4  10.02.p01
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 // $Id: G4MultiFunctionalDetector.cc 67992 2013-03-13 10:59:57Z gcosmo $
28 //
29 // G4MultiFunctionalDetector
30 //
31 // 2010-07-23 T.Aso Call PS if the step length or energy deposit is not zero.
32 //
33 //
35 #include "G4SDManager.hh"
36 #include "G4VPrimitiveScorer.hh"
37 
40 {;}
41 
43 {;}
44 
46 {
47  if(aStep->GetStepLength()>0. || aStep->GetTotalEnergyDeposit()>0.){
48  G4int nPrim = primitives.size();
49  for(G4int iPrim=0;iPrim<nPrim;iPrim++)
50  {
51  primitives[iPrim]->HitPrimitive(aStep,aTH);
52  }
53  }
54  return true;
55 }
56 
58 {
59  G4int nPrim = primitives.size();
60  for(G4int iPrim=0;iPrim<nPrim;iPrim++)
61  {
62  if(primitives[iPrim]==aPS)
63  {
65  ED << "Primitive <" << aPS->GetName() << "> is already defined in <" << SensitiveDetectorName
66  << ">." << G4endl << "Method RegisterPrimitive() is ignored." << G4endl;
67  G4Exception("G4MultiFunctionalDetector::RegisterPrimitive","Det0101",
68  JustWarning,ED);
69  return false;
70  }
71  }
72  primitives.push_back(aPS);
73  aPS->SetMultiFunctionalDetector(this);
76  {
77  // This G4MultiFunctionalDetector has already been registered to G4SDManager.
78  // Make sure this new primitive is registered as well.
80  }
81  return true;
82 }
83 
85 {
86  std::vector<G4VPrimitiveScorer*>::iterator iterPS;
87  std::vector<G4String>::iterator iterName = collectionName.begin();
88  for(iterPS=primitives.begin();iterPS!=primitives.end();iterPS++)
89  {
90  if(*iterPS==aPS)
91  {
92  primitives.erase(iterPS);
94  return true;
95  }
96  iterName++;
97  }
98  G4cerr << "Primitive <" << aPS->GetName() << "> is not defined in <" << SensitiveDetectorName
99  << ">." << G4endl << "Method RemovePrimitive() is ignored." << G4endl;
100  return false;
101 }
102 
104 {
105  G4int nPrim = primitives.size();
106  for(G4int iPrim=0;iPrim<nPrim;iPrim++)
107  { primitives[iPrim]->Initialize(HC); }
108 }
109 
111 {
112  G4int nPrim = primitives.size();
113  for(G4int iPrim=0;iPrim<nPrim;iPrim++)
114  { primitives[iPrim]->EndOfEvent(HC); }
115 }
116 
118 {
119  G4int nPrim = primitives.size();
120  for(G4int iPrim=0;iPrim<nPrim;iPrim++)
121  { primitives[iPrim]->clear(); }
122 }
123 
125 {
126  G4int nPrim = primitives.size();
127  for(G4int iPrim=0;iPrim<nPrim;iPrim++)
128  { primitives[iPrim]->DrawAll(); }
129 }
130 
132 {
133  G4int nPrim = primitives.size();
134  for(G4int iPrim=0;iPrim<nPrim;iPrim++)
135  { primitives[iPrim]->PrintAll(); }
136 }
137 
G4bool RegisterPrimitive(G4VPrimitiveScorer *)
void AddNewCollection(G4String SDname, G4String DCname)
Definition: G4SDManager.cc:88
G4String GetName() const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetStepLength() const
virtual void Initialize(G4HCofThisEvent *)
G4String name
Definition: TRTMaterials.hh:40
int G4int
Definition: G4Types.hh:78
std::vector< G4VPrimitiveScorer * > primitives
bool G4bool
Definition: G4Types.hh:79
Definition: G4Step.hh:76
G4VSensitiveDetector * FindSensitiveDetector(G4String dName, G4bool warning=true)
Definition: G4SDManager.cc:124
G4double GetTotalEnergyDeposit() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
virtual G4bool ProcessHits(G4Step *, G4TouchableHistory *)
void SetMultiFunctionalDetector(G4MultiFunctionalDetector *d)
virtual void EndOfEvent(G4HCofThisEvent *)
G4CollectionNameVector collectionName
G4bool RemovePrimitive(G4VPrimitiveScorer *)
G4GLOB_DLL std::ostream G4cerr