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 | // FredSensMother.cc |
---|
28 | // |
---|
29 | // Implementation of our sensitive mother volume |
---|
30 | // |
---|
31 | |
---|
32 | #include "FredSensMother.hh" |
---|
33 | #include "G4StepStatus.hh" |
---|
34 | |
---|
35 | // |
---|
36 | // Constructor |
---|
37 | // |
---|
38 | FredSensMother::FredSensMother( G4String name ) : G4VSensitiveDetector( name ) |
---|
39 | { |
---|
40 | // |
---|
41 | // Now we play the c++ guessing game: which inherited |
---|
42 | // parameters do we fill? Should be obvious, but, |
---|
43 | // the only clue I got was in the examples. |
---|
44 | // |
---|
45 | // IMHO: it would be |
---|
46 | // better to have an inherited class with more arguments |
---|
47 | // whose constructor is explicitly invoked here. |
---|
48 | // Then there would be no ambiguities. |
---|
49 | // |
---|
50 | collectionName.insert( "fredsMotherStuff" ); |
---|
51 | } |
---|
52 | |
---|
53 | // |
---|
54 | // Destructor |
---|
55 | // |
---|
56 | // Odd we don't bother deleting the hits here... shouldn't we? |
---|
57 | // Perhaps it doesn't matter, since G4 is pretty much static when |
---|
58 | // it comes to detector configuration. But, we're all c++ experts, |
---|
59 | // so we need to go through the moves. |
---|
60 | // |
---|
61 | FredSensMother::~FredSensMother() {;} |
---|
62 | |
---|
63 | // |
---|
64 | // Initialize |
---|
65 | // |
---|
66 | // Despite the misnomer, this is done at the beginning of each event. |
---|
67 | // HCE is a meta-list of hit collections where one is allowed to store |
---|
68 | // stuff. I'm not sure why you are forced to do this. |
---|
69 | // |
---|
70 | void FredSensMother::Initialize( G4HCofThisEvent *HCE ) |
---|
71 | { |
---|
72 | hits = new FredHitCollection( SensitiveDetectorName, collectionName[0] ); |
---|
73 | |
---|
74 | static int HCID = -1; |
---|
75 | if (HCID < 0) HCID = GetCollectionID(0); |
---|
76 | HCE->AddHitsCollection( HCID, hits ); |
---|
77 | } |
---|
78 | |
---|
79 | // |
---|
80 | // ProcessHits |
---|
81 | // |
---|
82 | // Another misnomer: this member function processes one step in the |
---|
83 | // sensitive volume. |
---|
84 | // |
---|
85 | // IMHO: the fact that a argument is delivered which I don't need |
---|
86 | // is not good design. |
---|
87 | // |
---|
88 | G4bool FredSensMother::ProcessHits( G4Step *step, G4TouchableHistory * ) |
---|
89 | { |
---|
90 | G4bool imHit = false; |
---|
91 | |
---|
92 | // |
---|
93 | // Okay, for test purposes, I want to store hits that just |
---|
94 | // started. |
---|
95 | // |
---|
96 | if (step->GetPreStepPoint()->GetGlobalTime() == 0.0) { |
---|
97 | FredHit *hit = new FredHit( step->GetPreStepPoint()->GetPosition(), true, step->GetTrack() ); |
---|
98 | hits->insert( hit ); |
---|
99 | imHit = true; |
---|
100 | } |
---|
101 | |
---|
102 | return imHit; |
---|
103 | } |
---|
104 | |
---|