Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
H02MuonSD.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 //
28 //
29 // ====================================================================
30 //
31 // H02MuonSD.cc
32 // $Id$
33 //
34 // ====================================================================
35 
36 #include "H02MuonSD.hh"
37 #include "H02MuonHit.hh"
38 #include "G4HCofThisEvent.hh"
39 #include "G4TouchableHistory.hh"
40 #include "G4VPhysicalVolume.hh"
41 #include "G4Track.hh"
42 #include "G4Step.hh"
43 #include "G4ios.hh"
44 
47  : G4VSensitiveDetector(name)
49 {
50  G4String HCname;
51  collectionName.insert("muonHit");
52 }
53 
57 {
58 }
59 
63 {
64  static int HCID=-1;
65  hitCollection= new H02MuonHitsCollection(SensitiveDetectorName,
66  collectionName[0]);
67  if(HCID<0) HCID= GetCollectionID(0);
68  HCE-> AddHitsCollection(HCID, hitCollection);
69 }
70 
74 {
75  G4ParticleDefinition* particle= astep-> GetTrack()-> GetDefinition();
76  if(particle-> GetPDGCharge() == 0.) return false;
77 
78  G4StepPoint* prestep= astep-> GetPreStepPoint();
79 
80  if(prestep-> GetStepStatus() != fGeomBoundary) return false;
81 
82  G4ThreeVector vmom= prestep-> GetMomentum();
83  G4ThreeVector vpos= prestep-> GetPosition();
84  G4double tof= prestep-> GetGlobalTime();
85 
86  G4VPhysicalVolume* volume= prestep-> GetPhysicalVolume();
87  G4int id= volume-> GetCopyNo();
88  if(volume-> GetName() == "ENDCAP_MUON_PV") id +=10;
89 
90  H02MuonHit* aHit=
91  new H02MuonHit(id, particle-> GetParticleName(), vmom, vpos, tof);
92  hitCollection-> insert(aHit);
93  return true;
94 
95 }
96 
100 {
101 }
102 
106 {
107 }
108 
112 {
113 }
114 
118 {
119  G4int nHit= hitCollection-> entries();
120  G4cout << "------------------------------------------" << G4endl
121  << "*** Muon System Hit (#hits=" << nHit << ")" << G4endl;
122  hitCollection-> PrintAllHits();
123 }
124