Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // 27 // 28 28 29 #include "G4VReadOutGeometry.hh" 29 #include "G4VReadOutGeometry.hh" 30 << 31 #include "G4Navigator.hh" 30 #include "G4Navigator.hh" 32 31 33 G4VReadOutGeometry::G4VReadOutGeometry() 32 G4VReadOutGeometry::G4VReadOutGeometry() 34 : ROworld(nullptr), fincludeList(nullptr), f << 33 : ROworld(nullptr) >> 34 , fincludeList(nullptr) >> 35 , fexcludeList(nullptr) >> 36 , touchableHistory(nullptr) 35 { 37 { 36 name = "unknown"; << 38 name = "unknown"; 37 ROnavigator = new G4Navigator(); 39 ROnavigator = new G4Navigator(); 38 G4ExceptionDescription ed; 40 G4ExceptionDescription ed; 39 ed << "The concept and the functionality of << 41 ed 40 << "into Parallel World. This G4VReadOutG << 42 << "The concept and the functionality of Readout Geometry has been merged\n" 41 << "not breaking the commonly-used interf << 43 << "into Parallel World. This G4VReadOutGeometry is kept for the sake of\n" 42 "class.\n" << 44 << "not breaking the commonly-used interface in the sensitive detector " 43 << "But this functionality of G4VReadOutG << 45 "class.\n" 44 "tested\n" << 46 << "But this functionality of G4VReadOutGeometry class is no longer " 45 << "and thus may not be working well. We << 47 "tested\n" 46 "to\n" << 48 << "and thus may not be working well. We strongly recommend our customers " 47 << "migrate to Parallel World scheme."; << 49 "to\n" >> 50 << "migrate to Parallel World scheme."; 48 G4Exception("G4VReadOutGeometry", "DIGIHIT10 51 G4Exception("G4VReadOutGeometry", "DIGIHIT1001", JustWarning, ed); 49 } 52 } 50 53 51 G4VReadOutGeometry::G4VReadOutGeometry(const G 54 G4VReadOutGeometry::G4VReadOutGeometry(const G4VReadOutGeometry& right) 52 { 55 { 53 fincludeList = nullptr; << 56 fincludeList = nullptr; 54 fexcludeList = nullptr; << 57 fexcludeList = nullptr; 55 name = right.name; << 58 name = right.name; 56 ROworld = right.ROworld; << 59 ROworld = right.ROworld; 57 touchableHistory = nullptr; 60 touchableHistory = nullptr; 58 ROnavigator = new G4Navigator(); << 61 ROnavigator = new G4Navigator(); 59 // COPY CONSTRUCTOR NOT STRAIGHT FORWARD: ne 62 // COPY CONSTRUCTOR NOT STRAIGHT FORWARD: need to copy the touchabelHistory 60 // VALUE, same for navigator and same for th 63 // VALUE, same for navigator and same for the World+Geom hierachy 61 } 64 } 62 65 63 G4VReadOutGeometry::G4VReadOutGeometry(const G << 66 G4VReadOutGeometry::G4VReadOutGeometry(G4String n) 64 : ROworld(nullptr), << 67 : ROworld(nullptr) 65 fincludeList(nullptr), << 68 , fincludeList(nullptr) 66 fexcludeList(nullptr), << 69 , fexcludeList(nullptr) 67 name(n), << 70 , name(n) 68 touchableHistory(nullptr) << 71 , touchableHistory(nullptr) 69 { 72 { 70 ROnavigator = new G4Navigator(); 73 ROnavigator = new G4Navigator(); 71 G4ExceptionDescription ed; 74 G4ExceptionDescription ed; 72 ed << "The concept and the functionality of << 75 ed 73 << "into Parallel World. This G4VReadOutG << 76 << "The concept and the functionality of Readout Geometry has been merged\n" 74 << "not breaking the commonly-used interf << 77 << "into Parallel World. This G4VReadOutGeometry is kept for the sake of\n" 75 "class.\n" << 78 << "not breaking the commonly-used interface in the sensitive detector " 76 << "But this functionality of G4VReadOutG << 79 "class.\n" 77 "tested\n" << 80 << "But this functionality of G4VReadOutGeometry class is no longer " 78 << "and thus may not be working well. We << 81 "tested\n" 79 "to\n" << 82 << "and thus may not be working well. We strongly recommend our customers " 80 << "migrate to Parallel World scheme."; << 83 "to\n" >> 84 << "migrate to Parallel World scheme."; 81 G4Exception("G4VReadOutGeometry", "DIGIHIT10 85 G4Exception("G4VReadOutGeometry", "DIGIHIT1001", JustWarning, ed); 82 } 86 } 83 87 84 G4VReadOutGeometry::~G4VReadOutGeometry() 88 G4VReadOutGeometry::~G4VReadOutGeometry() 85 { 89 { 86 // if(ROworld) delete ROworld; //should we d 90 // if(ROworld) delete ROworld; //should we do ? will it delete the goem tree 87 // also ? 91 // also ? 88 delete fincludeList; << 92 if(fincludeList) 89 delete fexcludeList; << 93 delete fincludeList; 90 delete touchableHistory; << 94 if(fexcludeList) 91 delete ROnavigator; << 95 delete fexcludeList; >> 96 if(touchableHistory) >> 97 delete touchableHistory; >> 98 if(ROnavigator) >> 99 delete ROnavigator; 92 } 100 } 93 101 94 G4VReadOutGeometry& G4VReadOutGeometry::operat << 102 G4VReadOutGeometry& G4VReadOutGeometry::operator=( >> 103 const G4VReadOutGeometry& right) 95 { 104 { 96 if (this == &right) return *this; << 105 if(this == &right) >> 106 return *this; 97 delete fincludeList; 107 delete fincludeList; 98 fincludeList = nullptr; 108 fincludeList = nullptr; 99 delete fexcludeList; 109 delete fexcludeList; 100 fexcludeList = nullptr; 110 fexcludeList = nullptr; 101 name = right.name; << 111 name = right.name; 102 ROworld = right.ROworld; << 112 ROworld = right.ROworld; 103 delete touchableHistory; 113 delete touchableHistory; 104 touchableHistory = nullptr; 114 touchableHistory = nullptr; 105 delete ROnavigator; 115 delete ROnavigator; 106 ROnavigator = new G4Navigator(); 116 ROnavigator = new G4Navigator(); 107 return *this; 117 return *this; 108 } 118 } 109 119 110 G4bool G4VReadOutGeometry::operator==(const G4 120 G4bool G4VReadOutGeometry::operator==(const G4VReadOutGeometry& right) const 111 { 121 { 112 return (this == (G4VReadOutGeometry*)&right) << 122 return (this == (G4VReadOutGeometry*) &right); 113 } 123 } 114 124 115 G4bool G4VReadOutGeometry::operator!=(const G4 125 G4bool G4VReadOutGeometry::operator!=(const G4VReadOutGeometry& right) const 116 { 126 { 117 return (this != (G4VReadOutGeometry*)&right) << 127 return (this != (G4VReadOutGeometry*) &right); 118 } 128 } 119 129 120 void G4VReadOutGeometry::BuildROGeometry() 130 void G4VReadOutGeometry::BuildROGeometry() 121 { 131 { 122 ROworld = Build(); 132 ROworld = Build(); 123 ROnavigator->SetWorldVolume(ROworld); 133 ROnavigator->SetWorldVolume(ROworld); 124 } 134 } 125 135 126 G4bool G4VReadOutGeometry::CheckROVolume(G4Ste << 136 G4bool G4VReadOutGeometry::CheckROVolume(G4Step* currentStep, >> 137 G4TouchableHistory*& ROhist) 127 { 138 { 128 ROhist = nullptr; << 139 ROhist = nullptr; 129 G4bool incFlg = true; 140 G4bool incFlg = true; 130 auto PV = currentStep->GetPreStepPoint()->Ge << 141 auto PV = currentStep->GetPreStepPoint()->GetPhysicalVolume(); 131 if (((fexcludeList) != nullptr) && (fexclude << 142 if((fexcludeList) && (fexcludeList->CheckPV(PV))) >> 143 { 132 incFlg = false; 144 incFlg = false; 133 } 145 } 134 else if (((fincludeList) != nullptr) && (fin << 146 else if((fincludeList) && (fincludeList->CheckPV(PV))) >> 147 { 135 incFlg = true; 148 incFlg = true; 136 } 149 } 137 else if (((fexcludeList) != nullptr) && (fex << 150 else if((fexcludeList) && (fexcludeList->CheckLV(PV->GetLogicalVolume()))) >> 151 { 138 incFlg = false; 152 incFlg = false; 139 } 153 } 140 else if (((fincludeList) != nullptr) && (fin << 154 else if((fincludeList) && (fincludeList->CheckLV(PV->GetLogicalVolume()))) >> 155 { 141 incFlg = true; 156 incFlg = true; 142 } 157 } 143 if (! incFlg) return false; << 158 if(!incFlg) >> 159 return false; 144 160 145 if (ROworld != nullptr) { << 161 if(ROworld) >> 162 { 146 incFlg = FindROTouchable(currentStep); 163 incFlg = FindROTouchable(currentStep); 147 } 164 } 148 if (incFlg) { << 165 if(incFlg) >> 166 { 149 ROhist = touchableHistory; 167 ROhist = touchableHistory; 150 } 168 } 151 return incFlg; 169 return incFlg; 152 } 170 } 153 171 154 G4bool G4VReadOutGeometry::FindROTouchable(G4S 172 G4bool G4VReadOutGeometry::FindROTouchable(G4Step* currentStep) 155 { 173 { 156 // Update G4TouchableHistory object (touchab 174 // Update G4TouchableHistory object (touchableHistory) 157 // using the parallel readout world (ROworld 175 // using the parallel readout world (ROworld) 158 // Return false in case the current Step is 176 // Return false in case the current Step is outside of the 159 // sensitive volume of the readout world. 177 // sensitive volume of the readout world. 160 178 161 // At first invokation, creates the touchabl 179 // At first invokation, creates the touchable history. Note 162 // that default value (false) of Locate meth 180 // that default value (false) of Locate method is used. 163 // ---------> But the default Value is TRUE 181 // ---------> But the default Value is TRUE <-------------------- J.A. 164 if (touchableHistory == nullptr) { << 182 if(!touchableHistory) >> 183 { 165 touchableHistory = new G4TouchableHistory( 184 touchableHistory = new G4TouchableHistory(); 166 ROnavigator->LocateGlobalPointAndUpdateTou << 185 ROnavigator->LocateGlobalPointAndUpdateTouchable( >> 186 currentStep->GetPreStepPoint()->GetPosition(), 167 currentStep->GetPreStepPoint()->GetMomen 187 currentStep->GetPreStepPoint()->GetMomentumDirection(), touchableHistory); 168 } 188 } 169 else { << 189 else 170 ROnavigator->LocateGlobalPointAndUpdateTou << 190 { 171 currentStep->GetPreStepPoint()->GetMomen << 191 ROnavigator->LocateGlobalPointAndUpdateTouchable( >> 192 currentStep->GetPreStepPoint()->GetPosition(), >> 193 currentStep->GetPreStepPoint()->GetMomentumDirection(), touchableHistory, >> 194 true); 172 } 195 } 173 // Can the above be improved by the use of a 196 // Can the above be improved by the use of an isotropic safety 174 // in order to avoid LocateGlobalPointAndUpd 197 // in order to avoid LocateGlobalPointAndUpdateTouchable 175 // at each Step ? 198 // at each Step ? 176 // Should require that an RO geometry is not 199 // Should require that an RO geometry is notified at the 177 // starting of a track to avoid possible con 200 // starting of a track to avoid possible confusion looking 178 // at the safety value only. 201 // at the safety value only. 179 202 180 // checks if volume is sensitive: 203 // checks if volume is sensitive: 181 auto currentVolume = touchableHistory->GetVo 204 auto currentVolume = touchableHistory->GetVolume(); 182 // checks first if a physical volume exists 205 // checks first if a physical volume exists here: 183 if (currentVolume != nullptr) { << 206 if(currentVolume) 184 return currentVolume->GetLogicalVolume()-> << 207 { >> 208 return currentVolume->GetLogicalVolume()->GetSensitiveDetector() != 0; 185 } 209 } 186 // no sensitive volume found: returns false 210 // no sensitive volume found: returns false 187 return false; 211 return false; 188 } 212 } 189 213