Geant4  10.01.p03
G4VReadOutGeometry.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 //
26 //
27 // $Id: G4VReadOutGeometry.cc 81087 2014-05-20 15:44:27Z gcosmo $
28 //
29 
30 #include "G4VReadOutGeometry.hh"
31 #include "G4Navigator.hh"
32 
33 
35  :ROworld(0),fincludeList(0),
36  fexcludeList(0),touchableHistory(0)
37 {
38  name = "unknown";
39  ROnavigator = new G4Navigator();
41  ed<<"The concept and the functionality of Readout Geometry has been merged\n"
42  <<"into Parallel World. This G4VReadOutGeometry is kept for the sake of\n"
43  <<"not breaking the commonly-used interface in the sensitive detector class.\n"
44  <<"But this functionality of G4VReadOutGeometry class is no longer tested\n"
45  <<"and thus may not be working well. We strongly recommend our customers to\n"
46  <<"migrate to Parallel World scheme.";
47  G4Exception("G4VReadOutGeometry","DIGIHIT1001",JustWarning,ed);
48 }
49 
51 {
52  fincludeList = 0;
53  fexcludeList = 0;
54  name = right.name;
55  ROworld = right.ROworld;
56  touchableHistory = 0;
57  ROnavigator = new G4Navigator();
58  // COPY CONSTRUCTOR NOT STRAIGHT FORWARD: need to copy the touchabelHistory
59  // VALUE, same for navigator and same for the World+Geom hierachy
60 }
61 
63  :ROworld(0),fincludeList(0),
64  fexcludeList(0),name(n),touchableHistory(0)
65 {
66  ROnavigator = new G4Navigator();
67 }
68 
70 {
71  //if(ROworld) delete ROworld; //should we do ? will it delete the goem tree also ?
72  if(fincludeList) delete fincludeList;
73  if(fexcludeList) delete fexcludeList;
75  if(ROnavigator) delete ROnavigator;
76 }
77 
79 {
80  if ( this == &right ) return *this;
81  delete fincludeList; fincludeList = 0;
82  delete fexcludeList; fexcludeList = 0;
83  name = right.name;
84  ROworld = right.ROworld;
86  delete ROnavigator; ROnavigator = new G4Navigator();
87  return *this;
88 }
89 
91 { return (this == (G4VReadOutGeometry *) &right); }
92 
94 { return (this != (G4VReadOutGeometry *) &right); }
95 
97 {
98  ROworld = Build();
100 }
101 
103 {
104  ROhist = 0;
105  G4bool incFlg = true;
106  G4VPhysicalVolume* PV = currentStep->GetPreStepPoint()->GetPhysicalVolume();
107  if((fexcludeList)&&(fexcludeList->CheckPV(PV)))
108  { incFlg = false; }
109  else if ((fincludeList)&&(fincludeList->CheckPV(PV)))
110  { incFlg = true; }
111  else if((fexcludeList)&&(fexcludeList->CheckLV(PV->GetLogicalVolume())))
112  { incFlg = false; }
113  else if((fincludeList)&&(fincludeList->CheckLV(PV->GetLogicalVolume())))
114  { incFlg = true; }
115  if(!incFlg) return false;
116 
117  if(ROworld)
118  { incFlg = FindROTouchable(currentStep); }
119  if(incFlg)
120  { ROhist = touchableHistory; }
121  return incFlg;
122 }
123 
125 {
126  // Update G4TouchableHistory object (touchableHistory)
127  // using the parallel readout world (ROworld)
128  // Return false in case the current Step is outside of the
129  // sensitive volume of the readout world.
130 
131  // At first invokation, creates the touchable history. Note
132  // that default value (false) of Locate method is used.
133  // ---------> But the default Value is TRUE <-------------------- J.A.
134  if(!touchableHistory)
135  {
138  currentStep->GetPreStepPoint()->GetPosition(),
139  currentStep->GetPreStepPoint()->GetMomentumDirection(),
141  }
142  else
143  {
145  currentStep->GetPreStepPoint()->GetPosition(),
146  currentStep->GetPreStepPoint()->GetMomentumDirection(),
148  true);
149  }
150  // Can the above be improved by the use of an isotropic safety
151  // in order to avoid LocateGlobalPointAndUpdateTouchable
152  // at each Step ?
153  // Should require that an RO geometry is notified at the
154  // starting of a track to avoid possible confusion looking
155  // at the safety value only.
156 
157  // checks if volume is sensitive:
158  G4VPhysicalVolume* currentVolume = touchableHistory->GetVolume();
159  // checks first if a physical volume exists here:
160  if ( currentVolume )
161  {
162  return currentVolume->GetLogicalVolume()->
163  GetSensitiveDetector() != 0;
164  }
165  // no sensitive volume found: returns false
166  return false;
167 }
168 
G4bool CheckPV(const G4VPhysicalVolume *pvp) const
G4int operator!=(const G4VReadOutGeometry &right) const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4VPhysicalVolume * GetVolume(G4int depth=0) const
G4Navigator * ROnavigator
G4SensitiveVolumeList * fincludeList
G4String name
Definition: TRTMaterials.hh:40
G4VPhysicalVolume * ROworld
virtual G4bool FindROTouchable(G4Step *)
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
const G4ThreeVector & GetMomentumDirection() const
G4VPhysicalVolume * GetPhysicalVolume() const
const G4ThreeVector & GetPosition() const
void LocateGlobalPointAndUpdateTouchable(const G4ThreeVector &position, const G4ThreeVector &direction, G4VTouchable *touchableToUpdate, const G4bool RelativeSearch=true)
bool G4bool
Definition: G4Types.hh:79
virtual G4VPhysicalVolume * Build()=0
Definition: G4Step.hh:76
const G4int n
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual G4bool CheckROVolume(G4Step *, G4TouchableHistory *&)
G4LogicalVolume * GetLogicalVolume() const
G4TouchableHistory * touchableHistory
G4int operator==(const G4VReadOutGeometry &right) const
void SetWorldVolume(G4VPhysicalVolume *pWorld)
G4SensitiveVolumeList * fexcludeList
G4bool CheckLV(const G4LogicalVolume *lvp) const
G4VReadOutGeometry & operator=(const G4VReadOutGeometry &right)