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 /// \file RE06/src/RE06Run.cc 26 /// \file RE06/src/RE06Run.cc 27 /// \brief Implementation of the RE06Run class 27 /// \brief Implementation of the RE06Run class 28 // 28 // >> 29 // $Id: RE06Run.cc 75123 2013-10-28 09:53:28Z gcosmo $ 29 // 30 // 30 31 31 #include "RE06Run.hh" 32 #include "RE06Run.hh" 32 << 33 #include "G4Event.hh" 33 #include "G4Event.hh" 34 #include "G4HCofThisEvent.hh" 34 #include "G4HCofThisEvent.hh" 35 #include "G4SDManager.hh" 35 #include "G4SDManager.hh" 36 36 37 //....oooOO0OOooo........oooOO0OOooo........oo 37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 38 38 39 RE06Run::RE06Run() : G4Run() << 39 RE06Run::RE06Run() >> 40 : G4Run() 40 { 41 { 41 G4String detName[6] = {"Calor-A_abs", "Calor << 42 G4String detName[6] 42 "Calor-B_gap", "Calor << 43 = {"Calor-A_abs","Calor-A_gap", 43 << 44 "Calor-B_abs","Calor-B_gap", 44 G4String primNameSum[6] = {"eDep", "nGamma", << 45 "Calor-C_abs","Calor-C_gap"}; >> 46 >> 47 G4String primNameSum[6] >> 48 = {"eDep","nGamma","nElectron","nPositron","trackLength","nStep"}; >> 49 >> 50 G4String primNameMin[3] >> 51 = {"minEkinGamma","minEkinElectron","minEkinPositron"}; 45 52 46 G4String primNameMin[3] = {"minEkinGamma", " << 53 G4String paraName[3] 47 << 54 = {"Calor-AP_para","Calor-BP_para","Calor-CP_para"}; 48 G4String paraName[3] = {"Calor-AP_para", "Ca << 49 55 50 G4SDManager* SDMan = G4SDManager::GetSDMpoin 56 G4SDManager* SDMan = G4SDManager::GetSDMpointer(); 51 G4String fullName; 57 G4String fullName; 52 size_t i, j; << 58 size_t i,j; 53 for (i = 0; i < 6; i++) { << 59 for(i=0;i<6;i++) 54 for (j = 0; j < 6; j++) { << 60 { 55 fullName = detName[i] + "/" + primNameSu << 61 for(j=0;j<6;j++) >> 62 { >> 63 fullName = detName[i]+"/"+primNameSum[j]; 56 fColIDSum[i][j] = SDMan->GetCollectionID 64 fColIDSum[i][j] = SDMan->GetCollectionID(fullName); 57 } 65 } 58 for (j = 0; j < 3; j++) { << 66 for(j=0;j<3;j++) 59 fullName = detName[i] + "/" + primNameMi << 67 { >> 68 fullName = detName[i]+"/"+primNameMin[j]; 60 fColIDMin[i][j] = SDMan->GetCollectionID 69 fColIDMin[i][j] = SDMan->GetCollectionID(fullName); 61 } 70 } 62 } 71 } 63 for (i = 0; i < 3; i++) { << 72 for(i=0;i<3;i++) 64 for (j = 0; j < 6; j++) { << 73 { 65 fullName = paraName[i] + "/" + primNameS << 74 for(j=0;j<6;j++) >> 75 { >> 76 fullName = paraName[i]+"/"+primNameSum[j]; 66 fColIDPara[i][j] = SDMan->GetCollectionI 77 fColIDPara[i][j] = SDMan->GetCollectionID(fullName); 67 } 78 } 68 } 79 } >> 80 69 } 81 } 70 82 71 //....oooOO0OOooo........oooOO0OOooo........oo 83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 72 84 73 RE06Run::~RE06Run() 85 RE06Run::~RE06Run() 74 { << 86 {;} 75 ; << 76 } << 77 87 78 //....oooOO0OOooo........oooOO0OOooo........oo 88 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 79 89 80 void RE06Run::RecordEvent(const G4Event* evt) 90 void RE06Run::RecordEvent(const G4Event* evt) 81 { 91 { 82 G4HCofThisEvent* HCE = evt->GetHCofThisEvent 92 G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); 83 if (!HCE) return; << 93 if(!HCE) return; 84 numberOfEvent++; 94 numberOfEvent++; 85 size_t i, j; << 95 size_t i,j; 86 for (i = 0; i < 6; i++) { << 96 for(i=0;i<6;i++) 87 for (j = 0; j < 6; j++) { << 97 { 88 G4THitsMap<G4double>* evtMap = (G4THitsM << 98 for(j=0;j<6;j++) >> 99 { >> 100 G4THitsMap<G4double>* evtMap >> 101 = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDSum[i][j])); 89 fMapSum[i][j] += *evtMap; 102 fMapSum[i][j] += *evtMap; 90 } 103 } 91 104 92 for (j = 0; j < 3; j++) { << 105 for(j=0;j<3;j++) 93 G4THitsMap<G4double>* evtMap = (G4THitsM << 106 { 94 std::map<G4int, G4double*>::iterator itr << 107 G4THitsMap<G4double>* evtMap 95 for (; itr != evtMap->GetMap()->end(); i << 108 = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDMin[i][j])); >> 109 std::map<G4int,G4double*>::iterator itr = evtMap->GetMap()->begin(); >> 110 for(; itr != evtMap->GetMap()->end(); itr++) >> 111 { 96 G4int key = (itr->first); 112 G4int key = (itr->first); 97 G4double val = *(itr->second); 113 G4double val = *(itr->second); 98 G4double* mapP = fMapMin[i][j][key]; 114 G4double* mapP = fMapMin[i][j][key]; 99 if (mapP && (val > *mapP)) continue; << 115 if( mapP && (val>*mapP) ) continue; 100 fMapMin[i][j].set(key, val); << 116 fMapMin[i][j].set(key,val); 101 } 117 } 102 } 118 } >> 119 103 } 120 } 104 for (i = 0; i < 3; i++) { << 121 for(i=0;i<3;i++) 105 for (j = 0; j < 6; j++) { << 122 { 106 G4THitsMap<G4double>* evtMap = (G4THitsM << 123 for(j=0;j<6;j++) >> 124 { >> 125 G4THitsMap<G4double>* evtMap >> 126 = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDPara[i][j])); 107 fMapPara[i][j] += *evtMap; 127 fMapPara[i][j] += *evtMap; 108 } 128 } 109 } 129 } 110 } 130 } 111 131 112 //....oooOO0OOooo........oooOO0OOooo........oo 132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 113 void RE06Run::Merge(const G4Run* aRun) << 133 void RE06Run::Merge(const G4Run * aRun) { 114 { << 134 const RE06Run * localRun = static_cast<const RE06Run *>(aRun); 115 const RE06Run* localRun = static_cast<const << 135 116 << 136 for(G4int i = 0; i < 6; i++) { 117 for (G4int i = 0; i < 6; i++) { << 137 for(G4int j = 0; j < 6; j++) { 118 for (G4int j = 0; j < 6; j++) { << 119 fMapSum[i][j] += localRun->fMapSum[i][j] 138 fMapSum[i][j] += localRun->fMapSum[i][j]; 120 } 139 } 121 140 122 for (G4int j = 0; j < 3; j++) { << 141 for(G4int j = 0; j < 3; j++) { 123 std::map<G4int, G4double*>::iterator itr 142 std::map<G4int, G4double*>::iterator itr = localRun->fMapMin[i][j].GetMap()->begin(); 124 for (; itr != localRun->fMapMin[i][j].Ge << 143 for(; itr != localRun->fMapMin[i][j].GetMap()->end(); itr++) { 125 G4int key = itr->first; 144 G4int key = itr->first; 126 G4double val = *(itr->second); 145 G4double val = *(itr->second); 127 G4double* mapP = fMapMin[i][j][key]; << 146 G4double * mapP = fMapMin[i][j][key]; 128 if (!mapP || val < *mapP) fMapMin[i][j << 147 if(!mapP || val < *mapP) fMapMin[i][j].set(key, val); 129 } 148 } 130 } 149 } 131 } 150 } 132 151 133 for (G4int i = 0; i < 3; i++) { << 152 for(G4int i = 0; i < 3; i++) { 134 for (G4int j = 0; j < 6; j++) { << 153 for(G4int j = 0; j < 6; j++) { 135 fMapPara[i][j] += localRun->fMapPara[i][ << 154 fMapPara[i][j] += localRun->fMapPara[i][j]; 136 } << 155 } 137 } 156 } 138 << 157 139 G4Run::Merge(aRun); 158 G4Run::Merge(aRun); 140 } 159 } 141 160 142 //....oooOO0OOooo........oooOO0OOooo........oo 161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 143 G4double RE06Run::GetTotal(const G4THitsMap<G4 << 162 G4double RE06Run::GetTotal(const G4THitsMap<G4double> &map) const 144 { 163 { 145 G4double tot = 0.; 164 G4double tot = 0.; 146 if (map.GetSize() == 0) return tot; << 165 if(map.GetSize()==0) return tot; 147 std::map<G4int, G4double*>::iterator itr = m << 166 std::map<G4int,G4double*>::iterator itr = map.GetMap()->begin(); 148 for (; itr != map.GetMap()->end(); itr++) { << 167 for(; itr != map.GetMap()->end(); itr++) 149 tot += *(itr->second); << 168 { tot += *(itr->second); } 150 } << 151 return tot; 169 return tot; 152 } 170 } 153 171 154 //....oooOO0OOooo........oooOO0OOooo........oo 172 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 155 173 156 G4double RE06Run::FindMinimum(const G4THitsMap << 174 G4double RE06Run::FindMinimum(const G4THitsMap<G4double> &map) const 157 { 175 { 158 G4double val = DBL_MAX; 176 G4double val = DBL_MAX; 159 177 160 if (map.GetSize() == 0) return val; << 178 if(map.GetSize()==0) return val; 161 std::map<G4int, G4double*>::iterator itr = m << 179 std::map<G4int,G4double*>::iterator itr = map.GetMap()->begin(); 162 for (; itr != map.GetMap()->end(); itr++) { << 180 for(; itr != map.GetMap()->end(); itr++) 163 if (val > *(itr->second)) val = *(itr->sec << 181 { if(val>*(itr->second)) val = *(itr->second); } 164 } << 165 return val; 182 return val; 166 } 183 } 167 184 168 //....oooOO0OOooo........oooOO0OOooo........oo 185 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 169 186