Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:01

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file ChemNtupleManager.cc
0028 /// \brief Implementation of the ChemNtupleManager class
0029 
0030 #include "ChemNtupleManager.hh"
0031 
0032 #include "G4UnitsTable.hh"
0033 #include "G4Filesystem.hh"
0034 
0035 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0036 
0037 void ChemNtupleManager::Book()
0038 {
0039     std::string outFolder = "chem_output";
0040     const G4fs::path outFolderP{outFolder};
0041     G4fs::file_status s = G4fs::file_status{};
0042     auto isExist = G4fs::status_known(s) ? G4fs::exists(s) : G4fs::exists(outFolderP);
0043     if (! isExist) {
0044         G4fs::create_directory(outFolderP);
0045     }
0046     G4String slash = "";
0047 #if defined(_WIN32) || defined(WIN32)
0048     slash= "\\";
0049 #else
0050     G4String slashu = "/";
0051     slash = slashu;
0052 #endif
0053     G4String fullFileName = outFolder+slash+fFileName;
0054     // open output file
0055     //
0056     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0057     G4bool fileOpen = analysisManager->OpenFile(fullFileName.c_str());
0058     if (!fileOpen) {
0059         G4cout << "\n---> HistoManager::book(): cannot open " << fFileName
0060                << G4endl;
0061         return;
0062     } 
0063 }
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0066 
0067 void ChemNtupleManager::Save()
0068 {  
0069     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0070     analysisManager->Write();
0071     analysisManager->CloseFile();
0072 }
0073 
0074 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0075 
0076 void ChemNtupleManager::FillNtupleIColumn(G4int icol, G4int ival)
0077 {
0078     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0079     analysisManager->FillNtupleIColumn(icol,ival);
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 
0084 void ChemNtupleManager::FillNtupleFColumn(G4int icol, G4float fval)
0085 {
0086     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0087     analysisManager->FillNtupleFColumn(icol,fval);
0088 }
0089 
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0091 
0092 void ChemNtupleManager::FillNtupleDColumn(G4int id, G4int icol, G4double dval)
0093 {
0094     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0095     analysisManager->FillNtupleDColumn(id,icol,dval);
0096 }
0097 
0098 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0099 
0100 void ChemNtupleManager::AddNtupleRow()
0101 {
0102     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0103     analysisManager->AddNtupleRow();
0104 }
0105 
0106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0107 
0108 void ChemNtupleManager::AddNtupleRow(G4int id)
0109 {
0110     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0111     analysisManager->AddNtupleRow(id);
0112 }
0113 
0114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0115 
0116 void ChemNtupleManager::CreateNtuples()
0117 {
0118     G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0119     analysisManager->SetVerboseLevel(1);
0120     analysisManager->SetDefaultFileType("root");
0121     // Create directories
0122     const G4String directoryName = "ntuple";
0123     if (analysisManager->GetNtupleDirectoryName() != directoryName) {
0124         analysisManager->SetNtupleDirectoryName(directoryName);
0125     }
0126     // create ntuple
0127 
0128     if (analysisManager->GetFirstNtupleId() != 1) analysisManager->SetFirstNtupleId(1);
0129     
0130     // DBScan
0131 
0132     analysisManager->CreateNtuple("ntuple_2","DB_chemical_stage");
0133     analysisManager->CreateNtupleDColumn(1,"strand");
0134     analysisManager->CreateNtupleDColumn(1,"copyNumber");
0135     analysisManager->CreateNtupleDColumn(1,"xp");
0136     analysisManager->CreateNtupleDColumn(1,"yp");
0137     analysisManager->CreateNtupleDColumn(1,"zp");
0138     analysisManager->CreateNtupleDColumn(1,"time");
0139     analysisManager->CreateNtupleDColumn(1,"base");
0140     analysisManager->FinishNtuple(1);
0141 }
0142 
0143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......