Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 /// \file biasing/B03/src/B03RunAction.cc 27 /// \brief Implementation of the B03RunAction 28 // 29 // 30 // 31 #include "B03RunAction.hh" 32 33 #include "B03Run.hh" 34 35 //-- In order to obtain detector information. 36 #include "B03ImportanceDetectorConstruction.hh 37 38 #include "G4RunManager.hh" 39 #include "G4THitsMap.hh" 40 #include "G4UnitsTable.hh" 41 42 //....oooOO0OOooo........oooOO0OOooo........oo 43 44 // B03RunAction 45 // 46 // 47 // 48 49 //....oooOO0OOooo........oooOO0OOooo........oo 50 51 // Constructor 52 B03RunAction::B03RunAction() 53 : G4UserRunAction(), 54 // fFieldName(15), 55 fFieldValue(14) 56 { 57 // - Prepare data member for B03Run. 58 // vector represents a list of MultiFuncti 59 fSDName.push_back(G4String("ConcreteSD")); 60 } 61 62 //....oooOO0OOooo........oooOO0OOooo........oo 63 64 // Destructor. 65 B03RunAction::~B03RunAction() 66 { 67 fSDName.clear(); 68 } 69 70 //....oooOO0OOooo........oooOO0OOooo........oo 71 72 G4Run* B03RunAction::GenerateRun() 73 { 74 // Generate new RUN object, which is special 75 // dedicated for MultiFunctionalDetector sch 76 // Detail description can be found in B03Ru 77 return new B03Run(fSDName); 78 } 79 80 //....oooOO0OOooo........oooOO0OOooo........oo 81 82 void B03RunAction::BeginOfRunAction(const G4Ru 83 { 84 G4cout << "### Run " << aRun->GetRunID() << 85 } 86 87 //....oooOO0OOooo........oooOO0OOooo........oo 88 89 void B03RunAction::EndOfRunAction(const G4Run* 90 { 91 G4cout << " ###### EndOfRunAction " << G4en 92 //- B03Run object. 93 B03Run* b02Run = (B03Run*)aRun; 94 //--- Dump all socred quantities involved in 95 // b02Run->DumpAllScorer(); 96 //--- 97 G4RunManager* mgr = G4RunManager::GetRunMana 98 // 99 100 for (G4int i = 0; i < (G4int)fSDName.size(); 101 const G4VUserDetectorConstruction* vdet = 102 // B03DetectorConstruction* bdet = (B03 103 B03ImportanceDetectorConstruction* bdet = 104 // 105 106 //---------------------------------------- 107 // Dump accumulated quantities for this RU 108 // (Display only central region of x-y pl 109 // 0 ConcreteSD/Collisions 110 // 1 ConcreteSD/CollWeight 111 // 2 ConcreteSD/Population 112 // 3 ConcreteSD/TrackEnter 113 // 4 ConcreteSD/SL 114 // 5 ConcreteSD/SLW 115 // 6 ConcreteSD/SLWE 116 // 7 ConcreteSD/SLW_V 117 // 8 ConcreteSD/SLWE_V 118 //---------------------------------------- 119 G4THitsMap<G4double>* Collisions = b02Run- 120 G4THitsMap<G4double>* CollWeight = b02Run- 121 G4THitsMap<G4double>* Population = b02Run- 122 G4THitsMap<G4double>* TrackEnter = b02Run- 123 G4THitsMap<G4double>* SL = b02Run->GetHits 124 G4THitsMap<G4double>* SLW = b02Run->GetHit 125 G4THitsMap<G4double>* SLWE = b02Run->GetHi 126 G4THitsMap<G4double>* SLW_V = b02Run->GetH 127 G4THitsMap<G4double>* SLWE_V = b02Run->Get 128 129 if (IsMaster()) { 130 G4cout << "\n--------------------End of 131 G4cout << " Number of event processed : 132 } 133 else { 134 G4cout << "\n--------------------End of 135 G4cout << " Number of event processed : 136 } 137 138 G4cout << "=============================== 139 G4cout << "=============================== 140 141 std::ostream* myout = &G4cout; 142 PrintHeader(myout); 143 144 for (G4int iz = 0; iz < 20; iz++) { 145 G4double* SumCollisions = (*Collisions)[ 146 G4double* SumCollWeight = (*CollWeight)[ 147 G4double* Populations = (*Population)[iz 148 G4double* TrackEnters = (*TrackEnter)[iz 149 G4double* SLs = (*SL)[iz]; 150 G4double* SLWs = (*SLW)[iz]; 151 G4double* SLWEs = (*SLWE)[iz]; 152 G4double* SLW_Vs = (*SLW_V)[iz]; 153 G4double* SLWE_Vs = (*SLWE_V)[iz]; 154 if (!SumCollisions) SumCollisions = new 155 if (!SumCollWeight) SumCollWeight = new 156 if (!Populations) Populations = new G4do 157 if (!TrackEnters) { 158 G4cout << " NO TRACKS - WHY? " << G4en 159 TrackEnters = new G4double(0.0); 160 } 161 if (!SLs) SLs = new G4double(0.0); 162 if (!SLWs) SLWs = new G4double(0.0); 163 if (!SLWEs) SLWEs = new G4double(0.0); 164 if (!SLW_Vs) SLW_Vs = new G4double(0.0); 165 if (!SLWE_Vs) SLWE_Vs = new G4double(0.0 166 G4double NumWeightedEnergy = 0.0; 167 G4double FluxWeightedEnergy = 0.0; 168 G4double AverageTrackWeight = 0.0; 169 if (*SLW_Vs != 0.) NumWeightedEnergy = ( 170 if (*SLWs != 0.) FluxWeightedEnergy = (* 171 if (*SLs != 0.) AverageTrackWeight = (*S 172 G4String cname = bdet->GetCellName(iz); 173 G4cout << std::setw(fFieldValue) << cnam 174 << " |" << std::setw(fFieldValue) 175 << (*SumCollisions) << " |" << st 176 << std::setw(fFieldValue) << NumW 177 << FluxWeightedEnergy << " |" << 178 << std::setw(fFieldValue) << (*SL 179 << " |" << std::setw(fFieldValue) 180 << (*SLWEs) << " |" << std::setw( 181 } 182 G4cout << "=============================== 183 } 184 } 185 186 //....oooOO0OOooo........oooOO0OOooo........oo 187 188 void B03RunAction::PrintHeader(std::ostream* o 189 { 190 std::vector<G4String> vecScoreName; 191 vecScoreName.push_back("Tr.Entering"); 192 vecScoreName.push_back("Population"); 193 vecScoreName.push_back("Collisions"); 194 vecScoreName.push_back("Coll*WGT"); 195 vecScoreName.push_back("NumWGTedE"); 196 vecScoreName.push_back("FluxWGTedE"); 197 vecScoreName.push_back("Av.Tr.WGT"); 198 vecScoreName.push_back("SL"); 199 vecScoreName.push_back("SLW"); 200 vecScoreName.push_back("SLW_v"); 201 vecScoreName.push_back("SLWE"); 202 vecScoreName.push_back("SLWE_v"); 203 204 // head line 205 // std::string vname = FillString("Volume", 206 //*out << vname << '|'; 207 std::string vname; 208 *out << std::setw(fFieldValue) << "Volume" 209 << " |"; 210 for (std::vector<G4String>::iterator it = ve 211 // vname = FillString((*it), 212 // ' ', 213 // fFieldValue+1, 214 // false); 215 // *out << vname << '|'; 216 *out << std::setw(fFieldValue) << (*it) << 217 } 218 *out << G4endl; 219 } 220 221 //....oooOO0OOooo........oooOO0OOooo........oo 222 223 std::string B03RunAction::FillString(const std 224 { 225 std::string fname(""); 226 G4int k = n - name.size(); 227 if (k > 0) { 228 if (back) { 229 fname = name; 230 fname += std::string(k, c); 231 } 232 else { 233 fname = std::string(k, c); 234 fname += name; 235 } 236 } 237 else { 238 fname = name; 239 } 240 return fname; 241 } 242 243 //....oooOO0OOooo........oooOO0OOooo........oo 244