#!/bin/bash # HIMster script ---------------------------------------------------------------------- # part2: run an alignment # each misalignment consts combination used in ${nDataSamp} diff. data samples # each data sample used in a sum from 1 to ${nDataSamp} samples # each sample contains $numEv events (2e4) # ver 1.0 [16/07/2014] # author: A.Karavdina # --------------------------------------------------------------------------------------- nDataSamp=100 #nConsSamp=10 nConsSamp=5 numEv=50000 #number of events in one sample #TRANS=(0 10 50 100 200 300 400 500 600 700 800 1000) #mkm #TRANS=(0 10 50 100 200 300 400 500 600 700 800) #mkm #TRANS=(10 50 100 200 300 400 500 0) #mkm #TRANS=(50 100 200 300 400 500 600 700 10 0) #mkm TRANS=(0) #mkm #ROT=(0 0.2 1 3 5) #mrad #ROT=(3 1 5 0) #mrad ROT=(0) #mrad TRANSN=${#TRANS[@]} ROTN=${#ROT[@]} #----------------------------------------------------------------------------------------- verbose=0 PANDAROOT=/home/karavdin/pandaroot13 PANDAROOTmy=/home/karavdin/develop/karavdina/ # #---------------------------------------------------------------------- #pbeam=1.5 echo Enter momentum from "1.5, 4.06, 8.9, 11.91, 15 [GeV/c]": read pbeam echo "Beam mometum is: $pbeam!" momStr=`echo $pbeam | sed -e '{ s/\./_/g; }'` #pathG=/home/karavdin/datastorage/AlignmentLMDpixel/100data_10consts_SamplesStudyOct2013/BOX/mom_${momStr} pathG=/home/karavdin/datastorage/AlignmentLMDpixel/RECdataAUG2014/BOX/mom_${momStr} pathMC=/home/karavdin/datastorage/AlignmentLMDpixel/MCdataJuly2014/BOX/mom_${momStr} mkdir -p ${pathG} # if [ ! -r ${pathG}/MCsamples ]; then # mkdir ${pathG}/MCsamples # fi if [ ! -r ${pathG}/misalignConsts ]; then mkdir ${pathG}/misalignConsts fi numTrks=1 mergedHits=true #switch on "missing plane" search algorithm misspl=true #use cuts during trk seacrh with "CA". Should be 'false' if sensors missaligned! trkcut=false useMSerr=false doalign=true ##Skip kinematic filter (before back-propagation) SkipFilt=true ### if SkipFilt=false (XThetaCut or YPhiCut) or BoxCut should be true: ### X-Theta kinematic cut before back-propagation, add constant shift dX[cm] if beam is shifted XThetaCut=false dX=0. ### Y-Phi kinematic cut before back-propagation, add constant shift dY[cm] if beam is shifted YPhiCut=false dY=0. ### BOX cut before back-propagation BoxCut=false ## Clean after back-propagation (M-cut: momentum or MVA cut) CleanSig=false ## Combined filter (X&Y and M-cut) CombFilt=false ## Write all MC info in TrkQA array WrAllMC=false ############## ##ITTER=(1) ##ITTERN=${#ITTER[@]} ### pick up half solenoid maps for 1.5 GeV/c [tmp, should be removed one day!] ### source /home/karavdin/pandaroot13/buildPanda/config.sh # solsw=3 #GeV, switch between half and full solenoid: below half of solenoid # if [[ $(echo "if (${pbeam} > ${solsw}) 1 else 0" | bc) -eq 1 ]]; then # echo "FULL solenoid field maps" # ln -sf ${VMCWORKDIR}/input/solenoid_fc/* ${VMCWORKDIR}/input/. # else # echo "HALF solenoid field maps" # ln -sf ${VMCWORKDIR}/input/solenoid_hc/* ${VMCWORKDIR}/input/. # fi # ###################################################### for (( jr=0;jr<$ROTN;jr++)); do for (( jt=0;jt<$TRANSN;jt++)); do dr=${TRANS[${jt}]} da=${ROT[${jr}]} daStr=`echo $da | sed -e '{ s/\./_/g; }'` for(( js=0;js<${nConsSamp};js++));do #samples with diff Delta_x, Delta_al in the same scale # for(( js=5;js<${nConsSamp};js++));do #samples with diff Delta_x, Delta_al in the same scale pathDxDa=${pathG}/${dr}mkm_${daStr}mrad/ConstSample${js} if [ ! -r ${pathDxDa} ]; then echo "Beam path ${pathDxDa} doesn't exist!" fi for jsn in `seq 0 ${step} $(( ${nDataSamp} - 1))`; do path=${pathDxDa}/RECrawDataSample${jn}/ path_res=${pathDxDa}/RECsum$((${jsn}+1))DataSamples/ if [ ! -r ${path_res} ]; then mkdir -p ${path_res} fi cat > ${path_res}/QA_hitsSamples.log < ${path_res}/names_hits_sec${jm}.log <> ${path_res}/QA_hitsSamples.log fi if [ -r ${path}/hits_trk_for_alignment_sector${jm}.txt ]; then echo -n "${path}/hits_trk_for_alignment_sector${jm}.txt " >> ${path_res}/names_hits_sec${jm}.log fi done done done for jsn in `seq 0 ${step} $(( ${nDataSamp} - 1))`; do path_res=${pathDxDa}/RECsum$((${jsn}+1))DataSamples/ path_resLOC=/local/scratch/karavdina/${dr}mkm_${daStr}mrad_${momStr}/${js}Sum$((${jsn}+1))Samples/ if [ ! -d jobs/align/mom_${momStr}/ ]; then mkdir -p jobs/align/mom_${momStr}/ fi numEvKnossos=$(expr $(expr ${jsn} + 1) \* $numEv) #echo "current number of events is $numEvKnossos" # numEvKnossos = expr ((${jsn}+1)) \* $numEv cat >jobs/align/mom_${momStr}/job_${dr}mkm_${daStr}mrad_${js}Sum${jsn}.sh <> ${path_resLOC}/hits_trk_for_alignment_sector0.txt cat ${filenames1} `cat ${path_res}/names_hits_sec1.log` >> ${path_resLOC}/hits_trk_for_alignment_sector1.txt cat ${filenames2} `cat ${path_res}/names_hits_sec2.log` >> ${path_resLOC}/hits_trk_for_alignment_sector2.txt cat ${filenames3} `cat ${path_res}/names_hits_sec3.log` >> ${path_resLOC}/hits_trk_for_alignment_sector3.txt cat ${filenames4} `cat ${path_res}/names_hits_sec4.log` >> ${path_resLOC}/hits_trk_for_alignment_sector4.txt cat ${filenames5} `cat ${path_res}/names_hits_sec5.log` >> ${path_resLOC}/hits_trk_for_alignment_sector5.txt cat ${filenames6} `cat ${path_res}/names_hits_sec6.log` >> ${path_resLOC}/hits_trk_for_alignment_sector6.txt cat ${filenames7} `cat ${path_res}/names_hits_sec7.log` >> ${path_resLOC}/hits_trk_for_alignment_sector7.txt cat ${filenames8} `cat ${path_res}/names_hits_sec8.log` >> ${path_resLOC}/hits_trk_for_alignment_sector8.txt cat ${filenames9} `cat ${path_res}/names_hits_sec9.log` >> ${path_resLOC}/hits_trk_for_alignment_sector9.txt PANDAROOT=/home/karavdin/pandaroot13 cd ${PANDAROOT}/macro/lmd source ${PANDAROOT}/buildPanda/config.sh cd ${PANDAROOTmy}/myKnossos ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector0.txt -o ${path_resLOC}/LumiAlignConst_sector0.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos0 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector1.txt -o ${path_resLOC}/LumiAlignConst_sector1.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos1 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector2.txt -o ${path_resLOC}/LumiAlignConst_sector2.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos2 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector3.txt -o ${path_resLOC}/LumiAlignConst_sector3.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos3 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector4.txt -o ${path_resLOC}/LumiAlignConst_sector4.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos4 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector5.txt -o ${path_resLOC}/LumiAlignConst_sector5.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos5 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector6.txt -o ${path_resLOC}/LumiAlignConst_sector6.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos6 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector7.txt -o ${path_resLOC}/LumiAlignConst_sector7.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos7 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector8.txt -o ${path_resLOC}/LumiAlignConst_sector8.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos8 ./knossos -i ${path_resLOC}/hits_trk_for_alignment_sector9.txt -o ${path_resLOC}/LumiAlignConst_sector9.txt -n ${numEvKnossos} -r 1 &> ${path_resLOC}/logKnossos9 if [ -r ${path_resLOC}/LumiAlignConst.txt ]; then rm ${path_resLOC}/LumiAlignConst.txt fi cat ${path_resLOC}/LumiAlignConst_sector0.txt ${path_resLOC}/LumiAlignConst_sector1.txt ${path_resLOC}/LumiAlignConst_sector2.txt ${path_resLOC}/LumiAlignConst_sector3.txt ${path_resLOC}/LumiAlignConst_sector4.txt ${path_resLOC}/LumiAlignConst_sector5.txt ${path_resLOC}/LumiAlignConst_sector6.txt ${path_resLOC}/LumiAlignConst_sector7.txt ${path_resLOC}/LumiAlignConst_sector8.txt ${path_resLOC}/LumiAlignConst_sector9.txt > ${path_resLOC}/LumiAlignConst.txt if [ -r ${path_resLOC}/ModulesStat.txt ]; then rm ${path_resLOC}/ModulesStat.txt fi echo "Module #0:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos0 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos0 >> ${path_resLOC}/ModulesStat.txt echo "Module #1:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos1 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos1 >> ${path_resLOC}/ModulesStat.txt echo "Module #2:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos2 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos2 >> ${path_resLOC}/ModulesStat.txt echo "Module #3:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos3 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos3 >> ${path_resLOC}/ModulesStat.txt echo "Module #4:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos4 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos4 >> ${path_resLOC}/ModulesStat.txt echo "Module #5:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos5 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos5 >> ${path_resLOC}/ModulesStat.txt echo "Module #6:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos6 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos6 >> ${path_resLOC}/ModulesStat.txt echo "Module #7:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos7 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos7 >> ${path_resLOC}/ModulesStat.txt echo "Module #8:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos8 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos8 >> ${path_resLOC}/ModulesStat.txt echo "Module #9:" >> ${path_resLOC}/ModulesStat.txt grep "Alignment based on" ${path_resLOC}/logKnossos9 >> ${path_resLOC}/ModulesStat.txt grep "Last iteration used" ${path_resLOC}/logKnossos9 >> ${path_resLOC}/ModulesStat.txt if [ -r ${path_res}/lumi.misalign_pixel_after.par ]; then rm ${path_res}/lumi.misalign_pixel_after.par fi cp ${pathG}/misalignConsts/lumi.misalign_pixel_${dr}mkm_${daStr}mrad_${js}.par ${path_resLOC}/lumi.misalign_pixel.par head -16 ${path_resLOC}/lumi.misalign_pixel.par >> ${path_resLOC}/lumi.misalign_pixel_after.par cd ${PANDAROOT}//buildPanda/bin ./analyze_alignment -stat ${path_resLOC}/ModulesStat.txt -in ${path_resLOC}/lumi.misalign_pixel.par -out ${path_resLOC}/LumiAlignConst.txt -new ${path_resLOC}/lumi.misalign_pixel_after.par -outroot ${path_resLOC}/KnossosResults.root ## mv ${path_resLOC}/logKnossos* ${path_res}/. mv ${path_resLOC}/logKnossos0 ${path_res}/. mv ${path_resLOC}/hits_trk_for_alignment_sector0.txt ${path_res}/. mv ${path_resLOC}/LumiAlignConst.txt ${path_res}/. mv ${path_resLOC}/lumi.misalign_pixel_after.par ${path_res}/. mv ${path_resLOC}/KnossosResults.root ${path_res}/. rm -r ${path_resLOC} rm ${path_res}/names_* echo "Time: `date` " exit 0 EOF # echo "Output files will be saved in $path_res" ### submit job to batch system iter=0 while [ $iter -lt 1 ];do qsub jobs/align/mom_${momStr}/job_${dr}mkm_${daStr}mrad_${js}Sum${jsn}.sh done_test=$(echo $?) if [ "$done_test" -eq "0" ];then echo "Output files will be saved in $path_res" iter=1 else echo "qsub did not work sleep for 60 seconds and then try again." sleep 60 fi done done done done done