ROOT/심화

상위 문서: ROOT


rootlogon.C

rootlogon.C 가 있는 디렉토리에서 root 를 실행하면, 매크로나 인터프리터 실행 전에 자동으로 rootlogon.C 를 먼저 실행합니다.

root-config

$ root-config
Usage: root-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags]
[--auxcflags] [--ldflags] [--new] [--nonew] [--libs] [--glibs] [--evelibs]
[--bindir] [--libdir] [--incdir] [--etcdir] [--tutdir] [--srcdir] [--noauxcflags] 
[--noauxlibs] [--noldflags] [--has-<feature>] [--arch] [--platform] [--config] 
[--features] [--ncpu] [--git-revision] [--python-version] [--python2-version] 
[--python3-version] [--cc] [--cxx] [--f77] [--ld ] [--help]

Designing Graphics: Visualizer Cosmetics

User-defined TStyle

#include "TStyle.h"
#include "TROOT.h"
#include "TColor.h"
#include "iostream"

TStyle* SetStyle(){// Add my own options here:
    TStyle* mcStyle = new TStyle("mcStyle","Style");
    Style_t font = 42;
    Float_t labelfontsize = 0.02;
    Float_t titlefontsize = 0.02;
    // mcStyle->SetPalette(0.5,0); // avoid horrible default color schem 
    mcStyle->SetOptStat(0);
    mcStyle->SetOptTitle(0);
    mcStyle->SetOptDate(0);
    mcStyle->SetLabelSize(labelfontsize,"xyz"); // size of axis value font 
    mcStyle->SetTitleSize(titlefontsize,"xyz"); // size of axis title font 
    mcStyle->SetLabelFont(font,"xyz");
    mcStyle->SetTitleFont(font,"xyz");
    mcStyle->SetTitleOffset(1.2,"y"); // default canvas options
    mcStyle->SetCanvasDefW(500); 
    mcStyle->SetCanvasDefH(500);
    mcStyle->SetCanvasColor(0); // canvas... 
    mcStyle->SetCanvasBorderMode(0); 
    mcStyle->SetCanvasBorderSize(0); 
    mcStyle->SetPadBorderMode(0);
    mcStyle->SetPadBorderSize(0);
    mcStyle->SetPadBottomMargin(0.05); //margins... 
    mcStyle->SetPadTopMargin(0.05); 
    // mcStyle->SetPadLeftMargin(0.05); 
    mcStyle->SetPadRightMargin(0.20); 
    // mcStyle->SetPadRightMargin(0.05); 
    mcStyle->SetPadGridX(0); // grids, tickmarks 
    mcStyle->SetPadGridY(0); 
    mcStyle->SetPadTickX(0); 
    mcStyle->SetPadTickY(0); 
    mcStyle->SetFrameBorderMode(0); 
    mcStyle->SetPaperSize(20,24); // US letter size 
    mcStyle->SetLegendBorderSize(1);
    mcStyle->SetLegendFont(font);
    
    

    gROOT->SetStyle("mcStyle");

    const Int_t NRGBs = 5;
    const Int_t NCont = 255;
    Double_t stops[NRGBs] = { 0.00, 0.30, 0.61, 0.84, 1.00 };
    Double_t red[NRGBs] = { 0.00, 0.00, 0.57, 0.90, 0.51 };
    Double_t green[NRGBs] = { 0.00, 0.65, 0.95, 0.20, 0.00 };
    Double_t blue[NRGBs] = { 0.51, 0.55, 0.15, 0.00, 0.10 };
    TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
    gStyle->SetNumberContours(NCont);
    
    std::cout << "Styles are Set!" << std::endl;
    return mcStyle; 
}

Load pre-compiled library in root interpreter

TString libFilename = "libMyLibName";
    
TString DirName = TString(gSystem->GetWorkingDirectory());
if( !(DirName.EndsWith("/build") || DirName.EndsWith("/build/")) ){
    DirName = DirName + TString("/build/");
}
if( !(DirName.EndsWith("/")) ){
    DirName = DirName + TString("/");
}
  
TString libIncludePath = TString::Format("%sinclude", DirName.Data());
TString libLoadPath = TString::Format("%s%s", DirName.Data(), libFilename.Data());

gInterpreter->AddIncludePath(libIncludePath);
gInterpreter->Load(libLoadPath, true);
gSystem->Load(libLoadPath);

Use ROOT as external library with cmake

cmake_minimum_required(VERSION 3.2)

project(myproject)

# by default build optimized code with debug symbols
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE DEBUG)
  # set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
  # set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

# require C++11-capable compiler
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
    message(WARNING "Compiler with incomplete C++11 support detected: functionality limited")
    set(OLD_CXX true)
  endif()
endif()

if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
  message("clang, undefined dynamic_lookup")
  set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup")
endif()

find_package(ROOT)

set(CMAKE_CXX_STANDARD 11)
if(ROOT_cxx17_FOUND)
  set(CMAKE_CXX_STANDARD 17)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
elseif(ROOT_cxx14_FOUND)
  set(CMAKE_CXX_STANDARD 14)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
elseif(ROOT_cxx11_FOUND)
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
message(STATUS "Using C++${CMAKE_CXX_STANDARD}")

file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hpp)
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cpp)

add_library(MyLibName SHARED ${sources})

include_directories(include)

target_link_libraries(MyLibName PUBLIC ROOT::Core ROOT::Hist ROOT::Graf)