Message: resetting counter for optical photons Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question resetting counter for optical photons 

Forum: Event and Track Management
Date: 10 Aug, 2011
From: Yusuf Erdogan <Yusuf Erdogan>

Dear community,

first of all, i'm a Geant4 novice, pls consider this :). My problem: i cannot reset my counter for optical photons after each event:

I want to count optical photons which are in a certain volume. My strategy for now:

In SteppingAction::UserSteppingAction

    G4Track* aTrack = aStep->GetTrack();

    G4StepPoint * aPreStepPoint = aStep->GetPreStepPoint();
    G4StepPoint * aPostStepPoint = aStep->GetPostStepPoint(); 

    if (aPostStepPoint->GetPhysicalVolume()) { 
      if (aTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) {

        if (aPreStepPoint->GetPhysicalVolume()->GetName() == "aVolume"
            && aPostStepPoint->GetPhysicalVolume()->GetName() == "anotherVolume"){

                counter++;
        }
      }
    }

After running over 3 events for example, the value of counter is in first event 1, in next 3 and in third 4, though in second event are two photons (or in third 1) created. To reset counter there is a reset function, which is called either in constructor of SteppingAction or in EventAction::BeginOfEventAction without success. Maybe i'm overseeing something trivial...

Furthermore it is in this case the best way to count in SteppingAction and not in StackingAction or in TrackingAction, am i right? I mean in TrackingAction, one can get the informations of a track before processing and after processing. However if i dont kill the track in a certain volume, it is not possible to count because the processing ends at the edge of the world volume (after killing it is also not possible, since the TrackingAction class doesnt know which tracks are killed and which not in advance, isnt it?).

I should confess, i dont know how to count in StackingAction in my case: I should call the step informations of the track in order to extract photons in a certain volume like i did in SteppingAction, but in StackingAction::ClassifyNewTrack after ensuring that the photons are secondaries

    G4Step* aStep = aTrack->GetStep();

    G4StepPoint * aPreStepPoint = aStep->GetPreStepPoint();
    G4StepPoint * aPostStepPoint = aStep->GetPostStepPoint(); 

    if (aPostStepPoint->GetPhysicalVolume()) { 
      if (aTrack->GetDefinition() == G4OpticalPhoton::OpticalPhotonDefinition()) {

        if (aPreStepPoint->GetPhysicalVolume()->GetName() == "aVolume"
            && aPostStepPoint->GetPhysicalVolume()->GetName() == "anotherVolume"){

                counter++;
        }
      }
    }

crashes with a segmentation violation after creating aStep or just before aPreStepPoint and aPostStepPoint are created... That means the track dont have any steps?

Thanks in advance!

Yusuf

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

1 Feedback: Re: resetting counter for optical photons   (Gumplinger Peter - 10 Aug, 2011)
(_ None: Re: resetting counter for optical photons   (Yusuf Erdogan - 11 Aug, 2011)
(_ Feedback: Re: resetting counter for optical photons   (Gumplinger Peter - 11 Aug, 2011)
 Add Message Add Message
to: "resetting counter for optical photons"

 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 ]