File minigbrahms.cc: Example of use

//
// $Id: minigbrahms.cc,v 1.1 1999/11/25 16:00:00 cholm Exp $
// $Author: cholm $
// $Date: 1999/11/25 16:00:00 $
//

#ifdef USE_ROOT 
#include <TROOT.h>
#endif 

#include <cstdlib>
#include <ctime>
#include <MiniGeantInc.hh>

main (int argc, char* argv[]) 
{
#ifdef USE_ROOT 
  TROOT minigrahms("minigrahms", "Minature gBrahms");
#endif

  int    events = 1; 
  long   seed   = 1;
  double impuls = 4;
  double field  = .1;
  for (int i = 1 ; i < argc ; i++) {
    string arg(argv[i]);
    if (arg == "-n")      events = atoi(argv[++i]);
    else if (arg == "-s") seed   = atol(argv[++i]);
    else if (arg == "-r") seed   = time(0);
    else if (arg == "-i") impuls = atof(argv[++i]);
    else if (arg == "-b") field  = atof(argv[++i]);
    else cout << "Unkown option " << arg << endl;
  }

  cout << endl 
       << "*** Simple spctrometer simulation ****"  << endl << endl
       << " Number of events:        " << events << endl
       << " Max momentum:            " << impuls << endl
       << " B field strength:        " << field  << endl 
       << " Seed for random numbers: " << seed   << endl << endl;

  srand(seed);

  Particle  pion("pion",.139,-1);
  double    t = 0;
  Vector    p(0,0,0);
  Vector    r(0,0,0);

  Vector    cavegeom(10,10,20);

  Vector    d1field(field,0,0);
  Vector    d1geom(10,10,10);
  Vector    d1pos(0,0,5);

  Vector    h1geom(10,10,.1);
  Vector    h1pos(0,0,17);
      
  Cave      cave("Spectrometer", cavegeom,2);
  Magnet    d1("D1", d1field, d1geom);
  Hodoscope h1("H1", 40, h1geom);

  cave.AddDetector(d1, d1pos);
  cave.AddDetector(h1, h1pos);

  for (int i = 1; i <= events; i++) {
    cout << "Event # " << i << endl; 

    r = Vector(0,0,0);
    p = Vector( impuls / 10 * rand() / RAND_MAX, 
		impuls / 10 * rand() / RAND_MAX,
		impuls * rand() / RAND_MAX);
    pion.SetMomentum(p);

    cave.Interact(pion,r,t);

    cout << cave;
  }
  
}

//
// $Log: minigbrahms.cc,v $
// Revision 1.1  1999/11/25 16:00:00  cholm
// Starting work on session 4 (partly imported from old session3
//
// Revision 1.2  1999/11/23 22:46:07  cholm
// Added log
//
//


ROOT page - Home page - Class index - Top of the page

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.