Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions PWGHF/D2H/Macros/CMakeLists_HFInvMassFitter.txt
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 4 additions & 3 deletions PWGHF/D2H/Macros/HFInvMassFitter.cxx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.

Check failure on line 1 in PWGHF/D2H/Macros/HFInvMassFitter.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[name/workflow-file]

Name of a workflow file must match the name of the main struct in it (without the PWG prefix). (Class implementation files should be in "Core" directories.)
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
Expand All @@ -16,6 +16,7 @@
/// \author Mingyu Zhang <mingyu.zang@cern.ch>
/// \author Xinye Peng <xinye.peng@cern.ch>
/// \author Biao Zhang <biao.zhang@cern.ch>
/// \author Oleksii Lubynets <oleksii.lubynets@cern.ch>

#include "HFInvMassFitter.h"

Expand All @@ -33,9 +34,6 @@
#include <RooPolynomial.h>
#include <RooRealVar.h>
#include <RooWorkspace.h>

#include <Rtypes.h>
#include <RtypesCore.h>
#include <TColor.h>
#include <TDatabasePDG.h>
#include <TLine.h>
Expand All @@ -45,6 +43,9 @@
#include <TStyle.h>
#include <TVirtualPad.h>

#include <Rtypes.h>
#include <RtypesCore.h>

#include <array>
#include <cmath>
#include <cstring>
Expand Down
7 changes: 4 additions & 3 deletions PWGHF/D2H/Macros/HFInvMassFitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@
/// \author Mingyu Zhang <mingyu.zang@cern.ch>
/// \author Xinye Peng <xinye.peng@cern.ch>
/// \author Biao Zhang <biao.zhang@cern.ch>
/// \author Oleksii Lubynets <oleksii.lubynets@cern.ch>

#ifndef PWGHF_D2H_MACROS_HFINVMASSFITTER_H_
#define PWGHF_D2H_MACROS_HFINVMASSFITTER_H_

#include <RooPlot.h>
#include <RooRealVar.h>
#include <RooWorkspace.h>
#include <Rtypes.h>
#include <RtypesCore.h>

#include <TF1.h>
#include <TH1.h>
#include <TNamed.h>
#include <TVirtualPad.h>

#include <Rtypes.h>
#include <RtypesCore.h>

#include <cstdio>

class HFInvMassFitter : public TNamed
Expand Down
31 changes: 31 additions & 0 deletions PWGHF/D2H/Macros/HFInvMassFitterLinkDef.h
Original file line number Diff line number Diff line change
@@ -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 <zhenz@cern.ch>
/// \author Mingyu Zhang <mingyu.zang@cern.ch>
/// \author Xinye Peng <xinye.peng@cern.ch>
/// \author Biao Zhang <biao.zhang@cern.ch>
/// \author Oleksii Lubynets <oleksii.lubynets@cern.ch>

#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_
59 changes: 59 additions & 0 deletions PWGHF/D2H/Macros/README.md
Original file line number Diff line number Diff line change
@@ -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 <https://rapidjson.org>.

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
```
23 changes: 19 additions & 4 deletions PWGHF/D2H/Macros/runMassFitter.C
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
/// \author Mingyu Zhang <mingyu.zang@cern.ch>
/// \author Xinye Peng <xinye.peng@cern.ch>
/// \author Biao Zhang <biao.zhang@cern.ch>
/// \author Oleksii Lubynets <oleksii.lubynets@cern.ch>

#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 <TCanvas.h>
#include <TDatabasePDG.h>
#include <TFile.h>
#include <TH2F.h>

#include <rapidjson/document.h>
#include <rapidjson/filereadstream.h>

Expand All @@ -30,10 +36,6 @@
#include <string> // std::string
#include <vector> // std::vector

#include <TDatabasePDG.h>
#include <TFile.h>
#include <TH2F.h>

#endif

using namespace rapidjson;
Expand Down Expand Up @@ -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;
}
Loading