Previous Page
17 rdf2root (in Linux)
  • 07 Mar 2011 10:22:51

Here is my log file for installing rdf, some C++ classes for converting babarl formatted data into ROOT trees. It was coded by Jonty Pearson, and also updated by Jun Chen and myself.

Purpose of the code

If you have rdf data collected by Babarl, chances are anyone local (besides me!!) is using ANAPAW to analyze the data. Personally, I hate Fortran, and while I think there are problems with ROOT, I find ROOT much more powerful than ANAPAW. But likely all the local experiments are only decoding the rdf data into a format ANAPAW can understand. If you want to do more low-level analysis than is available from, say, the h2root command, that's where this program comes in. If you can take about 1 day to understand the rdf program here and understand your channel mapping in the raw data, then you can convert rdf data directly into ROOT trees.

Getting the code

I have hosted the latest source code. Since it's using MySQL tables to control detectors, please make a symlink 'sql' to one of the other sql directories. This must be changed the MySQL tables updated for each different data set. You can only use one at a time. This is why I don't just give you everything in one sql directory.

Preparing your system

You may generally follow these instructions for Mac OS, but I have additional notes on rdf for Mac OS, and also Mac OS notes for MySQL.

Install MySQL, ideally through a package manager such as portage, apt-get, or rpm.

Setup /etc/mysql/my.cnf (may steal from daid). The main thing you need here is the port to be 3306 and to allow user login with passwords, so if your installation of MySQL comes with a decent my.cnf file, just look at mine for these two points.

Setup your profile for MySQL, ROOT

$ vi ~/.bashrc

        export MYSQL_TCP_PORT=3306

        export MYSQL="/usr/include/mysql:/usr/lib/mysql"

        export ROOTSYS="/usr"

        export ROOT_LIBRARIES="/usr/lib/root"

        export LD_LIBRARY_PATH="/usr/lib:$LD_LIBRARY_PATH"

$ source ~/.bashrc

You might need to be using bash or zsh, otherwise the rdf-1.0 install script will not work. You could re-write the installation script in csh or tcsh, but I wouldn't recommend it.

(It may be /usr/mysql/include and /usr/mysql/lib depending on your *nix distribution. Check these directories to determine where mysql is installed. Your ROOT directories may also differ. Change as appropriate.)

If you already have ROOT installed, but did not have the MYSQL variable exported during the ROOT installation, I think you will need to re-install ROOT. Otherwise you will eventually get rdf-1.0 build errors like "Cannot find -lRMySQL". You may try to continue without rebuilding, but keep this error in mind, since I told you the solution just now!

ROOT installation in Gentoo Linux

If you install ROOT through portage (only on Gentoo), then you can just

# USE=mysql emerge root

Because portage is amazing like that; really you should put the USE flag under /etc/make.conf for /etc/portage/package.use/root

ROOT installation in any Linux systems

For any Linux system you can manually compile ROOT (this takes an hour or more, depending on your hardware). I think something like this is correct, once you are inside the root directory:

sudo ./configure linux --enable-mysql

Once MySQL is installed (and ROOT is installed with MySQL dependencies), you must run the MySQL daemon

$ sudo /etc/init.d/mysql start

It may be called mysqld on your system. I also suggest adding it to a run-level so you don't need to do this every time your computer starts (an article overviewing runlevels in Linux and init).

If you have nmap installed, you can check to see if mysql is running on port 3306 if you want to confirm

$ nmap -PN localhost

Then you may log in to MySQL, specifying the root user, which is the only user setup by default. Note that this root user is unrelated to CERN's analysis package ROOT, and also unrelated to the root user of the *nix system; sorry it's confusing — not my fault! All mysql commands need to end in a semi-colon ;

$ mysql -u root

Then, once in mysql, you should set a password for root (replace MyNewPass with your preferred password)

mysql > UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root';


Now make a new user, with a password 'yourpassword' (for use with rdf, it's easiest if you use the user 'crib' and the standard crib password, unless you want to go digging through the rdf source code...):

mysql > GRANT ALL PRIVILEGES ON *.* TO 'crib'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

Now you may log out of mysql

mysql > quit

Re-login as crib

$ mysql -u crib -p

Enter the password you created

View the default databases

mysql > SHOW databases;

Add a new database called 'crib'

mysql> CREATE database crib;

Confirm that there is now a database called 'crib'

mysql > SHOW databases;

Then you can log out.

mysql > quit

Now you need to install Jonty's rdf-1.0 package.

Installing rdf

I have hosted the latest source code.

$ tar -xvzf rdf-1.0.tar.gz && cd rdf-1.0

Since rdf is using MySQL tables to control detectors, please make a symlink 'sql' to one of the other sql directories.

$ ln -s sql_sample1 sql

This must be changed and the MySQL tables updated for each different data set. You can only use one at a time. This is why I don't just give you everything in one sql directory. Anyway, now we can configure and install the program

$ ./configure

$ sudo make install-strip

You can use the --prefix option to change the install location (read README!).

You need to add all the .sql files in sql to the sql database crib you created. Do this like:

$ cd sql

$ mysql -u crib -p < ssd.sql

$ mysql -u crib -p < psd.sql

$ mysql -u crib -p < ppac.sql

$ mysql -u crib -p < nai.sql

Any time you change an sql file, you must update the database again for that file. There is even a reminder comment at the top of each sql file telling you this!

Testing rdf on some samples

Now that the rdf-1.0 package is installed, you are prepared to use the rdf2root macros to convert your data!

Since I'm such a nice person, I've hosted not just one sample rdf2root macro, but two sample rdf2root macros. Obviously from the file names I assume you can figure out which sql in the rdf-1.0 directory are corresponding. And no, I won't tell you any of the actual physical conditions for those runs, if they were any good, or why we wanted to get that data, so don't ask. Included with each tar.gz is an rdf data set you can test the macros on.

Obviously, if you can't make those macros work with the corresponding sql databases, then you are doing something very wrong.

Change lines in sort_rdf_files.C or rdf2root.C like:


to match your own directory structure...

Mainly I expect you'd be using the sort_rdf_files.C as a ROOT macro to check that the data is converted correctly, and then calling rdf2root.C via run_rdf2root.C. For the first case, I only was using sort_rdf_files.C to check some parameters in the raw data, so I did not create a rdf2root.C for sample1. The sort_rdf_files.C could also be used as a prototype for an online analysis macro, since it is converting the data and filling histograms straight away. The rdf2root.C is for offline analysis, and you'd need to write code to fill histograms and analyse the data separately

Inside root:

root [0] .x sort_rdf_files.C+

Make sure to use the + or get horrible errors!

You can email me asking for some sample analysis code, but if you aren't a collaborator, don't get your hopes up.

Using rdf for your own data

Sadly, I cannot give you too much instruction here, but I will try my best. Basically most your work will be with the sql databases trying to get the correct channel maps. Use sort_rdf_files.C to check the mappings. Once you are happy, then you should use rdf2root.C to actually convert all the runs, and use a separate code for analysis.

I will try to expand this section in the future.

        (__)               __(^^)              /   /    (__)      / PhD  \  (oO)     /|  /---^^---/     / | /| daid  ||    *  || ||------||
Next pageNext page