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 // Created by Joanna Weng 26.11.2004 30 31 31 #include "ExGflashEventAction.hh" << 32 32 33 #include "ExGflashDetectorConstruction.hh" << 33 #include "ExGflashEventAction.hh" 34 #include "ExGflashHistoManager.hh" << 35 #include "ExGflashHit.hh" 34 #include "ExGflashHit.hh" 36 << 35 #include "ExGflashHistoManager.hh" 37 #include "G4Event.hh" << 36 #include "ExGflashDetectorConstruction.hh" 38 #include "G4EventManager.hh" 37 #include "G4EventManager.hh" 39 #include "G4SDManager.hh" 38 #include "G4SDManager.hh" 40 #include "G4SystemOfUnits.hh" << 41 #include "G4UImanager.hh" 39 #include "G4UImanager.hh" 42 // std << 40 #include "G4Event.hh" 43 #include <algorithm> << 41 #include "G4SystemOfUnits.hh" >> 42 //std 44 #include <iostream> 43 #include <iostream> >> 44 #include <algorithm> 45 #include <vector> 45 #include <vector> >> 46 typedef std::vector<G4double> MyVector; 46 47 47 using MyVector = std::vector<G4double>; << 48 //Gflash 48 << 49 // Gflash << 50 using namespace std; 49 using namespace std; 51 50 52 //....oooOO0OOooo........oooOO0OOooo........oo 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 53 52 54 ExGflashEventAction::ExGflashEventAction(ExGfl << 53 ExGflashEventAction::ExGflashEventAction(ExGflashDetectorConstruction* det) >> 54 : G4UserEventAction(),fCalorimeterCollectionId(-1),fDet(det) >> 55 { >> 56 } 55 57 56 //....oooOO0OOooo........oooOO0OOooo........oo 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 57 59 58 ExGflashEventAction::~ExGflashEventAction() = << 60 ExGflashEventAction::~ExGflashEventAction() >> 61 { >> 62 } 59 63 60 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 61 65 62 void ExGflashEventAction::BeginOfEventAction(c << 66 void ExGflashEventAction::BeginOfEventAction(const G4Event * /* evt */) >> 67 { >> 68 } 63 69 64 //....oooOO0OOooo........oooOO0OOooo........oo 70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 65 71 66 void ExGflashEventAction::EndOfEventAction(con << 72 void ExGflashEventAction::EndOfEventAction(const G4Event *evt) 67 { << 73 { 68 G4SDManager* SDman = G4SDManager::GetSDMpoin << 74 >> 75 G4SDManager * SDman = G4SDManager::GetSDMpointer(); 69 G4String colNam; 76 G4String colNam; 70 fCalorimeterCollectionId = SDman->GetCollect << 77 fCalorimeterCollectionId=SDman->GetCollectionID(colNam="ExGflashCollection"); 71 78 72 if (fCalorimeterCollectionId < 0) { << 79 if (fCalorimeterCollectionId<0) return; 73 return; << 74 } << 75 80 76 G4HCofThisEvent* HCE = evt->GetHCofThisEvent << 81 G4HCofThisEvent * HCE = evt->GetHCofThisEvent(); 77 ExGflashHitsCollection* THC = nullptr; << 82 ExGflashHitsCollection* THC = 0; 78 G4double totE = 0; 83 G4double totE = 0; 79 84 80 // Read out of the crysta ECAL 85 // Read out of the crysta ECAL 81 THC = (ExGflashHitsCollection*)(HCE->GetHC(f << 86 THC=(ExGflashHitsCollection *)(HCE->GetHC(fCalorimeterCollectionId)); 82 87 83 if (THC != nullptr) { << 88 if (THC) 84 /// Hits in sensitive Detector << 89 { 85 int n_hit = THC->entries(); << 90 /// Hits in sensitive Detector 86 << 91 int n_hit = THC->entries(); 87 G4PrimaryVertex* pvertex = evt->GetPrimary << 92 // G4cout<<" " << n_hit<< " hits are stored in ExGflashHitsCollection "<<G4endl; 88 // Computing (x,y,z) of vertex of initial << 93 G4PrimaryVertex* pvertex=evt->GetPrimaryVertex(); 89 G4ThreeVector vtx = pvertex->GetPosition() << 94 //Computing (x,y,z) of vertex of initial particles 90 G4PrimaryParticle* pparticle = pvertex->Ge << 95 G4ThreeVector vtx=pvertex->GetPosition(); 91 // direction of the Shower << 96 G4PrimaryParticle* pparticle=pvertex->GetPrimary(); 92 G4ThreeVector mom = pparticle->GetMomentum << 97 // direction of the Shower 93 << 98 G4ThreeVector mom=pparticle->GetMomentumDirection(); 94 G4double Ekin = pparticle->GetKineticEnerg << 99 95 G4double mass = pparticle->GetParticleDefi << 100 G4double Ekin=pparticle->GetKineticEnergy(); 96 G4double Etot = Ekin / MeV + mass / MeV; << 101 G4double mass=pparticle->GetParticleDefinition()->GetPDGMass(); 97 << 102 G4double Etot = Ekin/MeV + mass/MeV; 98 G4int nLbin = fDet->GetnLtot(); << 103 99 G4int nRbin = fDet->GetnRtot(); << 104 G4int nLbin = fDet->GetnLtot(); 100 G4double dLradl = fDet->GetdLradl(); << 105 G4int nRbin = fDet->GetnRtot(); 101 G4double dRradl = fDet->GetdRradl(); << 106 G4double dLradl = fDet->GetdLradl(); 102 << 107 G4double dRradl = fDet->GetdRradl(); 103 G4double SDRadl = fDet->GetSDRadLen(); // << 108 104 G4double SDRm = fDet->GetSDRm(); // SD Ra << 109 G4double SDRadl = fDet->GetSDRadLen(); // SD matrial 105 << 110 // init to to 0.0 106 // init to to 0.0 << 111 MyVector dEdL(nLbin,0.0); 107 MyVector dEdL(nLbin, 0.0); << 112 MyVector dEdR(nRbin,0.0); 108 MyVector dEdR(nRbin, 0.0); << 113 109 << 114 G4AnalysisManager* fAnalysisManager = G4AnalysisManager::Instance(); 110 G4AnalysisManager* fAnalysisManager = G4An << 115 111 << 116 fAnalysisManager->FillH1(1,n_hit + 0.5); 112 fAnalysisManager->FillH1(1, n_hit + 0.5); << 117 /// For all Hits in sensitive detector 113 /// For all Hits in sensitive detector << 118 for (int i=0;i<n_hit;i++) 114 for (int i = 0; i < n_hit; i++) { << 119 { 115 G4double estep = (*THC)[i]->GetEdep(); << 120 G4double estep = (*THC)[i]->GetEdep(); 116 fAnalysisManager->FillH1(2, estep / MeV) << 121 fAnalysisManager->FillH1(2,estep/MeV); 117 estep /= MeV; << 122 estep /= MeV; 118 << 123 119 if (estep > 0.0) { << 124 if (estep >0.0) 120 totE += estep; << 125 { 121 << 126 totE += estep; 122 G4ThreeVector hitpos = (*THC)[i]->GetP << 127 123 // in shower coordinate system << 128 G4ThreeVector hitpos=(*THC)[i]->GetPos(); 124 // from shower start << 129 // in shower coordinate system 125 G4ThreeVector l = hitpos - vtx; << 130 // from shower start 126 // longitudinal profile << 131 G4ThreeVector l = hitpos - vtx; 127 G4ThreeVector longitudinal = l.dot(mom << 132 //longitudinal profile 128 // shower profiles (Radial) << 133 G4ThreeVector longitudinal = l.dot(mom) * mom; 129 G4ThreeVector radial = l - longitudina << 134 // shower profiles (Radial) 130 << 135 G4ThreeVector radial = l - longitudinal; 131 auto SlideNb = G4int((longitudinal.mag << 136 132 auto RingNb = G4int((radial.mag() / SD << 137 G4int SlideNb = G4int((longitudinal.mag()/SDRadl) / dLradl); 133 << 138 G4int RingNb = G4int((radial.mag()/SDRadl) / dRradl); 134 if ((SlideNb >= 0 && SlideNb < nLbin) << 139 135 dEdL[SlideNb] += estep; << 140 if ( SlideNb >=0 && SlideNb < nLbin) dEdL[SlideNb] += estep; 136 dEdR[RingNb] += estep; << 141 if ( RingNb >=0 && RingNb < nLbin)dEdR[RingNb] += estep; >> 142 } 137 } 143 } 138 } << 139 } << 140 144 141 G4double Lnorm = 100. / dLradl / Etot; << 145 G4double Lnorm = 100. / dLradl / Etot; 142 G4double Lsum = 0.0; << 146 G4double Lsum = 0.0; 143 for (int i = 0; i < nLbin; i++) { // Slid << 147 for (int i=0;i<nLbin;i++) 144 fAnalysisManager->FillP1(0, (i + 0.5) * << 148 { // Slide 145 Lsum += dEdL[i]; << 149 // fAnalysisManager->FillH1(3,(i +0.5) * dLradl,dEdL[i] * Lnorm); 146 fAnalysisManager->FillP1(2, (i + 0.5) * << 150 fAnalysisManager->FillP1(0,(i +0.5) * dLradl,dEdL[i] * Lnorm); 147 } << 151 Lsum += dEdL[i]; 148 G4double Rnorm = 100. / dRradl / Etot; << 152 fAnalysisManager->FillP1(2,(i +0.5) * dLradl,Lsum * Lnorm); 149 G4double Rsum = 0.0; << 153 } 150 for (int i = 0; i < nRbin; i++) { // Ring << 154 G4double Rnorm = 100. / dRradl / Etot; 151 fAnalysisManager->FillP1(1, (i + 0.5) * << 155 G4double Rsum = 0.0; 152 Rsum += dEdR[i]; << 156 for (int i=0;i<nRbin;i++) 153 fAnalysisManager->FillP1(3, (i + 0.5) * << 157 { // Ring 154 } << 158 // fAnalysisManager->FillH1(4,(i +0.5) * dRradl,dEdR[i] * Rnorm); >> 159 fAnalysisManager->FillP1(1,(i +0.5) * dRradl,dEdR[i] * Rnorm); >> 160 Rsum += dEdR[i]; >> 161 fAnalysisManager->FillP1(3,(i +0.5) * dRradl,Rsum * Rnorm); >> 162 } >> 163 >> 164 fAnalysisManager->FillH1(0,totE/Etot * 100.); 155 165 156 fAnalysisManager->FillH1(0, totE / Etot * << 166 } 157 } << 158 } 167 } 159 168 160 //....oooOO0OOooo........oooOO0OOooo........oo 169 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 161 170