Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

interact.cxx

Go to the documentation of this file.
00001 // Test of interactions in Gismo
00002 // $Header: /nfs/slac/g/glast/ground/cvs/gismo/src/test/interact.cxx,v 1.1 2000/09/01 20:25:15 burnett Exp $
00003 
00004 #include "gismo/Medium.h"
00005 #include "gismo/Material.h"
00006 #include "gismo/MCParticle.h"
00007 #include "gismo/Interactor.h"
00008 #include "gismo/Units.h"
00009 #include "gismo/EGSInteractor.h"
00010 #include "egs/PEGSData.h"
00011 #include "gismo/GheishaInteractor.h"
00012 
00013 #ifdef TESTPOL
00014 #  include "egs/EGSpolInteractor.h"
00015 #  include "gismo/PDT.h"
00016 #endif
00017 #ifdef MAKETUPLE
00018 # include "test/Tuple.h"
00019 #endif
00020 #include <stdlib.h>
00021 
00022 #ifdef TESTPOL
00023   char* particleName="polgamma";
00024   char* materialName="Pb";
00025   float pBeam =0.04;
00026   unsigned eventCount=10;
00027 #else
00028   const char* particleName="gamma";
00029   const char* materialName="Al";
00030   float pBeam =2.0;
00031   unsigned eventCount=1;
00032 
00033 #endif
00034 #ifdef _MSC_VER
00035 using namespace std;
00036 #endif
00037 Vector pinit(0,0,pBeam);
00038 
00039 void WARNING(const char * text){cerr << "WARNING: " << text << '\n';}
00040 void FATAL(const char * text){
00041     cerr << "FATAL error: " <<text << '\n'; 
00042     cerr << "type help for instructions\n";
00043     exit(-1);}
00044 
00045 const char* help=
00046 "Help for the gismo test program interact:\n\n"
00047 "   interact [[[[particleName] materialName] eventCount] pBeam]\n\n"
00048 "where:\n"
00049 "   particleName [default gamma] is the name of a particle to interact:\n"
00050 "                 (\"decay list\" for a list)\n"
00051 "   materialName [Al] the name of a PEGS4 material file, e.g. Al.mat\n"
00052 "   eventCount [1] number of events to generate\n"
00053 "   pBeam      [2.0 GeV] the beam momentum\n";
00054 
00055 
00056 int main(int argc, char* argv[])
00057 {
00058     int n=0;
00059     if( argc>++n ) particleName = argv[n];
00060     if( strcmp(particleName, "help")==0 ) {cout << help; return 0;}
00061     if( argc>++n ) materialName = argv[n];
00062     if( argc>++n ) eventCount = atoi(argv[n]);
00063     if( argc>++n ) pBeam = atof(argv[n]);
00064 
00065     // this sets up interactors for the default PDT
00066     MCParticle::addInteractor( new EGSInteractor("electromagnetic") );
00067     MCParticle::addInteractor( new GheishaInteractor("hadronic") );
00068 
00069     Material::addPath("../PEGS4:./");
00070 
00071 #ifdef TESTPOL
00072     MCParticle::addInteractor( new EGSpolInteractor("polarizedEM") );
00073     MCParticle::thePDT()->setInteraction("polarizedEM");
00074     MCParticle::thePDT()->addParticle("polgamma",    33, 2, 0,  0.) ;
00075 #endif
00076     // set up medium (really only for the material) and particle
00077     Medium* med = new Medium((Medium*)0,(Shape*)0,materialName);
00078     MCParticle p(particleName);
00079     p.setMomentum(Vector(0,0,pBeam));
00080 
00081     cout << "\nInteraction test of "
00082       << pBeam << " GeV " << particleName
00083          << " in " << materialName << '\n';
00084     cout << "Interactions performed by: "<< p.interactor()->className()
00085           << ", Interaction length: "
00086           << p.interactionLength(med) << " cm\n";
00087 
00088     // special stuff to look at e, gamma interaction probabilites
00089     const PEGSData* pegs = (PEGSData*)med->material().getMatData(0);
00090     if( string(particleName)== "e+") {
00091         float ke = Units::toMeV(p.e()-p.mass());
00092         float prob1= pegs->pbr1(ke),
00093             prob2 = pegs->pbr2(ke);
00094         cout << "Positron probabilities to brem, bhabha, annihilate: " 
00095             << prob1 <<", "<< prob2-prob1<< ", " << 1.0-prob2 << endl;
00096     }else if( string(particleName)=="gamma") {
00097         float ke = Units::toMeV(p.e());
00098         float prob1 = pegs->gbr1(ke), prob2 = pegs->gbr2(ke);
00099         cout << "photon probabilities to pair, compton, photo: "
00100             << prob1 <<", "<< prob2-prob1<< ", " << 1.0-prob2 << endl;
00101     }else if( string(particleName)=="e-"){
00102         float prob1 = pegs->ebr1(Units::toMeV(p.e()-p.mass()));
00103         cout << "electron probabilites to brems, moller: "
00104             << prob1 << ", " << 1.0-prob1 << endl;
00105     }
00106 
00107 
00108 #ifdef MAKETUPLE
00109     Tuple tuple("Polarized gamma study");
00110     TupleItem e1("e1"),e2("e2"),
00111         theta1("theta1"),theta2("theta2"),
00112         phi1("phi1"),phi2("phi2"),
00113         psi("psi"), open("open_angle");
00114     tuple.writeHeader(cout);
00115 #endif
00116     for( unsigned i=0; i<eventCount; i++) {
00117         MCParticle q(p);
00118         if( q.interact(med))
00119             q.setStatus(MCParticle::INTERACTED);
00120 #ifdef MAKETUPLE
00121         if( q.numChildren()==2) {
00122             GParticle& a= *q.child(0),
00123                 b= *q.child(1); // secondaries
00124 
00125             e1 = a.e();
00126             e2 = b.e();
00127             theta1=a.theta();
00128             theta2=b.theta();
00129             phi1 = a.phi();
00130             phi2 = b.phi();
00131             psi = phi2-phi1; if( psi<0 ) psi=psi+2*M_PI; 
00132             open = acos(a.direction()*b.direction());
00133             cout << tuple;
00134         }
00135 #else
00136         cout << q << '\n';
00137 #endif
00138     }
00139     cout.flush();
00140     return 0;
00141 }
00142                                   
00143 

Generated at Mon Nov 26 18:18:33 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000