Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:16:09

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 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0028 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0029 
0030 #include "SteppingAction.hh"
0031 
0032 #include "DetectorConstruction.hh"
0033 #include "EventAction.hh"
0034 
0035 #include "G4Step.hh"
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 SteppingAction::SteppingAction(DetectorConstruction* det, EventAction* evt)
0040 :G4UserSteppingAction(),detector(det),eventAct(evt)
0041 {
0042   first = true;
0043   lvol_world = lvol_module = lvol_layer = lvol_fiber = 0;
0044 } 
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 SteppingAction::~SteppingAction()
0049 {}
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0052 
0053 void SteppingAction::UserSteppingAction(const G4Step* step )
0054 { 
0055  //some initialisation
0056  // 
0057  if (first) {
0058    lvol_world  = detector->GetLvolWorld();
0059    lvol_module = detector->GetLvolModule();   
0060    lvol_layer  = detector->GetLvolLayer();
0061    lvol_fiber  = detector->GetLvolFiber();      
0062    first = false;   
0063  }
0064  
0065  //if no edep, return
0066  //
0067  G4double edep = step->GetTotalEnergyDeposit();
0068  ///if (edep == 0.) return;
0069  
0070  //locate point in geometry
0071  //
0072  G4int iModule = 0;
0073  G4int iLayer  = 0;
0074  G4int iFiber  = 0;
0075    
0076  G4TouchableHandle touch1 = step->GetPreStepPoint()->GetTouchableHandle(); 
0077  G4LogicalVolume* lvol = touch1->GetVolume()->GetLogicalVolume();
0078   
0079       if (lvol == lvol_world) return;
0080  else if (lvol == lvol_module) { iModule = touch1->GetCopyNumber(0);}
0081  else if (lvol == lvol_layer)  { iLayer  = touch1->GetCopyNumber(0);
0082                                  iModule = touch1->GetCopyNumber(1);}
0083  else if (lvol == lvol_fiber)  { iFiber  = touch1->GetCopyNumber(0);
0084                                  iLayer  = touch1->GetCopyNumber(1);
0085                                  iModule = touch1->GetCopyNumber(2);}
0086 
0087  // sum edep
0088  //
0089  eventAct->SumDeStep(iModule, iLayer, iFiber, edep);         
0090 }
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0093 
0094 G4double SteppingAction::BirksAttenuation(const G4Step* aStep)
0095 {
0096  //Example of Birk attenuation law in organic scintillators.
0097  //adapted from Geant3 PHYS337. See MIN 80 (1970) 239-244
0098  //
0099  const G4Material* material = aStep->GetTrack()->GetMaterial();
0100  G4double birk1       = material->GetIonisation()->GetBirksConstant();
0101  G4double destep      = aStep->GetTotalEnergyDeposit();
0102  G4double stepl       = aStep->GetStepLength();  
0103  G4double charge      = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
0104  //
0105  G4double response = destep;
0106  if (birk1*destep*stepl*charge != 0.)
0107    {
0108      response = destep/(1. + birk1*destep/stepl);
0109    }
0110  return response;
0111 }
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0114