From f9953100cc89fe9d4c6d914c48d562c92c569776 Mon Sep 17 00:00:00 2001
From: Viktor Klochkov <v.klochkov@gsi.de>
Date: Thu, 17 Mar 2022 10:14:06 +0000
Subject: [PATCH] Add AT interface

---
 .clang-format                                 |  66 +++++++++
 .idea/modules.xml                             |   8 --
 CMakeLists.txt                                | 133 +++---------------
 .../ATCentralityLinkDef.hpp                   |   3 -
 at_interface/CMakeLists.txt                   |  49 +++++++
 at_interface/CentralityFiller.cpp             |  72 ++++++++++
 at_interface/CentralityFiller.hpp             |  63 +++++++++
 CONTRIBUTING.md => docs/CONTRIBUTING.md       | 100 ++++++++-----
 Doxyfile => docs/Doxyfile                     |   0
 glauber/FitterHelper.cpp                      |   1 -
 {glauber/macro => macro}/HistoCompare.C       |  38 ++---
 {glauber/macro => macro}/RunGlauberAna.C      |  24 ++--
 macro/TestGetter.C                            |   9 +-
 {glauber/macro => macro}/TreeReader.C         |  39 ++---
 {glauber/macro => macro/batch}/run.sh         |   0
 .../macro => macro/batch}/run_glauberfit.sh   |   0
 {glauber/macro => macro}/plot_chi2.C          |  18 ++-
 macro/rootlogon.C                             |   4 +-
 src/BordersFinder.cpp                         |  27 ++--
 src/{BordersFinder.h => BordersFinder.hpp}    |  27 ++--
 src/BordersFinder2D.cpp                       |  58 ++++----
 ...{BordersFinder2D.h => BordersFinder2D.hpp} |  37 +++--
 src/BordersFinderHelper.cpp                   |  41 +++---
 ...FinderHelper.h => BordersFinderHelper.hpp} |  23 ++-
 src/CMakeLists.txt                            |  51 +++++++
 src/CentralityLinkDef.hpp                     |  10 ++
 src/Container.cpp                             |   6 -
 src/Container.h                               |  41 ------
 {glauber => src}/Fitter.cpp                   |  68 ++++-----
 glauber/Fitter.h => src/Fitter.hpp            |  33 ++---
 src/FitterHelper.cpp                          |   1 +
 .../FitterHelper.h => src/FitterHelper.hpp    |  29 ++--
 src/Getter.cpp                                |  24 ++--
 src/{Getter.h => Getter.hpp}                  |  33 ++---
 tasks/CMakeLists.txt                          |  22 +++
 tasks/fill_centrality.cpp                     |  36 +++++
 glauber/main.cpp => tasks/glauber.cpp         |  24 ++--
 main.cpp => tasks/main.cpp                    |  50 ++++---
 38 files changed, 751 insertions(+), 517 deletions(-)
 create mode 100644 .clang-format
 delete mode 100644 .idea/modules.xml
 rename src/CentralityLinkDef.h => at_interface/ATCentralityLinkDef.hpp (57%)
 create mode 100644 at_interface/CMakeLists.txt
 create mode 100644 at_interface/CentralityFiller.cpp
 create mode 100644 at_interface/CentralityFiller.hpp
 rename CONTRIBUTING.md => docs/CONTRIBUTING.md (50%)
 rename Doxyfile => docs/Doxyfile (100%)
 delete mode 100644 glauber/FitterHelper.cpp
 rename {glauber/macro => macro}/HistoCompare.C (53%)
 rename {glauber/macro => macro}/RunGlauberAna.C (75%)
 rename {glauber/macro => macro}/TreeReader.C (68%)
 rename {glauber/macro => macro/batch}/run.sh (100%)
 rename {glauber/macro => macro/batch}/run_glauberfit.sh (100%)
 rename {glauber/macro => macro}/plot_chi2.C (80%)
 rename src/{BordersFinder.h => BordersFinder.hpp} (65%)
 rename src/{BordersFinder2D.h => BordersFinder2D.hpp} (54%)
 rename src/{BordersFinderHelper.h => BordersFinderHelper.hpp} (59%)
 create mode 100644 src/CMakeLists.txt
 create mode 100644 src/CentralityLinkDef.hpp
 delete mode 100644 src/Container.cpp
 delete mode 100644 src/Container.h
 rename {glauber => src}/Fitter.cpp (88%)
 rename glauber/Fitter.h => src/Fitter.hpp (81%)
 create mode 100644 src/FitterHelper.cpp
 rename glauber/FitterHelper.h => src/FitterHelper.hpp (79%)
 rename src/{Getter.h => Getter.hpp} (65%)
 create mode 100644 tasks/CMakeLists.txt
 create mode 100644 tasks/fill_centrality.cpp
 rename glauber/main.cpp => tasks/glauber.cpp (83%)
 rename main.cpp => tasks/main.cpp (70%)

diff --git a/.clang-format b/.clang-format
new file mode 100644
index 0000000..ff58a91
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,66 @@
+# Generated from CLion C/C++ Code Style settings
+BasedOnStyle: LLVM
+AccessModifierOffset: -1
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignOperands: false
+AllowAllArgumentsOnNextLine: false
+AllowAllConstructorInitializersOnNextLine: false
+AllowAllParametersOfDeclarationOnNextLine: false
+AllowShortBlocksOnASingleLine: Always
+AllowShortCaseLabelsOnASingleLine: true
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: Always
+AllowShortLambdasOnASingleLine: All
+AllowShortLoopsOnASingleLine: true
+AlwaysBreakAfterReturnType: None
+AlwaysBreakTemplateDeclarations: Yes
+BreakBeforeBraces: Custom
+BraceWrapping:
+  AfterCaseLabel: false
+  AfterClass: false
+  AfterControlStatement: Never
+  AfterEnum: false
+  AfterFunction: false
+  AfterNamespace: false
+  AfterUnion: false
+  BeforeCatch: false
+  BeforeElse: false
+  IndentBraces: false
+  SplitEmptyFunction: false
+  SplitEmptyRecord: false
+BreakBeforeBinaryOperators: NonAssignment
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializers: BeforeColon
+BreakInheritanceList: BeforeColon
+ColumnLimit: 0
+CompactNamespaces: false
+ContinuationIndentWidth: 4
+IndentCaseLabels: true
+IndentPPDirectives: None
+IndentWidth: 2
+KeepEmptyLinesAtTheStartOfBlocks: true
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: false
+PointerAlignment: Left
+ReflowComments: false
+SpaceAfterCStyleCast: true
+SpaceAfterLogicalNot: false
+SpaceAfterTemplateKeyword: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeCpp11BracedList: false
+SpaceBeforeCtorInitializerColon: true
+SpaceBeforeInheritanceColon: true
+SpaceBeforeParens: ControlStatements
+SpaceBeforeRangeBasedForLoopColon: true
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 0
+SpacesInAngles: false
+SpacesInCStyleCastParentheses: false
+SpacesInContainerLiterals: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+TabWidth: 4
+UseTab: Never
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index b0ab82f..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
-  <component name="ProjectModuleManager">
-    <modules>
-      <module fileurl="file://$PROJECT_DIR$/.idea/centrality.iml" filepath="$PROJECT_DIR$/.idea/centrality.iml" />
-    </modules>
-  </component>
-</project>
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebfe732..612b767 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,138 +12,42 @@ message(STATUS "Using C++${CMAKE_CXX_STANDARD}")
 
 # by default build optimized code with debug symbols
 if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
-    set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
+    set(CMAKE_BUILD_TYPE Release)
 endif ()
 
 # in DEBUG mode make verbose Makefile
-if (CMAKE_BUILD_TYPE MATCHES DEBUG)
+if (CMAKE_BUILD_TYPE MATCHES DEBUG OR CMAKE_BUILD_TYPE MATCHES Debug)
     set(CMAKE_VERBOSE_MAKEFILE ON)
 endif ()
 
 set(CMAKE_CXX_FLAGS_DEBUG "-O0 -ggdb -DDEBUG -D__DEBUG -Wall -Wextra -fopenmp")
+set(CMAKE_CXX_FLAGS_Debug "-O0 -ggdb -DDEBUG -D__DEBUG -Wall -Wextra -fopenmp")
 set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native -ftree-vectorize -ffast-math -DNODEBUG -fopenmp")
-set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELEASE} -ggdb")
+set(CMAKE_CXX_FLAGS_Release "-O3 -march=native -ftree-vectorize -ffast-math -DNODEBUG -fopenmp")
 message(STATUS "Using CXX flags for ${CMAKE_BUILD_TYPE}: ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}")
 
-set(SOURCES
-        src/BordersFinder.cpp
-        src/BordersFinderHelper.cpp
-        src/Getter.cpp
-        src/BordersFinder2D.cpp
-#        src/Container.cpp
-        glauber/Fitter.cpp 
-        glauber/FitterHelper.cpp 
-        )
-
-string(REPLACE ".cpp" ".h" HEADERS "${SOURCES}")
-
-set(CMAKE_VERBOSE_MAKEFILE ON)
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
 
 # Telling CMake where to find the ROOT installation.
 list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
-list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/lib")
+list(APPEND CMAKE_PREFIX_PATH ${ROOTSYS})
 
 #---Locate the ROOT package and defines a number of variables (e.g. ROOT_INCLUDE_DIRS)
 find_package(ROOT REQUIRED COMPONENTS Core MathCore RIO Hist Tree)
+find_package(AnalysisTree QUIET)
 
 # Define useful ROOT functions and macros (e.g. ROOT_GENERATE_DICTIONARY)
+message(STATUS "Using ROOT: ${ROOT_VERSION} <${ROOT_CONFIG}>")
+include_directories(${CMAKE_SOURCE_DIR} ${ROOT_INCLUDE_DIR} ${ROOT_INCLUDE_DIRS})
 include(${ROOT_USE_FILE})
