Initial Upload

This commit is contained in:
Markus Köhli 2022-05-22 20:51:04 +02:00
parent d0f1ecc218
commit 666907ae0c
5 changed files with 5553 additions and 0 deletions

2805
Toolkit.cpp Normal file

File diff suppressed because it is too large Load Diff

221
Toolkit.h Normal file
View File

@ -0,0 +1,221 @@
#include "TGraph2D.h"
#include "TGraph2DErrors.h"
#include "TGraphErrors.h"
#include "TGraph.h"
#include "TMultiGraph.h"
#include "TGaxis.h"
#include "TStyle.h"
#include "TROOT.h"
#include <iostream>
#include <Riostream.h>
#include "TFile.h"
#include "TText.h"
//#include "TTree.h"
#include "THStack.h"
#include "TH1.h"
#include "TH2.h"
#include "TH3.h"
#include "TF1.h"
#include "TF2.h"
#include "TProfile.h"
#include "Fit/FitResult.h"
#include "TFitResultPtr.h"
#include "TFitResult.h"
#include "TCanvas.h"
#include "TPad.h"
//#include "TVirtualPad.h"
//#include "TVirtualFitter.h"
#include "TNamed.h"
#include "TMath.h"
#include "TMatrix.h"
#include "TVectorT.h"
#include "TMatrixF.h"
#include "TMatrixD.h"
#include "TMatrixT.h"
#include "TMatrixTSym.h"
#include "TPaveStats.h"
#include "TString.h"
#include "TLatex.h"
#include "TColor.h"
#include <string>
#include "RConfig.h"
#include "Rtypes.h"
#include "TLegend.h"
#include "TSpline.h"
#include "TObject.h"
#include <strstream>
#include <sstream>
//#include <vector>
#include <float.h>
#include <TCHAR.h>
#include <malloc.h>
#include <QImage>
#include "TRandom3.h"
using namespace std;
string castDoubleToString(double number);
string castDoubleToString(double number, Int_t intacters);
string castFloatToString(Float_t number);
string castFloatToString(Float_t number, Int_t intacters);
string castIntToString(Int_t &number);
string castLongToString(Long_t &number);
Double_t lorentzianPeak(Double_t* x, Double_t* par);
Double_t gaussoffset(Double_t* x, Double_t* par);
Double_t errf( Double_t *x, Double_t *par);
void rootlogon();
vector<float> getRGBfromHCL(double h, double c0, double l0);
float getLinearC(double factor, double cmin, double cmax);
float getScaledColorValue(double factor, double pow, double cmin, double cmax);
void set_plot_styleSingleGradient(float h, Double_t a0, Double_t a1, Double_t a2, Double_t a3, Double_t a4);
void set_plot_styleHeatGradient(Double_t a0, Double_t a1, Double_t a2, Double_t a3, Double_t a4);
void set_plot_styleRainbowGradient(Double_t a0, Double_t a1, Double_t a2, Double_t a3, Double_t a4);
void set_plot_styleAllGradient(Double_t a0, Double_t a1, Double_t a2, Double_t a3, Double_t a4);
void set_plot_styleHeatGradientModified(Double_t a0, Double_t a1, Double_t a2, Double_t a3, Double_t a4);
void set_plot_styleHeatGradient2(Double_t a0, Double_t a1, Double_t a2, Double_t a3, Double_t a4);
void set_plot_style(Double_t a0, Double_t a1, Double_t a2, Double_t a3, Double_t a4);
int getScaledColor(float min, float max, float scale, int mode);
vector<float> getScaledColorRGB(float min, float max, float scale, int mode);
void set_plot_styleCool();
void CanvasFashion(TCanvas* c);
void TGraphFashion(TGraph* graph, TString xLabel, TString yLabel, Bool_t setSize);
void TGraphErrorFashion(TGraphErrors* graph, TString xLabel, TString yLabel, Bool_t setSize);
void TGraph2DFashion(TGraph2D* graph, TString xLabel, TString yLabel, TString zLabel, Bool_t setSize);
void TMultiGraphFashion(TMultiGraph* graph, TString xLabel, TString yLabel, Bool_t setSize);
void TF1Fashion(TF1* hist, TString xLabel, TString yLabel, Bool_t setSize);
void TH1Fashion(TH1* hist, TString xLabel, TString yLabel, Bool_t setSize);
void TProfileFashion(TProfile* hist, TString xLabel, TString yLabel, Bool_t setSize);
void TH2Fashion(TH2* hist, Bool_t setSize);
void TH2Fashion(TH2* hist, TString xLabel, TString yLabel, Bool_t setSize);
void THStackFashion(THStack* stack, TString xLabel, TString yLabel, Bool_t setSize);
TH2F* printHisto(Double_t zmin, Double_t zmax, Int_t size, TMatrixF data, TString OutputFolder, TString dataname, Bool_t logPlot);
void printTH1F(Double_t zmin, Double_t zmax, TH1F* histo, TString OutputFolder, TString dataname);
void printTH2F(Double_t zmin, Double_t zmax, TH2F* histo, TString OutputFolder, TString dataname);
void storeTH2ToFile(TString OutputFolder, TString filename, TH2F* th2);
void storeToFile(TString OutputFolder, TString filename, TString what_has_to_be_written, bool new_line);
void embedFonts(TString path);
void storeTH1ToFile(TString OutputFolder, TString filename,TH1* histo);
TMatrixF readMatrixPNG(TString folder, TString filename);
TMatrixF readmatrix(TString folder, TString filename, TString filetype, Int_t counter, Int_t size);
Int_t countFiles(TString folder, TString filename, TString filetype);
//void deleteStatsTH(vector<TH1*> *allTHs);
unsigned int heXheX(const TCHAR *value);
const std::string intToHex( int i);
void extrapolateZeroValues(TMatrixF &matrix);
TMatrixF reduceMatrix(TMatrixF &matrix, Float_t factor);
TMatrixF getGradientMatrix(TMatrixF &matrix);
void getGradientMatrixFromTH2(TH2F* matrix, TH2F* newMatrix);
TH2F* getTH2fromMatrix(TMatrixF &matrix, TString thName, TString thTitle);
TH1F* convoluteGaussian(TH1F* hist, Double_t gaussRelW);
int countEventsInEllipse(TH2F* histo, double radiusX, double x, double radiusY, double y);
void histoClearUp(vector<TObject*>* vectorTH);
double getWWProb(double density, double atWeight, double cs, double lambda);
double getLfromE(double energy);
double getEfromL(double lambda);
TSpline3* getSplinedDetectorEnergyModel();
int getNumberOfFileEntries(TString dname);
inline double legendre_Pl(int n, double x);
void logXaxis(TH2* h);
void rebinX(TH1* h);
void logaxis(TH1* h);
void logXaxis(TH2* h);
void logYaxis(TH2* h);
double getRLuftWasser(float temperature);
double calcNeutronDiffTime(double z0, double z0Alt, double energy, double cosTheta);
double getEvaporationEnergy(double theta, TRandom* r);
double getModeratedCfEnergy(TRandom* r);
double getFissionEnergy(TRandom* r);
double getFissionEnergy2(TRandom* r);
vector<float> getThermalPDF(const double nEnergy, const float massElm, const float temperature, TRandom* r);
double getThermalEnergyLog(const TF1* spectrumFunc, TRandom* r);
double getThermalEnergy(TF1* spectrumFunc, TRandom* r);
double getThermalEnergyFromSource(const TF1* spectrumFunc, TRandom* r);
double scalarProduct(double rx1, double ry1, double rz1, double rx2, double ry2, double rz2);
double intersectCylinderMantle(double stVx, double stVy, double stVz, double theta, double phi, double px, double py, double pz, double dRad);
double intersectSphere(double stVx, double stVy, double stVz, double theta, double phi, double px, double py, double pz, double dRad);
double calcCylindricalHitDist2(double stVx, double stVy, double stVz, double theta, double phi, double px, double py, double pz, double dRad, double xRef, double yRef);
double calcCylindricalHitDist(double stVx, double stVy, double stVz, double theta, double phi, double px, double py, double pz, double dRad, double xRef, double yRef);
double intersectCylinder(double stVx, double stVy, double stVz, double theta, double phi, double px, double py, double pz, double dRad);
double getDistanceToLine(double stVx, double stVy, double stVz, double theta, double phi, double px, double py, double pz);
double getDistanceToPoint(double stVx, double stVy, double stVz, double theta, double phi, double px, double py, double pz);
double getDistanceToPointOLD(double stVx, double stVy, double stVz, double theta, double phi, double px, double py, double pz);
Double_t legendrian(double* x, Double_t* par);
Double_t legendrian10fold(double* x, Double_t* par);
string legendrian10folded(Float_t* par);
static int ArraySize(double array[]);
static double legendrianNfold(double* x, Double_t* par);
float endfNumberConv(string str);
float getIndexHorizontalPosition(const TMatrixF& matrix, int line, double value, bool doLogSearch);
float getIndexPosition(const TMatrixF& matrix, double value, bool doLogSearch);
double calcMeanCS(const TMatrixF& matrix, double energy);
double getHighEnergyCosTheta(const TMatrixF& angleMatrix, const TMatrixF& cumulatedProbMatrix, double energy, double prob);
double getAngleFromCumulativeFunction(const TF1* spectrumFunc, float min, float max, TRandom* r);
TF1* calcMeanAngularDistribution(const TMatrixF& matrix, double energy);
void turnInputMatrix(TMatrixF& inputMatrix);
int changeInputMatrixValue(int value);

