// Macro for running Panda simulation  with Geant3  or Geant4
// This macro is supposed to run the full simulation of the panda detector
// to run the macro:
//
// root -l -b -q tut_sim.C
//
// to run with different options:(e.g more events, different momentum, Geant4)
//
// root -l -b -q 'tut_sim.C(1000,"mydata","mydecay.dec",10.0,"TGeant4")'

void sim_pythia6ascii(Int_t nEvents = 100, TString  SimEngine ="TGeant4", Double_t BeamMomentum = 15.)
{
  //-----User Settings:------------------------------------------------------
  TString  parAsciiFile   = "all.par";
  //TString  inputGenerator = "box_1pi_1GeV_theta10-120";
  TString  inputGenerator = "pythia6test";
//  TString pythiaFile = "DYee15GeV_108277.dat";
  TString pythiaFile = "test.dat";
  //-------------------------------------------------------------------------
  // -----   Create the Simulation run manager ------------------------------
  PndMasterRunSim *fRun = new PndMasterRunSim();
  fRun->SetInput(inputGenerator);
  fRun->SetName(SimEngine);
  fRun->SetParamAsciiFile(parAsciiFile);
  fRun->SetNumberOfEvents(nEvents);
  fRun->SetBeamMom(BeamMomentum);
  // -----  Initialization   ------------------------------------------------
  fRun->Setup();
  // -----   Geometry   -----------------------------------------------------
  fRun->CreateGeometry();
  // -----   Event generator   ----------------------------------------------
  //  fRun->SetGenerator(); // Automatic setting by InputGenerator
  PndPythia6Generator *pythiaReader=new PndPythia6Generator(pythiaFile.Data());
  fRun->SetGenerator(pythiaReader);
  
  // -----   Add tasks   ----------------------------------------------------
  fRun->AddSimTasks();
  // -----   Intialise and run   --------------------------------------------
  fRun->Init();
  fRun->Run(nEvents);
  fRun->Finish();
  
  //exit(0);
};


