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