Example 1: An example of analysis with ROOT, which contains 2 files, ex.sh and mc.C.

  • ex.sh:

/bin/tcsh
setenv Offline /afs/cern.ch/ams/Offline
source $Offline/vdev/install/amsvar
source /afs/cern.ch/exp/ams/Offline/root/Linux/root-v5-34-9-icc64.17-slc6/amsvar
setenv AMSWD $Offline/vdev
root $Offline/vdev/install/l64PG.C
.L mc.C+
mc()

  • mc.C:

#include "root_RVSP.h"
#include "amschain.h"
void mc(){
    AMSEventR::hbook1(10,"kalman",200,-2,3);
    AMSEventR::hbook1(11,"kalmani",200,-2,3);
    AMSEventR::hbook1(12,"orig",200,-2,3);

    AMSChain a;
    a.Add("mc:2013311703");
    cout << " entries "<<a.GetEntries()<<endl;
    for(int k=0;k<a.GetEntries();k++){
        AMSEventR *pev=a.GetEvent(k);
        //cout <<" "<<pev->NParticle()<<" "<<pev->NTrTrack()<<endl;
        if(pev->nParticle()){
            //cout <<" l "<<k<<endl;
            ParticleR &p=pev->Particle(0);
            if(p.iTrTrack()>=0){
                TrTrackR &t=pev->TrTrack(p.iTrTrack());
                int ich=t.iTrTrackPar(6,0,1,TrFit::Mhelium);
                //cout <<" ich "<<ich<<" "<<pev->Event()<<endl;
                if(ich>=0){
                    //cout <<t.GetRigidity(ich)<<" "<<t.GetRigidity()<<endl;
                    //cout <<" ok "<<endl;
                }
                int ichi=t.iTrTrackPar(6,3,2,TrFit::Mhelium);
                //cout <<" ichi "<<ichi<<" "<<pev->Event()<<endl;
                if(ichi>=0){
                    //   cout <<t.GetRigidity(ichi)<<" "<<t.GetRigidity()<<endl;
                    //  cout <<" oki "<<endl;
                }
                MCEventgR *mce=pev->GetPrimaryMC();
                if(mce && t.GetRigidity()/mce->Momentum*2>0.1){
                    //cout<<" mom "<<mce->Momentum<<endl;
                    if(ich)AMSEventR::hf1(10,t.GetRigidity(ich,0)/mce->Momentum*2);
                    if(ichi)AMSEventR::hf1(11,t.GetRigidity(ichi,1)/mce->Momentum*2);
                    AMSEventR::hf1(12,t.GetRigidity()/mce->Momentum*2);
                }
            }
        }
    }
}

Example 2: The way to build your own code, say you have written myprog.C, you can build it by using the csh script link.csh:

setenv AMSWD . # or export AMSWD=. if you use bash
mkdir -p exe/linux
.link.csh myprog

  • link.csh:
#!/bin/csh
setenv Offline /cvmfs/ams.cern.ch/Offline
source /afs/cern.ch/exp/ams/Offline/root/Linux/root-v5-34-9-icc64.17-slc6/amsvar
source /cvmfs/sft.cern.ch/lcg/contrib/gcc/4.9.3/x86_64-slc6/setup.csh  /afs/cern.ch/sw/lcg/external

icc  -I/$ROOTSYS/include  -no-multibyte-chars -I$Offline/vdev/include -D__root__new  -D__WRITEROOT__ -D__ROOTSHAREDLIBRARY__ -qopenmp -O3 -axsse4.2,ssse3,AVX,CORE-AVX2 $1.C -c -o $1.o
icpc  -static-libstdc++ -static-libgcc -static-intel -qopenmp -qopenmp-link static  -axssse3  -static-intel  -static-libgcc -O $1.o -Bstatic -L$Offline/vdev/lib/linuxx8664icc5.34 -lntuple_slc6_PG    -L$ROOTSYS/lib -lRoot -L/afs/cern.ch/ams/Offline/CERN/NagLib -lnag64 -L/afs/cern.ch/ams/Offline/CERN/2005.icc16/lib -lmathlib -lpacklib -lgfortran  -pthread   -lpcre  -L/afs/cern.ch/ams/local2/opt/lib64 -lcrypto  -llzma -lfreetype -Bdynamic -L$XRDLIB/lib64 -lXrdClient  -lXrdUtils -Wl,--allow-multiple-definition   -Bstatic -lifcore -lshift    -Bdynamic    -ldl -lrt -o $AMSWD/exe/linux/$1_534
chmod +x $AMSWD/exe/linux/$1_534

-- BaosongShan - 2019-01-29

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2019-03-29 - BaosongShan
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    AMS All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback