Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:09: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 Analysis.cc
0028 /// @brief Define histograms
0029 
0030 #include "Analysis.hh"
0031 
0032 #include "G4AnalysisManager.hh"
0033 #include "G4AutoDelete.hh"
0034 #include "G4SystemOfUnits.hh"
0035 
0036 // Select format of output here
0037 G4ThreadLocal G4int Analysis::fincidentFlag = false;
0038 G4ThreadLocal Analysis* the_analysis = 0;
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 Analysis* Analysis::GetAnalysis()
0042 {
0043   if (!the_analysis) {
0044     the_analysis = new Analysis();
0045     G4AutoDelete::Register(the_analysis);
0046   }
0047   return the_analysis;
0048 }
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 Analysis::Analysis()
0052   : fincident_x_hist(0),
0053     fincident_map(0),
0054     fdose_hist(0),
0055     fdose_map(0),
0056     fdose_prof(0),
0057     fdose_map_prof(0),
0058     fdose_map3d(0)
0059 {}
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 void Analysis::Book()
0063 {
0064   G4AnalysisManager* mgr = G4AnalysisManager::Instance();
0065   mgr->SetDefaultFileType("root");
0066   mgr->SetVerboseLevel(1);
0067   fincident_x_hist = mgr->CreateH1("incident_x", "Incident X", 100, -5 * cm, 5 * cm, "cm");
0068   fincident_map = mgr->CreateH2("incident_map", "Incident Map", 50, -5 * cm, 5 * cm, 50, -5 * cm,
0069                                 5 * cm, "cm", "cm");
0070   fdose_hist = mgr->CreateH1("dose", "Dose distribution", 500, 0, 50 * cm, "cm");
0071   fdose_map = mgr->CreateH2("dose_map", "Dose distribution", 500, 0, 50 * cm, 200, -10 * cm,
0072                             10 * cm, "cm", "cm");
0073   fdose_map3d = mgr->CreateH3("dose_map_3d", "Dose distribution", 30, 0, 50 * cm, 20, -10 * cm,
0074                               10 * cm, 20, -10 * cm, 10 * cm, "cm", "cm", "cm");
0075   fdose_prof =
0076     mgr->CreateP1("dose_prof", "Dose distribution", 300, 0, 30 * cm, 0, 100 * MeV, "cm", "MeV");
0077   fdose_map_prof = mgr->CreateP2("dose_map_prof", "Dose distribution", 300, 0, 30 * cm, 80, -4 * cm,
0078                                  4 * cm, 0, 100 * MeV, "cm", "cm", "MeV");
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 Analysis::~Analysis() {}
0083 
0084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0085 void Analysis::Update()
0086 {
0087   return;
0088 }
0089 
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0091 void Analysis::Clear()
0092 {
0093   return;
0094 }
0095 
0096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0097 void Analysis::Save(const G4String& fname)
0098 {
0099   G4AnalysisManager* mgr = G4AnalysisManager::Instance();
0100   mgr->OpenFile(fname.c_str());
0101   mgr->Write();
0102   return;
0103 }
0104 
0105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0106 void Analysis::Close(G4bool reset)
0107 {
0108   G4AnalysisManager* mgr = G4AnalysisManager::Instance();
0109   mgr->CloseFile(reset);
0110   return;
0111 }
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0114 void Analysis::FillIncident(const G4ThreeVector& p)
0115 {
0116   if (!fincidentFlag) {
0117     G4AnalysisManager* mgr = G4AnalysisManager::Instance();
0118     mgr->FillH2(fincident_map, p.x(), p.y());
0119     mgr->FillH1(fincident_x_hist, p.x());
0120     fincidentFlag = true;
0121   }
0122 }
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0125 void Analysis::FillDose(const G4ThreeVector& p, G4double dedx)
0126 {
0127   const G4double dxy = 10. * mm;
0128   if (std::abs(p.y()) < dxy) {
0129     G4AnalysisManager* mgr = G4AnalysisManager::Instance();
0130     const G4double Z0 = 25. * cm;
0131 
0132     mgr->FillH2(fdose_map, p.z() + Z0, p.x(), dedx / GeV);
0133     mgr->FillP2(fdose_map_prof, p.z() + Z0, p.x(), dedx);
0134     mgr->FillH3(fdose_map3d, p.z() + Z0, p.x(), p.y(), dedx / GeV);
0135     if (std::abs(p.x()) < dxy) {
0136       mgr->FillH1(fdose_hist, p.z() + Z0, dedx / GeV);
0137       mgr->FillP1(fdose_prof, p.z() + Z0, dedx);
0138     }
0139   }
0140 }