[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 | #include "G4AtomicTransitionManager.hh" |
---|
| 27 | #include "G4AtomicDeexcitation.hh" |
---|
| 28 | #include "globals.hh" |
---|
| 29 | #include "G4ios.hh" |
---|
| 30 | #include <vector> |
---|
| 31 | #include "G4DynamicParticle.hh" |
---|
| 32 | #include "AIDA/AIDA.h" |
---|
| 33 | #include "Randomize.hh" |
---|
| 34 | |
---|
| 35 | using namespace CLHEP; |
---|
| 36 | |
---|
| 37 | int main(int argc, char* argv[]){ |
---|
| 38 | |
---|
| 39 | time_t seconds = time(NULL); |
---|
| 40 | G4int seed = seconds; |
---|
| 41 | |
---|
| 42 | // choose the Random engine |
---|
| 43 | CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine); |
---|
| 44 | CLHEP::HepRandom::setTheSeed(seed); |
---|
| 45 | |
---|
| 46 | G4int Z; |
---|
| 47 | G4int a; |
---|
| 48 | G4int b; |
---|
| 49 | G4int startId; |
---|
| 50 | G4int vacancyId; |
---|
| 51 | G4int numberOfRun; |
---|
| 52 | G4int batch=0; |
---|
| 53 | G4int element; |
---|
| 54 | if (argv[1]) {batch = atoi(argv[1]);} |
---|
| 55 | G4String fileName; |
---|
| 56 | if (argv[3]) {element = atoi(argv[3]);} |
---|
| 57 | if (argv[4]) {fileName = argv[4];} |
---|
| 58 | else {fileName = "transitions.xml";} |
---|
| 59 | |
---|
| 60 | AIDA::ITree* tree; |
---|
| 61 | AIDA::IAnalysisFactory* analysisFactory; |
---|
| 62 | AIDA::ITupleFactory* tupleFactory; |
---|
| 63 | AIDA::ITuple* tupleFluo; |
---|
| 64 | if (batch != 1) { |
---|
| 65 | G4cout << "Enter Z " << G4endl; |
---|
| 66 | G4cin >> a; |
---|
| 67 | G4cout << "Enter the id of the vacancy" << G4endl; |
---|
| 68 | G4cin >> startId; |
---|
| 69 | G4cout<<"Enter the number of runs "<<G4endl; |
---|
| 70 | G4cin>> numberOfRun; |
---|
| 71 | } |
---|
| 72 | else { |
---|
| 73 | |
---|
| 74 | a = 0; |
---|
| 75 | startId = -1; |
---|
| 76 | numberOfRun = atoi(argv[2]); |
---|
| 77 | } |
---|
| 78 | analysisFactory = AIDA_createAnalysisFactory(); |
---|
| 79 | AIDA::ITreeFactory* treeFactory = analysisFactory->createTreeFactory(); |
---|
| 80 | tree = treeFactory->create(fileName,"xml",false,true); |
---|
| 81 | tupleFactory = analysisFactory->createTupleFactory(*tree); |
---|
| 82 | // Book tuple column names |
---|
| 83 | std::vector<std::string> columnNames; |
---|
| 84 | // Book tuple column types |
---|
| 85 | std::vector<std::string> columnTypes; |
---|
| 86 | |
---|
| 87 | //if Z=0 a number of runs numberOfRun is generated for all the elements |
---|
| 88 | if (a==0) |
---|
| 89 | { |
---|
| 90 | if (element == 0) { |
---|
| 91 | a = 6; |
---|
| 92 | b = 98; |
---|
| 93 | } |
---|
| 94 | else { |
---|
| 95 | a = element; |
---|
| 96 | b = a;} |
---|
| 97 | columnNames.push_back("AtomicNumber"); |
---|
| 98 | columnNames.push_back("Particle"); |
---|
| 99 | columnNames.push_back("Energies"); |
---|
| 100 | |
---|
| 101 | columnTypes.push_back("int"); |
---|
| 102 | columnTypes.push_back("int"); |
---|
| 103 | columnTypes.push_back("double"); |
---|
| 104 | tupleFluo = tupleFactory->create("10", "Total Tuple", columnNames, columnTypes, ""); |
---|
| 105 | assert(tupleFluo); |
---|
| 106 | |
---|
| 107 | } |
---|
| 108 | else { b = a;} |
---|
| 109 | |
---|
| 110 | G4AtomicTransitionManager* transitionManager = G4AtomicTransitionManager::Instance(); |
---|
| 111 | |
---|
| 112 | G4AtomicDeexcitation* deexcitation = new G4AtomicDeexcitation; |
---|
| 113 | std::map<G4int,G4int> shellNumberTable; |
---|
| 114 | |
---|
| 115 | deexcitation->ActivateAugerElectronProduction(true); |
---|
| 116 | |
---|
| 117 | for (Z = a; Z<=b; Z++) { |
---|
| 118 | G4cout << "******** Z = "<< Z << "*********" << G4endl; |
---|
| 119 | |
---|
| 120 | G4int numberOfPossibleShell = transitionManager->NumberOfShells(Z); |
---|
| 121 | |
---|
| 122 | shellNumberTable[Z] = numberOfPossibleShell; |
---|
| 123 | G4int min = 0; |
---|
| 124 | G4int max = 0; |
---|
| 125 | std::vector<G4DynamicParticle*>* vectorOfParticles; |
---|
| 126 | |
---|
| 127 | for(G4int i = 0; i<numberOfRun;i++){ |
---|
| 128 | G4cout<<"**************"<<G4endl; |
---|
| 129 | G4cout<<"begin of run "<< i <<G4endl; |
---|
| 130 | G4cout<<"**************"<<G4endl; |
---|
| 131 | vectorOfParticles = 0; |
---|
| 132 | // if shellID = -1 the test runs on every shell of the atom |
---|
| 133 | if (startId == -1){ |
---|
| 134 | min = 1; |
---|
| 135 | max = shellNumberTable[Z]; |
---|
| 136 | } |
---|
| 137 | else { |
---|
| 138 | min = startId; |
---|
| 139 | max = min; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | for (vacancyId = min; vacancyId <= max; vacancyId++) { |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | vectorOfParticles = deexcitation-> GenerateParticles(Z,vacancyId); |
---|
| 146 | |
---|
| 147 | G4cout<< vectorOfParticles->size()<<" particles in the vector "<<G4endl; |
---|
| 148 | |
---|
| 149 | for (G4int k=0; k< vectorOfParticles->size();k++) |
---|
| 150 | { |
---|
| 151 | |
---|
| 152 | G4DynamicParticle* newParticle = (*vectorOfParticles)[k]; |
---|
| 153 | |
---|
| 154 | if ( newParticle->GetDefinition()->GetParticleName() == "e-") |
---|
| 155 | { |
---|
| 156 | |
---|
| 157 | G4DynamicParticle* newElectron = (*vectorOfParticles)[k]; |
---|
| 158 | G4ThreeVector augerDirection =newElectron ->GetMomentum(); |
---|
| 159 | G4double augerEnergy =newElectron ->GetKineticEnergy(); |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | if (startId==-1){ |
---|
| 163 | |
---|
| 164 | tupleFluo->fill(0,Z); |
---|
| 165 | tupleFluo->fill(1,0); |
---|
| 166 | tupleFluo->fill(2,augerEnergy); |
---|
| 167 | tupleFluo->addRow(); |
---|
| 168 | |
---|
| 169 | } |
---|
| 170 | else{ |
---|
| 171 | |
---|
| 172 | G4cout <<" An auger has been generated"<<G4endl; |
---|
| 173 | G4cout<<" vectorOfParticles ["<<k<<"]:"<<G4endl; |
---|
| 174 | G4cout<<"Non zero particle. Index: "<<k<<G4endl; |
---|
| 175 | G4cout<< "The Auger electron has a kinetic energy = "<<augerEnergy |
---|
| 176 | <<" MeV " <<G4endl; |
---|
| 177 | |
---|
| 178 | } |
---|
| 179 | } |
---|
| 180 | else{ |
---|
| 181 | G4cout << "pippo" << G4endl; |
---|
| 182 | |
---|
| 183 | G4ThreeVector photonDirection = newParticle ->GetMomentum(); |
---|
| 184 | G4double photonEnergy =newParticle ->GetKineticEnergy(); |
---|
| 185 | |
---|
| 186 | if (startId==-1){ |
---|
| 187 | G4cout << "pippo2" << G4endl; |
---|
| 188 | tupleFluo->fill(0,Z); |
---|
| 189 | |
---|
| 190 | tupleFluo->fill(1,1); |
---|
| 191 | tupleFluo->fill(2,photonEnergy); |
---|
| 192 | tupleFluo->addRow(); |
---|
| 193 | |
---|
| 194 | } |
---|
| 195 | else{ |
---|
| 196 | |
---|
| 197 | G4cout<<" vectorOfParticles ["<<k<<"]:"<<G4endl; |
---|
| 198 | G4cout<<"Non zero particle. Index: "<<k<<G4endl; |
---|
| 199 | G4cout<< "The photon has a kinetic energy = "<<photonEnergy |
---|
| 200 | <<" MeV " <<G4endl; |
---|
| 201 | } |
---|
| 202 | } |
---|
| 203 | } |
---|
| 204 | } |
---|
| 205 | if (batch == 1){ |
---|
| 206 | tree->commit(); // Write histos in file. |
---|
| 207 | tree->close(); |
---|
| 208 | } |
---|
| 209 | delete vectorOfParticles; |
---|
| 210 | } |
---|
| 211 | } |
---|
| 212 | delete deexcitation; |
---|
| 213 | G4cout<<"END OF THE MAIN PROGRAM"<<G4endl; |
---|
| 214 | } |
---|