From dae9dbf5e7657bd1506f164817c2427a27f366c3 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 13 Jun 2025 19:19:46 +0200 Subject: [PATCH 01/12] runMassFitter: add main() function and missing header --- PWGHF/D2H/Macros/runMassFitter.C | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/PWGHF/D2H/Macros/runMassFitter.C b/PWGHF/D2H/Macros/runMassFitter.C index 637171248cc..7a1f6f02366 100644 --- a/PWGHF/D2H/Macros/runMassFitter.C +++ b/PWGHF/D2H/Macros/runMassFitter.C @@ -22,6 +22,11 @@ #include "HFInvMassFitter.h" // if .h file not found, please include your local rapidjson/document.h and rapidjson/filereadstream.h here +#include +#include +#include +#include + #include #include @@ -30,10 +35,6 @@ #include // std::string #include // std::vector -#include -#include -#include - #endif using namespace rapidjson; @@ -672,3 +673,16 @@ void divideCanvas(TCanvas* canvas, int nSliceVarBins) } } } + +int main(int argc, char* argv[]) +{ + if (argc < 2) { + throw std::runtime_error("Not enough arguments. Please use\n./runMassFitter configFileName"); + } + + const std::string configFileName = argv[1]; + + runMassFitter(configFileName); + + return 0; +} From 17c685167f2fcc5045f649d5231afa5626b171a5 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 13 Jun 2025 19:26:50 +0200 Subject: [PATCH 02/12] linter fix: avoid magic number --- PWGHF/D2H/Macros/runMassFitter.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/D2H/Macros/runMassFitter.C b/PWGHF/D2H/Macros/runMassFitter.C index 7a1f6f02366..1ca56a0468d 100644 --- a/PWGHF/D2H/Macros/runMassFitter.C +++ b/PWGHF/D2H/Macros/runMassFitter.C @@ -676,7 +676,7 @@ void divideCanvas(TCanvas* canvas, int nSliceVarBins) int main(int argc, char* argv[]) { - if (argc < 2) { + if (argc == 1) { throw std::runtime_error("Not enough arguments. Please use\n./runMassFitter configFileName"); } From 7b168866dec8cb42fcac58149408965ffb66bef0 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Tue, 17 Jun 2025 11:09:14 +0200 Subject: [PATCH 03/12] provide CMakeLists for HFInvMassFitter --- PWGHF/D2H/Macros/CMakeLists.txt | 23 +++++++++++++++++++++++ PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 PWGHF/D2H/Macros/CMakeLists.txt create mode 100644 PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h diff --git a/PWGHF/D2H/Macros/CMakeLists.txt b/PWGHF/D2H/Macros/CMakeLists.txt new file mode 100644 index 00000000000..5a74cec1768 --- /dev/null +++ b/PWGHF/D2H/Macros/CMakeLists.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.10) + +project(HFInvMassFitter) + +set(HFFITTER_RAPIDJSON_INCLUDE_DIRS "" CACHE STRING "Location of rapidjson include directories") + +find_package(ROOT REQUIRED COMPONENTS RooFit RooFitCore) + +include_directories(${ROOT_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR} ${HFFITTER_RAPIDJSON_INCLUDE_DIRS}) + +set(SOURCES + HFInvMassFitter.cxx + runMassFitter.C +) + +add_executable(runMassFitter ${SOURCES} "HFInvMassFitter.h") + +ROOT_GENERATE_DICTIONARY(G__HFInvMassFitter + HFInvMassFitter.h LINKDEF HFInvMassFitterLinkDef.h + MODULE runMassFitter +) + +target_link_libraries(runMassFitter PRIVATE ${ROOT_LIBRARIES} ROOT::EG ROOT::RooFit ROOT::RooFitCore) diff --git a/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h b/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h new file mode 100644 index 00000000000..2ae7a0f13fe --- /dev/null +++ b/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h @@ -0,0 +1,22 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +#ifndef PWGHF_D2H_MACROS_HFINVMASSFITTERLINKDEF_H_ +#define PWGHF_D2H_MACROS_HFINVMASSFITTERLINKDEF_H_ + +#ifdef __CINT__ +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; +#pragma link C++ class HFInvMassFitter + ; +#endif + +#endif // PWGHF_D2H_MACROS_HFINVMASSFITTERLINKDEF_H_ From 5a48d6d9d9e813503843faa1b4cfff0daaafc0b1 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Tue, 17 Jun 2025 11:31:07 +0200 Subject: [PATCH 04/12] init README - describe compilation from the command line --- PWGHF/D2H/Macros/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 PWGHF/D2H/Macros/README.md diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md new file mode 100644 index 00000000000..67822c98be5 --- /dev/null +++ b/PWGHF/D2H/Macros/README.md @@ -0,0 +1,9 @@ + +Step 1: Generate ROOT dictionary: +rootcling -f G__HFInvMassFitter.cxx -c ../HFInvMassFitter.h ../HFInvMassFitterLinkDef.h + +Step 2: Compile source code: +g++ -fPIC -I$(root-config --incdir) -I path-to-json-include -c ../HFInvMassFitter.cxx ../runMassFitter.C G__HFInvMassFitter.cxx + +Step 3: Link the executable: +g++ -o runMassFitter HFInvMassFitter.o runMassFitter.o G__HFInvMassFitter.o $(root-config --libs) -lRooFit -lRooFitCore -lEG From d8be2d6cc7aaeeb15f3666d9a34fca09acce9614 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Wed, 18 Jun 2025 13:56:25 +0200 Subject: [PATCH 05/12] describe compilation as Root macro --- PWGHF/D2H/Macros/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md index 67822c98be5..a0ad4733108 100644 --- a/PWGHF/D2H/Macros/README.md +++ b/PWGHF/D2H/Macros/README.md @@ -1,3 +1,7 @@ +export ROOT_INCLUDE_PATH=path-to-json-include // if not in O2Physics environment + +root -l -x -b -q "HFInvMassFitter.cxx" "runMassFitter.C(\"config_massfitter.json\")" + Step 1: Generate ROOT dictionary: rootcling -f G__HFInvMassFitter.cxx -c ../HFInvMassFitter.h ../HFInvMassFitterLinkDef.h From 1327d91a7b45296ed68516ece87362a3e155fb3c Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 20 Jun 2025 13:04:59 +0200 Subject: [PATCH 06/12] write compilation instruction in Readme; rename CMakeLists.txt --- ...sts.txt => CMakeLists_HFInvMassFitter.txt} | 0 PWGHF/D2H/Macros/README.md | 50 +++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) rename PWGHF/D2H/Macros/{CMakeLists.txt => CMakeLists_HFInvMassFitter.txt} (100%) diff --git a/PWGHF/D2H/Macros/CMakeLists.txt b/PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.txt similarity index 100% rename from PWGHF/D2H/Macros/CMakeLists.txt rename to PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.txt diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md index a0ad4733108..88efb6fb570 100644 --- a/PWGHF/D2H/Macros/README.md +++ b/PWGHF/D2H/Macros/README.md @@ -1,13 +1,55 @@ -export ROOT_INCLUDE_PATH=path-to-json-include // if not in O2Physics environment +# Invariant mass fitter +Invariant mass fitter is implemented in the class `HFInvMassFitter` (`HFInvMassFitter.cxx/h` files), and its run is executed via `runMassFitter.C` macro. +Fitter is configured in `config_massfitter.json`.\ +The fitter is **not** a part of O2Physics source code. +## Dependencies +1. ROOT + +2. RapidJSON. Download the header-only (no compilation needed) RapidJSON library, see the link https://rapidjson.org. + +## How to run +### As a ROOT macro +The `runMassFitter.C` can be compiled as ROOT macro. +``` +source path-to-root-install/bin/thisroot.sh +export ROOT_INCLUDE_PATH=$ROOT_INCLUDE_PATH:path-to-json-include root -l -x -b -q "HFInvMassFitter.cxx" "runMassFitter.C(\"config_massfitter.json\")" +``` +If you have O2Physics compilation and enter into its environment there is no need to set environment variables (skip first two lines above). +### As a CMake project +It is also possible to compile the fitter as a CMake project or insert it into existing one if any. +Use the `CMakeLists_HFInvMassFitter.txt` (rename it into `CMakeLists.txt` before usage).\ +Compile the fitter with the following steps: +``` +mkdir build +cd build +source path-to-root-install/bin/thisroot.sh +cmake -DHFFITTER_RAPIDJSON_INCLUDE_DIRS=path-to-json-include .. +make +``` +and run the fitter: +``` +./runMassFitter ../config_massfitter.json +``` +### Directly from the terminal +Compile the fitter with the following steps: +``` +mkdir build +cd build +source path-to-root-install/bin/thisroot.sh -Step 1: Generate ROOT dictionary: +# Generate ROOT dictionary: rootcling -f G__HFInvMassFitter.cxx -c ../HFInvMassFitter.h ../HFInvMassFitterLinkDef.h -Step 2: Compile source code: +# Compile source code: g++ -fPIC -I$(root-config --incdir) -I path-to-json-include -c ../HFInvMassFitter.cxx ../runMassFitter.C G__HFInvMassFitter.cxx -Step 3: Link the executable: +# Link the executable: g++ -o runMassFitter HFInvMassFitter.o runMassFitter.o G__HFInvMassFitter.o $(root-config --libs) -lRooFit -lRooFitCore -lEG +``` +and run the fitter: +``` +./runMassFitter ../config_massfitter.json +``` From 0c92c7b18a755158e0d38081944782da36d6417a Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 20 Jun 2025 13:10:24 +0200 Subject: [PATCH 07/12] update author list; clang-format --- PWGHF/D2H/Macros/HFInvMassFitter.cxx | 7 ++++--- PWGHF/D2H/Macros/HFInvMassFitter.h | 7 ++++--- PWGHF/D2H/Macros/runMassFitter.C | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/PWGHF/D2H/Macros/HFInvMassFitter.cxx b/PWGHF/D2H/Macros/HFInvMassFitter.cxx index 255de80a079..ba14190be6a 100644 --- a/PWGHF/D2H/Macros/HFInvMassFitter.cxx +++ b/PWGHF/D2H/Macros/HFInvMassFitter.cxx @@ -16,6 +16,7 @@ /// \author Mingyu Zhang /// \author Xinye Peng /// \author Biao Zhang +/// \author Oleksii Lubynets #include "HFInvMassFitter.h" @@ -33,9 +34,6 @@ #include #include #include - -#include -#include #include #include #include @@ -45,6 +43,9 @@ #include #include +#include +#include + #include #include #include diff --git a/PWGHF/D2H/Macros/HFInvMassFitter.h b/PWGHF/D2H/Macros/HFInvMassFitter.h index 8a236412a13..521b83bd465 100644 --- a/PWGHF/D2H/Macros/HFInvMassFitter.h +++ b/PWGHF/D2H/Macros/HFInvMassFitter.h @@ -16,6 +16,7 @@ /// \author Mingyu Zhang /// \author Xinye Peng /// \author Biao Zhang +/// \author Oleksii Lubynets #ifndef PWGHF_D2H_MACROS_HFINVMASSFITTER_H_ #define PWGHF_D2H_MACROS_HFINVMASSFITTER_H_ @@ -23,14 +24,14 @@ #include #include #include -#include -#include - #include #include #include #include +#include +#include + #include class HFInvMassFitter : public TNamed diff --git a/PWGHF/D2H/Macros/runMassFitter.C b/PWGHF/D2H/Macros/runMassFitter.C index 1ca56a0468d..1181c13b814 100644 --- a/PWGHF/D2H/Macros/runMassFitter.C +++ b/PWGHF/D2H/Macros/runMassFitter.C @@ -16,6 +16,7 @@ /// \author Mingyu Zhang /// \author Xinye Peng /// \author Biao Zhang +/// \author Oleksii Lubynets #if !defined(__CINT__) || defined(__CLING__) From 6ee04fffa7f0f902e8478c5c7c322316f55bf43a Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Fri, 20 Jun 2025 11:15:28 +0000 Subject: [PATCH 08/12] MegaLinter fixes --- PWGHF/D2H/Macros/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md index 88efb6fb570..1f2d0501616 100644 --- a/PWGHF/D2H/Macros/README.md +++ b/PWGHF/D2H/Macros/README.md @@ -6,7 +6,7 @@ The fitter is **not** a part of O2Physics source code. ## Dependencies 1. ROOT -2. RapidJSON. Download the header-only (no compilation needed) RapidJSON library, see the link https://rapidjson.org. +2. RapidJSON. Download the header-only (no compilation needed) RapidJSON library, see the link . ## How to run ### As a ROOT macro From 074758faf5129534f30085f4307389c4ac59e11f Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Fri, 20 Jun 2025 13:24:09 +0200 Subject: [PATCH 09/12] address O2 linter error --- PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h b/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h index 2ae7a0f13fe..cc755de478f 100644 --- a/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h +++ b/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h @@ -9,6 +9,15 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. +/// \file HFInvMassFitterLinkDef.h +/// \brief HFInvMassFitter dictionary definition file +/// +/// \author Zhen Zhang +/// \author Mingyu Zhang +/// \author Xinye Peng +/// \author Biao Zhang +/// \author Oleksii Lubynets + #ifndef PWGHF_D2H_MACROS_HFINVMASSFITTERLINKDEF_H_ #define PWGHF_D2H_MACROS_HFINVMASSFITTERLINKDEF_H_ From 9041445c0074d9686daa7077ee616ac0e38baccc Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Sat, 21 Jun 2025 07:49:08 +0200 Subject: [PATCH 10/12] clarify paths in readme --- PWGHF/D2H/Macros/README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md index 1f2d0501616..a43696c94cf 100644 --- a/PWGHF/D2H/Macros/README.md +++ b/PWGHF/D2H/Macros/README.md @@ -5,28 +5,31 @@ The fitter is **not** a part of O2Physics source code. ## Dependencies 1. ROOT - 2. RapidJSON. Download the header-only (no compilation needed) RapidJSON library, see the link . +If you have O2Physics compilation you do not need to fulfill these dependencies explicitly. + ## How to run ### As a ROOT macro The `runMassFitter.C` can be compiled as ROOT macro. ``` +cd path-to-o2physics-src/PWGHF/D2H/Macros source path-to-root-install/bin/thisroot.sh export ROOT_INCLUDE_PATH=$ROOT_INCLUDE_PATH:path-to-json-include root -l -x -b -q "HFInvMassFitter.cxx" "runMassFitter.C(\"config_massfitter.json\")" ``` -If you have O2Physics compilation and enter into its environment there is no need to set environment variables (skip first two lines above). +If you have O2Physics compilation and enter into its environment there is no need to set environment variables (skip lines 2-3 above). ### As a CMake project It is also possible to compile the fitter as a CMake project or insert it into existing one if any. Use the `CMakeLists_HFInvMassFitter.txt` (rename it into `CMakeLists.txt` before usage).\ Compile the fitter with the following steps: ``` +cd path-to-o2physics-src/PWGHF/D2H/Macros mkdir build cd build source path-to-root-install/bin/thisroot.sh -cmake -DHFFITTER_RAPIDJSON_INCLUDE_DIRS=path-to-json-include .. +cmake -DHFFITTER_RAPIDJSON_INCLUDE_DIRS=path-to-json-include ../ make ``` and run the fitter: @@ -36,6 +39,7 @@ and run the fitter: ### Directly from the terminal Compile the fitter with the following steps: ``` +cd path-to-o2physics-src/PWGHF/D2H/Macros mkdir build cd build source path-to-root-install/bin/thisroot.sh From 4ea2b03ce4b194446cd3195bc4f8178126ec0a71 Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Tue, 24 Jun 2025 23:59:02 +0200 Subject: [PATCH 11/12] add language specification for bash commands in ReadMe --- PWGHF/D2H/Macros/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md index a43696c94cf..799ef8bac90 100644 --- a/PWGHF/D2H/Macros/README.md +++ b/PWGHF/D2H/Macros/README.md @@ -12,7 +12,7 @@ If you have O2Physics compilation you do not need to fulfill these dependencies ## How to run ### As a ROOT macro The `runMassFitter.C` can be compiled as ROOT macro. -``` +```bash cd path-to-o2physics-src/PWGHF/D2H/Macros source path-to-root-install/bin/thisroot.sh export ROOT_INCLUDE_PATH=$ROOT_INCLUDE_PATH:path-to-json-include @@ -24,7 +24,7 @@ If you have O2Physics compilation and enter into its environment there is no nee It is also possible to compile the fitter as a CMake project or insert it into existing one if any. Use the `CMakeLists_HFInvMassFitter.txt` (rename it into `CMakeLists.txt` before usage).\ Compile the fitter with the following steps: -``` +```bash cd path-to-o2physics-src/PWGHF/D2H/Macros mkdir build cd build @@ -33,12 +33,12 @@ cmake -DHFFITTER_RAPIDJSON_INCLUDE_DIRS=path-to-json-include ../ make ``` and run the fitter: -``` +```bash ./runMassFitter ../config_massfitter.json ``` ### Directly from the terminal Compile the fitter with the following steps: -``` +```bash cd path-to-o2physics-src/PWGHF/D2H/Macros mkdir build cd build @@ -54,6 +54,6 @@ g++ -fPIC -I$(root-config --incdir) -I path-to-json-include -c ../HFInvMassFitte g++ -o runMassFitter HFInvMassFitter.o runMassFitter.o G__HFInvMassFitter.o $(root-config --libs) -lRooFit -lRooFitCore -lEG ``` and run the fitter: -``` +```bash ./runMassFitter ../config_massfitter.json ``` From 0a699811b7a337c7b9e6de5b73ef6474c8eb896a Mon Sep 17 00:00:00 2001 From: Oleksii Lubynets Date: Thu, 26 Jun 2025 21:14:43 +0200 Subject: [PATCH 12/12] fix wording: invariant-mass --- PWGHF/D2H/Macros/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md index 799ef8bac90..f65de110419 100644 --- a/PWGHF/D2H/Macros/README.md +++ b/PWGHF/D2H/Macros/README.md @@ -1,5 +1,5 @@ -# Invariant mass fitter -Invariant mass fitter is implemented in the class `HFInvMassFitter` (`HFInvMassFitter.cxx/h` files), and its run is executed via `runMassFitter.C` macro. +# Invariant-mass fitter +Invariant-mass fitter is implemented in the class `HFInvMassFitter` (`HFInvMassFitter.cxx/h` files), and its run is executed via `runMassFitter.C` macro. Fitter is configured in `config_massfitter.json`.\ The fitter is **not** a part of O2Physics source code.