ProcessSingleFileEVD.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}_evd.root
21 
22 export LOCKFILE=${INFILE}EVD.LOCK
23 export DONEFILE=${INFILE}EVD.DONE
24 
25 START_DATE=`date`
26 
27 # Touch a lock file...
28 echo "Creating file ${infile}EVD.LOCK"
29 touch $RunDir/$LOCKFILE
30 
31 # Create a hard link...
32 ln ${infile} /data/lbnedaq/data/nearline-monitoring-links/${INFILE}
33 
34 # Setup the LArSoft environment...
35 echo ""
36 echo "Setting up LArSoft/DUNETPC:"
37 source /grid/fermiapp/products/dune/setup_dune.sh
38 cd $LPDir
39 source ./setup
40 cd ..
41 mrbslp
42 echo ""
43 
44 # Move into the appropriate output directory...
45 cd $RunDir
46 
47 export infilesize=`ls -l $infile | awk '{ print $5 }'`
48 
49 
50 # Skip files that are too small and probably DAQ junk...
51 if [ $infilesize -gt 500 ];
52 then
53  echo "Processing /data/lbnedaq/data/nearline-monitoring-links/${INFILE}"
54 
55  PEDESTAL=`cat /data/lbnedaq/pedestals/current_run.txt`
56  NEARLINE_PEDESTAL=/data/lbnedaq/pedestals/database_pedestals/offline_databaseRun_${PEDESTAL}.csv
57  if [ -e $NEARLINE_PEDESTAL ];then
58  export NEARLINE_PEDESTAL=$NEARLINE_PEDESTAL
59  else
60  export NEARLINE_PEDESTAL="/home/lbnedaq/nearline/pedestal_files/offline_databaseRun_9754.csv"
61  fi
62 
63  echo "Setting pedestal to: $NEARLINE_PEDESTAL"
64 
65  lar -c ctreeraw35t_trigTPC.fcl -n 10 /data/lbnedaq/data/nearline-monitoring-links/${INFILE}
66 
67  # Rename the output file for the RED35 EVD so that the script that looks for the most recent file
68  # knows that the processing is finished.
69  mv sample.root sample_done.root
70 
71  # Don't know why this text file gets created. Probably could be turned off at the fcl level.
72  # Just going to remove it manually for now...
73  rm -fv WireGeometry.txt
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_DATE $END_DATE" >> $RunDir/$DONEFILE
91 echo "NEARLINE_PEDESTAL $NEARLINE_PEDESTAL" >> $RunDir/$DONEFILE
92 
93 echo ""
94 echo "Done with file $infile..."
95 echo ""
96 echo ""