#!/bin/sh # ______________________________________________________________________ # # Purpose: run TMBChunkAnalyze # Created: 12AUG02, MVH # ______________________________________________________________________ # ______________________________________________________________________ # # Configuration parameters # ______________________________________________________________________ SCRIPTNAME="runtmbchunkanalyze" # Name of this script SCRIPTPATH="$D0TOOLS_BIN" # Location of the script rund0exe RUNFRMWRK="rund0exe" # Script to run framework exe RCPPKG="analysis_tmb" # Package containing framework rcp FILTERTRIGGERS="" # Filter events based on a trigger list TAGTRIGGERS="" # Tag events based on a trigger list FWKPARAMS="" # Use -fwkparams option of rund0exe EXE="TMBChunkAnalyze.x" # Executable INPUT="NONE" # Input format: DST or TMB SKIM="" # User required skimmed data sets SAM="" # Input from SAM CREATERCP="" # Don't execute, just create the custom # framework RCP INITSCRIPT="inittmbchunkanalyze.sh" # ______________________________________________________________________ # # Determine type of input, which specifies executable # ______________________________________________________________________ # Help mode for var in $*; do if [ $var = "-h" ]; then cat \ $D0TOOLS_DOC/runtmbchunkanalyze.man1 \ $D0TOOLS_DOC/runtmbchunkanalyze.man4 \ $D0TOOLS_DOC/rund0exe.man2 \ $D0TOOLS_DOC/rund0exe.man3 \ $D0TOOLS_DOC/rund0exe.man5 \ | more exit fi done PARAMS="" # This will hold command line options to pass to rund0exe for var in $*; do # If user specified -defname, must be SAM if [ `echo "$var" | grep -c "\-defname="` != 0 ]; then PARAMS="$PARAMS $var" SAM="SAM" # If user uses -filelist, need to look inside elif [ `echo "$var"| grep -c "\-filelist="` != 0 ]; then PARAMS="$PARAMS $var" FILELIST=`echo "$var"| sed 's/\-filelist=//'` # Support list of SAM dataset definitions in a filelist if [ `grep -c "SAMDEFNAME:" $FILELIST` != 0 ]; then SAM="SAM" fi # If user uses -mode, check the input format elif [ `echo "$var"| grep -c "\-mode="` != 0 ]; then INPUT=`echo "$var"| sed 's/\-mode=//'` # If user uses -skim, check for the required skimmed data sets elif [ `echo "$var"| grep -c "\-skim="` != 0 ]; then if [ "$SKIM" = "" ]; then SKIM=`echo "$var"| sed 's/\-skim=//' | sed 's/,/ /g'` else SKIM="$SKIM "`echo "$var"| sed 's/\-skim=//' | sed 's/,/ /g'` fi # If user uses -create_rcp elif [ `echo "$var"| grep -c "\-create_rcp="` != 0 ]; then CREATERCP=`echo "$var"| sed 's/\-create_rcp=//'` # If user uses -rcp elif [ `echo "$var"| grep -c "\-rcp="` != 0 ]; then RCP=`echo "$var"| sed 's/\-rcp=//'` # If user uses -rcppkg elif [ `echo "$var"| grep -c "\-rcppkg="` != 0 ]; then RCPPKG=`echo "$var"| sed 's/\-rcppkg=//'` # If user uses -exe elif [ `echo "$var"| grep -c "\-exe="` != 0 ]; then EXE=`echo "$var"| sed 's/\-exe=//'` # -filter_triggers=xxx: user provided list of triggers used # for event filtering elif [ `echo $var | grep -c "\-filter_triggers="` != 0 ]; then if [ "$FILTERTRIGGERS" = "" ]; then FILTERTRIGGERS=`echo $var | sed 's/\-filter_triggers=//' | sed 's/,/ /g'` else FILTERTRIGGERS="$FILTERTRIGGERS "`echo $var | sed 's/\-filter_triggers=//' | sed 's/,/ /g'` fi # -tag_triggers=xxx: user provided list of triggers used # for event tagging elif [ `echo $var | grep -c "\-tag_triggers="` != 0 ]; then if [ "$TAGTRIGGERS" = "" ]; then TAGTRIGGERS=`echo $var | sed 's/\-tag_triggers=//' | sed 's/,/ /g'` else TAGTRIGGERS="$TAGTRIGGERS "`echo $var | sed 's/\-tag_triggers=//' | sed 's/,/ /g'` fi else PARAMS="$PARAMS $var" fi done if [ "$INPUT" = "NONE" -a "$RCP" = "" ]; then echo "ERROR: You must specify the type of input file (DST or TMB)" echo " with the -mode option." exit fi if [ "$FILTERTRIGGERS" != "" -o "$TAGTRIGGERS" != "" ]; then FWKPARAMS=" -fwkparams" if [ "$FILTERTRIGGERS" != "" ]; then FWKPARAMS="$FWKPARAMS -filter_triggers $FILTERTRIGGERS" fi if [ "$TAGTRIGGERS" != "" ]; then FWKPARAMS="$FWKPARAMS -tag_triggers $TAGTRIGGERS" fi fi # ______________________________________________________________________ # # If the user has specified a framework RCP file, just use it, ignoring # all other options. Otherwise, if the user wants to skim files or # specify a list of triggers used for the event selection build custom # RCP files. In any other case, use one of the standard RCP files. # ______________________________________________________________________ if [ "$RCP" != "" ]; then echo "runtmbchunkanalyze: using the custom RCP file $RCP" # Don't know whether the user wants to write output files # For safety, force using the output file names from the RCP files PARAMS="$PARAMS -forcercpoutfile" elif [ "$SKIM" != "" -o "$CREATERCP" != "" ]; then # Basis for creating the custom RCP file BASIC="runTMBChunkAnalyze_basic.rcp" # Name of the custom RCP file RCP="runTMBChunkAnalyze_custom.rcp" echo $CREATERCP if [ "$CREATERCP" != "" ]; then RCP="$CREATERCP" fi echo "runtmbchunkanalyze: creating a custom RCP file $RCP" # Start building the string Packages line PACKAGES="geometry" # Input from SAM if necessary if [ "$SAM" != "" ]; then PACKAGES="$PACKAGES sam" echo " input from SAM" fi PACKAGES="$PACKAGES read config" # Unpack the TMB if necessary if [ "$INPUT" = "TMB" ]; then PACKAGES="$PACKAGES unpack" echo " input in TMB format" else echo " input in DST format" fi # Apply the trigger selection and the user analysis PACKAGES="$PACKAGES trigsel analyze" # Parse the list of required skimmed data sets if [ "$SKIM" != "" ]; then echo " you want to generate skimmed dataset(s)" fi for var in $SKIM; do # Use the output file names specified by the RCP files. PARAMS="$PARAMS -forcercpoutfile" # Generate a skimmed DST dataset if [ "$var" = "DST" ]; then # Cannot generate a DST from the TMB if [ "$INPUT" = "TMB" ]; then echo "ERROR: you required to generate a DST from the TMB." echo " Remove the -skim=DST option or use a DST as input." exit fi PACKAGES="$PACKAGES dstwrite" echo " will generate a skimmed DST" # Generate a skimmed TMB dataset elif [ "$var" = "TMB" ]; then # If starting from a DST, drop the TMB chunk and recreate the TMB if [ "$INPUT" = "DST" ]; then PACKAGES="$PACKAGES droptmb tmbcreate" echo " will regenerate the TMB from the DST" fi PACKAGES="$PACKAGES tmbwrite" echo " will generated a skimmed TMB" # Create a skimmed ROOT tree elif [ "$var" = "ROOT" ]; then # Apparently the TMBTree cannot be created directly from the DST if [ "$INPUT" = "DST" ]; then PACKAGES="$PACKAGES unpack" fi PACKAGES="$PACKAGES links tmb_tree tmb_core tmb_mc tmb_refs" echo " will generate a skimmed ROOT tree" else echo "ERROR: unknown -skim=$var option." echo " -skim accepts only DST, TMB or ROOT." exit fi done # Write the string Packages = " .... " line in the framework RCP sed "s/XXXXXX123456/$PACKAGES/" $RCPPKG/rcp/$BASIC > $RCPPKG/rcp/$RCP if [ "$?" != "0" ]; then echo "ERROR: could not create the custom RCP file." echo " Check the write permission to the analysis_example directory" exit fi echo "runtmbchunkanalyze: created custom RCP file $RCPPKG/rcp/$RCP" # The user just wants to create the custom RCP file if [ "$CREATERCP" != "" ]; then exit fi else RCP="runTMBChunkAnalyze$SAM"_"$INPUT.rcp" fi # ______________________________________________________________________ # # Use general run framework script to run TMBChunkAnalyze # ______________________________________________________________________ $SCRIPTPATH/$RUNFRMWRK \ -exe=$EXE \ -rcp=$RCP \ -rcppkg=$RCPPKG \ -localbuild \ -localrcp \ -localfwkrcp \ -initscript=$SRT_PRIVATE_CONTEXT/$INITSCRIPT \ $PARAMS \ $FWKPARAMS