ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/HiggsAnalysis/EarlyDataStudy/scripts/heds.sh
Revision: 1.5
Committed: Sat May 8 16:00:10 2010 UTC (14 years, 11 months ago) by mangano
Content type: application/x-sh
Branch: MAIN
Changes since 1.4: +233 -6 lines
Log Message:
make script more user friendly

File Contents

# User Rev Content
1 mangano 1.1 #!/bin/bash
2    
3     ######################################################
4     # heds 0 (create new directories)
5     # heds 1 (query runregistry)
6     # heds 2 (create crab task)
7     # heds 3 (get and publish jobs)
8     # heds 4 (create all the html tables and store logs)
9     # heds 5* (event display stuff)
10     ######################################################
11    
12     choice=$1
13    
14     dailySkim=$HEDS_NAMEPREFIX$HEDS_LABEL-v$HEDS_TASKATTEMPT
15    
16    
17    
18     case $choice in
19 mangano 1.5 ######### "public functions" which are meant to be called by the users ################
20     up) ### bootstrap for heds job submission. It creates the intial configuration file
21     cat > ./heds.cfg <<EOF
22     HEDS_LABEL=18.04.2010
23     HEDS_INPUTDATASET=/MinimumBias/Commissioning10-PromptReco-v8/RECO
24     HEDS_SKIMVERSION=20
25     HEDS_TASKATTEMPT=1
26    
27     HEDS_USERID=mangano
28     HEDS_T2SITE=T2_US_UCSD
29    
30     HEDS_LOCALSTORE=""
31    
32    
33     ### TO BE FIXED. THESE VARIABLE COULD BE RETRIEVED FROM A QUERY TO PHEDEX ###
34     HEDS_STORAGEPATH=/srm/v2/server?SFN=/hadoop/cms
35     HEDS_STORAGEPORT=8443
36     EOF
37     echo -e "+++ Bootstrap of \"heds\" scripts peformed"
38     echo -e "+++ The configuration file \"heds.cfg\" has been created in the current folder:"
39     echo -e " "$PWD "\n"
40     echo "+++ Edit the heds.cfg according to your needs and then execute: "
41     echo -e " ""heds.sh create heds.cfg"
42     ;;
43    
44     create) ### create local heds taskFolder
45     configFile=$2
46     if [ -z "$configFile" ]; then
47     echo "+++ ERROR: you have to specify the configuration file as in:"
48     echo " heds.sh create <heds.cfg>"
49     exit 1
50     fi
51    
52     if [ -z "$CMSSW_BASE" ]; then
53     echo "+++ ERROR: you have to setup CMSSW environment first. Run cmsenv";
54     (exit 1;)
55     fi
56    
57     if [ ! -d $CMSSW_BASE/src/HiggsAnalysis/EarlyDataStudy/scripts ]; then
58     echo "+++ ERROR: you have to checkout and compile \"HiggsAnalysis/EarlyDataStudy\" first.";
59     (exit 1;)
60     fi
61    
62    
63    
64     # get rid of lines with comments
65     grep -v '^#' $configFile > tmpFile
66     mv tmpFile ${configFile}
67    
68     # add export lines
69     grep -v '^$' ${configFile}| awk '{print "export "$0}' > tmpFile
70     mv tmpFile ${configFile}
71    
72     # define default taskFolder if it is not defined in the cfg file
73     autoString=heds_taskFolder_`date '+%d_%m_%Y_%H_%M'`
74     source ${configFile}
75     if [ -z "$HEDS_LOCALSTORE" ]; then
76     sed "s#HEDS_LOCALSTORE=\"\"#HEDS_LOCALSTORE=$autoString#" ${configFile} > tmpFile
77     mv tmpFile ${configFile}
78     fi
79    
80     # make taskFolder path absolute
81     tmpString="HEDS_LOCALSTORE=`pwd`/"
82     sed "s#HEDS_LOCALSTORE=#$tmpString#" ${configFile} > tmpFile
83     mv tmpFile ${configFile}
84    
85     source ${configFile}
86    
87     cat >> ${configFile} <<EOF
88     export HEDS_NAMEPREFIX=HiggsSimpleSkimV${HEDS_SKIMVERSION}\_
89     export HEDS_CASTORFOLDER=/castor/cern.ch/user/${HEDS_USERID:0:1}/$HEDS_USERID/HEDS
90     export HEDS_WWWAREA_TMP=${HEDS_LOCALSTORE}/wwwPagesInPreliminaryShape
91     export HEDS_WWWAREA=/afs/cern.ch/cms/Physics/Higgs/HiggsDQM/HiggsEDS
92     EOF
93    
94    
95    
96     if [ -d $HEDS_LOCALSTORE ]; then
97     echo "ERROR: the folder" $HEDS_LOCALSTORE "already exists." \
98     "Plese specify a different one in your .cfg file"
99     exit 1
100     else
101     mkdir $HEDS_LOCALSTORE
102     mv ./${configFile} $HEDS_LOCALSTORE/configuration
103     fi
104    
105    
106    
107     # STILL TO BE IMPLEMENTED
108     #if [ -z "$localFolder" ]; then
109     # echo "+++ WARNING: HEDS_LOCALSTORE wasn t set in the cfg file. The following folder will be used:"
110     ##
111     ###
112     #fi
113     ;;
114    
115     submit) ### start doing something serious using the settings stored in the hedsTaskFolder
116     hedsTaskFolder=$2
117     if [ -z "$hedsTaskFolder" -o ! -d ./$hedsTaskFolder ]; then
118     echo -e "+++ ERROR: you have to specify a \"hedsTaskFolder\" as in: "
119     echo " heds.sh submit <hedsTaskFolder>"
120     exit 1
121     fi
122    
123     echo -e "+++ Your heds task is going to use the following settings: \n"
124    
125     source ./$hedsTaskFolder/configuration
126     env |grep -i heds
127     echo -e "\n"
128    
129     echo -e "+++ Are you Ok with such settings? [y/n] "
130    
131    
132     read -p "$prompt" answer
133     case "$answer" in
134     [yY1] )
135     echo "you said you are happy"
136     ;;
137     [nN0] )
138     echo "you said you are not happy"
139     exit
140     ;;
141     *)
142     echo -e "Incorrect answer. Run \"heds submit\" again and type [y/n]"
143     exit
144     ;;
145     esac
146    
147     initialFolder=`pwd`
148     cd $HEDS_LOCALSTORE
149     heds.sh 0 #create setup
150     heds.sh 1 #query runregistry, create crab cfg
151     heds.sh 2 #submit crab jobs
152     cd $initialFolder
153     ;;
154    
155    
156     status) ### check status
157     hedsTaskFolder=$2
158     if [ -z "$hedsTaskFolder" -o ! -d ./$hedsTaskFolder ]; then
159     echo -e "+++ ERROR: you have to specify a \"hedsTaskFolder\" as in: "
160     echo " heds.sh status <hedsTaskFolder>"
161     exit 1
162     fi
163     source ./$hedsTaskFolder/configuration
164     echo "\"heds status\" call is not implementd yet"
165     ;;
166    
167    
168     get) ### get output from crab
169     hedsTaskFolder=$2
170     if [ -z "$hedsTaskFolder" -o ! -d ./$hedsTaskFolder ]; then
171     echo -e "+++ ERROR: you have to specify a \"hedsTaskFolder\" as in: "
172     echo " heds.sh status <hedsTaskFolder>"
173     exit 1
174     fi
175    
176     cd $HEDS_LOCALSTORE
177     source ./configuration
178     heds.sh 3 #get and publish crab task
179     heds.sh 4c #copy file from the SE
180     cd $initialFolder
181     ;;
182    
183    
184     tables) ### produce html tables
185     hedsTaskFolder=$2
186     if [ -z "$hedsTaskFolder" -o ! -d ./$hedsTaskFolder ]; then
187     echo -e "+++ ERROR: you have to specify a \"hedsTaskFolder\" as in: "
188     echo " heds.sh tables <hedsTaskFolder>"
189     exit 1
190     fi
191     cd $HEDS_LOCALSTORE
192     source ./configuration
193     heds.sh 4a #copy all logs file
194     heds.sh 4b #making skim report
195     heds.sh 4d #merging edm files
196     heds.sh 4f #list of skimmed events
197     heds.sh 4g #copy logs about run selection
198     heds.sh 4h #preparing event dumps
199     heds.sh 4i #preparing final html tables
200     cd $initialFolder
201     ;;
202    
203    
204     store) ### produce html tables
205     hedsTaskFolder=$2
206     if [ -z "$hedsTaskFolder" -o ! -d ./$hedsTaskFolder ]; then
207     echo -e "+++ ERROR: you have to specify a \"hedsTaskFolder\" as in: "
208     echo " heds.sh tables <hedsTaskFolder>"
209     exit 1
210     fi
211     cd $HEDS_LOCALSTORE
212     source ./configuration
213     heds.sh 6 #copy merged log files in CASTOR
214     heds.sh 4e #copy merged edm files in CASTOR
215    
216     cd $initialFolder
217     ;;
218    
219     preview) ### produce html tables
220     hedsTaskFolder=$2
221     if [ -z "$hedsTaskFolder" -o ! -d ./$hedsTaskFolder ]; then
222     echo -e "+++ ERROR: you have to specify a \"hedsTaskFolder\" as in: "
223     echo " heds.sh tables <hedsTaskFolder>"
224     exit 1
225     fi
226     cd $HEDS_LOCALSTORE
227     source ./configuration
228     heds.sh 4j #
229     cd $initialFolder
230     ;;
231    
232    
233    
234    
235     ########## internal "functions" which are not meant to be used by users ###############
236 mangano 1.1 0)
237 mangano 1.5 echo "=== Setting up directories and one-time things ==="
238 mangano 1.1 echo ""
239    
240 mangano 1.3 ### create local folder
241 mangano 1.1 if [ -d $HEDS_LOCALSTORE ]
242 mangano 1.3 then echo "directory " $HEDS_LOCALSTORE "already exists. Then skipping \"mkdir\" "
243 mangano 1.1 else
244     echo "making " $HEDS_LOCALSTORE " directory"
245     mkdir -p $HEDS_LOCALSTORE
246     fi
247    
248 mangano 1.3 ### create WWW folders
249 mangano 1.2 if [ -d $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION ]
250 mangano 1.3 then echo "directory " $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION \
251     " already exists. Then skipping \"mkdir\" "
252    
253     if [ ! -d $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents ]; then
254     echo "making " $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents
255     mkdir -p $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents
256     fi
257    
258 mangano 1.1 else
259 mangano 1.2 echo "making " $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION " directory"
260 mangano 1.3 mkdir -p $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/
261    
262     if [ -d $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION ]; then
263     echo "Warning: " logs.SkimV$HEDS_SKIMVERSION " already exist in final WWW_AREA."
264     echo "Copying base html tables from there."
265 mangano 1.4
266     ##TO BE FIXED. Check that files exist before copy
267 mangano 1.3 cp $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/FirstPage.php \
268     $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/
269     cp $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/tableHeader.shtm \
270     $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/
271     cp $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/tableBody.shtm \
272     $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/
273     fi
274    
275     if [ ! -d $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents ]; then
276     echo "making " $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents
277     mkdir -p $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents
278     fi
279 mangano 1.1 fi
280 mangano 1.3
281    
282     ### create CASTOR folder
283 mangano 1.1 nsls -d $HEDS_CASTORFOLDER/skimV$HEDS_SKIMVERSION >& tmp
284     check=`cat tmp |grep "No such" |wc -w`
285     rm tmp
286     if [ $check == 0 ]
287     then echo "directory " $HEDS_CASTORFOLDER/skimV$HEDS_SKIMVERSION "already exists"
288     else
289     echo "making " $HEDS_CASTORFOLDER/skimV$HEDS_SKIMVERSION " directory"
290     rfmkdir -p $HEDS_CASTORFOLDER/skimV$HEDS_SKIMVERSION
291     fi
292     ;;
293    
294     1)
295     echo "=== you selected option 1. Querying RunRegistry, select good runs and submit crab jobs ==="
296     echo ""
297    
298     dateForDbsSearch=`echo $HEDS_LABEL|awk -F\. '{print $3"-"$2"-"$1}'`
299     echo "dateForDbsSearch: " $dateForDbsSearch
300     dbs search --query="find run where dataset=$HEDS_INPUTDATASET and run.createdate=$dateForDbsSearch" \
301     > tmpRunList.txt
302     lastRun=`cat tmpRunList.txt |grep [0-9][0-9][0-9][0-9][0-9][0-9] |head -n1`
303     firstRun=`cat tmpRunList.txt|tail -n1`
304     rm tmpRunList.txt
305     #TO BE FIXED: add a protection for when there are no runs
306     echo "first,last runs: " $firstRun $lastRun
307    
308    
309     runselection="runselection="
310     cat $HEDSPATH/scripts/runreg.cfg | sed s/SET_RUNMIN/$firstRun/ | \
311     sed s/SET_RUNMAX/$lastRun/ > runreg.cfg
312     python $HEDSPATH/scripts/runregparse.py > tmp.log
313     rm runreg.cfg
314     echo "here we have the good run list"
315    
316     IFS=$'\n'
317     found=0
318     lastGoodRun=0
319     for line in $(cat tmp.log);
320     do
321     if [ $found == 0 ]
322     then
323     found=`echo $line |grep lumisToProcess|wc |awk '{print $1}'`
324     continue;
325     fi
326     if [ $line == ")" ]
327     then
328     break;
329     fi
330     thisRun=`echo $line | sed s/\'//g | sed s/,//g |awk -F: '{print $1}'`
331     if [ $thisRun != $lastGoodRun ]
332     then
333     runselection=$runselection$thisRun\,
334     fi
335     lastGoodRun=$thisRun
336     done
337     #echo "========= THE FOLLOWING LINE TO YOUR crab.cfg FILE ========="
338     echo $runselection
339     #echo "================================================================"
340     echo $runselection > $HEDS_LABEL.runselection
341     echo $firstRun-$lastRun > $HEDS_LABEL.runinterval
342     rm tmp.log
343    
344     check=`echo $runselection | sed s/runselection=// |wc -w`
345    
346     if [ $check == 0 ]
347     then
348     echo "No good runs have been selected. No CRAB cfg will be created."
349     else
350     echo "Some good runs have been selected. CRAB cfg will be created."
351     cat $HEDSPATH/scripts/crab.template.cfg |sed "s#SET_DATASET#$HEDS_INPUTDATASET#" | \
352 mangano 1.3 # sed "s#SET_REMOTEDIR#$HEDS_USERID/HEDS/#" | \
353     sed "s#SET_REMOTEDIR#$HEDS_USERID/#" | \
354 mangano 1.1 sed "s#SET_T2#$HEDS_T2SITE#" | \
355     sed "s/SET_RUNSELECTION/$runselection/" > tmp.cfg
356     pset=$HEDSPATH/python/earlyDataInterestingEvents_cfg.py
357     echo "pset: " $pset
358     cat tmp.cfg |sed s#SET_PSET#$pset# | sed "s#SET_TASK_NAME#$dailySkim#" > tmp2.cfg; rm tmp.cfg
359     mv tmp2.cfg $HEDS_LABEL.crab.cfg
360     fi
361     ;;
362     2)
363     echo "creating and submitting CRAB jobs for " $dailySkim
364     if [ -e $HEDS_LABEL.crab.cfg ]
365     then
366     crab -create -submit -cfg $HEDS_LABEL.crab.cfg
367     if ((! $?)); then rm $HEDS_LABEL.crab.cfg; fi
368     else
369     echo "ERROR: " $HEDS_LABEL.crab.cfg " doesn't exist"
370     fi
371     ;;
372     3)
373     echo "getting output and publishing crab jobs"
374     crab -status -c $dailySkim
375     crab -get -c $dailySkim
376     crab -status -c $dailySkim
377     crab -publish -c $dailySkim
378     ;;
379    
380    
381     4)
382     echo "option 4 "
383     if [ -d $dailySkim ] #the crab job was run on at least 1 run
384     then
385     heds 4a
386     heds 4b
387     heds 4c
388     heds 4d
389     heds 4e
390     heds 4f
391     heds 4g
392     heds 4h
393     heds 4i
394     else
395     echo "copying only the log files about runs and selected-runs"
396     heds 4g
397     fi
398     ;;
399    
400     4a)
401 mangano 1.3 #### echo "...copying log files"
402 mangano 1.1 if [ ! -d $HEDS_LOCALSTORE/$dailySkim/logs ]; then
403     mkdir -p $HEDS_LOCALSTORE/$dailySkim/logs
404     fi
405     cp $dailySkim/res/*.std* $HEDS_LOCALSTORE/$dailySkim/logs
406     if (($?)); then
407     echo "ERROR: failed to copy log files in " $HEDS_LOCALSTORE/$dailySkim/logs;
408     else
409     echo "copied all logs file in " $HEDS_LOCALSTORE/$dailySkim/logs
410     fi
411    
412 mangano 1.5 ###
413 mangano 1.1 tarName=$HEDS_LABEL.log.tgz
414     cd $HEDS_LOCALSTORE/$dailySkim/logs/
415     if (($?));then
416     echo "ERROR: failed to go to " $HEDS_LOCALSTORE/$dailySkim/logs/
417     else
418 mangano 1.3 echo "compriming log files... "
419     tar czvf $tarName *.std* >& /dev/null
420     echo -e "done \n"
421 mangano 1.1 cd -
422     fi
423     ;;
424    
425     4b)
426     ###
427 mangano 1.3 echo -e "creating skimReport..."
428 mangano 1.1 logName=$HEDS_LABEL.log
429     $HEDSPATH/scripts/skimreport $HEDS_LOCALSTORE/$dailySkim/logs/*.stdout > $logName
430 mangano 1.3 mv $logName $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents/
431     echo -e "done \n"
432 mangano 1.1 ;;
433    
434     4c)
435     ###
436     echo "...coping files from the T2's SE"
437     echo "dataset to retreive: " $dailySkim
438     dbs search --url=https://cmsdbsprod.cern.ch:8443/cms_dbs_ph_analysis_02_writer/servlet/DBSServlet \
439     --query="find file,site where dataset=*$dailySkim*" |grep .root >listFiles
440    
441     IFS=$'\n'
442     for j in $(cat listFiles)
443     do
444     echo "going to copy file: $j"
445     fileName=`echo $j |awk '{print$1}'| awk -F$dailySkim/ '{print $2}' | awk -F/ '{print $2}'`
446    
447     storage_elem=`echo $j |awk '{print $2}'`
448     remote_path=`echo $j|awk '{print $1}'`
449     lcg-cp -b -D srmv2 srm://$storage_elem:$HEDS_STORAGEPORT$HEDS_STORAGEPATH$remote_path file://$HEDS_LOCALSTORE/$dailySkim/$fileName
450     done
451     rm listFiles
452     nFiles=`ls $HEDS_LOCALSTORE/$dailySkim/*.root|wc -l`
453     nJobs=`ls $HEDS_LOCALSTORE/$dailySkim/logs/CMSSW_*.stdout |wc -l`
454    
455     ### TO BE FIXED!! this check isn't valid if some job selects zero events (no file is created)
456     #if [ $nFiles == $nJobs ]
457     #then
458     # echo "GOOD: #files copied from hadoop matches #jobs in the CRAB task"
459     #else
460     # echo "ERROR: #files in hadoop doesn't match #jobs in the CRAB task"
461     # exit
462     #fi
463     ;;
464    
465     4d)
466     ###
467 mangano 1.3 echo -e "Merging files edm files..."
468 mangano 1.1 cp $HEDSPATH/scripts/prepareMerging.sh $HEDS_LOCALSTORE/$dailySkim
469     cp $HEDSPATH/scripts/merge.py $HEDS_LOCALSTORE/$dailySkim
470     cd $HEDS_LOCALSTORE/$dailySkim
471    
472     ./prepareMerging.sh
473     numberFilesToMerge=`ls *.root|wc -l`
474     echo "numberFilesToMerge: " $numberFilesToMerge
475     cmsRun merge.py >& merging.log
476 mangano 1.3 echo -e "done \n"
477 mangano 1.1 cd -
478     ;;
479    
480     4e)
481     ###
482 mangano 1.3 echo -e "Storing merged edm file in CASTOR..."
483 mangano 1.1 mergedName=$HEDS_LABEL.root
484     mergedName=merged_$mergedName
485     echo "mergedName: " $mergedName
486     cd $HEDS_LOCALSTORE/$dailySkim
487     if ((! $?)); then
488     mv merged.root ../$mergedName
489     echo "going to copy the merged file into: " $HEDS_CASTORFOLDER/skimV$HEDS_SKIMVERSION
490     rfcp ../$mergedName $HEDS_CASTORFOLDER/skimV$HEDS_SKIMVERSION/
491     cd -
492     fi
493 mangano 1.3 echo -e "done \n"
494 mangano 1.1 ;;
495    
496     4f)
497     ###
498 mangano 1.3 echo "Preparing detailed list of skimmed events..."
499 mangano 1.1 cp $HEDSPATH/scripts/listSkimmedEvent.C $HEDS_LOCALSTORE
500     cd $HEDS_LOCALSTORE
501 mangano 1.3 root.exe -b -q "listSkimmedEvent.C+(\"$HEDS_LABEL\")" >& /dev/null
502 mangano 1.2 listSkimmedEventsPath=$HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents
503 mangano 1.1 if [ ! -d $listSkimmedEventsPath ]
504     then
505     mkdir $listSkimmedEventsPath
506     fi
507     listDetailedLogs=`ls $HEDS_LABEL*`
508     for j in $listDetailedLogs
509     do
510     echo "preparing log " $j
511     # sort entries by date
512     cat $j |sort -k7 > tmp
513     mv tmp $j
514     mv $j $listSkimmedEventsPath
515     done
516 mangano 1.3 echo -e "done \n"
517 mangano 1.1 cd -
518     ;;
519    
520     4g)
521     ###
522 mangano 1.3 echo "Copying logs about run selection..."
523     mv $HEDS_LABEL.runselection $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents
524     mv $HEDS_LABEL.runinterval $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents
525     echo -e "done \n"
526 mangano 1.1 ;;
527    
528     4h)
529     ###
530 mangano 1.3 echo "Preparing event dumps..."
531 mangano 1.1 input=$HEDS_LOCALSTORE/merged_$HEDS_LABEL.root
532     echo "input: " $input
533     sed s#INPUT#$input# $HEDSPATH/scripts/dumpEvent.py > dumpEvent.py
534     cmsRun dumpEvent.py >& $HEDS_LABEL.dumperLog
535     $HEDSPATH/scripts/parseDumperOutput.sh 1 >& $HEDS_LABEL.dump
536     $HEDSPATH/scripts/parseDumperOutput.sh 2
537     rm dumpEvent.py
538     rm $HEDS_LABEL.dumperLog
539     rm $HEDS_LABEL.dump
540 mangano 1.3 echo -e "done \n"
541 mangano 1.1 ;;
542     4i)
543     ###
544 mangano 1.3 echo "Preparing html tables..."
545 mangano 1.2 if [ ! -e $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/FirstPage.php ];then
546 mangano 1.1 echo "create first version of FirstTable.sh"
547     $HEDSPATH/scripts/editFirstTable.sh create
548 mangano 1.3 $HEDSPATH/scripts/createTableSkimDetails.sh add ; echo "level-3 tables produced"
549     $HEDSPATH/scripts/createTableSkimSummary.sh ; echo "level-2 tables produced"
550     $HEDSPATH/scripts/editFirstTable.sh add below ; echo "level-1 table modified"
551     else
552     $HEDSPATH/scripts/createTableSkimDetails.sh clean; echo "clean up old html tables"
553     $HEDSPATH/scripts/createTableSkimDetails.sh add ; echo "level-3 tables produced"
554     $HEDSPATH/scripts/createTableSkimSummary.sh ; echo "level-2 tables produced"
555     $HEDSPATH/scripts/editFirstTable.sh add below ; echo "level-1 table modified"
556     fi
557     echo -e "done \n"
558     ;;
559    
560     4j) ###
561     echo -e "Your preliminary table is available at the following URL: "
562     url="https://cms-project-higgsdqm.web.cern.ch/cms-project-higgsdqm/HiggsEDS/pagesInPreliminaryShape"
563     url=$url"/logs.SkimV$HEDS_SKIMVERSION/FirstPage.php"
564     echo -e $url "\n"
565     echo -e "After you verified that all the tables have been correctly produced, " \
566     "they can be moved to the final repository \n"
567    
568 mangano 1.1 ;;
569 mangano 1.3
570 mangano 1.5
571     6) ### copying stuff to castor
572     tarName=$HEDS_LABEL.log.tgz
573     cd $HEDS_LOCALSTORE/$dailySkim/logs/
574     if (($?));then
575     echo "ERROR: failed to go to " $HEDS_LOCALSTORE/$dailySkim/logs/
576     else
577     echo "copying " $tarName " file to CASTOR area.."
578     rfcp $tarName $HEDS_CASTORFOLDER/skimV$HEDS_SKIMVERSION
579     echo -e "done \n"
580     cd -
581     fi
582     ;;
583    
584 mangano 1.1 5a)
585     echo ".... preparing event display server"
586     mkdir $HEDS_LABEL.shots
587     port=3005
588     $HEDSPATH/scripts/eventDisplayServer.sh $port &
589     ;;
590     5b)
591     echo "getting snapshots"
592     port=3005
593     file=$HEDS_LOCALSTORE/merged_$HEDS_LABEL.root
594     echo "$file" | nc -w 10 localhost $port
595     ;;
596     5c)
597     echo "moving snapshots"
598 mangano 1.2 mv $HEDS_LABEL.shots $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/
599 mangano 1.1 cp $HEDSPATH/scripts/indexFileForDetailedSnapShots.php \
600 mangano 1.2 $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.shots/index.php
601 mangano 1.1 ;;
602    
603    
604 mangano 1.3 final)
605     #TO BE FIXED. this call could written in a much more compact way
606     echo "WWW pages are going to be moved from the temporary repository"
607     echo -e "("$HEDS_WWWAREA_TMP")\n"
608     echo "to the permanent one"
609     echo -e "("$HEDS_WWWAREA")\n"
610    
611     if [ ! -d $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION ]; then
612     mkdir $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION
613     fi
614    
615     if [ -e $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/FirstPage.php ]; then
616     cp $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/FirstPage.php \
617     $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/FirstPage.php.BAK
618     fi
619     if [ -e $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/tableBody.shtm ]; then
620     cp $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/tableBody.shtm \
621     $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/tableBody.shtm.BAK
622     fi
623     if [ -e $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/tableHeader.php ]; then
624     cp $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/tableHeader.shtm \
625     $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/tableHeader.shtm.BAK
626     fi
627    
628     mv $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/*.php \
629     $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/
630     mv $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/*.shtm \
631     $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/
632    
633     mv -T $HEDS_WWWAREA_TMP/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents \
634     $HEDS_WWWAREA/logs.SkimV$HEDS_SKIMVERSION/$HEDS_LABEL.listSkimmedEvents
635    
636    
637     url="https://cms-project-higgsdqm.web.cern.ch/cms-project-higgsdqm/HiggsEDS/"
638     url=$url"/logs.SkimV$HEDS_SKIMVERSION/FirstPage.php"
639    
640     echo "The new tables created by you are accessible through the following URL: "
641     echo $url
642     ;;
643    
644 mangano 1.1 ##################### after the crab part is done ###################
645 mangano 1.2 99) echo "Doing bakcup of $HEDS_WWWAREA_TMP"
646 mangano 1.1 date=`date +%k\.%M\.%S_%e\.%m\.%Y`
647     fileName="HiggsIES.BAK."$date".tgz"
648     echo "file name: " $fileName
649 mangano 1.2 tar -czvf $fileName $HEDS_WWWAREA_TMP
650     mv $fileName $HEDS_WWWAREA_TMP/..
651 mangano 1.1 ;;
652    
653    
654     *)
655     echo "option not defined"
656     ;;
657     esac