source: trunk/source/digits_hits/detector/src/G4MultiFunctionalDetector.cc@ 1343

Last change on this file since 1343 was 1340, checked in by garnier, 15 years ago

update ti head

File size: 4.7 KB
Line 
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,v 1.6 2010/07/23 02:07:23 taso Exp $
28// GEANT4 tag $Name: $
29//
30// G4MultiFunctionalDetector
31//
32// 2010-07-23 T.Aso Call PS if the step length or energy deposit is not zero.
33//
34//
35#include "G4MultiFunctionalDetector.hh"
36#include "G4SDManager.hh"
37#include "G4VPrimitiveScorer.hh"
38
39G4MultiFunctionalDetector::G4MultiFunctionalDetector(G4String name)
40:G4VSensitiveDetector(name)
41{;}
42
43G4MultiFunctionalDetector::~G4MultiFunctionalDetector()
44{;}
45
46G4bool G4MultiFunctionalDetector::ProcessHits(G4Step* aStep,G4TouchableHistory* aTH)
47{
48 if(aStep->GetStepLength()>0. || aStep->GetTotalEnergyDeposit()>0.){
49 G4int nPrim = primitives.size();
50 for(G4int iPrim=0;iPrim<nPrim;iPrim++)
51 {
52 primitives[iPrim]->HitPrimitive(aStep,aTH);
53 }
54 }
55 return true;
56}
57
58G4bool G4MultiFunctionalDetector::RegisterPrimitive(G4VPrimitiveScorer* aPS)
59{
60 G4int nPrim = primitives.size();
61 for(G4int iPrim=0;iPrim<nPrim;iPrim++)
62 {
63 if(primitives[iPrim]==aPS)
64 {
65 G4cerr << "Primitive <" << aPS->GetName() << "> is already defined in <" << SensitiveDetectorName
66 << ">." << G4endl << "Method RegisterPrimitive() is ignored." << G4endl;
67 return false;
68 }
69 }
70 primitives.push_back(aPS);
71 aPS->SetMultiFunctionalDetector(this);
72 collectionName.insert(aPS->GetName());
73 if(G4SDManager::GetSDMpointer()->FindSensitiveDetector(SensitiveDetectorName,false))
74 {
75 // This G4MultiFunctionalDetector has already been registered to G4SDManager.
76 // Make sure this new primitive is registered as well.
77 G4SDManager::GetSDMpointer()->AddNewCollection(SensitiveDetectorName,aPS->GetName());
78 }
79 return true;
80}
81
82G4bool G4MultiFunctionalDetector::RemovePrimitive(G4VPrimitiveScorer* aPS)
83{
84 std::vector<G4VPrimitiveScorer*>::iterator iterPS;
85 std::vector<G4String>::iterator iterName = collectionName.begin();
86 for(iterPS=primitives.begin();iterPS!=primitives.end();iterPS++)
87 {
88 if(*iterPS==aPS)
89 {
90 primitives.erase(iterPS);
91 aPS->SetMultiFunctionalDetector(0);
92 return true;
93 }
94 iterName++;
95 }
96 G4cerr << "Primitive <" << aPS->GetName() << "> is not defined in <" << SensitiveDetectorName
97 << ">." << G4endl << "Method RemovePrimitive() is ignored." << G4endl;
98 return false;
99}
100
101void G4MultiFunctionalDetector::Initialize(G4HCofThisEvent* HC)
102{
103 G4int nPrim = primitives.size();
104 for(G4int iPrim=0;iPrim<nPrim;iPrim++)
105 { primitives[iPrim]->Initialize(HC); }
106}
107
108void G4MultiFunctionalDetector::EndOfEvent(G4HCofThisEvent* HC)
109{
110 G4int nPrim = primitives.size();
111 for(G4int iPrim=0;iPrim<nPrim;iPrim++)
112 { primitives[iPrim]->EndOfEvent(HC); }
113}
114
115void G4MultiFunctionalDetector::clear()
116{
117 G4int nPrim = primitives.size();
118 for(G4int iPrim=0;iPrim<nPrim;iPrim++)
119 { primitives[iPrim]->clear(); }
120}
121
122void G4MultiFunctionalDetector::DrawAll()
123{
124 G4int nPrim = primitives.size();
125 for(G4int iPrim=0;iPrim<nPrim;iPrim++)
126 { primitives[iPrim]->DrawAll(); }
127}
128
129void G4MultiFunctionalDetector::PrintAll()
130{
131 G4int nPrim = primitives.size();
132 for(G4int iPrim=0;iPrim<nPrim;iPrim++)
133 { primitives[iPrim]->PrintAll(); }
134}
135
Note: See TracBrowser for help on using the repository browser.