82
ui_dialogshowpic.h Normal file
View File

@ -0,0 +1,82 @@
/********************************************************************************
** Form generated from reading UI file 'dialogshowpic.ui'
**
** Created by: Qt User Interface Compiler version 5.15.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_DIALOGSHOWPIC_H
#define UI_DIALOGSHOWPIC_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDialog>
#include <QtWidgets/QDialogButtonBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QPushButton>
#include "qcustomplot.h"
QT_BEGIN_NAMESPACE
class Ui_DialogShowPic
{
public:
QDialogButtonBox *buttonBox;
QCustomPlot *widget;
QPushButton *pushButtonPlus;
QPushButton *pushButtonMinus;
QLabel *labelNo;
QLabel *label;
void setupUi(QDialog *DialogShowPic)
{
if (DialogShowPic->objectName().isEmpty())
DialogShowPic->setObjectName(QString::fromUtf8("DialogShowPic"));
DialogShowPic->resize(627, 590);
buttonBox = new QDialogButtonBox(DialogShowPic);
buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
buttonBox->setGeometry(QRect(430, 550, 171, 32));
buttonBox->setOrientation(Qt::Horizontal);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
widget = new QCustomPlot(DialogShowPic);
widget->setObjectName(QString::fromUtf8("widget"));
widget->setGeometry(QRect(20, 20, 591, 521));
pushButtonPlus = new QPushButton(DialogShowPic);
pushButtonPlus->setObjectName(QString::fromUtf8("pushButtonPlus"));
pushButtonPlus->setGeometry(QRect(60, 555, 31, 23));
pushButtonMinus = new QPushButton(DialogShowPic);
pushButtonMinus->setObjectName(QString::fromUtf8("pushButtonMinus"));
pushButtonMinus->setGeometry(QRect(20, 555, 31, 23));
labelNo = new QLabel(DialogShowPic);
labelNo->setObjectName(QString::fromUtf8("labelNo"));
labelNo->setGeometry(QRect(163, 559, 46, 13));
label = new QLabel(DialogShowPic);
label->setObjectName(QString::fromUtf8("label"));
label->setGeometry(QRect(107, 557, 51, 16));
retranslateUi(DialogShowPic);
QObject::connect(buttonBox, SIGNAL(accepted()), DialogShowPic, SLOT(accept()));
QObject::connect(buttonBox, SIGNAL(rejected()), DialogShowPic, SLOT(reject()));
QMetaObject::connectSlotsByName(DialogShowPic);
} // setupUi
void retranslateUi(QDialog *DialogShowPic)
{
DialogShowPic->setWindowTitle(QCoreApplication::translate("DialogShowPic", "Input Matrix View", nullptr));
pushButtonPlus->setText(QCoreApplication::translate("DialogShowPic", "+", nullptr));
pushButtonMinus->setText(QCoreApplication::translate("DialogShowPic", "-", nullptr));
labelNo->setText(QCoreApplication::translate("DialogShowPic", "-", nullptr));
label->setText(QCoreApplication::translate("DialogShowPic", "Layer #:", nullptr));
} // retranslateUi
};
namespace Ui {
class DialogShowPic: public Ui_DialogShowPic {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_DIALOGSHOWPIC_H

2385
ui_mainwindow.h Normal file

File diff suppressed because it is too large Load Diff

60
ui_visualizationenlarge.h Normal file
View File

@ -0,0 +1,60 @@
/********************************************************************************
** Form generated from reading UI file 'visualizationenlarge.ui'
**
** Created by: Qt User Interface Compiler version 5.15.2
**
** WARNING! All changes made in this file will be lost when recompiling UI file!
********************************************************************************/
#ifndef UI_VISUALIZATIONENLARGE_H
#define UI_VISUALIZATIONENLARGE_H
#include <QtCore/QVariant>
#include <QtWidgets/QApplication>
#include <QtWidgets/QDialog>
#include <QtWidgets/QPushButton>
#include "qcustomplot.h"
QT_BEGIN_NAMESPACE
class Ui_VisualizationEnlarge
{
public:
QCustomPlot *customPlot;
QPushButton *pushButtonPNG;
void setupUi(QDialog *VisualizationEnlarge)
{
if (VisualizationEnlarge->objectName().isEmpty())
VisualizationEnlarge->setObjectName(QString::fromUtf8("VisualizationEnlarge"));
VisualizationEnlarge->resize(1212, 1052);
VisualizationEnlarge->setMaximumSize(QSize(1250, 1052));
customPlot = new QCustomPlot(VisualizationEnlarge);
customPlot->setObjectName(QString::fromUtf8("customPlot"));
customPlot->setGeometry(QRect(0, 0, 1211, 1052));
customPlot->setMaximumSize(QSize(1250, 1052));
pushButtonPNG = new QPushButton(customPlot);
pushButtonPNG->setObjectName(QString::fromUtf8("pushButtonPNG"));
pushButtonPNG->setGeometry(QRect(1140, 10, 61, 41));
retranslateUi(VisualizationEnlarge);
QMetaObject::connectSlotsByName(VisualizationEnlarge);
} // setupUi
void retranslateUi(QDialog *VisualizationEnlarge)
{
VisualizationEnlarge->setWindowTitle(QCoreApplication::translate("VisualizationEnlarge", "Enlarged Visualization", nullptr));
pushButtonPNG->setText(QCoreApplication::translate("VisualizationEnlarge", "URANOS\n"
"Export", nullptr));
} // retranslateUi
};
namespace Ui {
class VisualizationEnlarge: public Ui_VisualizationEnlarge {};
} // namespace Ui
QT_END_NAMESPACE
#endif // UI_VISUALIZATIONENLARGE_H