Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-27 07:33:31

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 SteppingAction.cc
0027 /// \brief Implementation of the SteppingAction class
0028 
0029 #include "SteppingAction.hh"
0030 
0031 #include "DetectorConstruction.hh"
0032 #include "EventAction.hh"
0033 #include "HistoManager.hh"
0034 #include "Run.hh"
0035 
0036 #include "G4RunManager.hh"
0037 
0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0039 
0040 SteppingAction::SteppingAction(DetectorConstruction* det, EventAction* evt)
0041   : fDetector(det), fEventAct(evt)
0042 {}
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 void SteppingAction::UserSteppingAction(const G4Step* aStep)
0047 {
0048   // count processes
0049   //
0050   const G4StepPoint* prePoint = aStep->GetPreStepPoint();
0051   const G4StepPoint* endPoint = aStep->GetPostStepPoint();
0052   const G4VProcess* process = endPoint->GetProcessDefinedStep();
0053   Run* run = static_cast<Run*>(G4RunManager::GetRunManager()->GetNonConstCurrentRun());
0054   run->CountProcesses(process);
0055 
0056   // if World, return
0057   //
0058   G4VPhysicalVolume* volume = prePoint->GetTouchableHandle()->GetVolume();
0059   // if sum of absorbers do not fill exactly a layer: check material, not volume.
0060   const G4Material* mat = volume->GetLogicalVolume()->GetMaterial();
0061   if (mat == fDetector->GetWorldMaterial()) return;
0062 
0063   const G4ParticleDefinition* particle = aStep->GetTrack()->GetDefinition();
0064 
0065   // here we are in an absorber. Locate it
0066   //
0067   G4int absorNum = prePoint->GetTouchableHandle()->GetCopyNumber(0);
0068   G4int layerNum = prePoint->GetTouchableHandle()->GetCopyNumber(1);
0069 
0070   // collect energy deposit (taking into account track weight)
0071   G4double edep = aStep->GetTotalEnergyDeposit();
0072   ////edep *= (aStep->GetTrack()->GetWeight());
0073 
0074   // collect step length of charged particles
0075   G4double stepl = 0.;
0076   if (particle->GetPDGCharge() != 0.) stepl = aStep->GetStepLength();
0077 
0078   // sum up per event
0079   fEventAct->SumEnergy(absorNum, edep, stepl);
0080 
0081   // longitudinal profile of edep per absorber
0082   if (edep > 0.) {
0083     G4AnalysisManager::Instance()->FillH1(kMaxAbsor + absorNum, G4double(layerNum + 1), edep);
0084   }
0085 
0086   // energy flow
0087   //
0088   //  unique identificator of layer+absorber
0089   G4int Idnow = (fDetector->GetNbOfAbsor()) * layerNum + absorNum;
0090   G4int plane;
0091   //
0092   // leaving the absorber ?
0093   if (endPoint->GetStepStatus() == fGeomBoundary) {
0094     G4ThreeVector position = endPoint->GetPosition();
0095     G4ThreeVector direction = endPoint->GetMomentumDirection();
0096     G4double Eflow = endPoint->GetKineticEnergy();
0097     if (direction.x() >= 0.)
0098       run->SumEnergyFlow(plane = Idnow + 1, Eflow);
0099     else
0100       run->SumEnergyFlow(plane = Idnow, -Eflow);
0101   }
0102 
0103   ////  example of Birk attenuation
0104   /// G4double destep   = aStep->GetTotalEnergyDeposit();
0105   /// G4double response = BirksAttenuation(aStep);
0106   /// G4cout << " Destep: " << destep/keV << " keV"
0107   ///       << " response after Birks: " << response/keV << " keV" << G4endl;
0108 }
0109 
0110 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0111 
0112 G4double SteppingAction::BirksAttenuation(const G4Step* aStep)
0113 {
0114   // Example of Birk attenuation law in organic scintillators.
0115   // adapted from Geant3 PHYS337. See MIN 80 (1970) 239-244
0116   //
0117   const G4Material* material = aStep->GetTrack()->GetMaterial();
0118   G4double birk1 = material->GetIonisation()->GetBirksConstant();
0119   G4double destep = aStep->GetTotalEnergyDeposit();
0120   G4double stepl = aStep->GetStepLength();
0121   G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
0122   //
0123   G4double response = destep;
0124   if (birk1 * destep * stepl * charge != 0.) {
0125     response = destep / (1. + birk1 * destep / stepl);
0126   }
0127   return response;
0128 }
0129 
0130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......