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 electromagnetic/TestEm6/src/RunActio 26 /// \file electromagnetic/TestEm6/src/RunAction.cc 27 /// \brief Implementation of the RunAction cla 27 /// \brief Implementation of the RunAction class 28 // 28 // 29 // << 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 32 33 #include "RunAction.hh" << 33 #include "G4SystemOfUnits.hh" >> 34 #include "G4PhysicalConstants.hh" >> 35 #include "G4EmCalculator.hh" >> 36 #include "G4ParticleTable.hh" >> 37 #include "G4ParticleDefinition.hh" >> 38 #include "G4Positron.hh" >> 39 #include "G4AnnihiToMuPair.hh" >> 40 #include "G4eeToHadrons.hh" >> 41 #include "G4eeToHadronsModel.hh" >> 42 #include "G4eBremsstrahlung.hh" 34 43 35 #include "G4AnnihiToMuPair.hh" << 44 #include "RunAction.hh" 36 #include "G4EmCalculator.hh" << 37 #include "G4MuonMinus.hh" << 38 #include "G4ParticleDefinition.hh" << 39 #include "G4ParticleTable.hh" << 40 #include "G4PhysicalConstants.hh" << 41 #include "G4Positron.hh" << 42 #include "G4Run.hh" 45 #include "G4Run.hh" 43 #include "G4RunManager.hh" 46 #include "G4RunManager.hh" 44 #include "G4SystemOfUnits.hh" << 47 #include "G4MuonMinus.hh" 45 #include "G4eBremsstrahlung.hh" << 48 46 #include "G4eeToHadrons.hh" << 47 #include "G4eeToHadronsModel.hh" << 48 #include "Randomize.hh" 49 #include "Randomize.hh" 49 50 50 #include <sstream> 51 #include <sstream> 51 52 52 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 54 54 RunAction::RunAction(DetectorConstruction* det 55 RunAction::RunAction(DetectorConstruction* det) 55 : G4UserRunAction(), fDetector(det), fProcCo << 56 : G4UserRunAction(),fDetector(det),fProcCounter(0),fAnalysis(0),fMat(0) 56 { 57 { 57 fMinE = 40 * GeV; << 58 fMinE = 40*GeV; 58 fMaxE = 10000 * GeV; << 59 fMaxE = 10000*GeV; 59 fnBin = 10000; 60 fnBin = 10000; 60 } 61 } 61 62 62 //....oooOO0OOooo........oooOO0OOooo........oo 63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 63 64 64 RunAction::~RunAction() {} << 65 RunAction::~RunAction() >> 66 {} 65 67 66 //....oooOO0OOooo........oooOO0OOooo........oo 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 67 69 68 void RunAction::BeginOfRunAction(const G4Run* 70 void RunAction::BeginOfRunAction(const G4Run* aRun) 69 { << 71 { 70 G4cout << "### Run " << aRun->GetRunID() << 72 G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl; 71 73 72 // get material << 74 //get material 73 // 75 // 74 fMat = fDetector->GetMaterial(); 76 fMat = fDetector->GetMaterial(); 75 G4cout << "###RunAction::BeginOfRunAction M << 77 G4cout << "###RunAction::BeginOfRunAction Material:" 76 << 78 << fMat->GetName() << G4endl; >> 79 77 fProcCounter = new ProcessesCount; 80 fProcCounter = new ProcessesCount; 78 81 79 fAnalysis = G4AnalysisManager::Instance(); 82 fAnalysis = G4AnalysisManager::Instance(); 80 fAnalysis->SetDefaultFileType("root"); 83 fAnalysis->SetDefaultFileType("root"); 81 84 82 // Open an output file 85 // Open an output file 83 // 86 // 84 std::stringstream tmp; 87 std::stringstream tmp; 85 tmp << "testem6_" << aRun->GetRunID(); 88 tmp << "testem6_" << aRun->GetRunID(); 86 G4String fileName = tmp.str(); 89 G4String fileName = tmp.str(); 87 fAnalysis->OpenFile(fileName); << 90 fAnalysis->OpenFile(fileName); 88 fAnalysis->SetVerboseLevel(2); 91 fAnalysis->SetVerboseLevel(2); 89 fAnalysis->SetActivation(true); 92 fAnalysis->SetActivation(true); 90 << 93 91 // Creating histograms 1,2,3,4,5,6 94 // Creating histograms 1,2,3,4,5,6 92 // << 95 // 93 fAnalysis->SetFirstHistoId(1); << 96 fAnalysis->SetFirstHistoId(1); 94 fAnalysis->CreateH1("h1", "1/(1+(theta+[g]+) << 97 fAnalysis->CreateH1("h1","1/(1+(theta+[g]+)**2)",100, 0 ,1.); 95 fAnalysis->CreateH1("h2", "log10(theta+ [g]+ << 98 fAnalysis->CreateH1("h2","log10(theta+ [g]+)", 100,-3.,1.); 96 fAnalysis->CreateH1("h3", "log10(theta- [g]- << 99 fAnalysis->CreateH1("h3","log10(theta- [g]-)", 100,-3.,1.); 97 fAnalysis->CreateH1("h4", "log10(theta+ [g]+ << 100 fAnalysis->CreateH1("h4","log10(theta+ [g]+ -theta- [g]-)", 100,-3.,1.); 98 fAnalysis->CreateH1("h5", "xPlus", 100, 0., << 101 fAnalysis->CreateH1("h5","xPlus" ,100,0.,1.); 99 fAnalysis->CreateH1("h6", "xMinus", 100, 0., << 102 fAnalysis->CreateH1("h6","xMinus",100,0.,1.); 100 << 103 101 // creating histogram 7,8,9,10,11 (CrossSect << 104 //creating histogram 7,8,9,10,11 (CrossSectionPerAtom) 102 // << 105 // 103 G4double minBin = std::log10(fMinE / GeV); << 106 G4double minBin = std::log10(fMinE/GeV); 104 G4double maxBin = std::log10(fMaxE / GeV); << 107 G4double maxBin = std::log10(fMaxE/GeV); 105 fAnalysis->CreateH1("h7", "CrossSectionPerAt << 108 fAnalysis->CreateH1("h7","CrossSectionPerAtom of AnnihiToMuMu (microbarn)", 106 maxBin); << 109 fnBin,minBin,maxBin); 107 fAnalysis->CreateH1("h8", "CrossSectionPerAt << 110 fAnalysis->CreateH1("h8", 108 maxBin); << 111 "CrossSectionPerAtom of AnnihiToTwoGamma (microbarn)",fnBin,minBin,maxBin); 109 fAnalysis->CreateH1("h9", "CrossSectionPerAt << 112 fAnalysis->CreateH1("h9","CrossSectionPerAtom of AnnihiToHadrons (microbarn)", 110 maxBin); << 113 fnBin,minBin,maxBin); 111 fAnalysis->CreateH1("h10", "Theoretical Cros << 114 fAnalysis->CreateH1("h10", 112 fnBin, minBin, maxBin); << 115 "Theoretical CrossSectionPerAtom of AnnihiToTwoGamma (microbarn)", 113 fAnalysis->CreateH1("h11", "Theoretical Cros << 116 fnBin,minBin,maxBin); 114 minBin, maxBin); << 117 fAnalysis->CreateH1("h11", 115 << 118 "Theoretical CrossSectionPerAtom of AnnihiToMuMu (microbarn)", 116 // creating histogram 12,13,14,15,16(CrossSe << 119 fnBin,minBin,maxBin); 117 // << 120 118 fAnalysis->CreateH1("h12", "CrossSectionPerV << 121 //creating histogram 12,13,14,15,16(CrossSectionPerVolume) 119 fAnalysis->CreateH1("h13", "CrossSectionPerV << 122 // 120 fAnalysis->CreateH1("h14", "CrossSectionPerV << 123 fAnalysis->CreateH1("h12","CrossSectionPerVol of Bremsstraulung (1/mm) ", 121 fAnalysis->CreateH1("h15", "CrossSectionPerV << 124 fnBin,minBin,maxBin); 122 maxBin); << 125 fAnalysis->CreateH1("h13","CrossSectionPerVol of Ionization (1/mm)", 123 fAnalysis->CreateH1("h16", "CrossSectionPerV << 126 fnBin,minBin,maxBin); 124 << 127 fAnalysis->CreateH1("h14","CrossSectionPerVol of AnnihiToMuMu (1/mm)", 125 // creating histogram 17 (R ratio) << 128 fnBin,minBin,maxBin); 126 fAnalysis->CreateH1("h17", "R : eeToHadr/eeT << 129 fAnalysis->CreateH1("h15","CrossSectionPerVol of AnnihiToTwoGamma (1/mm)", 127 << 130 fnBin,minBin,maxBin); 128 G4cout << "\n----> Histogram file is opened << 131 fAnalysis->CreateH1("h16","CrossSectionPerVol of AnnihiToHadrons (1/mm)", >> 132 fnBin,minBin,maxBin); >> 133 >> 134 //creating histogram 17 (R ratio) >> 135 fAnalysis->CreateH1("h17","R : eeToHadr/eeToMu",fnBin,minBin,maxBin); >> 136 >> 137 G4cout << "\n----> Histogram file is opened in " << fileName << G4endl; 129 } 138 } 130 139 131 //....oooOO0OOooo........oooOO0OOooo........oo 140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 132 141 133 void RunAction::CountProcesses(G4String procNa 142 void RunAction::CountProcesses(G4String procName) 134 { 143 { 135 // does the process already encounted ? << 144 //does the process already encounted ? 136 // 145 // 137 size_t nbProc = fProcCounter->size(); 146 size_t nbProc = fProcCounter->size(); 138 size_t i = 0; 147 size_t i = 0; 139 while ((i < nbProc) && ((*fProcCounter)[i]-> << 148 while ((i<nbProc)&&((*fProcCounter)[i]->GetName()!=procName)) i++; 140 i++; << 149 if (i == nbProc) fProcCounter->push_back( new OneProcessCount(procName)); 141 if (i == nbProc) fProcCounter->push_back(new << 150 142 << 143 (*fProcCounter)[i]->Count(); 151 (*fProcCounter)[i]->Count(); 144 } 152 } 145 153 146 //....oooOO0OOooo........oooOO0OOooo........oo 154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 147 155 148 void RunAction::EndOfRunAction(const G4Run*) 156 void RunAction::EndOfRunAction(const G4Run*) 149 { 157 { 150 G4cout << "### RunAction::EndOfRunAction" << 158 G4cout << "### RunAction::EndOfRunAction" << G4endl; 151 // total number of process calls << 159 //total number of process calls 152 // 160 // 153 G4cout << "\n Number of process calls --->"; 161 G4cout << "\n Number of process calls --->"; 154 for (size_t i = 0; i < fProcCounter->size(); << 162 for (size_t i=0; i< fProcCounter->size(); ++i) { 155 G4String procName = (*fProcCounter)[i]->Ge 163 G4String procName = (*fProcCounter)[i]->GetName(); 156 if (procName != "Transportation") { 164 if (procName != "Transportation") { 157 G4int count = (*fProcCounter)[i]->GetCou << 165 G4int count = (*fProcCounter)[i]->GetCounter(); 158 G4cout << "\t" << procName << " : " << c 166 G4cout << "\t" << procName << " : " << count; 159 } 167 } 160 } 168 } 161 G4cout << G4endl; 169 G4cout << G4endl; 162 << 170 163 // instance EmCalculator << 171 //instance EmCalculator 164 // 172 // 165 G4EmCalculator emCal; 173 G4EmCalculator emCal; 166 emCal.SetVerbose(0); 174 emCal.SetVerbose(0); 167 175 168 // get positron << 176 //get positron 169 // 177 // 170 G4String positronName = "e+"; 178 G4String positronName = "e+"; 171 G4ParticleDefinition* positron = G4ParticleT << 179 G4ParticleDefinition* positron = >> 180 G4ParticleTable::GetParticleTable()->FindParticle(positronName); 172 181 173 // process name << 182 //process name 174 // 183 // 175 G4String annihilName = "annihil"; << 184 G4String annihilName = "annihil"; 176 G4String annihiToMuName = "AnnihiToMuPair"; << 185 G4String annihiToMuName = "AnnihiToMuPair"; 177 G4String annihiToHadrName = "ee2hadr"; 186 G4String annihiToHadrName = "ee2hadr"; 178 G4String BremName = "eBrem"; << 187 G4String BremName = "eBrem"; 179 G4String IoniName = "eIoni"; << 188 G4String IoniName = "eIoni"; >> 189 >> 190 //get AnnihiToMuPair >> 191 // >> 192 G4AnnihiToMuPair* annihiToMu = >> 193 reinterpret_cast<G4AnnihiToMuPair*>(emCal.FindProcess(positron, >> 194 annihiToMuName)); 180 195 181 // get AnnihiToMuPair << 196 //parameters for ComputeCrossSection 182 // << 183 G4AnnihiToMuPair* annihiToMu = << 184 reinterpret_cast<G4AnnihiToMuPair*>(emCal. << 185 << 186 // parameters for ComputeCrossSection << 187 // 197 // 188 G4double atomicZ = 1.; 198 G4double atomicZ = 1.; 189 G4double atomicA = 2.; << 199 G4double atomicA = 2.; 190 200 191 // set parameters for theory << 201 //set parameters for theory 192 // 202 // 193 const G4ParticleDefinition* muon = G4MuonMin 203 const G4ParticleDefinition* muon = G4MuonMinus::MuonMinus(); 194 G4double Mu = muon->GetPDGMass(); 204 G4double Mu = muon->GetPDGMass(); 195 G4double Me = electron_mass_c2; 205 G4double Me = electron_mass_c2; 196 G4double Re = classic_electr_radius; 206 G4double Re = classic_electr_radius; 197 G4double Ru = Re * Me / Mu; << 207 G4double Ru = Re*Me/Mu; 198 G4double Eth = 2 * Mu * Mu / Me - Me; << 208 G4double Eth = 2*Mu*Mu/Me-Me; 199 G4PhysicsLogVector v(fMinE, fMaxE, fnBin, fa 209 G4PhysicsLogVector v(fMinE, fMaxE, fnBin, false); 200 << 210 201 // Compute CrossSections and Fill histgrams << 211 //Compute CrossSections and Fill histgrams 202 // 212 // 203 for (G4int i = 0; i <= fnBin; ++i) { << 213 for(G4int i=0; i<=fnBin; ++i) { 204 G4double energy = v.Energy(i); 214 G4double energy = v.Energy(i); 205 G4double x = std::log10(energy / GeV); << 215 G4double x = std::log10(energy/GeV); 206 216 207 // CrossSectionPerAtom << 217 //CrossSectionPerAtom 208 // 218 // 209 G4double crs_annihiToMu = annihiToMu->Comp << 219 G4double crs_annihiToMu = 210 // G4cout << "crs_annihiToMu(mkb)=" << crs << 220 annihiToMu->ComputeCrossSectionPerAtom(energy,atomicZ); 211 fAnalysis->FillH1(7, x, crs_annihiToMu / m << 221 //G4cout << "crs_annihiToMu(mkb)=" << crs_annihiToMu/microbarn << G4endl; 212 << 222 fAnalysis->FillH1(7,x,crs_annihiToMu/microbarn); 213 G4double crs_annihil = << 223 214 emCal.ComputeCrossSectionPerAtom(energy, << 224 G4double crs_annihil = 215 fAnalysis->FillH1(8, x, crs_annihil / micr << 225 emCal.ComputeCrossSectionPerAtom(energy,positron,annihilName, 216 << 226 atomicZ,atomicA); 217 G4double crs_annihiToHadr = << 227 fAnalysis->FillH1(8,x,crs_annihil/microbarn); 218 emCal.ComputeCrossSectionPerAtom(energy, << 228 219 fAnalysis->FillH1(9, x, crs_annihiToHadr / << 229 G4double crs_annihiToHadr = >> 230 emCal.ComputeCrossSectionPerAtom(energy,positron,annihiToHadrName, >> 231 atomicZ,atomicA); >> 232 fAnalysis->FillH1(9,x,crs_annihiToHadr/microbarn); 220 233 221 // CrossSectionPerVolume << 234 //CrossSectionPerVolume 222 // 235 // 223 G4double crsVol_Brem = << 236 G4double crsVol_Brem = 224 emCal.ComputeCrossSectionPerVolume(energ << 237 emCal.ComputeCrossSectionPerVolume(energy,positron,BremName,fMat,100*keV); 225 fAnalysis->FillH1(12, x, crsVol_Brem * mm) << 238 fAnalysis->FillH1(12,x,crsVol_Brem*mm); 226 << 239 227 G4double crsVol_Ioni = << 240 G4double crsVol_Ioni = 228 emCal.ComputeCrossSectionPerVolume(energ << 241 emCal.ComputeCrossSectionPerVolume(energy,positron,IoniName,fMat,100*keV); 229 fAnalysis->FillH1(13, x, crsVol_Ioni * mm) << 242 fAnalysis->FillH1(13,x,crsVol_Ioni*mm); 230 << 243 231 G4double crsVol_annihiToMu = annihiToMu->C << 244 G4double crsVol_annihiToMu = annihiToMu->CrossSectionPerVolume(energy,fMat); 232 fAnalysis->FillH1(14, x, crsVol_annihiToMu << 245 fAnalysis->FillH1(14,x,crsVol_annihiToMu*mm); 233 << 246 234 G4double crsVol_annihil = << 247 G4double crsVol_annihil = 235 emCal.ComputeCrossSectionPerVolume(energ << 248 emCal.ComputeCrossSectionPerVolume(energy,positron,annihilName,fMat); 236 fAnalysis->FillH1(15, x, crsVol_annihil * << 249 fAnalysis->FillH1(15,x,crsVol_annihil*mm); 237 << 250 238 G4double crsVol_annihiToHadr = << 251 G4double crsVol_annihiToHadr = 239 emCal.ComputeCrossSectionPerVolume(energ << 252 emCal.ComputeCrossSectionPerVolume(energy,positron,annihiToHadrName,fMat); 240 fAnalysis->FillH1(16, x, crsVol_annihiToHa << 253 fAnalysis->FillH1(16,x,crsVol_annihiToHadr*mm); 241 254 242 // R ratio << 255 //R ratio 243 // 256 // 244 G4double RR = 0.0; 257 G4double RR = 0.0; 245 if (crsVol_annihiToMu > 0.) RR = crsVol_an << 258 if(crsVol_annihiToMu > 0.) RR = crsVol_annihiToHadr/crsVol_annihiToMu; 246 fAnalysis->FillH1(17, x, RR); << 259 fAnalysis->FillH1(17,x,RR); 247 260 248 // Theoretical calculation << 261 //Theoretical calculation 249 // 262 // 250 G4double X1 = energy / Me; << 263 G4double X1 = energy/Me; 251 if (X1 > 1 && i % 1000 == 0) { << 264 if(X1>1 && i%1000==0){ 252 G4double crs_annihil_theory = << 265 G4double crs_annihil_theory = atomicZ*pi*Re*Re* 253 atomicZ * pi * Re * Re << 266 ( (X1*X1+4*X1+1)*G4Log(X1+std::sqrt(X1*X1-1))/(X1*X1-1) 254 * ((X1 * X1 + 4 * X1 + 1) * G4Log(X1 + << 267 -(X1+3)/std::sqrt(X1*X1-1) )/(X1+1); 255 - (X1 + 3) / std::sqrt(X1 * X1 - 1) << 268 fAnalysis->FillH1(10,x,crs_annihil_theory/microbarn); 256 / (X1 + 1); << 257 fAnalysis->FillH1(10, x, crs_annihil_the << 258 } 269 } 259 270 260 G4double X2 = Eth / energy; << 271 G4double X2 = Eth/energy; 261 if (X2 < 1. && i % 1000 == 0) { << 272 if(X2<1. && i%1000==0){ 262 G4double crs_annihiToMu_theory = << 273 G4double crs_annihiToMu_theory = 263 atomicZ * pi * Ru * Ru / 3 * X2 * (1 + << 274 atomicZ*pi*Ru*Ru/3*X2*(1+X2/2)*std::sqrt(1-X2); 264 fAnalysis->FillH1(11, x, crs_annihiToMu_ << 275 fAnalysis->FillH1(11,x,crs_annihiToMu_theory/microbarn); 265 } 276 } 266 277 267 // if(i%1000==0)G4cout <<"###energy:" << e << 278 //if(i%1000==0)G4cout <<"###energy:" << energy << "/crs_ToMuMu:" 268 // << crs_annihiToMu << "/crs_ToTw << 279 // << crs_annihiToMu << "/crs_ToTwoGamma:"<< crs_annihil 269 // <<"/crs_ToToHadr:"<<crs_annihiT << 280 // <<"/crs_ToToHadr:"<<crs_annihiToHadr<< G4endl; 270 } 281 } 271 << 282 272 fAnalysis->Write(); 283 fAnalysis->Write(); 273 fAnalysis->CloseFile(); 284 fAnalysis->CloseFile(); 274 fAnalysis->Clear(); 285 fAnalysis->Clear(); 275 286 276 G4cout << G4endl; 287 G4cout << G4endl; 277 } 288 } 278 289 279 //....oooOO0OOooo........oooOO0OOooo........oo 290 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 280 291