[807] | 1 | // |
---|
| 2 | // ******************************************************************** |
---|
| 3 | // * License and Disclaimer * |
---|
| 4 | // * * |
---|
| 5 | // * The Geant4 software is copyright of the Copyright Holders of * |
---|
| 6 | // * the Geant4 Collaboration. It is provided under the terms and * |
---|
| 7 | // * conditions of the Geant4 Software License, included in the file * |
---|
| 8 | // * LICENSE and available at http://cern.ch/geant4/license . These * |
---|
| 9 | // * include a list of copyright holders. * |
---|
| 10 | // * * |
---|
| 11 | // * Neither the authors of this software system, nor their employing * |
---|
| 12 | // * institutes,nor the agencies providing financial support for this * |
---|
| 13 | // * work make any representation or warranty, express or implied, * |
---|
| 14 | // * regarding this software system or assume any liability for its * |
---|
| 15 | // * use. Please see the license in the file LICENSE and URL above * |
---|
| 16 | // * for the full disclaimer and the limitation of liability. * |
---|
| 17 | // * * |
---|
| 18 | // * This code implementation is the result of the scientific and * |
---|
| 19 | // * technical work of the GEANT4 collaboration. * |
---|
| 20 | // * By using, copying, modifying or distributing the software (or * |
---|
| 21 | // * any work based on the software) you agree to acknowledge its * |
---|
| 22 | // * use in resulting scientific publications, and indicate your * |
---|
| 23 | // * acceptance of all terms of the Geant4 Software license. * |
---|
| 24 | // ******************************************************************** |
---|
| 25 | // |
---|
| 26 | // Rich advanced example for Geant4 |
---|
| 27 | // RichTbSteppingAction.cc for Rich of LHCb |
---|
| 28 | // History: |
---|
| 29 | // Created: Sajan Easo (Sajan.Easo@cern.ch) |
---|
| 30 | // Revision and changes: Patricia Mendez (Patricia.Mendez@cern.ch) |
---|
| 31 | ///////////////////////////////////////////////////////////////////////////// |
---|
| 32 | #include "globals.hh" |
---|
| 33 | #include "RichTbSteppingAction.hh" |
---|
| 34 | #include "G4SteppingManager.hh" |
---|
| 35 | #include "RichTbAnalysisManager.hh" |
---|
| 36 | #include "RichTbMaterial.hh" |
---|
| 37 | #include "RichTbGeometryParameters.hh" |
---|
| 38 | #include "RichTbMaterialParameters.hh" |
---|
| 39 | #include "RichTbRunConfig.hh" |
---|
| 40 | #include "RichTbPrimaryGeneratorAction.hh" |
---|
| 41 | #include "G4ParticleDefinition.hh" |
---|
| 42 | #include "G4DynamicParticle.hh" |
---|
| 43 | #include "G4Material.hh" |
---|
| 44 | #include "G4Step.hh" |
---|
| 45 | #include "G4Track.hh" |
---|
| 46 | #include "G4Electron.hh" |
---|
| 47 | #include "G4ThreeVector.hh" |
---|
| 48 | #include "G4OpticalPhoton.hh" |
---|
| 49 | #include "G4PionMinus.hh" |
---|
| 50 | |
---|
| 51 | #ifdef G4ANALYSIS_USE |
---|
| 52 | #include "AIDA/AIDA.h" |
---|
| 53 | #endif |
---|
| 54 | |
---|
| 55 | RichTbSteppingAction:: |
---|
| 56 | RichTbSteppingAction(RichTbRunConfig* rConfig , |
---|
| 57 | RichTbPrimaryGeneratorAction* RPrimGenAction) |
---|
| 58 | { |
---|
| 59 | richtbRunConfig= rConfig; |
---|
| 60 | rPrimGenAction = RPrimGenAction; |
---|
| 61 | HpdPhElectronKE=rConfig->getHpdPhElectronEnergy(); |
---|
| 62 | uParticleChange=new G4VParticleChange(); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | RichTbSteppingAction::~RichTbSteppingAction() |
---|
| 66 | { |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | void RichTbSteppingAction::UserSteppingAction(const G4Step* aStep) |
---|
| 70 | { |
---|
| 71 | RichTbGenericHisto(aStep); |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | void RichTbSteppingAction:: RichTbDebugHisto(const G4Step*) |
---|
| 75 | { |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | void RichTbSteppingAction::RichTbGenericHisto(const G4Step* aStep) |
---|
| 79 | { |
---|
| 80 | G4StepPoint* pPreStepPoint = aStep ->GetPreStepPoint(); |
---|
| 81 | G4StepPoint* pPostStepPoint = aStep ->GetPostStepPoint(); |
---|
| 82 | const G4ThreeVector prePos= pPreStepPoint->GetPosition(); |
---|
| 83 | const G4ThreeVector postPos= pPostStepPoint->GetPosition(); |
---|
| 84 | |
---|
| 85 | // In the following 1000 mm is the Z coord of a point |
---|
| 86 | // between the mirror and the dowstream end of the vessel. |
---|
| 87 | |
---|
| 88 | if(prePos.z()<1000*mm && prePos.z() > 0.0*mm ) |
---|
| 89 | { |
---|
| 90 | //check to see if we are at a boundary |
---|
| 91 | |
---|
| 92 | if (pPostStepPoint->GetStepStatus() == fGeomBoundary) |
---|
| 93 | { |
---|
| 94 | |
---|
| 95 | G4Track* aPhotTrack = aStep -> GetTrack(); |
---|
| 96 | const G4DynamicParticle* aParticle = aPhotTrack->GetDynamicParticle(); |
---|
| 97 | const G4double PhotonEnergy = aParticle->GetKineticEnergy(); |
---|
| 98 | |
---|
| 99 | G4String VolNameD="Agel"; |
---|
| 100 | G4String VolNameE="VesselEnclosure"; |
---|
| 101 | G4String VolNameF="MirrorSphe"; |
---|
| 102 | G4String VolNameG="RadFrame"; |
---|
| 103 | G4String VolNameH="FilterBox"; |
---|
| 104 | G4String VolNameQ="HpdQuartzWindow"; |
---|
| 105 | G4String VolNameP="HpdMaster"; |
---|
| 106 | |
---|
| 107 | if( aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) |
---|
| 108 | { |
---|
| 109 | if( pPreStepPoint -> GetPhysicalVolume() && |
---|
| 110 | pPostStepPoint -> GetPhysicalVolume() ) |
---|
| 111 | { |
---|
| 112 | G4String tpreVol = pPreStepPoint->GetPhysicalVolume()->GetName(); |
---|
| 113 | G4String tpostVol = pPostStepPoint->GetPhysicalVolume()->GetName(); |
---|
| 114 | |
---|
| 115 | #ifdef G4ANALISYS_USE |
---|
| 116 | if(richtbRunConfig-> GetRichTbParticleEnergyCode() == 1 || |
---|
| 117 | richtbRunConfig-> GetRichTbParticleEnergyCode() == 2 ) |
---|
| 118 | { |
---|
| 119 | // Optical photons are generated as beam particle. |
---|
| 120 | // count the photons entering the aerogel volume. |
---|
| 121 | // this is essentially same as the photons generated. |
---|
| 122 | |
---|
| 123 | if(( tpreVol == VolNameG || tpreVol == VolNameE ) && |
---|
| 124 | ( tpostVol == VolNameD ) ) |
---|
| 125 | { |
---|
| 126 | RichTbAnalysisManager * analysis = |
---|
| 127 | RichTbAnalysisManager::getInstance(); |
---|
| 128 | analysis->bumpNumPhotonsBeforeAerogel(); |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | #endif |
---|
| 132 | |
---|
| 133 | if(PhotonEnergy > 0.0 ) |
---|
| 134 | { |
---|
| 135 | |
---|
| 136 | const G4double PhotonWavelength = |
---|
| 137 | PhotMomWaveConv*1.0*eV/ PhotonEnergy; |
---|
| 138 | |
---|
| 139 | G4String tpreVol = pPreStepPoint -> GetPhysicalVolume()->GetName(); |
---|
| 140 | G4String tpostVol = pPostStepPoint -> GetPhysicalVolume()->GetName(); |
---|
| 141 | |
---|
| 142 | // First for the mirror volume |
---|
| 143 | |
---|
| 144 | #ifdef G4ANALYSIS_USE |
---|
| 145 | RichTbAnalysisManager * analysis = |
---|
| 146 | RichTbAnalysisManager::getInstance(); |
---|
| 147 | if(tpreVol == VolNameE && tpostVol == VolNameF ) |
---|
| 148 | { |
---|
| 149 | analysis->getfhistoWBeforeMirror()->fill(PhotonWavelength); |
---|
| 150 | analysis->bumpNumPhotonsBeforeMirror(); |
---|
| 151 | } |
---|
| 152 | if(tpreVol == VolNameF && tpostVol == VolNameE ) |
---|
| 153 | { |
---|
| 154 | analysis->getfhistoWAfterMirror()->fill(PhotonWavelength); |
---|
| 155 | analysis->bumpNumPhotonsAfterMirror(); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | //Now for the Aerogel Volume |
---|
| 159 | if(richtbRunConfig-> GetRichTbParticleEnergyCode() == 0 ) |
---|
| 160 | { |
---|
| 161 | if(( tpreVol == VolNameG || tpreVol == VolNameE ) && |
---|
| 162 | ( tpostVol == VolNameD ) ) |
---|
| 163 | { |
---|
| 164 | if(prePos.z() < postPos.z() ) |
---|
| 165 | { |
---|
| 166 | RichTbAnalysisManager * analysis = RichTbAnalysisManager::getInstance(); |
---|
| 167 | analysis->bumpNumPhotonsBeforeAerogel(); |
---|
| 168 | } |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | #endif |
---|
| 172 | |
---|
| 173 | if( ( tpreVol == VolNameD ) && |
---|
| 174 | ( tpostVol == VolNameG || tpostVol == VolNameE ) ) |
---|
| 175 | { |
---|
| 176 | |
---|
| 177 | // G4double XatAgelExit=postPos.x(); |
---|
| 178 | // G4double YatAgelExit=postPos.y(); |
---|
| 179 | // G4double ZatAgelExit=postPos.z(); |
---|
| 180 | const G4ThreeVector PhotCurMom = |
---|
| 181 | aPhotTrack->GetMomentumDirection(); |
---|
| 182 | // G4double CurExitangle= std::acos(PhotCurMom.z()); |
---|
| 183 | |
---|
| 184 | // Plot the Angle of emission of the photon. |
---|
| 185 | // When there is no Raylegh scattering this is the |
---|
| 186 | // Cherenkov angle. For now we only consider the charged |
---|
| 187 | // track to be of direction 001. Later this may be changed. |
---|
| 188 | // So the angle considered is just the angle of the photon |
---|
| 189 | // track. |
---|
| 190 | |
---|
| 191 | #ifdef G4ANALYSIS_USE |
---|
| 192 | RichTbAnalysisManager * analysis = |
---|
| 193 | RichTbAnalysisManager::getInstance(); |
---|
| 194 | |
---|
| 195 | const G4ThreeVector PhotOrgUnitMom = |
---|
| 196 | aPhotTrack->GetVertexMomentumDirection(); |
---|
| 197 | G4double Ckv_angle= std::acos(PhotOrgUnitMom.z()); |
---|
| 198 | |
---|
| 199 | analysis->getfhistoCkvProdSmall()->fill(Ckv_angle); |
---|
| 200 | |
---|
| 201 | // Now for the photon emission point in aerogel |
---|
| 202 | |
---|
| 203 | const G4ThreeVector PhotEmisPt = aPhotTrack->GetVertexPosition(); |
---|
| 204 | analysis->getfhistoEmisZ()->fill( PhotEmisPt.z()); |
---|
| 205 | #endif |
---|
| 206 | } |
---|
| 207 | } |
---|
| 208 | } |
---|
| 209 | } |
---|
| 210 | } |
---|
| 211 | } |
---|
| 212 | } |
---|