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 // $Id: G4VReadOutGeometry.cc 81087 2014-05-20 15:44:27Z gcosmo $ 27 // 28 // 28 29 29 #include "G4VReadOutGeometry.hh" 30 #include "G4VReadOutGeometry.hh" 30 << 31 #include "G4Navigator.hh" 31 #include "G4Navigator.hh" 32 32 >> 33 33 G4VReadOutGeometry::G4VReadOutGeometry() 34 G4VReadOutGeometry::G4VReadOutGeometry() 34 : ROworld(nullptr), fincludeList(nullptr), f << 35 :ROworld(0),fincludeList(0), >> 36 fexcludeList(0),touchableHistory(0) 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<<"The concept and the functionality of Readout Geometry has been merged\n" 40 << "into Parallel World. This G4VReadOutG << 42 <<"into Parallel World. This G4VReadOutGeometry is kept for the sake of\n" 41 << "not breaking the commonly-used interf << 43 <<"not breaking the commonly-used interface in the sensitive detector class.\n" 42 "class.\n" << 44 <<"But this functionality of G4VReadOutGeometry class is no longer tested\n" 43 << "But this functionality of G4VReadOutG << 45 <<"and thus may not be working well. We strongly recommend our customers to\n" 44 "tested\n" << 46 <<"migrate to Parallel World scheme."; 45 << "and thus may not be working well. We << 47 G4Exception("G4VReadOutGeometry","DIGIHIT1001",JustWarning,ed); 46 "to\n" << 47 << "migrate to Parallel World scheme."; << 48 G4Exception("G4VReadOutGeometry", "DIGIHIT10 << 49 } 48 } 50 49 51 G4VReadOutGeometry::G4VReadOutGeometry(const G << 50 G4VReadOutGeometry::G4VReadOutGeometry(const G4VReadOutGeometry &right) 52 { 51 { 53 fincludeList = nullptr; << 52 fincludeList = 0; 54 fexcludeList = nullptr; << 53 fexcludeList = 0; 55 name = right.name; 54 name = right.name; 56 ROworld = right.ROworld; 55 ROworld = right.ROworld; 57 touchableHistory = nullptr; << 56 touchableHistory = 0; 58 ROnavigator = new G4Navigator(); 57 ROnavigator = new G4Navigator(); 59 // COPY CONSTRUCTOR NOT STRAIGHT FORWARD: ne 58 // COPY CONSTRUCTOR NOT STRAIGHT FORWARD: need to copy the touchabelHistory 60 // VALUE, same for navigator and same for th 59 // VALUE, same for navigator and same for the World+Geom hierachy 61 } 60 } 62 61 63 G4VReadOutGeometry::G4VReadOutGeometry(const G << 62 G4VReadOutGeometry::G4VReadOutGeometry(G4String n) 64 : ROworld(nullptr), << 63 :ROworld(0),fincludeList(0), 65 fincludeList(nullptr), << 64 fexcludeList(0),name(n),touchableHistory(0) 66 fexcludeList(nullptr), << 67 name(n), << 68 touchableHistory(nullptr) << 69 { 65 { 70 ROnavigator = new G4Navigator(); 66 ROnavigator = new G4Navigator(); 71 G4ExceptionDescription ed; << 72 ed << "The concept and the functionality of << 73 << "into Parallel World. This G4VReadOutG << 74 << "not breaking the commonly-used interf << 75 "class.\n" << 76 << "But this functionality of G4VReadOutG << 77 "tested\n" << 78 << "and thus may not be working well. We << 79 "to\n" << 80 << "migrate to Parallel World scheme."; << 81 G4Exception("G4VReadOutGeometry", "DIGIHIT10 << 82 } 67 } 83 68 84 G4VReadOutGeometry::~G4VReadOutGeometry() 69 G4VReadOutGeometry::~G4VReadOutGeometry() 85 { << 70 { 86 // if(ROworld) delete ROworld; //should we d << 71 //if(ROworld) delete ROworld; //should we do ? will it delete the goem tree also ? 87 // also ? << 72 if(fincludeList) delete fincludeList; 88 delete fincludeList; << 73 if(fexcludeList) delete fexcludeList; 89 delete fexcludeList; << 74 if(touchableHistory) delete touchableHistory; 90 delete touchableHistory; << 75 if(ROnavigator) delete ROnavigator; 91 delete ROnavigator; << 76 } 92 } << 77 93 << 78 G4VReadOutGeometry & G4VReadOutGeometry::operator=(const G4VReadOutGeometry &right) 94 G4VReadOutGeometry& G4VReadOutGeometry::operat << 79 { 95 { << 80 if ( this == &right ) return *this; 96 if (this == &right) return *this; << 81 delete fincludeList; fincludeList = 0; 97 delete fincludeList; << 82 delete fexcludeList; fexcludeList = 0; 98 fincludeList = nullptr; << 83 name = right.name; 99 delete fexcludeList; << 84 ROworld = right.ROworld; 100 fexcludeList = nullptr; << 85 delete touchableHistory; touchableHistory = 0; 101 name = right.name; << 86 delete ROnavigator; ROnavigator = new G4Navigator(); 102 ROworld = right.ROworld; << 103 delete touchableHistory; << 104 touchableHistory = nullptr; << 105 delete ROnavigator; << 106 ROnavigator = new G4Navigator(); << 107 return *this; 87 return *this; 108 } 88 } 109 89 110 G4bool G4VReadOutGeometry::operator==(const G4 << 90 G4int G4VReadOutGeometry::operator==(const G4VReadOutGeometry &right) const 111 { << 91 { return (this == (G4VReadOutGeometry *) &right); } 112 return (this == (G4VReadOutGeometry*)&right) << 113 } << 114 92 115 G4bool G4VReadOutGeometry::operator!=(const G4 << 93 G4int G4VReadOutGeometry::operator!=(const G4VReadOutGeometry &right) const 116 { << 94 { return (this != (G4VReadOutGeometry *) &right); } 117 return (this != (G4VReadOutGeometry*)&right) << 118 } << 119 95 120 void G4VReadOutGeometry::BuildROGeometry() 96 void G4VReadOutGeometry::BuildROGeometry() 121 { 97 { 122 ROworld = Build(); 98 ROworld = Build(); 123 ROnavigator->SetWorldVolume(ROworld); 99 ROnavigator->SetWorldVolume(ROworld); 124 } 100 } 125 101 126 G4bool G4VReadOutGeometry::CheckROVolume(G4Ste << 102 G4bool G4VReadOutGeometry::CheckROVolume(G4Step*currentStep,G4TouchableHistory*& ROhist) 127 { 103 { 128 ROhist = nullptr; << 104 ROhist = 0; 129 G4bool incFlg = true; 105 G4bool incFlg = true; 130 auto PV = currentStep->GetPreStepPoint()->Ge << 106 G4VPhysicalVolume* PV = currentStep->GetPreStepPoint()->GetPhysicalVolume(); 131 if (((fexcludeList) != nullptr) && (fexclude << 107 if((fexcludeList)&&(fexcludeList->CheckPV(PV))) 132 incFlg = false; << 108 { incFlg = false; } 133 } << 109 else if ((fincludeList)&&(fincludeList->CheckPV(PV))) 134 else if (((fincludeList) != nullptr) && (fin << 110 { incFlg = true; } 135 incFlg = true; << 111 else if((fexcludeList)&&(fexcludeList->CheckLV(PV->GetLogicalVolume()))) 136 } << 112 { incFlg = false; } 137 else if (((fexcludeList) != nullptr) && (fex << 113 else if((fincludeList)&&(fincludeList->CheckLV(PV->GetLogicalVolume()))) 138 incFlg = false; << 114 { incFlg = true; } 139 } << 115 if(!incFlg) return false; 140 else if (((fincludeList) != nullptr) && (fin << 116 141 incFlg = true; << 117 if(ROworld) 142 } << 118 { incFlg = FindROTouchable(currentStep); } 143 if (! incFlg) return false; << 119 if(incFlg) 144 << 120 { ROhist = touchableHistory; } 145 if (ROworld != nullptr) { << 146 incFlg = FindROTouchable(currentStep); << 147 } << 148 if (incFlg) { << 149 ROhist = touchableHistory; << 150 } << 151 return incFlg; 121 return incFlg; 152 } 122 } 153 123 154 G4bool G4VReadOutGeometry::FindROTouchable(G4S << 124 G4bool G4VReadOutGeometry::FindROTouchable(G4Step*currentStep) 155 { 125 { 156 // Update G4TouchableHistory object (touchab 126 // Update G4TouchableHistory object (touchableHistory) 157 // using the parallel readout world (ROworld 127 // using the parallel readout world (ROworld) 158 // Return false in case the current Step is 128 // Return false in case the current Step is outside of the 159 // sensitive volume of the readout world. 129 // sensitive volume of the readout world. 160 130 161 // At first invokation, creates the touchabl 131 // At first invokation, creates the touchable history. Note 162 // that default value (false) of Locate meth 132 // that default value (false) of Locate method is used. 163 // ---------> But the default Value is TRUE << 133 // ---------> But the default Value is TRUE <-------------------- J.A. 164 if (touchableHistory == nullptr) { << 134 if(!touchableHistory) 165 touchableHistory = new G4TouchableHistory( << 135 { 166 ROnavigator->LocateGlobalPointAndUpdateTou << 136 touchableHistory = new G4TouchableHistory(); 167 currentStep->GetPreStepPoint()->GetMomen << 137 ROnavigator->LocateGlobalPointAndUpdateTouchable( 168 } << 138 currentStep->GetPreStepPoint()->GetPosition(), 169 else { << 139 currentStep->GetPreStepPoint()->GetMomentumDirection(), 170 ROnavigator->LocateGlobalPointAndUpdateTou << 140 touchableHistory); 171 currentStep->GetPreStepPoint()->GetMomen << 141 } 172 } << 142 else >> 143 { >> 144 ROnavigator->LocateGlobalPointAndUpdateTouchable( >> 145 currentStep->GetPreStepPoint()->GetPosition(), >> 146 currentStep->GetPreStepPoint()->GetMomentumDirection(), >> 147 touchableHistory, >> 148 true); >> 149 } 173 // Can the above be improved by the use of a 150 // Can the above be improved by the use of an isotropic safety 174 // in order to avoid LocateGlobalPointAndUpd 151 // in order to avoid LocateGlobalPointAndUpdateTouchable 175 // at each Step ? 152 // at each Step ? 176 // Should require that an RO geometry is not 153 // Should require that an RO geometry is notified at the 177 // starting of a track to avoid possible con 154 // starting of a track to avoid possible confusion looking 178 // at the safety value only. 155 // at the safety value only. 179 << 156 180 // checks if volume is sensitive: 157 // checks if volume is sensitive: 181 auto currentVolume = touchableHistory->GetVo << 158 G4VPhysicalVolume* currentVolume = touchableHistory->GetVolume(); 182 // checks first if a physical volume exists 159 // checks first if a physical volume exists here: 183 if (currentVolume != nullptr) { << 160 if ( currentVolume ) 184 return currentVolume->GetLogicalVolume()-> << 161 { 185 } << 162 return currentVolume->GetLogicalVolume()-> >> 163 GetSensitiveDetector() != 0; >> 164 } 186 // no sensitive volume found: returns false 165 // no sensitive volume found: returns false 187 return false; 166 return false; 188 } 167 } >> 168 189 169