ATLAS Offline Software
ISFFluxRecorder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "ISFFluxRecorder.h"
6 
7 #include "G4Event.hh"
8 #include "G4GeometryManager.hh"
9 #include "G4HCofThisEvent.hh"
10 #include "G4LogicalVolumeStore.hh"
11 #include "G4ParallelWorldScoringProcess.hh"
12 #include "G4ParticleTable.hh"
13 #include "G4ProcessManager.hh"
14 #include "G4RegionStore.hh"
15 #include "G4Run.hh"
16 #include "G4ScoringManager.hh"
17 #include "G4StateManager.hh"
18 #include "G4TransportationManager.hh"
19 #include "G4UImanager.hh"
20 #include "G4UserRunAction.hh"
21 #include "G4Version.hh"
22 
24 {
25  G4UImanager *ui = G4UImanager::GetUIpointer();
26  ui->ApplyCommand("/run/setCutForAGivenParticle proton 0 mm");
27 
28  G4ScoringManager* ScM = G4ScoringManager::GetScoringManagerIfExist();
29 
30  if(!ScM) { return; }
31 
32  ui->ApplyCommand("/score/create/cylinderMesh cylMesh_1");
33  // R Z(-24 to 24)
34  ui->ApplyCommand("/score/mesh/cylinderSize 12. 24. m");
35  // iR iZ
36  //ui->ApplyCommand("/score/mesh/nBin 1 1 1");
37  ui->ApplyCommand("/score/mesh/nBin 120 480 1");
38 
39  ui->ApplyCommand("/score/quantity/energyDeposit eDep");
40 
41  ui->ApplyCommand("/score/quantity/cellFlux CF_photon");
42  ui->ApplyCommand("/score/filter/particle photonFilter gamma");
43  // above 2 line crete tally for cell flux for gamma
44 
45  ui->ApplyCommand("/score/quantity/cellFlux CF_neutron");
46  ui->ApplyCommand("/score/filter/particle neutronFilter neutron");
47 
48  ui->ApplyCommand("/score/quantity/cellFlux CF_HEneutron");
49  ui->ApplyCommand("/score/filter/particleWithKineticEnergy HEneutronFilter 20 7000000 MeV neutron");
50 
51  ui->ApplyCommand("/score/quantity/doseDeposit dose");
52 
53  ui->ApplyCommand("/score/close");
54  ui->ApplyCommand("/score/list");
55 
56  G4int nPar = ScM->GetNumberOfMesh();
57 
58  if(nPar<1) { return; }
59 
60  G4ParticleTable::G4PTblDicIterator* particleIterator
61  = G4ParticleTable::GetParticleTable()->GetIterator();
62 
63  for(G4int iw=0;iw<nPar;iw++) {
64  G4VScoringMesh* mesh = ScM->GetMesh(iw);
65  G4VPhysicalVolume* pWorld
66  = G4TransportationManager::GetTransportationManager()
67  ->IsWorldExisting(ScM->GetWorldName(iw));
68  if(!pWorld) {
69  pWorld = G4TransportationManager::GetTransportationManager()
70  ->GetParallelWorld(ScM->GetWorldName(iw));
71  pWorld->SetName(ScM->GetWorldName(iw));
72 
73  G4ParallelWorldScoringProcess* theParallelWorldScoringProcess
74  = new G4ParallelWorldScoringProcess(ScM->GetWorldName(iw));
75  theParallelWorldScoringProcess->SetParallelWorld(ScM->GetWorldName(iw));
76 
77  particleIterator->reset();
78  while( (*particleIterator)() ) {
79  G4ParticleDefinition* particle = particleIterator->value();
80  G4ProcessManager* pmanager = particle->GetProcessManager();
81  if(pmanager) {
82  pmanager->AddProcess(theParallelWorldScoringProcess);
83  pmanager->SetProcessOrderingToLast(theParallelWorldScoringProcess, idxAtRest);
84  pmanager->SetProcessOrderingToSecond(theParallelWorldScoringProcess, idxAlongStep);
85  pmanager->SetProcessOrderingToLast(theParallelWorldScoringProcess, idxPostStep);
86  }
87  }
88  }
89 
90  mesh->Construct(pWorld);
91  }
92  return;
93 }
94 
95 void ISFFluxRecorder::RecordFlux(const G4Event* currentEvent)
96 {
97  G4ScoringManager* ScM = G4ScoringManager::GetScoringManagerIfExist();
98  if(ScM) {
99  G4int nPar = ScM->GetNumberOfMesh();
100  G4HCofThisEvent* HCE = currentEvent->GetHCofThisEvent();
101  if(HCE && nPar>0) {
102  G4int nColl = HCE->GetCapacity();
103  for(G4int i=0;i<nColl;i++) {
104  G4VHitsCollection* HC = HCE->GetHC(i);
105  if(HC) { ScM->Accumulate(HC); }
106  }
107  }
108  }
109  return;
110 }
111 
113 {
114  G4UImanager *ui=G4UImanager::GetUIpointer();
115  ui->ApplyCommand("/score/dumpQuantityToFile cylMesh_1 eDep edep.txt");
116  ui->ApplyCommand("/score/dumpQuantityToFile cylMesh_1 CF_neutron neutron.txt");
117  ui->ApplyCommand("/score/dumpQuantityToFile cylMesh_1 CF_HEneutron HEneutron.txt");
118  ui->ApplyCommand("/score/dumpQuantityToFile cylMesh_1 CF_photon photon.txt");
119  ui->ApplyCommand("/score/dumpQuantityToFile cylMesh_1 dose dose.txt");
120  return;
121 }
ISFFluxRecorder::RecordFlux
void RecordFlux(const G4Event *) override final
Record fluxes from current event.
Definition: ISFFluxRecorder.cxx:95
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
ISFFluxRecorder::InitializeFluxRecording
void InitializeFluxRecording() override final
Definition: ISFFluxRecorder.cxx:23
ISFFluxRecorder.h
lumiFormat.i
int i
Definition: lumiFormat.py:85
ISFFluxRecorder::WriteFluxInformation
void WriteFluxInformation() override final
Dump flux information to text files.
Definition: ISFFluxRecorder.cxx:112