[1350] | 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: G4PhotoElectricAngularGeneratorTest.cc,v 1.5 2006/06/29 19:44:28 gunter Exp $ |
---|
| 28 | // GEANT4 tag $Name: geant4-09-04-ref-00 $ |
---|
| 29 | // |
---|
| 30 | // ------------------------------------------------------------------- |
---|
| 31 | // GEANT 4 class file --- Copyright CERN 1998 |
---|
| 32 | // CERN Geneva Switzerland |
---|
| 33 | // |
---|
| 34 | // |
---|
| 35 | // File name: G4PhotoElectricAngularGeneratorTest.cc |
---|
| 36 | // |
---|
| 37 | // Author: Francesco Longo |
---|
| 38 | // |
---|
| 39 | // Creation date: 04 january 2001 |
---|
| 40 | // |
---|
| 41 | // Modifications: Luciano Pandola (27 november 2002) |
---|
| 42 | // Adapted in order to test G4PenelopePhotoElectricsstrahlung |
---|
| 43 | // Minor modification in n-tuple filling |
---|
| 44 | // Updated analysis to AIDA 3.0 |
---|
| 45 | // Pedro Rodrigues (10 May 2004) |
---|
| 46 | // Adapted in order to test angular generators for |
---|
| 47 | // G4LowEnergyPhotoElectricsstrahlung |
---|
| 48 | // |
---|
| 49 | // ------------------------------------------------------------------- |
---|
| 50 | |
---|
| 51 | #include "G4ThreeVector.hh" |
---|
| 52 | #include "globals.hh" |
---|
| 53 | #include "G4ios.hh" |
---|
| 54 | #include "G4RunManager.hh" |
---|
| 55 | #include "G4UImanager.hh" |
---|
| 56 | #include "G4UIterminal.hh" |
---|
| 57 | #include "G4UItcsh.hh" |
---|
| 58 | |
---|
| 59 | //#include "fstream" |
---|
| 60 | //#include "iomanip" |
---|
| 61 | |
---|
| 62 | #include "G4Material.hh" |
---|
| 63 | #include "G4MaterialTable.hh" |
---|
| 64 | #include "G4LowEnergyPhotoElectric.hh" |
---|
| 65 | #include "G4VPhotoElectricAngularDistribution.hh" |
---|
| 66 | #include "G4PhotoElectricAngularGeneratorSimple.hh" |
---|
| 67 | #include "G4PhotoElectricAngularGeneratorSauterGavrila.hh" |
---|
| 68 | #include "G4PhotoElectricAngularGeneratorPolarized.hh" |
---|
| 69 | |
---|
| 70 | #include "AIDA/IManagedObject.h" |
---|
| 71 | #include <memory> |
---|
| 72 | #include "AIDA/IAnalysisFactory.h" |
---|
| 73 | #include "AIDA/ITreeFactory.h" |
---|
| 74 | #include "AIDA/ITree.h" |
---|
| 75 | #include "AIDA/IHistogramFactory.h" |
---|
| 76 | #include "AIDA/IHistogram1D.h" |
---|
| 77 | #include "AIDA/IHistogram2D.h" |
---|
| 78 | #include "AIDA/IHistogram3D.h" |
---|
| 79 | #include "AIDA/ITupleFactory.h" |
---|
| 80 | #include "AIDA/ITuple.h" |
---|
| 81 | |
---|
| 82 | G4ThreeVector SetPerpendicularVector(G4ThreeVector& a) |
---|
| 83 | { |
---|
| 84 | G4double dx = a.x(); |
---|
| 85 | G4double dy = a.y(); |
---|
| 86 | G4double dz = a.z(); |
---|
| 87 | G4double x = dx < 0.0 ? -dx : dx; |
---|
| 88 | G4double y = dy < 0.0 ? -dy : dy; |
---|
| 89 | G4double z = dz < 0.0 ? -dz : dz; |
---|
| 90 | if (x < y) { |
---|
| 91 | return x < z ? G4ThreeVector(-dy,dx,0) : G4ThreeVector(0,-dz,dy); |
---|
| 92 | }else{ |
---|
| 93 | return y < z ? G4ThreeVector(dz,0,-dx) : G4ThreeVector(-dy,dx,0); |
---|
| 94 | } |
---|
| 95 | } |
---|
| 96 | |
---|
| 97 | int main() |
---|
| 98 | { |
---|
| 99 | |
---|
| 100 | // ------------------------------------------------------------------- |
---|
| 101 | |
---|
| 102 | // ---- HBOOK initialization |
---|
| 103 | |
---|
| 104 | AIDA::IAnalysisFactory* af = AIDA_createAnalysisFactory(); |
---|
| 105 | AIDA::ITreeFactory* tf = af->createTreeFactory(); |
---|
| 106 | AIDA::ITree* tree = tf->create("phot_angular_test.hbook","hbook",false,true); |
---|
| 107 | G4cout << "Tree store: " << tree->storeName() << G4endl; |
---|
| 108 | AIDA::IHistogramFactory* hf = af->createHistogramFactory(*tree); |
---|
| 109 | AIDA::IHistogram1D* histo_1 = hf->createHistogram1D("1","Cos Polar Angle", 100,0.,3.14159); |
---|
| 110 | AIDA::IHistogram1D* histo_2 = hf->createHistogram1D("2","Azimuthal Angle", 100,0.,3.14159); |
---|
| 111 | AIDA::IHistogram2D* histo_3 = hf->createHistogram2D("3","2d", 100,0.,3.14159,200,-3.14159,3.14159); |
---|
| 112 | |
---|
| 113 | // Interactive set-up |
---|
| 114 | G4cout << "How many interactions at generator level ?" << G4endl; |
---|
| 115 | G4int nIterations = 0; |
---|
| 116 | G4cin >> nIterations; |
---|
| 117 | if (nIterations <= 0) G4Exception("Wrong input"); |
---|
| 118 | |
---|
| 119 | G4int gType = 0; |
---|
| 120 | G4cout << "Simple [1]" << G4endl; |
---|
| 121 | G4cout << "SauterGavrila [2]" << G4endl; |
---|
| 122 | G4cout << "Polarized [3]" << G4endl; |
---|
| 123 | G4cin >> gType; |
---|
| 124 | if ( !(gType < 4)) G4Exception("Wrong input"); |
---|
| 125 | |
---|
| 126 | G4VPhotoElectricAngularDistribution* angularDistribution = 0; |
---|
| 127 | |
---|
| 128 | if (gType == 1) |
---|
| 129 | { |
---|
| 130 | angularDistribution = new G4PhotoElectricAngularGeneratorSimple("PhotoElectricAngularGeneratorSimple"); |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | if(gType == 2) |
---|
| 134 | { |
---|
| 135 | angularDistribution = new G4PhotoElectricAngularGeneratorSauterGavrila("PhotoElectricAngularGeneratorSauterGavrila"); |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | if(gType == 3) |
---|
| 139 | { |
---|
| 140 | angularDistribution = new G4PhotoElectricAngularGeneratorPolarized("PhotoElectricAngularGeneratorPolarized"); |
---|
| 141 | } |
---|
| 142 | |
---|
| 143 | angularDistribution->PrintGeneratorInformation(); |
---|
| 144 | |
---|
| 145 | G4ThreeVector direction(0,0,1); //photon incident energy |
---|
| 146 | G4double initEnergy = 0; |
---|
| 147 | G4cout << "Enter the photon energy E (keV)" << G4endl; |
---|
| 148 | G4cin >> initEnergy ; |
---|
| 149 | initEnergy = initEnergy*keV; |
---|
| 150 | |
---|
| 151 | if (initEnergy <= 0.) G4Exception("Wrong input"); |
---|
| 152 | G4cout << "Shell level" << G4endl; |
---|
| 153 | G4int level; |
---|
| 154 | G4cin >> level; |
---|
| 155 | |
---|
| 156 | for(G4int i = 0; i < nIterations; i++){ |
---|
| 157 | |
---|
| 158 | // random poll |
---|
| 159 | G4ThreeVector d0 = direction.unit(); |
---|
| 160 | G4ThreeVector a1 = SetPerpendicularVector(d0); //different orthogonal |
---|
| 161 | G4ThreeVector a0 = a1.unit(); // unit vector |
---|
| 162 | G4double rand1 = G4UniformRand(); |
---|
| 163 | // G4double rand1 = 0; |
---|
| 164 | G4double angle = twopi*rand1; // random polar angle |
---|
| 165 | G4ThreeVector b0 = d0.cross(a0); // cross product |
---|
| 166 | G4ThreeVector c; |
---|
| 167 | c.setX(std::cos(angle)*(a0.x())+std::sin(angle)*b0.x()); |
---|
| 168 | c.setY(std::cos(angle)*(a0.y())+std::sin(angle)*b0.y()); |
---|
| 169 | c.setZ(std::cos(angle)*(a0.z())+std::sin(angle)*b0.z()); |
---|
| 170 | G4ThreeVector pol = c.unit(); |
---|
| 171 | |
---|
| 172 | G4ThreeVector photondirection = angularDistribution->GetPhotoElectronDirection(direction, initEnergy, pol, level); |
---|
| 173 | G4cout << photondirection.theta() << G4endl; |
---|
| 174 | |
---|
| 175 | histo_1->fill(photondirection.theta()); |
---|
| 176 | histo_2->fill(photondirection.phi()); |
---|
| 177 | histo_3->fill(photondirection.theta(),photondirection.phi()); |
---|
| 178 | |
---|
| 179 | } |
---|
| 180 | |
---|
| 181 | G4cout << "Committing.............." << G4endl; |
---|
| 182 | tree->commit(); |
---|
| 183 | G4cout << "Closing the tree........" << G4endl; |
---|
| 184 | tree->close(); |
---|
| 185 | |
---|
| 186 | delete angularDistribution; |
---|
| 187 | G4cout << "END OF THE MAIN PROGRAM" << G4endl; |
---|
| 188 | return 0; |
---|
| 189 | |
---|
| 190 | } |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | |
---|
| 196 | |
---|
| 197 | |
---|
| 198 | |
---|
| 199 | |
---|
| 200 | |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | |
---|
| 204 | |
---|
| 205 | |
---|
| 206 | |
---|
| 207 | |
---|