OMSim
Geant4 for IceCube optical module studies
Loading...
Searching...
No Matches
OMSimTools.hh
Go to the documentation of this file.
1
6#pragma once
7
8#include "OMSimLogger.hh"
11#include <G4LogicalSkinSurface.hh>
12
13#include "globals.hh"
14#include <TGraph.h>
15#include <TH2D.h>
16#include <variant>
17#include <optional>
18
19#include <G4ThreeVector.hh>
20#include <G4RotationMatrix.hh>
21#include <G4LogicalVolume.hh>
22#include <CADMesh.hh>
23#include <G4MultiUnion.hh>
24
35namespace Tools
36{
37 std::vector<double> arange(double start, double stop, double step);
38 TGraph* create1dInterpolator(const std::vector<double>& pX, const std::vector<double>& pY, const std::string& pName);
39 TGraph* create1dInterpolator(const std::string& pFileName);
40 TH2D *create2DHistogramFromDataFile(const std::string &pFilePath);
41
42 void ensureDirectoryExists(const std::string &filepath);
43 std::pair<std::vector<double>, std::vector<double>> histogram(
44 const std::vector<double> &data,
45 const std::variant<int, std::vector<double>> &bins = 10,
46 const std::optional<std::pair<double, double>> &range = std::nullopt,
47 const std::vector<double> &weights = std::vector<double>());
48
49 G4String getThreadIDStr();
50 std::vector<std::vector<double>> loadtxt(const std::string &pFilePath,
51 bool pUnpack = true,
52 size_t pSkipRows = 0,
53 char pDelimiter = ' ',
54 char pComments = '#');
55 std::vector<double> linspace(double start, double end, int num_points, bool endpoint = true);
56 std::vector<double> logspace(double start, double end, int num_points, double base = 10.0, bool endpoint = true);
57 void sortVectorByReference(std::vector<G4double> &referenceVector, std::vector<G4double> &sortVector);
58 double median(std::vector<double> p_vec);
59 double mean(const std::vector<double> &p_vec, const std::vector<double> &p_weights = {});
60 double std(const std::vector<double>& vec, const std::vector<double> &p_weights = {});
61
62 void throwError(const G4String& message);
63 std::vector<G4String> splitStringByDelimiter(G4String const &p_string, char p_delim);
64 std::vector<G4String> splitStringByDelimiter(char *p_char, char p_delim);
65 extern std::string visualisationURL;
66
67 void AppendCADComponent(OMSimDetectorComponent* component,
68 const G4double scaleCAD,
69 const G4ThreeVector& offsetCAD,
70 const G4RotationMatrix& rotation,
71 const std::string& filename,
72 const std::string& componentname,
73 G4Material* material,
74 G4VisAttributes visAttributes,
75 G4OpticalSurface* opticalSurface = nullptr);
76};
77
Definition of the OMSimCommandArgsTable singleton class, which controls user args.
Provides helper base class OMSimDetectorComponent for constructing and managing detector components i...
Abstract base class used for constructing detector components.
Definition OMSimDetectorComponent.hh:26
A collection of helper functions for numerical operations.
std::vector< double > linspace(double start, double end, int num_points, bool endpoint=true)
Generates a linearly spaced vector.
Definition OMSimTools.cc:331
void sortVectorByReference(std::vector< G4double > &referenceVector, std::vector< G4double > &sortVector)
Sorts two vectors (p_sortVector & p_referenceVector) based on the order of values in p_referenceVecto...
Definition OMSimTools.cc:402
TGraph * create1dInterpolator(const std::vector< double > &pX, const std::vector< double > &pY, const std::string &pName)
Creates a TGraph interpolator from x and y data points.
Definition OMSimTools.cc:69
void ensureDirectoryExists(const std::string &filepath)
Ensure that the directory of a file to be created exists.
Definition OMSimTools.cc:452
std::pair< std::vector< double >, std::vector< double > > histogram(const std::vector< double > &data, const std::variant< int, std::vector< double > > &bins=10, const std::optional< std::pair< double, double > > &range=std::nullopt, const std::vector< double > &weights=std::vector< double >())
Compute the histogram of a dataset.
Definition OMSimTools.cc:162
TH2D * create2DHistogramFromDataFile(const std::string &pFilePath)
Create a histogram from provided data.
Definition OMSimTools.cc:102
std::vector< double > logspace(double start, double end, int num_points, double base=10.0, bool endpoint=true)
Generates a logarithmically spaced vector.
Definition OMSimTools.cc:365
G4String getThreadIDStr()
Definition OMSimTools.cc:440
std::vector< std::vector< double > > loadtxt(const std::string &pFilePath, bool pUnpack=true, size_t pSkipRows=0, char pDelimiter=' ', char pComments='#')
Reads numerical data from a file and returns it as a 2D vector. Similar to numpy.loadtxt.
Definition OMSimTools.cc:265
std::vector< double > arange(double start, double stop, double step)
Generates a sequence of numbers.
Definition OMSimTools.cc:23