Project

General

Profile

Setting Up and Running FluxReader » History » Version 37

« Previous - Version 37/39 (diff) - Next » - Current version
Kuldeep Maan, 11/17/2015 04:03 PM


Checking Out and Building FluxReader (1st Build)

In order to use FluxReader, it must first be checked out. To do this, it is first necessary to create a directory where FluxReader will live. This can be in a experiment's test release, or it can be in a user's home directory. Once it has been decided where FluxReader will go, it can be checked out.

If FluxReader will have its own area, run the following command:

% mkdir /path/to/FluxReaderRelease

To check out FluxReader, run the following commands:

% cd /path/to/FluxReaderRelease
% svn co http://cdcvs.fnal.gov/subversion/fluxreader/trunk/FluxReader

Before building FluxReader, the proper environment needs to be set up. Dk2Nu, and therefore FluxReader, depends on specific versions of ROOT and GENIE. The shell script, SetupFluxReader.sh, sets up the proper versions (so long as it is up to date). When using tagged code, then, it is also important to get the tagged version of FluxReader, otherwise there may be errors at compile or run time. This script also ensures that the environment variable $DK2NU is set, which is necessary for running scripts. The script sets up other environmental variables as well, but $DK2NU is likely the only one the user will reference. To set up the proper environment, run the following commands:

% cd /path/to/FluxReader/
% source SetupFluxReader.sh

To build FluxReader for the first time, run the following commands (and note the period on the cmake line!):

% cd /path/to/FluxReader/
% cmake .
% gmake all

Note that when the code is first checked out from the repository, only following files should be present. If the file sizes differ, don't worry; there may have been edits to the code since writing this Wiki. The important thing is the file names.

% ls -alFGh
total 44K
drwxr-xr-x 7 gkafka 2.0K Aug  6 13:28 ./
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 ../
-rw-r--r-- 1 gkafka 2.4K Aug  6 13:28 CMakeLists.txt
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 Demo/
-rw-r--r-- 1 gkafka 1.3K Aug  6 13:28 FluxReaderTemplate.C
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 include/
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 lib/
-rw-r--r-- 1 gkafka 1.8K Aug  6 13:28 load_flxrd.C
-rwxr-xr-x 1 gkafka  166 Aug  6 13:28 SetupFluxReader.sh*
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 src/
drwxr-xr-x 6 gkafka 2.0K Aug  6 13:28 .svn/

After running the cmake command, some additional files will appear.

% ls -alFGh
total 88K
drwxr-xr-x 8 gkafka 2.0K Aug  6 13:30 ./
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 ../
-rw-r--r-- 1 gkafka  13K Aug  6 13:30 CMakeCache.txt
drwxr-xr-x 6 gkafka 4.0K Aug  6 13:31 CMakeFiles/
-rw-r--r-- 1 gkafka 2.7K Aug  6 13:30 cmake_install.cmake
-rw-r--r-- 1 gkafka 2.4K Aug  6 13:28 CMakeLists.txt
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 Demo/
-rw-r--r-- 1 gkafka 1.3K Aug  6 13:28 FluxReaderTemplate.C
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 include/
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:31 lib/
-rw-r--r-- 1 gkafka 1.8K Aug  6 13:28 load_flxrd.C
-rw-r--r-- 1 gkafka  20K Aug  6 13:30 Makefile
-rwxr-xr-x 1 gkafka  166 Aug  6 13:28 SetupFluxReader.sh*
drwxr-xr-x 3 gkafka 2.0K Aug  6 13:28 src/
drwxr-xr-x 6 gkafka 2.0K Aug  6 13:28 .svn/

In particular, the files/directories that are new are CMakeCache.txt, CMakeFiles, cmake_install.cmake, and Makefile. A library (libFluxReader.so) will also appear in the lib directory. These are all files/directories that the user should not need to alter, but should not remove. Simply leave them be!

Setting Up and Building FluxReader (After 1st Build)

Not much changes once FluxReader has been built the first time. In fact, the commands to set up and build FluxReader are nearly identical. The main difference is that when building FluxReader subsequent to the first time, the user has the option to perform a clean build. However, the user should ALWAYS be sure to set up the proper environment first. To do this, run the same commands as above:

% cd /path/to/FluxReader/
% source SetupFluxReader.sh

As long as the file Makefile exists, the user can perform a clean build. To do so, perform the following commands:

% cd /path/to/FluxReader/
% gmake clean

Then, to build the code again, run the following commands (and note the period on the cmake line!):

% cd /path/to/FluxReader/
% cmake .
% gmake all

If the user alters any files in the include or src directories, then a new build (not necessarily a clean build) is necessary. If, after performing the new build, there are some strange bugs, it is advised to try a clean build to make sure that this is not the cause of the problems.

