Message: Identical track data from different simulations Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Identical track data from different simulations 

Forum: Event and Track Management
Date: 28 May, 2009
From: GaŽlle Angellier <GaŽlle Angellier>

Hello,

I am facing a weird problem using GEANT4 (geant4-09-01-patch-03).
I am simulating a protontherapy facility just like the hadrontherapy example available with the GEANT4 package.
I want to launch randomly created particles and to retrieve the characteristics of the particles at a particular point into the geometry.

Therefore I follow several steps:
1. I set the internal seed for the ranecu random engine (e.g. setTheSeed(0)).
2. I compile and run the application.
3. I launch 200 000 (or more) particles (IDLE > /run/beamOn 200000).
4. Within the SteppingAction class, I check if the particle of interest reached the particular point of the geometry and if so, I save its name, parentId, position, momentum and kinetic energy to a file.
5. Once the run is over, I stop the application (IDLE > exit), I set the internal seed to a different value (setTheSeed(2)) and I compile and run the application again
6. By the end I compare the two files containing the particles properties to each other.

The problem I am facing is that some of the particles from the different files are exactly identical.

I managed to reproduce the issue with the Hadrontherapy example althought I had to modify a little bit the code:

#### FILE Hadrontherapy.cc:
I replaced

  // Set the Random engine

  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());

with

  // Set the Random engine

  CLHEP::HepRandom::setTheEngine(new CLHEP::RanecuEngine());
  CLHEP::HepRandom::setTheSeed(2);

in order to manually set the internal seed.


#### FILE HadrontherapySteppingAction.cc
I replaced

  // Electromagnetic and hadronic processes of primary particles in the phantom
 
 if ((aStep -> GetTrack() -> GetTrackID() == 1) &&
    (aStep -> GetTrack() -> GetVolume() -> GetName() == "PhantomPhys") &&
    (aStep -> GetPostStepPoint() -> GetProcessDefinedStep() != NULL))
        {
          G4String process = aStep -> GetPostStepPoint() ->
        GetProcessDefinedStep() -> GetProcessName();
 
          if ((process == "Transportation") || (process == "StepLimiter")) {;}
          else {
        if ((process == "msc") || (process == "hLowEIoni") || (process == "hIoni"))
          {
                    runAction -> AddEMProcess();
          }
        else
                 {
           runAction -> AddHadronicProcess();

                   if ( (process != "LElastic") && (process != "ProtonInelastic") && (process != "hElastic") )
             G4cout << "Warning! Unknown proton process: "<< process << G4endl;
         }
          }
        }

with

    G4double prePointX = aStep->GetPreStepPoint() ->GetPosition().getX();
    G4double postPointX = aStep->GetPostStepPoint()->GetPosition().getX();
    G4Track* track = aStep -> GetTrack();
   
    // Retrieving the particles properties at X = -1900
    if (prePointX <= -1900 && postPointX > -1900)
    {
        G4String name = track -> GetDefinition()-> GetParticleName();
       
        G4bool isPrimary;
        if ( track -> GetParentID() != 0 )
            isPrimary = true;
        else
            isPrimary = false;

        G4double xP = track -> GetPosition().getX();
        G4double yP = track -> GetPosition().getY();
        G4double zP = track -> GetPosition().getZ();
       
        G4double zM = track -> GetMomentumDirection().getZ();
        G4double xM = track -> GetMomentumDirection().getX();
        G4double yM = track -> GetMomentumDirection().getY();
       
        G4double energy = track -> GetKineticEnergy();
       
        G4int trackId = track -> GetTrackID();
   
        // Saving particle status to a file
        std::ofstream outFile;
        outFile.open ("/home/utilisateur/TEST/hadrontherapy/particlesStatus.csv", std::ofstream::app);
        outFile << name << "," << isPrimary << "," << xP << "," << yP << "," << zP << "," << xM << "," << yM << "," << zM << "," << energy << "\n";
        outFile.close();
   
        // To accelerate the simulation
        track->SetTrackStatus(fKillTrackAndSecondaries );
    }

in order to save the particles properties at a X coordinate of -1900. (I do not care of the phantom !!!)

