Getting started with HDGeant D. Lawrence 11/11/04 Here are some instructions for getting started with the Hall-D Geant-3 based simulation HDGeant. These include: A. Getting and compiling the source code B. Running the program C. Analyzing the output file. =============================================================== A. Getting and compiling the source code ---------------------------------------- The source code is currently being kept in a CVS repository on the JLab CUE. You must have a CUE account and you must belong to the "halld" unix group. (Contact the JLab computer center for help with both of these.) I'm going to assume you are working on a machine outside of JLab. (All of these instructions will work onsite as well.) First, you will need to create a directory where your files will be kept. I use a directory called HallD in my home directory. Set your HALLD_HOME environment variable to point to this directory. (In order to build the supporting tools which are required for modifying the geometry) you'll need to have XERCES installed and the xerces perl module. You can download these for free from the web. After both of these packages are installed, make sure your environment has the appropriate variables set. Here is a list of the variables I have set for my CUE account: setenv HALLD_HOME /group/halld/Software/builds/latest setenv JAVAROOT /apps setenv HALLD_EXTERNALPACKAGES /group/halld/Software/ExternalPackages setenv XERCESCROOT ${HALLD_EXTERNALPACKAGES}/xerces-c-src_2_5_0 setenv XERCES_INCLUDE ${HALLD_EXTERNALPACKAGES}/include setenv XERCES_LIB ${HALLD_EXTERNALPACKAGES}/lib/${OSNAME} setenv PERL5LIB ${HALLD_EXTERNALPACKAGES}/perl_mods/lib/site_perl/5.8.2/i686-linux setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${XERCES_LIB} setenv PATH ${HALLD_EXTERNALPACKAGES}/bin:${HALLD_EXTERNALPACKAGES}/bin/${OSNAME}:${PATH} NOTES: - You MUST set your JAVAROOT environment variable or else the schema-hddm script will fail with a very misleading error message. This should point to the directory containing bin/java. For example, if your java executable is /usr/bin/java (i.e. this is what "which java" returns) then you should set JAVAROOT to /usr. - The HALLD_EXTERNALPACKAGES environment variable is not required. It is just convienient for defining the other environment variables since things like xerces must be install in a non-standard place on the CUE. CHECKING OUT THE CODE - - - - - - - - - - - 1. Make sure your CVS_RSH environment variable is set to point to ssh. You can do this with something like "setenv CVS_RSH `which ssh`" 2. Check out the needed files with: cvs -d davidl@cvs.jlab.org:/group/halld/Repositories/cvsroot co HDGeant hdds src include Where you should replace the "davidl" with your own JLab CUE account name 3. For historical reasons, the include directory is placed on the a level parallel with HDGeant and src. The Makefile will assume it is in the src directory. The easiest thing to do is to create a symbolic link: cd src ln -s ../include . cd .. You should now have 4 directories "HDGeant", "hdds", "include" and "src" in your HALLD_HOME directory. COMPILING THE CODE - - - - - - - - - - Since we're only interested in HDGeant here and not HDFast, we just need to build the hddsGeant3.F file from the XML source. 1. cd into "hdds" and do a "make hddsGeant3.F". This will build the hdds-geant executable and run it on the main_HDDS.xml to produce hddsGeant3.F. The hddsGeant3.F file is FORTRAN source which contains all of the geometry definitions for the entire GlueX detector. The make file also copies it into ../HDGeant where is will be compiled and used. It's worth noting here that this is where you would make changes to the geomtery. The .xml files kept in the hdds directory can be modified and the the hddsGeant3.F regenerated by re-running "make hddsGeant3.F". 2. A separate library exists in the HDGeant in the "gelhad" subdirectory. The *new* Makefile doesn't handle this properly just yet so you must explicitly build this before building HDGeant. To do this, cd into "HDGeant/gelhad" and do a "make". This should go fairly quickly. When it's done cd back up into the HDGeant directory. 3. Now, you should be in the HDGeant directory. just type "make". Don't worry if it seems to take a long time to compile hddsGeant3.F. This is a HUGE file so just be patient. When it is all done, you should end up with 2 different executables gxint and hdgeant. They will be placed in the the $HALLD_HOME/bin/$OSNAME directory. (for example ~/HallD/bin/Linux). RUNNING HDGEANT - - - - - - - - There are two versions of HDGeant. One is just called "hdgeant" and is a batch-mode version. The other is "gxint" and is the interactive version. The README file in the HDGeant directory gives some instructions on running the interactive version. I'll just give a couple of hints here (note that even though I use "hdgeant", these should be valid for the gxint executable as well): 1. When running hdgeant, make sure the control.in and dsolenoid.table files exist in the current working directory. 2. To test hdgeant without an input file of generated events, just comment out the "INFILE" and "BEAM" lines in control.in placing a "C" as the first character in each line. 3. The simulation produces several output files. The one with the detector responses that you want is called hdgeant.hddm. Looking at the output - - - - - - - - - - - There are a few ways to look at the output data from hdgeant. The first is to checkout and build the hddm package : cvs -d davidl@cvs.jlab.org:/group/halld/Repositories/cvsroot co hddm There is a tool called hddm-xml provided by this package that will display the contents in XML form. The second option is to build "hd_dump" which is based on the DANA framework. The source code for this program already exists in the src directory: 1. cd into src/library and do a "make" 2. cd into src/programs/Analysis/hd_dump and do "make" Running hd_dump with no arguments will print a usage message. The third (and probably most useful) option is to build a custom executable that can be used to define and fill your own histograms. To do this, take a look at the example program: src/programs/Analysis/hd_ana Try building and using it as-is first to make sure it all works. It will produce a couple of sample histograms. The only files you'll need to modify are the MyProcessor.cc and MyProcessor.h (All of the work is done in MyProcessor.cc).