ProcessSingleFile.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 args=("$@")
4 argssize=${#args[*]}
5 if [ $argssize -ne 3 ];then
6  echo ""
7  echo "Three input arguments must be provided! Exiting..."
8  echo ""
9  echo ""
10  exit
11 fi
12 
13 RunDir=${args[0]}
14 infile=${args[1]}
15 LPDir=${args[2]}
16 
17 INFILE=`basename $infile`
18 
19 fileend=.root
20 outhistfile=${INFILE%$fileend}_nearline_hist.root
21 outhistfilemuon=${INFILE%$fileend}_nearline_muon_counters.root
22 
23 export LOCKFILE=$INFILE.LOCK
24 export DONEFILE=$INFILE.DONE
25 
26 START_DATE=`date`
27 
28 # Touch a lock file...
29 echo "Creating file $infile.LOCK"
30 touch $RunDir/$LOCKFILE
31 
32 # Create a hard link...
33 ln ${infile} /data/lbnedaq/data/nearline-monitoring-links/${INFILE}
34 
35 # Setup the LArSoft environment...
36 echo ""
37 echo "Setting up LArSoft/DUNETPC:"
38 source /grid/fermiapp/products/dune/setup_dune.sh
39 cd $LPDir
40 source ./setup
41 cd ..
42 mrbslp
43 echo ""
44 
45 # Move into the appropriate output directory...
46 cd $RunDir
47 
48 export infilesize=`ls -l $infile | awk '{ print $5 }'`
49 
50 
51 # Skip files that are too small and probably DAQ junk...
52 if [ $infilesize -gt 500 ];
53 then
54  echo "Processing /data/lbnedaq/data/nearline-monitoring-links/${INFILE}"
55 
56  PEDESTAL=`cat /data/lbnedaq/pedestals/current_run.txt`
57  NEARLINE_PEDESTAL=/data/lbnedaq/pedestals/database_pedestals/offline_databaseRun_${PEDESTAL}.csv
58  if [ -e $NEARLINE_PEDESTAL ];then
59  export NEARLINE_PEDESTAL=$NEARLINE_PEDESTAL
60  else
61  export NEARLINE_PEDESTAL="/home/lbnedaq/nearline/pedestal_files/offline_databaseRun_9754.csv"
62  fi
63 
64  echo "Setting pedestal to: $NEARLINE_PEDESTAL"
65 
66  lar -c test_stitcher_nearlineana.fcl -n 10 /data/lbnedaq/data/nearline-monitoring-links/${INFILE} -T $outhistfile
67 
68  END_NEARLINE_ANA=`date`
69 
70  lar -c nearline_muoncounter35t.fcl /data/lbnedaq/data/nearline-monitoring-links/${INFILE} -T $outhistfilemuon
71 
72  END_NEARLINE_MUON=`date`
73 
74 fi
75 
76 
77 
78 # Remove lock file...
79 rm -v $RunDir/$LOCKFILE
80 
81 # Remove hard link...
82 rm -f /data/lbnedaq/data/nearline-monitoring-links/${INFILE}
83 
84 END_DATE=`date`
85 
86 # Touch done file...
87 touch $RunDir/$DONEFILE
88 
89 echo "START_DATE $START_DATE" >> $RunDir/$DONEFILE
90 echo "END_NEARLINE_ANA $END_NEARLINE_ANA" >> $RunDir/$DONEFILE
91 echo "END_NEARLINE_MUON $END_NEARLINE_MUON" >> $RunDir/$DONEFILE
92 echo "END_DATE $END_DATE" >> $RunDir/$DONEFILE
93 echo "NEARLINE_PEDESTAL $NEARLINE_PEDESTAL" >> $RunDir/$DONEFILE
94 
95 echo ""
96 echo "Done with file $infile..."
97 echo ""
98 echo ""