By the end I am using the following macro file :

    /control/verbose 1
    /tracking/verbose 0
    /run/verbose 0
    /event/verbose 0

    # SETTING FOR THE PHYSICS MODELS
    /physics/addPhysics Decay
    /physics/addPhysics EM-Photon-EPDL
    /physics/addPhysics EM-Electron-EEDL
    /physics/addPhysics EM-Positron-Standard
    /physics/addPhysics EM-HadronIon-LowE
    /physics/addPhysics EM-Muon-Standard
    /physics/addPhysics HadronicEl-HadronIon-LElastic
    /physics/addPhysics HadronicInel-ProtonNeutron-LEP
    /physics/addPhysics HadronicInel-Ion-LEP
    /physics/addPhysics HadronicInel-Pion-LEP
    /physics/addPhysics HadronicAtRest-MuonMinus-Capture

    # i add to initialize the GEANT4 kernel manually
    /run/initialize

    /run/beamOn 200000


Here are the results of the comparison of the two files generated for seeds 0 and 2 (200000 particles generated for eached simulation):

#### File 01 :
Seed : 0
Number of particles retrieved : 66801
sample :
line.836 - unique : "proton,0,-1899.92,0.176738,-4.19289,0.999802,0.0190303,-0.0058769,61.8651"
line.837 - unique : "proton,0,-1899.94,7.2854,4.45091,0.999976,0.00599902,0.00333688,61.8491"
line.838 - unique : "proton,0,-1899.94,0.25033,-5.00707,0.999988,0.001683,-0.00468154,62.1691"
line.839 - identical : "proton,0,-1899.99,-2.74354,-0.371709,0.999977,-0.0066578,-0.00120971,61.6171"
line.840 - identical : "proton,0,-1900,-2.51559,10.5889,0.999507,0.0113911,-0.0292686,37.6647"
line.841 - identical : "proton,0,-1899.98,3.19159,10.5675,0.999918,-0.00566967,0.0115149,61.5095"
line.842 - identical : "proton,0,-1899.97,7.62178,-4.92185,0.999858,0.0145265,-0.00858155,61.2452"

#### File 02 :
Seed : 2
Number of particles retrieved : 67034
sample :
line.18833 - unique : "proton,0,-1899.93,3.95119,-2.77882,0.999983,0.00444051,-0.00380069,61.4057"
line.18834 - unique : "proton,0,-1899.93,-3.49538,9.41306,0.999918,0.00556569,0.0115234,61.1341"
line.18835 - unique : "proton,0,-1899.92,19.1916,-1.34642,0.999412,0.0338261,-0.00559045,42.6244"
line.18836 - identical : "proton,0,-1899.99,-2.74354,-0.371709,0.999977,-0.0066578,-0.00120971,61.6171"
line.18837 - identical : "proton,0,-1900,-2.51559,10.5889,0.999507,0.0113911,-0.0292686,37.6647"
line.18838 - identical : "proton,0,-1899.98,3.19159,10.5675,0.999918,-0.00566967,0.0115149,61.5095"

Number of identical particles : 48199


You can notice that the order of the identical particles is exactly the same (e.g. particle line.839 is identical to particle line.18836; then particle line.840 is identical to particle line.18837 etc).

I am running GEANT4 (geant4-09-01-patch-03) on Ubuntu 8.10.
I have been wondering if there could be some memory leak when using the particles stacks which could cause particles generated during old simulations to appear again in other simulations.

I launched the applications one after the other (so there can't be multi core mistakes) and I tried to restart my computer between the two simulations without solving the issue.

Does anybody have encountered that kind of problem ?
Any help would be very appreciated !!!!

Regards,
GaŽlle Angellier

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Idea: Re: Identical track data from different simulations   (Tom Roberts - 28 May, 2009)
(_ Question: Re: Identical track data from different simulations   (GaŽlle Angellier - 29 May, 2009)
(_ None: Re: Identical track data from different simulations   (Paul Nicholas Colin Gloster - 31 May, 2009)
(_ Ok: Re: Identical track data from different simulations   (GaŽlle Angellier - 26 Oct, 2009)
 Add Message Add Message
to: "Identical track data from different simulations"

 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 ]