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 // G4VScoringMesh << 26 // >> 27 // >> 28 // --------------------------------------------------------------------- >> 29 // Modifications >> 30 // 17-Apr-2012 T.Aso SetSize() and SetNumberOfSegments() is not allowed >> 31 // to call twice in same geometrical mesh. Add warning >> 32 // message to notify. >> 33 // 27 // ------------------------------------------- 34 // --------------------------------------------------------------------- 28 35 29 #include "G4VScoringMesh.hh" 36 #include "G4VScoringMesh.hh" 30 #include "G4THitsMap.hh" 37 #include "G4THitsMap.hh" 31 #include "G4SystemOfUnits.hh" 38 #include "G4SystemOfUnits.hh" 32 #include "G4VPhysicalVolume.hh" 39 #include "G4VPhysicalVolume.hh" 33 #include "G4MultiFunctionalDetector.hh" 40 #include "G4MultiFunctionalDetector.hh" 34 #include "G4VPrimitiveScorer.hh" 41 #include "G4VPrimitiveScorer.hh" 35 #include "G4VSDFilter.hh" 42 #include "G4VSDFilter.hh" 36 #include "G4SDManager.hh" 43 #include "G4SDManager.hh" 37 44 38 G4VScoringMesh::G4VScoringMesh(const G4String& 45 G4VScoringMesh::G4VScoringMesh(const G4String& wName) 39 : fWorldName(wName) << 46 : fWorldName(wName),fCurrentPS(nullptr),fConstructed(false),fActive(true), 40 , fCurrentPS(nullptr) << 47 fShape(MeshShape::undefined), 41 , fConstructed(false) << 48 fRotationMatrix(nullptr), fMFD(new G4MultiFunctionalDetector(wName)), 42 , fActive(true) << 49 verboseLevel(0),sizeIsSet(false),nMeshIsSet(false), 43 , fShape(MeshShape::undefined) << 50 fDrawUnit(""), fDrawUnitValue(1.), fMeshElementLogical(nullptr), 44 , fRotationMatrix(nullptr) << 51 fParallelWorldProcess(nullptr), fGeometryHasBeenDestroyed(false), 45 , fMFD(new G4MultiFunctionalDetector(wName)) << 52 copyNumberLevel(0) 46 , verboseLevel(0) << 47 , sizeIsSet(false) << 48 , nMeshIsSet(false) << 49 , fDrawUnit("") << 50 , fDrawUnitValue(1.) << 51 , fMeshElementLogical(nullptr) << 52 , fParallelWorldProcess(nullptr) << 53 , fGeometryHasBeenDestroyed(false) << 54 , copyNumberLevel(0) << 55 , layeredMassFlg(false) << 56 { 53 { 57 G4SDManager::GetSDMpointer()->AddNewDetector 54 G4SDManager::GetSDMpointer()->AddNewDetector(fMFD); 58 55 59 fSize[0] = fSize[1] = fSize[2] = 0.; 56 fSize[0] = fSize[1] = fSize[2] = 0.; 60 fAngle[0] = 0.0; << 61 fAngle[1] = CLHEP::twop << 62 fNSegment[0] = fNSegment[1] = fNSegment[2] = 57 fNSegment[0] = fNSegment[1] = fNSegment[2] = 1; 63 fDivisionAxisNames[0] = fDivisionAxisNames[1 58 fDivisionAxisNames[0] = fDivisionAxisNames[1] = fDivisionAxisNames[2] = ""; 64 } 59 } 65 60 66 void G4VScoringMesh::ResetScore() << 61 G4VScoringMesh::~G4VScoringMesh() { 67 { << 62 ; 68 if(verboseLevel > 9) << 63 } 69 G4cout << "G4VScoringMesh::ResetScore() is << 64 70 for(const auto& mp : fMap) << 65 void G4VScoringMesh::ResetScore() { >> 66 if(verboseLevel > 9) G4cout << "G4VScoringMesh::ResetScore() is called." << G4endl; >> 67 for(auto mp : fMap) 71 { 68 { 72 if(verboseLevel > 9) << 69 if(verboseLevel > 9) G4cout << "G4VScoringMesh::ResetScore()" << mp.first << G4endl; 73 G4cout << "G4VScoringMesh::ResetScore()" << 74 mp.second->clear(); 70 mp.second->clear(); 75 } 71 } 76 } 72 } 77 73 78 void G4VScoringMesh::SetSize(G4double size[3]) << 74 void G4VScoringMesh::SetSize(G4double size[3]) { 79 { << 75 if ( !sizeIsSet ){ 80 if(!sizeIsSet) << 76 for(int i = 0; i < 3; i++) fSize[i] = size[i]; 81 { << 82 sizeIsSet = true; 77 sizeIsSet = true; 83 for(G4int i = 0; i < 3; ++i) << 78 }else{ 84 { << 79 G4String message = " The size of scoring mesh can not be changed."; 85 fSize[i] = size[i]; << 86 } << 87 } << 88 else << 89 { << 90 G4String message = " Mesh size has alrea << 91 message += " This method is ignored."; << 92 G4Exception("G4VScoringMesh::SetSize()", 80 G4Exception("G4VScoringMesh::SetSize()", 93 "DigiHitsUtilsScoreVScoringMes << 81 "DigiHitsUtilsScoreVScoringMesh000", JustWarning, >> 82 message); 94 } 83 } 95 } 84 } 96 << 85 G4ThreeVector G4VScoringMesh::GetSize() const { 97 G4ThreeVector G4VScoringMesh::GetSize() const << 98 { << 99 if(sizeIsSet) 86 if(sizeIsSet) 100 return G4ThreeVector(fSize[0], fSize[1], f 87 return G4ThreeVector(fSize[0], fSize[1], fSize[2]); 101 return G4ThreeVector(0., 0., 0.); << 88 else 102 } << 89 return G4ThreeVector(0., 0., 0.); 103 << 104 void G4VScoringMesh::SetAngles(G4double startA << 105 { << 106 fAngle[0] = startAngle; << 107 fAngle[1] = spanAngle; << 108 } 90 } 109 << 91 void G4VScoringMesh::SetCenterPosition(G4double centerPosition[3]) { 110 void G4VScoringMesh::SetCenterPosition(G4doubl << 92 fCenterPosition = G4ThreeVector(centerPosition[0], centerPosition[1], centerPosition[2]); 111 { << 112 fCenterPosition = << 113 G4ThreeVector(centerPosition[0], centerPos << 114 } 93 } 115 << 94 void G4VScoringMesh::SetNumberOfSegments(G4int nSegment[3]) { 116 void G4VScoringMesh::SetNumberOfSegments(G4int << 95 if ( !nMeshIsSet || fShape==MeshShape::realWorldLogVol ){ 117 { << 96 for(int i = 0; i < 3; i++) fNSegment[i] = nSegment[i]; 118 if(!nMeshIsSet || fShape == MeshShape::realW << 119 fShape == MeshShape::probe) << 120 { << 121 for(G4int i = 0; i < 3; ++i) << 122 fNSegment[i] = nSegment[i]; << 123 nMeshIsSet = true; 97 nMeshIsSet = true; 124 } << 98 } else { 125 else << 99 G4String message = " The size of scoring segments can not be changed."; 126 { << 127 G4String message = " Number of bins has << 128 message += " This method is ignored."; << 129 G4Exception("G4VScoringMesh::SetNumberOfSe 100 G4Exception("G4VScoringMesh::SetNumberOfSegments()", 130 "DigiHitsUtilsScoreVScoringMes << 101 "DigiHitsUtilsScoreVScoringMesh000", JustWarning, >> 102 message); 131 } 103 } 132 } 104 } 133 << 105 void G4VScoringMesh::GetNumberOfSegments(G4int nSegment[3]) { 134 void G4VScoringMesh::GetNumberOfSegments(G4int << 106 for(int i = 0; i < 3; i++) nSegment[i] = fNSegment[i]; 135 { << 136 for(G4int i = 0; i < 3; ++i) << 137 nSegment[i] = fNSegment[i]; << 138 } 107 } 139 << 108 void G4VScoringMesh::RotateX(G4double delta) { 140 void G4VScoringMesh::RotateX(G4double delta) << 109 if(!fRotationMatrix) fRotationMatrix = new G4RotationMatrix(); 141 { << 142 if(fRotationMatrix == nullptr) << 143 fRotationMatrix = new G4RotationMatrix(); << 144 fRotationMatrix->rotateX(delta); 110 fRotationMatrix->rotateX(delta); 145 } 111 } 146 112 147 void G4VScoringMesh::RotateY(G4double delta) << 113 void G4VScoringMesh::RotateY(G4double delta) { 148 { << 114 if(!fRotationMatrix) fRotationMatrix = new G4RotationMatrix(); 149 if(fRotationMatrix == nullptr) << 150 fRotationMatrix = new G4RotationMatrix(); << 151 fRotationMatrix->rotateY(delta); 115 fRotationMatrix->rotateY(delta); 152 } 116 } 153 117 154 void G4VScoringMesh::RotateZ(G4double delta) << 118 void G4VScoringMesh::RotateZ(G4double delta) { 155 { << 119 if(!fRotationMatrix) fRotationMatrix = new G4RotationMatrix(); 156 if(fRotationMatrix == nullptr) << 157 fRotationMatrix = new G4RotationMatrix(); << 158 fRotationMatrix->rotateZ(delta); 120 fRotationMatrix->rotateZ(delta); 159 } 121 } 160 122 161 void G4VScoringMesh::SetPrimitiveScorer(G4VPri << 123 void G4VScoringMesh::SetPrimitiveScorer(G4VPrimitiveScorer * prs) { 162 { << 124 163 if(!ReadyForQuantity()) 125 if(!ReadyForQuantity()) 164 { 126 { 165 G4cerr << "ERROR : G4VScoringMesh::SetPrim 127 G4cerr << "ERROR : G4VScoringMesh::SetPrimitiveScorer() : " 166 << prs->GetName() << 128 << prs->GetName() 167 << " does not yet have mesh size or << 129 << " does not yet have mesh size or number of bins. Set them first." << G4endl 168 << G4endl << "This Method is ignore << 130 << "This Method is ignored." << G4endl; 169 return; 131 return; 170 } 132 } 171 if(verboseLevel > 0) << 133 if(verboseLevel > 0) G4cout << "G4VScoringMesh::SetPrimitiveScorer() : " 172 G4cout << "G4VScoringMesh::SetPrimitiveSco << 134 << prs->GetName() << " is registered." 173 << " is registered." << 135 << " 3D size: (" 174 << " 3D size: (" << fNSegment[0] << << 136 << fNSegment[0] << ", " 175 << fNSegment[2] << ")" << G4endl; << 137 << fNSegment[1] << ", " >> 138 << fNSegment[2] << ")" << G4endl; 176 139 177 prs->SetNijk(fNSegment[0], fNSegment[1], fNS 140 prs->SetNijk(fNSegment[0], fNSegment[1], fNSegment[2]); 178 fCurrentPS = prs; 141 fCurrentPS = prs; 179 fMFD->RegisterPrimitive(prs); 142 fMFD->RegisterPrimitive(prs); 180 auto map = << 143 G4THitsMap<G4StatDouble> * map = new G4THitsMap<G4StatDouble>(fWorldName, prs->GetName()); 181 new G4THitsMap<G4StatDouble>(fWorldName, p << 182 fMap[prs->GetName()] = map; 144 fMap[prs->GetName()] = map; 183 } 145 } 184 146 185 void G4VScoringMesh::SetFilter(G4VSDFilter* fi << 147 void G4VScoringMesh::SetFilter(G4VSDFilter * filter) { 186 { << 148 187 if(fCurrentPS == nullptr) << 149 if(!fCurrentPS) { 188 { << 150 G4cerr << "ERROR : G4VScoringMesh::SetSDFilter() : a quantity must be defined first. This method is ignored." << G4endl; 189 G4cerr << "ERROR : G4VScoringMesh::SetSDFi << 190 "defined first. This method is i << 191 << G4endl; << 192 return; 151 return; 193 } 152 } 194 if(verboseLevel > 0) << 153 if(verboseLevel > 0) G4cout << "G4VScoringMesh::SetFilter() : " 195 G4cout << "G4VScoringMesh::SetFilter() : " << 154 << filter->GetName() 196 << " is set to " << fCurrentPS->Get << 155 << " is set to " >> 156 << fCurrentPS->GetName() << G4endl; 197 157 198 G4VSDFilter* oldFilter = fCurrentPS->GetFilt 158 G4VSDFilter* oldFilter = fCurrentPS->GetFilter(); 199 if(oldFilter != nullptr) << 159 if(oldFilter) 200 { 160 { 201 G4cout << "WARNING : G4VScoringMesh::SetFi << 161 G4cout << "WARNING : G4VScoringMesh::SetFilter() : " << oldFilter->GetName() 202 << " is overwritten by " << filter- 162 << " is overwritten by " << filter->GetName() << G4endl; 203 } 163 } 204 fCurrentPS->SetFilter(filter); 164 fCurrentPS->SetFilter(filter); 205 } 165 } 206 166 207 void G4VScoringMesh::SetCurrentPrimitiveScorer << 167 void G4VScoringMesh::SetCurrentPrimitiveScorer(const G4String & name) { 208 { << 209 fCurrentPS = GetPrimitiveScorer(name); 168 fCurrentPS = GetPrimitiveScorer(name); 210 if(fCurrentPS == nullptr) << 169 if(!fCurrentPS) { 211 { << 170 G4cerr << "ERROR : G4VScoringMesh::SetCurrentPrimitiveScorer() : The primitive scorer <" 212 G4cerr << "ERROR : G4VScoringMesh::SetCurr << 171 << name << "> does not found." << G4endl; 213 "primitive scorer <" << 214 << name << "> does not found." << G << 215 } 172 } 216 } 173 } 217 174 218 G4bool G4VScoringMesh::FindPrimitiveScorer(con << 175 G4bool G4VScoringMesh::FindPrimitiveScorer(const G4String & psname) { 219 { << 176 MeshScoreMap::iterator itr = fMap.find(psname); 220 const auto itr = fMap.find(psname); << 177 if(itr == fMap.end()) return false; 221 return itr != fMap.cend(); << 178 return true; 222 } 179 } 223 180 224 G4String G4VScoringMesh::GetPSUnit(const G4Str << 181 G4String G4VScoringMesh::GetPSUnit(const G4String & psname) { 225 { << 182 MeshScoreMap::iterator itr = fMap.find(psname); 226 const auto itr = fMap.find(psname); << 183 if(itr == fMap.end()) { 227 if(itr == fMap.cend()) << 228 { << 229 return G4String(""); 184 return G4String(""); >> 185 } else { >> 186 return GetPrimitiveScorer(psname)->GetUnit(); 230 } 187 } 231 << 232 return GetPrimitiveScorer(psname)->GetUnit() << 233 } 188 } 234 189 235 G4String G4VScoringMesh::GetCurrentPSUnit() << 190 G4String G4VScoringMesh::GetCurrentPSUnit(){ 236 { << 237 G4String unit = ""; 191 G4String unit = ""; 238 if(fCurrentPS == nullptr) << 192 if(!fCurrentPS) { 239 { << 193 G4String msg = "ERROR : G4VScoringMesh::GetCurrentPSUnit() : "; 240 G4String msg = "ERROR : G4VScoringMesh::Ge << 194 msg += " Current primitive scorer is null."; 241 msg += " Current primitive scorer is null. << 195 G4cerr << msg << G4endl; 242 G4cerr << msg << G4endl; << 196 }else{ 243 } << 197 unit = fCurrentPS->GetUnit(); 244 else << 245 { << 246 unit = fCurrentPS->GetUnit(); << 247 } 198 } 248 return unit; 199 return unit; 249 } 200 } 250 201 251 void G4VScoringMesh::SetCurrentPSUnit(const G4 << 202 void G4VScoringMesh::SetCurrentPSUnit(const G4String& unit){ 252 { << 203 if(!fCurrentPS) { 253 if(fCurrentPS == nullptr) << 204 G4String msg = "ERROR : G4VScoringMesh::GetCurrentPSUnit() : "; 254 { << 205 msg += " Current primitive scorer is null."; 255 G4String msg = "ERROR : G4VScoringMesh::Ge << 206 G4cerr << msg << G4endl; 256 msg += " Current primitive scorer is null. << 207 }else{ 257 G4cerr << msg << G4endl; << 208 fCurrentPS->SetUnit(unit); 258 } << 259 else << 260 { << 261 fCurrentPS->SetUnit(unit); << 262 } 209 } 263 } 210 } 264 211 265 G4double G4VScoringMesh::GetPSUnitValue(const << 212 G4double G4VScoringMesh::GetPSUnitValue(const G4String & psname) { 266 { << 213 MeshScoreMap::iterator itr = fMap.find(psname); 267 const auto itr = fMap.find(psname); << 214 if(itr == fMap.end()) { 268 if(itr == fMap.cend()) << 269 { << 270 return 1.; 215 return 1.; >> 216 } else { >> 217 return GetPrimitiveScorer(psname)->GetUnitValue(); 271 } 218 } 272 << 273 return GetPrimitiveScorer(psname)->GetUnitVa << 274 } 219 } 275 220 276 void G4VScoringMesh::GetDivisionAxisNames(G4St << 221 void G4VScoringMesh::GetDivisionAxisNames(G4String divisionAxisNames[3]) { 277 { << 222 for(int i = 0; i < 3; i++) divisionAxisNames[i] = fDivisionAxisNames[i]; 278 for(G4int i = 0; i < 3; ++i) << 279 divisionAxisNames[i] = fDivisionAxisNames[ << 280 } 223 } 281 224 282 G4VPrimitiveScorer* G4VScoringMesh::GetPrimiti << 225 G4VPrimitiveScorer * G4VScoringMesh::GetPrimitiveScorer(const G4String & name) { 283 { << 226 if(!fMFD) return nullptr; 284 if(fMFD == nullptr) << 285 return nullptr; << 286 227 287 G4int nps = fMFD->GetNumberOfPrimitives(); 228 G4int nps = fMFD->GetNumberOfPrimitives(); 288 for(G4int i = 0; i < nps; ++i) << 229 for(G4int i = 0; i < nps; i++) { 289 { << 230 G4VPrimitiveScorer * prs = fMFD->GetPrimitive(i); 290 G4VPrimitiveScorer* prs = fMFD->GetPrimiti << 231 if(name == prs->GetName()) return prs; 291 if(name == prs->GetName()) << 292 return prs; << 293 } 232 } 294 233 295 return nullptr; 234 return nullptr; 296 } 235 } >> 236 void G4VScoringMesh::List() const { 297 237 298 void G4VScoringMesh::List() const << 238 G4cout << " # of segments: (" 299 { << 239 << fNSegment[0] << ", " 300 G4cout << " # of segments: (" << fNSegment[0 << 240 << fNSegment[1] << ", " 301 << fNSegment[2] << ")" << G4endl; << 241 << fNSegment[2] << ")" 302 G4cout << " displacement: (" << fCenterPosit << 242 << G4endl; 303 << fCenterPosition.y() / cm << ", " < << 243 G4cout << " displacement: (" 304 << ") [cm]" << G4endl; << 244 << fCenterPosition.x()/cm << ", " 305 if(fRotationMatrix != nullptr) << 245 << fCenterPosition.y()/cm << ", " 306 { << 246 << fCenterPosition.z()/cm << ") [cm]" 307 G4cout << " rotation matrix: " << fRotatio << 247 << G4endl; 308 << fRotationMatrix->xy() << " " << << 248 if(fRotationMatrix != 0) { 309 << " " << fRotatio << 249 G4cout << " rotation matrix: " 310 << fRotationMatrix->yy() << " " << << 250 << fRotationMatrix->xx() << " " 311 << " " << fRotatio << 251 << fRotationMatrix->xy() << " " 312 << fRotationMatrix->zy() << " " << << 252 << fRotationMatrix->xz() << G4endl >> 253 << " " >> 254 << fRotationMatrix->yx() << " " >> 255 << fRotationMatrix->yy() << " " >> 256 << fRotationMatrix->yz() << G4endl >> 257 << " " >> 258 << fRotationMatrix->zx() << " " >> 259 << fRotationMatrix->zy() << " " >> 260 << fRotationMatrix->zz() << G4endl; 313 } 261 } 314 262 >> 263 315 G4cout << " registered primitve scorers : " 264 G4cout << " registered primitve scorers : " << G4endl; 316 G4int nps = fMFD->GetNumberOfPrimitives(); 265 G4int nps = fMFD->GetNumberOfPrimitives(); 317 G4VPrimitiveScorer* prs; << 266 G4VPrimitiveScorer * prs; 318 for(G4int i = 0; i < nps; ++i) << 267 for(int i = 0; i < nps; i++) { 319 { << 320 prs = fMFD->GetPrimitive(i); 268 prs = fMFD->GetPrimitive(i); 321 G4cout << " " << i << " " << prs->GetNa 269 G4cout << " " << i << " " << prs->GetName(); 322 if(prs->GetFilter() != nullptr) << 270 if(prs->GetFilter() != 0) G4cout << " with " << prs->GetFilter()->GetName(); 323 G4cout << " with " << prs->GetFilte << 324 G4cout << G4endl; 271 G4cout << G4endl; 325 } 272 } 326 } 273 } 327 274 328 void G4VScoringMesh::Dump() << 275 void G4VScoringMesh::Dump() { 329 { << 330 G4cout << "scoring mesh name: " << fWorldNam 276 G4cout << "scoring mesh name: " << fWorldName << G4endl; 331 G4cout << "# of G4THitsMap : " << fMap.size( 277 G4cout << "# of G4THitsMap : " << fMap.size() << G4endl; 332 for(const auto& mp : fMap) << 278 for(auto mp : fMap) 333 { 279 { 334 G4cout << "[" << mp.first << "]" << G4endl 280 G4cout << "[" << mp.first << "]" << G4endl; 335 mp.second->PrintAllHits(); 281 mp.second->PrintAllHits(); 336 } 282 } 337 G4cout << G4endl; 283 G4cout << G4endl; >> 284 338 } 285 } 339 286 340 void G4VScoringMesh::DrawMesh(const G4String& << 287 341 G4VScoreColorMap << 288 void G4VScoringMesh::DrawMesh(const G4String& psName,G4VScoreColorMap* colorMap,G4int axflg) 342 { 289 { 343 fDrawPSName = psName; 290 fDrawPSName = psName; 344 const auto fMapItr = fMap.find(psName); << 291 MeshScoreMap::const_iterator fMapItr = fMap.find(psName); 345 if(fMapItr != fMap.cend()) << 292 if(fMapItr!=fMap.end()) { 346 { << 293 fDrawUnit = GetPSUnit(psName); 347 fDrawUnit = GetPSUnit(psName); << 348 fDrawUnitValue = GetPSUnitValue(psName); 294 fDrawUnitValue = GetPSUnitValue(psName); 349 Draw(fMapItr->second, colorMap, axflg); << 295 Draw(fMapItr->second, colorMap,axflg); 350 } << 296 } else { 351 else << 297 G4cerr << "Scorer <" << psName << "> is not defined. Method ignored." << G4endl; 352 { << 353 G4cerr << "Scorer <" << psName << "> is no << 354 << G4endl; << 355 } 298 } 356 } 299 } 357 300 358 void G4VScoringMesh::DrawMesh(const G4String& << 301 void G4VScoringMesh::DrawMesh(const G4String& psName,G4int idxPlane,G4int iColumn,G4VScoreColorMap* colorMap) 359 G4int iColumn, G << 360 { 302 { 361 fDrawPSName = psName; 303 fDrawPSName = psName; 362 const auto fMapItr = fMap.find(psName); << 304 MeshScoreMap::const_iterator fMapItr = fMap.find(psName); 363 if(fMapItr != fMap.cend()) << 305 if(fMapItr!=fMap.end()) { 364 { << 306 fDrawUnit = GetPSUnit(psName); 365 fDrawUnit = GetPSUnit(psName); << 366 fDrawUnitValue = GetPSUnitValue(psName); 307 fDrawUnitValue = GetPSUnitValue(psName); 367 DrawColumn(fMapItr->second, colorMap, idxP << 308 DrawColumn(fMapItr->second,colorMap,idxPlane,iColumn); 368 } << 309 } else { 369 else << 310 G4cerr << "Scorer <" << psName << "> is not defined. Method ignored." << G4endl; 370 { << 371 G4cerr << "Scorer <" << psName << "> is no << 372 << G4endl; << 373 } 311 } 374 } 312 } 375 313 376 void G4VScoringMesh::Accumulate(G4THitsMap<G4d << 314 void G4VScoringMesh::Accumulate(G4THitsMap<G4double> * map) 377 { 315 { 378 G4String psName = map->GetName(); 316 G4String psName = map->GetName(); 379 const auto fMapItr = fMap.find(psName); << 317 MeshScoreMap::const_iterator fMapItr = fMap.find(psName); 380 if (fMapItr != fMap.cend()) { *(fMapItr->se << 318 *(fMapItr->second) += *map; 381 319 382 if(verboseLevel > 9) << 320 if(verboseLevel > 9) { 383 { << 384 G4cout << G4endl; 321 G4cout << G4endl; 385 G4cout << "G4VScoringMesh::Accumulate()" < 322 G4cout << "G4VScoringMesh::Accumulate()" << G4endl; 386 G4cout << " PS name : " << psName << G4en 323 G4cout << " PS name : " << psName << G4endl; 387 if(fMapItr == fMap.cend()) << 324 if(fMapItr == fMap.end()) { 388 { << 389 G4cout << " " << psName << " was not fo 325 G4cout << " " << psName << " was not found." << G4endl; 390 } << 326 } else { 391 else << 392 { << 393 G4cout << " map size : " << map->GetSiz 327 G4cout << " map size : " << map->GetSize() << G4endl; 394 map->PrintAllHits(); 328 map->PrintAllHits(); 395 } 329 } 396 G4cout << G4endl; 330 G4cout << G4endl; 397 } 331 } 398 } 332 } 399 333 400 void G4VScoringMesh::Accumulate(G4THitsMap<G4S << 334 void G4VScoringMesh::Accumulate(G4THitsMap<G4StatDouble> * map) 401 { 335 { 402 G4String psName = map->GetName(); 336 G4String psName = map->GetName(); 403 const auto fMapItr = fMap.find(psName); << 337 MeshScoreMap::const_iterator fMapItr = fMap.find(psName); 404 if (fMapItr != fMap.cend()) { *(fMapItr->sec << 338 *(fMapItr->second) += *map; 405 339 406 if(verboseLevel > 9) << 340 if(verboseLevel > 9) { 407 { << 408 G4cout << G4endl; 341 G4cout << G4endl; 409 G4cout << "G4VScoringMesh::Accumulate()" < 342 G4cout << "G4VScoringMesh::Accumulate()" << G4endl; 410 G4cout << " PS name : " << psName << G4en 343 G4cout << " PS name : " << psName << G4endl; 411 if(fMapItr == fMap.cend()) << 344 if(fMapItr == fMap.end()) { 412 { << 413 G4cout << " " << psName << " was not fo 345 G4cout << " " << psName << " was not found." << G4endl; 414 } << 346 } else { 415 else << 416 { << 417 G4cout << " map size : " << map->GetSiz 347 G4cout << " map size : " << map->GetSize() << G4endl; 418 map->PrintAllHits(); 348 map->PrintAllHits(); 419 } 349 } 420 G4cout << G4endl; 350 G4cout << G4endl; 421 } 351 } 422 } 352 } 423 353 424 void G4VScoringMesh::Construct(G4VPhysicalVolu 354 void G4VScoringMesh::Construct(G4VPhysicalVolume* fWorldPhys) 425 { 355 { 426 if(fConstructed) << 356 if(fConstructed) { 427 { << 357 if(fGeometryHasBeenDestroyed) { 428 if(fGeometryHasBeenDestroyed) << 429 { << 430 SetupGeometry(fWorldPhys); 358 SetupGeometry(fWorldPhys); 431 fGeometryHasBeenDestroyed = false; 359 fGeometryHasBeenDestroyed = false; 432 } 360 } 433 if(verboseLevel > 0) 361 if(verboseLevel > 0) 434 G4cout << fWorldName << " --- All quanti << 362 G4cout << fWorldName << " --- All quantities are reset." >> 363 << G4endl; 435 ResetScore(); 364 ResetScore(); 436 } 365 } 437 else << 366 else { 438 { << 439 fConstructed = true; 367 fConstructed = true; 440 SetupGeometry(fWorldPhys); 368 SetupGeometry(fWorldPhys); 441 } 369 } 442 } 370 } 443 371 444 void G4VScoringMesh::WorkerConstruct(G4VPhysic 372 void G4VScoringMesh::WorkerConstruct(G4VPhysicalVolume* fWorldPhys) 445 { 373 { 446 if(fConstructed) << 374 if(fConstructed) { 447 { << 375 if(fGeometryHasBeenDestroyed) { 448 if(fGeometryHasBeenDestroyed) << 449 { << 450 fMeshElementLogical->SetSensitiveDetecto 376 fMeshElementLogical->SetSensitiveDetector(fMFD); 451 fGeometryHasBeenDestroyed = false; 377 fGeometryHasBeenDestroyed = false; 452 } 378 } 453 379 454 if(verboseLevel > 0) 380 if(verboseLevel > 0) 455 G4cout << fWorldPhys->GetName() << " --- << 381 G4cout << fWorldPhys->GetName() << " --- All quantities are reset." << G4endl; 456 << G4endl; << 457 ResetScore(); 382 ResetScore(); 458 } << 383 459 else << 384 } else { 460 { << 461 fConstructed = true; 385 fConstructed = true; 462 fMeshElementLogical->SetSensitiveDetector( 386 fMeshElementLogical->SetSensitiveDetector(fMFD); 463 } 387 } 464 } 388 } 465 389 466 void G4VScoringMesh::Merge(const G4VScoringMes << 390 void G4VScoringMesh::Merge(const G4VScoringMesh * scMesh) 467 { 391 { 468 const MeshScoreMap scMap = scMesh->GetScoreM 392 const MeshScoreMap scMap = scMesh->GetScoreMap(); 469 393 470 auto fMapItr = fMap.cbegin(); << 394 MeshScoreMap::const_iterator fMapItr = fMap.begin(); 471 auto mapItr = scMap.cbegin(); << 395 MeshScoreMap::const_iterator mapItr = scMap.begin(); 472 for(; fMapItr != fMap.cend(); ++fMapItr) << 396 for(; fMapItr != fMap.end(); fMapItr++) { 473 { << 397 if(verboseLevel > 9) G4cout << "G4VScoringMesh::Merge()" << fMapItr->first << G4endl; 474 if(verboseLevel > 9) << 475 G4cout << "G4VScoringMesh::Merge()" << f << 476 *(fMapItr->second) += *(mapItr->second); 398 *(fMapItr->second) += *(mapItr->second); 477 ++mapItr; << 399 mapItr++; 478 } 400 } 479 } 401 } >> 402 480 403