Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • pwg-c2f/analysis/centrality
  • o.lubynets/centrality
2 results
Show changes
Commits on Source (11)
Showing
with 417 additions and 202 deletions
# 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
<?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
cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.5)
project(Centrality)
set(CMAKE_MACOSX_RPATH 1)
set(PROJECT_VERSION 1.0)
......@@ -12,97 +12,46 @@ 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})
include_directories(${CMAKE_SOURCE_DIR} ${ROOT_INCLUDE_DIRS})
set(DICT_FILE_NAME G__${PROJECT_NAME})
set(PCM_FILE_NAME lib${PROJECT_NAME})
ROOT_GENERATE_DICTIONARY(${DICT_FILE_NAME} ${HEADERS} LINKDEF src/CentralityLinkDef.h)
add_library(Centrality SHARED ${SOURCES} ${DICT_FILE_NAME})
target_link_libraries(Centrality ${ROOT_LIBRARIES})
# 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)
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
)
if (NOT AnalysisTree_FOUND)
message(STATUS "AnalysisTree is not found")
else ()
add_subdirectory(at_interface)
endif ()
install(
FILES
${HEADERS}
"${CMAKE_CURRENT_BINARY_DIR}/centrality_export.h"
DESTINATION
include/centrality
COMPONENT
Devel
)
add_subdirectory(src)
add_subdirectory(tasks)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PCM_FILE_NAME}_rdict.pcm"
"${CMAKE_CURRENT_BINARY_DIR}/${PCM_FILE_NAME}.rootmap"
DESTINATION
lib
OPTIONAL
......@@ -118,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")
......@@ -127,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
......@@ -148,5 +96,3 @@ install(FILES
Devel
)
install(TARGETS glauber RUNTIME DESTINATION bin)
install(TARGETS main RUNTIME DESTINATION bin)
\ No newline at end of file
# !!! NEW REPOSITORY
https://github.com/HeavyIonAnalysis/Centrality
# Centrality Framework
## Installation
......
......@@ -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
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
#)
#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
#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_
# 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:
......
File moved
#include "FitterHelper.h"
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
......@@ -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
......@@ -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.;
......
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");
......
File moved
......@@ -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();
}
{
const TString dir = "../build/";
gSystem->
Load( dir
+"libCentrality.so");
Load(dir
+ "libCentrality.so");
}
#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,10 +23,10 @@ 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);
x[i] = axis->GetBinLowEdge(i + 1);
}
TGraph intVsXGraph(n, x, histIntegral);
......@@ -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