ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ML2RunAction.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file ML2RunAction.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // The code was written by :
27 // ^Claudio Andenna claudio.andenna@ispesl.it, claudio.andenna@iss.infn.it
28 // *Barbara Caccia barbara.caccia@iss.it
29 // with the support of Pablo Cirrone (LNS, INFN Catania Italy)
30 // with the contribute of Alessandro Occhigrossi*
31 //
32 // ^INAIL DIPIA - ex ISPESL and INFN Roma, gruppo collegato Sanità, Italy
33 // *Istituto Superiore di Sanità and INFN Roma, gruppo collegato Sanità, Italy
34 // Viale Regina Elena 299, 00161 Roma (Italy)
35 // tel (39) 06 49902246
36 // fax (39) 06 49387075
37 //
38 // more information:
39 // http://g4advancedexamples.lngs.infn.it/Examples/medical-linac
40 //
41 //*******************************************************//
42 
43 
44 #include "G4ios.hh"
45 #include "ML2RunAction.hh"
46 #include "ML2Run.hh"
47 #include "G4THitsMap.hh"
48 #include "G4UnitsTable.hh"
49 #include "G4SystemOfUnits.hh"
50 
51 CML2RunAction::CML2RunAction(CML2Convergence *conv, G4int nB, G4bool bOV, G4int voxelX, G4int voxelY, G4int voxelZ): fNx(voxelX), fNy(voxelY), fNz(voxelZ)
52 {
54  convergence = conv;
55  nBeam = nB;
56  bOnlyVisio = bOV;
57  nLoop = 0;
58 
59 
60  fSDName.push_back(G4String("PhantomSD"));
61 }
62 
64 {
65  fSDName.clear();
66 }
67 
69 {
70  // SUSANNA
71  // Generate new RUN object, which is specially
72  // dedicated for MultiFunctionalDetector scheme.
73  return new ML2Run(fSDName);
74 }
75 
77 {
78  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
79 
80  G4String fullName;
82  {
85  }
86  else
87  {
88  fullName = "";
89  }
90 // CML2PhantomConstruction::GetInstance()->setNewName(fullName);
91 
94 
95 
96  G4cout << "*********************************************" << G4endl;
97  if (convergence -> getNMaxLoops() < 0 || bOnlyVisio)
98  {
99  G4cout << "loop n. " << ++nLoop << G4endl;
100  G4cout << "Launched " << nBeam << " random primary particles" << G4endl;
101  }
102  else
103  {
104  G4cout << "loop n. " << ++nLoop << "/" << convergence->getNMaxLoops() << G4endl;
105  G4cout << "Launched " << nBeam << " random primary particles" << G4endl;
106  }
107  if (!bOnlyVisio)
108  {
109  G4cout <<"Launched " << nBeam << " random primary particles" << G4endl;
110  }
111  G4cout<<"*********************************************"<<'\n';
112  MyTime.Start();
113 }
115 {
116 
117  if(!IsMaster()) return;
118 
119  ML2Run* ml2Run = (ML2Run*)aRun;
120  //--- Dump all socred quantities involved in RE02Run.
121  ml2Run->DumpAllScorer();
122  //---
123 
124  //---------------------------------------------
125  // Dump accumulated quantities for this RUN.
126  // (Display only central region of x-y plane)
127  //---------------------------------------------
128  G4THitsMap<G4double>* totDose = ml2Run->GetHitsMap("PhantomSD/TotalDose");
129 
130  G4int ix;
131  G4int iy;
132  G4int iz;
133 
134  std::ofstream file("totDose.txt");
135  for ( iz = 0; iz < fNz; iz++){
136  for ( iy = 0; iy < fNy; iy++){
137  for (ix = 0; ix < fNx; ix++){
138  G4double* TotD = (*totDose)[CopyNo(ix,iy,iz)];
139  if ( !TotD ) TotD = new G4double(0.0);
140  if (TotD!=0) file << ix << " "<<iy<<" "<<iz<<" "<< *TotD/gray << G4endl;
141  }
142  }
143  }
144  file.close();
145 
146  // CML2WorldConstruction::GetInstance()->savePhantomData();
147  // CML2WorldConstruction::GetInstance()->savePhaseSpaceData();
149 
150  MyTime.Stop();
152 
153  G4cout << "loop elapsed time [s] : " << loopElapsedTime << '\n' << G4endl;
154 }