diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..a9f5c31 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index dd44c24..01e9e07 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ working/Logs -working/Settings EventBuilder *.root diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 2e598e1..c027a9b 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,5 +1,20 @@ { "configurations": [ + { + "name": "Mac", + "includePath": [ + "${workspaceFolder}/**", + "/Applications/root-6.28.00/include/**" + ], + "defines": [], + "macFrameworkPath": [ + "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks" + ], + "compilerPath": "/usr/bin/g++", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "macos-gcc-arm64" + }, { "name": "Linux", "includePath": [ diff --git a/SOLARIS.sh b/SOLARIS.sh index 5e9bcd8..ff23040 100644 --- a/SOLARIS.sh +++ b/SOLARIS.sh @@ -1,4 +1,4 @@ - +#!/bin/bash #========== this script define the SOLARISANADIR as global env. unset SOLARISANADIR @@ -8,18 +8,8 @@ PCName=$(uname -n) if [ $(uname -n) == "solaris-daq" ]; then SOLARISANADIR=~/Analysis else - if [ $(pwd) == $HOME ]; then - SOLARISANADIR=$(dirname ${SOURCE}) - - if [[ ${SOLARISANADIR} == *"$HOME"* ]]; then - dummpy=0 - else - SOLARISANADIR=${HOME}/$SOLARISANADIR - fi - - else - SOLARISANADIR=$(pwd) - fi + ABSPATH=$(realpath ${SOURCE}) + SOLARISANADIR=$(dirname ${ABSPATH}) fi export SOLARISANADIR @@ -33,4 +23,26 @@ echo "####### add ${SOLARISANADIR}/armory into PATH" ########################### +echo "####### Define BASH Alias / Functions for SOLARIS" + alias 2Working='cd ${SOLARISANADIR}/working' +alias ShowRunTimeStamp='cat $SOLARISANADIR/data_raw/data/RunTimeStamp.dat' + +function ShowRunSize { + if [ $# -ne 1 ]; then + echo 'Please set run number ' + return 0 + fi + source $SOLARISANADIR/working/expName.sh + RUN=$1 + if [ ${RUN} = "latest" ]; then + RUN=${runID} + fi + runLen=${#RUN} + if [ ${runLen} -eq 1 ]; then + RUN="00"${RUN} + elif [ ${runLen} -eq 2 ]; then + RUN="0"${RUN} + fi + du -hc $SOLARISANADIR/data_raw/data/${expName}_${RUN}_*.sol +} diff --git a/armory/Event.h b/armory/Event.h deleted file mode 120000 index a57f30c..0000000 --- a/armory/Event.h +++ /dev/null @@ -1 +0,0 @@ -/home/solaris/SOLARIS_QT6_DAQ/Event.h \ No newline at end of file diff --git a/armory/Event.h b/armory/Event.h new file mode 100644 index 0000000..2a741c7 --- /dev/null +++ b/armory/Event.h @@ -0,0 +1,217 @@ +#ifndef EVENT_H +#define EVENT_H + +#include +#include +#include +#include + +#define MaxTraceLenght 8100 + +class Event { + public: + + unsigned short dataType; + + ///============= for dpp-pha + uint8_t channel; // 6 bit + uint16_t energy; // 16 bit + uint64_t timestamp; // 48 bit + uint16_t fine_timestamp; // 16 bit + uint16_t flags_low_priority; // 12 bit + uint16_t flags_high_priority; // 8 bit + size_t traceLenght; // 64 bit + uint8_t downSampling; // 8 bit + bool board_fail; + bool flush; + uint8_t analog_probes_type[2]; // 3 bit + uint8_t digital_probes_type[4]; // 4 bit + int32_t * analog_probes[2]; // 18 bit + uint8_t * digital_probes[4]; // 1 bit + uint16_t trigger_threashold; // 16 bit + size_t event_size; // 64 bit + uint32_t aggCounter; // 32 bit + + ///============= for raw + uint8_t * data; + size_t dataSize; /// number of byte of the data, size/8 = word [64 bits] + uint32_t n_events; + + bool isTraceAllZero; + + Event(){ + Init(); + } + + ~Event(){ + ClearMemory(); + } + + void Init(){ + channel = 0; + energy = 0; + timestamp = 0; + fine_timestamp = 0; + downSampling = 0; + board_fail = false; + flush = false; + flags_low_priority = 0; + flags_high_priority = 0; + trigger_threashold = 0; + event_size = 0; + aggCounter = 0; + analog_probes[0] = NULL; + analog_probes[1] = NULL; + digital_probes[0] = NULL; + digital_probes[1] = NULL; + digital_probes[2] = NULL; + digital_probes[3] = NULL; + + analog_probes_type[0] = 0xFF; + analog_probes_type[1] = 0xFF; + digital_probes_type[0] = 0xFF; + digital_probes_type[1] = 0xFF; + digital_probes_type[2] = 0xFF; + digital_probes_type[3] = 0xFF; + data = NULL; + + isTraceAllZero = true; // indicate trace are all zero + } + + void ClearMemory(){ + if( data != NULL ) delete data; + + if( analog_probes[0] != NULL) delete analog_probes[0]; + if( analog_probes[1] != NULL) delete analog_probes[1]; + + if( digital_probes[0] != NULL) delete digital_probes[0]; + if( digital_probes[1] != NULL) delete digital_probes[1]; + if( digital_probes[2] != NULL) delete digital_probes[2]; + if( digital_probes[3] != NULL) delete digital_probes[3]; + + isTraceAllZero = true; + } + + void SetDataType(unsigned int type){ + dataType = type; + ClearMemory(); + + if( dataType == 0xF){ + data = new uint8_t[20*1024*1024]; + }else{ + analog_probes[0] = new int32_t[MaxTraceLenght]; + analog_probes[1] = new int32_t[MaxTraceLenght]; + + digital_probes[0] = new uint8_t[MaxTraceLenght]; + digital_probes[1] = new uint8_t[MaxTraceLenght]; + digital_probes[2] = new uint8_t[MaxTraceLenght]; + digital_probes[3] = new uint8_t[MaxTraceLenght]; + + isTraceAllZero = true; + + } + } + + void ClearTrace(){ + if( isTraceAllZero ) return; // no need to clear again + + for( int i = 0; i < MaxTraceLenght; i++){ + analog_probes[0][i] = 0; + analog_probes[1][i] = 0; + + digital_probes[0][i] = 0; + digital_probes[1][i] = 0; + digital_probes[2][i] = 0; + digital_probes[3][i] = 0; + } + isTraceAllZero = true; + } + + void PrintEnergyTimeStamp(){ + printf("ch: %2d, energy: %u, timestamp: %llu ch, traceLenght: %lu\n", channel, energy, timestamp, traceLenght); + } + + std::string AnaProbeType(uint8_t probeType){ + switch(probeType){ + case 0: return "ADC"; + case 1: return "Time filter"; + case 2: return "Energy filter"; + default : return "none"; + } + } + + std::string DigiProbeType(uint8_t probeType){ + switch(probeType){ + case 0: return "Trigger"; + case 1: return "Time filter armed"; + case 2: return "Re-trigger guard"; + case 3: return "Energy filter baseline freeze"; + case 4: return "Energy filter peaking"; + case 5: return "Energy filter peaking ready"; + case 6: return "Energy filter pile-up guard"; + case 7: return "Event pile-up"; + case 8: return "ADC saturation"; + case 9: return "ADC saturation protection"; + case 10: return "Post-saturation event"; + case 11: return "Energy filter saturation"; + case 12: return "Signal inhibit"; + default : return "none"; + } + } + + std::string HighPriority(uint16_t prio){ + std::string output; + + bool pileup = prio & 0x1; + //bool pileupGuard = (prio >> 1) & 0x1; + //bool eventSaturated = (prio >> 2) & 0x1; + //bool postSatEvent = (prio >> 3) & 0x1; + //bool trapSatEvent = (prio >> 4) & 0x1; + //bool SCA_Event = (prio >> 5) & 0x1; + + output = std::string("Pile-up: ") + (pileup ? "Yes" : "No"); + + return output; + } + + //TODO LowPriority + + void PrintAll(){ + printf("============= Type : %u\n", dataType); + printf("ch : %2d (0x%02X), fail: %d, flush: %d\n", channel, channel, board_fail, flush); + printf("energy: %u, timestamp: %llu, fine_timestamp: %u \n", energy, timestamp, fine_timestamp); + printf("flag (high): 0x%02X, (low): 0x%03X, traceLength: %lu\n", flags_high_priority, flags_low_priority, traceLenght); + printf("Agg counter : %u, trigger Thr.: %u, downSampling: %u \n", aggCounter, trigger_threashold, downSampling); + printf("AnaProbe Type: %s(%u), %s(%u)\n", AnaProbeType(analog_probes_type[0]).c_str(), analog_probes_type[0], + AnaProbeType(analog_probes_type[1]).c_str(), analog_probes_type[1]); + printf("DigProbe Type: %s(%u), %s(%u), %s(%u), %s(%u)\n", DigiProbeType(digital_probes_type[0]).c_str(), digital_probes_type[0], + DigiProbeType(digital_probes_type[1]).c_str(), digital_probes_type[1], + DigiProbeType(digital_probes_type[2]).c_str(), digital_probes_type[2], + DigiProbeType(digital_probes_type[3]).c_str(), digital_probes_type[3]); + } + + void PrintTrace(unsigned short ID){ + for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){ + if( ID == 0 ) printf("%4d| %6d\n", i, analog_probes[0][i]); + if( ID == 1 ) printf("%4d| %6d\n", i, analog_probes[1][i]); + if( ID == 2 ) printf("%4d| %u\n", i, digital_probes[0][i]); + if( ID == 3 ) printf("%4d| %u\n", i, digital_probes[1][i]); + if( ID == 4 ) printf("%4d| %u\n", i, digital_probes[2][i]); + if( ID == 5 ) printf("%4d| %u\n", i, digital_probes[3][i]); + } + } + + void PrintAllTrace(){ + for(unsigned short i = 0; i < (unsigned short)traceLenght; i++){ + printf("%4d| %6d %6d %1d %1d %1d %1d\n", i, analog_probes[0][i], + analog_probes[1][i], + digital_probes[0][i], + digital_probes[1][i], + digital_probes[2][i], + digital_probes[3][i]); + } + } + +}; + +#endif \ No newline at end of file diff --git a/armory/EventBuilder.cpp b/armory/EventBuilder.cpp index 9af05be..382ad26 100644 --- a/armory/EventBuilder.cpp +++ b/armory/EventBuilder.cpp @@ -89,6 +89,10 @@ int main(int argc, char ** argv){ return -1; } + // for( int i = 0; i < argc; i++){ + // printf("%d | %s\n", i, argv[i]); + // } + TString outFileName = argv[1]; int timeWindow = atoi(argv[2]); const bool saveTrace = atoi(argv[3]); diff --git a/armory/GeneralSort.C b/armory/GeneralSort.C index 88ef59d..33c9b45 100644 --- a/armory/GeneralSort.C +++ b/armory/GeneralSort.C @@ -87,11 +87,13 @@ void GeneralSort::Terminate(){ DecodeOption(); if( !isParallel){ + printf("%s::SaveTree %p, %p\n", __func__, saveFile, newTree); saveFile->cd(); newTree->Write(); saveFile->Close(); } + printf("=======================================================\n"); //get entries saveFile = TFile::Open(saveFileName); if( saveFile->IsOpen() ){ @@ -115,6 +117,7 @@ void GeneralSort::Begin(TTree * tree){ PrintMapping(mapping, detTypeName, detMaxID); + tree->GetEntriesFast(); } @@ -128,6 +131,7 @@ void GeneralSort::SlaveTerminate(){ printf("%s\n", __func__); if( isParallel){ + printf("%s::SaveTree\n", __func__); saveFile->cd(); newTree->Write(); fOutput->Add(proofFile); diff --git a/armory/GeneralSort.h b/armory/GeneralSort.h index 7ff6140..bddf5d4 100644 --- a/armory/GeneralSort.h +++ b/armory/GeneralSort.h @@ -255,6 +255,7 @@ void GeneralSort::Init(TTree *tree){ printf(" ++++++++ no Trace.\n"); isTraceExist = false; }else{ + printf(" ++++++++ Found Trace.\n"); isTraceExist = true; fChain->SetBranchAddress("tl", tl, &b_tl); fChain->SetBranchAddress("trace", trace, &b_trace); diff --git a/armory/Process_BasicConfig b/armory/Process_BasicConfig index d57ac02..ccc16de 100644 --- a/armory/Process_BasicConfig +++ b/armory/Process_BasicConfig @@ -6,6 +6,11 @@ # ############################################## +if [ ! -z $RED ]; then + echo "Process_BasicConfig already loaded." + return +fi + RED='\033[1;31m' YELLOW='\033[1;33m' ORANGE='\033[0;33m' diff --git a/armory/Process_Download b/armory/Process_Download new file mode 100755 index 0000000..171175a --- /dev/null +++ b/armory/Process_Download @@ -0,0 +1,87 @@ +#!/bin/bash + +if [ $# -eq 0 ] || [ $1 == "-help" ]; then + echo "$./process_Download [RunNum]" + echo " RunNum = run number" + echo " * if RunNum = all, sync all" + exit 1 +fi; +RUN=$1 + +source $SOLARISANADIR/armory/Process_BasicConfig +source $SOLARISANADIR/working/expName.sh + +MacRawDataPath=$rawDataPathParent/$expName/ +IP=solarisdaq # defined at ~/.ssh/config +USR=solaris + +if [ ${RUN} == "all" ]; then + + if [ ${PCID} -eq 2 ]; then + #============ Get the raw data + rsync -avuht --progress $USR@$IP:$rawDataPath/$expName_* $MacRawDataPath/data/. + + echo -e "$YELLOW======== rsync RunTimeStamp.dat $NC" + rsync -avuht --progress $USR@$IP:$rawDataPath/$RunTimeStamp* $MacRawDataPath/data/. + + echo -e "$YELLOW======== rsync expName.sh $NC" + rsync -avuht --progress $USR@$IP:Analysis/working/expName.sh $SOLARISANADIR/working/. + + echo -e "$YELLOW=============================================$NC" + tail -10 $MacRawDataPath/data/RunTimeStamp.dat + echo -e "$YELLOW=============================================$NC" + else + echo -e "$RED############### Only in SOLARIS MAC can donwload data. skip.$NC" + fi + + exit 1 +fi + +#just in case people put %03d as RUN +if [ "${RUN:0:2}" == "00" ]; then + RUN=${RUN:2:1} +elif [ "${RUN:0:1}" == "0" ]; then + RUN=${RUN:1:2} +else + RUN=$(printf '%d' $RUN) +fi +RUN=$(printf '%03d' ${RUN}) + +echo $RUN + +####################################### +#################### Download raw data +echo -e "${RED}######################### Download raw data: run ${RUN}${NC}" +if [ ${PCID} -eq 2 ]; then + #============ Get the raw data + echo -e "================= RUN $RUN: Get the raw data `date`" + + rsync -avuht --progress $USR@$IP:$rawDataPath/$expName_$RUN* $MacRawDataPath/data/. + + echo -e "$YELLOW======== rsync RunTimeStamp.dat $NC" + rsync -avuht --progress $USR@$IP:$rawDataPath/$RunTimeStamp* $MacRawDataPath/data/. + + echo -e "$YELLOW======== rsync expName.sh $NC" + rsync -avuht --progress $USR@$IP:Analysis/working/expName.sh $SOLARISANADIR/working/. + + echo -e "$YELLOW=============================================$NC" + tail -10 $MacRawDataPath/data/RunTimeStamp.dat + echo -e "$YELLOW=============================================$NC" + +else + echo -e "$RED############### Only in SOLARIS MAC can donwload data. skip.$NC" +fi + +count=`ls -1 $SOLARISANADIR/data_raw/${expName}_${RUN}_*.sol 2>/dev/null | wc -l` +echo -e "========== Number of Files : ${count}${NC}" +if [ ${count} -eq 0 ]; then + echo "============================================" + echo "==== RAW Files of RUN-${RUN} not found! " + echo "============================================" + +else + echo -e "${YELLOW}" + du -hc $SOLARISANADIR/data_raw/${expName}_${RUN}_*.sol + echo -e "$NC=============================================" + +fi diff --git a/armory/Process_EventBuilder b/armory/Process_EventBuilder old mode 100644 new mode 100755 index 898e0d1..1e55bf7 --- a/armory/Process_EventBuilder +++ b/armory/Process_EventBuilder @@ -1,12 +1,35 @@ -################################################ EventBuilder +#!/bin/bash + +if [ -z $SOLARISANADIR ]; then + echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh." + echo "better add \"source \" into .bashrc" + exit +fi + +if [ $# -ne 3 ] || [ $1 == "-help" ]; then + echo "$ Process_EventBuilder [RunNum] [EventBuild] [timeWin]" + echo " RunNum = run number" + echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace" + echo " timeWin = number of tick for an event " + echo "" + exit 1 +fi; + RUN=$1 EventBld=$2 +timeWin=$3 -rawDataPath=${SOLARISANADIR}/data_raw -rootDataPath=${SOLARISANADIR}/root_data +source ${SOLARISANADIR}/armory/Process_BasicConfig +source ${SOLARISANADIR}/working/expName.sh -rawDataPattern="${rawDataPath}/${expName}_${RUN}_" -rootDataName="${rootDataPath}/run${RUN}.root" +runNum=${RUN#0} #remove zero +RUN=$(printf '%03d' $runNum) ##add back the zero + +rawDataPath=$SOLARISANADIR/data_raw +rootDataPath=$SOLARISANADIR/root_data + +rawDataPattern="$rawDataPath/${expName}_${RUN}_*.sol" +rootDataName="$rootDataPath/run$RUN.root" dir=$(pwd) cd ${SOLARISANADIR}/armory @@ -17,7 +40,7 @@ cd ${dir} isRawDataExist=`ls -1 ${rawDataPattern}* 2>/dev/null | wc -l` if [ ! $isRawDataExist -gt 0 ]; then - echo -e "${LRED}################# Run Data not exist. Abort ${NC}" + echo -e "${LRED}################# Run Data $rawDataPattern not exist. Abort. ${NC}" exit fi @@ -32,13 +55,13 @@ echo -e "${CYAN} ============== total file size : ${totSize}${NC}" if [ ${Arch} == "Linux" ]; then rawDataTime=`stat -c "%Z" ${rawDataPattern}* | sort -rn | head -1` else - rawDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" ${rawDataPattern}* | sort -rn | head -1` + rawDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $rawDataPattern | sort -rn | head -1` fi #==== check if root data exist isRootDataExist=`ls -1 $rootDataName 2>/dev/null | wc -l` -#==== if merged data exist, check timeStamp +#==== if root data exist, check timeStamp if [ ${isRootDataExist} -gt 0 ]; then if [ ${Arch} == "Linux" ]; then rootDataTime=`stat -c "%Z" $rootDataName | sort -rn | head -1` @@ -60,14 +83,14 @@ elif [ ${EventBld} -ge 1 ]; then echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> Event Building $(date) ${NC}" if [ ${EventBld} -eq 1 ]; then - EventBuilder $rootDataName ${timeWin} 0 `ls -1 ${rawDataPattern}*` + EventBuilder $rootDataName ${timeWin} 0 $rawDataPattern elif [ ${EventBld} -eq 2 ]; then - EventBuilder $rootDataName ${timeWin} 1 `ls -1 ${rawDataPattern}*` + EventBuilder $rootDataName ${timeWin} 1 $rawDataPattern fi echo -e "${LRED}<<<<<<<<<<<<<<<< Done Event Building $(date) ${NC}" else - echo -e "${GREEN}Merged data are newer than raw data. No need to merged again.${NC}" + echo -e "${GREEN} root data are newer than raw data. No need to merged again.${NC}" echo -e "${GREEN}You can Force merging using option -${EventBld}, ${ORANGE} see ./process_run.sh -help${NC}" fi @@ -75,9 +98,9 @@ else echo -e "${LRED}>>>>>>>>>>>>>>> Force Event Building $(date) ${NC}" if [ ${EventBld} -eq -1 ]; then - EventBuilder $rootDataName ${timeWin} 0 `ls -1 ${rawDataPattern}*` + EventBuilder $rootDataName ${timeWin} 0 $rawDataPattern elif [ ${EventBld} -eq -2 ]; then - EventBuilder $rootDataName ${timeWin} 1 `ls -1 ${rawDataPattern}*` + EventBuilder $rootDataName ${timeWin} 1 $rawDataPattern fi echo -e "${LRED}<<<<<<<<<<<<<<<< Done Event Building $(date) ${NC}" diff --git a/armory/Process_Run b/armory/Process_Run index 1cb6668..3ed09a3 100755 --- a/armory/Process_Run +++ b/armory/Process_Run @@ -1,5 +1,8 @@ #!/bin/bash +######## default time window = 100 tick +timeWin=100 + if [ -z $SOLARISANADIR ]; then echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh." echo "better add \"source \" into .bashrc" @@ -8,10 +11,11 @@ fi if [ $# -eq 0 ] || [ $1 == "-help" ]; then - echo "$ Proess_Run [RunNum] [EventBuild] [GeneralSort] [Monitor]" + echo "$ Process_Run [RunNum] [EventBuild] [GeneralSort] [TraceMethod] [Monitor]" echo " RunNum = run number / \"lastRun\" " echo " EventBld = 2/1/0/-1/-2 || 2 = with Trace" echo " GeneralSort = n/0/-n || n = number of worker" + echo " TraceMethod = -1/0/1/2 || -1 no trace, 0 save trace, 1 fit, 2 trapezoid" echo " Monitors = 2/1/0 || 1 = single run, 2 = using the list in ChainMonitors.C" echo " 10 = single run and post to websrv, 20 = list runs and post to websrv" echo "" @@ -25,11 +29,13 @@ RUN=$1 runNum=$1 EventBld=0 nWorker=1 +TraceMethod=0 isMonitor=0 if [ $# -ge 2 ]; then EventBld=$2; fi if [ $# -ge 3 ]; then nWorker=$3; fi -if [ $# -ge 4 ]; then isMonitor=$4; fi +if [ $# -ge 4 ]; then TraceMethod=$3; fi +if [ $# -ge 5 ]; then isMonitor=$5; fi timeWin=100000 @@ -40,41 +46,22 @@ if [ "$RUN" == "lastRun" ]; then RUN=$runID fi -#padding -if [ "${RUN:0:1}" == "0" ]; then - RUN=${RUN:1:2} -else - RUN=$(printf '%d' $RUN) -fi -RUN=$(printf '%03d' ${RUN}) +RUN=${RUN%0} #remove zero +RUN=$(printf '%03d' $RUN) ##add back the zero #################################### if [ ${PCID} -eq 1 ]; then - source Process_EventBuilder $RUN ${EventBld} -fi + source Process_EventBuilder $RUN $EventBld $timeWin + +else + source Process_Download $RUN + + source Process_EventBuilder $RUN $EventBld -if [ ${PCID} -eq 2 ]; then - ## Dwonlaod Data - echo "Downlaod data" fi #################################### GeneralSort -if [ ${nWorker} -eq 0 ]; then - - echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> GeneralSort Skipped by user. ${NC}" - -else - source $ROOTSYS/bin/thisroot.sh - - mkdir ~/.proof/working - cp ${SOLARISANADIR}/working/Mapping.h ~/.proof/working/. - mkdir ~/.proof/armory - cp ${SOLARISANADIR}/armory/AnalysisLib.h ~/.proof/armory/. - - root -l -q -b "${SOLARISANADIR}/armory/GeneralSortAgent.C($runNum, ${nWorker}, 0)" - -fi #################################### Monitor diff --git a/armory/Process_Sort b/armory/Process_Sort new file mode 100755 index 0000000..c305e06 --- /dev/null +++ b/armory/Process_Sort @@ -0,0 +1,92 @@ +#!/bin/bash + +if [ -z $SOLARISANADIR ]; then + echo "###### env variable SOLARISANADIR not defined. Abort. Please run the SOLARIS.sh." + echo "better add \"source \" into .bashrc" + exit +fi + +if [ $# -eq 0 ] || [ $1 == "-help" ]; then + echo "$ Process_Sort [RunNum] [GeneralSort] [TraceMethod]" + echo " RunNum = run number" + echo " GeneralSort = n/0/-n || n = number of worker" + echo " TraceMethod = -1/0/1/2 || -1 no trace, 0 save trace, 1 fit, 2 trapezoid" + echo "" + exit 1 +fi; + +RUN=$1 +nWorker=$2 +TraceMethod=$3 + +source $SOLARISANADIR/armory/Process_BasicConfig +source $SOLARISANADIR/working/expName.sh + +runNum=${RUN#0} #remove zero +RUN=$(printf '%03d' $runNum) ##add back the zero + +if [ ${nWorker} -eq 0 ]; then + echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> GeneralSort Skipped by user. ${NC}" +else + source $ROOTSYS/bin/thisroot.sh + + #--------- Check is runXXX.root exist + rootDataPath=$SOLARISANADIR/root_data + rootDataName="$rootDataPath/run$RUN.root" + isRootDataExist=`ls -1 $rootDataName 2>/dev/null | wc -l` + + #==== if root data exist, check timeStamp + if [ $isRootDataExist -gt 0 ]; then + if [ ${Arch} == "Linux" ]; then + rootDataTime=`stat -c "%Z" $rootDataName | sort -rn | head -1` + else + rootDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $rootDataName | sort -rn | head -1` + fi + else + rootDataTime=0 + echo -e "$LRED ################# run$RUN.root does not exist. Abort. $NC" + exit 1 + fi + + #-------- check gen_root timestamp + genRootDataName="$rootDataPath/gen_run$RUN.root" + isGenRootDataExist=`ls -1 $genRootDataName 2>/dev/null | wc -l` + + #----- if gen_runXXX.data exist, check timeStamp + if [ $isGenRootDataExist -gt 0 ]; then + if [ ${Arch} == "Linux" ]; then + genRootDataTime=`stat -c "%Z" $genRootDataName | sort -rn | head -1` + else + genRootDataTime=`stat -f "%Sm" -t "%Y%m%d%H%M%S" $genRootDataName | sort -rn | head -1` + fi + else + genRootDataTime=0 + fi + + mkdir -p ~/.proof/working + cp ${SOLARISANADIR}/working/Mapping.h ~/.proof/working/. + mkdir -p ~/.proof/armory + cp ${SOLARISANADIR}/armory/AnalysisLib.h ~/.proof/armory/. + + if [ $nWorker -le -1 ]; then + echo -e "${LRED}>>>>>>>>>>>>>>> Force GeneralSort $(date) ${NC}" + root -l -q -b "$SOLARISANADIR/armory/GeneralSortAgent.C($runNum, $nWorker, $TraceMethod)" + echo -e "${LRED}<<<<<<<<<<<<<<<< Done GeneralSort $(date) ${NC}" + fi + + if [ $nWorker -ge 1 ]; then + + if [ $rootDataTime -ge $genRootDataTime ]; then + + echo -e "${LRED}>>>>>>>>>>>>>>>>>>>>> Event Building $(date) ${NC}" + root -l -q -b "$SOLARISANADIR/armory/GeneralSortAgent.C($runNum, $nWorker, $TraceMethod)" + echo -e "${LRED}<<<<<<<<<<<<<<<< Done Event Building $(date) ${NC}" + + else + echo -e "${GREEN}gen_run$RUN.root is newer than run$RUN.root. No need to GeneralSort again.${NC}" + echo -e "${GREEN}You can Force GeneralSort using option -${nWorker}, ${ORANGE} see Process_Run -help${NC}" + fi + + fi + +fi \ No newline at end of file diff --git a/working/expName.sh b/working/expName.sh index 6f6ac88..ac83168 100644 --- a/working/expName.sh +++ b/working/expName.sh @@ -1,6 +1,6 @@ expName=Master rawDataPath=/mnt/data0/Master rootDataPath=/mnt/data1/Master -runID=21 -elogID=59 +runID=5 +elogID=9 #------------end of file. \ No newline at end of file