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