| 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 | // FredSensitive.cc
|
|---|
| 28 | //
|
|---|
| 29 | // Implementation of our sensitive test volume
|
|---|
| 30 | //
|
|---|
| 31 |
|
|---|
| 32 | #include "FredSensitive.hh"
|
|---|
| 33 | #include "G4StepStatus.hh"
|
|---|
| 34 |
|
|---|
| 35 | //
|
|---|
| 36 | // Constructor
|
|---|
| 37 | //
|
|---|
| 38 | FredSensitive::FredSensitive( 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( "fredsStuff" );
|
|---|
| 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 | FredSensitive::~FredSensitive() {;}
|
|---|
| 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.
|
|---|
| 69 | //
|
|---|
| 70 | void FredSensitive::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 | G4bool FredSensitive::ProcessHits( G4Step *step, G4TouchableHistory * )
|
|---|
| 86 | {
|
|---|
| 87 | G4bool imHit = false;
|
|---|
| 88 |
|
|---|
| 89 | //
|
|---|
| 90 | // Okay, for test purposes, I want to store hits that intersect
|
|---|
| 91 | // the boundary of the detector
|
|---|
| 92 | //
|
|---|
| 93 | if (step->GetPreStepPoint()->GetStepStatus() == fGeomBoundary) {
|
|---|
| 94 | FredHit *hit = new FredHit( step->GetPreStepPoint()->GetPosition(), true, step->GetTrack() );
|
|---|
| 95 | hits->insert( hit );
|
|---|
| 96 | imHit = true;
|
|---|
| 97 | }
|
|---|
| 98 | if (step->GetPostStepPoint()->GetStepStatus() == fGeomBoundary) {
|
|---|
| 99 | FredHit *hit = new FredHit( step->GetPostStepPoint()->GetPosition(), false, step->GetTrack() );
|
|---|
| 100 | hits->insert( hit );
|
|---|
| 101 | imHit = true;
|
|---|
| 102 | }
|
|---|
| 103 |
|
|---|
| 104 | return imHit;
|
|---|
| 105 | }
|
|---|
| 106 |
|
|---|