Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 94771 2015-12-09 09:44:05Z gcosmo $
28 //
29 
30 #include "G4VReadOutGeometry.hh"
31 #include "G4Navigator.hh"
32 
33 
35  :ROworld(nullptr),fincludeList(nullptr),
36  fexcludeList(nullptr),touchableHistory(nullptr)
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 = nullptr;
53  fexcludeList = nullptr;
54  name = right.name;
55  ROworld = right.ROworld;
56  touchableHistory = nullptr;
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(nullptr),fincludeList(nullptr),
64  fexcludeList(nullptr),name(n),touchableHistory(nullptr)
65 {
66  ROnavigator = new G4Navigator();
68  ed<<"The concept and the functionality of Readout Geometry has been merged\n"
69  <<"into Parallel World. This G4VReadOutGeometry is kept for the sake of\n"
70  <<"not breaking the commonly-used interface in the sensitive detector class.\n"
71  <<"But this functionality of G4VReadOutGeometry class is no longer tested\n"
72  <<"and thus may not be working well. We strongly recommend our customers to\n"
73  <<"migrate to Parallel World scheme.";
74  G4Exception("G4VReadOutGeometry","DIGIHIT1001",JustWarning,ed);
75 }
76 
78 {
79  //if(ROworld) delete ROworld; //should we do ? will it delete the goem tree also ?
80  if(fincludeList) delete fincludeList;
81  if(fexcludeList) delete fexcludeList;
83  if(ROnavigator) delete ROnavigator;
84 }
85 
87 {
88  if ( this == &right ) return *this;
89  delete fincludeList; fincludeList = nullptr;
90  delete fexcludeList; fexcludeList = nullptr;
91  name = right.name;
92  ROworld = right.ROworld;
93  delete touchableHistory; touchableHistory = nullptr;
94  delete ROnavigator; ROnavigator = new G4Navigator();
95  return *this;
96 }
97 
99 { return (this == (G4VReadOutGeometry *) &right); }
100 
102 { return (this != (G4VReadOutGeometry *) &right); }
103 
105 {
106  ROworld = Build();
108 }
109 
111 {
112  ROhist = nullptr;
113  G4bool incFlg = true;
114  G4VPhysicalVolume* PV = currentStep->GetPreStepPoint()->GetPhysicalVolume();
115  if((fexcludeList)&&(fexcludeList->CheckPV(PV)))
116  { incFlg = false; }
117  else if ((fincludeList)&&(fincludeList->CheckPV(PV)))
118  { incFlg = true; }
119  else if((fexcludeList)&&(fexcludeList->CheckLV(PV->GetLogicalVolume())))
120  { incFlg = false; }
121  else if((fincludeList)&&(fincludeList->CheckLV(PV->GetLogicalVolume())))
122  { incFlg = true; }
123  if(!incFlg) return false;
124 
125  if(ROworld)
126  { incFlg = FindROTouchable(currentStep); }
127  if(incFlg)
128  { ROhist = touchableHistory; }
129  return incFlg;
130 }
131 
133 {
134  // Update G4TouchableHistory object (touchableHistory)
135  // using the parallel readout world (ROworld)
136  // Return false in case the current Step is outside of the
137  // sensitive volume of the readout world.
138 
139  // At first invokation, creates the touchable history. Note
140  // that default value (false) of Locate method is used.
141  // ---------> But the default Value is TRUE <-------------------- J.A.
142  if(!touchableHistory)
143  {
146  currentStep->GetPreStepPoint()->GetPosition(),
147  currentStep->GetPreStepPoint()->GetMomentumDirection(),
149  }
150  else
151  {
153  currentStep->GetPreStepPoint()->GetPosition(),
154  currentStep->GetPreStepPoint()->GetMomentumDirection(),
156  true);
157  }
158  // Can the above be improved by the use of an isotropic safety
159  // in order to avoid LocateGlobalPointAndUpdateTouchable
160  // at each Step ?
161  // Should require that an RO geometry is notified at the
162  // starting of a track to avoid possible confusion looking
163  // at the safety value only.
164 
165  // checks if volume is sensitive:
166  G4VPhysicalVolume* currentVolume = touchableHistory->GetVolume();
167  // checks first if a physical volume exists here:
168  if ( currentVolume )
169  {
170  return currentVolume->GetLogicalVolume()->
171  GetSensitiveDetector() != 0;
172  }
173  // no sensitive volume found: returns false
174  return false;
175 }
176 
const XML_Char * name
Definition: expat.h:151
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
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)