source: trunk/examples/advanced/microbeam/src/MicrobeamEventAction.cc@ 1313

Last change on this file since 1313 was 807, checked in by garnier, 17 years ago

update

  • Property svn:executable set to *
File size: 4.3 KB
RevLine 
[807]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// -------------------------------------------------------------------
27// $Id: MicrobeamEventAction.cc,v 1.6 2006/06/29 16:05:29 gunter Exp $
28// -------------------------------------------------------------------
29
30#include "G4Event.hh"
31#include "G4TrajectoryContainer.hh"
32#include "G4Trajectory.hh"
33#include "G4VVisManager.hh"
34#include "Randomize.hh"
35
36#include "MicrobeamEventAction.hh"
37#include "MicrobeamRunAction.hh"
38
39//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
40
41MicrobeamEventAction::MicrobeamEventAction(MicrobeamRunAction* run)
42 :Run(run),drawFlag("all"),printModulo(10000)
43{}
44
45//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
46
47MicrobeamEventAction::~MicrobeamEventAction()
48{}
49
50//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
51
52void MicrobeamEventAction::BeginOfEventAction(const G4Event* evt)
53{
54 G4int evtNb = evt->GetEventID();
55 Run->SetNumEvent(evtNb);
56 Run->SetDoseN(0);
57 Run->SetDoseC(0);
58}
59
60//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
61
62void MicrobeamEventAction::EndOfEventAction(const G4Event* evt)
63{
64
65// SAVE TOTAL ABSORBED DOSE IN PHANTOM
66
67if (Run->GetDoseN()>0 || Run->GetDoseC()>0)
68{
69 FILE* myFile;
70 myFile=fopen("dose.txt","a");
71 fprintf(myFile,"%e %e\n",Run->GetDoseN(),Run->GetDoseC());
72 fclose (myFile);
73 G4cout << " ===> The incident alpha particle has reached the targeted cell :" << G4endl;
74 G4cout << " -----> total absorbed dose within Nucleus is (Gy) = " << Run->GetDoseN() << G4endl;
75 G4cout << " -----> total absorbed dose within Cytoplasm is (Gy) = " << Run->GetDoseC() << G4endl;
76 G4cout << G4endl;
77}
78else
79{
80 G4cout << " ===> Sorry, the incident alpha particle has missed the targeted cell !" << G4endl;
81 G4cout << G4endl;
82}
83
84
85if (G4VVisManager::GetConcreteInstance())
86 {
87 G4TrajectoryContainer * trajectoryContainer = evt->GetTrajectoryContainer();
88 G4int n_trajectories = 0;
89 if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
90
91 for (G4int i=0; i<n_trajectories; i++)
92 {
93 //G4cout<< "Iteration" << i <<G4endl;
94 G4Trajectory* trj = (G4Trajectory*)((*(evt->GetTrajectoryContainer()))[i]);
95 if (drawFlag == "all")
96 {
97 trj->DrawTrajectory(50);
98 }
99 else if ((drawFlag == "charged")&&(trj->GetCharge() != 0.))
100 {
101 trj->DrawTrajectory(50);
102 }
103 }
104
105 //save rndm status
106
107 /*
108 if (Run->GetRndmFreq() == 2)
109 {
110 HepRandom::saveEngineStatus("endOfEvent.rndm");
111 G4int evtNb = evt->GetEventID();
112 if (evtNb%printModulo == 0)
113 {
114 //G4cout << "\n---> End of Event: " << evtNb << G4endl;
115 //HepRandom::showEngineStatus();
116 }
117 }
118 */
119 }
120
121}
Note: See TracBrowser for help on using the repository browser.