// ----------------------------------------------------------------------------
// $Id: stdhep_GoGenMC.C,v 1.4 2001/05/11 21:52:56 toshi Exp $
// ----------------------------------------------------------------------------
// $Log: stdhep_GoGenMC.C,v $
// Revision 1.4  2001/05/11 21:52:56  toshi
// Remove .so suffix from gSystem->Load("...") in order to call macros from
// Windows system.
//
// Revision 1.3  2001/05/09 22:10:13  toshi
// Add $Id: stdhep_GoGenMC.C,v 1.4 2001/05/11 21:52:56 toshi Exp $.
//
// Revision 1.2  2001/05/01 20:33:18  masako
// Bug fix.
// Correct typo miss.
//
//
//  Example file for event generation interactively with Root.
//  
//  In this file, 1) event generation (e+e- -> ZH) with pandora_pythia
//                2) out put a stdhep file
//        
//        Apr. 26 2001  Toshi
//
//   :: How to run ::
// 
//   1) type root
//   2)
//      root [0]  .x stdhep_GoGenMC.C
//
// For example, if you like to generate 20 events, type like
//      root [0]  .x stdhep_GoGenMC.C(20)

//__________________________________________________________________________
Int_t stdhep_GoGenMC(Int_t nEvent=100){

  gROOT->Reset();

  // In order to refer to shareable libraries in this simple form,
  // include their paths in a .rootrc file.

  gSystem->Load("libPandora");
  gSystem->Load("libPandoraProc");
  gSystem->Load("libPythia6");
  gSystem->Load("libEG");
  gSystem->Load("libEGPythia6");
  gSystem->Load("libTauola");
  gSystem->Load("libPandPyth");
  //gSystem->Load("libLCDEvent");
  //gSystem->Load("libLCDRootAppsUtil");
  //gSystem->Load("libLCDFastMC");
  //gSystem->Load("libLCDPhUtil");
  //gSystem->Load("libLCDGenUtil");


  //------------ Out put file (stdhep)
  Char_t* outfile = "test.dat";


  //------------< Setup Generator (Pandora-Pythia) >------------------------
  cout<<"Start Generator Setup!"<<endl;

#include "pandpythconsts.h"

  Int_t iseed_pan = 7;  // default pandora initial seed

  /*    define the pandora event selection in this space     */
  
  double ECM  = 500.;
  double PolE = -0.8; // Polarization Electron
  double PolP =  0.0; // Polarization Positron

  ebeam b1(ECM/2.0, PolE, electron, electron);
  b1.setup(NLC500);
  b1.ISRoff();            // Turn off initial-state radiation
  b1.beamstrahlungoff();  // Turn off beamstrahlung

  //Int_t positron = -11;
  ebeam b2(ECM/2.0, PolP, positron, positron);
  b2.setup(NLC500);
  b2.ISRoff();
  b2.beamstrahlungoff();
  
  double Hmass = 120.; // Higgs Mass
//double Hmass = 140.; // Higgs Mass
  eetoZHiggs pr(Hmass);

  //For example:: Z0 decays to anything. H0 decays to b only.
  pr.onlyDecay(allStates,bOnly); 

  pandora P(b1,b2,pr);
  
  const Int_t epluseminus  = 1;
  const Int_t gammagamma   = 2;
  const Int_t eminuseminus = 3;
  pandorarun  PR(&P, epluseminus, ECM, nEvent, iseed_pan);
  
  //----- For PYTHIA ------
  //Or you can also change PYTHIA seed here.
  int iseed_pyth = 22846; PR.newseed(iseed_pyth); // Change Seed

  //PR.partonshoweroff();   // Turn off parton shower
  //PR.fragmentationoff();  // Turn off fragmentation
  //PR.FSRoff();            // Turn off final-state QCD QED radiation

  PR.StdHepIOon();  // Use stdhep IO

  //       end of definition

  PR.initialize(outfile);
  
  // If you want/don't want to decay some specific particle(s),
  // you can call PartDecayOn/PartDecayOff here.   
  // For example: Do not allow to decay K0S and Lambda
  //int ipart1 = 310;  // K0S
  //int ipart2 = 3122; // Lambda
  //PR.PartDecayOff(ipart1);
  //PR.PartDecayOff(ipart2);


  cout<<"End of Generator Setup!"<<endl;=
  //------------< End Generator (Pandora-Pythia) setup>-------------------

  gBenchmark->Start("gen_eetoZH");

  PR->getevents();//Event Generation

  gBenchmark->Stop("gen_eetoZH");
  gBenchmark->Print("gen_eetoZH");

  PR.terminate();
}
