Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:04

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file FlashSteppingAction.cc
0028 /// \brief Implementation of the FlashSteppingAction class
0029 
0030 #include "FlashSteppingAction.hh"
0031 #include "FlashDetectorConstruction.hh"
0032 #include "FlashEventAction.hh"
0033 #include "FlashRunAction.hh"
0034 #include "G4Electron.hh"
0035 #include "G4Event.hh"
0036 #include "G4Gamma.hh"
0037 #include "G4LogicalVolume.hh"
0038 #include "G4RunManager.hh"
0039 #include "G4Step.hh"
0040 #include "G4Threading.hh"
0041 #include "G4Track.hh"
0042 #include <sstream>
0043 #include <string>
0044 
0045 FlashSteppingAction::FlashSteppingAction(FlashEventAction *)
0046     : G4UserSteppingAction()
0047      
0048 {
0049 
0050 
0051 }
0052 
0053 FlashSteppingAction::~FlashSteppingAction() {
0054 }
0055 
0056 void FlashSteppingAction::UserSteppingAction(const G4Step *aStep)
0057 {
0058 
0059   G4int eventid =
0060       G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
0061   G4StepPoint *postStep = aStep->GetPostStepPoint();
0062   G4StepPoint *preStep = aStep->GetPreStepPoint();
0063   // G4int trackID = aStep->GetTrack()->GetTrackID();
0064 
0065   //===========================INCIDENT
0066   //PARTICLES===============================================
0067 
0068   //==============================PRIMARIES ENERGY
0069   //SPECTRUM=======================================
0070   if (postStep->GetStepStatus() == fGeomBoundary)
0071     {
0072 
0073     G4String volumeName =
0074         postStep->GetPhysicalVolume()->GetLogicalVolume()->GetName();
0075     G4String prevolumeName =
0076         preStep->GetPhysicalVolume()->GetLogicalVolume()->GetName();
0077 
0078  G4int parentid = aStep->GetTrack()->GetParentID();
0079  //G4Track* theTrack = aStep->GetTrack();
0080  G4double kineticEnergy = aStep->GetTrack()->GetKineticEnergy();
0081  G4double pos_x = aStep->GetTrack()->GetPosition().x();
0082  G4double pos_y = aStep->GetTrack()->GetPosition().y();
0083  G4double pos_z = aStep->GetTrack()->GetPosition().z();
0084  G4double cos_x = aStep->GetTrack()->GetMomentum().x();
0085  G4double cos_y = aStep->GetTrack()->GetMomentum().y();
0086  G4double cos_z = aStep->GetTrack()->GetMomentum().z();
0087  
0088  G4double momentum = std::sqrt(cos_x*cos_x+cos_y*cos_y+cos_z*cos_z);
0089  
0090 
0091 
0092  if (aStep->GetTrack()->GetDefinition()==G4Electron::ElectronDefinition() && prevolumeName == "logicTreatmentRoom" && volumeName == "phantomLog")
0093 
0094         {
0095 
0096       std::ofstream WriteDataIn("PhantomEntrance.txt", std::ios::app);
0097       WriteDataIn    
0098 
0099         << parentid << "\t"<< eventid << "\t" << kineticEnergy << "\t" <<pos_x<<"\t"<<pos_y<<"\t"<<pos_z<<"\t"<<momentum<<"\t"<<cos_x<<"\t"<<cos_y<<"\t"<<cos_z<<"\t"<<G4endl;
0100        
0101     
0102      }
0103        
0104     }
0105 }