You are here

Frequently Asked Questions

A dictionary is a source file that once compiled, linked into a library or executable and loaded into a process will give to CINT all the information its need about a type or variable. A dictionary is essential for a C++ to entity to useable from a CINT script or to be Streamed in or out of a ROOT file.

You have 3 options to create a dictionary.

Use ACLiC to generate the dictionary for everything defined in a source or header file:

root [] .L myScript.cxx+

or (from compiled code):

gROOT->ProcessLine(".L myScript.cxx+")
To generate the dictionary for a single class or for a class template instance use (with ROOT v5.27/06 and above):
To generate the dictionary from a Makefile, you can use the following rule to generate a dictionary for the headers $(HEADERS) and a library containing the dictionary and the compiled $(SOURCES):
MyDict.cxx: $(HEADERS) Linkdef.h
[TAB]     rootcint -f $@ -c $(CXXFLAGS) -p $^ MyDict.cxx $(SOURCES)
[TAB]     g++ -shared -o$@ `root-config --ldflags` $(CXXFLAGS) -I$(ROOTSYS)/include $^

See Interacting with Shared Libraries: rootcint for more details.

This usually indicates that some classes dictionary refer and/or use this particular instance of std::vector.

To solve the problem, you will need to generate a dictionary for this particular instance. With ROOT v5.27/06 and above this can be done by executing:
With older version of ROOT ; this can simply be done using ACLiC and a simple loader.C script:
// File loader.C
#ifdef __MAKECINT__
#pragma link C++ class vector<Track>+;
I am defining a vector for my custom type (for example Track) in a root macro but when I push_back a Track object in the vector, CINT complains. e.g.
vector testVector;
Track obj;
Error: Can't call vector::push_back(timeStamp) in current scope MyAnalysisMasterTreeMaker.C:358:
Possible candidates are...
(in vector)
*** Interpreter error recovered ***
Although, if I use a vector or vector or vector push_back works fine.
TFolder manages a hierrachy of objects in memory. TDirectory is doing it for a file. One can save the TFolder structure to a directory in a file.

Absolutely. The CMake command find_package() will set all needed ROOT related variables, which can be used to compile and link one's own code. An example from the ROOT Event example (found in root/test) can be downloaded here. Just un-tar the attached file and run:

cd event/build
cmake ..
I use CMake to build my own code, and I would like to use ROOT in that code. Is there a way to wire ROOT into the CMake build files? Something like FindROOT.cmake?

Enable /proc/sys/kernel/yama/ptrace_scope or edit /etc/sysctl.d/10-ptrace.conf. See this blog entry for details.

Disable the title and add yourself your own title with a TPaveLabel:

   TPaveLabel *title = new TPaveLabel(.11,.95,.35,.99,"new title","brndc");
Changing the Displayed Title in Canvas.

Microsoft's STL classes (std::string, std::vector,...) are different for debug and optimized mode. When calling a ROOT function that expects a STL object as an argument, the caller (e.g. your code) and ROOT must agree on what the object looks like. Thus if you link against ROOT libraries built as debug (non-debug) you must also compile your code as debug (non-debug). ACLiC does that automatically for you.

Type at the ROOT prompt:

   root [0] TProof::Open("")
How do I start PROOF?

The configure command should specify explicitly where ROOT should find all X11-related libs

./configure --with-x11-libdir=/opt/local/lib/ 
A simple Draw(0 or a Browser opening might cause a Segmentation violation in TASImage::InitVisual () on Mac.

To successfully build ROOT a number of prerequisite packages must be installed. Check the prerequisites page for the list of packages needed for your platform.

Run in batch mode:

root -b -q myscript.C
or in your program add:

   if (gROOT->GetListOfFiles()->FindObject(filename) ) {
      // do not open the file
   } else {
      // open the file

The easiest way is to use cmake and let it create the Xcode project, this has the advantage that the dictionaries are created automatically. The CMakeLists.txt file will define the libraries and executables to be added to the Xcode project. An example from the ROOT Event example (found in root/test) can be downloaded here. Just un-tar the attached file and run

cd event/build
cmake -G Xcode ..

This will create an Xcode project event.xcodeproj which can be opened and used by Xcode.

It is enough to change the title of the histogram htemp:

htemp.SetTitle("New Title");

You probably used ssh to connect to the remote computer. You need to specify the option "-Y" which turns on trusted X11 forwarding.

Some or all windows don't get displayed when ROOT is running on a remote computer.

There is a translation of the FAQ in Belorussian by Paul Bukhovko. We hope the example of Paul will be followed by other translations.