Geant4_10
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 74048 2013-09-20 09:34:57Z 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  delete fincludeList; fincludeList = 0;
81  delete fexcludeList; fexcludeList = 0;
82  name = right.name;
83  ROworld = right.ROworld;
85  delete ROnavigator; ROnavigator = new G4Navigator();
86  return *this;
87 }
88 
90 { return (this == (G4VReadOutGeometry *) &right); }
91 
93 { return (this != (G4VReadOutGeometry *) &right); }
94 
96 {
97  ROworld = Build();
99 }
100 
102 {
103  ROhist = 0;
104  G4bool incFlg = true;
105  G4VPhysicalVolume* PV = currentStep->GetPreStepPoint()->GetPhysicalVolume();
106  if((fexcludeList)&&(fexcludeList->CheckPV(PV)))
107  { incFlg = false; }
108  else if ((fincludeList)&&(fincludeList->CheckPV(PV)))
109  { incFlg = true; }
110  else if((fexcludeList)&&(fexcludeList->CheckLV(PV->GetLogicalVolume())))
111  { incFlg = false; }
112  else if((fincludeList)&&(fincludeList->CheckLV(PV->GetLogicalVolume())))
113  { incFlg = true; }
114  if(!incFlg) return false;
115 
116  if(ROworld)
117  { incFlg = FindROTouchable(currentStep); }
118  if(incFlg)
119  { ROhist = touchableHistory; }
120  return incFlg;
121 }
122 
124 {
125  // Update G4TouchableHistory object (touchableHistory)
126  // using the parallel readout world (ROworld)
127  // Return false in case the current Step is outside of the
128  // sensitive volume of the readout world.
129 
130  // At first invokation, creates the touchable history. Note
131  // that default value (false) of Locate method is used.
132  // ---------> But the default Value is TRUE <-------------------- J.A.
133  if(!touchableHistory)
134  {
137  currentStep->GetPreStepPoint()->GetPosition(),
138  currentStep->GetPreStepPoint()->GetMomentumDirection(),
140  }
141  else
142  {
144  currentStep->GetPreStepPoint()->GetPosition(),
145  currentStep->GetPreStepPoint()->GetMomentumDirection(),
147  true);
148  }
149  // Can the above be improved by the use of an isotropic safety
150  // in order to avoid LocateGlobalPointAndUpdateTouchable
151  // at each Step ?
152  // Should require that an RO geometry is notified at the
153  // starting of a track to avoid possible confusion looking
154  // at the safety value only.
155 
156  // checks if volume is sensitive:
157  G4VPhysicalVolume* currentVolume = touchableHistory->GetVolume();
158  // checks first if a physical volume exists here:
159  if ( currentVolume )
160  {
161  return currentVolume->GetLogicalVolume()->
162  GetSensitiveDetector() != 0;
163  }
164  // no sensitive volume found: returns false
165  return false;
166 }
167 
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
const XML_Char * name
Definition: expat.h:151
virtual G4bool FindROTouchable(G4Step *)
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
Char_t n[5]
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
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
const G4VReadOutGeometry & operator=(const G4VReadOutGeometry &right)