Message: Re: GPS for gamma ray spectrum from radioactive isotope Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: GPS for gamma ray spectrum from radioactive isotope 

Forum: Particles
Re: Question GPS for gamma ray spectrum from radioactive isotope (benny)
Re: None Re: GPS for gamma ray spectrum from radioactive isotope (Andrew Pollitt)
Date: 04 Jun, 2014
From: benny <benny>

Andrew, i am out of touch with geant...so can not suggest why your code is not working.

this is from my archived working code.

[runargument.mac] file

# viewing in HepRApp: /vis/open HepRepFile #

# trajectories are established: /vis/viewer/set/autoRefresh false /vis/verbose errors

#
# Draw geometry:
/vis/drawVolume

# Specify zoom value: /vis/viewer/zoom 1.4 #

/vis/scene/add/trajectories smooth /vis/modeling/trajectories/create/drawByCharge /vis/modeling/trajectories/drawByCharge-0/default/setDrawStepPts true /vis/modeling/trajectories/drawByCharge-0/default/setStepPtsSize 1

/vis/modeling/trajectories/create/drawByParticleID /vis/modeling/trajectories/drawByParticleID-0/default/setDrawStepPts true

/vis/scene/endOfEventAction accumulate

/control/verbose 2

#
#/run/beamOn 40000
#
# change beta source
#
/gun/particle ion
#/gun/ion 6 11
#AM-241
#/gun/ion 95 241 0 0
#Cs-137
#/gun/ion 55 137
#Co-60
/gun/ion 27 60
#Co-57
#/gun/ion 27 57
#Ba-137
#/gun/ion 56 137 662 0

/run/beamOn 2500

********************************************************* [PhysicsList.cc]

#include "PhysicsList.hh"

#include "G4DecayPhysics.hh"
#include "G4RadioactiveDecayPhysics.hh"
#include "G4EmStandardPhysics.hh"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B3PhysicsList::B3PhysicsList() 
: G4VModularPhysicsList(){
  SetVerboseLevel(1);

  // Default physics
  RegisterPhysics(new G4DecayPhysics());

  // Radioactive decay
  RegisterPhysics(new G4RadioactiveDecayPhysics());

  // EM physics
  RegisterPhysics(new G4EmStandardPhysics());
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B3PhysicsList::~B3PhysicsList() { }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void B3PhysicsList::SetCuts()
{
  G4VUserPhysicsList::SetCuts();
}  

***************************************************

[StackingAction.cc]

#include "StackingAction.hh"

#include "G4Track.hh"
#include "G4NeutrinoE.hh"
#include "G4Gamma.hh"
#include "G4AntiNeutrinoE.hh"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B3StackingAction::B3StackingAction() { }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B3StackingAction::~B3StackingAction() { }

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4ClassificationOfNewTrack
B3StackingAction::ClassifyNewTrack(const G4Track* track)
{
  //keep primary particle
  if (track->GetParentID() == 0) return fUrgent;

  if (track->GetDefinition() == G4NeutrinoE::NeutrinoE()||track->GetDefinition() == G4AntiNeutrinoE::AntiNeutrinoE()) return fKill;
   else return fUrgent;

}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

*****************************************************************

[PrimaryGeneratorAction.cc] #include "PrimaryGeneratorAction.hh"

#include "G4RunManager.hh"
#include "G4Event.hh"
#include "G4ParticleGun.hh"
#include "G4ParticleTable.hh"
#include "G4ParticleDefinition.hh"
#include "G4ChargedGeantino.hh"
#include "Randomize.hh"

#include <cmath>

//G4double gun_ENR; //G4String gun_PRT;

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B3PrimaryGeneratorAction::B3PrimaryGeneratorAction()
 : G4VUserPrimaryGeneratorAction(),
   fParticleGun(0)
{
  G4int n_particle = 1;
  fParticleGun  = new G4ParticleGun(n_particle);

  // default particle kinematic

  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
  G4ParticleDefinition* particle
                    = particleTable->FindParticle("chargedgeantino");
  fParticleGun->SetParticleDefinition(particle);
  fParticleGun->SetParticlePosition(G4ThreeVector(0.,0.,0.));
  fParticleGun->SetParticleEnergy(1*eV);    
  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(1.,0.,0.));
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

B3PrimaryGeneratorAction::~B3PrimaryGeneratorAction()
{
  delete fParticleGun;
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void B3PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
{
  G4ParticleDefinition* particle = fParticleGun->GetParticleDefinition();
  if (particle == G4ChargedGeantino::ChargedGeantino()) {
    //fluorine 
    G4int Z = 9, A = 18;
    G4double ionCharge   = 0.*eplus;
    G4double excitEnergy = 0.*keV;

    G4ParticleDefinition* ion
       = G4ParticleTable::GetParticleTable()->GetIon(Z,A,excitEnergy);
    fParticleGun->SetParticleDefinition(ion);
    fParticleGun->SetParticleCharge(ionCharge);
  }

// /* Raj no random

  // randomized position
  //
  ///G4double x0  = 0*cm, y0  = 0*cm, z0  = 0*cm;
  ///G4double dx0 = 0*cm, dy0 = 0*cm, dz0 = 0*cm;   
  G4double Mr0 = 5*cm, Mh0 = 10*cm ;
  G4double Mx0  = 4*cm, My0  = 4*cm, Mz0  = 4*cm;
  /*
  G4double x0  = 4*cm, y0  = 4*cm, z0  = 4*cm;
  G4double dx0 = 1*cm, dy0 = 1*cm, dz0 = 1*cm; 
  x0 += dx0*(G4UniformRand()-0.5);
  y0 += dy0*(G4UniformRand()-0.5);
  z0 += dz0*(G4UniformRand()-0.5);
  fParticleGun->SetParticlePosition(G4ThreeVector(x0,y0,z0));
            */
  //x=r cos theta, y = rsin theta[0,2pi] z=[-h/2,h/2]   		
   G4double Mtheta = (twopi)*G4UniformRand();
  G4double Mheight = (-Mh0/2) + ((Mh0/2)-(-Mh0/2))*G4UniformRand();
   // MinPhi + (MaxPhi - MinPhi) * rndm2;
       Mx0 = Mr0*(std::cos(Mtheta)); 
	   My0 = Mr0*(std::sin(Mtheta));
	   Mz0 = Mheight;

 // fParticleGun->SetParticlePosition(G4ThreeVector(0,0,49.*cm));
 // fParticleGun->SetParticlePosition(G4ThreeVector(0,0,0));
fParticleGun->SetParticlePosition(G4ThreeVector(Mx0,My0,Mz0));
  //create vertex
  //
  fParticleGun->GeneratePrimaryVertex(anEvent);
  /*
  gun_ENR = fParticleGun->GetParticleEnergy();
  gun_PRT = fParticleGun->GetParticleDefinition()->GetParticleName();

  G4cout
     << "\n--------------------from primary generator------------------------------\n"
     << " gunParticle name " << gun_PRT << " "
     << "; PRT _Energy" << gun_ENR
     << "\n------------------------------------------------------------\n"
     << G4endl;
  */
}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

************************************************************************

hope it will give you some direction

 Add Message Add Message
to: "Re: GPS for gamma ray spectrum from radioactive isotope"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]