3 # creates metadata for one or more iceberg raw data files. Puts JSON files in the
4 # current working directory.
6 # invoke this as iceberg_metadata.sh <input>
7 # where <input> is a file path, or a directory. It is the input to a find command
9 function iceberg_metadata_single_file {
12 config_dumper -P $1 | sed -e "s/\\\n/\n/g" > ${CFNAME}
15 sam_metadata_dumper $1 > ${TMPMD}
18 grep Component $CFNAME | awk '{print $3}' > $CMPFILE
20 gain=`grep "gain:" $CFNAME | head -1 | awk '{print $2}'`
21 shapetime=`grep "peak_time:" $CFNAME | head -1 | awk '{print $2}'`
22 accouple=`grep "ac_couple:" $CFNAME | head -1 | awk '{print $2}'`
23 baselineHigh=`grep "baseline:" $CFNAME | head -1 | awk '{print $2}'`
24 leakHigh=`grep "leak:" $CFNAME | head -1 | awk '{print $2}'`
25 leak10x=`grep "leak_10x:" $CFNAME | head -1 | awk '{print $2}'`
26 if [[ ${leak10x} = false ]]; then
31 pulsemode=`grep "enable_pulser:" $CFNAME | head -1 | awk '{print $2}'`
32 if [[ ${pulsemode} = false ]]; then
37 configname=`grep "Config name:" $CFNAME | head -1 | awk '{print $3}'`
39 runno=`grep first_event $TMPMD | head -1 | awk '{print $3}' | sed -e "s/,//g"`
40 firstevent=`grep first_event $TMPMD | head -1 | awk '{print $5}'`
41 lastevent=`grep last_event $TMPMD | head -1 | awk '{print $5}'`
42 eventcountline=`grep event_count $TMPMD | head -1 | sed -e "s/,//g"`
43 starttimeline=`grep start_time $TMPMD | head -1 | sed -e "s/,//g"`
44 endtimeline=`grep end_time $TMPMD | head -1 | sed -e "s/,//g"`
47 echo \ \"file_name\": \"`basename $1`\",
48 echo \ \"file_type\": \"detector\",
49 echo \ \"data_tier\": \"raw\",
50 echo \ \"file_size\": `stat -c%s $1`,
51 echo \ ${starttimeline},
52 echo \ ${endtimeline},
53 echo \ ${eventcountline},
54 echo \ \"first_event\": ${firstevent},
55 echo \ \"last_event\": ${lastevent},
63 echo \ \"DUNE.campaign\": \"iceberg\",
64 echo \ \"data_stream\": \"cosmics\",
65 echo \ \"DUNE_data.fegain\": ${gain},
66 echo \ \"DUNE_data.feshapingtime\": ${shapetime},
67 echo \ \"DUNE_data.acCouple\": ${accouple},
68 echo \ \"DUNE_data.febaselineHigh\": ${baselineHigh},
69 echo \ \"DUNE_data.feleakHigh\": ${leakHigh},
70 echo \ \"DUNE_data.feleak10x\": ${leak10x},
71 echo \ \"DUNE_data.calibpulsemode\": ${pulsemode},
72 echo \ \"DUNE_data.DAQConfigName\": \"${configname}\",
77 if [ "$components" = "" ]; then
80 components=${line2}:${components}
83 echo \ \"DUNE_data.detector_config\": \"${components}\"
93 source /home/nfs/dunecet/offlsetup.sh
94 source /cvmfs/oasis.opensciencegrid.org/mis/osg-wn-client/current/el7-x86_64/setup.sh
97 find $1 | grep iceberg | grep root | grep -v decode | grep -v json | grep -v anal | while read line
99 echo Making metadata json for $line
100 jsonfile=`basename $line`.json
101 if [ -e $jsonfile ]; then
102 echo $jsonfile already exists, not re-making it.
104 iceberg_metadata_single_file $line > $jsonfile
105 samweb declare-file $jsonfile
107 echo "mv'ing $line to the dropbox"
108 mv $line /data1/dropbox/