Message: Re: Adding a Get...() and Set...() function to G4Track Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Re: Adding a Get...() and Set...() function to G4Track 

Forum: Event and Track Management
Re: Sad Adding a Get...() and Set...() function to G4Track (Cristian Bungau)
Re: None Re: Adding a Get...() and Set...() function to G4Track (Neoh)
Date: 22 Oct, 2010
From: Cristian Bungau <Cristian Bungau>

Dear Neoh,

Thank you very much for your reply.

I modified G4NeutronHPFission.cc such that each time a fission process takes place the SetIsoZ() function from G4Track is called (G4Track is declared as a friend class in G4NeutronHPFission.hh).

So in G4NeutronHPFission.cc I am calling the SetIsoZ() function from G4Track and pass it an integer, SetIsoZ(92) for example.

The SetIsoZ() function in G4Track is:

  inline void G4Track::SetIsoZ(const G4int aValue)
  { 
fIsoZ = aValue; 
}

To make sure that fIsoZ (a private integer variable of G4Track.hh) is assigned the value which I intended to assign when calling SetIsoZ(92) from G4NeutronHPFision.cc, I added the G4cout message, to see what "aValue" I am actually assigning to fIsoZ when SetIsoZ() is called:

 inline void G4Track::SetIsoZ(const G4int aValue)
  { 
fIsoZ = aValue; 
G4cout << "Setting Z for track to : " << aValue << G4endl; 
// OR EQUIVALENT: G4cout << "Setting fIsoZ to be = " << aValue << G4endl;
}

........................................

In my SteppingAction, if a PostStepPoint process is fission, I am cam calling

G4cout << "Z is = " << Step->GetTrack()->GetIsoZ() << G4endl;

........................

When the program is executed each time a fission process is simulated two messages are displayed:

1. the first message I get is:

Setting Z for track to : 92

2. second message:

Z = is = 0

So the SetIsoZ(92) is executed first, followed by GetIsoZ() returning zero.

Now looking at the definition of SetIsoZ(92) , fIsoZ should be clearly made equal to 92.

.............................................................................

Regarding the choice of inline definition for my Get and Set functions, it was purely because all the pre-existing Get/Set functions of G4Track were defined this way. I followed the example of :

   inline G4double G4Track::GetGlobalTime() const
   { return fGlobalTime; }

   inline void G4Track::SetGlobalTime(const G4double aValue)
   { fGlobalTime = aValue; }

replacing of course double with int, and GlobalTime with IsoZ.

But there has to be a mistake I am making since the GetIsoZ() function seems to not be working as I expected.

Best regards,

Cristian

 Add Message Add Message
to: "Re: Adding a Get...() and Set...() function to G4Track"

 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 ]