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 | // $Id: GFlashHitMaker.cc,v 1.7 2006/06/29 19:14:12 gunter Exp $ |
---|
27 | // GEANT4 tag $Name: geant4-09-03 $ |
---|
28 | // |
---|
29 | // |
---|
30 | // ------------------------------------------------------------ |
---|
31 | // GEANT 4 class implementation |
---|
32 | // |
---|
33 | // ---------------- GFlashHitMaker ---------------- |
---|
34 | // |
---|
35 | // Authors: E.Barberio & Joanna Weng |
---|
36 | // ------------------------------------------------------------ |
---|
37 | |
---|
38 | #include "G4ios.hh" |
---|
39 | #include "G4TransportationManager.hh" |
---|
40 | #include "G4VSensitiveDetector.hh" |
---|
41 | #include "G4TouchableHandle.hh" |
---|
42 | #include "G4VGFlashSensitiveDetector.hh" |
---|
43 | |
---|
44 | #include "GFlashHitMaker.hh" |
---|
45 | #include "G4GFlashSpot.hh" |
---|
46 | |
---|
47 | GFlashHitMaker::GFlashHitMaker() |
---|
48 | { |
---|
49 | fTouchableHandle = new G4TouchableHistory(); // talk to ?@@@ |
---|
50 | fpNavigator = new G4Navigator(); |
---|
51 | fNaviSetup = false; |
---|
52 | } |
---|
53 | |
---|
54 | GFlashHitMaker::~GFlashHitMaker() |
---|
55 | { |
---|
56 | delete fpNavigator; |
---|
57 | } |
---|
58 | |
---|
59 | void GFlashHitMaker::make(GFlashEnergySpot * aSpot, const G4FastTrack * aT) |
---|
60 | { |
---|
61 | // Locate the spot |
---|
62 | if (!fNaviSetup) |
---|
63 | { |
---|
64 | fpNavigator-> |
---|
65 | SetWorldVolume(G4TransportationManager::GetTransportationManager()-> |
---|
66 | GetNavigatorForTracking()->GetWorldVolume() ); |
---|
67 | fpNavigator-> |
---|
68 | LocateGlobalPointAndUpdateTouchable(aSpot->GetPosition(), |
---|
69 | fTouchableHandle(), false); |
---|
70 | fNaviSetup = true; |
---|
71 | } |
---|
72 | else |
---|
73 | { |
---|
74 | fpNavigator-> |
---|
75 | LocateGlobalPointAndUpdateTouchable(aSpot->GetPosition(), |
---|
76 | fTouchableHandle()); |
---|
77 | } |
---|
78 | |
---|
79 | //-------------------------------------- |
---|
80 | // Fills attribute of the G4Step needed |
---|
81 | // by our sensitive detector: |
---|
82 | //------------------------------------- |
---|
83 | // set spot information: |
---|
84 | G4GFlashSpot theSpot(aSpot, aT, fTouchableHandle); |
---|
85 | ///Navigator |
---|
86 | //-------------------------------------- |
---|
87 | // Produce Hits |
---|
88 | // call sensitive part: taken/adapted from the stepping: |
---|
89 | // Send G4Step information to Hit/Dig if the volume is sensitive |
---|
90 | //--------------G4TouchableHistory---------------------------------------- |
---|
91 | |
---|
92 | G4VPhysicalVolume* pCurrentVolume = fTouchableHandle()->GetVolume(); |
---|
93 | G4VSensitiveDetector* pSensitive; |
---|
94 | if( pCurrentVolume != 0 ) |
---|
95 | { |
---|
96 | pSensitive = pCurrentVolume->GetLogicalVolume()->GetSensitiveDetector(); |
---|
97 | G4VGFlashSensitiveDetector * gflashSensitive = |
---|
98 | dynamic_cast<G4VGFlashSensitiveDetector * > (pSensitive); |
---|
99 | if( gflashSensitive ) |
---|
100 | { |
---|
101 | gflashSensitive->Hit(&theSpot); |
---|
102 | } |
---|
103 | else if ( (!gflashSensitive ) && |
---|
104 | ( pSensitive ) && |
---|
105 | ( pCurrentVolume->GetLogicalVolume()->GetFastSimulationManager() ) |
---|
106 | ) // Using gflash without implementing the |
---|
107 | // gflashSensitive detector interface -> not allowed! |
---|
108 | |
---|
109 | { |
---|
110 | G4cerr << "ERROR - GFlashHitMaker::make()" << G4endl |
---|
111 | << " It is required to implement the "<< G4endl |
---|
112 | << " G4VGFlashSensitiveDetector interface in "<< G4endl |
---|
113 | << " addition to the usual SensitiveDetector class." |
---|
114 | << G4endl; |
---|
115 | G4Exception("GFlashHitMaker::make()", "InvalidSetup", FatalException, |
---|
116 | "G4VGFlashSensitiveDetector interface not implemented."); |
---|
117 | } |
---|
118 | } |
---|
119 | else |
---|
120 | { |
---|
121 | #ifdef GFLASH_DEBUG |
---|
122 | G4cout << "GFlashHitMaker::Out of volume "<< G4endl; |
---|
123 | #endif |
---|
124 | } |
---|
125 | } |
---|