-add_definitions(${ROOT_CXX_FLAGS})
-
-
-set(DICT_FILE_NAME G__${PROJECT_NAME})
-set(PCM_FILE_NAME lib${PROJECT_NAME})
-
-set(CENTRALITY_SOURCES
-        src/BordersFinder.cpp
-        src/BordersFinderHelper.cpp
-        src/Getter.cpp
-        src/BordersFinder2D.cpp)
-
-string(REPLACE ".cpp" ".h" CENTRALITY_HEADERS "${CENTRALITY_SOURCES}")
-
-set(GLAUBER_SOURCES
-        glauber/Fitter.cpp
-        glauber/FitterHelper.cpp
-        )
-
-string(REPLACE ".cpp" ".h" GLAUBER_HEADERS "${GLAUBER_SOURCES}")
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-ROOT_GENERATE_DICTIONARY(${DICT_FILE_NAME} ${CENTRALITY_HEADERS} ${GLAUBER_HEADERS} LINKDEF src/CentralityLinkDef.h)
-add_library(Centrality SHARED ${CENTRALITY_SOURCES} ${GLAUBER_SOURCES} ${DICT_FILE_NAME})
-target_link_libraries(Centrality ${ROOT_LIBRARIES})
-add_custom_command(
-        TARGET Centrality POST_BUILD
-        COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/include/centrality
-        COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${CENTRALITY_HEADERS} ${CMAKE_BINARY_DIR}/include/centrality/
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-)
-add_custom_command(
-        TARGET Centrality POST_BUILD
-        COMMAND ${CMAKE_COMMAND} ARGS -E make_directory ${CMAKE_BINARY_DIR}/include/glauber
-        COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${GLAUBER_HEADERS} ${CMAKE_BINARY_DIR}/include/glauber/
-        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
-target_include_directories(Centrality
-        PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
-        PUBLIC
-            $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
-        # backward compatibility
-            $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
-            $<INSTALL_INTERFACE:include>
-        )
-
-# Create a main program using the library
-add_executable(main main.cpp)
-target_link_libraries(main Centrality ${ROOT_LIBRARIES})
-target_include_directories(main PUBLIC src)
-
-add_executable(glauber glauber/main.cpp)
-target_link_libraries(glauber ${ROOT_LIBRARIES} Centrality)
-
-
-# install(FILES ${HEADERS} DESTINATION include)
-# install(TARGETS Centrality DESTINATION lib)
-
-# Packaging routine
-# For complete explanation
-# @see https://cmake.org/cmake/help/git-master/manual/cmake-packages.7.html#creating-packages
-include(GenerateExportHeader)
 
+if (NOT AnalysisTree_FOUND)
+    message(STATUS "AnalysisTree is not found")
+else ()
+    add_subdirectory(at_interface)
+endif ()
 
-generate_export_header(Centrality)
-set_property(TARGET Centrality PROPERTY VERSION ${PROJECT_VERSION})
-set_property(TARGET Centrality PROPERTY SOVERSION ${PROJECT_VERSION})
-set_property(TARGET Centrality PROPERTY INTERFACE_Centrality_MAJOR_VERSION 1)
-set_property(TARGET Centrality APPEND PROPERTY COMPATIBLE_INTERFACE_STRING INTERFACE_Centrality_MAJOR_VERSION)
-
-install(TARGETS Centrality EXPORT CentralityTargets
-        LIBRARY DESTINATION lib
-        ARCHIVE DESTINATION lib
-        RUNTIME DESTINATION bin
-        INCLUDES DESTINATION include
-        )
-
-install(
-        FILES
-        ${HEADERS}
-        "${CMAKE_CURRENT_BINARY_DIR}/centrality_export.h"
-        DESTINATION
-        include/centrality
-        COMPONENT
-        Devel
-)
-
-install(
-        FILES
-        "${CMAKE_CURRENT_BINARY_DIR}/${PCM_FILE_NAME}_rdict.pcm"
-        DESTINATION
-        lib
-        OPTIONAL
-)
+add_subdirectory(src)
+add_subdirectory(tasks)
 
 install(
         FILES
@@ -163,6 +67,8 @@ write_basic_package_version_file(
 export(EXPORT CentralityTargets
         FILE "${CMAKE_CURRENT_BINARY_DIR}/Centrality/CentralityTargets.cmake")
 
+message(STATUS "CentralityTargets: ${CentralityTargets}")
+
 set(ConfigPackageLocation lib/cmake/Centrality)
 
 set(Centrality_INCLUDE_DIR "include")
@@ -172,9 +78,6 @@ configure_package_config_file(
         CentralityConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/Centrality/CentralityConfig.cmake
         INSTALL_DESTINATION ${ConfigPackageLocation}
         PATH_VARS Centrality_INCLUDE_DIR Centrality_LIBRARY_DIR
-        #  [NO_SET_AND_CHECK_MACRO]
-        #  [NO_CHECK_REQUIRED_COMPONENTS_MACRO]
-        #  [INSTALL_PREFIX <path>]
 )
 
 install(EXPORT CentralityTargets
@@ -193,5 +96,3 @@ install(FILES
         Devel
         )
 
-install(TARGETS glauber RUNTIME DESTINATION bin)
-install(TARGETS main RUNTIME DESTINATION bin)
\ No newline at end of file
diff --git a/src/CentralityLinkDef.h b/at_interface/ATCentralityLinkDef.hpp
similarity index 57%
rename from src/CentralityLinkDef.h
rename to at_interface/ATCentralityLinkDef.hpp
index edec1b6..7510190 100644
--- a/src/CentralityLinkDef.h
+++ b/at_interface/ATCentralityLinkDef.hpp
@@ -4,7 +4,4 @@
 #pragma link off all classes;
 #pragma link off all functions;
 
-#pragma link C++ class Glauber::Fitter+;
-#pragma link C++ class Centrality::Getter+;
-
 #endif
diff --git a/at_interface/CMakeLists.txt b/at_interface/CMakeLists.txt
new file mode 100644
index 0000000..4794791
--- /dev/null
+++ b/at_interface/CMakeLists.txt
@@ -0,0 +1,49 @@
+set(SOURCES
+        CentralityFiller.cpp
+        #        CentralityTask.cpp
+        #        CentralityTaskTracks.cpp
+        #        CentralityTaskPsd.cpp
+        )
+
+string(REPLACE ".cpp" ".hpp" HEADERS "${SOURCES}")
+
+set(DICT_FILE_NAME G__ATCentrality)
+set(PCM_FILE_NAME libATCentrality)
+
+include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR} ${AnalysisTree_INCLUDE_DIR})
+
+add_library(ATCentrality SHARED ${SOURCES} ${DICT_FILE_NAME})
+ROOT_GENERATE_DICTIONARY(${DICT_FILE_NAME} ${HEADERS} LINKDEF ATCentralityLinkDef.hpp)
+target_link_libraries(ATCentrality Centrality AnalysisTreeBase AnalysisTreeInfra ${ROOT_LIBRARIES})
+
+#install(TARGETS Centrality EXPORT CentralityTargets
+#        LIBRARY DESTINATION lib
+#        ARCHIVE DESTINATION lib
+#        RUNTIME DESTINATION bin
+#        INCLUDES DESTINATION include
+#        )
+#
+#install(
+#        FILES
+#        ${HEADERS}
+#        DESTINATION
+#        include/Centrality
+#        COMPONENT
+#        Devel
+#)
+#
+#install(
+#        FILES
+#        "${CMAKE_CURRENT_BINARY_DIR}/${PCM_FILE_NAME}_rdict.pcm"
+#        DESTINATION
+#        lib
+#        OPTIONAL
+#)
+#
+#install(
+#        FILES
+#        "${CMAKE_CURRENT_BINARY_DIR}/${PCM_FILE_NAME}.rootmap"
+#        DESTINATION
+#        lib
+#        OPTIONAL
+#)
diff --git a/at_interface/CentralityFiller.cpp b/at_interface/CentralityFiller.cpp
new file mode 100644
index 0000000..517643e
--- /dev/null
+++ b/at_interface/CentralityFiller.cpp
@@ -0,0 +1,72 @@
+#include "CentralityFiller.hpp"
+
+#include <memory>
+#include "TFile.h"
+
+namespace AnalysisTree{
+
+CentralityFiller::CentralityFiller(const std::string& file, const std::string& getter) {
+  auto centr_file = std::unique_ptr<TFile>(TFile::Open(file.c_str(), "read"));
+
+  if((!centr_file) || (centr_file->IsZombie())) {
+    throw std::runtime_error("No file or file is zombie");
+  }
+  getter_ = centr_file->Get<Centrality::Getter>(getter.c_str());
+  if(getter_ == nullptr) {
+    throw std::runtime_error("Centrality Getter is nullptr");
+  }
+}
+
+void CentralityFiller::Init() {
+  auto man = TaskManager::GetInstance();
+  auto chain = man->GetChain();
+  input_ = chain->GetBranch(input_name_);
+
+  is_event_header_ = input_.GetBranchType() == DetType::kEventHeader;
+
+  in_field_ = input_.GetField(input_field_name_);
+  in_branches_.emplace(input_name_);
+
+  auto conf = input_.GetConfig().Clone(output_name_, AnalysisTree::DetType::kEventHeader);
+  conf.AddField<float>(output_field_name_, "centrality, %");
+  output_ = Branch(conf);
+  out_field_ = output_.GetField(output_field_name_);
+
+  output_.SetMutable();
+  output_.Freeze();
+
+  input_.Freeze();
+
+  man->AddBranch(&output_);
+}
+
+void CentralityFiller::Exec() {
+  if(is_event_header_) {
+    FillFromEventHeader();
+  } else {
+    FillFromChannels();
+  }
+}
+
+void CentralityFiller::FillFromEventHeader() {
+
+  const auto value = input_[0][in_field_];
+  output_[0].CopyContent(input_[0]);
+
+  const auto centrality = getter_->GetCentrality(value);
+  output_[0].SetValue(out_field_, centrality);
+}
+
+void CentralityFiller::FillFromChannels() {
+  const auto n = input_.size();
+  int m{0};
+  for(size_t i = 0; i < n; ++i) {
+    if(!event_cuts_ || event_cuts_->Apply(input_[i])) {
+      m++;
+    }
+  }
+  const auto centrality = getter_->GetCentrality(m);
+  output_[0].SetValue(out_field_, centrality);
+}
+
+}
\ No newline at end of file
diff --git a/at_interface/CentralityFiller.hpp b/at_interface/CentralityFiller.hpp
new file mode 100644
index 0000000..fa067cf
--- /dev/null
+++ b/at_interface/CentralityFiller.hpp
@@ -0,0 +1,63 @@
+#ifndef CENTRALITY_AT_INTERFACE_CENTRALITYFILLER_HPP_
+#define CENTRALITY_AT_INTERFACE_CENTRALITYFILLER_HPP_
+
+#include <utility>
+
+#include "AnalysisTree/Task.hpp"
+#include "AnalysisTree/TaskManager.hpp"
+#include "Getter.hpp"
+
+namespace AnalysisTree{
+
+class CentralityFiller : public AnalysisTree::Task{
+ public:
+
+  CentralityFiller() = delete;
+  CentralityFiller(const std::string& file, const std::string& getter);
+
+  void Init() override;
+
+  void Exec() override;
+
+  void Finish() override {
+    delete getter_;
+  }
+
+  void SetInput(std::string branch, std::string field = "") {
+    input_name_ = std::move(branch);
+    input_field_name_ = std::move(field);
+  }
+
+  void SetOutput(std::string branch, std::string field) {
+    output_name_ = std::move(branch);
+    output_field_name_ = std::move(field);
+  }
+
+  ~CentralityFiller() override = default;
+
+ protected:
+  void FillFromEventHeader();
+  void FillFromChannels();
+
+  std::string input_name_;
+  std::string input_field_name_;
+  std::string output_name_;
+  std::string output_field_name_;
+
+  Centrality::Getter* getter_{nullptr};
+
+  AnalysisTree::Branch input_;
+  AnalysisTree::Branch output_;
+
+  AnalysisTree::Field in_field_;
+  AnalysisTree::Field out_field_;
+
+  bool is_event_header_{true};
+
+//  AnalysisTree::Cuts* cuts_{nullptr};
+
+};
+
+}
+
+#endif //CENTRALITY_AT_INTERFACE_CENTRALITYFILLER_HPP_
diff --git a/CONTRIBUTING.md b/docs/CONTRIBUTING.md
similarity index 50%
rename from CONTRIBUTING.md
rename to docs/CONTRIBUTING.md
index 999b0bc..e6676c4 100644
--- a/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -1,8 +1,9 @@
-# Contribution Guide 
+# Contribution Guide
 
 https://google.github.io/styleguide/cppguide.html
 
 ## Doxygen documentation
+
 Always document your code, e. g. put at least a brief class description
 
     /** @file MyClass.h
@@ -37,9 +38,11 @@ The selection of name spaces is reflected also in the directory structure for th
 
 ## Include Files
 
-In header files only use include which MUST be there. Unnecessary includes increase the compilation time. Most of the time all necessary includes can be moved to the implementation.
+In header files only use include which MUST be there. Unnecessary includes increase the compilation time. Most of the
+time all necessary includes can be moved to the implementation.
 
-To avoid including header files more than once, use the preprocessor macro _nsp_ClassName_h_ to mark a header as already included. Usage of these inclusion guards is nonnegotiable.
+To avoid including header files more than once, use the preprocessor macro _nsp_ClassName_h_ to mark a header as already
+included. Usage of these inclusion guards is nonnegotiable.
 
     // file: .../include/nsp/ClassName.h
 
@@ -51,34 +54,40 @@ To avoid including header files more than once, use the preprocessor macro _nsp_
 
     #endif
 
-Since with the introduction of namespaces, a class can exist in more than one namespace, we can have header files with the same name to define the same class. We have to add the namespace both to the path for locating the file and to the preprocessor macro preventing multiple inclusion of a header.
+Since with the introduction of namespaces, a class can exist in more than one namespace, we can have header files with
+the same name to define the same class. We have to add the namespace both to the path for locating the file and to the
+preprocessor macro preventing multiple inclusion of a header.
 
 ## Pass by const reference
-* Complex objects should be passed by reference. 
+
+* Complex objects should be passed by reference.
 * Don’t use it for simple types (int, float, . . . ), it can be an overhead
 * Prefer over pointer: This makes sure you get a valid object
-    
-    void func(const myClass& c); // good
-    void func(const myClass* c); // ok, if you know why (needed only in rare cases)
-    void func(myClass c); // not so good, unless you know why
+
+  void func(const myClass& c); // good void func(const myClass* c); // ok, if you know why (needed only in rare cases)
+  void func(myClass c); // not so good, unless you know why
 
 ## Pointers
- * Only use pointer if you have a strong reason!
- * If you use objects on the stack you don’t have to care about deletion
- * If you need pointers, prefer smart pointers over plain pointers
+
+* Only use pointer if you have a strong reason!
+* If you use objects on the stack you don’t have to care about deletion
+* If you need pointers, prefer smart pointers over plain pointers
 
 ## Using namespace statement
 
-Due to the global effect on all code that includes the particular header, using and using namespace statement should never be given in header files. NEVER do that in header:
-    
+Due to the global effect on all code that includes the particular header, using and using namespace statement should
+never be given in header files. NEVER do that in header:
+
     using namespace std;
 
-This means all files including your header will have the std namespace. You could do it in the implementation, not considered nice style. Prefer importing only single function, only do it in your implementation
-    
+This means all files including your header will have the std namespace. You could do it in the implementation, not
+considered nice style. Prefer importing only single function, only do it in your implementation
+
     using std::cout;
 
-Furthermore, since using namespace statement has an immediate effect also outside of the file scope, in .cpp files all such statements should come after all includes.
-You could also define an alias, this can even be done locally in a function body
+Furthermore, since using namespace statement has an immediate effect also outside of the file scope, in .cpp files all
+such statements should come after all includes. You could also define an alias, this can even be done locally in a
+function body
 
     using cout = std::cout;
 
@@ -89,71 +98,92 @@ consider using modern ‘typedef’
 
 ## Abbreviations
 
-In general, avoid abbreviations in variable and class names. Here is a list of accepted abbreviations which should not be expanded explicitly:
+In general, avoid abbreviations in variable and class names. Here is a list of accepted abbreviations which should not
+be expanded explicitly:
 
- * MC: Monte-Carlo
- * NBD: Negative Binomial Distribution
- *  ...  
+* MC: Monte-Carlo
+* NBD: Negative Binomial Distribution
+* ...
 
 ## Const correctness and constness issues
-It is of utmost importance that all classes, functions and methods respect the correct and logical use of const modifier. Methods that do not change class data members should be declared const. Function and method parameters should be declared const if they are not intended to be changed inside of the function body. This is even more true when references are passed through the parameters.
+
+It is of utmost importance that all classes, functions and methods respect the correct and logical use of const
+modifier. Methods that do not change class data members should be declared const. Function and method parameters should
+be declared const if they are not intended to be changed inside of the function body. This is even more true when
+references are passed through the parameters.
 
 In this respect the use of const_cast is strongly discouraged since it can unravel weird compiler bugs.
 
-The rule of a thumb for each programmer should be that first of all a new variable (if possible) is declared not before the value for it is available (i.e. no C-style declarations of variables at the beginning of the code block) and that every new local variable is declared const by default. A forward declaration of a local variable should be used only in special cases when its value will be known only after complex processing (possibly taking place inside of a nested scope).
+The rule of a thumb for each programmer should be that first of all a new variable (if possible) is declared not before
+the value for it is available (i.e. no C-style declarations of variables at the beginning of the code block) and that
+every new local variable is declared const by default. A forward declaration of a local variable should be used only in
+special cases when its value will be known only after complex processing (possibly taking place inside of a nested
+scope).
 
 ## NULL vs. nullptr
-Note that NULL is a (macro) remainder from C and should be avoided. nullptr is meant as a replacement to NULL. nullptr provides a typesafe pointer value representing an empty (null) pointer. The general rule of thumb that I recommend is that you should start using nullptr whenever you would have used NULL in the past. Even better: avoid usage of pointers completely. Almost everything can be done with references instead and is more bug-resistant.
+
+Note that NULL is a (macro) remainder from C and should be avoided. nullptr is meant as a replacement to NULL. nullptr
+provides a typesafe pointer value representing an empty (null) pointer. The general rule of thumb that I recommend is
+that you should start using nullptr whenever you would have used NULL in the past. Even better: avoid usage of pointers
+completely. Almost everything can be done with references instead and is more bug-resistant.
 
 ## Pointer * and reference & placement
+
 The * and & modifiers are part of the type and there thus they belong:
 
     Core::Track& foo;
 
 ## Constructor initializer list
+
 If possible put it directly after member declaration in the header
 
     Double32_t energy_{0}; // track energy in GeV
 
 ## Increment, decrement
-As default, only pre-increment (++i) and pre-decrement (--i) operators should be used, unless the post-increment/-decrement (i++) feature is explicitly required. The reason is that the post- versions require temporary storage of the previous value of a variable. The compiler will (most probably) optimize such waste away for the built-in types (int etc) but this does not happen for custom code of the various iterators (STL, Offline). The bad habit of placing ++ after the variables can be avoided by forcing yourself to use pre- versions of operators everywhere.
+
+As default, only pre-increment (++i) and pre-decrement (--i) operators should be used, unless the
+post-increment/-decrement (i++) feature is explicitly required. The reason is that the post- versions require temporary
+storage of the previous value of a variable. The compiler will (most probably) optimize such waste away for the built-in
+types (int etc) but this does not happen for custom code of the various iterators (STL, Offline). The bad habit of
+placing ++ after the variables can be avoided by forcing yourself to use pre- versions of operators everywhere.
 
 ## Forbidden practices
-Generally, the C/FORTRAN-hackish style should be avoided. In particular, the following practices are absolutely forbidden.
+
+Generally, the C/FORTRAN-hackish style should be avoided. In particular, the following practices are absolutely
+forbidden.
 
 Do not use fixed size C arrays when variable size arrays are needed, such as
 
     // A "probably big enough" fixed size array in a place where variable size array would be needed:
     double a[20];
-     
+
 Use STL vector instead, such as
 
     std::vector<double> a(20);
-     
+
 Do not use dynamical C arrays, such as
 
     // Allocate:
     double* a = (double*)calloc(30, sizeof(double));
     // De-allocate:
     free(a);
-     
-Use STL vector instead, see previous point.
-Do not pass large data to function arguments via pointers, such as
+
+Use STL vector instead, see previous point. Do not pass large data to function arguments via pointers, such as
 
     int function(int a, double* array); 
 
 or
 
     int function(int a, double[] array);
-     
+
 Use instead C++ reference:
 
     int function(int a, std::vector<double>& array);
-     
+
 Do not use unnamed constants, such as
 
     std::vector<double> array(23);
-     
+
 Use instead enums so that we know what 23 is:
 
     // Declared somewhere at the beginning:
diff --git a/Doxyfile b/docs/Doxyfile
similarity index 100%
rename from Doxyfile
rename to docs/Doxyfile
diff --git a/glauber/FitterHelper.cpp b/glauber/FitterHelper.cpp
deleted file mode 100644
index b796804..0000000
--- a/glauber/FitterHelper.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "FitterHelper.h"
diff --git a/glauber/macro/HistoCompare.C b/macro/HistoCompare.C
similarity index 53%
rename from glauber/macro/HistoCompare.C
rename to macro/HistoCompare.C
index 14777f1..e86f464 100644
--- a/glauber/macro/HistoCompare.C
+++ b/macro/HistoCompare.C
@@ -1,21 +1,21 @@
 
 
 void HistoCompare() {
-  TFile *f = new TFile("root_files/out_histo_2.root");
+  TFile* f = new TFile("root_files/out_histo_2.root");
 
-  TH1F *hData = (TH1F *) f->Get("h1d_Mult_TPC_Ref");
+  TH1F* hData = (TH1F*) f->Get("h1d_Mult_TPC_Ref");
 
-  TH1F *h0 = new TH1F("h0", "", 125, 0, 250);
-  TH1F *h1 = (TH1F *) f->Get("glaub_0.25_0.1709_0.78_1000000");
-  TH1F *h2 = (TH1F *) f->Get("glaub_0.80_0.3048_0.75_1000000");
-  TH1F *h3 = (TH1F *) f->Get("glaub_0.80_0.3048_0.75_1000000");
+  TH1F* h0 = new TH1F("h0", "", 125, 0, 250);
+  TH1F* h1 = (TH1F*) f->Get("glaub_0.25_0.1709_0.78_1000000");
+  TH1F* h2 = (TH1F*) f->Get("glaub_0.80_0.3048_0.75_1000000");
+  TH1F* h3 = (TH1F*) f->Get("glaub_0.80_0.3048_0.75_1000000");
 
-  TH1F *hDiff1 = new TH1F("diff1", "", 125, 0, 250);
-  TH1F *hDiff2 = new TH1F("diff2", "", 125, 0, 250);
-  TH1F *hDiff3 = new TH1F("diff3", "", 125, 0, 250);
+  TH1F* hDiff1 = new TH1F("diff1", "", 125, 0, 250);
+  TH1F* hDiff2 = new TH1F("diff2", "", 125, 0, 250);
+  TH1F* hDiff3 = new TH1F("diff3", "", 125, 0, 250);
 
-  for (Int_t ii = 0; ii < 125; ii++) {
-    if (hData->GetBinContent(ii + 1) > 0) {
+  for(Int_t ii = 0; ii < 125; ii++) {
+    if(hData->GetBinContent(ii + 1) > 0) {
       Float_t diff1 = (h1->GetBinContent(ii + 1) / hData->GetBinContent(ii + 1));
       hDiff1->SetBinContent(ii + 1, diff1);
 
@@ -29,23 +29,23 @@ void HistoCompare() {
     }
   }
 
-  TCanvas *c1 = new TCanvas("c1", "canvas", 1500, 900);
+  TCanvas* c1 = new TCanvas("c1", "canvas", 1500, 900);
 
   hDiff1->SetLineColor(2);
   hDiff2->SetLineColor(3);
   hDiff3->SetLineColor(4);
   hDiff1->Draw();
   hDiff2->Draw("same");
-//     hDiff3->Draw("same");
+  //     hDiff3->Draw("same");
   h0->Draw("same");
 
-  TLegend *legDiff = new TLegend(0.4, 0.75, 0.75, 0.9);
+  TLegend* legDiff = new TLegend(0.4, 0.75, 0.75, 0.9);
   legDiff->AddEntry(hDiff1, "f = 0.25 mu = 0.1709 k = 0.78", "l");
   legDiff->AddEntry(hDiff2, "f = 0.80 mu = 0.3048 k = 0.75", "l");
-//     legDiff->AddEntry(hDiff3 ,"f = 1", "l");    
+  //     legDiff->AddEntry(hDiff3 ,"f = 1", "l");
   legDiff->Draw("same");
 
-  TCanvas *c2 = new TCanvas("c2", "canvas", 1500, 900);
+  TCanvas* c2 = new TCanvas("c2", "canvas", 1500, 900);
 
   h1->SetLineColor(2);
   h2->SetLineColor(3);
@@ -55,12 +55,12 @@ void HistoCompare() {
   h1->Draw();
   hData->Draw("same");
   h2->Draw("same");
-//     h3->Draw("same");
+  //     h3->Draw("same");
 
-  TLegend *legData = new TLegend(0.4, 0.75, 0.75, 0.9);
+  TLegend* legData = new TLegend(0.4, 0.75, 0.75, 0.9);
   legData->AddEntry(h1, "f = 0.25 mu = 0.1709 k = 0.78", "l");
   legData->AddEntry(h2, "f = 0.80 mu = 0.3048 k = 0.75", "l");
-//     legData->AddEntry(h3 ,"f = 1", "l");    
+  //     legData->AddEntry(h3 ,"f = 1", "l");
   legData->AddEntry(hData, "data", "l");
   legData->Draw("same");
 }
\ No newline at end of file
diff --git a/glauber/macro/RunGlauberAna.C b/macro/RunGlauberAna.C
similarity index 75%
rename from glauber/macro/RunGlauberAna.C
rename to macro/RunGlauberAna.C
index 8175994..f7edee4 100644
--- a/glauber/macro/RunGlauberAna.C
+++ b/macro/RunGlauberAna.C
@@ -2,24 +2,24 @@
 
 void RunGlauberAna(TString InFileName = "root_files/MinMult_60/merged.root") {
   TString CentralityFrameworkDir = "/lustre/nyx/cbm/users/klochkov/soft/CentralityFramework/";
-//     TString DataFileName = CentralityFrameworkDir + "containers/ana_dima_merged.root";
+  //     TString DataFileName = CentralityFrameworkDir + "containers/ana_dima_merged.root";
   TString DataFileName = "/lustre/nyx/cbm/users/klochkov/soft/PidFramework/input/DCM_1M.root";
   gStyle->SetOptStat(0000);
 
-  TFile *DataFile = new TFile(DataFileName, "read");
-  CentralityEventContainer *container = new CentralityEventContainer;
-  TTree *ContTree = (TTree *) DataFile->Get("cbm_data");
+  TFile* DataFile = new TFile(DataFileName, "read");
+  CentralityEventContainer* container = new CentralityEventContainer;
+  TTree* ContTree = (TTree*) DataFile->Get("cbm_data");
   ContTree->SetBranchAddress("CentralityEventContainer", &container);
   ContTree->Draw("CentralityEventContainer.GetDetectorWeight(3) >> h1(500, 0, 500)");
-  TH1F *hData1 = (TH1F *) gPad->GetPrimitive("h1");
+  TH1F* hData1 = (TH1F*) gPad->GetPrimitive("h1");
 
-  TFile *file = new TFile(InFileName);
-  TTree *tree = file->Get("test_tree");
+  TFile* file = new TFile(InFileName);
+  TTree* tree = file->Get("test_tree");
 
   Float_t f, mu, k;
   Float_t chi2;
   Float_t sigma;
-  TH1F *h1 = new TH1F("h1", "", 500, 0, 500);
+  TH1F* h1 = new TH1F("h1", "", 500, 0, 500);
 
   tree->SetBranchAddress("f", &f);
   tree->SetBranchAddress("mu", &mu);
@@ -47,7 +47,7 @@ void RunGlauberAna(TString InFileName = "root_files/MinMult_60/merged.root") {
     if (chi2 > 2.5) continue;
 
     if (true) {
-      TCanvas *c1 = new TCanvas("c1", "c1", 1200, 800);
+      TCanvas* c1 = new TCanvas("c1", "c1", 1200, 800);
 
       hData1->Draw();
       h1->Draw("same");
@@ -57,7 +57,7 @@ void RunGlauberAna(TString InFileName = "root_files/MinMult_60/merged.root") {
       gPad->SetLogy();
       gPad->Update();
       hData1->SetLineColor(kRed);
-      TLegend *leg1 = new TLegend(0.7, 0.75, 0.85, 0.89);
+      TLegend* leg1 = new TLegend(0.7, 0.75, 0.85, 0.89);
       leg1->AddEntry(hData1, "M_{STS}", "l");
       leg1->AddEntry(h1, "MC-Glauber Fit", "l");
       leg1->Draw("same");
@@ -65,7 +65,6 @@ void RunGlauberAna(TString InFileName = "root_files/MinMult_60/merged.root") {
 
       c1->SaveAs("fit.root");
       c1->SaveAs("fit.C");
-
     }
 
     Int_t jj;
@@ -73,7 +72,7 @@ void RunGlauberAna(TString InFileName = "root_files/MinMult_60/merged.root") {
     if (jj == 0) break;
   }
 
-  TGraph2D *g = new TGraph2D(x.size(), &(x[0]), &(y[0]), &(z[0]));
+  TGraph2D* g = new TGraph2D(x.size(), &(x[0]), &(y[0]), &(z[0]));
   g->GetXaxis()->SetTitle("f");
   g->SetName(" ");
   g->SetMinimum(5);
@@ -82,5 +81,4 @@ void RunGlauberAna(TString InFileName = "root_files/MinMult_60/merged.root") {
   gPad->SetLogz();
   g->Draw("colz");
   gPad->Update();
-
 }
\ No newline at end of file
diff --git a/macro/TestGetter.C b/macro/TestGetter.C
index b42337f..029804f 100644
--- a/macro/TestGetter.C
+++ b/macro/TestGetter.C
@@ -5,16 +5,15 @@ enum eEstimators{
   nEstimators
 };
 
-void TestGetter(const TString file = "../build/test.root" )
-{
+void TestGetter(const TString file = "../build/test.root") {
   std::unique_ptr<TFile> f{TFile::Open(file, "read")};
 
-  std::unique_ptr<Centrality::Getter> getter1d{(Centrality::Getter *) f->Get("centr_getter_1d")};
-  std::unique_ptr<Centrality::Getter> getter2d{(Centrality::Getter *) f->Get("centr_getter_2d")};
+  std::unique_ptr<Centrality::Getter> getter1d{(Centrality::Getter*) f->Get("centr_getter_1d")};
+  std::unique_ptr<Centrality::Getter> getter2d{(Centrality::Getter*) f->Get("centr_getter_2d")};
 
   Centrality::Container cont;
 
-  for (uint iEvent = 0; iEvent < 1; ++iEvent) {
+  for(uint iEvent = 0; iEvent < 1; ++iEvent) {
     const float value1 = 150.;
     const float value2 = 20.;
 
diff --git a/glauber/macro/TreeReader.C b/macro/TreeReader.C
similarity index 68%
rename from glauber/macro/TreeReader.C
rename to macro/TreeReader.C
index 7cf6cb7..233d1f8 100644
--- a/glauber/macro/TreeReader.C
+++ b/macro/TreeReader.C
@@ -1,32 +1,33 @@
 const int nPoints = 10000;
 
 void TreeReader(Int_t MultMin = 130, Int_t Mode = 2) {
-  TH1F *h1d_Mult_TPC_Ref/* = new TH1F("h1d_Mult_TPC_Ref","M_{TPC}^{ref}", 125, 0, 250)*/;
-  TFile *f111 = new TFile("/lustre/nyx/cbm/users/klochkov/soft/CentralityFramework/Macro/hTPC_ref.root");
-  h1d_Mult_TPC_Ref = (TH1F *) f111->Get("h1Corr");
+  TH1F* h1d_Mult_TPC_Ref /* = new TH1F("h1d_Mult_TPC_Ref","M_{TPC}^{ref}", 125, 0, 250)*/;
+  TFile* f111 = new TFile("/lustre/nyx/cbm/users/klochkov/soft/CentralityFramework/Macro/hTPC_ref.root");
+  h1d_Mult_TPC_Ref = (TH1F*) f111->Get("h1Corr");
   h1d_Mult_TPC_Ref->GetYaxis()->SetRangeUser(0.1, 1e5);
 
-  TCanvas *c1 = new TCanvas("c1", "canvas", 1400, 1000);
+  TCanvas* c1 = new TCanvas("c1", "canvas", 1400, 1000);
 
-  if (Mode == 2) {
+  if(Mode == 2) {
     c1->Divide(2, 1);
-    TPad *c1_1 = (TPad *) c1->GetListOfPrimitives()->FindObject("c1_1");
+    TPad* c1_1 = (TPad*) c1->GetListOfPrimitives()->FindObject("c1_1");
     c1_1->SetLogy(1);
   }
 
   TString filename = Form("MinMult_%d/merged_%d.root", MultMin, MultMin);
 
-  TFile *file = new TFile(filename);
-//     TTree *tree = file->Get("fit_tree");
-  TTree *tree = file->Get("test_tree");
+  TFile* file = new TFile(filename);
+  //     TTree *tree = file->Get("fit_tree");
+  TTree* tree = file->Get("test_tree");
 
-  TH1F *h1 = new TH1F("h1", "", 125, 0, 250);
-  TH1F *h3 = new TH1F("h3", "", 125, 0, 250);
-  for (Int_t i = 0; i < 125; i++)
+  TH1F* h1 = new TH1F("h1", "", 125, 0, 250);
+  TH1F* h3 = new TH1F("h3", "", 125, 0, 250);
+  for(Int_t i = 0; i < 125; i++) {
     h3->SetBinContent(i + 1, 1);
+  }
   h3->SetLineColor(3);
 
-  TH1F *hDiff = new TH1F("hDiff", "", 125, 0, 250);
+  TH1F* hDiff = new TH1F("hDiff", "", 125, 0, 250);
   hDiff->GetYaxis()->SetRangeUser(0.0, 2);
 
   Float_t f, mu, k;
@@ -42,7 +43,7 @@ void TreeReader(Int_t MultMin = 130, Int_t Mode = 2) {
 
   Int_t n = tree->GetEntries();
 
-  TH2F *h2 = new TH2F("h2", "", 20, 0., 1., 50, 0., 1);
+  TH2F* h2 = new TH2F("h2", "", 20, 0., 1., 50, 0., 1);
   h1d_Mult_TPC_Ref->GetYaxis()->SetRangeUser(0.1, 1e6);
   h1d_Mult_TPC_Ref->SetLineColor(2);
 
@@ -60,7 +61,7 @@ void TreeReader(Int_t MultMin = 130, Int_t Mode = 2) {
       h1->Draw("same");
       gPad->Update();
     }
-//         sigma = mu*(1+mu/k);
+    //         sigma = mu*(1+mu/k);
     for (Int_t ii = 0; ii < 125; ii++)
       if (h1d_Mult_TPC_Ref->GetBinContent(ii + 1) > 0) {
         Float_t diff1 = (h1->GetBinContent(ii + 1) / h1d_Mult_TPC_Ref->GetBinContent(ii + 1));
@@ -78,16 +79,16 @@ void TreeReader(Int_t MultMin = 130, Int_t Mode = 2) {
     Int_t k_bin = int(k / 0.02 + 0.01);
     Int_t sigma_bin = TMath::Nint(sigma * 50) + 1;
 
-//         if (chi2 < 2)
+    //         if (chi2 < 2)
     std::cout << "f = " << f << "    mu = " << mu << "    k = " << k << "    sigma = " << sigma << "    chi2 = " << chi2
               << std::endl;
-//         std::cout << "f = " << f_bin << "    mu = " << mu << "    k = " << k_bin << "    sigma = " << sigma_bin << std::endl;    
+    //         std::cout << "f = " << f_bin << "    mu = " << mu << "    k = " << k_bin << "    sigma = " << sigma_bin << std::endl;
 
     x[i] = f;
     y[i] = sigma;
     z[i] = chi2;
 
-//         if (chi2 < 50)
+    //         if (chi2 < 50)
     h2->SetBinContent(f_bin, sigma_bin, chi2);
 
     if (Mode == 2) {
@@ -98,7 +99,7 @@ void TreeReader(Int_t MultMin = 130, Int_t Mode = 2) {
   }
 
   if (Mode == 1) {
-    TGraph2D *g = new TGraph2D(nPoints, x, y, z);
+    TGraph2D* g = new TGraph2D(nPoints, x, y, z);
     g->GetXaxis()->SetTitle("f");
     g->GetYaxis()->SetTitle("sigma");
     g->Draw("colz");
diff --git a/glauber/macro/run.sh b/macro/batch/run.sh
similarity index 100%
rename from glauber/macro/run.sh
rename to macro/batch/run.sh
diff --git a/glauber/macro/run_glauberfit.sh b/macro/batch/run_glauberfit.sh
similarity index 100%
rename from glauber/macro/run_glauberfit.sh
rename to macro/batch/run_glauberfit.sh
diff --git a/glauber/macro/plot_chi2.C b/macro/plot_chi2.C
similarity index 80%
rename from glauber/macro/plot_chi2.C
rename to macro/plot_chi2.C
index 566e089..6378cff 100644
--- a/glauber/macro/plot_chi2.C
+++ b/macro/plot_chi2.C
@@ -7,15 +7,15 @@ void plot_chi2(TString InFileName) {
   TString histoname = "reco_info/hMreco";
 
   std::unique_ptr<TFile> fqa{TFile::Open(qa_filename.Data())};
-  TH1F *hData1 = (TH1F *) fqa->Get(histoname);
+  TH1F* hData1 = (TH1F*) fqa->Get(histoname);
 
-  TFile *file = new TFile(InFileName);
-  TTree *tree = (TTree *) file->Get("test_tree");
+  TFile* file = new TFile(InFileName);
+  TTree* tree = (TTree*) file->Get("test_tree");
 
   Float_t f, mu, k;
   Float_t chi2;
   Float_t sigma;
-  TH1F *h1 = new TH1F("h1", "", 500, 0, 500);
+  TH1F* h1 = new TH1F("h1", "", 500, 0, 500);
 
   tree->SetBranchAddress("f", &f);
   tree->SetBranchAddress("mu", &mu);
@@ -45,7 +45,7 @@ void plot_chi2(TString InFileName) {
     //         if ( chi2 > 2.5 ) continue;
 
     if (false) {
-      TCanvas *c1 = new TCanvas("c1", "c1", 1200, 800);
+      TCanvas* c1 = new TCanvas("c1", "c1", 1200, 800);
 
       hData1->Draw();
       h1->Draw("same");
@@ -55,7 +55,7 @@ void plot_chi2(TString InFileName) {
       gPad->SetLogy();
       gPad->Update();
       hData1->SetLineColor(kRed);
-      TLegend *leg1 = new TLegend(0.7, 0.75, 0.85, 0.89);
+      TLegend* leg1 = new TLegend(0.7, 0.75, 0.85, 0.89);
       leg1->AddEntry(hData1, "M_{STS}", "l");
       leg1->AddEntry(h1, "MC-Glauber Fit", "l");
       leg1->Draw("same");
@@ -63,7 +63,6 @@ void plot_chi2(TString InFileName) {
 
       c1->SaveAs("fit.root");
       c1->SaveAs("fit.C");
-
     }
 
     //         Int_t jj;
@@ -71,14 +70,13 @@ void plot_chi2(TString InFileName) {
     //         if (jj == 0) break;
   }
 
-  TCanvas *c1 = new TCanvas("c1", "c1", 800, 800);
+  TCanvas* c1 = new TCanvas("c1", "c1", 800, 800);
 
-  TGraph2D *g = new TGraph2D(x.size(), &(x[0]), &(y[0]), &(z[0]));
+  TGraph2D* g = new TGraph2D(x.size(), &(x[0]), &(y[0]), &(z[0]));
   g->SetName("#chi^{2} vs f, k");
   g->SetTitle("#chi^{2} vs f, k; f; k; #chi^{2}");
 
   //     gPad->SetLogz();
   g->Draw("colz");
   gPad->Update();
-
 }
diff --git a/macro/rootlogon.C b/macro/rootlogon.C
index 520ad2d..ec3f8ea 100644
--- a/macro/rootlogon.C
+++ b/macro/rootlogon.C
@@ -1,6 +1,6 @@
 {
 const TString dir = "../build/";
 gSystem->
-Load( dir
-+"libCentrality.so");
+Load(dir
++ "libCentrality.so");
 }
diff --git a/src/BordersFinder.cpp b/src/BordersFinder.cpp
index c193779..377092d 100644
--- a/src/BordersFinder.cpp
+++ b/src/BordersFinder.cpp
@@ -1,13 +1,13 @@
-#include "BordersFinder.h"
-#include "Getter.h"
-#include "BordersFinderHelper.h"
+#include "BordersFinder.hpp"
+#include "BordersFinderHelper.hpp"
+#include "Getter.hpp"
 
-#include <iostream>
 #include <TGraph.h>
+#include <iostream>
 
 #include "TFile.h"
 
-namespace Centrality {
+namespace Centrality{
 
 void BordersFinder::FindBorders() {
   using namespace std;
@@ -23,7 +23,7 @@ void BordersFinder::FindBorders() {
 
   int n = axis->GetNbins();
 
-  double *histIntegral = histo_.GetIntegral();
+  double* histIntegral = histo_.GetIntegral();
   double x[n];
   for (int i = 0; i < n; ++i) {
     x[i] = axis->GetBinCenter(i + 1);
@@ -44,11 +44,12 @@ void BordersFinder::FindBorders() {
 
   for (auto cc : ranges_) {
     double xx = isSpectator_ ? xC(cc) : xC(100 - cc);
-    cout << cc << "%" << ", border:" << xx << endl;
+    cout << cc << "%"
+         << ", border:" << xx << endl;
     borders_.push_back(xx);
   }
 
-/*
+  /*
     uint iSlice{0};
     long int entriesCurrent{0};
     
@@ -72,10 +73,10 @@ void BordersFinder::FindBorders() {
 */
 }
 
-void BordersFinder::SaveBorders(const std::string &filename, const std::string &getter_name) {
+void BordersFinder::SaveBorders(const std::string& filename, const std::string& getter_name) {
   Getter getter;
 
-  if (this->GetBorders().size() < 2) return;
+  if(this->GetBorders().size() < 2) { return; }
 
   std::unique_ptr<TFile> f{TFile::Open(filename.data(), "update")};
 
@@ -85,8 +86,8 @@ void BordersFinder::SaveBorders(const std::string &filename, const std::string &
 
   getter.Write(getter_name.c_str());
 
-//     f->mkdir( ("dir_" + getter_name).c_str());
-//     f->cd( ("dir_" + getter_name).c_str() );
+  //     f->mkdir( ("dir_" + getter_name).c_str());
+  //     f->cd( ("dir_" + getter_name).c_str() );
 
   BordersFinderHelper h;
   h.SetName(getter_name);
@@ -97,4 +98,4 @@ void BordersFinder::SaveBorders(const std::string &filename, const std::string &
   f->Close();
 }
 
-}
+}// namespace Centrality
diff --git a/src/BordersFinder.h b/src/BordersFinder.hpp
similarity index 65%
rename from src/BordersFinder.h
rename to src/BordersFinder.hpp
index f524605..f1fc505 100644
--- a/src/BordersFinder.h
+++ b/src/BordersFinder.hpp
@@ -10,30 +10,30 @@
 
 #include "TH1.h"
 
-namespace Centrality {
+namespace Centrality{
 
-class BordersFinder {
+class BordersFinder{
 
  public:
-
   BordersFinder() = default;
 
   void FindBorders();
-  void SaveBorders(const std::string &filename, const std::string &getter_name);
+  void SaveBorders(const std::string& filename, const std::string& getter_name);
 
-  void SetHisto(const TH1F &h) { histo_ = h; }
-  TH1F &GetHisto() { return histo_; }   // not const to use Draw etc
+  void SetHisto(const TH1F& h) { histo_ = h; }
+  TH1F& GetHisto() { return histo_; }// not const to use Draw etc
 
   void SetNormalization(long int norm) { norm_ = norm; }
   Double_t GetNormalization() const { return norm_; }
 
-  void SetRanges(const std::vector<double> &ranges) { ranges_ = ranges; }
+  void SetRanges(const std::vector<double>& ranges) { ranges_ = ranges; }
   void SetRanges(int n, double min, double max) {
     ranges_.clear();
-//         ranges_.reserve(n+1);
+    //         ranges_.reserve(n+1);
 
-    for (int i = 0; i <= n; ++i)
+    for(int i = 0; i <= n; ++i) {
       ranges_.push_back(min + i * (max - min) / n);
+    }
   }
 
   void SetLimits(double xLo, double xHi) {
@@ -44,12 +44,11 @@ class BordersFinder {
 
   void IsSpectator(bool is = true) { isSpectator_ = is; }
 
-  const std::vector<double> &GetRanges() const { return ranges_; }
-  const std::vector<double> &GetBorders() const { return borders_; }
+  const std::vector<double>& GetRanges() const { return ranges_; }
+  const std::vector<double>& GetBorders() const { return borders_; }
   bool GetIsSpectator() const { return isSpectator_; }
 
  private:
-
   TH1F histo_;
   Double_t norm_{-1};
 
@@ -62,6 +61,6 @@ class BordersFinder {
   double xLo_{-1};
   double xHi_{-1};
 };
-}
+}// namespace Centrality
 
-#endif //CENTRALITY_BORDERSFINDER_H
+#endif//CENTRALITY_BORDERSFINDER_H
diff --git a/src/BordersFinder2D.cpp b/src/BordersFinder2D.cpp
index 9e682bc..12ba3cc 100644
--- a/src/BordersFinder2D.cpp
+++ b/src/BordersFinder2D.cpp
@@ -1,23 +1,23 @@
-#include "BordersFinder2D.h"
-#include "Getter.h"
-#include "BordersFinderHelper.h"
+#include "BordersFinder2D.hpp"
+#include "BordersFinderHelper.hpp"
+#include "Getter.hpp"
 
 #include <iostream>
 
-#include "TProfile.h"
-#include "TMath.h"
 #include "TF1.h"
 #include "TFile.h"
+#include "TMath.h"
+#include "TProfile.h"
 
 // ClassImp(Centrality::BordersFinder2D)
 
-namespace Centrality {
+namespace Centrality{
 
 void BordersFinder2D::Init() {
   fitname_ = "pol2";
 
-  for (int iBin = histo2d_.GetNbinsX(); iBin >= 1; --iBin) {
-    if (histo2d_.Integral(iBin, iBin, 0, histo2d_.GetNbinsY()) >= 1.) {
+  for(int iBin = histo2d_.GetNbinsX(); iBin >= 1; --iBin) {
+    if(histo2d_.Integral(iBin, iBin, 0, histo2d_.GetNbinsY()) >= 1.) {
       xmax_ = histo2d_.GetXaxis()->GetBinCenter(iBin);
       break;
     }
@@ -41,15 +41,17 @@ std::unique_ptr<TH1F> BordersFinder2D::Convert() {
   Init();
 
   std::unique_ptr<TH1F> histo1d
-      {new TH1F("histo1d", "", histo2d_.GetNbinsX(), histo2d_.GetXaxis()->GetXmin(), histo2d_.GetXaxis()->GetXmax())};
+    {new TH1F("histo1d", "", histo2d_.GetNbinsX(), histo2d_.GetXaxis()->GetXmin(), histo2d_.GetXaxis()->GetXmax())};
 
   Fit2D(fitname_);
   std::vector<double> par;
-  for (int ipar = 0; ipar < fit_->GetNpar(); ++ipar)
-    par.push_back(fit_->GetParameter(ipar));
+  par.reserve(fit_->GetNpar());
 
-  for (int iBin = 1; iBin <= histo2d_.GetNbinsX(); ++iBin) {
-//         if ( histo2d_.Integral(iBin, iBin, 0, histo2d_.GetNbinsY()) <= 1. ) continue;
+  for(int ipar = 0; ipar < fit_->GetNpar(); ++ipar) {
+    par.push_back(fit_->GetParameter(ipar));
+  }
+  for(int iBin = 1; iBin <= histo2d_.GetNbinsX(); ++iBin) {
+    //         if ( histo2d_.Integral(iBin, iBin, 0, histo2d_.GetNbinsY()) <= 1. ) continue;
 
     const auto x1 = iBin == 1 ? -0.2 : histo2d_.GetXaxis()->GetBinCenter(iBin - 1);
     const auto x2 = histo2d_.GetXaxis()->GetBinCenter(iBin);
@@ -58,7 +60,7 @@ std::unique_ptr<TH1F> BordersFinder2D::Convert() {
     const auto norm2 = FindNorm(par, x2);
 
     const auto integral = FindIntegral(norm1, norm2);
-//         std::cout << integral << std::endl;
+    //         std::cout << integral << std::endl;
 
     histo1d->SetBinContent(iBin, integral);
   }
@@ -71,13 +73,13 @@ std::unique_ptr<TH1F> BordersFinder2D::Convert() {
  * @param norm2 seconsd line parametrization
  * @return number of entries (integral)
  */
-double BordersFinder2D::FindIntegral(const std::array<double, 2> &norm1, const std::array<double, 2> &norm2) {
+double BordersFinder2D::FindIntegral(const std::array<double, 2>& norm1, const std::array<double, 2>& norm2) {
   double sum{0.};
 
-  for (int iBinX = 1; iBinX <= histo2d_.GetNbinsX(); ++iBinX) {
-    for (int iBinY = 1; iBinY <= histo2d_.GetNbinsY(); ++iBinY) {
+  for(int iBinX = 1; iBinX <= histo2d_.GetNbinsX(); ++iBinX) {
+    for(int iBinY = 1; iBinY <= histo2d_.GetNbinsY(); ++iBinY) {
       const auto entries = histo2d_.GetBinContent(iBinX, iBinY);
-      if (entries == 0) continue;
+      if(entries == 0) { continue; }
 
       const auto x = histo2d_.GetXaxis()->GetBinCenter(iBinX);
       const auto y = histo2d_.GetYaxis()->GetBinCenter(iBinY);
@@ -92,10 +94,10 @@ double BordersFinder2D::FindIntegral(const std::array<double, 2> &norm1, const s
   return sum;
 }
 
-void BordersFinder2D::SaveBorders2D(const std::string &filename, const std::string &getter_name) {
+void BordersFinder2D::SaveBorders2D(const std::string& filename, const std::string& getter_name) {
   Getter getter;
 
-  if (this->GetBorders().size() < 2) return;
+  if(this->GetBorders().size() < 2) { return; }
 
   std::unique_ptr<TFile> f{TFile::Open(filename.data(), "update")};
 
@@ -104,17 +106,19 @@ void BordersFinder2D::SaveBorders2D(const std::string &filename, const std::stri
   getter.SetMax(xmax_, ymax_);
 
   std::vector<double> par;
-  for (int ipar = 0; ipar < fit_->GetNpar(); ++ipar)
+  par.reserve(fit_->GetNpar());
+  for(int ipar = 0; ipar < fit_->GetNpar(); ++ipar) {
     par.push_back(fit_->GetParameter(ipar));
+  }
 
-  for (const auto &iborder : this->GetBorders()) {
+  for(const auto& iborder : this->GetBorders()) {
     const auto kb = FindNorm(par, iborder);
     getter.AddBorder2D(kb);
   }
   getter.Write(getter_name.c_str());
 
-//     f->mkdir( ("dir_" + getter_name).c_str());
-//     f->cd( ("dir_" + getter_name).c_str() );
+  //     f->mkdir( ("dir_" + getter_name).c_str());
+  //     f->cd( ("dir_" + getter_name).c_str() );
 
   BordersFinderHelper h;
   h.SetName(getter_name);
@@ -125,7 +129,7 @@ void BordersFinder2D::SaveBorders2D(const std::string &filename, const std::stri
   f->Close();
 }
 
-void BordersFinder2D::Fit2D(const TString &func) {
+void BordersFinder2D::Fit2D(const TString& func) {
   std::unique_ptr<TProfile> prof{histo2d_.ProfileX()};
   fit_ = new TF1("fit", func, histo2d_.GetXaxis()->GetXmin(), histo2d_.GetXaxis()->GetXmax());
   prof->Fit(fit_, "Q");
@@ -137,7 +141,7 @@ void BordersFinder2D::Fit2D(const TString &func) {
  * @param x argument
  * @return a0 and a1 parameters y = a0 + a1 * x
  */
-std::array<double, 2> BordersFinder2D::FindNorm(const std::vector<double> &par, double x) {
+std::array<double, 2> BordersFinder2D::FindNorm(const std::vector<double>& par, double x) {
   std::array<double, 2> ret{};
   const auto dx = (histo2d_.GetXaxis()->GetXmax() - histo2d_.GetXaxis()->GetXmin()) / 10000.;
 
@@ -160,4 +164,4 @@ std::array<double, 2> BordersFinder2D::FindNorm(const std::vector<double> &par,
   return ret;
 }
 
-}
+}// namespace Centrality
diff --git a/src/BordersFinder2D.h b/src/BordersFinder2D.hpp
similarity index 54%
rename from src/BordersFinder2D.h
rename to src/BordersFinder2D.hpp
index fa55459..0aa990a 100644
--- a/src/BordersFinder2D.h
+++ b/src/BordersFinder2D.hpp
@@ -8,31 +8,30 @@
 #ifndef CENTRALITY_BORDERSFINDER2D_H
 #define CENTRALITY_BORDERSFINDER2D_H
 
-#include "BordersFinder.h"
+#include "BordersFinder.hpp"
 
-#include "vector"
 #include "array"
+#include "vector"
 
-#include "TH2.h"
 #include "TF1.h"
+#include "TH2.h"
 
-namespace Centrality {
+namespace Centrality{
 
-class BordersFinder2D : public BordersFinder {
+class BordersFinder2D : public BordersFinder{
 
  public:
-
   BordersFinder2D() = default;
 
-  void SetHisto2D(TH2F &&histo2d) { histo2d_ = histo2d; }
-  TH2F &&GetHisto2D() { return std::move(histo2d_); }
+  void SetHisto2D(TH2F&& histo2d) { histo2d_ = histo2d; }
+  TH2F&& GetHisto2D() { return std::move(histo2d_); }
 
   void Init();
   std::unique_ptr<TH1F> Convert();
-  void Fit2D(const TString &func);
-  std::array<double, 2> FindNorm(const std::vector<double> &par, double x);
-  double FindIntegral(const std::array<double, 2> &norm1, const std::array<double, 2> &norm2);
-  void SaveBorders2D(const std::string &filename, const std::string &getter_name);
+  void Fit2D(const TString& func);
+  std::array<double, 2> FindNorm(const std::vector<double>& par, double x);
+  double FindIntegral(const std::array<double, 2>& norm1, const std::array<double, 2>& norm2);
+  void SaveBorders2D(const std::string& filename, const std::string& getter_name);
 
   /**
    *
@@ -41,10 +40,10 @@ class BordersFinder2D : public BordersFinder {
    * @param N order
    * @return
    */
-  static double polN(const std::vector<double> &par, double x) {
+  static double polN(const std::vector<double>& par, double x) {
     double res{0.};
     double xn{1.};
-    for (const auto ipar : par) {
+    for(const auto ipar : par) {
       res += ipar * xn;
       xn *= x;
     }
@@ -52,18 +51,16 @@ class BordersFinder2D : public BordersFinder {
   }
 
  private:
-
   TH2F histo2d_;
-  TF1 *fit_{nullptr};
+  TF1* fit_{nullptr};
 
   TString fitname_{""};
 
   double xmax_{1.};
   double ymax_{1.};
 
-//     ClassDef(BordersFinder2D, 1);
-
+  //     ClassDef(BordersFinder2D, 1);
 };
-}
+}// namespace Centrality
 
-#endif //CENTRALITY_BORDERSFINDER2D_H
+#endif//CENTRALITY_BORDERSFINDER2D_H
diff --git a/src/BordersFinderHelper.cpp b/src/BordersFinderHelper.cpp
index df92fa7..8618327 100644
--- a/src/BordersFinderHelper.cpp
+++ b/src/BordersFinderHelper.cpp
@@ -1,16 +1,16 @@
-#include "BordersFinderHelper.h"
+#include "BordersFinderHelper.hpp"
 
 #include <iostream>
 
-#include "TRandom.h"
 #include "TCanvas.h"
 #include "TLine.h"
+#include "TRandom.h"
 
 #include "TStyle.h"
 
 namespace Centrality {
 
-void BordersFinderHelper::QA(const Getter &getter, const TH1F &histo) const {
+void BordersFinderHelper::QA(const Getter& getter, const TH1F& histo) const {
   auto ranges = getter.GetRanges();
   std::sort(ranges.begin(), ranges.end());
 
@@ -18,7 +18,7 @@ void BordersFinderHelper::QA(const Getter &getter, const TH1F &histo) const {
 
   std::unique_ptr<TRandom> r{new TRandom};
 
-  for (Int_t iBin = 0; iBin < histo.GetNbinsX(); ++iBin) {
+  for(Int_t iBin = 0; iBin < histo.GetNbinsX(); ++iBin) {
     const Float_t Mult = histo.GetBinCenter(iBin + 1);
 
     for (Int_t j = 0; j < histo.GetBinContent(iBin + 1); ++j) {
@@ -33,14 +33,14 @@ void BordersFinderHelper::QA(const Getter &getter, const TH1F &histo) const {
   }
 }
 
-void BordersFinderHelper::PlotHisto(const Getter &getter, TH1F &histo) const {
+void BordersFinderHelper::PlotHisto(const Getter& getter, TH1F& histo) const {
   std::unique_ptr<TCanvas> c{new TCanvas("c", "", 1200, 800)};
   histo.Draw();
 
-  const auto &borders = getter.GetBorders();
-  TLine *line;
+  const auto& borders = getter.GetBorders();
+  TLine* line;
 
-  for (int i = 0; i < borders.GetNbins(); ++i) {
+  for(int i = 0; i < borders.GetNbins(); ++i) {
     const float border = borders.GetBinLowEdge(i + 1);
     const int height = histo.GetBinContent(histo.FindBin(border));
 
@@ -56,7 +56,7 @@ void BordersFinderHelper::PlotHisto(const Getter &getter, TH1F &histo) const {
   delete line;
 }
 
-void BordersFinderHelper::PlotHisto2D(const Getter &getter, TH2F &histo, TF1 &func) const {
+void BordersFinderHelper::PlotHisto2D(const Getter& getter, TH2F& histo, TF1& func) const {
   gStyle->SetOptStat(0000);
 
   std::unique_ptr<TCanvas> c{new TCanvas("c", "", 1000, 1000)};
@@ -66,23 +66,25 @@ void BordersFinderHelper::PlotHisto2D(const Getter &getter, TH2F &histo, TF1 &fu
   func.SetLineColor(kBlack);
   func.Draw("same");
 
-  const auto &borders = getter.GetBorders2D();
-  TLine *line{nullptr};
+  const auto& borders = getter.GetBorders2D();
+  TLine* line{nullptr};
 
-  for (uint i = 0; i < borders.size() - 1; ++i) {
+  for(uint i = 0; i < borders.size() - 1; ++i) {
 
     float x1{0.};
     float x2{1.};
     float x{0.5};
 
-    for (int iter = 0; iter < 10; ++iter) {
+    for(int iter = 0; iter < 10; ++iter) {
       x = (x1 + x2) / 2;
 
-      if ((func.Eval(x1) - borders.at(i)[0] - borders.at(i)[1] * x1)
-          * (func.Eval(x) - borders.at(i)[0] - borders.at(i)[1] * x) < 0)
+      if((func.Eval(x1) - borders.at(i)[0] - borders.at(i)[1] * x1)
+        * (func.Eval(x) - borders.at(i)[0] - borders.at(i)[1] * x)
+        < 0) {
         x2 = x;
-      else
+      } else {
         x1 = x;
+      }
     }
     x1 = x - 0.06 * borders.at(i)[1];
     x2 = x + 0.06 * borders.at(i)[1];
@@ -91,7 +93,7 @@ void BordersFinderHelper::PlotHisto2D(const Getter &getter, TH2F &histo, TF1 &fu
     float y1 = borders.at(i)[0] + borders.at(i)[1] * x1;
     float y2 = borders.at(i)[0] + borders.at(i)[1] * x2;
 
-//       if (y1 < 0) y1=0;
+    //       if (y1 < 0) y1=0;
 
     line = new TLine(x1, y1, x2, y2);
     line->SetLineWidth(2);
@@ -102,10 +104,11 @@ void BordersFinderHelper::PlotHisto2D(const Getter &getter, TH2F &histo, TF1 &fu
   c->SetLogz(true);
   c->Write(name_ + "_histo_2d");
 
-  if (ispdf_)
+  if(ispdf_) {
     c->SaveAs(name_ + "_histo_2d" + ".pdf");
+  }
 
   delete line;
 }
 
-}
+}// namespace Centrality
diff --git a/src/BordersFinderHelper.h b/src/BordersFinderHelper.hpp
similarity index 59%
rename from src/BordersFinderHelper.h
rename to src/BordersFinderHelper.hpp
index abfbed9..dee3f4d 100644
--- a/src/BordersFinderHelper.h
+++ b/src/BordersFinderHelper.hpp
@@ -8,31 +8,30 @@
 #ifndef CENTRALITY_BORDERSFINDERHELPER_H
 #define CENTRALITY_BORDERSFINDERHELPER_H
 
+#include "TF1.h"
 #include "TH1.h"
 #include "TH2.h"
-#include "TF1.h"
 
-#include "Getter.h"
+#include "Getter.hpp"
 
-namespace Centrality {
+namespace Centrality{
 
-class BordersFinderHelper {
+class BordersFinderHelper{
 
  public:
-
   BordersFinderHelper() = default;
-  void QA(const Getter &getter, const TH1F &histo) const;
-  void PlotHisto(const Getter &getter, TH1F &histo) const;
-  void PlotHisto2D(const Getter &getter, TH2F &histo, TF1 &func) const;
+  void QA(const Getter& getter, const TH1F& histo) const;
+  void PlotHisto(const Getter& getter, TH1F& histo) const;
+  void PlotHisto2D(const Getter& getter, TH2F& histo, TF1& func) const;
 
-  void SetName(const TString &name) { name_ = name; }
+  void SetName(const TString& name) { name_ = name; }
   void SetIsPdf(bool is = true) { ispdf_ = is; }
- private:
 
+ private:
   TString name_{"test"};
   bool ispdf_{false};
 };
 
-}
+}// namespace Centrality
 
-#endif //CENTRALITY_BORDERSFINDERHELPER_H
+#endif//CENTRALITY_BORDERSFINDERHELPER_H
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644
index 0000000..1a160e4
--- /dev/null
+++ b/src/CMakeLists.txt
@@ -0,0 +1,51 @@
+set(SOURCES
+        BordersFinder.cpp
+        BordersFinderHelper.cpp
+        Getter.cpp
+        BordersFinder2D.cpp
+        Fitter.cpp
+        FitterHelper.cpp
+        )
+
+string(REPLACE ".cpp" ".hpp" HEADERS "${SOURCES}")
+
+set(DICT_FILE_NAME G__${PROJECT_NAME})
+set(PCM_FILE_NAME lib${PROJECT_NAME})
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+add_library(Centrality SHARED ${SOURCES} ${DICT_FILE_NAME})
+ROOT_GENERATE_DICTIONARY(${DICT_FILE_NAME} ${HEADERS} LINKDEF CentralityLinkDef.hpp)
+target_link_libraries(Centrality ${ROOT_LIBRARIES})
+
+install(TARGETS Centrality EXPORT CentralityTargets
+        LIBRARY DESTINATION lib
+        ARCHIVE DESTINATION lib
+        RUNTIME DESTINATION bin
+        INCLUDES DESTINATION include
+        )
+
+install(
+        FILES
+        ${HEADERS}
+        DESTINATION
+        include/Centrality
+        COMPONENT
+        Devel
+)
+
+install(
+        FILES
+        "${CMAKE_CURRENT_BINARY_DIR}/${PCM_FILE_NAME}_rdict.pcm"
+        DESTINATION
+        lib
+        OPTIONAL
+)
+
+install(
+        FILES
+        "${CMAKE_CURRENT_BINARY_DIR}/${PCM_FILE_NAME}.rootmap"
+        DESTINATION
+        lib
+        OPTIONAL
+)
diff --git a/src/CentralityLinkDef.hpp b/src/CentralityLinkDef.hpp
new file mode 100644
index 0000000..c9d5b95
--- /dev/null
+++ b/src/CentralityLinkDef.hpp
@@ -0,0 +1,10 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class Glauber::Fitter + ;
+#pragma link C++ class Centrality::Getter + ;
+
+#endif
diff --git a/src/Container.cpp b/src/Container.cpp
deleted file mode 100644
index 91ba9c8..0000000
--- a/src/Container.cpp
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "Container.h"
-// ClassImp(Centrality::Container)
-
-namespace Centrality {
-
-}
diff --git a/src/Container.h b/src/Container.h
deleted file mode 100644
index 1ed876d..0000000
--- a/src/Container.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/** @file   Container.h
-    @class  Centrality::Container
-    @author Viktor Klochkov (klochkov44@gmail.com)
-    @author Ilya Selyuzhenkov (ilya.selyuzhenkov@gmail.com)
-    @brief  Class to store centrality information
-*/
-
-#ifndef CENTRALITY_CONTAINER_H
-#define CENTRALITY_CONTAINER_H
-
-#include <map>
-
-namespace Centrality {
-
-class Container {
-
- public:
-
-  Container() = default;
-
-  void AddCentralityEstimator(uint num, double centrality) {
-    centrality_.insert(std::make_pair(num, centrality));
-  }
-
-  double GetCentrality(uint num) const {
-    auto find = centrality_.find(num);
-    return find != centrality_.end() ? find->second : -1;
-  }
-
-  void Clear() { centrality_.clear(); }
-
- private:
-
-  std::map<uint, double> centrality_;
-
-//     ClassDef(Container, 1);
-
-};
-}
-
-#endif //CENTRALITY_CONTAINER_H
diff --git a/glauber/Fitter.cpp b/src/Fitter.cpp
similarity index 88%
rename from glauber/Fitter.cpp
rename to src/Fitter.cpp
index 854fce3..ae208f5 100644
--- a/glauber/Fitter.cpp
+++ b/src/Fitter.cpp
@@ -1,12 +1,10 @@
-#include "Fitter.h"
-#include "TTree.h"
-#include "TCanvas.h"
+#include "Fitter.hpp"
+
 #include "TF1.h"
 #include "TFile.h"
-#include "TGraph.h"
-#include "TLegend.h"
 #include "TMath.h"
 #include "TRandom.h"
+#include "TTree.h"
 
 ClassImp(Glauber::Fitter)
 
@@ -15,7 +13,7 @@ Glauber::Fitter::Fitter(std::unique_ptr<TTree> tree) {
   fSimTree = std::move(tree);
   std::cout << fSimTree->GetEntries() << std::endl;
 
-  if (!fSimTree) {
+  if(!fSimTree) {
     std::cout << "SetSimHistos: *** Error - " << std::endl;
     exit(EXIT_FAILURE);
   }
@@ -58,26 +56,33 @@ void Glauber::Fitter::Init(int nEntries) {
 
   std::cout << "fNbins = " << fNbins << std::endl;
   std::cout << "fMaxValue = " << fMaxValue << std::endl;
-
 }
 
 double Glauber::Fitter::Nancestors(double f) const {
-  if (fMode == "Default") return f * fNpart + (1 - f) * fNcoll;
-  else if (fMode == "PSD") return f - fNpart;
-  else if (fMode == "Npart") return TMath::Power(fNpart, f);
-  else if (fMode == "Ncoll") return TMath::Power(fNcoll, f);
+  if(fMode == "Default") { return f * fNpart + (1 - f) * fNcoll; }
+  else if(fMode == "PSD") {
+    return f - fNpart;
+  } else if(fMode == "Npart") {
+    return TMath::Power(fNpart, f);
+  } else if(fMode == "Ncoll") {
+    return TMath::Power(fNcoll, f);
+  }
 
   return -1.;
 }
 
 double Glauber::Fitter::NancestorsMax(double f) const {
-  const int NpartMax = fNpartHisto.GetXaxis()->GetXmax();  // some magic
-  const int NcollMax = fNcollHisto.GetXaxis()->GetXmax(); //TODO
-
-  if (fMode == "Default") return f * NpartMax + (1 - f) * NcollMax;
-  else if (fMode == "PSD") return NpartMax;
-  else if (fMode == "Npart") return TMath::Power(NpartMax, f);
-  else if (fMode == "Ncoll") return TMath::Power(NcollMax, f);
+  const int NpartMax = fNpartHisto.GetXaxis()->GetXmax();// some magic
+  const int NcollMax = fNcollHisto.GetXaxis()->GetXmax();//TODO
+
+  if(fMode == "Default") { return f * NpartMax + (1 - f) * NcollMax; }
+  else if(fMode == "PSD") {
+    return NpartMax;
+  } else if(fMode == "Npart") {
+    return TMath::Power(NpartMax, f);
+  } else if(fMode == "Ncoll") {
+    return TMath::Power(NcollMax, f);
+  }
 
   return -1.;
 }
@@ -92,13 +97,13 @@ void Glauber::Fitter::SetGlauberFitHisto(double f, double mu, double k, int n, B
 
   SetNBDhist(mu, k);
 
-  std::unique_ptr<TH1F> htemp{(TH1F *) fNbdHisto.Clone("htemp")}; // WTF??? Not working without pointer
-  for (int i = 0; i < n; i++) {
+  std::unique_ptr<TH1F> htemp{(TH1F*) fNbdHisto.Clone("htemp")};// WTF??? Not working without pointer
+  for(int i = 0; i < n; i++) {
     fSimTree->GetEntry(i);
     const int Na = int(Nancestors(f));
 
     double nHits{0.};
-    for (int j = 0; j < Na; j++) {
+    for(int j = 0; j < Na; j++) {
       nHits += int(htemp->GetRandom());
     }
     fGlauberFitHisto.Fill(nHits);
@@ -138,8 +143,8 @@ void Glauber::Fitter::NormalizeGlauberFit() {
  * @param nEvents
  * @param nIter
  */
-void Glauber::Fitter::FindMuGoldenSection(double *mu,
-                                          double *chi2,
+void Glauber::Fitter::FindMuGoldenSection(double* mu,
+                                          double* chi2,
                                           double mu_min,
                                           double mu_max,
                                           double f,
@@ -196,7 +201,7 @@ void Glauber::Fitter::FindMuGoldenSection(double *mu,
  * @param k1 upper search edge for NBD parameter
  * @param nEvents
  */
-double Glauber::Fitter::FitGlauber(double *par, double f0, Int_t k0, Int_t k1, Int_t nEvents) {
+double Glauber::Fitter::FitGlauber(double* par, double f0, Int_t k0, Int_t k1, Int_t nEvents) {
   double f_fit{-1};
   double mu_fit{-1};
   double k_fit{-1};
@@ -204,11 +209,11 @@ double Glauber::Fitter::FitGlauber(double *par, double f0, Int_t k0, Int_t k1, I
 
   const TString filename = Form("%s/fit_%4.2f_%d_%d_%d.root", fOutDirName.Data(), f0, k0, k1, fFitMinBin);
 
-  //     std::unique_ptr<TFile> file {TFile::Open(filename, "recreate")};    
+  //     std::unique_ptr<TFile> file {TFile::Open(filename, "recreate")};
   //     std::unique_ptr<TTree> tree {new TTree("test_tree", "tree" )};
 
-  TFile *file{TFile::Open(filename, "recreate")};
-  TTree *tree{new TTree("test_tree", "tree")};
+  TFile* file{TFile::Open(filename, "recreate")};
+  TTree* tree{new TTree("test_tree", "tree")};
 
   TH1F h1("h1", "", fNbins, 0, fMaxValue);
 
@@ -241,7 +246,6 @@ double Glauber::Fitter::FitGlauber(double *par, double f0, Int_t k0, Int_t k1, I
       Chi2Min = chi2;
       fBestFitHisto = fGlauberFitHisto;
     }
-
   }
   tree->Write();
   file->Write();
@@ -291,7 +295,7 @@ void Glauber::Fitter::SetNBDhist(double mu, double k) {
   for (int i = 0; i < nBins; ++i) {
     const double val = NBD(i, mu, k);
     if (val > 1e-10) fNbdHisto.SetBinContent(i + 1, val);
-    //         std::cout << "val " << val << std::endl;    
+    //         std::cout << "val " << val << std::endl;
   }
 }
 
@@ -331,7 +335,7 @@ double Glauber::Fitter::NBD(double n, double mu, double k) const {
  * @return pointer to the histogram 
  */
 std::unique_ptr<TH1F> Glauber::Fitter::GetModelHisto(const double range[2],
-                                                     const TString &name,
+                                                     const TString& name,
                                                      const double par[3],
                                                      int nEvents) {
   const double f = par[0];
@@ -359,8 +363,4 @@ std::unique_ptr<TH1F> Glauber::Fitter::GetModelHisto(const double range[2],
   }
 
   return hModel;
-
 }
-
-
-
diff --git a/glauber/Fitter.h b/src/Fitter.hpp
similarity index 81%
rename from glauber/Fitter.h
rename to src/Fitter.hpp
index 07e02d2..3ac444d 100644
--- a/glauber/Fitter.h
+++ b/src/Fitter.hpp
@@ -8,19 +8,18 @@
 #ifndef GlauberFitter_H
 #define GlauberFitter_H 1
 
-#include <vector>
-#include "TString.h"
-#include "TNamed.h"
 #include "TH1F.h"
+#include "TNamed.h"
+#include "TString.h"
 #include "TTree.h"
-// #include "TMinuit.h"
 
+#include <vector>
+// #include "TMinuit.h"
 
-namespace Glauber {
-class Fitter {
+namespace Glauber{
+class Fitter{
 
  public:
-
   /**   Default constructor   **/
   Fitter() = default;;
   explicit Fitter(std::unique_ptr<TTree> tree);
@@ -30,11 +29,11 @@ class Fitter {
   void Init(int nEntries);
   void SetGlauberFitHisto(double f, double mu, double k, Int_t n = 10000, Bool_t Norm2Data = true);
   void NormalizeGlauberFit();
-//  void DrawHistos(Bool_t isSim = true, Bool_t isData = true, Bool_t isGlauber = false, Bool_t isNBD = false) {};
+  //  void DrawHistos(Bool_t isSim = true, Bool_t isData = true, Bool_t isGlauber = false, Bool_t isNBD = false) {};
 
-  double FitGlauber(double *par, double f0, Int_t k0, Int_t k1, Int_t nEvents);
-  void FindMuGoldenSection(double *mu,
-                           double *chi2,
+  double FitGlauber(double* par, double f0, Int_t k0, Int_t k1, Int_t nEvents);
+  void FindMuGoldenSection(double* mu,
+                           double* chi2,
                            double mu_min,
                            double mu_max,
                            double f,
@@ -49,18 +48,18 @@ class Fitter {
   double Nancestors(double f) const;
   double NancestorsMax(double f) const;
 
-  std::unique_ptr<TH1F> GetModelHisto(const double range[2], const TString &name, const double par[3], Int_t nEvents);
+  std::unique_ptr<TH1F> GetModelHisto(const double range[2], const TString& name, const double par[3], Int_t nEvents);
 
   //
   //         Setters
   //
-  void SetInputHisto(const TH1F &h) { fDataHisto = h; }
+  void SetInputHisto(const TH1F& h) { fDataHisto = h; }
   void SetFitMinBin(Int_t min) { fFitMinBin = min; }
   void SetFitMaxBin(Int_t min) { fFitMaxBin = min; }
   void SetNormMinBin(Int_t min) { fNormMinBin = min; }
   void SetBinSize(Int_t size) { fBinSize = size; }
-  void SetOutDirName(const TString &name) { fOutDirName = name; }
-  void SetMode(const TString &mode) { fMode = mode; }
+  void SetOutDirName(const TString& name) { fOutDirName = name; }
+  void SetMode(const TString& mode) { fMode = mode; }
 
   //
   //         Getters
@@ -73,7 +72,6 @@ class Fitter {
   TH1F GetBestFiHisto() const { return fBestFitHisto; }
 
  private:
-
   /**   Data members  **/
   TH1F fNpartHisto;
   TH1F fNcollHisto;
@@ -102,8 +100,7 @@ class Fitter {
 
   TString fOutDirName{""};
  ClassDef(Fitter, 2);
-
 };
-}
+}// namespace Glauber
 
 #endif
diff --git a/src/FitterHelper.cpp b/src/FitterHelper.cpp
new file mode 100644
index 0000000..c965f97
--- /dev/null
+++ b/src/FitterHelper.cpp
@@ -0,0 +1 @@
+#include "FitterHelper.hpp"
diff --git a/glauber/FitterHelper.h b/src/FitterHelper.hpp
similarity index 79%
rename from glauber/FitterHelper.h
rename to src/FitterHelper.hpp
index 79addf2..6836b6a 100644
--- a/glauber/FitterHelper.h
+++ b/src/FitterHelper.hpp
@@ -8,22 +8,22 @@
 #define GlauberFitterHelper_H 1
 
 #include "TCanvas.h"
+#include "TFile.h"
 #include "TH1.h"
-#include "TPad.h"
 #include "TLegend.h"
-#include "TFile.h"
+#include "TPad.h"
 
-#include "glauber/Fitter.h"
+#include "Fitter.hpp"
 
-namespace Glauber {
-inline void DrawHistos(const Fitter &fit, Bool_t isSim, Bool_t isData, Bool_t isGlauber, Bool_t isNBD) {
+namespace Glauber{
+inline void DrawHistos(const Fitter& fit, Bool_t isSim, Bool_t isData, Bool_t isGlauber, Bool_t isNBD) {
   std::unique_ptr<TCanvas> c1{new TCanvas("c1", "canvas", 1500, 900)};
 
   c1->Divide(2, 2);
 
-  std::unique_ptr<TPad> c1_1{(TPad *) c1->GetListOfPrimitives()->FindObject("c1_1")};
-  std::unique_ptr<TPad> c1_2{(TPad *) c1->GetListOfPrimitives()->FindObject("c1_2")};
-  std::unique_ptr<TPad> c1_4{(TPad *) c1->GetListOfPrimitives()->FindObject("c1_4")};
+  std::unique_ptr<TPad> c1_1{(TPad*) c1->GetListOfPrimitives()->FindObject("c1_1")};
+  std::unique_ptr<TPad> c1_2{(TPad*) c1->GetListOfPrimitives()->FindObject("c1_2")};
+  std::unique_ptr<TPad> c1_4{(TPad*) c1->GetListOfPrimitives()->FindObject("c1_4")};
 
   c1_1->SetLogy(1);
   c1_2->SetLogy(1);
@@ -38,7 +38,7 @@ inline void DrawHistos(const Fitter &fit, Bool_t isSim, Bool_t isData, Bool_t is
 
   std::unique_ptr<TFile> fOut{TFile::Open("glauber_qa.root", "recreate")};
 
-  if (isSim) {
+  if(isSim) {
     c1->cd(1);
     hNcoll.SetLineColor(2);
 
@@ -54,11 +54,11 @@ inline void DrawHistos(const Fitter &fit, Bool_t isSim, Bool_t isData, Bool_t is
     hNpart.Write();
   }
 
-  if (isData) {
+  if(isData) {
     c1->cd(2);
     hData.Draw();
     hData.Write();
-    if (isGlauber) {
+    if(isGlauber) {
       hBestFit.SetLineColor(kRed);
       hBestFit.Draw("same");
 
@@ -70,14 +70,13 @@ inline void DrawHistos(const Fitter &fit, Bool_t isSim, Bool_t isData, Bool_t is
     }
   }
 
-  if (isNBD) {
+  if(isNBD) {
     c1->cd(3);
     hNBD.Draw();
     hNBD.Write();
-
   }
 
-  if (isGlauber) {
+  if(isGlauber) {
     c1->cd(4);
     hBestFit.Draw();
   }
@@ -87,6 +86,6 @@ inline void DrawHistos(const Fitter &fit, Bool_t isSim, Bool_t isData, Bool_t is
   fOut->Close();
 }
 
-}
+}// namespace Glauber
 
 #endif
diff --git a/src/Getter.cpp b/src/Getter.cpp
index af8fb46..fbfb68c 100644
--- a/src/Getter.cpp
+++ b/src/Getter.cpp
@@ -1,20 +1,22 @@
-#include "Getter.h"
+#include "Getter.hpp"
+
 #include <iostream>
 
 ClassImp(Centrality::Getter)
 
-namespace Centrality {
+namespace Centrality{
 
 double Getter::GetCentrality(double value) const {
-  if (!isinitialized_) {
+  if(!isinitialized_) {
     std::cout << "Centrality::Getter is not initialized!" << std::endl;
     exit(-1);
   }
   const int ibin = borders_.FindBin(value);
-  if (ibin == 0 || ibin > borders_.GetNbins())
+  if(ibin == 0 || ibin > borders_.GetNbins()) {
     return -1;
+  }
 
-//     std::cout << value << " " << ranges_.at(ibin-1) << "  " << ranges_.at(ibin) << std::endl; 
+  //     std::cout << value << " " << ranges_.at(ibin-1) << "  " << ranges_.at(ibin) << std::endl;
 
   const double centrality = 0.5 * (ranges_.at(ibin - 1) + ranges_.at(ibin));
 
@@ -22,7 +24,7 @@ double Getter::GetCentrality(double value) const {
 }
 
 double Getter::GetCentrality(double xvalue, double yvalue) const {
-  if (!isinitialized2D_) {
+  if(!isinitialized2D_) {
     std::cout << "Centrality::Getter is not initialized!" << std::endl;
     exit(-1);
   }
@@ -30,18 +32,19 @@ double Getter::GetCentrality(double xvalue, double yvalue) const {
   xvalue /= xmax_;
   yvalue /= ymax_;
 
-  for (uint iborder = 0; iborder < borders2d_.size() - 1; ++iborder) {
+  for(uint iborder = 0; iborder < borders2d_.size() - 1; ++iborder) {
     const double y1 = borders2d_.at(iborder)[0] + borders2d_.at(iborder)[1] * xvalue;
     const double y2 = borders2d_.at(iborder + 1)[0] + borders2d_.at(iborder + 1)[1] * xvalue;
 
-    if (yvalue < y1 && yvalue > y2)
+    if(yvalue < y1 && yvalue > y2) {
       return 0.5 * (ranges_.at(iborder - 1) + ranges_.at(iborder));
+    }
   }
 
   return -1.;
 }
 
-Getter *Getter::Create1DGetter(std::vector<double> borders) {
+Getter* Getter::Create1DGetter(std::vector<double> borders) {
   typedef decltype(ranges_)::value_type doubleing_t;
 
   size_t n_borders = borders.size();
@@ -52,7 +55,7 @@ Getter *Getter::Create1DGetter(std::vector<double> borders) {
   doubleing_t range_step = (range_max - range_min) / (n_borders - 1);
 
   decltype(ranges_) ranges(n_borders);
-  for (uint i = 0; i < n_borders; ++i) {
+  for(uint i = 0; i < n_borders; ++i) {
     auto rr = range_min + range_step * i;
     ranges[i] = rr;
 
@@ -68,5 +71,4 @@ Getter *Getter::Create1DGetter(std::vector<double> borders) {
 
   return getter;
 }
-
 }
diff --git a/src/Getter.h b/src/Getter.hpp
similarity index 65%
rename from src/Getter.h
rename to src/Getter.hpp
index 9864dcd..5abb0b8 100644
--- a/src/Getter.h
+++ b/src/Getter.hpp
@@ -8,52 +8,50 @@
 #ifndef CENTRALITY_GETTER_H
 #define CENTRALITY_GETTER_H
 
-#include <cassert>
-#include "vector"
 #include "array"
+#include "vector"
+#include <cassert>
 
-#include "TObject.h"
 #include "TAxis.h"
+#include "TObject.h"
 #include "TRandom.h"
 
-namespace Centrality {
+namespace Centrality{
 
-class Getter : public TObject {
+class Getter : public TObject{
 
  public:
-
   Getter() = default;
 
   double GetCentrality(double value) const;
   double GetCentrality(double xvalue, double yvalue) const;
 
-  void SetBorders(const std::vector<double> &borders) {
+  void SetBorders(const std::vector<double>& borders) {
     borders_ = TAxis(borders.size() - 1, &(borders[0]));
     isinitialized_ = true;
   }
 
-  const TAxis &GetBorders() const { return borders_; };
-  const std::vector<double> &GetRanges() const { return ranges_; };
+  const TAxis& GetBorders() const { return borders_; };
+  const std::vector<double>& GetRanges() const { return ranges_; };
 
-  void SetRanges(const std::vector<double> &ranges) { ranges_ = ranges; }
+  void SetRanges(const std::vector<double>& ranges) { ranges_ = ranges; }
   void IsSpectator(bool is = true) { isspectator_ = is; }
 
-  void AddBorder2D(const std::array<double, 2> &border2D) {
+  void AddBorder2D(const std::array<double, 2>& border2D) {
     borders2d_.push_back(border2D);
-    if (!isinitialized2D_) isinitialized2D_ = true;
+    if(!isinitialized2D_) { isinitialized2D_ = true; }
   }
 
-  const std::vector<std::array<double, 2>> &GetBorders2D() const { return borders2d_; };
+  const std::vector<std::array<double, 2>>& GetBorders2D() const { return borders2d_; };
 
   void SetMax(double x, double y) {
     xmax_ = x;
     ymax_ = y;
   }
 
-  static Getter *Create1DGetter(std::vector<double> borders);
+  static Getter* Create1DGetter(std::vector<double> borders);
 
  private:
-
   TAxis borders_;
   std::vector<std::array<double, 2>> borders2d_{};
   std::vector<double> ranges_{};
@@ -66,8 +64,7 @@ class Getter : public TObject {
   bool isinitialized2D_{false};
 
  ClassDef(Getter, 2);
-
 };
-}
+}// namespace Centrality
 
-#endif //CENTRALITY_GETTER_H
+#endif//CENTRALITY_GETTER_H
diff --git a/tasks/CMakeLists.txt b/tasks/CMakeLists.txt
new file mode 100644
index 0000000..47fab07
--- /dev/null
+++ b/tasks/CMakeLists.txt
@@ -0,0 +1,22 @@
+# Create a main program using the library
+add_executable(main main.cpp)
+target_link_libraries(main Centrality ${ROOT_LIBRARIES})
+target_include_directories(main PUBLIC ${CMAKE_SOURCE_DIR}/src)
+
+add_executable(glauber glauber.cpp)
+target_link_libraries(glauber ${ROOT_LIBRARIES} Centrality)
+target_include_directories(glauber PUBLIC ${CMAKE_SOURCE_DIR}/src)
+
+if (1)
+    #    include(AnalysisTree)
+
+    add_executable(fill_centrality fill_centrality.cpp)
+    target_link_libraries(fill_centrality Centrality ATCentrality AnalysisTreeBase AnalysisTreeInfra ${ROOT_LIBRARIES})
+    target_include_directories(fill_centrality PUBLIC ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/at_interface ${PROJECT_INCLUDE_DIRECTORIES})
+
+    install(TARGETS fill_centrality RUNTIME DESTINATION bin)
+endif ()
+
+
+install(TARGETS glauber RUNTIME DESTINATION bin)
+install(TARGETS main RUNTIME DESTINATION bin)
\ No newline at end of file
diff --git a/tasks/fill_centrality.cpp b/tasks/fill_centrality.cpp
new file mode 100644
index 0000000..3ca961f
--- /dev/null
+++ b/tasks/fill_centrality.cpp
@@ -0,0 +1,36 @@
+#include "CentralityFiller.hpp"
+#include "AnalysisTree/TaskManager.hpp"
+
+using namespace AnalysisTree;
+
+void fill_centrality(const std::string& filelist, const std::string& centrality_file, const std::string& output) {
+
+  auto* man = TaskManager::GetInstance();
+  man->SetOutputName(output, "aTree");
+  man->SetOutputTreeConfig(OutputTreeConfig(eBranchWriteMode::kCopyTree));
+
+  auto* task = new CentralityFiller(centrality_file, "centr_getter_1d");
+  task->SetInput("RecEventHeader", "M");
+  task->SetOutput("AnaEventHeader", "centrality_tracks");
+
+  man->AddTask(task);
+
+  man->Init({filelist}, {"rTree"});
+  man->Run(-1);
+  man->Finish();
+}
+
+int main(int argc, char** argv) {
+  if(argc <= 2) {
+    std::cout << "Not enough arguments! Please use:" << std::endl;
+    std::cout << "   ./fill_centrality filelist centrality_file" << std::endl;
+    return EXIT_FAILURE;
+  }
+
+  const std::string filelist = argv[1];
+  const std::string centrality_file = argv[2];
+  const std::string output_file = "centrality.analysistree.root";
+
+  fill_centrality(filelist, centrality_file, output_file);
+  return EXIT_SUCCESS;
+}
diff --git a/glauber/main.cpp b/tasks/glauber.cpp
similarity index 83%
rename from glauber/main.cpp
rename to tasks/glauber.cpp
index 0229eb2..dcc75e8 100644
--- a/glauber/main.cpp
+++ b/tasks/glauber.cpp
@@ -1,17 +1,17 @@
-#include <iostream>
 #include <chrono>
+#include <iostream>
 
-#include "Fitter.h"
-#include "FitterHelper.h"
+#include "Fitter.hpp"
+#include "FitterHelper.hpp"
 
-#include "TH1.h"
 #include "TFile.h"
+#include "TH1.h"
 #include "TLegend.h"
-#include "TH2.h"
+
 using namespace Glauber;
 
-int main(int argc, char *argv[]) {
-  if (argc < 2) {
+int main(int argc, char* argv[]) {
+  if(argc < 2) {
     std::cout << "Wrong number of parameters! Executable usage:" << std::endl;
     std::cout << "   ./glauber f0 k0" << std::endl;
     return -1;
@@ -31,13 +31,13 @@ int main(int argc, char *argv[]) {
   ///  |   Ncoll   |     Ncoll^f           |
   const TString mode = "Default";
 
-  const TString glauber_filename = "../input/glauber_auau_sigma_30_100k.root";   // input files
+  const TString glauber_filename = "../input/glauber_auau_sigma_30_100k.root";// input files
   const TString glauber_treename = "nt_Au_Au";
   const TString in_filename = "../input/test_input.root";
   const TString histoname = "hMreco";
 
-  const Int_t min_bin = 50;      // not fitting low multiplicity region due to trigger bias, etc
-  const Int_t max_bin = 10000;   // very large number to fit the whole histo
+  const Int_t min_bin = 50;   // not fitting low multiplicity region due to trigger bias, etc
+  const Int_t max_bin = 10000;// very large number to fit the whole histo
   const Int_t nevents = 100000;
 
   const TString outdir = ".";
@@ -45,10 +45,10 @@ int main(int argc, char *argv[]) {
   // *****************************************
 
   std::unique_ptr<TFile> glauber_file{TFile::Open(glauber_filename, "read")};
-  std::unique_ptr<TTree> glauber_tree{(TTree *) glauber_file->Get(glauber_treename)};
+  std::unique_ptr<TTree> glauber_tree{(TTree*) glauber_file->Get(glauber_treename)};
 
   std::unique_ptr<TFile> f{TFile::Open(in_filename)};
-  TH1F *hdata = (TH1F *) f->Get(histoname);
+  TH1F* hdata = (TH1F*) f->Get(histoname);
 
   Fitter fitter(std::move(glauber_tree));
 
diff --git a/main.cpp b/tasks/main.cpp
similarity index 70%
rename from main.cpp
rename to tasks/main.cpp
index 28d55ac..89e0c46 100644
--- a/main.cpp
+++ b/tasks/main.cpp
@@ -1,21 +1,20 @@
-#include "Getter.h"
-#include "BordersFinder.h"
-#include "BordersFinder2D.h"
+#include "BordersFinder.hpp"
+#include "BordersFinder2D.hpp"
+#include "Getter.hpp"
 
-#include <iostream>
-#include <vector>
-#include <random>
 #include <array>
-#include <iomanip>
 #include <chrono>
+#include <iomanip>
+#include <iostream>
+#include <random>
 
-#include <TSystem.h>
-#include <TROOT.h>
-#include "TTree.h"
 #include "TFile.h"
 #include "TH2.h"
+#include "TTree.h"
+#include <TROOT.h>
+#include <TSystem.h>
 
-int main(int argc, char **argv) {
+int main(int argc, char** argv) {
 
   auto start = std::chrono::system_clock::now();
   ROOT::EnableImplicitMT(2);
@@ -23,7 +22,7 @@ int main(int argc, char **argv) {
   if(argc <= 4) {
     std::cout << "Not enough arguments! Please use:" << std::endl;
     std::cout << "   ./main filename histoname is_spectator is2d" << std::endl;
-    return - 1;
+    return -1;
   }
 
   const char* filename{argv[1]};
@@ -33,34 +32,33 @@ int main(int argc, char **argv) {
 
   std::unique_ptr<TFile> fIn{TFile::Open(filename, "read")};
   std::string outfilename = "test.root";
-  if(! is_2d) {
+  if(!is_2d) {
     std::unique_ptr<TH1F> histo{(TH1F*) (fIn->Get(histoname))};
     Centrality::BordersFinder bf;
     bf.SetHisto(*histo);
-    bf.SetRanges(20, 0, 100);   // number of bins, min, max value
+    bf.SetRanges(20, 0, 100);// number of bins, min, max value
     //   bf.SetRanges( {0,10,30,60,100} );  // centrality bins borders with array
-    bf.IsSpectator(is_spectator);  // true if impact parameter b correlated with estimator (spectators eneggy),
-    // false - anticorrelated (multiplicity of produced particles) 
+    bf.IsSpectator(is_spectator);// true if impact parameter b correlated with estimator (spectators eneggy),
+    // false - anticorrelated (multiplicity of produced particles)
 
     bf.FindBorders();
     bf.SaveBorders(outfilename, "centr_getter_1d");
-  } else
-  {
-    std::unique_ptr <TH2F> histo2d {(TH2F*) (fIn->Get(argv[2]))};
+  } else {
+    std::unique_ptr<TH2F> histo2d{(TH2F*) (fIn->Get(argv[2]))};
     Centrality::BordersFinder2D bf;
-    bf.SetHisto2D( std::move(*histo2d) );
+    bf.SetHisto2D(std::move(*histo2d));
     std::unique_ptr<TH1F> h1d = bf.Convert();
-    
+
     bf.SetHisto(*h1d);
-    bf.SetRanges( 20,0,100 );   // number of bins, min, max value
+    bf.SetRanges(20, 0, 100);// number of bins, min, max value
     //   bf.SetRanges( {0,10,30,60,100} );  // centrality bins borders with array
-    bf.IsSpectator(false);  // true if impact parameter b correlated with estimator (spectators eneggy), 
-    // false - anticorrelated (multiplicity of produced particles) 
-    
+    bf.IsSpectator(is_spectator);// true if impact parameter b correlated with estimator (spectators energy),
+    // false - anticorrelated (multiplicity of produced particles)
+
     bf.FindBorders();
     bf.SaveBorders2D(outfilename, "centr_getter_2d");
   }
-  
+
   auto end = std::chrono::system_clock::now();
   std::chrono::duration<double> elapsed_seconds = end - start;
   std::cout << "elapsed time: " << elapsed_seconds.count() << " s\n";
-- 
GitLab