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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ if(roofit)
endif()

ROOT_ADD_TEST_SUBDIRECTORY(test)
ROOT_ADD_TEST_SUBDIRECTORY(tutorials)

# Each subdirectory added above will register headers to be copied to the build tree.
# Here, the copy targets are created:
Expand Down Expand Up @@ -574,6 +573,8 @@ if(runtime_cxxmodules)
set_directory_properties(PROPERTIES ADDITIONAL_CLEAN_FILES "${library_output_dir}/modules.timestamp")
endif()

ROOT_ADD_TEST_SUBDIRECTORY(tutorials)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a comment why this is here and not next to the 'other' ROOT_ADD_TEST_SUBDIRECTORY ...


#---hsimple.root---------(use the executable for clearer dependencies and proper return code)---
add_custom_target(hsimple ALL DEPENDS tutorials/hsimple.root)
add_dependencies(hsimple onepcm)
Expand Down
11 changes: 10 additions & 1 deletion tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ if(DEFINED ROOT_SOURCE_DIR) # Testing using the binary tree
set(ROOT_environ PATH=${CMAKE_BINARY_DIR}/bin:$ENV{PATH}
${ld_library_path}=${CMAKE_BINARY_DIR}/lib:$ENV{${ld_library_path}}
ROOTSYS=${CMAKE_BINARY_DIR}
ROOT_INCLUDE_PATH=${CMAKE_BINARY_DIR}/tutorials/io/tree
PYTHONPATH=${CMAKE_BINARY_DIR}/lib:$ENV{PYTHONPATH})
else()
set(ROOT_environ ROOTSYS=${CMAKE_BINARY_DIR}
ROOT_INCLUDE_PATH=${CMAKE_BINARY_DIR}/tutorials/io/tree
PYTHONPATH=${CMAKE_BINARY_DIR}/bin;$ENV{PYTHONPATH})
endif()
else() # testing using an installation
Expand Down Expand Up @@ -423,7 +425,6 @@ set(extra_veto
io/tree/hsimpleProxy.C # A driver uses this macro which cannot be executed directly
io/tree/tree103_tree.C
io/tree/tree106_tree.C
io/tree/tree108_tree.C
roofit/roostats/rs401d_FeldmanCousins.C # Takes too much time
roofit/roostats/rs401d_FeldmanCousins.py
roofit/histfactory/ModifyInterpolation.C
Expand All @@ -437,6 +438,11 @@ set(extra_veto
math/r/rootlogon.C
roofit/roostats/StandardFrequentistDiscovery.C)

configure_file(${CMAKE_SOURCE_DIR}/test/Event.h ${CMAKE_BINARY_DIR}/tutorials/io/tree/Event.h COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/test/Event.cxx ${CMAKE_BINARY_DIR}/tutorials/io/tree/Event.cxx COPYONLY)
install(FILES ${CMAKE_SOURCE_DIR}/test/Event.h ${CMAKE_SOURCE_DIR}/test/Event.cxx
DESTINATION ${CMAKE_INSTALL_TUTDIR}/io/tree COMPONENT tests)

if(MSVC)
# disable run_h1analysis.C because of Endpoint Security HTTP traffic scanning,
# which is corrupting the data on Windows
Expand Down Expand Up @@ -549,6 +555,9 @@ set(io-xml-xmlmodifyfile-depends tutorial-io-xml-xmlnewfile)
set(io-xml-xmlreadfile-depends tutorial-io-xml-xmlnewfile)
set(roofit-roofit-rf503_wspaceread-depends tutorial-roofit-roofit-rf502_wspacewrite)
set(io-readCode-depends tutorial-io-importCode)
set(io-tree-tree110_copy-depends tutorial-io-tree-tree108_tree)
set(io-tree-tree111_copy-depends tutorial-io-tree-tree108_tree)
set(io-tree-tree112_copy-depends tutorial-io-tree-tree108_tree)
set(math-fit-fit1-depends tutorial-hist-hist001_TH1_fillrandom)
set(math-fit-myfit-depends tutorial-math-fit-fitslicesy)
set(math-foam-foam_demopers-depends tutorial-math-foam-foam_demo)
Expand Down
21 changes: 18 additions & 3 deletions tutorials/io/tree/tree108_tree.C
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@
///
/// \author Rene Brun

R__LOAD_LIBRARY($ROOTSYS/test/libEvent)

#ifdef ACTUAL_RUN // -------- Second pass: dictionary already built --------

#include "./Event.h" // now safe to include Event, its dictionary is loaded

#include "TFile.h"
#include "TTree.h"
Expand All @@ -59,7 +62,6 @@ R__LOAD_LIBRARY($ROOTSYS/test/libEvent)
#include "TClassTable.h"
#include "TSystem.h"
#include "TROOT.h"
#include "../test/Event.h"

void tree108_write()
{
Expand Down Expand Up @@ -168,10 +170,23 @@ void tree108_read()
t4->StartViewer();
}

void tree108_tree()
void run()
{
Event::Reset(); // Allow for re-run this script by cleaning static variables.
tree108_write();
Event::Reset(); // Allow for re-run this script by cleaning static variables.
tree108_read();
}

#else // -------- First pass: build dictionary + rerun macro --------

void tree108_tree()
{
TString tutdir = gROOT->GetTutorialDir();
gROOT->ProcessLine(".L " + tutdir + "/io/tree/Event.cxx+");
gROOT->ProcessLine("#define ACTUAL_RUN yes");
gROOT->ProcessLine("#include \"" __FILE__ "\"");
gROOT->ProcessLine("run()");
}

#endif
33 changes: 21 additions & 12 deletions tutorials/io/tree/tree110_copy.C
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,40 @@
///
/// \author Rene Brun

// Load the library at macro parsing time: we need this to use its content in the code
R__LOAD_LIBRARY($ROOTSYS/test/libEvent)
#ifdef ACTUAL_RUN // -------- Second pass: dictionary already built --------

void tree110_copy()
{

TString dir = "$ROOTSYS/test/Event.root";
gSystem->ExpandPathName(dir);
const auto filename = gSystem->AccessPathName(dir) ? "./Event.root" : "$ROOTSYS/test/Event.root";
#include "./Event.h" // now safe to include Event, its dictionary is loaded

TFile oldfile(filename);
void run()
{
TFile oldfile("tree108.root");
TTree *oldtree;
oldfile.GetObject("T", oldtree);
oldfile.GetObject("t4", oldtree);

// Deactivate all branches
oldtree->SetBranchStatus("*", 0);

// Activate only four of them
for (auto activeBranchName : {"event", "fNtrack", "fNseg", "fH"})
for (auto activeBranchName : {"event_split", "fNtrack", "fNseg", "fH"})
oldtree->SetBranchStatus(activeBranchName, 1);

// Create a new file + a clone of old tree in new file
TFile newfile("small.root", "recreate");
TFile newfile("tree110.root", "recreate");
auto newtree = oldtree->CloneTree();

newtree->Print();
newfile.Write();
}

#else // -------- First pass: build dictionary + rerun macro --------

void tree110_copy()
{
TString tutdir = gROOT->GetTutorialDir();
gROOT->ProcessLine(".L " + tutdir + "/io/tree/Event.cxx+");
gROOT->ProcessLine("#define ACTUAL_RUN yes");
gROOT->ProcessLine("#include \"" __FILE__ "\"");
gROOT->ProcessLine("run()");
}

#endif
33 changes: 21 additions & 12 deletions tutorials/io/tree/tree111_copy.C
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,23 @@
///
/// \author Rene Brun

// Load the library at macro parsing time: we need this to use its content in the code
R__LOAD_LIBRARY($ROOTSYS/test/libEvent)
#ifdef ACTUAL_RUN // -------- Second pass: dictionary already built --------

void tree111_copy()
{

TString dir = "$ROOTSYS/test/Event.root";
gSystem->ExpandPathName(dir);
const auto filename = gSystem->AccessPathName(dir) ? "./Event.root" : "$ROOTSYS/test/Event.root";
#include "./Event.h" // now safe to include Event, its dictionary is loaded

TFile oldfile(filename);
void run()
{
TFile oldfile("tree108.root");
TTree *oldtree;
oldfile.GetObject("T", oldtree);
oldfile.GetObject("t4", oldtree);

// Activate only four of them
for (auto activeBranchName : {"event", "fNtrack", "fNseg", "fH"}) {
for (auto activeBranchName : {"event_split", "fNtrack", "fNseg", "fH"}) {
oldtree->SetBranchStatus(activeBranchName, 1);
}

// Create a new file + a clone of old tree header. Do not copy events
TFile newfile("small.root", "recreate");
TFile newfile("tree111.root", "recreate");
auto newtree = oldtree->CloneTree(0);

// Divert branch fH to a separate file and copy all events
Expand All @@ -41,3 +37,16 @@ void tree111_copy()
newtree->Print();
newfile.Write();
}

#else // -------- First pass: build dictionary + rerun macro --------

void tree111_copy()
{
TString tutdir = gROOT->GetTutorialDir();
gROOT->ProcessLine(".L " + tutdir + "/io/tree/Event.cxx+");
gROOT->ProcessLine("#define ACTUAL_RUN yes");
gROOT->ProcessLine("#include \"" __FILE__ "\"");
gROOT->ProcessLine("run()");
}

#endif
32 changes: 21 additions & 11 deletions tutorials/io/tree/tree112_copy.C
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,23 @@
///
/// \author Rene Brun

R__LOAD_LIBRARY($ROOTSYS/test/libEvent)
#ifdef ACTUAL_RUN // -------- Second pass: dictionary already built --------

void tree112_copy()
{
// Get old file, old tree and set top branch address
TString dir = "$ROOTSYS/test/Event.root";
gSystem->ExpandPathName(dir);
const auto filename = gSystem->AccessPathName(dir) ? "./Event.root" : "$ROOTSYS/test/Event.root";
#include "./Event.h" // now safe to include Event, its dictionary is loaded

TFile oldfile(filename);
void run()
{
TFile oldfile("tree108.root");
TTree *oldtree;
oldfile.GetObject("T", oldtree);
oldfile.GetObject("t4", oldtree);

const auto nentries = oldtree->GetEntries();

Event *event = nullptr;
oldtree->SetBranchAddress("event", &event);
oldtree->SetBranchAddress("event_split", &event);

// Create a new file + a clone of old tree in new file
TFile newfile("small.root", "recreate");
TFile newfile("tree112.root", "recreate");
auto newtree = oldtree->CloneTree(0);

for (auto i : ROOT::TSeqI(nentries)) {
Expand All @@ -43,3 +40,16 @@ void tree112_copy()
newtree->Print();
newfile.Write();
}

#else // -------- First pass: build dictionary + rerun macro --------

void tree112_copy()
{
TString tutdir = gROOT->GetTutorialDir();
gROOT->ProcessLine(".L " + tutdir + "/io/tree/Event.cxx+");
gROOT->ProcessLine("#define ACTUAL_RUN yes");
gROOT->ProcessLine("#include \"" __FILE__ "\"");
gROOT->ProcessLine("run()");
}

#endif
Loading