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