Message: Re: Tracking Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None Re: Tracking 

Forum: Biasing and Scoring
Re: Question Tracking (smith)
Date: 11 Oct, 2012
From: Tsukasa Aso <Tsukasa Aso>

Hi,

  I think your question is same as previous one.
You are using Hadr00 example. As you might know the Hadr00 uses 
AIDA Histogram for checking elemental (static) information such as 
cross-section table etc. Therefore, there is not functionality to
save/store track information at all.

  You have to develop your code to pick the track information up by yourself.
I suppose that the most easy way is with using UserSteppingAction for it.

  I attached SteppingAction.hh/cc which was modified from N03 example,
which will help you to understand how you can access the information.

  Please include it in your main program as:
  1)   describe include statement.
             #include "SteppingAction.hh"

  2)    register it to RunManager.
            runManager->SetUserAction(new SteppingAction());

 Then, compile and link, and run.
   You will see the following lines for example in standard output.

Volume name : Lead
Energy Deposit : 653.281 keV
Step Length (charged) : 0.431826 mm

   You will be able to check the volume. If the volume is in your interest
   you may write energy deposit into the file or make histograms etc.

NOTE: Please remind the computational efficiency strongly depends how you make the code,
because the SteppingAction is called at every step for all tracks.

   Again, I recommend to check tutorial site and try Hands-on examples.

 Tsukasa 



---- SteppingAction.cc----
// $Id: SteppingAction.hh,v 1.1 2010-10-18 15:56:17 maire Exp $                  
// GEANT4 tag $Name: not supported by cvs2svn $                                  
//                                                                               
//                                                                               

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

#ifndef SteppingAction_h
#define SteppingAction_h 1

#include "G4UserSteppingAction.hh"

class DetectorConstruction;
class EventAction;

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

class SteppingAction : public G4UserSteppingAction
{
public:
  SteppingAction();
  virtual ~SteppingAction();

  void UserSteppingAction(const G4Step*);

private:
  DetectorConstruction* detector;
  EventAction*          eventaction;
};

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

#endif


--------SteppingAction.cc--------
// $Id: SteppingAction.cc,v 1.1 2010-10-18 15:56:17 maire Exp $                  
// GEANT4 tag $Name: not supported by cvs2svn $                                  
//                                                                               
//                                                                               

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

#include "SteppingAction.hh"

#include "G4Step.hh"
#include "G4RunManager.hh"

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

SteppingAction::SteppingAction()
{ }

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

SteppingAction::~SteppingAction()
{ }

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

void SteppingAction::UserSteppingAction(const G4Step* aStep)
{
  // get volume of the current step                                              
  G4VPhysicalVolume* volume
  = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume();

  G4cout << "Volume name : " << volume->GetName()<<G4endl;

  // collect energy and track length step by step                                
  G4double edep = aStep->GetTotalEnergyDeposit();

  G4cout << "Energy Deposit : " << edep/keV << " keV"<< G4endl;

  G4double stepl = 0.;
  if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.){
    stepl = aStep->GetStepLength();
    G4cout << "Step Length (charged) : " << stepl/mm << " mm"<<G4endl;
  }

}

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


----EOF---


 

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

1 Ok: Re: Tracking   (smith - 14 Oct, 2012)
1 None: Re: Tracking   (Tsukasa Aso - 15 Oct, 2012)
1 None: Re: Tracking   (smith - 16 Oct, 2012)
2 None: Re: Tracking   (Tsukasa Aso - 16 Oct, 2012)
1 None: Re: Tracking   (smith - 16 Oct, 2012)
2 Question: Re: Tracking   (smith - 21 Oct, 2012)
1 None: Re: Tracking   (Tsukasa Aso - 21 Oct, 2012)
1 Feedback: Re: Tracking   (smith - 22 Oct, 2012)
... 4 Message(s)
2 Feedback: Re: Tracking   (smith - 22 Oct, 2012)
 Add Message Add Message
to: "Re: Tracking"

 Subscribe Subscribe

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