Skip to content
Snippets Groups Projects
Commit 6c3d42ed authored by Vangelis Kourlitis's avatar Vangelis Kourlitis Committed by Marilena Bandieramonte
Browse files

add field reading on stepping action. commented out at the moment.

parent e5b281ca
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,8 @@
#include "MyTrackInformation.hh"
#include "G4Step.hh"
#include "G4ParticleDefinition.hh"
#include "G4FieldManager.hh"
#include "G4Field.hh"
MySteppingAction::MySteppingAction(MyEventAction* evtact) : G4UserSteppingAction(), fEventAction(evtact) {}
......@@ -20,4 +22,30 @@ void MySteppingAction::UserSteppingAction(const G4Step* theStep) {
G4bool isCharged = (theTrack->GetDefinition()->GetPDGCharge()!=0.);
G4int primTrackID = static_cast<MyTrackInformation*>(theTrack->GetUserInformation())->GetPrimaryTrackID();
fEventAction->AddData(edep, stepl, isCharged, primTrackID-1);
}
/* read and print field
const G4int stepNumber = theTrack->GetCurrentStepNumber();
std::cout<<"CurrentStepNumber is: "<<stepNumber<<std::endl;
auto preStepPoint = theStep->GetPreStepPoint();
auto position = preStepPoint->GetPosition();
const double point[3] = {position.getX(), position.getY(), position.getZ()};
auto volume = preStepPoint->GetPhysicalVolume()->GetLogicalVolume();
auto fieldManager = volume->GetFieldManager();
if (fieldManager) {
const G4Field* field = fieldManager->GetDetectorField();
if (field) {
std::cout<<"Field DOES exist!"<<std::endl;
double fieldValue[3];
field->GetFieldValue(point, fieldValue);
std::cout<<"Field value is: "<<fieldValue[0]<<", "<<fieldValue[1]<<", "<<fieldValue[2]<<std::endl;
}
else
std::cout<<"Field does NOT exist!"<<std::endl;
}
else
std::cout<<"Field manager does NOT exist!"<<std::endl;
*/
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment