00001
00002
00003
00004
00005
00006
00007 #include "BaseApp.h"
00008 #include "Demo1.h"
00009 #include "egs/EGSInteractor.h"
00010 #include "gheisha/Gheisha.h"
00011
00012
00013
00014 char* particleName="mu+";
00015 float pBeam=(float)5.0, phi=0;
00016 Vector beamVec(pBeam*sin(phi),0,pBeam*cos(phi));
00017 Point beamPos(10,0,-60);
00018
00019
00020 void WARNING(const char* s){cerr << s << endl;}
00021 void FATAL(const char* s){cerr << s << endl; exit(-1);}
00022
00023 #define USEGUI
00024 #ifndef USEGUI
00025
00026
00027
00028 int main(int argc, char* argv[])
00029 {
00030 if( argc>1 ) particleName = argv[1];
00031 if( argc>2 ) pBeam = atof(argv[2]);
00032
00033 cout << "\n\t Run a simple test application with a beam of "<<pBeam
00034 << " GeV " << particleName << '\n';
00035
00036 BaseApp app;
00037 app.addInteractor(new EGSInteractor("electromagnetic"));
00038 #if defined( _Windows ) || defined(WIN32)
00039 Material::addPath("/PEGS4");
00040 #else
00041 app.addInteractor(new Gheisha("hadronic"));
00042 #endif
00043
00044 app.setGenerator(
00045 new Generator(particleName, beamVec, beamPos) );
00046 app.setWorld(new Demo1);
00047
00048 app.run(1);
00049 cout << "\nThe response of the detectors...\n";
00050 app.printResponse(cout);
00051 return 0;
00052 }
00053 #else
00054
00055
00057
00058 #include "control/Command.h"
00059 #include "gismo/PDT.h"
00060
00061
00062
00063
00064 class SetBeam : public Command{
00065 public:
00066 SetBeam(GUIapp* app) :_app(app){}
00067 void execute()
00068 {
00069 if( particleName=_app->gui()->askUser("new beam particle?", "gamma" ) )
00070 {
00071 Generator& gen= _app->generator();
00072 if( gen.thePDT()->lookUp(particleName)==0)
00073 {
00074 WARNING("Particle not recognized");
00075 return;
00076 }
00077 _app->setGenerator(new Generator(particleName,beamVec, beamPos) );
00078 }
00079 }
00080 private:
00081 GUIapp* _app;
00082 };
00083
00084
00085
00086
00087 #if defined(WIN32)
00088 extern "C" void UserMain(int argc, char *argv[]);
00089 #define main(ARGC,ARGV) UserMain(ARGC,ARGV)
00090 #endif
00091
00092 class ThisApp : public GUIapp
00093 {
00094 public:
00095 ThisApp()
00096 : GUIapp(GUI::createGUI("testapp", "Demonstration Detector"))
00097 {
00098 setGenerator(new Generator(particleName,Vector(0,0,pBeam), Point(0,0,-60) ));
00099
00100
00101 gui()->addToMenu("set Beam...",new SetBeam(this));
00102 addInteractor(new EGSInteractor("electromagnetic"));
00103 addInteractor(new Gheisha("hadronic"));
00104 #if defined(WIN32)
00105 Material::addPath("/PEGS4");
00106 #endif
00107
00108 }
00109 };
00110
00111 void main(int, char * argv[])
00112 {
00113
00114 ThisApp app;
00115
00116
00117 app.setWorld(new Demo1);
00118
00119
00120 app.gui()->run();
00121 }
00122
00123 #endif
00124