Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:22:14

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 /// \file medical/electronScattering/src/TrackingAction.cc
0027 /// \brief Implementation of the TrackingAction class
0028 //
0029 //
0030 //
0031 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 
0034 #include "TrackingAction.hh"
0035 
0036 #include "DetectorConstruction.hh"
0037 #include "HistoManager.hh"
0038 #include "Run.hh"
0039 
0040 #include "G4PhysicalConstants.hh"
0041 #include "G4RunManager.hh"
0042 #include "G4SystemOfUnits.hh"
0043 #include "G4Track.hh"
0044 
0045 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0046 
0047 TrackingAction::TrackingAction(DetectorConstruction* DET) : fDetector(DET)
0048 {
0049   fZend = 0.5 * (fDetector->GetThicknessWorld());
0050 }
0051 
0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0053 
0054 void TrackingAction::PreUserTrackingAction(const G4Track*) {}
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 
0058 void TrackingAction::PostUserTrackingAction(const G4Track* track)
0059 {
0060   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0061 
0062   G4double charge = track->GetDefinition()->GetPDGCharge();
0063   G4ThreeVector position = track->GetPosition();
0064   G4ThreeVector direction = track->GetMomentumDirection();
0065 
0066   if (charge == 0.0) return;
0067   if (position.z() < fZend) return;
0068   if (direction.z() <= 0.) return;
0069 
0070   G4double rmin, dr, ds;
0071   G4int ih = 1;
0072 
0073   // projected angle at exit
0074 
0075   G4double ux = direction.x(), uy = direction.y(), uz = direction.z();
0076   G4double thetax = std::atan(ux / uz);
0077   G4double thetay = std::atan(uy / uz);
0078   analysisManager->FillH1(ih, thetax);
0079   analysisManager->FillH1(ih, thetay);
0080 
0081   // dN/dS at exit
0082 
0083   G4double x = position.x(), y = position.y();
0084   G4double r = std::sqrt(x * x + y * y);
0085   ih = 2;
0086   dr = analysisManager->GetH1Width(ih);
0087   rmin = ((int)(r / dr)) * dr;
0088   ds = twopi * (rmin + 0.5 * dr) * dr;
0089   analysisManager->FillH1(ih, r, 1 / ds);
0090 
0091   // d(N/cost)/dS at exit
0092 
0093   ih = 3;
0094   dr = analysisManager->GetH1Width(ih);
0095   rmin = ((int)(r / dr)) * dr;
0096   ds = twopi * (rmin + 0.5 * dr) * dr;
0097   analysisManager->FillH1(ih, r, 1 / (uz * ds));
0098 
0099   // vector of d(N/cost)/dS at exit
0100 
0101   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0102 
0103   run->SumFluence(r, 1 / uz);
0104 
0105   // space angle at exit : dN/dOmega
0106 
0107   ih = 5;
0108   G4double theta = std::acos(uz);
0109   if (theta > 0.) {
0110     G4double dtheta = analysisManager->GetH1Width(ih);
0111     G4double unit = analysisManager->GetH1Unit(ih);
0112     if (dtheta > 0.) {
0113       G4double weight = unit * unit / (twopi * std::sin(theta) * dtheta);
0114       analysisManager->FillH1(ih, theta, weight);
0115     }
0116   }
0117 
0118   // measured space angle at exit : dN/dOmega_meas
0119   //
0120   ih = 6;
0121   const G4double dist = fDetector->GetZdist_foil_detector();
0122   G4double thetam = std::atan(r / dist);
0123   if (thetam > 0.) {
0124     G4double dtheta = analysisManager->GetH1Width(ih);
0125     G4double unit = analysisManager->GetH1Unit(ih);
0126     if (dtheta > 0.) {
0127       G4double weight = unit * unit / (twopi * std::sin(thetam) * dtheta);
0128       analysisManager->FillH1(ih, thetam, weight);
0129     }
0130   }
0131 }
0132 
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......