#!/bin/bash if [ -z "$MacroDir" ]; then if [ -z "$1" ]; then echo 'no macro directory specified' exit 1 else MacroDir=$1 fi fi if [ -z "$UnpackDir" ]; then if [ -z "$2" ]; then echo 'no unpack directory specified' exit 1 else UnpackDir=$2 fi fi if [ -z "$CluDir" ]; then if [ -z "$3" ]; then echo 'no clu directory specified' exit 1 else CluDir=$3 fi fi if [ -z "$AnaDir" ]; then if [ -z "$4" ]; then echo 'no ana directory specified' exit 1 else AnaDir=$4 fi fi if [ -z "$SimulationDir" ]; then if [ -z "$5" ]; then echo 'no simulation directory specified' exit 1 else SimulationDir=$5 fi fi if [ -z "$iNDigiFiles" ]; then if [ -z "$6" ]; then echo 'no number of digi files specified' exit 1 else iNDigiFiles=$6 fi fi if [ -z "$MCFileName" ]; then if [ -z "$7" ]; then echo 'no MC file name specified' exit 1 else MCFileName=$7 fi fi if [ -z "$iNMCFiles" ]; then if [ -z "$8" ]; then echo 'no number of MC files specified' exit 1 else iNMCFiles=$8 fi fi if [ -z "$cGeometry" ]; then if [ -z "$9" ]; then echo 'no geometry tag specified' exit 1 else cGeometry=$9 fi fi if [ -z "$iDut" -o "${#iDut}" != "3" ]; then if [ -z "${10}" -o "${#10}" != "3" ]; then echo 'no valid Dut specified' exit 1 else iDut=${10} fi fi if [ -z "$iMRef" -o "${#iMRef}" != "3" ]; then if [ -z "${11}" -o "${#11}" != "3" ]; then echo 'no valid MRef specified' exit 1 else iMRef=${11} fi fi if [ -z "$iBRef" -o "${#iBRef}" != "3" ]; then if [ -z "${12}" -o "${#12}" != "3" ]; then echo 'no valid BRef specified' exit 1 else iBRef=${12} fi fi if [ -z "$iSel2" -o "${#iSel2}" != "3" ]; then if [ -z "${13}" -o "${#13}" != "3" ]; then echo 'no valid Sel2 specified' exit 1 else iSel2=${13} fi fi if [ -z "$dScaleFactor" ]; then if [ -z "${14}" ]; then echo 'no scale factor specified' exit 1 else dScaleFactor=${14} fi fi if [ -z "$bIdealCalibration" ]; then if [ -z "${15}" ]; then echo 'no calibration flag specified' exit 1 else bIdealCalibration=${15} fi fi if [ -z "$bHeavyIonCollisions" ]; then if [ -z "${16}" ]; then echo 'no collision flag specified' exit 1 else bHeavyIonCollisions=${16} fi fi if [ -z "$bSeparateHitFile" ]; then if [ -z "${17}" ]; then echo 'no hit file flag specified' exit 1 else bSeparateHitFile=${17} fi fi if [ -z "$bIdealClustering" ]; then if [ -z "${18}" ]; then echo 'no clustering flag specified' exit 1 else bIdealClustering=${18} fi fi if [ -z "$bAnalysisMCQA" ]; then if [ -z "${19}" ]; then echo 'no analysis MC QA flag specified' exit 1 else bAnalysisMCQA=${19} fi fi if [ -z "$cSetupName" ]; then if [ -z "${20}" ]; then echo 'no setup specified' exit 1 else cSetupName=${20} fi fi if [ -z "$bSimData" ]; then if [ -z "${21}" ]; then echo 'no data type specified' exit 1 else bSimData=${21} fi fi if [ -z "$iCalibrationMode" ]; then if [ -z "${22}" ]; then echo 'no calibration mode specified' exit 1 else iCalibrationMode=${22} fi fi if [ -z "$dTimeInSpill" ]; then if [ -z "${23}" ]; then echo 'no time in spill specified' exit 1 else dTimeInSpill=${23} fi fi if [ -z "$iNTISBins" ]; then if [ -z "${24}" ]; then echo 'no N TIS bins specified' exit 1 else iNTISBins=${24} fi fi if [ -z "$VMCWORKDIR" ]; then echo 'no ROOT environment available' exit 1 fi if [ ! -d "${MacroDir}" ]; then echo 'macro directory does not exist' exit 1 fi if [ ! -d "${UnpackDir}" -o ! -d "${CluDir}" -o ! -d "${AnaDir}" ]; then echo 'unpack/clu/ana directory does not exist' exit 1 fi dDTres=10000000 compare_result=1 iStep=0 iStepLast=0 if [ "${bIdealCalibration}" == "0" -a "${iCalibrationMode}" == "1" ]; then while [ "$compare_result" -eq "1" ]; do for iCal in 1 2 3 5 6 1 do ((iStepLast = ${iStep})) ((iStep += 1)) mkdir ${AnaDir}/Iter${iStep} cp -v ${MacroDir}/.rootrc ${AnaDir}/Iter${iStep}/ cp -v ${MacroDir}/rootlogon.C ${AnaDir}/Iter${iStep}/ cd ${AnaDir}/Iter${iStep} # copy previous calibration file if [ "$iStep" -gt "1" ]; then cp -v ${AnaDir}/Iter${iStepLast}/calib_ana.cor_out.root ${AnaDir}/Iter${iStep}/calib_ana.cor_in.root fi # generate new calibration file root -b -q ''${MacroDir}'/ana_hits.C(10000000,'${iCal}',"'${UnpackDir}'","'${CluDir}'",\ "'${SimulationDir}'",'${iNDigiFiles}',"'${MCFileName}'",'${iNMCFiles}',\ "'${cGeometry}'","'${cSetupName}'",'${bIdealCalibration}','${bHeavyIonCollisions}',\ '${bIdealClustering}','${bSeparateHitFile}',kFALSE,\ '${iDut}','${iMRef}','${iBRef}','${iSel2}','${dScaleFactor}','${bSimData}',\ '${iCalibrationMode}',kFALSE,'${dTimeInSpill}','${iNTISBins}')' rm ${AnaDir}/Iter${iStep}/all_* rm ${AnaDir}/Iter${iStep}/hits.out.root done if [ ! -e ./Test.res ]; then echo 'file Test.res does not exist' exit 1 fi Tres=`cat ./Test.res` dTdif=`echo "$dDTres - $Tres" | bc` dDTres=`echo "$dDTres - 0.001" | bc` compare_result=`echo "$Tres < $dDTres" | bc` echo "got Tres = $Tres, compare to $dDTres, dTdif = $dTdif, compare_result = $compare_result" if [ "$compare_result" -eq "1" ]; then dDTres=$Tres fi done fi # final action -> scan full statistics mkdir ${AnaDir}/Final cp -v ${MacroDir}/.rootrc ${AnaDir}/Final/ cp -v ${MacroDir}/rootlogon.C ${AnaDir}/Final/ cd ${AnaDir}/Final if [ "$iStep" -gt "1" ]; then cp -v ${AnaDir}/Iter${iStep}/calib_ana.cor_out.root ${AnaDir}/Final/calib_ana.cor_in.root fi root -b -q ''${MacroDir}'/ana_hits.C(1000000000,0,"'${UnpackDir}'","'${CluDir}'",\ "'${SimulationDir}'",'${iNDigiFiles}',"'${MCFileName}'",'${iNMCFiles}',\ "'${cGeometry}'","'${cSetupName}'",'${bIdealCalibration}','${bHeavyIonCollisions}',\ '${bIdealClustering}','${bSeparateHitFile}','${bAnalysisMCQA}',\ '${iDut}','${iMRef}','${iBRef}','${iSel2}','${dScaleFactor}','${bSimData}',\ '${iCalibrationMode}',kTRUE,'${dTimeInSpill}','${iNTISBins}')' rm ${AnaDir}/Final/all_* rm ${AnaDir}/Final/hits.out.root cp -v ${AnaDir}/Final/ana_cluster.hst.root ${AnaDir}/hst/final_ana_cluster.hst.root cp -v ${AnaDir}/Final/calib_ana.cor_out.root ${AnaDir}/hst/final_calib_ana.cor_out.root