diff --git a/PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.txt b/PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.txt new file mode 100644 index 00000000000..5a74cec1768 --- /dev/null +++ b/PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.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/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/HFInvMassFitterLinkDef.h b/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h new file mode 100644 index 00000000000..cc755de478f --- /dev/null +++ b/PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h @@ -0,0 +1,31 @@ +// 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. + +/// \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_ + +#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_ diff --git a/PWGHF/D2H/Macros/README.md b/PWGHF/D2H/Macros/README.md new file mode 100644 index 00000000000..f65de110419 --- /dev/null +++ b/PWGHF/D2H/Macros/README.md @@ -0,0 +1,59 @@ +# 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 . + +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. +```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 +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 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: +```bash +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 ../ +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 +source path-to-root-install/bin/thisroot.sh + +# Generate ROOT dictionary: +rootcling -f G__HFInvMassFitter.cxx -c ../HFInvMassFitter.h ../HFInvMassFitterLinkDef.h + +# Compile source code: +g++ -fPIC -I$(root-config --incdir) -I path-to-json-include -c ../HFInvMassFitter.cxx ../runMassFitter.C G__HFInvMassFitter.cxx + +# Link the executable: +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 +``` diff --git a/PWGHF/D2H/Macros/runMassFitter.C b/PWGHF/D2H/Macros/runMassFitter.C index 637171248cc..1181c13b814 100644 --- a/PWGHF/D2H/Macros/runMassFitter.C +++ b/PWGHF/D2H/Macros/runMassFitter.C @@ -16,12 +16,18 @@ /// \author Mingyu Zhang /// \author Xinye Peng /// \author Biao Zhang +/// \author Oleksii Lubynets #if !defined(__CINT__) || defined(__CLING__) #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 +36,6 @@ #include // std::string #include // std::vector -#include -#include -#include - #endif using namespace rapidjson; @@ -672,3 +674,16 @@ void divideCanvas(TCanvas* canvas, int nSliceVarBins) } } } + +int main(int argc, char* argv[]) +{ + if (argc == 1) { + throw std::runtime_error("Not enough arguments. Please use\n./runMassFitter configFileName"); + } + + const std::string configFileName = argv[1]; + + runMassFitter(configFileName); + + return 0; +}