 //§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//*
//             LOW ENERGY MUON SPIN RELAXATION, ROTATION, RADIATION 
//
//  ID    : LEMuSRGeneralPhysics.cc , v 1.1
//  AUTHOR: Taofiq PARAISO
//  DATE  : 2004-08-24 16:33
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//
//
//  &           &&&&&&&&&&                            &&&&&&&         &&&&&&&&
//  &           &                                   &&      &&       &       &&
//  &           &                   &      &       &                &       &&
//  &           &&&&&&&            &      &         &&&&&&         &&&&&&&&  
//  &           &                 &      &&                &      &      &&
//  &           &                &&     &  &     &&      &&      &        &
//  &&&&&&&&&&  &&&&&&&&&&      &  &&&&&    &&    &&&&&&&       &        &&   
//                             &
//                            &
//                           &
//                         &  
//                               GENERAL PHYSICS
//§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§//

#include "LEMuSRGeneralPhysics.hh"

#include "globals.hh"
#include "G4ios.hh"
#include <iomanip>   
#include "G4StepLimiter.hh"


LEMuSRGeneralPhysics::LEMuSRGeneralPhysics(const G4String& name)
                     :  G4VPhysicsConstructor(name)
{
}

LEMuSRGeneralPhysics::~LEMuSRGeneralPhysics()
{
} 

#include "G4ParticleDefinition.hh"
#include "G4ProcessManager.hh"
// Bosons
#include "G4ChargedGeantino.hh"
#include "G4Geantino.hh"

#include "G4UserSpecialCuts.hh"
#include "G4Neutron.hh"


void LEMuSRGeneralPhysics::ConstructParticle()
{
  // pseudo-particles
  G4Neutron::Neutron();
  G4Geantino::GeantinoDefinition();
  G4ChargedGeantino::ChargedGeantinoDefinition();  
}

void LEMuSRGeneralPhysics::ConstructProcess()
{
  // Add Decay Process
  theParticleIterator->reset();
  while( (*theParticleIterator)() )
    {
   
      G4ParticleDefinition* particle = theParticleIterator->value();
      G4ProcessManager* pmanager = particle->GetProcessManager();
      if (fDecayProcess.IsApplicable(*particle)&&particle->GetParticleName()!="mu+"&&particle->GetParticleName()!="Mu") 
	{ 
	  pmanager ->AddProcess(&fDecayProcess);
	  //  set ordering for PostStepDoIt and AtRestDoIt
	  pmanager ->SetProcessOrdering(&fDecayProcess, idxPostStep);
	  pmanager ->SetProcessOrdering(&fDecayProcess, idxAtRest);
	}  
      if (particle->GetParticleName()!="mu+"&&particle->GetParticleName()!="Mu") 
	{ 
	  pmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1);
	}
      //#if defined LEMU_TEST_FIELD 
      if (particle->GetParticleName()=="mu+"||particle->GetParticleName()=="Mu") 
	{ 
	  pmanager->AddProcess(&fStepLimiter,-1,-1,1); //
	  pmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1);

	}
      //#endif
    }
  
  
  G4ProcessManager* Gpmanager;
  Gpmanager = G4Geantino::Geantino()->GetProcessManager();
  Gpmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1); //
  Gpmanager->AddProcess(&fStepLimiter,-1,-1,1); //
  
   
  G4ProcessManager* Npmanager;
  Npmanager = G4Neutron::Neutron()->GetProcessManager();
  
  Npmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1); //
  Npmanager->AddProcess(new G4UserSpecialCuts(),-1,-1,1); //
   

}


 
