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 #include "Par04RunAction.hh" 26 #include "Par04RunAction.hh" 27 << 27 #include <G4GenericAnalysisManager.hh> // for G4GenericAnalysisManager >> 28 #include <G4ThreeVector.hh> // for G4ThreeVector >> 29 #include <G4Types.hh> // for G4int, G4double >> 30 #include <G4UserRunAction.hh> // for G4UserRunAction >> 31 #include "G4AnalysisManager.hh" // for G4AnalysisManager 28 #include "Par04DetectorConstruction.hh" // fo 32 #include "Par04DetectorConstruction.hh" // for Par04DetectorConstruction 29 #include "Par04EventAction.hh" // for Par04Ev << 33 #include "Par04EventAction.hh" // for Par04EventAction 30 << 31 #include "G4AnalysisManager.hh" // for G4Anal << 32 << 33 #include <G4GenericAnalysisManager.hh> // for << 34 #include <G4ThreeVector.hh> // for G4ThreeVec << 35 #include <G4Types.hh> // for G4int, G4double << 36 #include <G4UserRunAction.hh> // for G4UserRu << 37 34 38 //....oooOO0OOooo........oooOO0OOooo........oo 35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 39 36 40 Par04RunAction::Par04RunAction(Par04DetectorCo 37 Par04RunAction::Par04RunAction(Par04DetectorConstruction* aDetector, Par04EventAction* aEventAction) 41 : G4UserRunAction(), fDetector(aDetector), f << 38 : G4UserRunAction() >> 39 , fDetector(aDetector) >> 40 , fEventAction(aEventAction) 42 { 41 { 43 // Create analysis manager 42 // Create analysis manager 44 G4AnalysisManager* analysisManager = G4Analy 43 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 45 analysisManager->SetDefaultFileType("root"); 44 analysisManager->SetDefaultFileType("root"); 46 45 47 // Default filename, can be overriden with / 46 // Default filename, can be overriden with /analysis/setFileName 48 analysisManager->SetFileName("Par04Output"); 47 analysisManager->SetFileName("Par04Output"); 49 } 48 } 50 49 51 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 52 51 53 Par04RunAction::~Par04RunAction() = default; << 52 Par04RunAction::~Par04RunAction() {} 54 53 55 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 56 55 57 void Par04RunAction::BeginOfRunAction(const G4 56 void Par04RunAction::BeginOfRunAction(const G4Run*) 58 { 57 { 59 // Get analysis manager 58 // Get analysis manager 60 G4AnalysisManager* analysisManager = G4Analy 59 G4AnalysisManager* analysisManager = G4AnalysisManager::Instance(); 61 60 62 // Create directories 61 // Create directories 63 analysisManager->SetNtupleMerging(true); 62 analysisManager->SetNtupleMerging(true); 64 analysisManager->SetVerboseLevel(0); 63 analysisManager->SetVerboseLevel(0); 65 64 66 // Get detector dimensions 65 // Get detector dimensions 67 G4int cellNumZ = fDetector->GetMeshNbOfCells << 66 G4int cellNumZ = fDetector->GetMeshNbOfCells().z(); 68 G4int cellNumRho = fDetector->GetMeshNbOfCel << 67 G4int cellNumRho = fDetector->GetMeshNbOfCells().x(); 69 G4int cellNumPhi = fDetector->GetMeshNbOfCel << 68 G4int cellNumPhi = fDetector->GetMeshNbOfCells().y(); 70 G4double cellSizeZ = fDetector->GetMeshSizeO << 69 G4double cellSizeZ = fDetector->GetMeshSizeOfCells().z(); 71 G4double cellSizeRho = fDetector->GetMeshSiz 70 G4double cellSizeRho = fDetector->GetMeshSizeOfCells().x(); 72 G4double cellSizePhi = fDetector->GetMeshSiz 71 G4double cellSizePhi = fDetector->GetMeshSizeOfCells().y(); 73 // Default max value of energy stored in his 72 // Default max value of energy stored in histogram (in GeV) 74 G4double maxEnergy = 1000; 73 G4double maxEnergy = 1000; 75 74 76 // Creating control histograms 75 // Creating control histograms 77 analysisManager->CreateH1("energyParticle", 76 analysisManager->CreateH1("energyParticle", "Primary energy;E_{MC} (GeV);Entries", 1024, 0, 78 1.1 * maxEnergy); 77 1.1 * maxEnergy); 79 analysisManager->CreateH1("energyDepositedIn << 78 analysisManager->CreateH1("energyDeposited", "Deposited energy;E_{MC} (GeV);Entries", 1024, 0, 80 1024, 0, 1.1 * max << 79 1.1 * maxEnergy); 81 analysisManager->CreateH1("energyRatioInVirt << 80 analysisManager->CreateH1( 82 "Ratio of energy d << 81 "energyRatio", "Ratio of energy deposited to primary;E_{dep} / E_{MC};Entries", 1024, 0, 1); 83 0, 1); << 84 analysisManager->CreateH1("time", "Simulatio 82 analysisManager->CreateH1("time", "Simulation time; time (s);Entries", 2048, 0, 100); 85 analysisManager->CreateH1("longProfile", "Lo 83 analysisManager->CreateH1("longProfile", "Longitudinal profile;t (mm);#LTE#GT (MeV)", cellNumZ, 86 -0.5 * cellSizeZ, 84 -0.5 * cellSizeZ, (cellNumZ - 0.5) * cellSizeZ); 87 analysisManager->CreateH1("transProfile", "T 85 analysisManager->CreateH1("transProfile", "Transverse profile;r (mm);#LTE#GT (MeV)", cellNumRho, 88 -0.5 * cellSizeRho 86 -0.5 * cellSizeRho, (cellNumRho - 0.5) * cellSizeRho); 89 analysisManager->CreateH1("longFirstMoment", 87 analysisManager->CreateH1("longFirstMoment", 90 "First moment of l 88 "First moment of longitudinal distribution;#LT#lambda#GT (mm);Entries", 91 1024, -0.5 * cellS 89 1024, -0.5 * cellSizeZ, 92 cellNumZ * cellSiz 90 cellNumZ * cellSizeZ / 2); // arbitrary scaling of max value on axis 93 analysisManager->CreateH1("transFirstMoment" 91 analysisManager->CreateH1("transFirstMoment", 94 "First moment of t 92 "First moment of transverse distribution;#LTr#GT " 95 "(mm);Entries", 93 "(mm);Entries", 96 1024, -0.5 * cellS 94 1024, -0.5 * cellSizeRho, 97 cellNumRho * cellS << 95 cellNumRho * cellSizeRho / 98 / 1); // arbitr << 96 1); // arbitrary scaling of max value on axis 99 analysisManager->CreateH1( 97 analysisManager->CreateH1( 100 "longSecondMoment", 98 "longSecondMoment", 101 "Second moment of longitudinal distributio 99 "Second moment of longitudinal distribution;#LT#lambda^{2}#GT " 102 "(mm^{2});Entries", 100 "(mm^{2});Entries", 103 1024, 0, std::pow(cellNumZ * cellSizeZ, 2) 101 1024, 0, std::pow(cellNumZ * cellSizeZ, 2) / 25); // arbitrary scaling of max value on axis 104 analysisManager->CreateH1( 102 analysisManager->CreateH1( 105 "transSecondMoment", "Second moment of tra 103 "transSecondMoment", "Second moment of transverse distribution;#LTr^{2}#GT (mm^{2});Entries", 106 1024, 0, std::pow(cellNumRho * cellSizeRho 104 1024, 0, std::pow(cellNumRho * cellSizeRho, 2) / 5); // arbitrary scaling of max value on axis 107 analysisManager->CreateH1("hitType", "hit ty 105 analysisManager->CreateH1("hitType", "hit type;type (0=full, 1= fast);Entries", 2, -0.5, 1.5); 108 analysisManager->CreateH1( << 106 analysisManager->CreateH1("phiProfile", "Azimuthal angle profile, centred at mean;phi;#LTE#GT (MeV)", cellNumPhi, 109 "phiProfile", "Azimuthal angle profile, ce << 107 - (cellNumPhi - 0.5) * cellSizePhi, (cellNumPhi - 0.5) * cellSizePhi); 110 -(cellNumPhi - 0.5) * cellSizePhi, (cellNu << 108 analysisManager->CreateH1("numHits", "Number of hits above 0.5 keV", 4048, 0, 40500); 111 analysisManager->CreateH1("numHitsInVirtual" << 109 analysisManager->CreateH1("cellEnergy", "Cell energy distribution;log10(E/MeV);Entries", 1024, -4, 2); 112 analysisManager->CreateH1("cellEnergy", "Cel << 113 2); << 114 analysisManager->CreateH1("numDepositsInVirt << 115 4048, 0, 40000); << 116 analysisManager->CreateH1("cellDepositsInVir << 117 "Distribution of n << 118 analysisManager->CreateH1("energyDepositedIn << 119 "Deposited energy << 120 1024, 0, 1.1 * max << 121 analysisManager->CreateH1( << 122 "energyRatioInPhysical", << 123 "Ratio of energy deposited in physical rea << 124 1); << 125 analysisManager->CreateH1("numHitsInPhysical << 126 4048, 0, 5000); << 127 analysisManager->CreateH1("cellEnergyInPhysi << 128 "Physical cell ene << 129 analysisManager->CreateH1("numDepositsInPhys << 130 "Number of deposit << 131 analysisManager->CreateH1("cellDepositsInPhy << 132 "Distribution of n << 133 0, 1024); << 134 110 135 // Creating ntuple 111 // Creating ntuple 136 analysisManager->CreateNtuple("global", "Eve << 112 analysisManager->CreateNtuple("events", "per event data"); 137 analysisManager->CreateNtupleDColumn("Energy 113 analysisManager->CreateNtupleDColumn("EnergyMC"); 138 analysisManager->CreateNtupleDColumn("SimTim << 139 analysisManager->FinishNtuple(); << 140 << 141 analysisManager->CreateNtuple("virtualReadou << 142 analysisManager->CreateNtupleDColumn("Energy 114 analysisManager->CreateNtupleDColumn("EnergyCell", fEventAction->GetCalEdep()); 143 analysisManager->CreateNtupleIColumn("rhoCel 115 analysisManager->CreateNtupleIColumn("rhoCell", fEventAction->GetCalRho()); 144 analysisManager->CreateNtupleIColumn("phiCel 116 analysisManager->CreateNtupleIColumn("phiCell", fEventAction->GetCalPhi()); 145 analysisManager->CreateNtupleIColumn("zCell" 117 analysisManager->CreateNtupleIColumn("zCell", fEventAction->GetCalZ()); 146 analysisManager->FinishNtuple(); << 118 analysisManager->CreateNtupleDColumn("SimTime"); 147 << 148 analysisManager->CreateNtuple("physicalReado << 149 analysisManager->CreateNtupleDColumn("Energy << 150 analysisManager->CreateNtupleIColumn("layerC << 151 analysisManager->CreateNtupleIColumn("rowCel << 152 analysisManager->CreateNtupleIColumn("sliceC << 153 analysisManager->FinishNtuple(); 119 analysisManager->FinishNtuple(); 154 120 155 analysisManager->OpenFile(); 121 analysisManager->OpenFile(); 156 } 122 } 157 123 158 //....oooOO0OOooo........oooOO0OOooo........oo 124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 159 125 160 void Par04RunAction::EndOfRunAction(const G4Ru 126 void Par04RunAction::EndOfRunAction(const G4Run*) 161 { 127 { 162 auto analysisManager = G4AnalysisManager::In 128 auto analysisManager = G4AnalysisManager::Instance(); 163 analysisManager->Write(); 129 analysisManager->Write(); 164 analysisManager->CloseFile(); 130 analysisManager->CloseFile(); 165 } 131 } 166 132