Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RunAction.cc
Go to the documentation of this file.
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$
28 // -------------------------------------------------------------------
29 
30 #include <iomanip>
31 #include <iostream>
32 #include <fstream>
33 #include <fstream>
34 #include <vector>
35 #include <cmath>
36 
37 // #define MATRIX_BOUND_CHECK
38 
39 #include "RunAction.hh"
40 
41 #include "G4ios.hh"
42 #include "Randomize.hh"
43 
44 #include "G4SteppingManager.hh"
45 #include "G4Run.hh"
46 #include "G4Material.hh"
47 #include "G4UImanager.hh"
48 #include "G4UnitsTable.hh"
49 
50 using namespace std;
51 
52 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
53 
55 HistoManager* hi)
56 :detector(det),primary(pri),hist(hi)
57 {
58 }
59 
60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
61 
63 {}
64 
65 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
66 
67 void RunAction::BeginOfRunAction(const G4Run* /*aRun*/)
68 {
69  // Vector initialization
70  row=0;
71 
72  xVector = CLHEP::HepVector(32);
73  yVector = CLHEP::HepVector(32);
74  thetaVector = CLHEP::HepVector(32);
75  phiVector = CLHEP::HepVector(32);
76 
77  // Histograms
78  hist->book();
79 
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
83 
84 void RunAction::EndOfRunAction(const G4Run* /*aRun*/)
85 {
86 
87 if (detector->GetCoef()==1)
88 {
89 
90  CLHEP::HepMatrix m;
91 
92  // VECTOR READING
93  // VECTOR READING
94 
95  m = CLHEP::HepMatrix(32,32);
96  m = primary->GetMatrix();
97 
98  G4cout << G4endl;
99  G4cout << "===> NANOBEAM LINE INTRINSIC ABERRATION COEFFICIENTS (units of micrometer and mrad) :" << G4endl;
100  G4cout << G4endl;
101 
102  int inv;
103 
104  m.invert(inv);
105  CLHEP::HepVector tmp(32,0);
106  tmp=m*xVector;
107  CLHEP::HepVector b;
108  b=tmp.sub(2,2); G4cout << "<x|theta>=" << b << G4endl;
109  b=tmp.sub(8,8); G4cout << "<x|theta*delta>=" << b << G4endl;
110  b=tmp.sub(10,10); G4cout << "<x|theta^3>=" << b << G4endl;
111  b=tmp.sub(12,12); G4cout << "<x|theta*phi^2>=" << b << G4endl;
112  m.invert(inv);
113 
114  m.invert(inv);
115  tmp = m*thetaVector;
116  m.invert(inv);
117  b=tmp.sub(2,2); G4cout << "<x|x>=" << b << G4endl;
118 
119  m.invert(inv);
120  tmp=m*yVector;
121  b=tmp.sub(3,3); G4cout << "<y|phi>=" << b << G4endl;
122  b=tmp.sub(9,9); G4cout << "<y|phi*delta>=" << b << G4endl;
123  b=tmp.sub(11,11); G4cout << "<y|theta^2*phi>=" << b << G4endl;
124  b=tmp.sub(13,13); G4cout << "<y|phi^3>=" << b << G4endl;
125  m.invert(inv);
126 
127  m.invert(inv);
128  tmp = m*phiVector;
129  m.invert(inv);
130  b=tmp.sub(3,3); G4cout << "<y|y>=" << b << G4endl;
131 
132 }
133 
134  //save histograms
135  hist->save();
136 
137 }
138 
139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....