All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
makeNoOverburdenVersionOf.sh
Go to the documentation of this file.
1 #!/usr/bin/env bash
2 
3 declare -r SCRIPTNAME="$(basename "$0")"
4 declare -r SCRIPTVERSION="1.0"
5 
6 # script configuration
7 declare -r SubdirName='overburden'
8 declare -r DropInConfigurationName='use_nooverburden_geometry_icarus.fcl'
9 
10 
11 # ------------------------------------------------------------------------------
12 function help() {
13  cat <<EOH
14 Creates a no-overburden version of the specified original job file.
15 
16 Usage: ${SCRIPTNAME} OriginalFHiCLfile NewFHiCLname
17 
18 The new file includes OriginalFHiCLfile and it is placed in the \`${SubdirName}\` subdirectory
19 of the directory that already contains it (or the current one if path is not
20 included in OriginalFHiCLfile).
21 
22 EOH
23 
24 } # help()
25 
26 
27 function printUserName() {
28 
29  local UserName
30  local Email
31 
32  # try to get the information from GIT
33  local GitDirectory
34  [[ -d ".git" ]] && GitDirectory="$(pwd)"
35  [[ -d "${MRB_SOURCE}/icaruscode/.git" ]] && GitDirectory="${MRB_SOURCE}/icaruscode"
36  if [[ -d "$GitDirectory" ]]; then
37  UserName="$(git -C "$GitDirectory" config --get user.name 2> /dev/null)"
38  Email="$(git -C "$GitDirectory" config --get user.email 2> /dev/null)"
39  fi
40 
41  # fallback: ask the operating system
42  [[ -z "$UserName" ]] && UserName="$USER"
43  [[ -z "$UserName" ]] && UserName="$(whoami)"
44 
45  echo "${UserName}${Email:+" (${Email})"}"
46 } # printUserName()
47 
48 
49 # ------------------------------------------------------------------------------
50 
51 if [[ $# -lt 2 ]]; then
52  help
53  exit
54 fi
55 
56 declare -r SourceFile="$1"
57 declare -r DestName="$(basename "${2%.fcl}.fcl")"
58 
59 declare -r SourceDir="$(dirname "$SourceFile")"
60 declare -r SourceName="$(basename "${SourceFile%.fcl}.fcl")"
61 declare -r DestDir="${SourceDir%/}/${SubdirName}"
62 declare -r DestFile="${DestDir:+"${DestDir%/}/"}${DestName}"
63 
64 if [[ "$SourceName" == "$DestName" ]]; then
65  echo "Cowardly refusing to create a new FHiCL file with the same name as the original one ('${SourceName}')." >&2
66  exit 1
67 fi
68 
69 echo "'${SourceName}' => '${DestName}'"
70 
71 [[ -d "$DestDir" ]] || mkdir "$DestDir"
72 
73 cat <<EOF > "$DestFile"
74 #
75 # File: ${DestName}
76 # Purpose: No-overburden version of \`${SourceName}\`.
77 # Author: $(printUserName)
78 # Date: $(date)
79 #
80 # This file was automatically generated by ${SCRIPTNAME} version ${SCRIPTVERSION}.
81 #
82 
83 #include "${SourceName}"
84 
85 # turn to no-overburden geometry:
86 #include "${DropInConfigurationName}"
87 
88 EOF
process_name opflash particleana ie ie ie z
* file
Definition: file_to_url.sh:69
#define the
SCRIPTNAME
Definition: publish.sh:21
then help exit fi declare r SourceFile
then echo Sam station was not specified(use option--sam_station)." exit 1 fi if [ x$SAM_GROUP
process_name gaushit a
BEGIN_PROLOG triggeremu_data_config_icarus settings PMTADCthresholds sequence::icarus_stage0_multiTPC_TPC physics sequence::icarus_stage0_EastHits_TPC physics sequence::icarus_stage0_WestHits_TPC physics producers purityana0 caloskimCalorimetryCryoE physics caloskimCalorimetryCryoW physics path
then local
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
then shift fi
then echo Cowardly refusing to create a new FHiCL file with the same name as the original one('${SourceName}')." >&2 exit 1 fi echo "'$
then echo Work directory not specified exit fi echo Work directory
esac voms proxy info all source grid fermiapp products common etc setups sh source cvmfs oasis opensciencegrid org fermilab products larsoft setup setup ifdhc echo Here is the your environment in this job
Definition: run_job.sh:29
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
esac echo uname r