SAM Run Project Examples

 

1. Introduction

Sam Run Project is a simple way to use SAM to retrieve data stored on sam controlled disk  or in the tape robot. Following are two examples that illustrate how files can be retrieved, and stored using the system. The basic sam commands which need to be issued are  the following:

setup n32 # on irix only
setup sam
sam define project --filename='gen.pmc02_01.pythia.ttbar_200evts.265_1417' --defname=your_project_name --group=test
sam run project config_file.py

The first two lines are used to setup sam and are needed for any use of the sam system. The next line,   sam define project, defines the project which contains the files with which you wish to work. In this simple example, a  specific file name is given.  although a  wild card (%) could be used in the name, or other interesting constraints can be specified as well. See the project definition  documentation for more details.  The configuration file tells the system what project is being processed and which resources to use. Also, a small piece of python code in the configuration file can be used to control jobs which process the files being retrieved, and store data into the system.

2. 1 Example 1: Getting a List of Files

The following script is used as the configuration file (config_file.py) for the above list of commands.
#!/usr/bin/env python
#
# a sample project file for SAM
#
import os, sys, string, time, signal
from re import *

############################################################################

#
project_definition = "lauri_b4_0_test"
sam_station        = "central-analysis"
snapshot_version   = 'new'
appname            = 'reco_analyze'
version            = "t01.21.00"
group              = "dzero"
max_file_amt       = 1000

##verbosity          = "--verbose"
verbosity           = ""

# Give up on all exceptions
give_up            = 1

# to illustrate pre/post processing:
global fileCount

# optional initialization:
def begin_project():
    global fileCount
    print("MY PROJECT: into begin_project, do what needs to be done BEFORE file_ready().")
    fileCount = 0
    return

# REQUIRED, file_ready processing:
def file_ready(filename):
    global fileCount
    print("MY PROJECT: working on a file named >%s<" % filename)
    fileCount += 1
    return

# optional post-processing:
def end_project():
    global fileCount
    print("MY PROJECT: into end_project, do what needs to be done AFTER all files are processed.")
    print("MY PROJECT saw %s files." % fileCount)
    return

=============================================================================
Project : SAM
Package : sam
$Id: SamRunProjectExample.html,v 1.5 2002/05/21 19:51:57 lauri Exp $

This work is part of a development project, called SAM, which consists of a
number of coordinated packages each named sam_xxxx .

Notice of authorship, copyright status, and terms and conditions, should
the software eventually become available for use outside Fermilab, can be
found in the README and LICENCE files in the top level directory of the main
sam package.

==============================================================================