Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rootless heplike #3

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
4399aee
Started Rootless Heplike
tegonzalo Sep 7, 2022
f6d280d
More progess on removing root
tegonzalo Oct 15, 2022
1f35a86
Clean up and removed some ROOT dependency
tegonzalo Oct 19, 2022
9c63a72
Complete derootified ProfLikelihood
tegonzalo Oct 19, 2022
a2f5773
Restored some Root functionality
tegonzalo Oct 19, 2022
1e73587
Finish derooting
tegonzalo Oct 20, 2022
4a91747
Cleanup and proper use of exceptions
tegonzalo Oct 20, 2022
c3c5eda
Some bugfixes
tegonzalo Oct 20, 2022
5de5da5
More bugfixes
tegonzalo Oct 20, 2022
80c22ca
More
tegonzalo Oct 20, 2022
4f5a43a
Remove warnings
tegonzalo Oct 20, 2022
5c5eefa
Changed to 1d arrays
tegonzalo Oct 20, 2022
9f990ef
Fixed interpolator bug
tegonzalo Oct 20, 2022
5fd5c6c
Improved gsl functions
tegonzalo Oct 21, 2022
07cf4f5
Removed more warnings
tegonzalo Oct 21, 2022
9ecffeb
Minor tweaks
tegonzalo Oct 21, 2022
b55bf62
Tried with non-gradient minimizers
tegonzalo Oct 21, 2022
93e49cb
Fixed minimizer
tegonzalo Oct 26, 2022
eef25e8
typo
tegonzalo Oct 26, 2022
280c84a
More typos and missing headers
tegonzalo Oct 26, 2022
8cf7e04
Removed warnings
tegonzalo Oct 26, 2022
6e653e8
Removed CMake warning
tegonzalo Oct 26, 2022
2f77b1b
Improved 2D interpolation
tegonzalo Oct 26, 2022
34b398a
Added build directory to gitignore
tegonzalo Oct 26, 2022
57d2c74
Fixed HL_nDimLikelihood to match 2D Root histograms
tegonzalo Dec 1, 2022
b830477
Fixed memory problems and profile likelihood
tegonzalo Dec 2, 2022
59fdaae
Extracted copied GAMBIT code to new files and added license disclaimer
tegonzalo Jan 9, 2023
1acaf48
Fixed missing headers
tegonzalo Jan 9, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.d

# Compiled Object files
build/
*.slo
*.lo
*.o
Expand Down Expand Up @@ -30,3 +31,6 @@
*.exe
*.out
*.app

# Hidden files
.*
69 changes: 37 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8.11)
cmake_minimum_required (VERSION 2.8.12)
project (HEPLike)
enable_testing()

Expand Down Expand Up @@ -34,25 +34,30 @@ if(COMPILER_SUPPORTS_CXX11)
endif()



###########################
#
# Packages search
#
###########################
# looking for yaml-cpp
find_package(Yaml-cpp)
# Use provided version of yaml-cpp
add_subdirectory(${PROJECT_SOURCE_DIR}/yaml-cpp EXCLUDE_FROM_ALL)
# looking for boost
find_package(Boost REQUIRED)
# GSL
find_package(GSL REQUIRED)
# ROOT:
find_package(ROOT REQUIRED COMPONENTS MathCore RIO Hist Tree Net)

include(${ROOT_USE_FILE})
include_directories(${CMAKE_SOURCE_DIR}/include ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
add_definitions(${ROOT_CXX_FLAGS})
include_directories(${CMAKE_SOURCE_DIR}/yaml-cpp/include)
include_directories(${CMAKE_SOURCE_DIR}/include ${Boost_INCLUDE_DIRS})

option(USE_ROOT "Compile with ROOT enabled" TRUE)
if(USE_ROOT)
# ROOT:
find_package(ROOT REQUIRED COMPONENTS MathCore RIO Hist Tree Net)

include(${ROOT_USE_FILE})
include_directories(${ROOT_INCLUDE_DIRS})
add_definitions(${ROOT_CXX_FLAGS})
endif()

###########################
#
Expand All @@ -63,23 +68,17 @@ if(NOT DEFINED EXECUTABLE)
set(EXECUTABLE FALSE)
endif()

if(NOT DEFINED USE_ROOT)
set(USE_ROOT TRUE)
endif()

# Configure the file
set(outhdr "${CMAKE_SOURCE_DIR}/include/cmake_variables.h")
configure_file("${CMAKE_SOURCE_DIR}/include/cmake_variables.h.in" ${outhdr})

###########################
#
# Libraries
#
###########################
if(USE_ROOT)

file(GLOB HL_SOURCES ${CMAKE_SOURCE_DIR}/src/*.cc)
else()
file(GLOB HL_SOURCES ${CMAKE_SOURCE_DIR}/src/HL_Stats.cc ${CMAKE_SOURCE_DIR}/src/HL_nDimGaussian.cc ${CMAKE_SOURCE_DIR}/src/HL_nDimBifurGaussian.cc ${CMAKE_SOURCE_DIR}/src/HL_Limit.cc ${CMAKE_SOURCE_DIR}/src/HL_Gaussian.cc ${CMAKE_SOURCE_DIR}/src/HL_Data.cc ${CMAKE_SOURCE_DIR}/src/HL_BifurGaussian.cc )

endif()
file(GLOB HL_SOURCES ${CMAKE_SOURCE_DIR}/src/*.cc)

add_library(HEPLike_static ${HL_SOURCES})
add_library(HEPLike_shared SHARED ${HL_SOURCES})
Expand All @@ -94,8 +93,8 @@ target_link_libraries(HEPLike_shared PRIVATE ${ROOT_LIBRARIES} ${Boost_LIBRARIES
#
###########################

if(EXECUTABLE AND USE_ROOT)
if(EXECUTABLE)

execute_process (
COMMAND bash -c "ln -s ../data_toy/ data"
)
Expand All @@ -110,15 +109,21 @@ if(EXECUTABLE AND USE_ROOT)
add_executable(Data_Fit_example main/Data_Fit_example.cc)
add_executable(Test_YAML main/Test_YAML.cc)

target_link_libraries(Br_example HEPLike_shared yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} )
target_link_libraries(BrBifurGaussian_example HEPLike_static yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES} )
target_link_libraries(Limit_example HEPLike_static yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
target_link_libraries(Ndim_Gaussian HEPLike_static yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
target_link_libraries(ProfLikelihood_example HEPLike_static yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
target_link_libraries(Ndim_BifurGaussian_example HEPLike_static yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
target_link_libraries(Ndim_Likelihood_example HEPLike_static yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
target_link_libraries(Data_Fit_example HEPLike_static yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
target_link_libraries(Test_YAML HEPLike_static yaml-cpp ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
if(USE_ROOT)
set(LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${GSL_LIBRARIES})
else()
set(LIBARRIES ${Boost_LIBRARIES} ${GSL_LIBRARIES})
endif()

target_link_libraries(Br_example HEPLike_shared yaml-cpp ${LIBRARIES} )
target_link_libraries(BrBifurGaussian_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Limit_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Ndim_Gaussian HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(ProfLikelihood_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Ndim_BifurGaussian_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Ndim_Likelihood_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Data_Fit_example HEPLike_static yaml-cpp ${LIBRARIES})
target_link_libraries(Test_YAML HEPLike_static yaml-cpp ${LIBRARIES})

add_test(HL_Test_YAML Test_YAML ../data_toy/examples/test_3dimassym.yaml)
add_test(HL_Limit Limit_example xterm)
Expand All @@ -127,7 +132,7 @@ if(EXECUTABLE AND USE_ROOT)
add_test(HL_Ndim_Gaussian Ndim_Gaussian)
add_test(HL_ProfLikelihood_example ProfLikelihood_example ${CMAKE_CURRENT_BINARY_DIR})
add_test(HL_Ndim_BifurGaussian_example Ndim_BifurGaussian_example)





endif()
31 changes: 31 additions & 0 deletions include/GAMBIT_Stats.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// HEPLike: High Energy Physics Likelihoods
//
// Module with statistic functions from GAMBIT
//
//////////////////////////////////////////////////

/* Copyright (c) 2017-2021, The GAMBIT Collaboration
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef GAMBIT_STATS_H
#define GAMBIT_STATS_H

namespace HL_Stats
{
double gaussian_loglikelihood(double theory, double obs, double theoryerr, double obserr, bool profile_systematics);
double gaussian_upper_limit(double theory, double obs, double theoryerr, double obserr, bool profile_systematics);

}

#endif
26 changes: 13 additions & 13 deletions include/HL_Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Header for baseic class
//
// author: Jihyun Bhom, Marcin Chrzaszcz
// author: Tomas Gonzalo
//////////////////////////////////////////////////
#ifndef HL_DATA_H
#define HL_DATA_H
Expand All @@ -26,54 +27,53 @@ class HL_Data

HL_Data();
HL_Data(std::string);

HL_Data(std::string,YAML::Node);

std::string HFile;
void Read();
std::string find_path(std::string);
void set_debug_yaml(bool);



protected:

YAML::Node config;

//HL_LIke info:
std::string HL_FileName;
std::string HL_Name;

// bibligraphic data:
std::string HL_DOI;
std::string HL_BibCite;
std::string HL_BibEntry;
std::string HL_Arxiv;
std::string HL_SubmissionYear;
std::string HL_PublicationYear;

// Collaborations numbers
std::string HL_Collaborations;
std::string HL_Collaboration_number;

// addition data
std::string HL_ExperimentalDataLumi; // 1fb for example
std::string HL_ExperimentalDataYears;
std::string HL_Decay;
std::string HL_Kinematics;


std::string HL_Author;
std::string HL_Email;
std::string HL_Type;





bool initialized;
bool HL_debug_yaml;

void read_standard();


};


Expand Down
35 changes: 11 additions & 24 deletions include/HL_ExpPoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@
//HEPLike headers
#include "HL_Stats.h"
#include "HL_Data.h"
#include "HL_Root.h"

//external:
#include "yaml-cpp/yaml.h"
#include "gsl/gsl_cdf.h"
#include "gsl/gsl_sf_erf.h"
#include "gsl/gsl_math.h"
#include "gsl/gsl_sf_exp.h"
#include "TFile.h"
#include "TTree.h"
#include "TGraph.h"
#include "TAxis.h"
#include "TMath.h"
#include "TH1D.h"
#include "TBranch.h"


class HL_ExpPoints: public HL_Data
{
Expand All @@ -39,47 +34,39 @@ class HL_ExpPoints: public HL_Data

explicit HL_ExpPoints() : HL_Data() {};
explicit HL_ExpPoints(std::string s) : HL_Data(s) { };


void Read();
double GetChi2(vector<double> theory);
double GetLogLikelihood(vector<double> theory);
double GetLikelihood(vector<double> theory);
bool InitData();
void SetFun( double FUN( vector<double>, vector<double>));


private:

TTree *HL_tree;
double xmin;
double xmax;
double central_mes_val;
std::string ObsName;
std::string ObsName;

std::string HL_RootFile;
std::string HL_PATH;
std::string HL_weight;
vector<std::string> HL_obs;
vector<TBranch*> HL_Branches;
TBranch *HL_weight_branch;


TFile *f;

double (*fun)(vector<double>, vector<double>);

vector<vector<double>> points;
vector<double> weights;




TFile *f;

double (*fun)(vector<double>, vector<double>);

vector<vector<double>> points;
vector<double> weights;



};


Expand Down
Loading