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: G4PSPopulation.cc,v 1.1 2007/07/11 01:31:03 asaim Exp $ >> 28 // GEANT4 tag $Name: geant4-09-02 $ 27 // 29 // 28 // G4PSPopulation 30 // G4PSPopulation 29 #include "G4PSPopulation.hh" 31 #include "G4PSPopulation.hh" 30 32 >> 33 31 ////////////////////////////////////////////// 34 /////////////////////////////////////////////////////////////////////////////// 32 // (Description) 35 // (Description) 33 // This is a primitive scorer class for scor 36 // This is a primitive scorer class for scoring population in a cell. 34 // 37 // 35 // Created: 2007-02-02 Tsukasa ASO, Akinori K 38 // Created: 2007-02-02 Tsukasa ASO, Akinori Kimura. 36 // 2010-07-22 Introduce Unit specification. << 37 // 39 // 38 ////////////////////////////////////////////// 40 /////////////////////////////////////////////////////////////////////////////// 39 41 40 G4PSPopulation::G4PSPopulation(const G4String& << 42 G4PSPopulation::G4PSPopulation(G4String name, G4int depth) 41 : G4VPrimitiveScorer(name, depth) << 43 :G4VPrimitiveScorer(name,depth),HCID(-1),weighted(false) 42 { << 44 {;} 43 SetUnit(""); << 45 44 } << 46 G4PSPopulation::~G4PSPopulation() >> 47 {;} 45 48 46 G4bool G4PSPopulation::ProcessHits(G4Step* aSt << 49 G4bool G4PSPopulation::ProcessHits(G4Step* aStep,G4TouchableHistory*) 47 { 50 { 48 G4int index = GetIndex(aStep); << 51 >> 52 G4int index = GetIndex(aStep); 49 G4TrackLogger& tlog = fCellTrackLogger[index 53 G4TrackLogger& tlog = fCellTrackLogger[index]; 50 if(tlog.FirstEnterance(aStep->GetTrack()->Ge << 54 if (tlog.FirstEnterance(aStep->GetTrack()->GetTrackID())) { 51 { << 55 G4double val = 1.0; 52 G4double val = 1.0; << 56 if(weighted) val *= aStep->GetPreStepPoint()->GetWeight(); 53 if(weighted) << 57 EvtMap->add(index,val); 54 val *= aStep->GetPreStepPoint()->GetWeig << 55 EvtMap->add(index, val); << 56 } 58 } 57 59 58 return true; << 60 return TRUE; 59 } 61 } 60 62 61 void G4PSPopulation::Initialize(G4HCofThisEven 63 void G4PSPopulation::Initialize(G4HCofThisEvent* HCE) 62 { 64 { 63 EvtMap = new G4THitsMap<G4double>(detector-> << 65 EvtMap = new G4THitsMap<G4double>(detector->GetName(),GetName()); 64 if(HCID < 0) << 66 if(HCID < 0) {HCID = GetCollectionID(0);} 65 { << 67 HCE->AddHitsCollection(HCID, (G4VHitsCollection*)EvtMap); 66 HCID = GetCollectionID(0); << 67 } << 68 HCE->AddHitsCollection(HCID, (G4VHitsCollect << 69 } 68 } 70 69 71 void G4PSPopulation::EndOfEvent(G4HCofThisEven << 70 void G4PSPopulation::EndOfEvent(G4HCofThisEvent*) 72 << 73 void G4PSPopulation::clear() << 74 { 71 { >> 72 fCellTrackLogger.clear(); >> 73 } >> 74 >> 75 void G4PSPopulation::clear(){ 75 EvtMap->clear(); 76 EvtMap->clear(); 76 fCellTrackLogger.clear(); 77 fCellTrackLogger.clear(); 77 } 78 } 78 79 >> 80 void G4PSPopulation::DrawAll() >> 81 {;} >> 82 79 void G4PSPopulation::PrintAll() 83 void G4PSPopulation::PrintAll() 80 { 84 { 81 G4cout << " MultiFunctionalDet " << detecto 85 G4cout << " MultiFunctionalDet " << detector->GetName() << G4endl; 82 G4cout << " PrimitiveScorer " << GetName() < 86 G4cout << " PrimitiveScorer " << GetName() << G4endl; 83 G4cout << " Number of entries " << EvtMap->e 87 G4cout << " Number of entries " << EvtMap->entries() << G4endl; 84 for(const auto& [copy, population] : *(EvtMa << 88 std::map<G4int,G4double*>::iterator itr = EvtMap->GetMap()->begin(); 85 { << 89 for(; itr != EvtMap->GetMap()->end(); itr++) { 86 G4cout << " copy no.: " << copy << 90 G4cout << " copy no.: " << itr->first 87 << " population: " << *(population << 91 << " population: " << *(itr->second) 88 << G4endl; << 92 << G4endl; 89 } 93 } 90 } 94 } 91 95 92 void G4PSPopulation::SetUnit(const G4String& u << 93 { << 94 if(unit.empty()) << 95 { << 96 unitName = unit; << 97 unitValue = 1.0; << 98 } << 99 else << 100 { << 101 G4String msg = "Invalid unit [" + unit + " << 102 GetUnit() + "] ) for " + Ge << 103 G4Exception("G4PSPopulation::SetUnit", "De << 104 } << 105 } << 106 96