OMSim
Geant4 for IceCube optical module studies
Loading...
Searching...
No Matches
OMSimEffectiveAreaAnalyisis.hh
1
6#pragma once
7
8#include "OMSimPMTResponse.hh"
9#include "OMSimHitManager.hh"
10
11#include <G4ThreeVector.hh>
12#include <fstream>
13
18{
19 double EA;
20 double EAError;
21};
22
29{
30public:
33
34 template <typename... Args>
35 void writeScan(Args... p_args);
36 template <typename... Args>
37 void writeHeader(Args... p_args);
38
39 effectiveAreaResult calculateEffectiveArea(double weightedTotal, double countTotal);
40 G4String m_outputFileName;
41};
42
47template <typename... Args>
49{
50 std::vector<double> hits = OMSimHitManager::getInstance().countMergedHits(0, true);
51
52 std::fstream dataFile;
53 dataFile.open(m_outputFileName.c_str(), std::ios::out | std::ios::app);
54
55 // Write all arguments to the file
56 ((dataFile << p_args << "\t"), ...);
57
58 G4double weightedTotal = 0;
59 for (const auto &hit : hits)
60 {
61 dataFile << hit << "\t";
62 weightedTotal = hit;
63 }
64
65 hits = OMSimHitManager::getInstance().countMergedHits(); //unweighted
66 G4double totalHits = 0;
67 for (const auto &hit : hits)
68 {
69 totalHits = hit;
70 }
71
72 effectiveAreaResult effectiveArea = calculateEffectiveArea(weightedTotal, totalHits);
73 dataFile << effectiveArea.EA << "\t" << effectiveArea.EAError << "\t";
74 dataFile << G4endl;
75 dataFile.close();
76}
77
81template <typename... Args>
83{
84 std::fstream dataFile;
85 dataFile.open(m_outputFileName.c_str(), std::ios::out | std::ios::app);
86 dataFile << "# ";
87 ((dataFile << p_args << "\t"), ...);
88 dataFile << "hits[1perPMT]"
89 << "\t"
90 << "total_hits"
91 << "\t"
92 << "EA_Total(cm^2)"
93 << "\t"
94 << "EA_Total_error(cm^2)"
95 << "\t" << G4endl;
96 dataFile.close();
97}
Defines structures and classes related to optical module photon hit management.
Simulation of PMT response.
Responsible for calculating the effective area of optical hits and saving the results.
Definition OMSimEffectiveAreaAnalyisis.hh:29
effectiveAreaResult calculateEffectiveArea(double weightedTotal, double countTotal)
Calculates the effective area based on the number of hits and beam properties.
Definition OMSimEffectiveAreaAnalyisis.cc:14
void writeHeader(Args... p_args)
Writes the header line to the output file.
Definition OMSimEffectiveAreaAnalyisis.hh:82
void writeScan(Args... p_args)
Writes a scan result to the output file.
Definition OMSimEffectiveAreaAnalyisis.hh:48
std::vector< double > countMergedHits(int pModuleIndex=0, bool pDEweight=false)
Counts hits for a specified module.
Definition OMSimHitManager.cc:209
static OMSimHitManager & getInstance()
Definition OMSimHitManager.cc:44
Struct to hold results of effective area calculations.
Definition OMSimEffectiveAreaAnalyisis.hh:18
double EA
Effective area.
Definition OMSimEffectiveAreaAnalyisis.hh:19
double EAError
Uncertainty of effective area.
Definition OMSimEffectiveAreaAnalyisis.hh:20