// $Id: g4Config.C,v 1.2 2006/03/30 11:47:27 dbertini Exp $
//
// Configuration macro for Geant4 VirtualMC for Example01

void Config()
{
     
         TG4RunConfiguration* runConfiguration 
    = new TG4RunConfiguration("geomRoot", "LHEP_BERT+emStandard+optical", "specialCuts");
      
      
      

 cout << "Geant4 has been created. 1 " << endl;

  // TGeant4
  // TGeant4 *geant4= new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);
      TGeant4* geant4
      = new TGeant4("TGeant4", "The Geant4 Monte Carlo", runConfiguration);
  // create the Specific stack
    CbmStack *stack = new CbmStack(1000);
     stack->StoreSecondaries(kTRUE);
    stack->SetMinPoints(0);
     geant4->SetStack(stack);

   if(CbmRunSim::Instance()->IsExtDecayer()){
   	TVirtualMCDecayer* decayer = TPythia6Decayer::Instance();
   	geant4->SetExternalDecayer(decayer);
       //runConfiguration->SetExternalDecayer(decayer);
   }


  geant4->SetProcess("PAIR",1); /** pair production*/
  geant4->SetProcess("COMP",1); /**Compton scattering*/
  geant4->SetProcess("PHOT",1); /** photo electric effect */
  geant4->SetProcess("PFIS",0); /**photofission*/
  geant4->SetProcess("DRAY",1); /**delta-ray*/
  geant4->SetProcess("ANNI",1); /**annihilation*/
  geant4->SetProcess("BREM",1); /**bremsstrahlung*/
  geant4->SetProcess("HADR",1); /**hadronic process*/
  geant4->SetProcess("MUNU",1); /**muon nuclear interaction*/
  geant4->SetProcess("DCAY",0); /**decay*/
  geant4->SetProcess("LOSS",1); /**energy loss*/
  geant4->SetProcess("MULS",1); /**multiple scattering*/

 
  Double_t cut1=1.0E-3; //GeV
  Double_t tofmax = 1.0; //seconds

  geant4->SetCut("CUTGAM",cut1);   /** gammas (GeV)*/
  geant4->SetCut("CUTELE",cut1);   /** electrons (GeV)*/
  geant4->SetCut("CUTNEU",cut1);   /** neutral hadrons (GeV)*/
  geant4->SetCut("CUTHAD",cut1);   /**charged hadrons (GeV)*/
  geant4->SetCut("CUTMUO",cut1);   /** muons (GeV)*/
  geant4->SetCut("BCUTE",cut1);    /**electron bremsstrahlung (GeV)*/
  geant4->SetCut("BCUTM",cut1);    /**muon and hadron bremsstrahlung(GeV)*/ 
  geant4->SetCut("DCUTE",cut1);    /**delta-rays by electrons (GeV)*/
  geant4->SetCut("DCUTM",cut1);    /**delta-rays by muons (GeV)*/
  geant4->SetCut("PPCUTM",cut1);   /**direct pair production by muons (GeV)*/
  geant4->SetCut("TOFMAX",tofmax); /**time of flight cut in seconds */

     cout << "Geant4 has been created." << endl;
  
  // Customise Geant4 setting
  // (verbose level, global range cut, ..)

  TString configm(gSystem->Getenv("VMCWORKDIR"));
  configm = configm + "/gconfig/g4config.in";
  cout << " -I g4Config() using g4conf  macro: " << configm << endl;

  geant4->SetMaxNStep(10000);  // default is 30000
  geant4->ProcessGeantMacro(configm.Data());


                  
  

}
