#include <stdio.h>#include <iostream>#include <CLHEP/Vector/ThreeVector.h>#include <CLHEP/Random/Randomize.h>#include <CLHEP/Units/PhysicalConstants.h>#include <TRandom.h>#include <TMath.h>#include <TF1.h>#include <TH1.h>Include dependency graph for Ge68.cc:
Go to the source code of this file.
Namespaces | |
| namespace | std |
| namespace | CLHEP |
Functions | |
| Double_t | dNdE (Double_t *x, Double_t *par) |
| void | ProcessArgs (int argc, char **argv, long *rseed, char **outfilename, unsigned int *nevents) |
| void | Usage (char *name) |
| int | main (int argc, char **argv) |
Variables | |
| const double | electronMass = 0.510998910e-3 |
| const double | Q_gs = 1.8991e-3 |
| const double | Q_1st = 0.8218e-3 |
| const double | E_gamma = 1.07735e-3 |
| Double_t dNdE | ( | Double_t * | x, | |
| Double_t * | par | |||
| ) |
Definition at line 41 of file Ge68.cc.
00042 { 00043 // par[0] is the Q value in GeV 00044 // x[0] is electron energy with unit GeV 00045 Double_t KE = x[0]; 00046 Double_t Q = par[0]; 00047 00048 Double_t Energy = KE + electronMass; 00049 Double_t p = sqrt(KE*(KE+2*electronMass)); 00050 00051 Double_t spec = (Q-KE)*(Q-KE)*Energy*p; 00052 return spec; 00053 }
| void ProcessArgs | ( | int | argc, | |
| char ** | argv, | |||
| long * | rseed, | |||
| char ** | outfilename, | |||
| unsigned int * | nevents | |||
| ) |
Definition at line 157 of file Ge68.cc.
00158 { 00159 int i; 00160 for( i=1 ; i<argc ; i++ ) { 00161 if( strcmp(argv[i], "-seed")==0 ) { 00162 i++; 00163 sscanf(argv[i], "%ld", rseed); 00164 } else if( strcmp(argv[i], "-o")==0 ) { 00165 i++; 00166 *outfilename = new char[strlen(argv[i]) +1]; 00167 strcpy(*outfilename, argv[i]); 00168 } else if( strcmp(argv[i], "-n")==0 ) { 00169 i++; 00170 sscanf(argv[i], "%ud", nevents); 00171 } else { 00172 Usage(argv[0]); 00173 exit(0); 00174 } 00175 } 00176 }
| void Usage | ( | char * | name | ) |
| int main | ( | int | argc, | |
| char ** | argv | |||
| ) |
Definition at line 59 of file Ge68.cc.
00059 { 00060 long rseed = 0; 00061 char* outFilename = NULL; 00062 unsigned int nEvents = 1000000000; // a billion. Default to something big for piping 00063 ProcessArgs(argc, argv, &rseed, &outFilename, &nEvents); 00064 00065 FILE* stream = stdout; 00066 if( outFilename!=NULL ) { 00067 stream = fopen(outFilename, "w"); 00068 if( stream==NULL ) { 00069 printf("Please enetr a valid filename.\n"); 00070 Usage(argv[0]); 00071 exit(0); 00072 } 00073 } 00074 00075 gRandom->SetSeed(rseed); 00076 00077 //create beta spectrum function 00078 TF1* funcBetaEnergy = new TF1("funcBetaEnergy", dNdE, 0., 2e-3, 1);//GeV 00079 00080 00081 //HepRandom::setTheSeed(rseed); 00082 //start by printing some information to comment lines 00083 fprintf(stream, "# File generated by %s.\n", argv[0]); 00084 fprintf(stream, "# Random seed for generator = %ld.\n", rseed); 00085 00086 00087 00088 //create a branch weighting table for random sampling 00089 TH1I *hBranching = new TH1I("hBranching","", 3, 0, 3); 00090 //See notes at the beginning of the code for the prob values below 00091 hBranching->SetBinContent(1,87.94); 00092 hBranching->SetBinContent(2,1.20); 00093 hBranching->SetBinContent(3,2.02);//lump EC 1st excited state with other cascade 00094 00095 for( size_t i=0 ; i<nEvents ; i++ ) { 00096 Int_t ibranch = hBranching->FindBin(hBranching->GetRandom()); 00097 double energyInGeV(0.0), momentumInGeV(0.0); 00098 double px = 0.0, py = 0.0, pz = 0.0; 00099 double phi = 0.0, theta = 0.0; 00100 00101 if(ibranch==1){//ground state positron emission 00102 funcBetaEnergy->SetParameter(0, Q_gs);//Q value in GeV for G.S. 00103 energyInGeV=funcBetaEnergy->GetRandom(); 00104 momentumInGeV = TMath::Sqrt(energyInGeV*energyInGeV 00105 +2.0*electronMass*energyInGeV); 00106 phi= gRandom->Uniform(0.0,2.0*TMath::Pi()); 00107 theta= acos(gRandom->Uniform(-1.0,1.0)); 00108 00109 px = cos(phi)*sin(theta)*momentumInGeV; 00110 py = sin(phi)*sin(theta)*momentumInGeV; 00111 pz = cos(theta)*momentumInGeV; 00112 00113 fprintf(stream, "1\n"); 00114 fprintf(stream, "1\t-11 0 0 %e %e %e %e\n", px, py, pz, electronMass); 00115 00116 } else if (ibranch==2) {//1st excited state, positron emission 00117 funcBetaEnergy->SetParameter(0, Q_1st);//Q value in GeV for 1st ES 00118 energyInGeV=funcBetaEnergy->GetRandom(); 00119 momentumInGeV = TMath::Sqrt(energyInGeV*energyInGeV 00120 +2.0*electronMass*energyInGeV); 00121 phi= gRandom->Uniform(0.0,2.0*TMath::Pi()); 00122 theta= acos(gRandom->Uniform(-1.0,1.0)); 00123 00124 px = cos(phi)*sin(theta)*momentumInGeV; 00125 py = sin(phi)*sin(theta)*momentumInGeV; 00126 pz = cos(theta)*momentumInGeV; 00127 00128 fprintf(stream, "2\n"); 00129 fprintf(stream, "1\t-11 0 0 %e %e %e %e\n", px, py, pz, electronMass); 00130 //now do the gamma, assuming no angular correlation with e+ 00131 phi= gRandom->Uniform(0.0,2.0*TMath::Pi()); 00132 theta= acos(gRandom->Uniform(-1.0,1.0)); 00133 00134 px = cos(phi)*sin(theta)*E_gamma; 00135 py = sin(phi)*sin(theta)*E_gamma; 00136 pz = cos(theta)*E_gamma; 00137 00138 fprintf(stream, "1\t22 0 0 %e %e %e 0\n", px, py, pz); 00139 } else if (ibranch==3) {//single gamma emission 00140 phi= gRandom->Uniform(0.0,2.0*TMath::Pi()); 00141 theta= acos(gRandom->Uniform(-1.0,1.0)); 00142 00143 px = cos(phi)*sin(theta)*E_gamma; 00144 py = sin(phi)*sin(theta)*E_gamma; 00145 pz = cos(theta)*E_gamma; 00146 fprintf(stream, "1\n"); 00147 fprintf(stream, "1\t22 0 0 %e %e %e 0\n", px, py, pz); 00148 } 00149 else { 00150 cout<<"Wrong branch ID. Ignored ..."<<endl; 00151 } 00152 } 00153 return 0; 00154 }
| const double electronMass = 0.510998910e-3 |
1.4.7