File indexing completed on 2025-01-18 09:16:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
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
0055
0056 FCALSteppingAction::FCALSteppingAction():IDold(-1),IDout(-1)
0057 {;}
0058
0059
0060
0061 FCALSteppingAction::~FCALSteppingAction()
0062 {;}
0063
0064
0065
0066 void FCALSteppingAction::UserSteppingAction(const G4Step* astep)
0067 {
0068
0069 G4double Edep = astep->GetTotalEnergyDeposit();
0070
0071
0072 G4Track* aTrack = astep->GetTrack();
0073
0074
0075 G4TouchableHistory* theTouchable = (G4TouchableHistory*)(aTrack->GetTouchable());
0076
0077
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
0100 G4int TrackID = aTrack->GetTrackID();
0101 G4int ParentID = aTrack->GetParentID();
0102
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
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
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
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
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
0250
0251
0252