Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:26

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 //  Author: F. Poignant, floriane.poignant@gmail.com
0027 //
0028 // file STCyclotronSensitiveFoil.cc
0029 //
0030 #include "STCyclotronRun.hh"
0031 #include "STCyclotronSensitiveFoil.hh"
0032 #include "G4AnalysisManager.hh"
0033 #include "G4RunManager.hh"
0034 #include "G4HCofThisEvent.hh"
0035 #include "G4Step.hh"
0036 #include "G4ThreeVector.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4ios.hh"
0039 #include "G4SystemOfUnits.hh"
0040 #include "G4ThreeVector.hh"
0041 
0042 STCyclotronSensitiveFoil::STCyclotronSensitiveFoil(const G4String& name,
0043                                STCyclotronDetectorConstruction* det)
0044   : G4VSensitiveDetector(name), 
0045     fDet(det)
0046 { 
0047   fTempTrack = 0;
0048   fTempTrack1 = 0;
0049   fTempEnergy = 0.;
0050   fTempVector = G4ThreeVector(0.,0.,0.);  
0051   fRun =0; 
0052 }
0053 
0054 STCyclotronSensitiveFoil::~STCyclotronSensitiveFoil()
0055 { 
0056 delete fRun;
0057 }
0058 
0059 G4bool STCyclotronSensitiveFoil::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0060 {
0061 
0062   fRun  = static_cast<STCyclotronRun*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0063   G4Track* fTrack = aStep->GetTrack();
0064 
0065   auto analysisManager = G4AnalysisManager::Instance();
0066   
0067   //Step/track information
0068   G4double edep = aStep->GetTotalEnergyDeposit();
0069   G4double energy = aStep->GetPreStepPoint()->GetKineticEnergy();
0070   G4ThreeVector momentumDirection = aStep->GetPreStepPoint()->GetMomentumDirection();
0071   G4ThreeVector vectorPosition = aStep->GetPreStepPoint()->GetPosition();
0072   G4String name = fTrack->GetDefinition()->GetParticleName();
0073   
0074   //Collect general information concerning all of the particles
0075   fRun->EnergyDepositionFoil(edep);
0076 
0077   //Collect information about protons
0078   if(name == "proton" || name == "deuteron"){
0079 
0080     if(fTrack->GetTrackID()!=fTempTrack && (momentumDirection.getZ()>0.) &&
0081        vectorPosition.getX()< 7.5 &&  
0082        vectorPosition.getX()>-7.5 &&
0083        vectorPosition.getY()< 7.5 &&  
0084        vectorPosition.getY()>-7.5){
0085     
0086       analysisManager->FillH2(1,vectorPosition.getX(),vectorPosition.getY());
0087       analysisManager->FillH1(1,energy);
0088     
0089       fTempTrack = fTrack->GetTrackID();
0090     
0091     }
0092     
0093     if(fTempTrack1 == 0){
0094       fTempTrack1 = fTrack->GetTrackID();
0095     }
0096 
0097     if(fTrack->GetTrackID()!=fTempTrack1 && (momentumDirection.getZ()>0.) &&
0098        vectorPosition.getX()< 7.5 &&  
0099        vectorPosition.getX()>-7.5 &&
0100        vectorPosition.getY()< 7.5 &&  
0101        vectorPosition.getY()>-7.5 ){
0102 
0103       analysisManager->FillH2(5,fTempVector.getX(),fTempVector.getY());
0104       analysisManager->FillH1(3,fTempEnergy);
0105 
0106       fTempTrack1 = fTrack->GetTrackID();
0107 
0108     }
0109  
0110     fTempVector =  aStep->GetPostStepPoint()->GetPosition();//vectorPosition;
0111     fTempEnergy = aStep->GetPostStepPoint()->GetKineticEnergy();//energy;
0112   }
0113   
0114   fRun->SetFoilVolume(fDet->GetFoilVolume());
0115   fRun->SetFoilThickness(fDet->GetFoilThickness());
0116   return true;
0117 }