Back to home page

EIC code displayed by LXR

 
 

    


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

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 // 
0028 
0029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0030 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0031 
0032 #include <iostream>
0033 
0034 #include "FCALSteppingAction.hh"
0035 #include "G4SteppingManager.hh"
0036 
0037 #include "globals.hh"
0038 #include "G4SystemOfUnits.hh"
0039 #include "G4Track.hh"
0040 #include "G4DynamicParticle.hh"
0041 #include "G4Material.hh"
0042 
0043 #include "G4LogicalVolume.hh"
0044 #include "G4VPhysicalVolume.hh"
0045 #include "G4VTouchable.hh"
0046 #include "G4TouchableHistory.hh"
0047 
0048 #include "G4Event.hh"
0049 
0050 #include "G4ThreeVector.hh"
0051 
0052 #include "G4ios.hh"
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0055 
0056 FCALSteppingAction::FCALSteppingAction():IDold(-1),IDout(-1)
0057 {;}
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0060 
0061 FCALSteppingAction::~FCALSteppingAction()
0062 {;}
0063 
0064 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0065 
0066 void FCALSteppingAction::UserSteppingAction(const G4Step* astep)
0067 { 
0068   // Get Edep
0069    G4double Edep = astep->GetTotalEnergyDeposit();
0070 
0071    // Get Track
0072      G4Track* aTrack = astep->GetTrack();
0073 
0074    // Get Touchable History
0075   G4TouchableHistory* theTouchable =  (G4TouchableHistory*)(aTrack->GetTouchable());
0076 
0077   // Energy deposit in FCAL1 and FCAL2
0078   if(Edep != 0.) 
0079     {
0080       G4VPhysicalVolume* physVol = theTouchable->GetVolume();
0081       
0082       if(strcmp(physVol->GetName(),"FCALEmModulePhysical")== 0 ||
0083      strcmp(physVol->GetName(),"F1LArGapPhysical") == 0) 
0084     {
0085       EdepFCALEm = EdepFCALEm + Edep;
0086     };
0087       
0088       if( (strcmp(physVol->GetName(), "FCALHadModulePhysical") == 0) ||
0089       (strcmp(physVol->GetName(), "CuPlateAPhysical") == 0) ||
0090       (strcmp(physVol->GetName(), "CuPlateBPhysical") == 0) ||
0091       (strcmp(physVol->GetName(), "WAbsorberPhysical") == 0) ||
0092       (strcmp(physVol->GetName(), "F2RodPhysical") == 0) ||
0093       (strcmp(physVol->GetName(), "F2LArGapPhysical") == 0) ) 
0094     {
0095       EdepFCALHad = EdepFCALHad + Edep;
0096     };
0097     };
0098 
0099   // Get Tracks properties
0100   G4int TrackID = aTrack->GetTrackID();
0101   G4int ParentID = aTrack->GetParentID();
0102   // Get Associated particle
0103   const G4DynamicParticle * aDynamicParticle = aTrack->GetDynamicParticle();
0104   G4ParticleDefinition * aParticle = aTrack->GetDefinition();
0105   G4String ParticleName = aParticle->GetParticleName();
0106   
0107   IDnow = EventNo + 10000*TrackID+ 100000000*ParentID;
0108   
0109   if(IDnow != IDold)
0110     {
0111       IDold = IDnow;
0112       
0113       // Get the primary particle
0114       if(TrackID==1 && ParentID==0 && (aTrack->GetCurrentStepNumber()) == 1)
0115     {
0116       PrimaryVertex    = aTrack->GetVertexPosition(); 
0117       PrimaryDirection = aTrack->GetVertexMomentumDirection();
0118       
0119       NSecondaries = 1;   
0120       Secondaries[NSecondaries][1] = aParticle->GetPDGEncoding();
0121       Secondaries[NSecondaries][2] = PrimaryVertex.x();
0122       Secondaries[NSecondaries][3] = PrimaryVertex.y();
0123       Secondaries[NSecondaries][4] = PrimaryVertex.z();
0124       Secondaries[NSecondaries][5] = (aDynamicParticle->GetMomentum()).x(); 
0125       Secondaries[NSecondaries][6] = (aDynamicParticle->GetMomentum()).y();
0126       Secondaries[NSecondaries][7] = (aDynamicParticle->GetMomentum()).z();
0127       Secondaries[NSecondaries][8] = aDynamicParticle->GetTotalMomentum();
0128       Secondaries[NSecondaries][9] = aDynamicParticle->GetTotalEnergy();
0129       Secondaries[NSecondaries][10] = aDynamicParticle->GetKineticEnergy();
0130       
0131       G4cout << " ****  Primary : " << EventNo << G4endl;
0132       G4cout << " Vertex : " << PrimaryVertex << G4endl;
0133     }
0134       
0135       
0136       // Get secondaries in air close to the primary tracks (DCA < 2.mm) 
0137       G4double DCACut = 2.*mm;
0138       G4String Material = aTrack->GetMaterial()->GetName();
0139       G4ThreeVector TrackPos = aTrack->GetVertexPosition();
0140       
0141       if(TrackID != 1 && ParentID == 1 && (strcmp(Material,"Air")==0) && (TrackPos.z() > 135.*cm)) 
0142     {
0143       SecondaryVertex = aTrack->GetVertexPosition();
0144       SecondaryDirection = aTrack->GetVertexMomentumDirection();
0145       
0146       // calculate DCA of secondries to primary particle
0147       Distance = PrimaryVertex - SecondaryVertex ;
0148       VectorProduct = PrimaryDirection.cross(SecondaryDirection);
0149       if(VectorProduct == G4ThreeVector() &&  
0150          PrimaryDirection != G4ThreeVector() && SecondaryDirection != G4ThreeVector()) 
0151         {
0152           G4ThreeVector Temp = Distance.cross(PrimaryDirection);
0153           VectorProduct = Temp.cross(PrimaryDirection);
0154         };    
0155           
0156 VectorProductMagnitude = VectorProduct.mag();
0157       if(VectorProductMagnitude == 0.) 
0158         {
0159           VectorProductNorm = G4ThreeVector();
0160         } else {
0161           VectorProductNorm = (1./VectorProduct.mag()) * VectorProduct ;
0162         };    
0163       DistOfClosestApproach = Distance * VectorProductNorm ;
0164       
0165       if(std::abs(DistOfClosestApproach) < DCACut) 
0166         {
0167           NSecondaries++;         
0168           Secondaries[0][0] = NSecondaries;
0169           Secondaries[NSecondaries][1] = aParticle->GetPDGEncoding();
0170           Secondaries[NSecondaries][2] = (aTrack->GetVertexPosition()).x();
0171           Secondaries[NSecondaries][3] = (aTrack->GetVertexPosition()).y();
0172           Secondaries[NSecondaries][4] = (aTrack->GetVertexPosition()).z();
0173           Secondaries[NSecondaries][5] =(aDynamicParticle->GetMomentum()).x(); 
0174           Secondaries[NSecondaries][6] = (aDynamicParticle->GetMomentum()).y();
0175           Secondaries[NSecondaries][7] = (aDynamicParticle->GetMomentum()).z();
0176           Secondaries[NSecondaries][8] = aDynamicParticle->GetTotalMomentum();
0177           Secondaries[NSecondaries][9] = aDynamicParticle->GetTotalEnergy();
0178           Secondaries[NSecondaries][10] =aDynamicParticle->GetKineticEnergy();
0179         };  
0180     };
0181     };
0182 
0183 
0184   // Get the World leaving particle
0185   if(aTrack->GetNextVolume() == 0) {
0186     if(IDnow != IDout) {
0187       IDout = IDnow;
0188 
0189       NTracks++;
0190 
0191       OutOfWorldTracksData[0][0] = NTracks;
0192 
0193       OutOfWorldTracksData[NTracks][1] = aParticle->GetPDGEncoding();
0194 
0195       OutOfWorldTracksData[NTracks][2] = (aTrack->GetVertexPosition()).x();
0196       OutOfWorldTracksData[NTracks][3] = (aTrack->GetVertexPosition()).y();
0197       OutOfWorldTracksData[NTracks][4] = (aTrack->GetVertexPosition()).z();
0198 
0199       OutOfWorldTracksData[NTracks][5] = (aDynamicParticle->GetMomentum()).x();
0200       OutOfWorldTracksData[NTracks][6] = (aDynamicParticle->GetMomentum()).y();
0201       OutOfWorldTracksData[NTracks][7] = (aDynamicParticle->GetMomentum()).z();
0202       
0203       OutOfWorldTracksData[NTracks][8] = aDynamicParticle->GetTotalMomentum();
0204 
0205       OutOfWorldTracksData[NTracks][9] = aDynamicParticle->GetTotalEnergy();
0206 
0207       OutOfWorldTracksData[NTracks][10] = aDynamicParticle->GetKineticEnergy();      
0208     };
0209   };
0210   
0211  
0212 }
0213 
0214 void FCALSteppingAction::initialize(G4int Nev) {
0215   EventNo = Nev;
0216   NTracks = 0;
0217   NSecondaries = 0;
0218   EdepFCALEm = EdepFCALHad = 0.;
0219 
0220   for(G4int i=0; i<6000; i++)
0221     {
0222       for(G4int j=0; j<11; j++) 
0223     { 
0224       OutOfWorldTracksData[i][j] = 0.;
0225       Secondaries[i][j] = 0.; 
0226     }
0227     };
0228 }
0229 
0230 G4double FCALSteppingAction::GetOutOfWorldTracks(G4int i, G4int j){
0231   return OutOfWorldTracksData[i][j];
0232 }
0233 
0234 G4double FCALSteppingAction::GetSecondaries(G4int i, G4int j){
0235   return Secondaries[i][j];
0236 }
0237 
0238 G4double FCALSteppingAction::GetEdepFCAL(G4String FCAL) {
0239   if(strcmp(FCAL,"FCALEm") == 0) {
0240     return EdepFCALEm;
0241   } else {
0242     if(strcmp(FCAL,"FCALHad") == 0) {
0243       return EdepFCALHad;}
0244   }
0245   return 0.0; 
0246 } 
0247 
0248 
0249 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0250 
0251 
0252