Skip to content

Commit

Permalink
tidy: add new TH2Poly related fucniton and more authros
Browse files Browse the repository at this point in the history
  • Loading branch information
KSkwarczynski committed Jan 6, 2025
1 parent ad32cb9 commit 0598ee4
Show file tree
Hide file tree
Showing 14 changed files with 61 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = . Doc/mainpage.md manager splines samplePDF mcmc Diagnostics plotting plotting/plottingUtils Diagnostics/Diagnostics_utils covariance
INPUT = . Doc/mainpage.md manager splines samplePDF mcmc Diagnostics plotting plotting/plottingUtils Diagnostics/Diagnostics_utils covariance python

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
2 changes: 1 addition & 1 deletion cmake/Templates/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = . Doc/mainpage.md manager splines samplePDF mcmc Diagnostics plotting plotting/plottingUtils Diagnostics/Diagnostics_utils covariance
INPUT = . Doc/mainpage.md manager splines samplePDF mcmc Diagnostics plotting plotting/plottingUtils Diagnostics/Diagnostics_utils covariance python

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
3 changes: 3 additions & 0 deletions covariance/covarianceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ constexpr static const double _LARGE_LOGL_ = 1234567890.0;

/// @brief Base class responsible for handling of systematic error parameters. Capable of using PCA or using adaptive throw matrix
/// @see For more details, visit the [Wiki](https://github.com/mach3-software/MaCh3/wiki/02.-Implementation-of-Systematic).
/// @author Dan Barrow
/// @author Ed Atkin
/// @author Kamil Skwarczynski
class covarianceBase {
public:
/// @brief ETA - constructor for a YAML file
Expand Down
4 changes: 2 additions & 2 deletions covariance/covarianceOsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "covariance/covarianceBase.h"

/// @brief Class responsible for handling of neutrino oscillation parameters.
/// @author Richard Calland
/// @author Asher Kaboth
class covarianceOsc : public covarianceBase
{
public:
Expand All @@ -29,10 +31,8 @@ class covarianceOsc : public covarianceBase
void Print();

protected:

/// Do we flip DeltaM23 or not
bool flipdelM;

/// There is special treatment for delta CP, therefore store enum keeping track when to apply special treatment
int kDeltaCP;
/// There is special treatment for DeltaM23, therefore store enum keeping track when to apply special treatment
Expand Down
3 changes: 2 additions & 1 deletion manager/MaCh3Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#include <functional>
#include <string>

//KS: Based on this https://github.com/gabime/spdlog/blob/a2b4262090fd3f005c2315dcb5be2f0f1774a005/include/spdlog/spdlog.h#L284
/// @file MaCh3Logger.h
/// @brief KS: Based on this https://github.com/gabime/spdlog/blob/a2b4262090fd3f005c2315dcb5be2f0f1774a005/include/spdlog/spdlog.h#L284

#define MACH3LOG_TRACE SPDLOG_TRACE
#define MACH3LOG_DEBUG SPDLOG_DEBUG
Expand Down
1 change: 1 addition & 0 deletions manager/Monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

/// @file Monitor.h
/// @brief System and monitoring utilities for printing system information and status updates.
/// @author Kamil Skwarczynski

namespace MaCh3Utils {
/// @brief KS: Prints welcome message with MaCh3 logo
Expand Down
1 change: 1 addition & 0 deletions manager/YamlHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/// @file YamlHelper.h
/// @brief Utility functions for handling YAML nodes
/// @author Kamil Skwarczynski

// **********************
/// @brief Get content of config file if node is not found take default value specified
Expand Down
5 changes: 4 additions & 1 deletion python/pyMaCh3.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

/// @file pyMaCh3.cpp
/// @author Ewan Miller

namespace py = pybind11;

void initPlotting(py::module &); // <- defined in python/plotting.cpp
Expand All @@ -17,4 +20,4 @@ PYBIND11_MODULE( _pyMaCh3, m ) {
initManager(m);
initCovariance(m);
initSplines(m);
}
}
2 changes: 1 addition & 1 deletion python/splines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,4 @@ void initSplines(py::module &m){
.doc() = "This 'monolith' deals with event by event weighting using splines."

; // End of binding for EventSplineMonolith
}
}
24 changes: 23 additions & 1 deletion samplePDF/HistogramUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ TH1D* PolyProjectionX(TObject* poly, std::string TempName, const std::vector<dou
//WP: Helper function for projecting TH2Poly onto the Y axis
TH1D* PolyProjectionY(TObject* poly, std::string TempName, const std::vector<double>& ybins, const bool computeErrors) {
// **************************************************

TH1D* hProjY = new TH1D((TempName+"_y").c_str(),(TempName+"_y").c_str(),int(ybins.size()-1),&ybins[0]);
//KS: Temp Histogram to store error, use double as this is thread safe
std::vector<double> hProjY_Error(hProjY->GetXaxis()->GetNbins() + 1, 0.0);
Expand Down Expand Up @@ -327,6 +326,29 @@ double PolyIntegralWidth(TH2Poly *Histogram) {
return integral;
}

// *********************
TH2Poly* MakePolyHist(const std::string& name, const std::vector<double>& BinArray_x, const std::vector<double>& BinArray_y) {
// *********************
TH2Poly* poly = new TH2Poly();
poly->SetName(name.c_str());
poly->SetTitle(name.c_str());
double xmax, xmin, ymax, ymin;
for(unsigned int iy = 0; iy < BinArray_y.size()-1; iy++)
{
ymax = BinArray_y[iy+1];
ymin = BinArray_y[iy];
for(unsigned int ix = 0; ix < BinArray_x.size()-1; ix++)
{
xmax = BinArray_x[ix+1];
xmin = BinArray_x[ix];
double binofx[] = {xmin, xmax, xmax, xmin};
double binofy[] = {ymin, ymin, ymax, ymax};
poly->AddBin(4,binofx,binofy);
}
}
return poly;
}

// *********************
//KS: Remove fitted TF1 from hist to make comparison easier
void RemoveFitter(TH1D* hist, const std::string& name) {
Expand Down
9 changes: 9 additions & 0 deletions samplePDF/HistogramUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// MaCh3 inlcudes
#include "samplePDF/Structs.h"

/// @file HistogramUtils.h
/// @author Will Parker

/// @brief WP: Helper function for calculating unbinned Integral of TH2Poly i.e including overflow
double OverflowIntegral(TH2Poly* poly);

Expand All @@ -32,6 +35,12 @@ TH2Poly* PolyScaleWidth(TH2Poly *Histogram, double scale);
/// @brief WP: Helper to calc integral of th2poly analogous to th2d integra; with option "width"
double PolyIntegralWidth(TH2Poly *Histogram);

/// @brief WP: Helper function to create TH2Poly histogram with uniform binning
/// @param name This will be tittle of output histogram
/// @param BinArray_x Bin edges for X axis
/// @param BinArray_y Bin edges for Y axis
TH2Poly* MakePolyHist(const std::string& name, const std::vector<double>& BinArray_x, const std::vector<double>& BinArray_y);

/// @brief KS: ROOT changes something with binning when moving from ROOT 5 to ROOT 6. If you open ROOT5 produced file with ROOT6 you will be missing 9 last bins
/// @brief However if you use ROOT6 and have ROOT6 file exactly the same code will work. Something have changed with how TH2Poly bins are stored in TFile
/// @param file ROOT file that we will make version checks
Expand Down
9 changes: 9 additions & 0 deletions samplePDF/Structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ constexpr static const int Unity_Int = 1;
#include "Constants/OscillatorConstants.h"
#pragma GCC diagnostic pop


/// @file Structs.h
/// @author Asher Kaboth
/// @author Clarence Wret
/// @author Patrick Dunne
/// @author Dan Barrow
/// @author Ed Atkin
/// @author Kamil Skwarczynski

// *******************
/// @brief Template to make vector out of an array of any length
template< typename T, size_t N >
Expand Down
3 changes: 2 additions & 1 deletion splines/SplineCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
/// @details This file includes macros and enums for defining spline coefficients.
/// It is designed to be compatible with older CUDA versions, so be cautious
/// when adding new features or including other headers.
/// @author Clarence Wret
/// @author Kamil Skwarczynski

#ifndef _BAD_SPLINE_
#define _BAD_SPLINE_ 123456789
Expand All @@ -25,7 +27,6 @@ enum SplineSegmentCoeffs
kCoeffD = 3 ///< Coefficient D
};


// *******************
/// @brief KS: Struct storing information for spline monolith
/// @details This structure holds the X coefficients, other spline coefficients,
Expand Down
2 changes: 2 additions & 0 deletions splines/SplineStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/// @file SplineStructs.h
/// @brief Contains structures and helper functions for handling spline representations of systematic parameters in the MaCh3.
/// @author Clarence Wret
/// @author Kamil Skwarczynski

// *******************
/// @brief CW: Add a struct to hold info about the splinified xsec parameters and help with FindSplineSegment
Expand Down

0 comments on commit 0598ee4

Please sign in to comment.