//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... #include #include #include "G4RunManager.hh" #include "HistoManager.hh" #include "DetectorConstruction.hh" #include "PrimaryGeneratorAction.hh" //#include "G4UnitsTable.hh" #include "G4SystemOfUnits.hh" //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... HistoManager::HistoManager() : fDetector(0),fPrimary(0),fFileName("Final") { fDetector = static_cast (G4RunManager::GetRunManager()->GetUserDetectorConstruction()); fPrimary = static_cast (G4RunManager::GetRunManager()->GetUserPrimaryGeneratorAction()); Book(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... HistoManager::~HistoManager() { delete G4AnalysisManager::Instance(); } void HistoManager::Book() { /* This member reset the histograms and it is called at the begin of each run; here we put the initialization so that the histograms have always the right dimensions depending from the detector geometry */ auto analysisManager = G4AnalysisManager::Instance(); analysisManager->SetFileName(fFileName); G4cout<< "-------------" << fFileName<<"---------------"<SetVerboseLevel(1); analysisManager->SetNtupleMerging(true); G4cout << " done" << G4endl; G4double sizemax = fDetector->GetAbsorSizeZ(); G4int nbins = sizemax/um; analysisManager->CreateH1("0", "Edep_along_absorbers" , nbins, 0, sizemax*mm); //G4cout<< 0 << " --- " << "Edep_along_absorbers" << " --- " << nbins << " --- " << sizemax*mm << " ---" << G4endl; for (G4int iAbs=1; iAbs<(fDetector->GetNbOfAbsor()+1); iAbs++){ G4double sizeAbsor = fDetector->GetAbsorThickness(fDetector->GetNbOfAbsor()-iAbs+1); G4int nbinsAbsor = sizeAbsor/um; std::stringstream ss; ss << iAbs; G4String str = ss.str(); G4String abs = "Edep_along_absorber_"+str; analysisManager->CreateH1(str, abs, nbinsAbsor, 0, sizeAbsor*mm); //G4cout<< str << " --- " << abs << " --- " << nbinsAbsor << " --- " << sizeAbsor*mm << " ---" << G4endl; } analysisManager->CreateNtuple("Landau", "Edep and TrackLength"); analysisManager->CreateNtupleDColumn("Particle"); analysisManager->CreateNtupleDColumn("Detector"); analysisManager->CreateNtupleDColumn("edep"); analysisManager->FinishNtuple(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... /* This member is called at the end of each run */ void HistoManager::Save() { //Save histograms auto analysisManager = G4AnalysisManager::Instance(); analysisManager->Write(); analysisManager->CloseFile(); }