Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // Gorad (Geant4 Open-source Radiation Analys 27 // 28 // Author : Makoto Asai (SLAC National Accele 29 // 30 // Development of Gorad is funded by NASA Joh 31 // under the contract NNJ15HK11B. 32 // 33 // ******************************************* 34 // 35 // GRRun.cc 36 // Gorad Run class that handles filling hist 37 // with scores accumulated by scoeres for ea 38 // 39 // History 40 // September 8th, 2020 : first implementatio 41 // 42 // ******************************************* 43 44 #include "GRRun.hh" 45 #include "GRRunAction.hh" 46 47 #include "G4AnalysisManager.hh" 48 #include "G4MultiFunctionalDetector.hh" 49 #include "G4VPrimitiveScorer.hh" 50 51 #include "G4PrimaryVertex.hh" 52 #include "G4PrimaryParticle.hh" 53 54 GRRun::GRRun(GRRunAction* ra) : G4Run(),pRA(ra 55 { 56 ; 57 } 58 59 GRRun::~GRRun() 60 { 61 ; 62 } 63 64 void GRRun::RecordEvent(const G4Event* anEvent 65 { 66 67 numberOfEvent++; // This is an original lin 68 69 G4HCofThisEvent* pHCE = anEvent->GetHCofThis 70 71 auto analysisManager = G4AnalysisManager::In 72 auto map = pRA->IDMap; 73 for(auto itr : map) 74 { 75 if(itr.second->pplotter!=nullptr) continue 76 77 auto cID = itr.second->collID; 78 auto hID = itr.second->histID; 79 auto hTyp = itr.second->histType; 80 81 if(hTyp==1) // 1D histogram 82 { 83 if(cID>=0) // scorer 84 { 85 if(!pHCE) continue; 86 auto score = (G4THitsMap<G4double>*)(p 87 G4double val = 0.; 88 for(auto hItr : *score) 89 { 90 if(itr.second->idx==-1 || itr.second 91 { val += *(hItr.second); } 92 } 93 analysisManager->FillH1(hID,val); 94 } 95 else // primary particle 96 { 97 auto pv = anEvent->GetPrimaryVertex(); 98 while(pv) 99 { 100 auto pp = pv->GetPrimary(); 101 while(pp) 102 { 103 auto primE = pp->GetKineticEnergy( 104 G4double weight = 1.0; 105 if(itr.second->biasf) weight = pp- 106 analysisManager->FillH1(hID,primE, 107 pp = pp->GetNext(); 108 } 109 pv = pv->GetNext(); 110 } 111 } 112 } 113 114 else if(hTyp==2) // 1D profile plot 115 { 116 if(!pHCE) continue; 117 auto score = (G4THitsMap<G4double>*)(pHC 118 for(auto hItr : *score) 119 { analysisManager->FillP1(hID,G4double(h 120 } 121 122 } 123 124 auto ntmap = pRA->NTMap; 125 if(ntmap.size()>0) 126 { 127 for(auto ntitr : ntmap) 128 { 129 auto colID = ntitr.first; 130 auto cID = ntitr.second->collID; 131 G4double val = 0.; 132 if(cID>=0) 133 { 134 if(!pHCE) continue; 135 auto score = (G4THitsMap<G4double>*)(p 136 for(auto hItr : *score) 137 { 138 if(ntitr.second->idx==-1 || ntitr.se 139 { val += *(hItr.second); } 140 } 141 } 142 else 143 { 144 auto pv = anEvent->GetPrimaryVertex(); 145 auto pp = pv->GetPrimary(); 146 val = pp->GetKineticEnergy(); 147 } 148 analysisManager->FillNtupleDColumn(colID 149 } 150 analysisManager->AddNtupleRow(); 151 } 152 153 } 154 155 void GRRun::Merge(const G4Run * aRun) 156 { 157 G4Run::Merge(aRun); 158 } 159 160 161