Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Examples

dynamic.doc


`Dynamic' Analysis Mode


The C code in dynamic.C and the script run_dynamic constitute a typical set of files for running in 'dynamic' mode. The script run_dynamic shows the full compilation+link sequence required to build the executable.

The advantages of the "dynamic" mode are:

There are also some disadvantages: Some AMS specific issues follow:
#!/bin/sh

file="dynamic.C"
exe="dynamic.exe"

system=`uname`

# Use all libs
#all_libs=1
# Use just libAMSRoot
unset all_libs

AMSLIBS="../lib/libAMSRoot.so"
if [ "$system" = "Darwin" ]; then
      AMSLIBCMD="-dylib_file /lib/libAMSRoot.so:$PWD/../lib/libAMSRoot.so $PWD/../lib/libAMSRoot.so"
      ROOTLIBS="`${ROOTSYS}/bin/root-config --glibs` -lASImage -lMinuit"
      EXTRALIBS="-ldl"
      CXXOPTS="-Wno-deprecated -bind_at_load"
else
      AMSLIBCMD="-Xlinker -R../lib -L../lib -lAMSRoot"
      ROOTLIBS="-Xlinker -R${ROOTSYS}/lib `${ROOTSYS}/bin/root-config --glibs` -lASImage -lMinuit"
      EXTRALIBS="-ldl -lcrypt"
      CXXOPTS="-Wno-deprecated"
fi

machine=`uname -m`
if [ "$machine" = "x86_64" ]; then
      CXXOPTS="${CXXOPTS} -fPIC -m32"
fi


AMSINCS="-I../lib/AMSRoot"
if [ -n "$all_libs" ]; then
  old_dir=${PWD}
  cd ../lib
  for dir in `ls -d */` ; do
      dir=${dir/\//}
      if [ "${dir}" != "CVS" -a "${dir}" != "AMSRoot" ]; then
            AMSINCS="${AMSINCS} -I../lib/${dir}"
            AMSLIBS="${AMSLIBS} ../lib/lib${dir}.so"
            AMSLIBCMD="${AMSLIBCMD} -l${dir}"
      fi      
  done
  cd ${old_dir}
fi

if [ "$system" != "Darwin" ]; then
 if [ "`/usr/bin/gcc -dumpversion`" == "2.96" ]; then
  if [ -e "/usr/local/gcc-alt-3.2.3" ]; then
      export PATH=/usr/local/gcc-alt-3.2.3/bin:$PATH
      export LD_LIBRARY_PATH=/usr/local/gcc-alt-3.2.3/lib:$LD_LIBRARY_PATH
  fi
 fi
fi

ROOTINCDIR=`${ROOTSYS}/bin/root-config --incdir`

INCS="${AMSINCS} -I${ROOTINCDIR}"

RH9add=""
if [ -e "/usr/lib/ctype.o" ]; then
 RH9add="-Wl,/usr/lib/ctype.o"
fi

echo -e "\n>>> Recreating libraries if necessary"
old_dir=$PWD
cd ../lib/ >/dev/null
make shared
if [ -n "$all_libs" ]; then
      make utils_shared
fi
cd $old_dir

echo -e "\n>>> COMPILING and LINKING: ${file}"
make -f - -s <<!
SHELL=/bin/sh

${exe}: ${file} ${AMSLIBS}
        g++ ${CXXOPTS} ${INCS} -o ${exe} ${file} ${AMSLIBCMD} ${ROOTLIBS} ${EXTRALIBS} ${RH9add}
!

echo -e "\n>>> EXECUTING: ${exe}"
if [ "$system" = "Darwin" ]; then
      export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:../lib
fi
${exe}
#include <root.h>
#include "TRint.h"
#include "TFile.h"
#include "TH1F.h"
int main(){

      // Do not use this when linking with static libraries
      TRint* app = new TRint("AMS Root Application", 0, 0);

      AMSChain* ams = new AMSChain;
      ams->Add("../files/test.root");
      //ams->Add("http://pcamsf0.cern.ch/f2dah1/MC/AMS02/2004A/protons/el.pl1.10200/738197524.0000001.root");
      //ams->Add("rfio:/castor/cern.ch/ams/MC/AMS02/2004A/protons/el.pl1.10200/738197524.0000001.root");

      TFile* hfile = new TFile ("amstest.root", "RECREATE"); 

      AMSEventList* list = new AMSEventList;

      TH1F* hrig = new TH1F ("hrig", "Momentum (GeV)", 50, -10., 10.);
      
      AMSEventR* pev = NULL;
      while (pev=ams->GetEvent()) {
            for (int i=0; i<pev->nParticle(); i++) {
                  ParticleR* part = pev->pParticle(i);
                  hrig->Fill(part->Momentum);
                  if (pev->nVertex()>0) {
                          list->Add(pev); // Add to list of selected events
                          pev->Fill(); // write it into output ROOT file
                  }
            }
      }

      hrig->Draw();
      hfile->Write();
      list->Write("select.list");

      printf("We have processed %d events\n", (int)ams->GetEntries());
      printf("Histograms saved in '%s'\n", hfile->GetName());

      // Do not use this when linking with static libraries
      app->Run();
}


Generated on Fri Oct 10 10:39:23 2008 for AMSRoot by  doxygen 1.3.9.1