It is possible to run commands that essentially perform a "hard reset." This method deletes all of the files generated by cmake, so that the next build is as if it is the first build. This set of commands should be used as a last resort. One of the commands deletes important files for building the code through use of the rm command. It is recommended that this line be copy/pasted in order to avoid removing other files that should not be deleted. The following commands should be run from a fresh terminal session.

% cd /path/to/FluxReader/
% source SetupFluxReader.sh
% gmake clean
% rm -rf CMakeCache.txt CMakeFiles/ cmake_install.cmake Makefile
% cmake .
% gmake all

Running Scripts

FluxReader is used by creating and running compiled ROOT macros (.C scripts). It is necessary to load/run load_flxrd.C before running any compiled script. This script, load_flxrd.C, is located in the FluxReader directory itself. Before running any of the scripts that come with FluxReader, make sure to edit the output file location to an area you have write permissions. Then to run any script, like the template FluxReaderTemplate.C, one would execute the command:

% root load_flxrd.C FluxReaderTemplate.C+

Note that this assumes that the current working directory is the top level of the FluxReader package! If this is not the current working directory, update the paths to the two scripts accordingly. For example, if the current working directory is one directory above the FluxReader directory, then the line above would become:

% root FluxReader/load_flxrd.C FluxReader/FluxReaderTemplate.C+

There are several demo scripts within the Demo directory. If the current working directory is the top level of the FluxReader package, then to run one of the demos, like the first one, Demo0_FluxReader.C, run the following command:

% root load_flxrd.C Demo/Demo0_FluxReader.C+

FluxReader can be run as a background process, and the output of FluxReader can be automatically directed into an output log file using the nohup command. Proper usage of this command allows jobs to finish, even after a terminal session is closed. To run the template script in the background and redirect output into a log file called mylog.txt, use the following command:

% nohup root load_flxrd.C FluxReaderTemplate.C+ >& mylog.txt &

Running the FluxReader job on Grid

You can run the FluxReader job on Grid using two bash scripts FRjob.sh and wrapper_NOvA_grid_FR.sh

FRjob.sh (Setting Required Environment Variables)

#!/bin/bash

whoami
hostname
date
ddate

umask 002 #Ensure that files are user and group writable by default

export DISPLAY=localhost0.0
export CPN=/grid/fermiapp/common/tools/cpn
export SRS_BASE=/nova/app/users/${USER}/FluxReaderRelease/FluxReader

#SetupFluxReader.sh
echo source ${SRS_BASE}/SetupFluxReader.sh
source ${SRS_BASE}/SetupFluxReader.sh

echo source
 mkdir ${_CONDOR_SCRATCH_DIR}/output
cd ${_CONDOR_SCRATCH_DIR}/output
echo Working in $PWD

# Need to copy FluxReader macro on ${_CONDOR_SCRATCH_DIR}/output/ to run FR.

 mkdir lib
${CPN}  ${SRS_BASE}/lib/libFluxReader.so lib/libFluxReader.so
${CPN} ${SRS_BASE}/load_flxrd.C   load_flxrd.C
${CPN} ${SRS_BASE}/FluxReaderTemplate.C FluxReaderTemplate.C

# Run root (must be in batch mode on the grid)
root -lbq load_flxrd.C FluxReaderTemplate.C+
ls

#set OUTPUT directory here, the script will make it if it doesn't already exist
export OUTPUT=/nova/ana/${USER}/FluxReaderouput
mkdir -p $OUTPUT
echo Writing to $OUTPUT

# Output file name i.e outputfile.root should be same as in FluxReaderTemplate.C
${CPN}  ${_CONDOR_SCRATCH_DIR}/output/outputfile.root  $OUTPUT/  

#clean ${_CONDOR_SCRATCH_DIR}/output/
rm -f ${_CONDOR_SCRATCH_DIR}/output/*.root
rm -f ${_CONDOR_SCRATCH_DIR}/output/*.C
rm -f ${_CONDOR_SCRATCH_DIR}/output/*.so

echo THE END

wrapper_NOvA_grid_FR.sh (Submit the job on grid)

#!/bin/bash
umask 002
source /grid/fermiapp/nova/novaart/novasvn/setup/setup_nova.sh
# This is wherever your FRjob.sh file lives
export MacroDir=/nova/app/users/${USER}/FluxReaderRelease/FluxReader
jobsub_submit --role=Analysis --resource-provides=usage_model=DEDICATED,OPPORTUNISTIC -G nova  file://$MacroDir/FRjob.sh

Command to submit the job on grid

./wrapper_NOvA_grid_FR.sh