Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Code developed by:
0027 //  S.Larsson
0028 //
0029 //    ***********************************
0030 //    *                                 *
0031 //    *    PurgMagSteppingAction.cc     *
0032 //    *                                 *
0033 //    ***********************************
0034 //
0035 //
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0038 
0039 #include "PurgMagSteppingAction.hh"
0040 #include "PurgMagRunAction.hh"
0041 #include "PurgMagDetectorConstruction.hh"
0042 
0043 #include "G4SteppingManager.hh"
0044 #include "G4Electron.hh"
0045 #include "G4Gamma.hh"
0046 #include "G4Positron.hh"
0047 #include "G4VTouchable.hh"
0048 #include "G4VPhysicalVolume.hh"
0049 #include "G4AnalysisManager.hh"
0050 
0051 #include "G4SystemOfUnits.hh"
0052 
0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0054 
0055 PurgMagSteppingAction::PurgMagSteppingAction(const 
0056                          PurgMagDetectorConstruction* det)
0057 :Detector(det)
0058 { }
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0061 
0062 PurgMagSteppingAction::~PurgMagSteppingAction()
0063 { }
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0066 
0067 void PurgMagSteppingAction::UserSteppingAction(const G4Step* aStep)
0068   
0069 { 
0070   G4AnalysisManager* man = G4AnalysisManager::Instance();
0071   
0072   //Collection at SSD in N-tuples. Electrons and photons separated
0073   //Prestep point in World, next volume MeasureVolume, process transportation
0074   if ((aStep->GetPreStepPoint()->GetPhysicalVolume() == Detector->GetWorld())&&
0075       (aStep->GetTrack()->GetNextVolume() == Detector->GetMeasureVolume())&&
0076       //(aStep->GetTrack()->GetMomentumDirection().z()>0.)&& // only particles with positive momentum
0077       (aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "Transportation"))
0078     {
0079       G4double gx, gy, gz, ge, gpx, gpy, gpz, ex, ey, ez, ee; 
0080       G4double epx, epy, epz, px, py, pz, pe, ppx, ppy, ppz;   
0081          
0082       // Electrons 
0083       if(aStep->GetTrack()->GetDynamicParticle()->GetDefinition()
0084      == G4Electron::Definition())
0085     {//Position 
0086          ex = (aStep->GetTrack()->GetPosition().x())/cm;
0087          ey = (aStep->GetTrack()->GetPosition().y())/cm; 
0088          ez = (aStep->GetTrack()->GetPosition().z())/cm;
0089      // Energy
0090      ee = (aStep->GetTrack()->GetKineticEnergy())/MeV;
0091      // Momentum
0092      epx = aStep->GetTrack()->GetMomentum().x();
0093      epy = aStep->GetTrack()->GetMomentum().y();
0094      epz = aStep->GetTrack()->GetMomentum().z();
0095       
0096      // Fill N-tuple electrons  ( id = 1)
0097      man->FillNtupleDColumn(1,0, ex);
0098      man->FillNtupleDColumn(1,1, ey);
0099      man->FillNtupleDColumn(1,2, ez);
0100      man->FillNtupleDColumn(1,3, ee);
0101      man->FillNtupleDColumn(1,4, epx);
0102      man->FillNtupleDColumn(1,5, epy);
0103      man->FillNtupleDColumn(1,6, epz);
0104      man->AddNtupleRow(1);  
0105       }
0106 
0107       // Photons
0108       if (aStep->GetTrack()->GetDynamicParticle()->GetDefinition() == 
0109       G4Gamma::Definition())
0110     {
0111       
0112       // Position
0113           gx = (aStep->GetTrack()->GetPosition().x())/cm;
0114       gy = (aStep->GetTrack()->GetPosition().y())/cm;
0115       gz = (aStep->GetTrack()->GetPosition().z())/cm;
0116       
0117       // Energy
0118       ge = (aStep->GetTrack()->GetKineticEnergy())/MeV;
0119       
0120       // Momentum
0121       gpx = aStep->GetTrack()->GetMomentum().x();
0122       gpy = aStep->GetTrack()->GetMomentum().y();
0123       gpz = aStep->GetTrack()->GetMomentum().z();
0124 
0125       // Fill N-tuple photons (id=2)
0126       man->FillNtupleDColumn(2,0, gx);
0127       man->FillNtupleDColumn(2,1, gy);
0128       man->FillNtupleDColumn(2,2, gz);
0129       man->FillNtupleDColumn(2,3, ge);
0130       man->FillNtupleDColumn(2,4, gpx);
0131       man->FillNtupleDColumn(2,5, gpy);
0132       man->FillNtupleDColumn(2,6, gpz);
0133       man->AddNtupleRow(2); 
0134     }
0135 
0136 
0137       // Positrons
0138       if (aStep->GetTrack()->GetDynamicParticle()->GetDefinition() == 
0139       G4Positron::Definition())
0140     {
0141 
0142       // Position
0143           px = (aStep->GetTrack()->GetPosition().x())/cm;
0144       py = (aStep->GetTrack()->GetPosition().y())/cm;
0145       pz = (aStep->GetTrack()->GetPosition().z())/cm;
0146       
0147       // Energy
0148       pe = (aStep->GetTrack()->GetKineticEnergy())/MeV;
0149       
0150       // Momentum
0151       ppx = aStep->GetTrack()->GetMomentum().x();
0152       ppy = aStep->GetTrack()->GetMomentum().y();
0153       ppz = aStep->GetTrack()->GetMomentum().z();
0154       
0155       // Fill Ntuple positrons ( id = 3)
0156       man->FillNtupleDColumn(3,0, px);
0157       man->FillNtupleDColumn(3,1, py);
0158       man->FillNtupleDColumn(3,2, pz);
0159       man->FillNtupleDColumn(3,3, pe);
0160       man->FillNtupleDColumn(3,4, ppx);
0161       man->FillNtupleDColumn(3,5, ppy);
0162       man->FillNtupleDColumn(3,6, ppz);
0163       man->AddNtupleRow(3);  
0164     }
0165     }
0166 }
0167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....