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 biasing/B03/src/B03RunAction.cc 26 /// \file biasing/B03/src/B03RunAction.cc 27 /// \brief Implementation of the B03RunAction 27 /// \brief Implementation of the B03RunAction class 28 // 28 // 29 // 29 // 30 // << 30 // $Id: B03RunAction.cc 72953 2013-08-14 14:13:36Z gcosmo $ >> 31 // 31 #include "B03RunAction.hh" 32 #include "B03RunAction.hh" 32 << 33 #include "B03Run.hh" 33 #include "B03Run.hh" 34 34 35 //-- In order to obtain detector information. 35 //-- In order to obtain detector information. 36 #include "B03ImportanceDetectorConstruction.hh << 37 << 38 #include "G4RunManager.hh" 36 #include "G4RunManager.hh" >> 37 #include "B03ImportanceDetectorConstruction.hh" 39 #include "G4THitsMap.hh" 38 #include "G4THitsMap.hh" >> 39 40 #include "G4UnitsTable.hh" 40 #include "G4UnitsTable.hh" 41 41 42 //....oooOO0OOooo........oooOO0OOooo........oo 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 43 43 44 // B03RunAction 44 // B03RunAction 45 // << 45 // 46 // 46 // 47 // 47 // 48 48 49 //....oooOO0OOooo........oooOO0OOooo........oo 49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 50 50 51 // Constructor 51 // Constructor 52 B03RunAction::B03RunAction() << 52 B03RunAction::B03RunAction(): 53 : G4UserRunAction(), << 53 G4UserRunAction(), 54 // fFieldName(15), << 54 // fFieldName(15), 55 fFieldValue(14) << 55 fFieldValue(14) 56 { 56 { 57 // - Prepare data member for B03Run. 57 // - Prepare data member for B03Run. 58 // vector represents a list of MultiFuncti 58 // vector represents a list of MultiFunctionalDetector names. 59 fSDName.push_back(G4String("ConcreteSD")); 59 fSDName.push_back(G4String("ConcreteSD")); 60 } 60 } 61 61 62 //....oooOO0OOooo........oooOO0OOooo........oo 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 63 64 // Destructor. 64 // Destructor. 65 B03RunAction::~B03RunAction() 65 B03RunAction::~B03RunAction() 66 { 66 { 67 fSDName.clear(); 67 fSDName.clear(); 68 } 68 } 69 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 71 71 72 G4Run* B03RunAction::GenerateRun() 72 G4Run* B03RunAction::GenerateRun() 73 { 73 { 74 // Generate new RUN object, which is special 74 // Generate new RUN object, which is specially 75 // dedicated for MultiFunctionalDetector sch 75 // dedicated for MultiFunctionalDetector scheme. 76 // Detail description can be found in B03Ru 76 // Detail description can be found in B03Run.hh/cc. 77 return new B03Run(fSDName); 77 return new B03Run(fSDName); 78 } 78 } 79 79 80 //....oooOO0OOooo........oooOO0OOooo........oo 80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 81 81 82 void B03RunAction::BeginOfRunAction(const G4Ru 82 void B03RunAction::BeginOfRunAction(const G4Run* aRun) 83 { 83 { 84 G4cout << "### Run " << aRun->GetRunID() << 84 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; 85 } 85 } 86 86 87 //....oooOO0OOooo........oooOO0OOooo........oo 87 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 88 88 89 void B03RunAction::EndOfRunAction(const G4Run* 89 void B03RunAction::EndOfRunAction(const G4Run* aRun) 90 { 90 { 91 G4cout << " ###### EndOfRunAction " << G4en << 91 G4cout << " ###### EndOfRunAction " <<G4endl; 92 //- B03Run object. 92 //- B03Run object. 93 B03Run* b02Run = (B03Run*)aRun; 93 B03Run* b02Run = (B03Run*)aRun; 94 //--- Dump all socred quantities involved in 94 //--- Dump all socred quantities involved in B03Run. 95 // b02Run->DumpAllScorer(); 95 // b02Run->DumpAllScorer(); 96 //--- 96 //--- 97 G4RunManager* mgr = G4RunManager::GetRunMana 97 G4RunManager* mgr = G4RunManager::GetRunManager(); 98 // 98 // 99 << 99 100 for (G4int i = 0; i < (G4int)fSDName.size(); << 100 for ( G4int i = 0; i < (G4int)fSDName.size(); i++ ){ 101 const G4VUserDetectorConstruction* vdet = << 101 const G4VUserDetectorConstruction* vdet = >> 102 mgr->GetUserDetectorConstruction(); 102 // B03DetectorConstruction* bdet = (B03 103 // B03DetectorConstruction* bdet = (B03DetectorConstruction*)vdet; 103 B03ImportanceDetectorConstruction* bdet = << 104 B03ImportanceDetectorConstruction* bdet = >> 105 (B03ImportanceDetectorConstruction*)vdet; 104 // 106 // 105 << 107 106 //---------------------------------------- 108 //--------------------------------------------- 107 // Dump accumulated quantities for this RU 109 // Dump accumulated quantities for this RUN. 108 // (Display only central region of x-y pl 110 // (Display only central region of x-y plane) 109 // 0 ConcreteSD/Collisions 111 // 0 ConcreteSD/Collisions 110 // 1 ConcreteSD/CollWeight 112 // 1 ConcreteSD/CollWeight 111 // 2 ConcreteSD/Population 113 // 2 ConcreteSD/Population 112 // 3 ConcreteSD/TrackEnter 114 // 3 ConcreteSD/TrackEnter 113 // 4 ConcreteSD/SL 115 // 4 ConcreteSD/SL 114 // 5 ConcreteSD/SLW 116 // 5 ConcreteSD/SLW 115 // 6 ConcreteSD/SLWE 117 // 6 ConcreteSD/SLWE 116 // 7 ConcreteSD/SLW_V 118 // 7 ConcreteSD/SLW_V 117 // 8 ConcreteSD/SLWE_V 119 // 8 ConcreteSD/SLWE_V 118 //---------------------------------------- 120 //--------------------------------------------- 119 G4THitsMap<G4double>* Collisions = b02Run- << 121 G4THitsMap<G4double>* Collisions = 120 G4THitsMap<G4double>* CollWeight = b02Run- << 122 b02Run->GetHitsMap(fSDName[i]+"/Collisions"); 121 G4THitsMap<G4double>* Population = b02Run- << 123 G4THitsMap<G4double>* CollWeight = 122 G4THitsMap<G4double>* TrackEnter = b02Run- << 124 b02Run->GetHitsMap(fSDName[i]+"/CollWeight"); 123 G4THitsMap<G4double>* SL = b02Run->GetHits << 125 G4THitsMap<G4double>* Population = 124 G4THitsMap<G4double>* SLW = b02Run->GetHit << 126 b02Run->GetHitsMap(fSDName[i]+"/Population"); 125 G4THitsMap<G4double>* SLWE = b02Run->GetHi << 127 G4THitsMap<G4double>* TrackEnter = 126 G4THitsMap<G4double>* SLW_V = b02Run->GetH << 128 b02Run->GetHitsMap(fSDName[i]+"/TrackEnter"); 127 G4THitsMap<G4double>* SLWE_V = b02Run->Get << 129 G4THitsMap<G4double>* SL = 128 << 130 b02Run->GetHitsMap(fSDName[i]+"/SL"); 129 if (IsMaster()) { << 131 G4THitsMap<G4double>* SLW = 130 G4cout << "\n--------------------End of << 132 b02Run->GetHitsMap(fSDName[i]+"/SLW"); 131 G4cout << " Number of event processed : << 133 G4THitsMap<G4double>* SLWE = 132 } << 134 b02Run->GetHitsMap(fSDName[i]+"/SLWE"); 133 else { << 135 G4THitsMap<G4double>* SLW_V = 134 G4cout << "\n--------------------End of << 136 b02Run->GetHitsMap(fSDName[i]+"/SLW_V"); 135 G4cout << " Number of event processed : << 137 G4THitsMap<G4double>* SLWE_V = 136 } << 138 b02Run->GetHitsMap(fSDName[i]+"/SLWE_V"); >> 139 >> 140 if (IsMaster()) >> 141 { >> 142 G4cout << >> 143 "\n--------------------End of Global Run-----------------------" << >> 144 G4endl; >> 145 G4cout << >> 146 " Number of event processed : "<< aRun->GetNumberOfEvent() << G4endl; >> 147 } >> 148 else >> 149 { >> 150 G4cout << >> 151 "\n--------------------End of Local Run------------------------" << >> 152 G4endl; >> 153 G4cout << " Number of event processed : "<< aRun->GetNumberOfEvent() << >> 154 G4endl; >> 155 } >> 156 >> 157 G4cout << "=============================================================" >> 158 <<G4endl; >> 159 G4cout << "=============================================================" >> 160 <<G4endl; 137 161 138 G4cout << "=============================== << 139 G4cout << "=============================== << 140 162 141 std::ostream* myout = &G4cout; << 163 std::ostream *myout = &G4cout; 142 PrintHeader(myout); 164 PrintHeader(myout); 143 165 144 for (G4int iz = 0; iz < 20; iz++) { << 166 for ( G4int iz = 0; iz < 20; iz++){ 145 G4double* SumCollisions = (*Collisions)[ 167 G4double* SumCollisions = (*Collisions)[iz]; 146 G4double* SumCollWeight = (*CollWeight)[ 168 G4double* SumCollWeight = (*CollWeight)[iz]; 147 G4double* Populations = (*Population)[iz << 169 G4double* Populations = (*Population)[iz]; 148 G4double* TrackEnters = (*TrackEnter)[iz << 170 G4double* TrackEnters = (*TrackEnter)[iz]; 149 G4double* SLs = (*SL)[iz]; << 171 G4double* SLs = (*SL)[iz]; 150 G4double* SLWs = (*SLW)[iz]; << 172 G4double* SLWs = (*SLW)[iz]; 151 G4double* SLWEs = (*SLWE)[iz]; << 173 G4double* SLWEs = (*SLWE)[iz]; 152 G4double* SLW_Vs = (*SLW_V)[iz]; << 174 G4double* SLW_Vs = (*SLW_V)[iz]; 153 G4double* SLWE_Vs = (*SLWE_V)[iz]; << 175 G4double* SLWE_Vs = (*SLWE_V)[iz]; 154 if (!SumCollisions) SumCollisions = new << 176 if ( !SumCollisions ) SumCollisions = new G4double(0.0); 155 if (!SumCollWeight) SumCollWeight = new << 177 if ( !SumCollWeight ) SumCollWeight = new G4double(0.0); 156 if (!Populations) Populations = new G4do << 178 if ( !Populations ) Populations = new G4double(0.0); 157 if (!TrackEnters) { << 179 if ( !TrackEnters ) { G4cout << " NO TRACKS - WHY? " << G4endl; 158 G4cout << " NO TRACKS - WHY? " << G4en << 180 TrackEnters = new G4double(0.0);} 159 TrackEnters = new G4double(0.0); << 181 if ( !SLs ) SLs = new G4double(0.0); 160 } << 182 if ( !SLWs ) SLWs = new G4double(0.0); 161 if (!SLs) SLs = new G4double(0.0); << 183 if ( !SLWEs ) SLWEs = new G4double(0.0); 162 if (!SLWs) SLWs = new G4double(0.0); << 184 if ( !SLW_Vs ) SLW_Vs = new G4double(0.0); 163 if (!SLWEs) SLWEs = new G4double(0.0); << 185 if ( !SLWE_Vs ) SLWE_Vs = new G4double(0.0); 164 if (!SLW_Vs) SLW_Vs = new G4double(0.0); << 186 G4double NumWeightedEnergy =0.0; 165 if (!SLWE_Vs) SLWE_Vs = new G4double(0.0 << 187 G4double FluxWeightedEnergy=0.0; 166 G4double NumWeightedEnergy = 0.0; << 188 G4double AverageTrackWeight=0.0; 167 G4double FluxWeightedEnergy = 0.0; << 189 if ( *SLW_Vs !=0. ) NumWeightedEnergy = (*SLWE_Vs)/(*SLW_Vs); 168 G4double AverageTrackWeight = 0.0; << 190 if ( *SLWs !=0. ) FluxWeightedEnergy = (*SLWEs)/(*SLWs); 169 if (*SLW_Vs != 0.) NumWeightedEnergy = ( << 191 if ( *SLs !=0. ) AverageTrackWeight = (*SLWs)/(*SLs); 170 if (*SLWs != 0.) FluxWeightedEnergy = (* << 171 if (*SLs != 0.) AverageTrackWeight = (*S << 172 G4String cname = bdet->GetCellName(iz); 192 G4String cname = bdet->GetCellName(iz); 173 G4cout << std::setw(fFieldValue) << cnam << 193 G4cout 174 << " |" << std::setw(fFieldValue) << 194 << std::setw(fFieldValue) << cname << " |" 175 << (*SumCollisions) << " |" << st << 195 << std::setw(fFieldValue) << (*TrackEnters) << " |" 176 << std::setw(fFieldValue) << NumW << 196 << std::setw(fFieldValue) << (*Populations) << " |" 177 << FluxWeightedEnergy << " |" << << 197 << std::setw(fFieldValue) << (*SumCollisions) << " |" 178 << std::setw(fFieldValue) << (*SL << 198 << std::setw(fFieldValue) << (*SumCollWeight) << " |" 179 << " |" << std::setw(fFieldValue) << 199 << std::setw(fFieldValue) << NumWeightedEnergy << " |" 180 << (*SLWEs) << " |" << std::setw( << 200 << std::setw(fFieldValue) << FluxWeightedEnergy << " |" >> 201 << std::setw(fFieldValue) << AverageTrackWeight << " |" >> 202 << std::setw(fFieldValue) << (*SLs) << " |" >> 203 << std::setw(fFieldValue) << (*SLWs) << " |" >> 204 << std::setw(fFieldValue) << (*SLW_Vs) << " |" >> 205 << std::setw(fFieldValue) << (*SLWEs) << " |" >> 206 << std::setw(fFieldValue) << (*SLWE_Vs) << " |" >> 207 << G4endl; 181 } 208 } 182 G4cout << "=============================== << 209 G4cout << "============================================="<<G4endl; 183 } 210 } 184 } 211 } 185 212 186 //....oooOO0OOooo........oooOO0OOooo........oo 213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 187 214 188 void B03RunAction::PrintHeader(std::ostream* o << 215 void B03RunAction::PrintHeader(std::ostream *out) 189 { 216 { 190 std::vector<G4String> vecScoreName; 217 std::vector<G4String> vecScoreName; 191 vecScoreName.push_back("Tr.Entering"); 218 vecScoreName.push_back("Tr.Entering"); 192 vecScoreName.push_back("Population"); 219 vecScoreName.push_back("Population"); 193 vecScoreName.push_back("Collisions"); 220 vecScoreName.push_back("Collisions"); 194 vecScoreName.push_back("Coll*WGT"); 221 vecScoreName.push_back("Coll*WGT"); 195 vecScoreName.push_back("NumWGTedE"); 222 vecScoreName.push_back("NumWGTedE"); 196 vecScoreName.push_back("FluxWGTedE"); 223 vecScoreName.push_back("FluxWGTedE"); 197 vecScoreName.push_back("Av.Tr.WGT"); 224 vecScoreName.push_back("Av.Tr.WGT"); 198 vecScoreName.push_back("SL"); 225 vecScoreName.push_back("SL"); 199 vecScoreName.push_back("SLW"); 226 vecScoreName.push_back("SLW"); 200 vecScoreName.push_back("SLW_v"); 227 vecScoreName.push_back("SLW_v"); 201 vecScoreName.push_back("SLWE"); 228 vecScoreName.push_back("SLWE"); 202 vecScoreName.push_back("SLWE_v"); 229 vecScoreName.push_back("SLWE_v"); 203 230 204 // head line 231 // head line 205 // std::string vname = FillString("Volume", << 232 //std::string vname = FillString("Volume", ' ', FieldName+1); 206 //*out << vname << '|'; 233 //*out << vname << '|'; 207 std::string vname; 234 std::string vname; 208 *out << std::setw(fFieldValue) << "Volume" << 235 *out << std::setw(fFieldValue) << "Volume" << " |"; 209 << " |"; << 236 for (std::vector<G4String>::iterator it = vecScoreName.begin(); 210 for (std::vector<G4String>::iterator it = ve << 237 it != vecScoreName.end(); it++) { 211 // vname = FillString((*it), << 238 //vname = FillString((*it), 212 // ' ', << 239 // ' ', 213 // fFieldValue+1, << 240 // fFieldValue+1, 214 // false); << 241 // false); 215 // *out << vname << '|'; << 242 // *out << vname << '|'; 216 *out << std::setw(fFieldValue) << (*it) << << 243 *out << std::setw(fFieldValue) << (*it) << " |"; 217 } 244 } 218 *out << G4endl; << 245 *out << G4endl; 219 } 246 } 220 247 221 //....oooOO0OOooo........oooOO0OOooo........oo 248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 222 249 223 std::string B03RunAction::FillString(const std << 250 std::string B03RunAction::FillString(const std::string &name, >> 251 char c, G4int n, G4bool back) 224 { 252 { 225 std::string fname(""); 253 std::string fname(""); 226 G4int k = n - name.size(); 254 G4int k = n - name.size(); 227 if (k > 0) { 255 if (k > 0) { 228 if (back) { 256 if (back) { 229 fname = name; 257 fname = name; 230 fname += std::string(k, c); << 258 fname += std::string(k,c); 231 } 259 } 232 else { 260 else { 233 fname = std::string(k, c); << 261 fname = std::string(k,c); 234 fname += name; 262 fname += name; 235 } 263 } 236 } 264 } 237 else { 265 else { 238 fname = name; 266 fname = name; 239 } 267 } 240 return fname; 268 return fname; 241 } 269 } 242 270 243 //....oooOO0OOooo........oooOO0OOooo........oo 271 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 244 272