Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 /// \file ExGflashEventAction.cc 27 /// \file ExGflashEventAction.cc 28 /// \brief Implementation of the ExGflashEvent 28 /// \brief Implementation of the ExGflashEventAction class 29 // 29 // 30 30 31 #include "ExGflashEventAction.hh" 31 #include "ExGflashEventAction.hh" 32 << 33 #include "ExGflashDetectorConstruction.hh" 32 #include "ExGflashDetectorConstruction.hh" 34 #include "ExGflashHistoManager.hh" 33 #include "ExGflashHistoManager.hh" 35 #include "ExGflashHit.hh" 34 #include "ExGflashHit.hh" 36 << 37 #include "G4Event.hh" 35 #include "G4Event.hh" 38 #include "G4EventManager.hh" 36 #include "G4EventManager.hh" 39 #include "G4SDManager.hh" 37 #include "G4SDManager.hh" 40 #include "G4SystemOfUnits.hh" 38 #include "G4SystemOfUnits.hh" 41 #include "G4UImanager.hh" 39 #include "G4UImanager.hh" 42 // std 40 // std 43 #include <algorithm> 41 #include <algorithm> 44 #include <iostream> 42 #include <iostream> 45 #include <vector> 43 #include <vector> 46 44 47 using MyVector = std::vector<G4double>; 45 using MyVector = std::vector<G4double>; 48 46 49 // Gflash 47 // Gflash 50 using namespace std; 48 using namespace std; 51 49 52 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 51 54 ExGflashEventAction::ExGflashEventAction(ExGfl << 52 ExGflashEventAction::ExGflashEventAction(ExGflashDetectorConstruction* det) >> 53 : G4UserEventAction(), fCalorimeterCollectionId(-1), fDet(det) >> 54 {} 55 55 56 //....oooOO0OOooo........oooOO0OOooo........oo 56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 57 58 ExGflashEventAction::~ExGflashEventAction() = 58 ExGflashEventAction::~ExGflashEventAction() = default; 59 59 60 //....oooOO0OOooo........oooOO0OOooo........oo 60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 61 62 void ExGflashEventAction::BeginOfEventAction(c 62 void ExGflashEventAction::BeginOfEventAction(const G4Event* /* evt */) {} 63 63 64 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 65 66 void ExGflashEventAction::EndOfEventAction(con 66 void ExGflashEventAction::EndOfEventAction(const G4Event* evt) 67 { 67 { 68 G4SDManager* SDman = G4SDManager::GetSDMpoin 68 G4SDManager* SDman = G4SDManager::GetSDMpointer(); 69 G4String colNam; << 69 G4String colNam; 70 fCalorimeterCollectionId = SDman->GetCollect << 70 fCalorimeterCollectionId = >> 71 SDman->GetCollectionID(colNam = "ExGflashCollection"); 71 72 72 if (fCalorimeterCollectionId < 0) { << 73 if ( fCalorimeterCollectionId < 0 ) { 73 return; 74 return; 74 } 75 } 75 76 76 G4HCofThisEvent* HCE = evt->GetHCofThisEvent << 77 G4HCofThisEvent* HCE = evt->GetHCofThisEvent(); 77 ExGflashHitsCollection* THC = nullptr; << 78 ExGflashHitsCollection* THC = nullptr; 78 G4double totE = 0; << 79 G4double totE = 0; 79 80 80 // Read out of the crysta ECAL 81 // Read out of the crysta ECAL 81 THC = (ExGflashHitsCollection*)(HCE->GetHC(f 82 THC = (ExGflashHitsCollection*)(HCE->GetHC(fCalorimeterCollectionId)); 82 83 83 if (THC != nullptr) { << 84 if ( THC != nullptr ) { 84 /// Hits in sensitive Detector 85 /// Hits in sensitive Detector 85 int n_hit = THC->entries(); 86 int n_hit = THC->entries(); 86 << 87 // G4cout<<" " << n_hit<< " hits are stored in ExGflashHitsCollection >> 88 // "<<G4endl; 87 G4PrimaryVertex* pvertex = evt->GetPrimary 89 G4PrimaryVertex* pvertex = evt->GetPrimaryVertex(); 88 // Computing (x,y,z) of vertex of initial 90 // Computing (x,y,z) of vertex of initial particles 89 G4ThreeVector vtx = pvertex->GetPosition() << 91 G4ThreeVector vtx = pvertex->GetPosition(); 90 G4PrimaryParticle* pparticle = pvertex->Ge 92 G4PrimaryParticle* pparticle = pvertex->GetPrimary(); 91 // direction of the Shower 93 // direction of the Shower 92 G4ThreeVector mom = pparticle->GetMomentum 94 G4ThreeVector mom = pparticle->GetMomentumDirection(); 93 95 94 G4double Ekin = pparticle->GetKineticEnerg 96 G4double Ekin = pparticle->GetKineticEnergy(); 95 G4double mass = pparticle->GetParticleDefi 97 G4double mass = pparticle->GetParticleDefinition()->GetPDGMass(); 96 G4double Etot = Ekin / MeV + mass / MeV; 98 G4double Etot = Ekin / MeV + mass / MeV; 97 99 98 G4int nLbin = fDet->GetnLtot(); << 100 G4int nLbin = fDet->GetnLtot(); 99 G4int nRbin = fDet->GetnRtot(); << 101 G4int nRbin = fDet->GetnRtot(); 100 G4double dLradl = fDet->GetdLradl(); 102 G4double dLradl = fDet->GetdLradl(); 101 G4double dRradl = fDet->GetdRradl(); 103 G4double dRradl = fDet->GetdRradl(); 102 104 103 G4double SDRadl = fDet->GetSDRadLen(); // << 105 G4double SDRadl = fDet->GetSDRadLen(); // SD matrial 104 G4double SDRm = fDet->GetSDRm(); // SD Ra << 105 << 106 // init to to 0.0 106 // init to to 0.0 107 MyVector dEdL(nLbin, 0.0); 107 MyVector dEdL(nLbin, 0.0); 108 MyVector dEdR(nRbin, 0.0); 108 MyVector dEdR(nRbin, 0.0); 109 109 110 G4AnalysisManager* fAnalysisManager = G4An 110 G4AnalysisManager* fAnalysisManager = G4AnalysisManager::Instance(); 111 111 112 fAnalysisManager->FillH1(1, n_hit + 0.5); 112 fAnalysisManager->FillH1(1, n_hit + 0.5); 113 /// For all Hits in sensitive detector 113 /// For all Hits in sensitive detector 114 for (int i = 0; i < n_hit; i++) { << 114 for ( int i = 0; i < n_hit; i++ ) { 115 G4double estep = (*THC)[i]->GetEdep(); 115 G4double estep = (*THC)[i]->GetEdep(); 116 fAnalysisManager->FillH1(2, estep / MeV) 116 fAnalysisManager->FillH1(2, estep / MeV); 117 estep /= MeV; 117 estep /= MeV; 118 118 119 if (estep > 0.0) { << 119 if ( estep > 0.0 ) { 120 totE += estep; 120 totE += estep; 121 121 122 G4ThreeVector hitpos = (*THC)[i]->GetP 122 G4ThreeVector hitpos = (*THC)[i]->GetPos(); 123 // in shower coordinate system 123 // in shower coordinate system 124 // from shower start 124 // from shower start 125 G4ThreeVector l = hitpos - vtx; 125 G4ThreeVector l = hitpos - vtx; 126 // longitudinal profile 126 // longitudinal profile 127 G4ThreeVector longitudinal = l.dot(mom 127 G4ThreeVector longitudinal = l.dot(mom) * mom; 128 // shower profiles (Radial) 128 // shower profiles (Radial) 129 G4ThreeVector radial = l - longitudina 129 G4ThreeVector radial = l - longitudinal; 130 130 131 auto SlideNb = G4int((longitudinal.mag << 131 G4int SlideNb = G4int((longitudinal.mag() / SDRadl) / dLradl); 132 auto RingNb = G4int((radial.mag() / SD << 132 G4int RingNb = G4int((radial.mag() / SDRadl) / dRradl); 133 133 134 if ((SlideNb >= 0 && SlideNb < nLbin) << 134 if ( SlideNb >= 0 && SlideNb < nLbin ) dEdL[SlideNb] += estep; 135 dEdL[SlideNb] += estep; << 135 if ( RingNb >= 0 && RingNb < nLbin ) dEdR[RingNb] += estep; 136 dEdR[RingNb] += estep; << 137 } << 138 } 136 } 139 } 137 } 140 138 141 G4double Lnorm = 100. / dLradl / Etot; 139 G4double Lnorm = 100. / dLradl / Etot; 142 G4double Lsum = 0.0; << 140 G4double Lsum = 0.0; 143 for (int i = 0; i < nLbin; i++) { // Slid << 141 for ( int i = 0; i < nLbin; i++ ) { // Slide 144 fAnalysisManager->FillP1(0, (i + 0.5) * 142 fAnalysisManager->FillP1(0, (i + 0.5) * dLradl, dEdL[i] * Lnorm); 145 Lsum += dEdL[i]; 143 Lsum += dEdL[i]; 146 fAnalysisManager->FillP1(2, (i + 0.5) * 144 fAnalysisManager->FillP1(2, (i + 0.5) * dLradl, Lsum * Lnorm); 147 } 145 } 148 G4double Rnorm = 100. / dRradl / Etot; 146 G4double Rnorm = 100. / dRradl / Etot; 149 G4double Rsum = 0.0; << 147 G4double Rsum = 0.0; 150 for (int i = 0; i < nRbin; i++) { // Ring << 148 for ( int i = 0; i < nRbin; i++ ) { // Ring 151 fAnalysisManager->FillP1(1, (i + 0.5) * 149 fAnalysisManager->FillP1(1, (i + 0.5) * dRradl, dEdR[i] * Rnorm); 152 Rsum += dEdR[i]; 150 Rsum += dEdR[i]; 153 fAnalysisManager->FillP1(3, (i + 0.5) * 151 fAnalysisManager->FillP1(3, (i + 0.5) * dRradl, Rsum * Rnorm); 154 } 152 } 155 153 156 fAnalysisManager->FillH1(0, totE / Etot * 154 fAnalysisManager->FillH1(0, totE / Etot * 100.); 157 } 155 } 158 } 156 } 159 157 160 //....oooOO0OOooo........oooOO0OOooo........oo 158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 161 159