source: trunk/source/digits_hits/detector/src/G4VReadOutGeometry.cc@ 960

Last change on this file since 960 was 850, checked in by garnier, 17 years ago

geant4.8.2 beta

File size: 5.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: G4VReadOutGeometry.cc,v 1.2 2006/06/29 18:06:05 gunter Exp $
28// GEANT4 tag $Name: HEAD $
29//
30
31#include "G4VReadOutGeometry.hh"
32#include "G4Navigator.hh"
33
34
35G4VReadOutGeometry::G4VReadOutGeometry()
36 :ROworld(0),fincludeList(0),
37 fexcludeList(0),touchableHistory(0)
38{
39 name = "unknown";
40 ROnavigator = new G4Navigator();
41}
42
43G4VReadOutGeometry::G4VReadOutGeometry(const G4VReadOutGeometry &right)
44{
45 fincludeList = right.fincludeList;
46 fexcludeList = right.fexcludeList;
47 name = right.name;
48 ROworld = right.ROworld;
49 touchableHistory = 0;
50 // COPY CONSTRUCTOR NOT STRAIGHT FORWARD: need to copy the touchabelHistory
51 // VALUE, same foe navigator and same for the World+Geom hierachy ??
52}
53
54G4VReadOutGeometry::G4VReadOutGeometry(G4String n)
55 :ROworld(0),fincludeList(0),
56 fexcludeList(0),name(n),touchableHistory(0)
57{
58 ROnavigator = new G4Navigator();
59}
60
61G4VReadOutGeometry::~G4VReadOutGeometry()
62{
63 //if(ROworld) delete ROworld; //should we do ? will it delete the goem tree also ?
64 if(fincludeList) delete fincludeList;
65 if(fexcludeList) delete fexcludeList;
66 if(touchableHistory) delete touchableHistory;
67 if(ROnavigator) delete ROnavigator;
68}
69
70const G4VReadOutGeometry & G4VReadOutGeometry::operator=(const G4VReadOutGeometry &right)
71{
72 fincludeList = right.fincludeList;
73 fexcludeList = right.fexcludeList;
74 name = right.name;
75 ROworld = right.ROworld;
76 touchableHistory = 0;
77 return *this;
78}
79
80G4int G4VReadOutGeometry::operator==(const G4VReadOutGeometry &right) const
81{ return (this == (G4VReadOutGeometry *) &right); }
82
83G4int G4VReadOutGeometry::operator!=(const G4VReadOutGeometry &right) const
84{ return (this != (G4VReadOutGeometry *) &right); }
85
86void G4VReadOutGeometry::BuildROGeometry()
87{
88 ROworld = Build();
89 ROnavigator->SetWorldVolume(ROworld);
90}
91
92G4bool G4VReadOutGeometry::CheckROVolume(G4Step*currentStep,G4TouchableHistory*& ROhist)
93{
94 ROhist = 0;
95 G4bool incFlg = true;
96 G4VPhysicalVolume* PV = currentStep->GetPreStepPoint()->GetPhysicalVolume();
97 if((fexcludeList)&&(fexcludeList->CheckPV(PV)))
98 { incFlg = false; }
99 else if ((fincludeList)&&(fincludeList->CheckPV(PV)))
100 { incFlg = true; }
101 else if((fexcludeList)&&(fexcludeList->CheckLV(PV->GetLogicalVolume())))
102 { incFlg = false; }
103 else if((fincludeList)&&(fincludeList->CheckLV(PV->GetLogicalVolume())))
104 { incFlg = true; }
105 if(!incFlg) return false;
106
107 if(ROworld)
108 { incFlg = FindROTouchable(currentStep); }
109 if(incFlg)
110 { ROhist = touchableHistory; }
111 return incFlg;
112}
113
114G4bool G4VReadOutGeometry::FindROTouchable(G4Step*currentStep)
115{
116 // Update G4TouchableHistory object (touchableHistory)
117 // using the parallel readout world (ROworld)
118 // Return false in case the current Step is outside of the
119 // sensitive volume of the readout world.
120
121 // At first invokation, creates the touchable history. Note
122 // that default value (false) of Locate method is used.
123 // ---------> But the default Value is TRUE <-------------------- J.A.
124 if(!touchableHistory)
125 {
126 touchableHistory = new G4TouchableHistory();
127 ROnavigator->LocateGlobalPointAndUpdateTouchable(
128 currentStep->GetPreStepPoint()->GetPosition(),
129 currentStep->GetPreStepPoint()->GetMomentumDirection(),
130 touchableHistory);
131 }
132 else
133 {
134 ROnavigator->LocateGlobalPointAndUpdateTouchable(
135 currentStep->GetPreStepPoint()->GetPosition(),
136 currentStep->GetPreStepPoint()->GetMomentumDirection(),
137 touchableHistory,
138 true);
139 }
140 // Can the above be improved by the use of an isotropic safety
141 // in order to avoid LocateGlobalPointAndUpdateTouchable
142 // at each Step ?
143 // Should require that an RO geometry is notified at the
144 // starting of a track to avoid possible confusion looking
145 // at the safety value only.
146
147 // checks if volume is sensitive:
148 G4VPhysicalVolume* currentVolume = touchableHistory->GetVolume();
149 // checks first if a physical volume exists here:
150 if ( currentVolume )
151 {
152 return currentVolume->GetLogicalVolume()->
153 GetSensitiveDetector() != 0;
154 }
155 // no sensitive volume found: returns false
156 return false;
157}
158
Note: See TracBrowser for help on using the repository browser.