Example #1
0
void Scene::BuildBaseScene()
{
    // Build the polygons vector
    double robotBottom = robot.yPos - robot.baseSize[1]/2;
    for(auto& t : staticScene.triangles)
    {
        Point p[3] = { staticScene.points[t[0]], staticScene.points[t[1]], staticScene.points[t[2]] };
        Point n = ((p[1]-p[0])^(p[2]-p[0])).Normalize();;
        Triangle trig(p[0], p[1], p[2]);

        if(n[0] == 0 && n[1] == 1 && n[2] == 0)
        {
            groundTriangles.push_back(trig);

            if(p[0][1] != robotBottom)
                noBaseGroundTriangles.push_back(t);
        }
        else
            noBaseGroundTriangles.push_back(t);

        triangles.push_back(trig);
    }
}
Example #2
0
void margVideoPlayer::update() {
	if (player.getIsMovieDone()) {
		player.setFrame(0);
		player.setPaused(true);
		bNeedToPlay = true;
	}
	if(!bNeedToPlay) {
		player.update();
		if (nextTrigger > 0) {
			if (player.getCurrentFrame() >= nextTriggerFrame) {
				trig();
			}
		}
	}
	if (bVideoPixFlushed) {
		bool success = false;
		while (!success) {
			success = tryLockPix();
		}
		memcpy(bufVideoPix, player.getPixels(), pixN);
		bVideoPixFlushed = false;
		bVideoPixLocked = false;
	}
}
Example #3
0
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void starsim( Int_t nevents=1, Int_t rngSeed=1234 )
{ 
	gROOT->ProcessLine(".L bfc.C");
	{
		TString simple = "y2012 geant gstar usexgeom agml ";
		bfc(0, simple );
	}
	
	gSystem->Load( "libVMC.so");
	
	gSystem->Load( "StarGeneratorUtil.so" );
	gSystem->Load( "StarGeneratorEvent.so" );
	gSystem->Load( "StarGeneratorBase.so" );
	
	gSystem->Load( "libMathMore.so"   );
	gSystem->Load( "xgeometry.so"     );

	// Setup RNG seed and captuire ROOT TRandom
	StarRandom::seed(rngSeed);
	StarRandom::capture();
 
	//
	// Create the primary event generator and insert it
	// before the geant maker
	//
	//  StarPrimaryMaker *
	_primary = new StarPrimaryMaker();
	{
		_primary -> SetFileName( "kinematics.starsim.root");
		chain -> AddBefore( "geant", _primary );
	}
	
	Particles();	
	Kinematics();
	
	//
	// Initialize primary event generator and all sub makers
	//
	_primary -> Init();
	
	//
	// Setup geometry and set starsim to use agusread for input
	//
	geometry("y2012");
	command("gkine -4 0");
	command("gfile o pythia6.starsim.fzd");
	
	//
	// Setup PT and ETA distributions
	//
	
	Double_t pt0 = 3.0;
	ptDist = new TF1("ptDist","(x/[0])/(1+(x/[0])^2)^6",0.0,10.0);
	ptDist->SetParameter(0, pt0);
	ptDist->Draw();
	
	etaDist = new TF1("etaDist","-TMath::Erf(x+2.6)*TMath::Erf(x-2.6)",-0.8,+0.8);
	
	//
	// Trigger on nevents
	//
	trig( nevents );
	
	//	command("call agexit");  // Make sure that STARSIM exits properly
}
Example #4
0
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void starsim( Int_t nevents=10, Int_t rngSeed=1234 )
{ 

  gROOT->ProcessLine(".L bfc.C");
  {
    TString simple = "y2012 geant gstar usexgeom agml ";
    bfc(0, simple );
  }

  gSystem->Load( "libVMC.so");

  gSystem->Load( "StarGeneratorUtil.so");
  gSystem->Load( "StarGeneratorEvent.so");
  gSystem->Load( "StarGeneratorBase.so" );

  gSystem->Load( "Pythia8_1_62.so");

  gSystem->Load( "libMathMore.so"   );  

  // Force loading of xgeometry
  gSystem->Load( "xgeometry.so"     );

//   // And unloading of geometry
//   TString geo = gSystem->DynamicPathName("geometry.so");
//   if ( !geo.Contains("Error" ) ) {
//     std::cout << "Unloading geometry.so" << endl;
//     gSystem->Unload( gSystem->DynamicPathName("geometry.so") );
//   }

  gSystem->Load( "Pythia8_1_62.so"  );

  // Setup RNG seed and map all ROOT TRandom here
  StarRandom::seed( rngSeed );
  StarRandom::capture();
  
  //
  // Create the primary event generator and insert it
  // before the geant maker
  //
  //  StarPrimaryMaker *
  primary = new StarPrimaryMaker();
  {
    primary -> SetFileName( "pythia8.starsim.root");
    primary -> SetVertex( 0.1, -0.1, 0.0 );
    primary -> SetSigma ( 0.1,  0.1, 30.0 );
    chain -> AddBefore( "geant", primary );
  }

  //
  // Setup an event generator
  //
  Pythia8("pp:W");

  //
  // Setup cuts on which particles get passed to geant for
  //   simulation.  (To run generator in standalone mode,
  //   set ptmin=1.0E9.)
  //                    ptmin  ptmax
  primary->SetPtRange  (0.0,  -1.0);         // GeV
  //                    etamin etamax
  primary->SetEtaRange ( -3.0, +3.0 );
  //                    phimin phimax
  primary->SetPhiRange ( 0., TMath::TwoPi() );
  
  
  // 
  // Setup a realistic z-vertex distribution:
  //   x = 0 gauss width = 1mm
  //   y = 0 gauss width = 1mm
  //   z = 0 gauss width = 30cm
  // 
  primary->SetVertex( 0., 0., 0. );
  primary->SetSigma( 0.1, 0.1, 30.0 );

  
  //
  // Initialize primary event generator and all sub makers
  //
  primary -> Init();

  //
  // Setup geometry and set starsim to use agusread for input
  //
  //geometry("y2012");
  //* AGUSER/GKINE NTRACK ID [ PTLOW PTHIGH YLOW YHIGH PHILOW PHIHIGH ZLOW ZHIGH option ]

  command("gkine -4 0");
  command("gfile o pythia8.starsim.fzd");
  

  //
  // Trigger on nevents
  //
  trig( nevents );

  //
  // Finish the chain
  //
  chain->Finish();

  //
  // EXIT starsim
  //
  command("call agexit");  // Make sure that STARSIM exits properly

}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void starsim( Int_t nevents=1, Int_t rngSeed=4321 )
{ 

  gROOT->ProcessLine(".L bfc.C");
  {
    TString simple = "y2012 geant gstar usexgeom agml ";
    bfc(0, simple );
  }

  gSystem->Load( "libVMC.so");

  gSystem->Load( "StarGeneratorUtil.so" );
  gSystem->Load( "StarGeneratorEvent.so" );
  gSystem->Load( "StarGeneratorBase.so" );
  gSystem->Load( "libMathMore.so"   );  
  gSystem->Load( "libHijing1_383.so");
  gSystem->Load( "libKinematics.so");
  gSystem->Load( "xgeometry.so"     );

  // force gstar load/call
  gSystem->Load( "gstar.so" );
  command("call gstar");

  // Setup RNG seed and map all ROOT TRandom here
  StarRandom::seed( rngSeed );
  StarRandom::capture();

  // Load STAR Particle DataBase and add the hypertriton definitions (as defined in gstar_part.g)
  StarParticleData &pdb = StarParticleData::instance();
  pdb.AddParticle("HyperTriton",     new TParticlePDG( "HyperTriton",     "HyperTriton     --> He3    pi-", 2.99131, false, 0.0, +3.0, "hypernucleus", +hid(1,1,1), 0, 61054 ));	      
  pdb.AddParticle("AntiHyperTriton", new TParticlePDG( "AntiHyperTriton", "AntiHyperTriton --> He3bar pi+", 2.99131, false, 0.0, -3.0, "hypernucleus", -hid(1,1,1), 0, 61055 ));

  //
  // Create the primary event generator and insert it
  // before the geant maker
  //
  _primary = new StarPrimaryMaker();
  {
    _primary -> SetFileName( "hijing.starsim.root");
    chain -> AddBefore( "geant", _primary );
  }




  // Setup an event generator
  //
  Hijing();
  //
  // Setup single hypertritons
  //  
  HyperTritons(); 
 

  //
  // Initialize primary event generator and all sub makers
  //
  _primary -> Init();

  //
  // Setup geometry and set starsim to use agusread for input
  //
  //geometry("y2012");
  command("gkine -4 0");
  command("gfile o hijing.starsim.fzd");
  
  //
  // Trigger on nevents
  //
  trig( nevents );

  _primary->event()->Print();

  //  command("gprint kine");

  command("call agexit");  // Make sure that STARSIM exits properly

}
Example #6
0
/* random_helix_or_trig */
static unsigned long
helix_draw (Display *dpy, Window window, void *closure)
{
  struct state *st = (struct state *) closure;
  Bool free_color = False;
  XColor color;
  int delay = st->subdelay;
  int erase_delay = 10000;
  int ii;

  if (st->eraser) {
    st->eraser = erase_window (dpy, window, st->eraser);
    if (st->eraser) 
      delay = erase_delay;
    goto END;
  }

  switch (st->dstate) 
    {
    case LINGER:
      delay = st->sleep_time * 1000000;
      st->dstate = ERASE;
      break;

    case ERASE:
      st->eraser = erase_window (dpy, window, st->eraser);
      delay = erase_delay;
      if (free_color) XFreeColors (dpy, st->cmap, &color.pixel, 1, 0);
      st->dstate = (random() & 1) ? HELIX : TRIG;
      break;

    case DRAW_HELIX:
      for (ii = 0; ii < 10; ii++) {
        helix (dpy, window, st);
        if (st->dstate != DRAW_HELIX)
          break;
      }
      break;

    case DRAW_TRIG:
      for (ii = 0; ii < 5; ii++) {
        trig (dpy, window, st);
        if (st->dstate != DRAW_TRIG)
          break;
      }
      break;

    case HELIX:
      random_helix (dpy, window, st, &color, &free_color);
      st->dstate = DRAW_HELIX;
      break;

    case TRIG:
      random_trig(dpy, window, st, &color, &free_color);
      st->dstate = DRAW_TRIG;
      break;

    default: 
      abort();
    }

 END:
  return delay;
}
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void starsim( Int_t nevents=10, Int_t rngSeed=4321 )
{ 

  gROOT->ProcessLine(".L bfc.C");
  {
    TString simple = "y2014a geant gstar usexgeom agml ";
    bfc(0, simple );
  }

  gSystem->Load( "libVMC.so");

  gSystem->Load( "StarGeneratorUtil.so" );
  gSystem->Load( "StarGeneratorEvent.so" );
  gSystem->Load( "StarGeneratorBase.so" );
  gSystem->Load( "libMathMore.so"   );  
  gSystem->Load( "libHijing1_383.so");
  gSystem->Load( "libKinematics.so");
  gSystem->Load( "xgeometry.so"     );

  // force gstar load/call
  gSystem->Load( "gstar.so" );
  command("call gstar");

  // Setup RNG seed and map all ROOT TRandom here
  StarRandom::seed( rngSeed );
  StarRandom::capture();

  //
  // Create the primary event generator and insert it
  // before the geant maker
  //
  _primary = new StarPrimaryMaker();
  {
    _primary -> SetFileName( "hijing.starsim.root");
    chain -> AddBefore( "geant", _primary );
  }

  //
  // These should be adjusted to your best vertex estimates
  //
  _primary -> SetVertex( 0., 0., 0. );
  _primary -> SetSigma(  0.3, 0.3, 60.0 );




  // Setup an event generator
  //
  Hijing();
  //
  // Setup single dalitzdecay
  //  
  Dalitzdecay(); 
 

  //
  // Initialize primary event generator and all sub makers
  //
  _primary -> Init();


  //
  // Setup geometry and set starsim to use agusread for input
  //

  command("gkine -4 0");
  command("gfile o hijing.starsim.fzd");
  
  //
  // Trigger on nevents
  //
  trig( nevents );

  _primary->event()->Print();

  //  command("gprint kine");

  command("call agexit");  // Make sure that STARSIM exits properly

}
int main (void)
{
  stralloc indata = STRALLOC_ZERO ;
  unsigned int instate = 0 ;
  PROG = "s6-ftrigrd" ;

  if (ndelay_on(0) < 0) strerr_diefu2sys(111, "ndelay_on ", "0") ;
  if (ndelay_on(1) < 0) strerr_diefu2sys(111, "ndelay_on ", "1") ;
  if (sig_ignore(SIGPIPE) < 0) strerr_diefu1sys(111, "ignore SIGPIPE") ;

  {
    struct taia deadline, stamp ;
    taia_now(&stamp) ;
    taia_addsec(&deadline, &stamp, 2) ;
    if (!skaserver2_sync(&asyncout, FTRIGR_BANNER1, FTRIGR_BANNER1_LEN, FTRIGR_BANNER2, FTRIGR_BANNER2_LEN, &deadline, &stamp))
      strerr_diefu1sys(111, "sync with client") ;
  }

  for (;;)
  {
    register unsigned int n = genalloc_len(ftrigio_t, &a) ;
    iopause_fd x[3 + n] ;
    unsigned int i = 0 ;
    int r ;

    x[0].fd = 0 ; x[0].events = IOPAUSE_EXCEPT | IOPAUSE_READ ;
    x[1].fd = 1 ; x[1].events = IOPAUSE_EXCEPT | (bufalloc_len(bufalloc_1) ? IOPAUSE_WRITE : 0) ;
    x[2].fd = bufalloc_fd(&asyncout) ; x[2].events = IOPAUSE_EXCEPT | (bufalloc_len(&asyncout) ? IOPAUSE_WRITE : 0) ;
    for (; i < n ; i++)
    {
      register ftrigio_t_ref p = genalloc_s(ftrigio_t, &a) + i ;
      p->xindex = 3 + i ;
      x[3+i].fd = p->trig.fd ;
      x[3+i].events = IOPAUSE_READ ;
    }

    r = iopause(x, 3 + n, 0, 0) ;
    if (r < 0)
    {
      cleanup() ;
      strerr_diefu1sys(111, "iopause") ;
    }

   /* client closed => exit */
    if ((x[0].revents | x[1].revents) & IOPAUSE_EXCEPT) break ;

   /* client reading => flush pending data */
    if (x[1].revents & IOPAUSE_WRITE)
      if ((bufalloc_flush(bufalloc_1) == -1) && !error_isagain(errno))
      {
        cleanup() ;
        strerr_diefu1sys(111, "flush stdout") ;
      }
    if (x[2].revents & IOPAUSE_WRITE)
      if ((bufalloc_flush(&asyncout) == -1) && !error_isagain(errno))
      {
        cleanup() ;
        strerr_diefu1sys(111, "flush asyncout") ;
      }

   /* scan listening ftrigs */
    for (i = 0 ; i < genalloc_len(ftrigio_t, &a) ; i++)
    {
      register ftrigio_t_ref p = genalloc_s(ftrigio_t, &a) + i ;
      if (x[p->xindex].revents & IOPAUSE_READ)
      {
        char c ;
        register int r = sanitize_read(fd_read(p->trig.fd, &c, 1)) ;
        if (!r) continue ;
        if (r < 0)
        {
          trig(p->id, 'd', errno) ;
          remove(i--) ;
        }
        else if (!sredfa_feed(p->re, &p->dfastate, c))
        {
          trig(p->id, 'd', ENOEXEC) ;
          remove(i--) ;
        }
        else if (p->dfastate & SREDFA_ACCEPT)
        {
          trig(p->id, '!', c) ;
          if (p->options & FTRIGR_REPEAT)
            p->dfastate = SREDFA_START ;
          else remove(i--) ;
        }
      }
    }

   /* client writing => get data and parse it */
    if (buffer_len(buffer_0small) || x[0].revents & IOPAUSE_READ)
    {
      int r ;
      for (;;)
      {
        uint16 id ;
        r = sanitize_read(netstring_get(buffer_0small, &indata, &instate)) ;
        if (r <= 0) break ;
        if (indata.len < 3)
        {
          cleanup() ;
          strerr_dief1x(100, "invalid client request") ;
        }
        uint16_unpack_big(indata.s, &id) ;
        switch (indata.s[2])  /* protocol parsing */
        {
          case 'U' : /* unsubscribe */
          {
            register unsigned int i = genalloc_len(ftrigio_t, &a) ;
            for (; i ; i--) if (genalloc_s(ftrigio_t, &a)[i-1].id == id) break ;
            if (i) remove(i-1) ;
            answer(0) ;
            break ;
          }
          case 'L' : /* subscribe to path and match re */
          {
            ftrigio_t f = FTRIGIO_ZERO ;
            uint32 pathlen, relen ;
            if (indata.len < 18)
            {
              answer(EPROTO) ;
              break ;
            }
            uint32_unpack_big(indata.s + 3, &f.options) ;
            uint32_unpack_big(indata.s + 7, &pathlen) ;
            uint32_unpack_big(indata.s + 11, &relen) ;
            if (((pathlen + relen + 16) != indata.len) || indata.s[15 + pathlen])
            {
              answer(EPROTO) ;
              break ;
            }
            f.id = id ;
            if (!stralloc_0(&indata))
            {
              answer(errno) ;
              break ;
            }
            f.re = sredfa_new() ;
            if (!f.re)
            {
              answer(errno) ;
              break ;
            }
            if (!sredfa_from_regexp(f.re, indata.s + 16 + pathlen)
             || !ftrig1_make(&f.trig, indata.s + 15))
            {
              sredfa_delete(f.re) ;
              answer(errno) ;
              break ;
            }
            if (!genalloc_append(ftrigio_t, &a, &f))
            {
              ftrigio_deepfree(&f) ;
              answer(errno) ;
              break ;
            }
            answer(0) ;
            break ;
          }
          default :
          {
            cleanup() ;
            strerr_dief1x(100, "invalid client request") ;
          }
        }
        indata.len = 0 ;
      } /* end loop: parse input from client */

      if (r < 0)
      {
        if (errno == EPIPE) break ; /* client closed */
        else
        {
          cleanup() ;
          strerr_diefu1sys(111, "read a netstring") ;
        }
      } 
    } /* end if: stuff to read on stdin */
  } /* end loop: main iopause */

  cleanup() ;
  return 0 ;
}
Example #9
0
void starsim( Int_t nevents=10, Int_t Index = 0, Int_t rngSeed=4321 )
{ 

  gROOT->ProcessLine(".L bfc.C");
  {
    TString simple = "y2013_1c geant gstar usexgeom agml ";
    bfc(0, simple );
  }

  gSystem->Load( "libVMC.so");

  gSystem->Load( "StarGeneratorUtil.so" );
  gSystem->Load( "StarGeneratorEvent.so" );
  gSystem->Load( "StarGeneratorBase.so" );
  gSystem->Load( "StarGeneratorDecay.so" );
  gSystem->Load( "libMathMore.so"   );
  gSystem->Load( "libHijing1_383.so");
  gSystem->Load( "libKinematics.so");
  gSystem->Load( "xgeometry.so"     );

  gSystem->Load("libHepMC2_06_09.so");
  gSystem->Load("libPythia8_1_86.so");
  gSystem->Load("libPhotos3_61.so");
  gSystem->Load("libTauola1_1_5.so");
  gSystem->Load("libEvtGen1_06_00.so");


  // Setup RNG seed and map all ROOT TRandom here
  StarRandom::seed( rngSeed );
  StarRandom::capture();

  //  char rootname[100],fzname[100];
  //  sprintf(rootname,"st_pythiaevtgen_%d.starsim.root",Index);
  //  sprintf(fzname,"gfile o st_pythiaevtgen_%d.starsim.fzd",Index);
  TString rootname = "pythia6.reader.root";
  TString fzname   = "gfile o pythia6.reader.fzd";

  //
  // Create the primary event generator and insert it
  // before the geant maker
  //
  _primary = new StarPrimaryMaker();
  {
    _primary -> SetFileName(rootname);
    chain -> AddBefore( "geant", _primary );
  }

  //
  // These should be adjusted to your best vertex estimates
  //
  _primary -> SetVertex( vx,vy,vz );
  _primary -> SetSigma( vx_sig,vy_sig,vz_sig );

  //
  // Setup an event generator
  //
  //  Pythia6("pp:W");
  Pythia6( "pythia6.standalone.root" ); // input

  //
  // Setup decay manager
  //
  StarDecayManager   *decayMgr = AgUDecay::Manager();

  //
  // Output a decay table for taus which specifies Tauola as the decay model
  //
  {
    ofstream out("TAUS.DEC");
    const char* cmds[] = {
      "Decay tau-",      // 1
      "1.0 TAUOLA 0;",   // 2
      "Enddecay",        // 3
      "CDecay tau+",     // 4
      "End"              // 5
    };
    for ( int i=0;i<5;i++ ) 
      {
	out << cmds[i] << endl;
      }
  }
 
  // //
  // // Setup EvtGen to decay most particles in STAR
  // //
  // StarEvtGenDecayer *decayEvt = new StarEvtGenDecayer();
  // decayEvt->SetDecayTable("TAUS.DEC");
  // decayMgr->AddDecayer(  23, decayEvt ); // Handle any decay requested
  // decayMgr->AddDecayer( +15, decayEvt ); // Handle any decay requested [tau+]
  // decayMgr->AddDecayer( -15, decayEvt ); // Handle any decay requested [tau-]
  // decayEvt->SetDebug(0);


  //
  // Setup pythia8 to decay W+ and W- (and possibly others...)
  //
  StarPythia8Decayer *decayPy8 = new StarPythia8Decayer();
  decayMgr -> AddDecayer( 0, decayPy8 );
  decayMgr->AddDecayer( +24, decayPy8 );
  decayMgr->AddDecayer( -24, decayPy8 );
  decayMgr->AddDecayer( +23, decayPy8 );
  decayMgr->AddDecayer( -23, decayPy8 );
  decayPy8->SetDebug(1);


  // Allow W to e+ nu or e- nu only
  decayPy8->Set("24:onMode  = 0");
  decayPy8->Set("24:onIfAny = 11 -11");
  decayPy8->Set("23:onMode  = 0");
  decayPy8->Set("23:onIfAny = 15 -15");

    
  //
  // Initialize primary event generator and all sub makers
  //
  _primary -> Init();

  //return;

  //
  // Setup geometry and set starsim to use agusread for input
  //
  geometry("y2013_1c");
  command("gkine -4 0");
  command(fzname);


  //
  // Limits on eta, pt, ...
  //
  _primary->SetPtRange(0,-1.0); // no limits
  _primary->SetEtaRange(-2.5,2.5);

  //
  // Trigger on nevents
  //
  trig( nevents );

  //  _primary->event()->Print();

  command("call agexit");  // Make sure that STARSIM exits properly
  //  command("gprint kine");
}
Example #10
0
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
void starsim( Int_t nevents=50, Int_t rngSeed=1234 )
{ 

  gROOT->ProcessLine(".L bfc.C");
  {
    TString simple = "y2012 geant gstar usexgeom agml ";
    //TString full   = "tpcrs TpxRaw y2010a MakeEvent ITTF NoSvtIt NoSsdIt Idst IAna l0 ftpc Sti Tree logger genvtx tpcDB TpcHitMover TpxClu pmd bbcSim tofsim tags emcY2 EEfs evout IdTruth geantout -dstout big fzin MiniMcMk clearmem";
    //  TString full = "y2012 geant gstar tpcrs genvtx tpcDb tpxclu dedx event sdt20120224 ";
    bfc(0, simple );
  }

  gSystem->Load( "libVMC.so");

  gSystem->Load( "StarGeneratorUtil.so" );
  gSystem->Load( "StarGeneratorEvent.so" );
  gSystem->Load( "StarGeneratorBase.so" );
  gSystem->Load( "libMathMore.so"   );  
  gSystem->Load( "libHijing1_383.so");
  gSystem->Load( "xgeometry.so"     );

  // Setup RNG seed and map all ROOT TRandom here
  StarRandom::seed( rngSeed );
  StarRandom::capture();
  
  //
  // Create the primary event generator and insert it
  // before the geant maker
  //
  primary = new StarPrimaryMaker();
  {
    primary -> SetFileName( "hijing.starsim.root");
    chain -> AddBefore( "geant", primary );
  }


  //
  // Setup an event generator
  //
  Hijing();

  //
  // Initialize primary event generator and all sub makers
  //
  primary -> Init();

  //
  // Setup geometry and set starsim to use agusread for input
  //
  //geometry("y2012");
  command("gkine -4 0");
  command("gfile o hijing.starsim.fzd");
  
  //
  // Trigger on nevents
  //
  trig( nevents );
  command("gprint kine");

  //  command("call agexit");  // Make sure that STARSIM exits properly

}
Example #11
0
int Eyes::scan() {
    trig();
    return echo();
}
Example #12
0
///////////////////////////////////////////////////////////////////////
// RUN THE ARPEGGIATOR STATE MACHINE
void CLogicalChannel::runArpeggiator() 
{
    // Arpeggiator can only run on single note channel (mono or unison) and only
    // if arpeggiation is enabled!
    if((m_conf->flags & TONE_CONFIG::ARPEGGIATE) && isSingleNoteChan(m_conf) && (m_noteCount > 0)) {

      float arpRate;      
      switch(m_conf->arpRateModSrc) {
        case TONE_CONFIG::MODSRC_WHEEL:
          arpRate = m_fModWheel; 
          break;
        case TONE_CONFIG::MODSRC_ENV:  //TODO
        case TONE_CONFIG::MODSRC_LFO:  //TODO
        case TONE_CONFIG::MODSRC_NONE:
        default:
           arpRate = m_conf->arpRate/127.0;
          break;
      }
      
      
/*      
      if(m_conf->modEnvDest & TONE_CONFIG::TO_ARP_RATE) {
        arpPeriod *= (1.0-Voice[m_voiceBegin].m_mod.fValue); // NB - mod is of RATE not period
      } 
      else if(m_conf->modEnvDestNeg & TONE_CONFIG::TO_ARP_RATE) {
        arpPeriod *= Voice[m_voiceBegin].m_mod.fValue;
      }

      if(m_conf->lfoDest & TONE_CONFIG::TO_ARP_RATE) {
        arpPeriod *= (1.0-m_fLFO);
      } 
      else if(m_conf->lfoDestNeg & TONE_CONFIG::TO_ARP_RATE) {
        arpPeriod *= m_fLFO;
      }
*/      
      // convert arp rate into arp period
      int arpPeriod = 100/(1+arpRate) - 50;
      
      // check if next note is due
      if(--m_arpCounter <= 0)
      {          
        // determine the next note
        if(m_arpIndex >= m_noteCount) { // reached the last note?            
          if(m_noteCount > m_conf->arpCount) { // need to arp just recent notes?
            m_arpIndex = m_noteCount - m_conf->arpCount;
          } 
          else {
            m_arpIndex = 0;
          }            
        }      
        
        // trigger the bext note
        trig(
          m_notes[m_arpIndex].note,  
          (m_conf->flags & TONE_CONFIG::USE_VELOCITY)? m_notes[m_arpIndex].velocity : 127, !!(m_conf->flags & TONE_CONFIG::ARP2ENV)
        );      
        ++m_arpIndex;
        m_arpCounter = arpPeriod;
      }
      else if(m_arpCounter > arpPeriod) {
        // in case CC is being swept down from a long value
        m_arpCounter = arpPeriod;
      }
    }
}
Example #13
0
void cMiniBench::RunTests()
{
   if( TestsToRun[ eAes ] )
   {
      StatusBarUpdate( "Running AES ECB Encypt/Decrypt Tests..." );
      cAesBench AesBench;

      StatusBarUpdate( "Running AES 8kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark8KB( true ), "AES ECB Encrypt 8kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark8KB( true ), "AES ECB Decrypt 8kB score: " );

      StatusBarUpdate( "Running AES 16kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark16KB( true ), "AES ECB Encrypt 16kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark16KB( true ), "AES ECB Decrypt 16kB score: " );

      StatusBarUpdate( "Running AES 32kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark32KB( true ), "AES ECB Encrypt 32kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark32KB( true ), "AES ECB Decrypt 32kB score: " );

      StatusBarUpdate( "Running AES 64kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark64KB( true ), "AES ECB Encrypt 64kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark64KB( true ), "AES ECB Decrypt 64kB score: " );

      StatusBarUpdate( "Running AES 128kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark128KB( true ), "AES ECB Encrypt 128kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark128KB( true ), "AES ECB Decrypt 128kB score: " );

      StatusBarUpdate( "Running AES 256kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark256KB( true ), "AES ECB Encrypt 256kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark256KB( true ), "AES ECB Decrypt 256kB score: " );

      StatusBarUpdate( "Running AES 512kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark512KB( true ), "AES ECB Encrypt 512kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark512KB( true ), "AES ECB Decrypt 512kB score: " );

      StatusBarUpdate( "Running AES 1024kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark1024KB( true ), "AES ECB Encrypt 1024kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark1024KB( true ), "AES ECB Decrypt 1024kB score: " );

      StatusBarUpdate( "Running AES 2048kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark2048KB( true ), "AES ECB Encrypt 2048kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark2048KB( true ), "AES ECB Decrypt 2048kB score: " );

      StatusBarUpdate( "Running AES 4096kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark4096KB( true ), "AES ECB Encrypt 4096kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark4096KB( true ), "AES ECB Decrypt 4096kB score: " );

      StatusBarUpdate( "Running AES 8192kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark8192KB( true ), "AES ECB Encrypt 8192kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark8192KB( true ), "AES ECB Decrypt 8192kB score: " );

      StatusBarUpdate( "Running AES 16384kB ECB Encypt/Decrypt Tests..." );
      OutputRaw( AesBench.runEncryptBenchmark16384KB( true ), "AES ECB Encrypt 16384kB score: " );
      OutputRaw( AesBench.runDecryptBenchmark16384KB( true ), "AES ECB Decrypt 16384kB score: " );
    }

   if( TestsToRun[ eDhrystone ] )
   {
      StatusBarUpdate( "Running Dhrystone..." );
      CDhryApp dhry( 20000000 );
      OutputSeconds( dhry.RunTest( 20000000 ), "Dhrystone" );
   }

   if( TestsToRun[ eDoubleArithmetic ] )
   {
      StatusBarUpdate( "Running Double Arithmetic..." );
      OutputSeconds( doubleArithmetic( 10000000000.0, 11000000000.0 ), "Double Arithmetic (s): " );
   }

   if( TestsToRun[ eFibonacci ] )
   {
      StatusBarUpdate( "Running Fibonacci( 42 )..." );
      cFibTest FibTest( 1 );
      OutputSeconds( FibTest.Run(), "Fib(42)" );
   }


   if( TestsToRun[ eFft ] )
   {
      StatusBarUpdate( "Running FFT..." );
      cFFT FFT( 1 );
      OutputSeconds( FFT.Run(), "FFT" );
   }

   if( TestsToRun[ eFlops ] )
   {
      cFlops lFlops;

      // addition:
      StatusBarUpdate( "MFLOPS SP Add..." );
      OutputRaw( lFlops.runFpuFloatAddTest(), "MFLOPS (SP add): " );
      StatusBarUpdate( "MFLOPS DP Add..." );
      OutputRaw( lFlops.runFpuDoubleAddTest(), "MFLOPS (DP add): " );
      // multiplication
      StatusBarUpdate( "MFLOPS SP Mul..." );
      OutputRaw( lFlops.runFpuFloatMulTest(), "MFLOPS (SP mul): " );
      StatusBarUpdate( "MFLOPS DP Mul..." );
      OutputRaw( lFlops.runFpuDoubleMulTest(), "MFLOPS (DP mul): " );
      // division:
      StatusBarUpdate( "MFLOPS SP Div..." );
      OutputRaw( lFlops.runFpuFloatDivTest(), "MFLOPS (SP div): " );
      StatusBarUpdate( "MFLOPS DP Div..." );
      OutputRaw( lFlops.runFpuDoubleDivTest(), "MFLOPS (DP div): " );
      // mul-add:
      StatusBarUpdate( "MFLOPS DP Mul-Add..." );
      OutputRaw( lFlops.runFpuDoubleMulAdd3Test(), "MFLOPS (DP mul-add): " );
   }

   if( TestsToRun[ eHeapSort ] )
   {
      StatusBarUpdate( "Running Heap Sort..." );
      OutputSeconds( HeapSortTest( 5000000 ), "Heap Sort (s): " );
   }

   if( TestsToRun[ eIntArithmetic ] )
   {
      StatusBarUpdate( "Running Integer Arithmetic..." );
      OutputSeconds( intArithmetic( 1000000000 ), "Integer Arithmetic (s): " );
   }

   if( TestsToRun[ eInt64Arithmetic ] )
   {
      StatusBarUpdate( "Running 64-bit Arithmetic..." );
      OutputSeconds( longArithmetic( 10000000000LL, 11000000000LL ), "64-bit Arithmetic (s): " );
   }

   if( TestsToRun[ eIntegerMatrixMul ] )
   {
      StatusBarUpdate( "Running Integer Matrix Multiplication..." );
      OutputSeconds( IntegerMatrixMultiplication( 1 ), "Integer Matrix Multiplication (s): " );
   }

   if( TestsToRun[ eIO ] )
   {
      StatusBarUpdate( "Running I/O..." );
      OutputSeconds( io( 10000000 ), "I/O (s): " );
      remove( "DeleteMe_minibench.txt" );
   }

   if( TestsToRun[ eLinpack ] )
   {
      cLinpackTest lLinpack( 1 );

      StatusBarUpdate( "Running Linpack rolled..." );
      lLinpack.Run();
      OutputRaw( lLinpack.GetFlops(), "LinPack rolled (FLOPS): " );

      StatusBarUpdate( "Running Linpack unrolled..." );
      lLinpack.SetRolling( eUnrolled );
      lLinpack.Run();
      OutputRaw( lLinpack.GetFlops(), "LinPack unrolled (FLOPS): " );
   }

   if( TestsToRun[ eAllMemoryTests] )
   {
      StatusBarUpdate( "Memory Bandwidth Integer Write (MB/s): " );
      OutputRaw( BandwidthIntegerWrite( 2000000 ), "Memory Bandwidth Integer Write (MB/s): " );

      StatusBarUpdate( "Memory Bandwidth MemCpy (MB/s): " );
      OutputRaw( BandwidthMemCpy( 2000000 ), "Memory Bandwidth MemCpy (MB/s): " );

      StatusBarUpdate( "Memory Bandwidth Double Copy (MB/s): " );
      OutputRaw( BandwidthDoubleCopy( 2000000 ), "Memory Bandwidth Double Copy (MB/s): " );
   }

   if( TestsToRun[ eRandomAssignment ] )
   {
      StatusBarUpdate( "Memory Latency Random Assignment (MB/s): " );
      OutputRaw( RandomAssignment( 2000000 ), "Memory Latency Random Assignment (MB/s): " );
   }

   if( TestsToRun[ ePi ] )
   {
      StatusBarUpdate( "Running Pi( 10,000 )..." );
      int i = 0;

      {
        i += PiTest( 10000 );
      }
      OutputSeconds( i, "Pi to 10,000 digits (s): " );
   }

   if( TestsToRun[ eQueens ] )
   {
      StatusBarUpdate( "Running Queens..." );
      double ldRunTime = 0;
      cQueensTest Queens( 1 );
      ldRunTime = Queens.Run();
/*      #pragma omp parallel
      {
        num_threads = omp_get_num_threads();
        CQueens Queens;
        #pragma omp atomic
        ldRunTime += Queens.RunTest(25000);
      }
*/
      cout << "Queens (seconds per thread): " << ldRunTime << endl;
      cout << "Number of threads = " << Queens.GetNumberOfThreads() << endl;
   }

   if( TestsToRun[ eSha1 ] )
   {
      StatusBarUpdate( "Running SHA1 Tests..." );
      cSha1Bench lSha1Bench;
      if( lSha1Bench.runSha1ValidationTests( true ) )
      {
        OutputSeconds( lSha1Bench.runBenchmark( true ), "SHA1 (s): " );
   //     OutputRaw( lSha1Bench.getScoreOverall() );
   //     OutputRaw( lSha1Bench.getScoreForSmallStrings(), "SHA1 small strings: " );
   //       Sha1Score50KString = lSha1Bench.getScoreFor50kString();
   //       Sha1Score1MString = lSha1Bench.getScoreFor1MString();
   //       Sha1Score10MString = lSha1Bench.getScoreFor10MString();
   //     } // if
      } else
      {
        cerr << "Sha1 validation tests failed!" << endl;
        StatusBarUpdate( "Sha1 validation tests failed!" );
      } // if...else
   }

   if( TestsToRun[ eSha256 ] )
   {
      cSha256Bench lSha256Bench;
      if( lSha256Bench.runSha256ValidationTests( true ) )
      {
         StatusBarUpdate( "Executing SHA-256 timed tests..." );
         OutputSeconds( lSha256Bench.runBenchmark( true ), "SHA256 (s): " );
   //      cerr << "The benchmark took " << TestTime << " milliseconds for all hash tests." << endl;
   //      if( Sha256ScoreOverall < lSha256Bench.getScoreOverall() )
   //      {
   //        Sha256ScoreOverall = lSha256Bench.getScoreOverall();
   //        Sha256ScoreSmallStrings = lSha256Bench.getScoreForSmallStrings();
   //        Sha256Score50KString = lSha256Bench.getScoreFor50kString();
   //        Sha256Score1MString = lSha256Bench.getScoreFor1MString();
   //        Sha256Score10MString = lSha256Bench.getScoreFor10MString();
   //      } // if
       } else
       {
         StatusBarUpdate( "Sha256 validation tests failed!" );
       } // if...else
    }

   if( TestsToRun[ eSieve ] )
   {
      StatusBarUpdate( "Sieve..." );
      OutputSeconds( Sieve( 50000 ), "Sieve (s): " );
   }

   if( TestsToRun[ eStringConcat ] )
   {
      StatusBarUpdate( "String Concatenation..." );
      OutputSeconds( StringConcatenation( 40000000 ), "String Concatenation (s): " );
   }

   if( TestsToRun[ eTrig ] )
   {
      StatusBarUpdate( "Running Trig..." );
      OutputSeconds( trig( 10000000 ), "Trig (s): " );
   }

   if( TestsToRun[ eWhetstone ] )
   {
      StatusBarUpdate( "Running Whetstone..." );
      CWhetApp whet;
      OutputSeconds( whet.RunTest( 50000 ), "Whetstone (s): " );
   }

   StatusBarUpdate( "All tests finished!" );
}