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

static.doc


`Static' Analysis Mode


The C code in static.C plus the script run_static constitute a typical set of files to run in 'static' mode. The script run_static shows the full compilation+link sequence required to build a fully static executable.

The advantages of the "static" mode are:

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

file="static.C"
exe="static.exe"

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

AMSLIBS="../lib/libAMSRoot.a"
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}.a"
      fi      
  done
  cd ${old_dir}
fi

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
  fi
fi

ROOTLIBDIR=`$ROOTSYS/bin/root-config --libdir`
ROOTINCDIR=`$ROOTSYS/bin/root-config --incdir`

system=`uname`
CXXOPTS="-Wno-deprecated"
if [ "$system" != "Darwin" ]; then
      CXXOPTS="-Wno-deprecated -static"
fi

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

LIBS="${AMSLIBS} ${ROOTLIBDIR}/libRoot.a ${ROOTLIBDIR}/libpcre.a"

if [ "$system" != "Darwin" ]; then
      LIBS="${LIBS} -ldl"
fi

RFIO=`$ROOTSYS/bin/root-config --has-rfio`
if [ "$RFIO" = "yes" ]; then
      LIBS="${LIBS} -lshift"
fi

if [ -e "/usr/lib/ctype-info.o" ]; then
      RH9add="-pthread /usr/lib/ctype-info.o"
else
      RH9add=
fi

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

echo -e "\n>>> Recreating libraries if necessary: ${AMSLIB}"
old_dir=$PWD
cd ../lib/ >/dev/null
make static
if [ -n "$all_libs" ]; then
      make utils_static
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} ${LIBS} ${RH9add}
!

echo -e "\n>>> EXECUTING: ${exe}"
${exe}
#include <root.h>
#include "TFile.h"
#include "TH1F.h"
/* NEEDED FOR CASTOR FILES 
#include "TRFIOFile.h"
*/

int main(){

      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");

      /* NEEDED FOR CASTOR FILES
      char chfile[256] = "rfio:/castor/cern.ch/ams/MC/AMS02/2004A/protons/el.pl1.10200/738197524.0000001.root";
      new TRFIOFile(chfile);
      ams->Add(chfile);
      */

      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()) {
            if (pev==NULL) break;
            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());
}


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