3 # Creates file lists from a run number, or SAM definition, or just SAM files.
5 # Run with `--help` for usage instructions
7 # Author: Gianluca Petrillo (petrillo@slac.fnal.gov)
11 # 20220720 (petrillo@slac.stanford.edu) [1.4]
12 # added --locate option
13 # 20220406 (petrillo@slac.stanford.edu) [1.3]
14 # --max option now only converts that many files
15 # 20220126 (petrillo@slac.stanford.edu) [1.2]
16 # added --stream options
17 # 20210429 (petrillo@slac.stanford.edu) [1.1]
19 # 20210411 (petrillo@slac.stanford.edu) [1.0]
20 # first public version
27 declare -
r RawType=
'raw'
28 declare -
r DecodeType=
'decoded'
29 declare -
r XRootDschema=
'root'
30 declare -
r LocateSchema=
'locate'
31 declare -
r dCacheLocation=
'dcache'
32 declare -
r TapeLocation=
'enstore'
33 declare -
r BNBstream=
'bnb'
34 declare -
r NuMIstream=
'numi'
35 declare -
r AnyStream=
''
37 declare -
r DefaultType=
"$DecodeType"
38 declare -
r DefaultSchema=
"$XRootDschema"
39 declare -
r DefaultLocation=
"$dCacheLocation"
40 declare -
r DefaultDecoderStageName=
"stage0" # used to be
'decoder' up to
a certain time
41 declare -
r DefaultStream=
"$AnyStream"
43 declare -
r DefaultOutputPattern=
"%TYPE%-run%RUN%%DASHSTREAM%%DASHSCHEMA%%DASHLOCATION%%DASHLIMIT%.filelist"
45 # ------------------------------------------------------------------------------
48 [[ -
n "${!VarName//0}" ]]
51 function isDebugging() {
52 local -i Level=
"${1:-1}"
53 [[
"$DEBUG" -ge
"$Level" ]]
59 isDebugging
"$Level" &&
STDERR "DBG[${Level}]| $*" ;
61 function DBG() { DBGN 1
"$*" ; }
63 function STDERR() { echo
"$*" >&2 ; }
72 STDERR "FATAL(${Code}): $*"
78 [[ $res == 0 ]] ||
FATAL "$res" "$@"
82 function PrintHelp() {
85 Queries SAM
for all
the files
in a run
and translates each
file into
a URL.
89 Each specification may be
a run number,
a SAM definition (preceded by \`@\`,
90 e.g. \`@icarus_run005300_raw\`) or
a file name.
91 In all cases, run, definition or
file, they must be known to SAM.
94 --
type=<${RawType}|${DecodeType}|...> [${DefaultType}]
98 select
the type of files to query (raw
from DAQ, decoded...);
99 if the stage is explicitly selected, it is used as constraint
in SAM query
100 --
schema=<${XRootDschema}|...> [${DefaultSchema}]
101 --xrootd , --
root , -
X
104 special schema
value <${LocateSchema}> will cause
the query to be done via
106 --location=<${dCacheLocation}|${TapeLocation}> [${DefaultLocation}]
107 --tape , --enstore , -T
108 --disk , --dcache , -C
109 select
the storage
type (no effect
for \`locate\` schema)
110 --
stream=<${BNBstream}|${NuMIstream}|...> [${DefaultStream}]
118 use OUTPUTFILE
for all output
file lists
119 --outputdir=OUTPUTDIR
120 prepend all output filelist paths with
this directory
123 --outputpattern=PATTERN [${DefaultOutputPattern}]
125 the following tags
in PATTERN
are replaced: \`%
RUN%\` by
the run number;
127 \`%SCHEMA%\` by
the URL
schema; \`%LOCATION%\` by
the storage location;
128 \`%TYPE%\` by
the file content
type; \`%LIMIT%\` by
the number of requested
130 and all tags prepended by \`DASH\` (
e.g. \`%DASHTYPE%\`)
are replaced
134 retrieves only
the first LIMIT files
from SAM (only when querying run numbers);
135 in all cases, it translates only LIMIT files into
a location; 0 means no limit
137 experiment
name (
and SAM station) passed to SAM
141 enable debugging printout (optionally with
the specified verbosity LEVEL)
151 function PrintVersion() {
160 # ------------------------------------------------------------------------------
161 function AddPathToList() {
165 DBGN 2
"Adding: '${Path}'"
166 if [[ -
n "$OutputFile" ]]; then
167 echo
"$Path" >>
"$OutputFile"
176 function DeclareTempFile() {
179 local TemplateName=
"${SCRIPTNAME%.sh}-run${Run}.tmp.XXXXXX"
181 TempFile=
"$(mktemp --tmpdir "$TemplateName
")"
182 LASTFATAL "Failed to create a temporary file (after '${TemplateName}') for run ${Run}."
183 TempFiles+=(
"$TempFile" )
187 } # DeclareTempFile()
190 rm -f
"${TempFiles[@]}"
194 function isRunNumber() { [[
"$1" =~ ^[[:digit:]]+$ ]]; }
195 function isSAMdefName() { [[
"${1:0:1}" ==
'@' ]]; }
196 function isSAMfile() { [[
"${1: -5}" ==
'.root' ]]; }
197 function SpecType() {
200 [
'run']=
'isRunNumber'
201 [
'SAMdef']=
'isSAMdefName'
202 [
'SAMfile']=
'isSAMfile'
205 for Type in "${!Tests[@]}" ;
do
206 "${Tests[$Type]}" "$Spec" ||
continue
214 function BuildOutputFilePath() {
218 local OutputName=
"$Pattern"
221 local VarName VarValue
223 VarValue=
"${!VarName}"
224 Replacements[
"${VarName^^}"]=
"$VarValue"
225 Replacements[
"DASH${VarName^^}"]=
"${VarValue:+"-${VarValue}
"}"
228 for TagName
in "${!Replacements[@]}" ;
do
229 OutputName=
"${OutputName//%${TagName}%/${Replacements["$TagName
"]}}"
232 echo
"${OutputDir:+"${OutputDir%/}/
"}${OutputName}"
233 } # BuildOutputFilePath()
236 # ------------------------------------------------------------------------------
246 # ------------------------------------------------------------------------------
247 function getFileAccessURL() {
252 RunSAM
get-
file-
access-url ${Schema:+
"--schema=${Schema}"} ${Location:+
"--location=${Location}"}
"$FileName"
254 } # getFileAccessURL()
257 # ------------------------------------------------------------------------------
258 function locateFile() {
261 RunSAM locate-
file "$FileName"
266 # ------------------------------------------------------------------------------
268 declare -i UseDefaultOutputFile=0 DoQuiet=0
270 declare
Type=
"$DefaultType"
271 declare
Schema=
"$DefaultSchema"
273 declare
Stream=
"$DefaultStream"
274 declare OutputPattern=
"$DefaultOutputPattern"
275 declare EntryLimit=0 # 0 = no
limits'
277 for (( iParam=1 ; iParam <= $# ; ++iParam )); do
279 if [[ "${Param:0:1}" == '-
' ]]; then
281 ( '--raw
' | '-R
' ) Type="$RawType" ;;
282 ( '--decoded
' | '--
decode' | '-D
' ) Type="$DecodeType" ;;
283 ( '--type=
'* ) Type="${Param#--*=}" ;;
284 ( '--stage=
'* ) Type="${Param#--*=}" ;;
286 ( '--schema=
'* | '--scheme=
'* ) Schema="${Param#--*=}" ;;
287 ( '--xrootd
' | '--XRootD
' | '--root
' | '--
ROOT' | '-
X' ) Schema="$XRootDschema" ;;
288 ( '--locate
' ) Schema="$LocateSchema" ;;
290 ( '--
loc=
'* | '--location=
'* ) Location="${Param#--*=}" ;;
291 ( '--dcache
' | '--dCache
' | '-C
' ) Location="$dCacheLocation" ;;
292 ( '--tape
' | '--enstore
' | '-T
' ) Location="$TapeLocation" ;;
295 ( '--stream=
'* ) Stream="${Param#--*=}" ;;
296 ( '--bnb
' | '--BNB
' ) Stream="$BNBstream" ;;
297 ( '--numi
' | '--NuMI
' | '--NUMI
' ) Stream="$NuMIstream" ;;
298 ( '--allstreams
' ) Stream="$AnyStream" ;;
300 ( "--output="* ) OutputFile="${Param#--*=}" ;;
301 ( "--outputpattern="* ) OutputPattern="${Param#--*=}" ;;
302 ( "--outputdir="* ) OutputDir="${Param#--*=}" ;;
303 ( "-O" ) UseDefaultOutputFile=1 ;;
304 ( "--max="* | "--limit="* ) EntryLimit="${Param#--*=}" ;;
305 ( "--experiment="* ) Experiment="${Param#--*=}" ;;
307 ( '--
debug' ) DEBUG=1 ;;
308 ( '--
debug=
'* ) DEBUG="${Param#--*=}" ;;
309 ( '--quiet
' | '-
q' ) DoQuiet=1 ;;
310 ( '--
version' | '-
V' ) DoVersion=1 ;;
311 ( '--
help' | '-
h' | '-?
' ) DoHelp=1 ;;
316 FATAL 1 "Invalid option #${iParam} ('${
Param}
')."
321 LASTFATAL "Parameter #${iParam} ('${
Param}
') is not a valid (run) number."
325 if isFlagSet UseDefaultOutputFile && [[ -n "$OutputFile" ]]; then
326 FATAL 1 "Options \`-O\` and \`--outputfile\` (value: '${OutputFile}
') are exclusive."
329 if isFlagSet DoVersion ; then
331 [[ "${ExitWithCode:-0}" -gt 0 ]] || ExitWithCode=0
334 if isFlagSet DoHelp ; then
336 [[ "${ExitWithCode:-0}" -gt 0 ]] || ExitWithCode=0
339 [[ -n "$ExitWithCode" ]] && exit "$ExitWithCode"
344 [[ "$EntryLimit" -gt 0 ]] && Limit="max${EntryLimit}"
346 declare Constraints=''
348 ( 'raw
' ) Constraints+=" and data_tier=raw" ;;
350 if [[ "${Type,,}" == 'decoded
' ]]; then
351 Stage="$DefaultDecoderStageName"
355 Constraints+=" and icarus_project.stage=${Stage}"
357 # echo "Type '${Type}
' not supported!" >&2
360 [[ -n "$Stream" ]] && Constraints+=" and sbn_dm.beam_type=${Stream}"
361 [[ "$EntryLimit" -gt 0 ]] && Constraints+=" with limit ${EntryLimit}"
367 [[ -n "$OutputDir" ]] && mkdir -p "$OutputDir"
368 if [[ -n "$OutputFile" ]]; then
369 [[ "${OutputFile:0:1}" == '/
' ]] || OutputFile="${OutputDir%/}/${OutputFile}"
372 for Spec in "${Specs[@]}" ; do
374 declare FileList="$(DeclareTempFile "$Spec")"
375 if isFlagSet UseDefaultOutputFile ; then
376 OutputFile="$(BuildOutputFilePath "$OutputPattern" "$Spec")"
381 case "$(SpecType "$Spec")" in
385 declare Query="run_number=${Run}${Constraints}"
386 RunSAM list-files "$Query" > "$FileList"
387 LASTFATAL "getting run ${Run} file list (SAM query: '${Query}
')."
390 SAMdefName="${Spec:1}"
391 JobTag="SAM definition ${SAMdefName}"
392 RunSAM list-definition-files "$SAMdefName" > "$FileList"
393 LASTFATAL "getting ${JobTag} file list."
397 JobTag="SAM-declared file '${
FileName}
'"
398 echo "$FileName" > "$FileList"
401 ERROR "Unknown type for specification '${Spec}
'."
406 declare -i nFiles="$(wc -l "$FileList" | cut -d' ' -f1)"
410 INFO "${JobTag}: ${nFiles} files${OutputFile:+" => '${OutputFile}
'"}"
411 while read FileName ; do
412 [[ "$EntryLimit" -gt 0 ]] && [[ $iFile -ge "$EntryLimit" ]] && INFO "Limit of ${EntryLimit} reached." && break
413 INFO "[$((++iFile))/${nFiles}] '${
FileName}
'"
416 FileURL=( $(locateFile "$FileName" ) )
419 FileURL=( $(getFileAccessURL "$FileName" "$Schema" "$Location" ) )
422 LASTFATAL "getting file '${
FileName}
' location from SAM."
423 [[ "${#FileURL[@]}" == 0 ]] && FATAL 2 "failed getting file '${
FileName}
' location from SAM."
424 [[ "${#FileURL[@]}" -gt 1 ]] && WARN "File '${
FileName}
' matched ${#FileURL[@]} locations (only the first one included):$(printf -- "\n- '%
s'" "${FileURL[@]}")"
425 AddPathToList "${FileURL[0]}"
430 [[ $nErrors -gt 0 ]] && FATAL 1 "${nErrors} error(s) accumulated while processing."
xrootd XRootD root ROOT X Schema
finds tracks best matching by with limits
esac done echo Signal files are
do one_file $F done echo for F in find $TOP name CMakeLists txt print
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
then echo Sam station was not specified(use option--sam_station)." exit 1 fi if [ x$SAM_GROUP
void decode(std::any const &src, Interval< Args...> &iv)
Decodes an interval.
BEGIN_PROLOG dataFFTHistosEW root
BEGIN_PROLOG gatesFromTracksW gatesFromTracksE streams
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more information
then echo Work directory not specified exit fi echo Work directory
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then echo File list $list not found else cat $list while read file do echo $file sed s
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker options
BEGIN_PROLOG triggeremu_data_config_icarus settings sequence::triggeremu_data_config_icarus settings PMTADCthresholds sequence::triggeremu_data_config_icarus settings PMTADCthresholds sequence::triggeremu_data_config_icarus settings PMTADCthresholds Pattern
bool empty(FixedBins< T, C > const &) noexcept