Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 /// \file RE06/src/RE06Run.cc 27 /// \brief Implementation of the RE06Run class 28 // 29 // 30 31 #include "RE06Run.hh" 32 33 #include "G4Event.hh" 34 #include "G4HCofThisEvent.hh" 35 #include "G4SDManager.hh" 36 37 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 38 39 RE06Run::RE06Run() : G4Run() 40 { 41 G4String detName[6] = {"Calor-A_abs", "Calor-A_gap", "Calor-B_abs", 42 "Calor-B_gap", "Calor-C_abs", "Calor-C_gap"}; 43 44 G4String primNameSum[6] = {"eDep", "nGamma", "nElectron", "nPositron", "trackLength", "nStep"}; 45 46 G4String primNameMin[3] = {"minEkinGamma", "minEkinElectron", "minEkinPositron"}; 47 48 G4String paraName[3] = {"Calor-AP_para", "Calor-BP_para", "Calor-CP_para"}; 49 50 G4SDManager* SDMan = G4SDManager::GetSDMpointer(); 51 G4String fullName; 52 size_t i, j; 53 for (i = 0; i < 6; i++) { 54 for (j = 0; j < 6; j++) { 55 fullName = detName[i] + "/" + primNameSum[j]; 56 fColIDSum[i][j] = SDMan->GetCollectionID(fullName); 57 } 58 for (j = 0; j < 3; j++) { 59 fullName = detName[i] + "/" + primNameMin[j]; 60 fColIDMin[i][j] = SDMan->GetCollectionID(fullName); 61 } 62 } 63 for (i = 0; i < 3; i++) { 64 for (j = 0; j < 6; j++) { 65 fullName = paraName[i] + "/" + primNameSum[j]; 66 fColIDPara[i][j] = SDMan->GetCollectionID(fullName); 67 } 68 } 69 } 70 71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 72 73 RE06Run::~RE06Run() 74 { 75 ; 76 } 77 78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 79 80 void RE06Run::RecordEvent(const G4Event* evt) 81 { 82 G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); 83 if (!HCE) return; 84 numberOfEvent++; 85 size_t i, j; 86 for (i = 0; i < 6; i++) { 87 for (j = 0; j < 6; j++) { 88 G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDSum[i][j])); 89 fMapSum[i][j] += *evtMap; 90 } 91 92 for (j = 0; j < 3; j++) { 93 G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDMin[i][j])); 94 std::map<G4int, G4double*>::iterator itr = evtMap->GetMap()->begin(); 95 for (; itr != evtMap->GetMap()->end(); itr++) { 96 G4int key = (itr->first); 97 G4double val = *(itr->second); 98 G4double* mapP = fMapMin[i][j][key]; 99 if (mapP && (val > *mapP)) continue; 100 fMapMin[i][j].set(key, val); 101 } 102 } 103 } 104 for (i = 0; i < 3; i++) { 105 for (j = 0; j < 6; j++) { 106 G4THitsMap<G4double>* evtMap = (G4THitsMap<G4double>*)(HCE->GetHC(fColIDPara[i][j])); 107 fMapPara[i][j] += *evtMap; 108 } 109 } 110 } 111 112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 113 void RE06Run::Merge(const G4Run* aRun) 114 { 115 const RE06Run* localRun = static_cast<const RE06Run*>(aRun); 116 117 for (G4int i = 0; i < 6; i++) { 118 for (G4int j = 0; j < 6; j++) { 119 fMapSum[i][j] += localRun->fMapSum[i][j]; 120 } 121 122 for (G4int j = 0; j < 3; j++) { 123 std::map<G4int, G4double*>::iterator itr = localRun->fMapMin[i][j].GetMap()->begin(); 124 for (; itr != localRun->fMapMin[i][j].GetMap()->end(); itr++) { 125 G4int key = itr->first; 126 G4double val = *(itr->second); 127 G4double* mapP = fMapMin[i][j][key]; 128 if (!mapP || val < *mapP) fMapMin[i][j].set(key, val); 129 } 130 } 131 } 132 133 for (G4int i = 0; i < 3; i++) { 134 for (G4int j = 0; j < 6; j++) { 135 fMapPara[i][j] += localRun->fMapPara[i][j]; 136 } 137 } 138 139 G4Run::Merge(aRun); 140 } 141 142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 143 G4double RE06Run::GetTotal(const G4THitsMap<G4double>& map) const 144 { 145 G4double tot = 0.; 146 if (map.GetSize() == 0) return tot; 147 std::map<G4int, G4double*>::iterator itr = map.GetMap()->begin(); 148 for (; itr != map.GetMap()->end(); itr++) { 149 tot += *(itr->second); 150 } 151 return tot; 152 } 153 154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 155 156 G4double RE06Run::FindMinimum(const G4THitsMap<G4double>& map) const 157 { 158 G4double val = DBL_MAX; 159 160 if (map.GetSize() == 0) return val; 161 std::map<G4int, G4double*>::iterator itr = map.GetMap()->begin(); 162 for (; itr != map.GetMap()->end(); itr++) { 163 if (val > *(itr->second)) val = *(itr->second); 164 } 165 return val; 166 } 167 168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 169