diff --git a/MQ/hitbuilder/CMakeLists.txt b/MQ/hitbuilder/CMakeLists.txt index 79387621ad2753419b1a2d79cbdd86f8e00d6f28..365f168a51adfae1a11ffb5df6482ed87b953c06 100644 --- a/MQ/hitbuilder/CMakeLists.txt +++ b/MQ/hitbuilder/CMakeLists.txt @@ -77,7 +77,7 @@ set(EXE_NAME HitBuilderTof) set(SRCS CbmDeviceHitBuilderTof.cxx runHitBuilderTof.cxx) set(DEPENDENCIES ${DEPENDENCIES_ALL} -# fles_ipc +# external::fles_ipc CbmBase CbmData CbmTofBase diff --git a/MQ/hitbuilder/CbmDeviceHitBuilderTof.cxx b/MQ/hitbuilder/CbmDeviceHitBuilderTof.cxx index 76c3905cb902be08fe21f080cd8660f0251b3944..06824946d8191f31aaab6a10086670e0eef56fd7 100644 --- a/MQ/hitbuilder/CbmDeviceHitBuilderTof.cxx +++ b/MQ/hitbuilder/CbmDeviceHitBuilderTof.cxx @@ -78,6 +78,9 @@ static Double_t StartAnalysisTime = 0.; //const Double_t cLight = 29.9792; // in cm/ns static FairRootManager* rootMgr = NULL; static Int_t iRunId = 1; +static Int_t SelMask = DetMask; +static Double_t dTstart = 0.; +static Double_t dTmax = 0.; CbmTofDigi* pRef; CbmTofDigi* pRefCal; @@ -133,7 +136,11 @@ CbmDeviceHitBuilderTof::CbmDeviceHitBuilderTof() , fvPulserOffset() , fvPulserTimes() , fhEvDetMul(NULL) + , fhEvDigiMul(NULL) + , fhEvRateIn(NULL) + , fhEvRateOut(NULL) , fhPulMul(NULL) + , fhDigiTdif(NULL) , fhPulserTimesRaw() , fhPulserTimeRawEvo() , fhPulserTimesCor() @@ -297,6 +304,7 @@ Bool_t CbmDeviceHitBuilderTof::InitWorkspace() fiPulDetRef = fConfig->GetValue<uint64_t>("PulDetRef"); fiPulTotMin = fConfig->GetValue<uint64_t>("PulTotMin"); fiPulTotMax = fConfig->GetValue<uint64_t>("PulTotMax"); + dTmax = (Double_t) fConfig->GetValue<uint64_t>("ReqTint"); //fTofCalDigisColl = new TClonesArray("CbmTofDigi", 100); //fTofCalDigisCollOut = new TClonesArray("CbmTofDigi", 100); @@ -366,7 +374,8 @@ Bool_t CbmDeviceHitBuilderTof::InitRootOutput() // rootMgr->Register("CbmTofDigi", "Tof raw Digi", fTofCalDigisColl, kTRUE); // fOutRootFile->cd(); - rootMgr->RegisterAny("TofCalDigi", fTofCalDigiVec, kTRUE); + // rootMgr->RegisterAny("TofCalDigi", fTofCalDigiVec, kTRUE); + rootMgr->RegisterAny("TofDigi", fTofCalDigiVec, kTRUE); TTree* outTree = new TTree(FairRootManager::GetTreeName(), "/cbmout", 99); LOG(info) << "define Tree " << outTree->GetName(); @@ -475,9 +484,7 @@ Bool_t CbmDeviceHitBuilderTof::InitContainers() tofDigiPar->Init(); fDigiPar = (CbmTofDigiPar*) (fRtdb->getContainer("CbmTofDigiPar")); if (NULL == fDigiPar) { - LOG(error) << "CbmTofEventClusterizer::InitParameters => " - "Could not obtain " - "the CbmTofDigiPar "; + LOG(error) << "CbmTofEventClusterizer::InitParameters => Could not obtain CbmTofDigiPar"; return kFALSE; } } @@ -505,7 +512,18 @@ Bool_t CbmDeviceHitBuilderTof::InitContainers() fDutAddr = CbmTofAddress::GetUniqueAddress(fDutSm, fDutRpc, 0, 0, fDutId); fSelAddr = CbmTofAddress::GetUniqueAddress(fSelSm, fSelRpc, 0, 0, fSelId); fSel2Addr = CbmTofAddress::GetUniqueAddress(fSel2Sm, fSel2Rpc, 0, 0, fSel2Id); - fiBeamRefAddr = CbmTofAddress::GetUniqueAddress(fiBeamRefSm, fiBeamRefDet, 0, 0, fiBeamRefType); + if (fiBeamRefType > -1) { + if (fiBeamRefDet > -1) { + fiBeamRefAddr = CbmTofAddress::GetUniqueAddress(fiBeamRefSm, fiBeamRefDet, 0, 0, fiBeamRefType); + } + else { + SelMask = ModMask; + fiBeamRefAddr = CbmTofAddress::GetUniqueAddress(fiBeamRefSm, 0, 0, 0, fiBeamRefType); + } + } + else + fiBeamRefAddr = -1; + iIndexDut = fDigiBdfPar->GetDetInd(fDutAddr); LOG(info) << Form("Use Dut 0x%08x, Sel 0x%08x, Sel2 0x%08x, BRef 0x%08x", fDutAddr, fSelAddr, fSel2Addr, fiBeamRefAddr); @@ -534,7 +552,8 @@ bool CbmDeviceHitBuilderTof::HandleData(FairMQParts& parts, int /*index*/) std::istringstream issE(msgStrE); boost::archive::binary_iarchive inputArchiveE(issE); inputArchiveE >> fEventHeader; - LOG(debug) << "EventHeader: " << fEventHeader[0] << " " << fEventHeader[1] << " " << fEventHeader[2]; + LOG(debug) << "EventHeader: " << fEventHeader[0] << " " << fEventHeader[1] << " " << fEventHeader[2] << " " + << fEventHeader[3] << " " << fEventHeader[4]; fiNDigiIn = 0; // LOG(debug) << "Received message # "<< fNumMessages @@ -591,6 +610,38 @@ bool CbmDeviceHitBuilderTof::HandleData(FairMQParts& parts, int /*index*/) fvDigiIn.resize(fiNDigiIn); for (int iDigi = 0; iDigi < fiNDigiIn; iDigi++) { fvDigiIn[iDigi] = *vdigi[iDigi]; + + // Remap Digis for v21a_cosmicHD + if (1) { + int iSmType = 8; + int iSm = -1; + int iRpc = 0; + int iDetId = 0; + CbmTofDigi* pDigi = &fvDigiIn[iDigi]; + + if (pDigi->GetType() == 6 && pDigi->GetRpc() == 1) { + switch ((int) (pDigi->GetChannel() * 2 + pDigi->GetSide())) { + case 62: //800 + iSm = 0; + break; + case 46: //810 + iSm = 1; + break; + case 22: //820 + iSm = 2; + break; + case 2: //830 + iSm = 3; + break; + default:; + } + if (iSm > -1) { + iDetId = CbmTofAddress::GetUniqueAddress(iSm, iRpc, 0, 0, iSmType); + pDigi->SetAddress(iDetId); + } + } + } //remapping end + delete vdigi[iDigi]; } vdigi.clear(); @@ -625,6 +676,14 @@ bool CbmDeviceHitBuilderTof::HandleData(FairMQParts& parts, int /*index*/) fdEvent++; fhEvDetMul->Fill((Double_t) fEventHeader[1]); + fhEvDigiMul->Fill(fiNDigiIn); + if (fiNDigiIn > 0) { + if (dTstart == 0) { + dTstart = fvDigiIn[0].GetTime() + fEventHeader[4]; + LOG(info) << "Start time set to " << dTstart / 1.E9 << " sec "; + } + fhEvRateIn->Fill((fvDigiIn[0].GetTime() + fEventHeader[4] - dTstart) / 1.E9); + } if (!InspectRawDigis()) return kFALSE; if (fiPulserMode > 0) @@ -634,11 +693,13 @@ bool CbmDeviceHitBuilderTof::HandleData(FairMQParts& parts, int /*index*/) //if(!MergeClusters()) return kFALSE; if (NULL != fOutRootFile) { // CbmEvent output to root file + fEvtHeader->SetEventTime((double) fEventHeader[4]); rootMgr->FillEventHeader(fEvtHeader); //LOG(info) << "Fill WriteOutBuffer with rootMgr at " << rootMgr; fOutRootFile->cd(); rootMgr->Fill(); rootMgr->StoreWriteoutBufferData(rootMgr->GetEventTime()); + fhEvRateOut->Fill((fvDigiIn[0].GetTime() + fEventHeader[4] - dTstart) / 1.E9); //rootMgr->StoreAllWriteoutBufferData(); rootMgr->DeleteOldWriteoutBufferData(); if ((Int_t) fdEvent == fiMaxEvent) { @@ -928,31 +989,37 @@ void CbmDeviceHitBuilderTof::CreateHistograms() TDirectory* oldir = gDirectory; // <= To prevent histos from being sucked in by the param file of the TRootManager! gROOT->cd(); // <= To prevent histos from being sucked in by the param file of the TRootManager ! // process event header info - fhEvDetMul = new TH1F("hEvDetMul", "Detector multiplicity of Selector; Mul", 50, 0, 50); - fhPulMul = new TH1F("hPulMul", "Pulser multiplicity; Mul", 110, 0, 110); + fhEvDetMul = new TH1F("hEvDetMul", "Detector multiplicity of Selector; Mul", 50, 0, 50); + fhEvDigiMul = new TH1F("hEvDigiMul", "Digi multiplicity of Selector; Mul", 1000, 0, 10000); + fhEvRateIn = new TH1F("hEvRateIn", "Incoming Event rate; time (s); rate (Hz)", 10000, 0, 10000); + fhEvRateOut = new TH1F("hEvRateOut", "Outgoing Event rate; time (s); rate (Hz)", 10000, 0, 10000); + fhPulMul = new TH1F("hPulMul", "Pulser multiplicity; Mul", 110, 0, 110); + fhDigiTdif = new TH1F("hDigiTdif", "Digi time difference; #Deltat ns)", 8000, -20, 20); Int_t iNDet = 0; + dTmax *= 2; // cover full range of selector + for (Int_t iModTyp = 0; iModTyp < 10; iModTyp++) iNDet += fDigiBdfPar->GetNbSm(iModTyp) * fDigiBdfPar->GetNbRpc(iModTyp); fhPulserTimesRaw = new TH2F(Form("hPulserTimesRaw"), Form("Pulser Times uncorrected; Det# []; t - t0 [ns]"), - iNDet * 2, 0, iNDet * 2, 999, -100., 100.); + iNDet * 2, 0, iNDet * 2, 999, -dTmax, dTmax); fhPulserTimeRawEvo.resize(iNDet * 2); for (Int_t iDetSide = 0; iDetSide < iNDet * 2; iDetSide++) { fhPulserTimeRawEvo[iDetSide] = new TProfile( Form("hPulserTimeRawEvo_%d", iDetSide), - Form("Raw Pulser TimeEvolution %d; PulserEvent# ; DeltaT [ns] ", iDetSide), 1000, 0., 1.E5, -100., 100.); + Form("Raw Pulser TimeEvolution %d; PulserEvent# ; DeltaT [ns] ", iDetSide), 1000, 0., 1.E5, -dTmax, dTmax); } fhPulserTimesCor = new TH2F(Form("hPulserTimesCor"), Form("Pulser Times corrected; Det# []; t - t0 [ns]"), iNDet * 2, 0, iNDet * 2, 999, -10., 10.); fhDigiTimesRaw = new TH2F(Form("hDigiTimesRaw"), Form("Digi Times uncorrected; Det# []; t - t0 [ns]"), iNDet * 2, 0, - iNDet * 2, 999, -100., 100.); + iNDet * 2, 999, -dTmax, dTmax); fhDigiTimesCor = new TH2F(Form("hDigiTimesCor"), Form("Digi Times corrected; Det# []; t - t0 [ns]"), iNDet * 2, 0, - iNDet * 2, 999, -100., 100.); + iNDet * 2, 999, -dTmax, dTmax); fhBucDigiCor = new TH2F(Form("hBucDigiCor"), Form("Buc Digi Correlation; ch1 []; ch2 []"), 128, 0, 128, 128, 0, 128); @@ -968,6 +1035,9 @@ void CbmDeviceHitBuilderTof::CreateHistograms() Int_t iSmType = CbmTofAddress::GetSmType(iUniqueId); Int_t iSmId = CbmTofAddress::GetSmId(iUniqueId); Int_t iRpcId = CbmTofAddress::GetRpcId(iUniqueId); + LOG(info) << "Index map entry " << iDetIndx << ": TSR " << iSmType << iSmId << iRpcId + << Form(", addr 0x%08x", iUniqueId); + fhRpcDigiTot[iDetIndx] = new TH2F( Form("hDigiTot_SmT%01d_sm%03d_rpc%03d", iSmType, iSmId, iRpcId), Form("Digi Tot of Rpc #%03d in Sm %03d of type %d; digi 0; digi 1", iRpcId, iSmId, iSmType), @@ -1046,7 +1116,7 @@ void CbmDeviceHitBuilderTof::CreateHistograms() fhSmCluFpar[iS][iPar] = new TProfile(Form("cl_SmT%01d_Fpar%1d", iS, iPar), Form("Clu Fpar %d in SmType %d; Sm+Rpc# []; value ", iPar, iS), fDigiBdfPar->GetNbSm(iS) * fDigiBdfPar->GetNbRpc(iS), 0, - fDigiBdfPar->GetNbSm(iS) * fDigiBdfPar->GetNbRpc(iS), -100., 100.); + fDigiBdfPar->GetNbSm(iS) * fDigiBdfPar->GetNbRpc(iS), -dTmax, dTmax); } else fhSmCluFpar[iS][iPar] = (TProfile*) hFparcur->Clone(); @@ -1444,28 +1514,26 @@ Bool_t CbmDeviceHitBuilderTof::InspectRawDigis() for (Int_t iDigInd = 0; iDigInd < fiNDigiIn; iDigInd++) { CbmTofDigi* pDigi = &fvDigiIn[iDigInd]; //LOG(debug)<<iDigInd<<" "<<pDigi; + Int_t iAddr = pDigi->GetAddress() & DetMask; + Int_t iDetIndx = fDigiBdfPar->GetDetInd(iAddr); /* - LOG(debug)<<iDigInd + LOG(info)<<iDigInd //<<Form(" Address : 0x%08x ",pDigi->GetAddress()) - <<" TSRC " << pDigi->GetType() - << pDigi->GetSm() - << pDigi->GetRpc() - << pDigi->GetChannel() - <<" S " << pDigi->GetSide() - <<" : " << pDigi->ToString(); + <<Form(" TSRCS %d%d%d%02d%d ", (int)pDigi->GetType(), + (int)pDigi->GetSm(),(int)pDigi->GetRpc(),(int)pDigi->GetChannel(),(int)pDigi->GetSide()) + <<" : " << Form("Ind %2d, T %15.3f, Tot %5.1f",iDetIndx,pDigi->GetTime(),pDigi->GetTot()); */ - Int_t iAddr = pDigi->GetAddress() & DetMask; - if (iAddr == fiBeamRefAddr) { + + if (fiBeamRefAddr < 0 || iAddr == fiBeamRefAddr) { //LOG(debug) << Form("Ref digi found for 0x%08x, Mask 0x%08x ", fiBeamRefAddr, DetMask); if (NULL == pRef) pRef = pDigi; else { if (pDigi->GetTime() < pRef->GetTime()) pRef = pDigi; } } - Int_t iDetIndx = fDigiBdfPar->GetDetInd(iAddr); if (fDigiBdfPar->GetNbDet() - 1 < iDetIndx || iDetIndx < 0) { - LOG(debug) << Form(" Wrong DetIndx %d >< %d,0 ", iDetIndx, fDigiBdfPar->GetNbDet()); + LOG(warn) << Form(" Wrong DetIndx %d >< %d,0 ", iDetIndx, fDigiBdfPar->GetNbDet()); break; } @@ -1483,12 +1551,20 @@ Bool_t CbmDeviceHitBuilderTof::InspectRawDigis() // for (Int_t iDigI2 =iDigInd+1; iDigI2<iNbTofDigi;iDigI2++){ for (Int_t iDigI2 = 0; iDigI2 < iNbTofDigi; iDigI2++) { CbmTofDigi* pDigi2 = &fvDigiIn[iDigI2]; + if (pDigi != pDigi2) { fhDigiTdif->Fill(pDigi->GetTime() - pDigi2->GetTime()); } if (pDigi->GetAddress() != pDigi2->GetAddress()) if (pDigi->GetType() == 6 && pDigi2->GetType() == 6) fhBucDigiCor->Fill(pDigi->GetRpc() * 64 + pDigi->GetChannel() * 2 + pDigi->GetSide(), pDigi2->GetRpc() * 64 + pDigi2->GetChannel() * 2 + pDigi2->GetSide()); if (iDetIndx == fDigiBdfPar->GetDetInd(pDigi2->GetAddress())) { + /* + LOG(info) <<" Correlate DetIndx "<<iDetIndx + <<Form(", TSRCS %d%d%d%02d%d ", (int)pDigi->GetType(), + (int)pDigi->GetSm(),(int)pDigi->GetRpc(),(int)pDigi->GetChannel(),(int)pDigi->GetSide()) + <<Form(" with %d%d%d%02d%d ", (int)pDigi2->GetType(), + (int)pDigi2->GetSm(),(int)pDigi2->GetRpc(),(int)pDigi2->GetChannel(),(int)pDigi2->GetSide()); + */ if (0. == pDigi->GetSide() && 1. == pDigi2->GetSide()) { fhRpcDigiCor[iDetIndx]->Fill(pDigi->GetChannel(), pDigi2->GetChannel()); } @@ -1664,6 +1740,7 @@ Bool_t CbmDeviceHitBuilderTof::CalibRawDigis() <<Form("%f",pDigi->GetTime())<<" " <<pDigi->GetTot(); */ + if (fbPs2Ns) { pCalDigi->SetTime(pCalDigi->GetTime() / 1000.); // for backward compatibility pCalDigi->SetTot(pCalDigi->GetTot() / 1000.); // for backward compatibility @@ -3735,7 +3812,7 @@ Bool_t CbmDeviceHitBuilderTof::MonitorPulser() } if (iDigi0 == -1) { - LOG(error) << Form("Pulser reference %d not found in pulser event %d of mul %d, return", iDet0, iNPulserFound, + LOG(debug) << Form("Pulser reference %d not found in pulser event %d of mul %d, return", iDet0, iNPulserFound, fiNDigiIn); return kTRUE; } diff --git a/MQ/hitbuilder/CbmDeviceHitBuilderTof.h b/MQ/hitbuilder/CbmDeviceHitBuilderTof.h index a5b7ed7c7ce89348dc0e15f92c05ac3dbe05238b..84b59dc31cc5a2ab810ec2083d301a8c78d87785 100644 --- a/MQ/hitbuilder/CbmDeviceHitBuilderTof.h +++ b/MQ/hitbuilder/CbmDeviceHitBuilderTof.h @@ -119,7 +119,7 @@ private: // Input variables Int_t fiNDigiIn; std::vector<CbmTofDigi> fvDigiIn; - std::vector<int> fEventHeader; + std::vector<uint64_t> fEventHeader; FairEventHeader* fEvtHeader; // Output variables @@ -180,7 +180,11 @@ private: // histograms TH1* fhEvDetMul; + TH1* fhEvDigiMul; + TH1* fhEvRateIn; + TH1* fhEvRateOut; TH1* fhPulMul; + TH1* fhDigiTdif; TH2* fhPulserTimesRaw; std::vector<TProfile*> fhPulserTimeRawEvo; TH2* fhPulserTimesCor; diff --git a/MQ/hitbuilder/runHitBuilderTof.cxx b/MQ/hitbuilder/runHitBuilderTof.cxx index 53fdb50127e88c74d008b4899cda049c4a2725df..d59e7f940174f7ec7e92d29bc34c0601e7312f50 100644 --- a/MQ/hitbuilder/runHitBuilderTof.cxx +++ b/MQ/hitbuilder/runHitBuilderTof.cxx @@ -20,6 +20,8 @@ void addCustomOptions(bpo::options_description& options) options.add_options()("PulTotMin", bpo::value<uint64_t>()->default_value(0), "Min Tot value"); options.add_options()("PulTotMax", bpo::value<uint64_t>()->default_value(0), "Max Tot value"); + options.add_options()("ReqTint", bpo::value<uint64_t>()->default_value(50), "Coincidence time interval"); + options.add_options()("DutType", bpo::value<uint64_t>()->default_value(0), "Dut type identifier"); options.add_options()("DutSm", bpo::value<uint64_t>()->default_value(0), "Dut module number"); options.add_options()("DutRpc", bpo::value<uint64_t>()->default_value(1), "Dut counter number"); diff --git a/MQ/hitbuilder/runMQ_Cri2021.sh b/MQ/hitbuilder/runMQ_Cri2021.sh new file mode 100644 index 0000000000000000000000000000000000000000..8780b5fef8f4abc934ac8b8c04d49eac8b49e005 --- /dev/null +++ b/MQ/hitbuilder/runMQ_Cri2021.sh @@ -0,0 +1,376 @@ +#!/bin/bash +#SBATCH -J MQevb +#SBATCH -D /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/topologies +#SBATCH --time=6-00:00:00 +#SBATCH --mem=4000 +#SBATCH --partition=long + +X=$((${SLURM_ARRAY_TASK_ID} - 0)) +XXX=$(printf "%03d" "$X") +#$FAIRROOTPATH/bin/shmmonitor --cleanup +node=`hostname` +nodeStatus=`ps uaxwww | grep parmq` +nodeOK=`echo $nodeStatus | grep ParServ` +if [[ $nodeOK != "" ]]; then + echo parmq already running on node $node: $nodeOK, exiting ... + exit 0 +fi +echo node check on $node passed, stop eventually relict processes + +./stop_MQ.sh +#exit 0 ## debug exit + +if [ -z "$1" ]; then + _runname="359" +else + _runname=$1 +fi + +if [ -z "$2" ]; then +_reqmod=-193 +else +_reqmod=$2 +fi + +if [ -z "$3" ]; then +_pulmode=1 +else +_pulmode=$3 +fi + +if [ -z "$4" ]; then + _reqtint=100 +else + _reqtint=$4 +fi + +_Opt=$5 + +#_ntimeslices=-1 +_ntimeslices=10000 +_iUnp=4 +_batch=1 +_pulmulmin=5 +_pultotmin=50 +_pultotmax=500 +#_puldetref=12 # TSR=022 +#_puldetref=16 # TSR=032 +_puldetref=16 # TSR=031 + +#_tofftof=0. +_tofftof=-35. + +if [[ $_reqmod -eq 1 ]]; then + _iUnp=1 +fi + +#_dirname=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/ +_outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/data/ +#_datapath=~/KRONOS/CBM/cbmroot/trunk +#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/ +#_outdir=$_datapath/macro/beamtime/mcbm2018/data/ + +#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa" +#_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa" +if [ $_runname -lt 1400 ]; then +_dirname="" +_filename="./tsaData2021/${_runname}_node8_*.tsa;./tsaData2021/${_runname}_node9_*.tsa" +_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21b_mcbm.digibdf.par +else + if [ $_runname -lt 1384 ]; then + _dirname=`ls -d /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/input06/r${_runname}*` # double stack AFCK + else + _dirname=`ls -d /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/inp07/r${_runname}*` # triple stack AFCK + fi + _filename="r${_runname}*.tsa" + _digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21c_mcbm.digibdf.par + echo dir: $_dirname + echo file: $_filename +fi + +_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root + +# ASCII files +#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/MQ/hitbuilder/MapTofGbtx.par +_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar.par +if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_2Stack.par +else + if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_3Stack.par + _puldetref=12 # TSR=022 + else + if [ $_runname -ge 1079 ] && [ $_runname -lt 1086 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar2Stack.par + else + if [ $_runname -lt 1172 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524_DirectBeam.par + else + if [ $_runname -lt 1600 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524.par + else + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524.par + fi + fi + fi + fi +fi +#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/etofPar.par +#_digibdffile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v18j_cosmicHD.digibdf.par +#_digiparfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v18j_cosmicHD.digi.par +#_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21a_mcbm.digibdf.par +#_digiparfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v19b_mcbm.digi.par + +# ROOT files +#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root +#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root +_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_02.par.root + +# MQ ports +_pPar=5603 +_pSam=5613 +_pCmd=5623 +_pDig=5633 + +#rm -v nohup.out +#rm -v *log +rm all_* + +PARAMETERSERVER="parmq-server" +echo pkill $PARAMETERSERVER +pkill -9 $PARAMETERSERVER +sleep 1 +PARAMETERSERVER+=" --id parmq-server" +PARAMETERSERVER+=" --channel-name parameters" +PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018" +#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile" +PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile" +PARAMETERSERVER+=" --first-input-type ASCII" +PARAMETERSERVER+=" --second-input-name $_geofile" +PARAMETERSERVER+=" --second-input-type ROOT" +PARAMETERSERVER+=" --severity INFO" +if [[ $_batch = 1 ]]; then +PARAMETERSERVER+=" --control static" +PARAMETERSERVER+=" --log-to-file ParServ_${_runname}.out" +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER & +else +xterm -geometry 80x23+0+340 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER & +#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER & +fi + +echo Started ParameterServer + +SAMPLER="TsaMultiSamplerTof" +SAMPLER+=" --id sampler1" +SAMPLER+=" --max-timeslices $_ntimeslices" +#SAMPLER+=" --max-timeslices 1000000" +#SAMPLER+=" --flib-port 10" +SAMPLER+=" --dirname $_dirname" +SAMPLER+=" --filename $_filename" +#SAMPLER+=" --flib-host myHost" +SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam" +SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd" +#SAMPLER+=" --transport shmem" +#SAMPLER+=" --transport zeromq" +#SAMPLER+=" --transport nanomsg" +#SAMPLER+=" --severity WARN" +SAMPLER+=" --severity INFO" +#SAMPLER+=" --severity DEBUG" +SAMPLER+=" --SelectComponents 1" +if [[ $_batch = 1 ]]; then +SAMPLER+=" --log-to-file Sampl_${_runname}.out" +SAMPLER+=" --control static" +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER & +else +xterm -geometry 80x23+0+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER & +fi + +echo Started Sampler + +while (( _iUnp > 0 )); do + +UNPACKER="UnpackTofMcbm2018" +UNPACKER+=" --id unpack$_iUnp" +UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam" +UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig" +UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd" +#UNPACKER+=" --transport shmem" +#UNPACKER+=" --severity DEBUG" +UNPACKER+=" --severity INFO" +UNPACKER+=" --SelectComponents 1" +if [[ $_reqmod -gt 10 ]]; then + echo define ReqBeam + #UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a + UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a +fi + +if [[ $_reqmod -lt 1 ]]; then + UNPACKER+=" --ReqMode 0" + case $_reqmod in + 0) + ;; + -1) + UNPACKER+=" --ReqDet0 10246" # diamond -> 0x00002806 v21a + UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a + UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a + ;; + -2) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 131126" # RPC 032 + UNPACKER+=" --ReqDet2 131142" # RPC 042 + ;; # for ceramics + + -3) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 196662" # RPC 033 + UNPACKER+=" --ReqDet2 196678" # RPC 043 + ;; # for BUC + + -4) # v21a address mode + UNPACKER+=" --ReqDet0 10246" # diamond + UNPACKER+=" --ReqDet1 65542" # RPC 002 + UNPACKER+=" --ReqDet2 65574" # RPC 022 + ;; + + -190) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 65606" # RPC 041 + UNPACKER+=" --ReqDet2 36870" # RPC 900 + UNPACKER+=" --ReqDet3 102406" # RPC 901 + ;; # for double stack calibration + + -191) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 65606" # RPC 041 + UNPACKER+=" --ReqDet2 24582" # RPC 600 + UNPACKER+=" --ReqDet3 90118" # RPC 601 + ;; # for USTC counter analysis + + -192) + UNPACKER+=" --ReqDet0 65606" # RPC 041 + UNPACKER+=" --ReqDet1 36870" # RPC 900 + UNPACKER+=" --ReqDet2 102406" # RPC 901 + ;; # for double stack calibration + + -193) BeamBeam + UNPACKER+=" --ReqDet0 65606" # RPC 041 + UNPACKER+=" --ReqDet1 24582" # RPC 600 + UNPACKER+=" --ReqDet2 90118" # RPC 601 + ;; # for USTC counter analysis + + -194) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 24582" # RPC 600 + UNPACKER+=" --ReqDet2 90118" # RPC 601 + ;; # for USTC counter analysis + + *) + echo ReqMode $_reqmod not yet defined, exiting + exit 1 + ;; + esac; +else + UNPACKER+=" --ReqMode $_reqmod" +fi +UNPACKER+=" --ReqTint $_reqtint" +UNPACKER+=" --PulserMode $_pulmode" +UNPACKER+=" --PulMulMin $_pulmulmin" +UNPACKER+=" --PulTotMin $_pultotmin" +UNPACKER+=" --PulTotMax $_pultotmax" +UNPACKER+=" --ToffTof $_tofftof" +UNPACKER+=" --RefModType 5" +UNPACKER+=" --RefModId 0" +UNPACKER+=" --RefCtrType 0" +UNPACKER+=" --RefCtrId 0" +if [[ $_batch = 1 ]]; then +UNPACKER+=" --control static" +UNPACKER+=" --log-to-file Unp${_iUnp}_${_runname}.out" +#echo nohup $UNPACKER +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER & +#echo execute interactively in a separate console: /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER +#read -p "Continue? (Y/N): "confirm && [[ $confirm == [yY] ]] +else +xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER & +fi + +(( _iUnp -= 1 )) +done + +echo Started Unpacker + +HITBUILDER="HitBuilderTof" +HITBUILDER+=" --id hitbuilder1" +HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig" +HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd" +#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557" +#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558" +#HITBUILDER+=" --transport shmem" +#HITBUILDER+=" --severity DEBUG" +HITBUILDER+=" --severity INFO" +#HITBUILDER+=" --severity WARN" +HITBUILDER+=" --OutRootFile $_outdir$_digifile" +#HITBUILDER+=" --MaxEvent 10000000" +#HITBUILDER+=" --RunId 1552883952" +#HITBUILDER+=" --RunId 1614415472" # tof_mcbm_beam_2021_01.par.root +HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root +HITBUILDER+=" --PulserMode $_pulmode" +HITBUILDER+=" --PulMulMin $_pulmulmin" +HITBUILDER+=" --PulTotMin $_pultotmin" +HITBUILDER+=" --PulTotMax $_pultotmax" +HITBUILDER+=" --PulDetRef $_puldetref" +HITBUILDER+=" --ReqTint $_reqtint" +#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006 +HITBUILDER+=" --BRefType 0" +HITBUILDER+=" --BRefSm 4" +HITBUILDER+=" --BRefDet 1" +HITBUILDER+=" --DutType 0" +HITBUILDER+=" --DutSm 3" +HITBUILDER+=" --DutRpc 1" +HITBUILDER+=" --SelType 0" +HITBUILDER+=" --SelSm 4" +HITBUILDER+=" --SelRpc 1" +HITBUILDER+=" --Sel2Type 5" +HITBUILDER+=" --Sel2Sm 0" +HITBUILDER+=" --Sel2Rpc 0" +if [[ $_reqmod -eq 1 ]]; then +HITBUILDER+=" --Mode 1" +fi + +if [[ $_batch = 1 ]]; then +HITBUILDER+=" --control static" +HITBUILDER+=" --log-to-file HitBuild_${_runname}.out" +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER & +else +xterm -geometry 120x23+1400+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER & +fi + +echo Started HitBuilder + +# show daughter processes +ps + +# wait for completion +RUNTIMEMAX=28000 +DeltaTime=120 +RunTime=0 +while [ $RunTime -lt $RUNTIMEMAX ]; do + PROC=`ps uaxww | grep Hit` + ProcRunning=`echo $PROC | grep Builder` + if [[ $ProcRunning != "" ]]; then + (( Runtime += DeltaTime )) + sleep $DeltaTime + else + echo No HitBuilder in $PROC + break; + fi +done +#sleep 14400 # 4h +#sleep 28000 # 8h + +echo kill all MQ processes +./stop_MQ.sh + +echo done diff --git a/MQ/hitbuilder/runMQ_Mcbm2021.sh b/MQ/hitbuilder/runMQ_Mcbm2021.sh new file mode 100644 index 0000000000000000000000000000000000000000..64f8333f90b320bc1faa549edd5fa11f0b5a9947 --- /dev/null +++ b/MQ/hitbuilder/runMQ_Mcbm2021.sh @@ -0,0 +1,376 @@ +#!/bin/bash +#SBATCH -J MQevb +#SBATCH -D /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/topologies +#SBATCH --time=6-00:00:00 +#SBATCH --mem=4000 +#SBATCH --partition=long + +X=$((${SLURM_ARRAY_TASK_ID} - 0)) +XXX=$(printf "%03d" "$X") +#$FAIRROOTPATH/bin/shmmonitor --cleanup +node=`hostname` +nodeStatus=`ps uaxwww | grep parmq` +nodeOK=`echo $nodeStatus | grep ParServ` +if [[ $nodeOK != "" ]]; then + echo parmq already running on node $node: $nodeOK, exiting ... + exit 0 +fi +echo node check on $node passed, stop eventually relict processes + +./stop_MQ.sh +#exit 0 ## debug exit + +if [ -z "$1" ]; then + _runname="359" +else + _runname=$1 +fi + +if [ -z "$2" ]; then +_reqmod=-193 +else +_reqmod=$2 +fi + +if [ -z "$3" ]; then +_pulmode=1 +else +_pulmode=$3 +fi + +if [ -z "$4" ]; then + _reqtint=100 +else + _reqtint=$4 +fi + +_Opt=$5 + +_ntimeslices=-1 +#_ntimeslices=10000 +_iUnp=1 +_batch=1 +_pulmulmin=5 +_pultotmin=50 +_pultotmax=500 +#_puldetref=12 # TSR=022 +#_puldetref=16 # TSR=032 +_puldetref=16 # TSR=031 + +#_tofftof=0. +_tofftof=-35. + +if [[ $_reqmod -eq 1 ]]; then + _iUnp=1 +fi + +#_dirname=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/ +_outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/data/ +#_datapath=~/KRONOS/CBM/cbmroot/trunk +#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/ +#_outdir=$_datapath/macro/beamtime/mcbm2018/data/ + +#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa" +#_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa" +if [ $_runname -lt 1400 ]; then +_dirname="" +_filename="./tsaData2021/${_runname}_node8_*.tsa;./tsaData2021/${_runname}_node9_*.tsa" +_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21b_mcbm.digibdf.par +else + if [ $_runname -lt 1384 ]; then + _dirname=`ls -d /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/input06/r${_runname}*` # double stack AFCK + else + _dirname=`ls -d /lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/inp07/r${_runname}*` # triple stack AFCK + fi + _filename="r${_runname}*.tsa" + _digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21c_mcbm.digibdf.par + echo dir: $_dirname + echo file: $_filename +fi + +_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root + +# ASCII files +#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/MQ/hitbuilder/MapTofGbtx.par +_mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar.par +if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_2Stack.par +else + if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_3Stack.par + _puldetref=12 # TSR=022 + else + if [ $_runname -ge 1079 ] && [ $_runname -lt 1086 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar2Stack.par + else + if [ $_runname -lt 1172 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524_DirectBeam.par + else + if [ $_runname -lt 1600 ]; then + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524.par + else + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar_20210524.par + fi + fi + fi + fi +fi +#_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/etofPar.par +#_digibdffile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v18j_cosmicHD.digibdf.par +#_digiparfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v18j_cosmicHD.digi.par +#_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21a_mcbm.digibdf.par +#_digiparfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v19b_mcbm.digi.par + +# ROOT files +#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root +#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root +_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_02.par.root + +# MQ ports +_pPar=5603 +_pSam=5613 +_pCmd=5623 +_pDig=5633 + +#rm -v nohup.out +#rm -v *log +rm all_* + +PARAMETERSERVER="parmq-server" +echo pkill $PARAMETERSERVER +pkill -9 $PARAMETERSERVER +sleep 1 +PARAMETERSERVER+=" --id parmq-server" +PARAMETERSERVER+=" --channel-name parameters" +PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018" +#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile" +PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile" +PARAMETERSERVER+=" --first-input-type ASCII" +PARAMETERSERVER+=" --second-input-name $_geofile" +PARAMETERSERVER+=" --second-input-type ROOT" +PARAMETERSERVER+=" --severity INFO" +if [[ $_batch = 1 ]]; then +PARAMETERSERVER+=" --control static" +PARAMETERSERVER+=" --log-to-file ParServ_${_runname}.out" +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER & +else +xterm -geometry 80x23+0+340 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER & +#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER & +fi + +echo Started ParameterServer + +SAMPLER="TsaMultiSamplerTof" +SAMPLER+=" --id sampler1" +SAMPLER+=" --max-timeslices $_ntimeslices" +#SAMPLER+=" --max-timeslices 1000000" +#SAMPLER+=" --flib-port 10" +#SAMPLER+=" --dirname $_dirname" +SAMPLER+=" --filename $_filename" +#SAMPLER+=" --flib-host myHost" +SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam" +SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd" +#SAMPLER+=" --transport shmem" +#SAMPLER+=" --transport zeromq" +#SAMPLER+=" --transport nanomsg" +#SAMPLER+=" --severity WARN" +SAMPLER+=" --severity INFO" +#SAMPLER+=" --severity DEBUG" +SAMPLER+=" --SelectComponents 1" +if [[ $_batch = 1 ]]; then +SAMPLER+=" --log-to-file Sampl_${_runname}.out" +SAMPLER+=" --control static" +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER & +else +xterm -geometry 80x23+0+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER & +fi + +echo Started Sampler + +while (( _iUnp > 0 )); do + +UNPACKER="UnpackTofMcbm2018" +UNPACKER+=" --id unpack$_iUnp" +UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam" +UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig" +UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd" +#UNPACKER+=" --transport shmem" +#UNPACKER+=" --severity DEBUG" +UNPACKER+=" --severity INFO" +UNPACKER+=" --SelectComponents 1" +if [[ $_reqmod -gt 10 ]]; then + echo define ReqBeam + #UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a + UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a +fi + +if [[ $_reqmod -lt 1 ]]; then + UNPACKER+=" --ReqMode 0" + case $_reqmod in + 0) + ;; + -1) + UNPACKER+=" --ReqDet0 10246" # diamond -> 0x00002806 v21a + UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a + UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a + ;; + -2) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 131126" # RPC 032 + UNPACKER+=" --ReqDet2 131142" # RPC 042 + ;; # for ceramics + + -3) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 196662" # RPC 033 + UNPACKER+=" --ReqDet2 196678" # RPC 043 + ;; # for BUC + + -4) # v21a address mode + UNPACKER+=" --ReqDet0 10246" # diamond + UNPACKER+=" --ReqDet1 65542" # RPC 002 + UNPACKER+=" --ReqDet2 65574" # RPC 022 + ;; + + -190) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 65606" # RPC 041 + UNPACKER+=" --ReqDet2 36870" # RPC 900 + UNPACKER+=" --ReqDet3 102406" # RPC 901 + ;; # for double stack calibration + + -191) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 65606" # RPC 041 + UNPACKER+=" --ReqDet2 24582" # RPC 600 + UNPACKER+=" --ReqDet3 90118" # RPC 601 + ;; # for USTC counter analysis + + -192) + UNPACKER+=" --ReqDet0 65606" # RPC 041 + UNPACKER+=" --ReqDet1 36870" # RPC 900 + UNPACKER+=" --ReqDet2 102406" # RPC 901 + ;; # for double stack calibration + + -193) BeamBeam + UNPACKER+=" --ReqDet0 65606" # RPC 041 + UNPACKER+=" --ReqDet1 24582" # RPC 600 + UNPACKER+=" --ReqDet2 90118" # RPC 601 + ;; # for USTC counter analysis + + -194) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 24582" # RPC 600 + UNPACKER+=" --ReqDet2 90118" # RPC 601 + ;; # for USTC counter analysis + + *) + echo ReqMode $_reqmod not yet defined, exiting + exit 1 + ;; + esac; +else + UNPACKER+=" --ReqMode $_reqmod" +fi +UNPACKER+=" --ReqTint $_reqtint" +UNPACKER+=" --PulserMode $_pulmode" +UNPACKER+=" --PulMulMin $_pulmulmin" +UNPACKER+=" --PulTotMin $_pultotmin" +UNPACKER+=" --PulTotMax $_pultotmax" +UNPACKER+=" --ToffTof $_tofftof" +UNPACKER+=" --RefModType 5" +UNPACKER+=" --RefModId 0" +UNPACKER+=" --RefCtrType 0" +UNPACKER+=" --RefCtrId 0" +if [[ $_batch = 1 ]]; then +UNPACKER+=" --control static" +UNPACKER+=" --log-to-file Unp${_iUnp}_${_runname}.out" +#echo nohup $UNPACKER +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER & +#echo execute interactively in a separate console: /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER +#read -p "Continue? (Y/N): "confirm && [[ $confirm == [yY] ]] +else +xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER & +fi + +(( _iUnp -= 1 )) +done + +echo Started Unpacker + +HITBUILDER="HitBuilderTof" +HITBUILDER+=" --id hitbuilder1" +HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig" +HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd" +#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557" +#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558" +#HITBUILDER+=" --transport shmem" +#HITBUILDER+=" --severity DEBUG" +HITBUILDER+=" --severity INFO" +#HITBUILDER+=" --severity WARN" +HITBUILDER+=" --OutRootFile $_outdir$_digifile" +#HITBUILDER+=" --MaxEvent 10000000" +#HITBUILDER+=" --RunId 1552883952" +#HITBUILDER+=" --RunId 1614415472" # tof_mcbm_beam_2021_01.par.root +HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root +HITBUILDER+=" --PulserMode $_pulmode" +HITBUILDER+=" --PulMulMin $_pulmulmin" +HITBUILDER+=" --PulTotMin $_pultotmin" +HITBUILDER+=" --PulTotMax $_pultotmax" +HITBUILDER+=" --PulDetRef $_puldetref" +HITBUILDER+=" --ReqTint $_reqtint" +#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006 +HITBUILDER+=" --BRefType 0" +HITBUILDER+=" --BRefSm 4" +HITBUILDER+=" --BRefDet 1" +HITBUILDER+=" --DutType 0" +HITBUILDER+=" --DutSm 3" +HITBUILDER+=" --DutRpc 1" +HITBUILDER+=" --SelType 0" +HITBUILDER+=" --SelSm 4" +HITBUILDER+=" --SelRpc 1" +HITBUILDER+=" --Sel2Type 5" +HITBUILDER+=" --Sel2Sm 0" +HITBUILDER+=" --Sel2Rpc 0" +if [[ $_reqmod -eq 1 ]]; then +HITBUILDER+=" --Mode 1" +fi + +if [[ $_batch = 1 ]]; then +HITBUILDER+=" --control static" +HITBUILDER+=" --log-to-file HitBuild_${_runname}.out" +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER & +else +xterm -geometry 120x23+1400+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER & +fi + +echo Started HitBuilder + +# show daughter processes +ps + +# wait for completion +RUNTIMEMAX=28000 +DeltaTime=120 +RunTime=0 +while [ $RunTime -lt $RUNTIMEMAX ]; do + PROC=`ps uaxww | grep Hit` + ProcRunning=`echo $PROC | grep Builder` + if [[ $ProcRunning != "" ]]; then + (( Runtime += DeltaTime )) + sleep $DeltaTime + else + echo No HitBuilder in $PROC + break; + fi +done +#sleep 14400 # 4h +#sleep 28000 # 8h + +echo kill all MQ processes +./stop_MQ.sh + +echo done diff --git a/MQ/hitbuilder/startMQ_Mcbm2021.sh b/MQ/hitbuilder/startMQ_Mcbm2021.sh index c2df6f3d178d1438623edcb367d4913848d29498..fa6ef02cd91a8f57622aaaef5c88cf3658af15b4 100755 --- a/MQ/hitbuilder/startMQ_Mcbm2021.sh +++ b/MQ/hitbuilder/startMQ_Mcbm2021.sh @@ -5,44 +5,44 @@ $FAIRROOTPATH/bin/shmmonitor --cleanup -if [ -z "$1" ]; then +if [ -z "$1" ]; then _runname="359" -else +else _runname=$1 fi - -if [ -z "$2" ]; then + +if [ -z "$2" ]; then _reqmod=-193 -else +else _reqmod=$2 fi -if [ -z "$3" ]; then +if [ -z "$3" ]; then _pulmode=1 -else +else _pulmode=$3 fi -if [ -z "$4" ]; then +if [ -z "$4" ]; then _reqtint=100 else - _reqtint=$4 + _reqtint=$4 fi _Opt=$5 -_ntimeslices=-1 -#_ntimeslices=10000 -_iUnp=1 +#_ntimeslices=-1 +_ntimeslices=100000 +_iUnp=4 _batch=1 _pulmulmin=5 _pultotmin=50 _pultotmax=500 -#_puldetref=12 # TSR=022 -_puldetref=16 # TSR=032 +_puldetref=12 # TSR=022 +#_puldetref=16 # TSR=032 -#_tofftof=0. -_tofftof=-35. +#_tofftof=0. +_tofftof=-35. if [[ $_reqmod -eq 1 ]]; then _iUnp=1 @@ -53,36 +53,42 @@ _outdir=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/data/ #_datapath=~/KRONOS/CBM/cbmroot/trunk #_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/ #_outdir=$_datapath/macro/beamtime/mcbm2018/data/ - + #_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa" #_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa" -_filename="./tsaData2021/${_runname}_node8_*.tsa;./tsaData2021/${_runname}_node9_*.tsa" +#_filename="./tsaData2021/${_runname}_node8_*.tsa;./tsaData2021/${_runname}_node9_*.tsa" +_filename="./input07/${_runname}_node8_1_*.tsa;./input07/${_runname}_node9_1_*.tsa;./input07/${_runname}_node8_2_*.tsa;./input07/${_runname}_node9_2_*.tsa;./input07/${_runname}_node8_3_*.tsa;./input07/${_runname}_node9_3_*.tsa;./input07/${_runname}_node8_4_*.tsa;./input07/${_runname}_node9_4_*.tsa;./input07/${_runname}_node8_5_*.tsa;./input07/${_runname}_node9_5_*.tsa" +#_filename="./input07/${_runname}*" _digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root -# ASCII files +# ASCII files #_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/MQ/hitbuilder/MapTofGbtx.par _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar.par -if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then +if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_2Stack.par else - if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then + if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2020/mTofPar_3Stack.par _puldetref=12 # TSR=022 - else - if [ $_runname -ge 1079 ] && [ $_runname -lt 10000 ]; then + else + if [ $_runname -ge 1079 ] && [ $_runname -lt 1086 ]; then _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofPar2Stack.par + else + _mapfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/mTofParCri.par fi fi -fi +fi #_mapfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/etofPar.par #_digibdffile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/v18j_cosmicHD.digibdf.par #_digiparfile=/lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v18j_cosmicHD.digi.par -_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21a_mcbm.digibdf.par +_digibdffile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v21c_mcbm.digibdf.par #_digiparfile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/parameters/tof/tof_v19b_mcbm.digi.par -# ROOT files +# ROOT files #_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root -_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root +#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root +#_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_02.par.root +_geofile=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_07.par.root # MQ ports _pPar=5603 @@ -90,14 +96,13 @@ _pSam=5613 _pCmd=5623 _pDig=5633 -rm -v nohup.out -rm -v *log +#rm -v nohup.out +#rm -v *log rm all_* PARAMETERSERVER="parmq-server" echo pkill $PARAMETERSERVER pkill -9 $PARAMETERSERVER -pkill -9 $PARAMETERSERVER sleep 1 PARAMETERSERVER+=" --id parmq-server" PARAMETERSERVER+=" --channel-name parameters" @@ -109,15 +114,17 @@ PARAMETERSERVER+=" --first-input-type ASCII" PARAMETERSERVER+=" --second-input-name $_geofile" PARAMETERSERVER+=" --second-input-type ROOT" PARAMETERSERVER+=" --severity INFO" -if [[ $_batch = 1 ]]; then +if [[ $_batch = 1 ]]; then PARAMETERSERVER+=" --control static" -PARAMETERSERVER+=" --log-to-file ParServ.out" +PARAMETERSERVER+=" --log-to-file ParServ_${_runname}.out" nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER & else xterm -geometry 80x23+0+340 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/parmq/$PARAMETERSERVER & #xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER & fi +echo Started ParameterServer + SAMPLER="TsaMultiSamplerTof" SAMPLER+=" --id sampler1" SAMPLER+=" --max-timeslices $_ntimeslices" @@ -134,18 +141,18 @@ SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,trans #SAMPLER+=" --severity WARN" SAMPLER+=" --severity INFO" #SAMPLER+=" --severity DEBUG" -SAMPLER+=" --SelectComponents 1" -if [[ $_batch = 1 ]]; then -SAMPLER+=" --log-to-file Sampl.out" +SAMPLER+=" --SelectComponents 0" +if [[ $_batch = 1 ]]; then +SAMPLER+=" --log-to-file Sampl_${_runname}.out" SAMPLER+=" --control static" -nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER & -else +nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER & +else xterm -geometry 80x23+0+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/source/$SAMPLER & fi - + while (( _iUnp > 0 )); do -UNPACKER="UnpackTofMcbm2018" +UNPACKER="UnpackTofCri" UNPACKER+=" --id unpack$_iUnp" UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam" UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" @@ -153,10 +160,10 @@ UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging= UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd" #UNPACKER+=" --transport shmem" #UNPACKER+=" --severity DEBUG" -UNPACKER+=" --severity INFO" -UNPACKER+=" --SelectComponents 1" +UNPACKER+=" --severity INFO" +UNPACKER+=" --SelectComponents 0" #UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a -UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a +#UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a if [[ $_reqmod -lt 1 ]]; then UNPACKER+=" --ReqMode 0" case $_reqmod in @@ -167,7 +174,7 @@ if [[ $_reqmod -lt 1 ]]; then UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a ;; - -2) + -2) UNPACKER+=" --ReqDet0 20486" # diamond UNPACKER+=" --ReqDet1 131126" # RPC 032 UNPACKER+=" --ReqDet2 131142" # RPC 042 @@ -178,28 +185,28 @@ if [[ $_reqmod -lt 1 ]]; then UNPACKER+=" --ReqDet1 196662" # RPC 033 UNPACKER+=" --ReqDet2 196678" # RPC 043 ;; # for BUC - + -4) # v21a address mode UNPACKER+=" --ReqDet0 10246" # diamond - UNPACKER+=" --ReqDet1 65542" # RPC 002 - UNPACKER+=" --ReqDet2 65574" # RPC 022 + UNPACKER+=" --ReqDet1 65542" # RPC 002 + UNPACKER+=" --ReqDet2 65574" # RPC 022 ;; - - -190) + + -190) UNPACKER+=" --ReqDet0 20486" # diamond UNPACKER+=" --ReqDet1 65606" # RPC 041 UNPACKER+=" --ReqDet2 36870" # RPC 900 UNPACKER+=" --ReqDet3 102406" # RPC 901 ;; # for double stack calibration - - -191) + + -191) UNPACKER+=" --ReqDet0 20486" # diamond UNPACKER+=" --ReqDet1 65606" # RPC 041 UNPACKER+=" --ReqDet2 24582" # RPC 600 UNPACKER+=" --ReqDet3 90118" # RPC 601 ;; # for USTC counter analysis - -192) + -192) UNPACKER+=" --ReqDet0 65606" # RPC 041 UNPACKER+=" --ReqDet1 36870" # RPC 900 UNPACKER+=" --ReqDet2 102406" # RPC 901 @@ -211,12 +218,12 @@ if [[ $_reqmod -lt 1 ]]; then UNPACKER+=" --ReqDet2 90118" # RPC 601 ;; # for USTC counter analysis - -194) + -194) UNPACKER+=" --ReqDet0 20486" # diamond UNPACKER+=" --ReqDet1 24582" # RPC 600 UNPACKER+=" --ReqDet2 90118" # RPC 601 ;; # for USTC counter analysis - + *) echo ReqMode $_reqmod not yet defined, exiting exit 1 @@ -235,17 +242,17 @@ UNPACKER+=" --RefModType 5" UNPACKER+=" --RefModId 0" UNPACKER+=" --RefCtrType 0" UNPACKER+=" --RefCtrId 0" -if [[ $_batch = 1 ]]; then +if [[ $_batch = 1 ]]; then UNPACKER+=" --control static" -UNPACKER+=" --log-to-file Unp$_iUnp.out" -#echo nohup $UNPACKER +UNPACKER+=" --log-to-file Unp${_iUnp}_${_runname}.out" +#echo nohup $UNPACKER nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER & -else -xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER & +else +xterm -geometry 110x23+520+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/unpacker/$UNPACKER & fi (( _iUnp -= 1 )) -done +done HITBUILDER="HitBuilderTof" HITBUILDER+=" --id hitbuilder1" @@ -261,7 +268,9 @@ HITBUILDER+=" --severity INFO" HITBUILDER+=" --OutRootFile $_outdir$_digifile" #HITBUILDER+=" --MaxEvent 10000000" #HITBUILDER+=" --RunId 1552883952" -HITBUILDER+=" --RunId 1614415472" +#HITBUILDER+=" --RunId 1614415472" # tof_mcbm_beam_2021_01.par.root +#HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root +HITBUILDER+=" --RunId 1629444189" # tof_mcbm_beam_2021_07.par.root HITBUILDER+=" --PulserMode $_pulmode" HITBUILDER+=" --PulMulMin $_pulmulmin" HITBUILDER+=" --PulTotMin $_pultotmin" @@ -269,25 +278,25 @@ HITBUILDER+=" --PulTotMax $_pultotmax" HITBUILDER+=" --PulDetRef $_puldetref" HITBUILDER+=" --ReqTint $_reqtint" #HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006 -HITBUILDER+=" --BRefType 5" +HITBUILDER+=" --BRefType 0" HITBUILDER+=" --BRefSm 0" -HITBUILDER+=" --BRefDet 0" +HITBUILDER+=" --BRefDet 3" HITBUILDER+=" --DutType 0" -HITBUILDER+=" --DutSm 3" -HITBUILDER+=" --DutRpc 1" +HITBUILDER+=" --DutSm 1" +HITBUILDER+=" --DutRpc 3" HITBUILDER+=" --SelType 0" -HITBUILDER+=" --SelSm 4" -HITBUILDER+=" --SelRpc 1" -HITBUILDER+=" --Sel2Type 5" +HITBUILDER+=" --SelSm 2" +HITBUILDER+=" --SelRpc 3" +HITBUILDER+=" --Sel2Type 0" HITBUILDER+=" --Sel2Sm 0" -HITBUILDER+=" --Sel2Rpc 0" +HITBUILDER+=" --Sel2Rpc 3" if [[ $_reqmod -eq 1 ]]; then HITBUILDER+=" --Mode 1" fi -if [[ $_batch = 1 ]]; then +if [[ $_batch = 1 ]]; then HITBUILDER+=" --control static" -HITBUILDER+=" --log-to-file HitBuild.out" +HITBUILDER+=" --log-to-file HitBuild_${_runname}.out" nohup /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER & else xterm -geometry 120x23+1400+0 -hold -e /lustre/nyx/cbm/users/nh/CBM/cbmroot/trunk/build/bin/MQ/hitbuilder/$HITBUILDER & diff --git a/MQ/hitbuilder/startMQ_Mcbm2022.sh b/MQ/hitbuilder/startMQ_Mcbm2022.sh new file mode 100644 index 0000000000000000000000000000000000000000..215253e5ebe4465f49446da825b78032b3fc3ddd --- /dev/null +++ b/MQ/hitbuilder/startMQ_Mcbm2022.sh @@ -0,0 +1,324 @@ +#!/bin/bash +# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt +# SPDX-License-Identifier: GPL-3.0-only +# First commited by Florian Uhlig + +$FAIRROOTPATH/bin/shmmonitor --cleanup + +if [ -z "$1" ]; then + _runname="359" +else + _runname=$1 +fi + +if [ -z "$2" ]; then +_reqmod=-193 +else +_reqmod=$2 +fi + +if [ -z "$3" ]; then +_pulmode=1 +else +_pulmode=$3 +fi + +if [ -z "$4" ]; then + _reqtint=100 +else + _reqtint=$4 +fi + +_Opt=$5 + +_ntimeslices=-1 +#_ntimeslices=1 +_iUnp=4 +_batch=1 +_pulmulmin=5 +_pultotmin=50 +_pultotmax=500 +_puldetref=12 # TSR=022 +#_puldetref=16 # TSR=032 + +#_tofftof=0. +_tofftof=-35. + +if [[ $_reqmod -eq 1 ]]; then + _iUnp=1 +fi + +#_dirname=/lustre/cbm/users/nh/CBM/cbmroot/trunk/macro/beamtime/mcbm2018/input/$_runname/ +_outdir=${VMCWORKDIR}/macro/beamtime/mcbm2021/data/ +#_datapath=~/KRONOS/CBM/cbmroot/trunk +#_dirname=$_datapath/macro/beamtime/mcbm2018/input/$_runname/ +#_outdir=$_datapath/macro/beamtime/mcbm2018/data/ + +#_filename="./tsaData/${_runname}_pn05_*.tsa;./tsaData/${_runname}_pn06_*.tsa;./tsaData/${_runname}_pn07_*.tsa" +#_filename="./tsaData2020/${_runname}_pn02_*.tsa;./tsaData2020/${_runname}_pn04_*.tsa;./tsaData2020/${_runname}_pn05_*.tsa;./tsaData2020/${_runname}_pn06_*.tsa;./tsaData2020/${_runname}_pn08_*.tsa;./tsaData2020/${_runname}_pn10_*.tsa;./tsaData2020/${_runname}_pn11_*.tsa;./tsaData2020/${_runname}_pn12_*.tsa;./tsaData2020/${_runname}_pn13_*.tsa;./tsaData2020/${_runname}_pn15_*.tsa" +_filename="${_runname}_node8_*.tsa;${_runname}_node9_*.tsa" +_dirname="${VMCWORKDIR}/build/bin/MQ/topologies/tsaData2022" + +#_filename="./input07/${_runname}_node8_1_*.tsa;./input07/${_runname}_node9_1_*.tsa;./input07/${_runname}_node8_2_*.tsa;./input07/${_runname}_node9_2_*.tsa;./input07/${_runname}_node8_3_*.tsa;./input07/${_runname}_node9_3_*.tsa;./input07/${_runname}_node8_4_*.tsa;./input07/${_runname}_node9_4_*.tsa;./input07/${_runname}_node8_5_*.tsa;./input07/${_runname}_node9_5_*.tsa" +#_filename="./input07/${_runname}*" +_digifile=$_runname.$_reqtint.$_reqmod.${_pulmode}${_Opt}.root + +# ASCII files +#_mapfile=${VMCWORKDIR}/MQ/hitbuilder/MapTofGbtx.par +_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2021/mTofPar.par +if [ $_runname -ge 707 ] && [ $_runname -lt 754 ]; then + _mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2020/mTofPar_2Stack.par +else + if [ $_runname -ge 754 ] && [ $_runname -lt 900 ]; then + _mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2020/mTofPar_3Stack.par + _puldetref=12 # TSR=022 + else + if [ $_runname -ge 1079 ] && [ $_runname -lt 1086 ]; then + _mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2021/mTofPar2Stack.par + else + _mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2021/mTofCriPar.par + fi + fi +fi +#_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2018/etofPar.par +#_digibdffile=${VMCWORKDIR}/parameters/tof/v18j_cosmicHD.digibdf.par +#_digiparfile=${VMCWORKDIR}/parameters/tof/tof_v18j_cosmicHD.digi.par +_digibdffile=${VMCWORKDIR}/parameters/tof/tof_v21f_mcbm.digibdf.par +#_digiparfile=${VMCWORKDIR}/parameters/tof/tof_v19b_mcbm.digi.par + +# ROOT files +#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2018/tof_v18l_mCbm.par.root +#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_01.par.root +#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_02.par.root +_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_09.par.root + +# MQ ports +_pPar=5603 +_pSam=5613 +_pCmd=5623 +_pDig=5633 + +#rm -v nohup.out +#rm -v *log +rm all_* + +PARAMETERSERVER="parmq-server" +echo pkill $PARAMETERSERVER +pkill -9 $PARAMETERSERVER +sleep 1 +PARAMETERSERVER+=" --id parmq-server" +PARAMETERSERVER+=" --channel-name parameters" +PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018" +#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile" +PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile" +PARAMETERSERVER+=" --first-input-type ASCII" +PARAMETERSERVER+=" --second-input-name $_geofile" +PARAMETERSERVER+=" --second-input-type ROOT" +PARAMETERSERVER+=" --severity info" +PARAMETERSERVER+=" --file-severity info" +if [[ $_batch = 1 ]]; then +PARAMETERSERVER+=" --control static" +PARAMETERSERVER+=" --log-to-file ParServ_${_runname}.out" +nohup ${VMCWORKDIR}/build/bin/MQ/parmq/$PARAMETERSERVER & +else +xterm -geometry 80x23+0+340 -hold -e ${VMCWORKDIR}/build/bin/MQ/parmq/$PARAMETERSERVER & +#xterm -geometry 80x23+500+0 -hold -e /cvmfs/fairroot.gsi.de/fairroot/v18.0.6_fairsoft-may18/bin/$PARAMETERSERVER & +fi + +echo Started ParameterServer + +SAMPLER="TsaMultiSamplerTof" +SAMPLER+=" --id sampler1" +SAMPLER+=" --max-timeslices $_ntimeslices" +#SAMPLER+=" --max-timeslices 1000000" +#SAMPLER+=" --flib-port 10" +SAMPLER+=" --dirname $_dirname" +SAMPLER+=" --filename $_filename" +#SAMPLER+=" --flib-host myHost" +SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,sndBufSize=10,rateLogging=0,transport=zeromq,address=tcp://*:$_pSam" +SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:$_pCmd" +#SAMPLER+=" --transport shmem" +#SAMPLER+=" --transport zeromq" +#SAMPLER+=" --transport nanomsg" +#SAMPLER+=" --severity WARN" +SAMPLER+=" --severity info" +SAMPLER+=" --file-severity info" +#SAMPLER+=" --file-severity debug" +SAMPLER+=" --SelectComponents 0" +if [[ $_batch = 1 ]]; then +SAMPLER+=" --log-to-file Sampl_${_runname}.out" +SAMPLER+=" --control static" +echo Sampler cmd: +echo ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER +nohup ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER & +else +xterm -geometry 80x23+0+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER & +fi + +while (( _iUnp > 0 )); do + +UNPACKER="UnpackTofCri" +UNPACKER+=" --id unpack$_iUnp" +UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rcvBufSize=2,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pSam" +UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,sndBufSize=2,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pDig" +UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd" +#UNPACKER+=" --transport shmem" +#UNPACKER+=" --severity debug" +UNPACKER+=" --severity info" +UNPACKER+=" --file-severity info" +UNPACKER+=" --SelectComponents 0" +#UNPACKER+=" --ReqBeam 20486" # diamond -> 0x00005006 v14a +UNPACKER+=" --ReqBeam 10246" # diamond -> 0x00002806 v21a +if [[ $_reqmod -lt 1 ]]; then + UNPACKER+=" --ReqMode 0" + case $_reqmod in + 0) + ;; + -1) + UNPACKER+=" --ReqDet0 10246" # diamond -> 0x00002806 v21a + UNPACKER+=" --ReqDet1 32822" # RPC 031 -> 0x00008036 v21a + UNPACKER+=" --ReqDet2 32838" # RPC 041 -> 0x00008046 v21a + ;; + -2) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 131126" # RPC 032 + UNPACKER+=" --ReqDet2 131142" # RPC 042 + ;; # for ceramics + + -3) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 196662" # RPC 033 + UNPACKER+=" --ReqDet2 196678" # RPC 043 + ;; # for BUC + + -4) # v21a address mode + UNPACKER+=" --ReqDet0 10246" # diamond + UNPACKER+=" --ReqDet1 65542" # RPC 002 + UNPACKER+=" --ReqDet2 65574" # RPC 022 + ;; + + -190) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 65606" # RPC 041 + UNPACKER+=" --ReqDet2 36870" # RPC 900 + UNPACKER+=" --ReqDet3 102406" # RPC 901 + ;; # for double stack calibration + + -191) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 65606" # RPC 041 + UNPACKER+=" --ReqDet2 24582" # RPC 600 + UNPACKER+=" --ReqDet3 90118" # RPC 601 + ;; # for USTC counter analysis + + -192) + UNPACKER+=" --ReqDet0 65606" # RPC 041 + UNPACKER+=" --ReqDet1 36870" # RPC 900 + UNPACKER+=" --ReqDet2 102406" # RPC 901 + ;; # for double stack calibration + + -193) BeamBeam + UNPACKER+=" --ReqDet0 65606" # RPC 041 + UNPACKER+=" --ReqDet1 24582" # RPC 600 + UNPACKER+=" --ReqDet2 90118" # RPC 601 + ;; # for USTC counter analysis + + -194) + UNPACKER+=" --ReqDet0 20486" # diamond + UNPACKER+=" --ReqDet1 24582" # RPC 600 + UNPACKER+=" --ReqDet2 90118" # RPC 601 + ;; # for USTC counter analysis + + -810) + UNPACKER+=" --ReqDet0 16406" # RPC 810 -> 0x00004016 v21a + #UNPACKER+=" --ReqDet1 10246" # diamond 500 -> 0x00002806 v21a + #UNPACKER+=" --ReqDet2 98358" # RPC 033 -> 0x00018036 v21a + #UNPACKER+=" --ReqDet3 12294" # RPC 600 -> 0x00003006 v21a + #UNPACKER+=" --ReqDet4 98374" # RPC 043 -> 0x00018046 v21a + ;; + + *) + echo ReqMode $_reqmod not yet defined, exiting + exit 1 + ;; + esac; +else + UNPACKER+=" --ReqMode $_reqmod" +fi +UNPACKER+=" --ReqTint $_reqtint" +UNPACKER+=" --PulserMode $_pulmode" +UNPACKER+=" --PulMulMin $_pulmulmin" +UNPACKER+=" --PulTotMin $_pultotmin" +UNPACKER+=" --PulTotMax $_pultotmax" +UNPACKER+=" --ToffTof $_tofftof" +UNPACKER+=" --RefModType 5" +UNPACKER+=" --RefModId 0" +UNPACKER+=" --RefCtrType 0" +UNPACKER+=" --RefCtrId 0" +if [[ $_batch = 1 ]]; then +UNPACKER+=" --control static" +UNPACKER+=" --log-to-file Unp${_iUnp}_${_runname}.out" +#echo nohup $UNPACKER +nohup ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER & +#VALGRIND_UNP="valgrind -v --error-limit=no --tool=memcheck --leak-check=full --show-reachable=yes --log-file=valgrind_unp_log.txt" +VALGRIND_UNP="valgrind -v --error-limit=no --tool=massif --massif-out-file=massif_unp_log.out" +#nohup $VALGRIND_UNP ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER & + +else +xterm -geometry 110x23+520+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER & +fi + +(( _iUnp -= 1 )) +done + +HITBUILDER="HitBuilderTof" +HITBUILDER+=" --id hitbuilder1" +HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rcvBufSize=4,rateLogging=0,transport=zeromq,address=tcp://*:$_pDig" +HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pPar" +HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:$_pCmd" +#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557" +#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558" +#HITBUILDER+=" --transport shmem" +#HITBUILDER+=" --severity debug" +HITBUILDER+=" --severity info" +HITBUILDER+=" --file-severity info" +#HITBUILDER+=" --severity WARN" +HITBUILDER+=" --OutRootFile $_outdir$_digifile" +#HITBUILDER+=" --MaxEvent 10000000" +#HITBUILDER+=" --RunId 1552883952" +#HITBUILDER+=" --RunId 1614415472" # tof_mcbm_beam_2021_01.par.root +#HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root +#HITBUILDER+=" --RunId 1629444189" # tof_mcbm_beam_2021_07.par.root +HITBUILDER+=" --RunId 1648616420" # tof_mcbm_beam_2021_09.par.root +HITBUILDER+=" --PulserMode $_pulmode" +HITBUILDER+=" --PulMulMin $_pulmulmin" +HITBUILDER+=" --PulTotMin $_pultotmin" +HITBUILDER+=" --PulTotMax $_pultotmax" +HITBUILDER+=" --PulDetRef $_puldetref" +HITBUILDER+=" --ReqTint $_reqtint" +#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006 +HITBUILDER+=" --BRefType 0" +HITBUILDER+=" --BRefSm 0" +HITBUILDER+=" --BRefDet 3" +HITBUILDER+=" --DutType 0" +HITBUILDER+=" --DutSm 1" +HITBUILDER+=" --DutRpc 3" +HITBUILDER+=" --SelType 0" +HITBUILDER+=" --SelSm 2" +HITBUILDER+=" --SelRpc 3" +HITBUILDER+=" --Sel2Type 0" +HITBUILDER+=" --Sel2Sm 0" +HITBUILDER+=" --Sel2Rpc 3" +if [[ $_reqmod -eq 1 ]]; then +HITBUILDER+=" --Mode 1" +fi + +if [[ $_batch = 1 ]]; then +HITBUILDER+=" --control static" +HITBUILDER+=" --log-to-file HitBuild_${_runname}.out" +nohup ${VMCWORKDIR}/build/bin/MQ/hitbuilder/$HITBUILDER & +else +xterm -geometry 120x23+1400+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/hitbuilder/$HITBUILDER & +fi diff --git a/MQ/hitbuilder/startMQ_cosmicMcbm.sh b/MQ/hitbuilder/startMQ_cosmicMcbm.sh new file mode 100644 index 0000000000000000000000000000000000000000..245b5690068500c37c53645539eeb9b88af3c10b --- /dev/null +++ b/MQ/hitbuilder/startMQ_cosmicMcbm.sh @@ -0,0 +1,203 @@ +#!/bin/bash +# Copyright (C) 2020 PI-UHd,GSI +# SPDX-License-Identifier: GPL-3.0-only +# First commited by Norbert Herrmann + +$FAIRROOTPATH/bin/shmmonitor --cleanup + +if [ -z "$1" ]; then + _runname="MCBM_cosmic_`date +%F`_`date +%T`" +else + _runname=$1 +fi + +if [ -z "$2" ]; then + _version=0 +else + _version=$2 +fi + +if [ -z "$3" ]; then + _node="node8" +else + _node=$3 +fi + +_reqmod=0 +_reqtint=50 +_ntimeslices=-1 +#_ntimeslices=100 +_iUnp=1 +_batch=1 +_pulmode=0 +_pulmulmin=18 +_pultotmin=80 +_pultotmax=500 +_puldetref=12 # TSR=022 +#_puldetref=16 # TSR=032 +#_puldetref=17 # TSR=032 + +_tofftof=0. +#_tofftof=-30. + +if [[ $_reqmod -eq 1 ]]; then + _iUnp=1 +fi + +_dirname=${VMCWORKDIR}/macro/beamtime/mcbm2021/input/$_runname/ +#_outdir=${VMCWORKDIR}/macro/beamtime/hd2020/data/ +_outdir=${VMCWORKDIR}/macro/beamtime/mcbm2021/data/ +#_datapath=~/KRONOS/CBM/cbmroot/git/cbmroot +_filename=$_runname*.tsa +#_filename=${VMCWORKDIR}/macro/beamtime/hd2020/input/$_runname/*.tsa +#_outdir=$_datapath/macro/beamtime/mcbm2018/data/ + +#_filename="./tsaData/_pn05_*.tsa;./tsaData/_pn06_*.tsa;./tsaData/_pn07_*.tsa" +_digifile=$_runname.$_reqtint.$_reqmod.$_pulmode.$_version.$_node.root + +# ASCII files +_mapfile=${VMCWORKDIR}/macro/beamtime/mcbm2021/mTofCriPar.par +_digibdffile=${VMCWORKDIR}/parameters/tof/tof_v21f_mcbm.digibdf.par +#_digiparfile=${VMCWORKDIR}/parameters/tof/tof_v21c_mcbm.digi.par + +# ROOT files +#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_07.par.root +#_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_07_surveyed.par.root +_geofile=${VMCWORKDIR}/macro/beamtime/mcbm2021/tof_mcbm_beam_2021_08.par.root + +rm -v nohup.out +rm -v *log +rm all_* + +PARAMETERSERVER="parmq-server" +echo pkill $PARAMETERSERVER +pkill -9 $PARAMETERSERVER +sleep 1 +PARAMETERSERVER+=" --id parmq-server" +PARAMETERSERVER+=" --channel-name parameters" +PARAMETERSERVER+=" --channel-config name=parameters,type=rep,method=bind,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005" +#PARAMETERSERVER+=" --libs-to-load libCbmTof;libCbmFlibMcbm2018" +#PARAMETERSERVER+=" --first-input-name $_mapfile;$_digiparfile;$_digibdffile" +PARAMETERSERVER+=" --first-input-name $_mapfile;$_digibdffile" +PARAMETERSERVER+=" --first-input-type ASCII" +PARAMETERSERVER+=" --second-input-name $_geofile" +PARAMETERSERVER+=" --second-input-type ROOT" +#PARAMETERSERVER+=" --severity INFO" +PARAMETERSERVER+=" --severity DEBUG" +#PARAMETERSERVER+=" --file-severity INFO" +if [[ $_batch = 1 ]]; then +PARAMETERSERVER+=" --control static" +PARAMETERSERVER+=" --log-to-file ParServ.out" +nohup ${VMCWORKDIR}/build/bin/MQ/parmq/$PARAMETERSERVER & +else +xterm -geometry 80x23+0+340 -hold -e ${VMCWORKDIR}/build/bin/MQ/parmq/$PARAMETERSERVER & +#xterm -geometry 80x23+500+0 -hold -e /home/cbm/starsoft/fairroot_v18.0.6-fairsoft_may18p1_root6/bin/$PARAMETERSERVER & +fi + +SAMPLER="TsaMultiSamplerTof" +SAMPLER+=" --id sampler1" +SAMPLER+=" --max-timeslices $_ntimeslices" +#SAMPLER+=" --max-timeslices 1000000" +#SAMPLER+=" --flib-port 5556" +#SAMPLER+=" --flib-host $_node" +SAMPLER+=" --dirname $_dirname" +SAMPLER+=" --filename $_filename" +SAMPLER+=" --channel-config name=tofcomponent,type=push,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5655" +SAMPLER+=" --channel-config name=syscmd,type=pub,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5666" +#SAMPLER+=" --transport shmem" +#SAMPLER+=" --transport zeromq" +#SAMPLER+=" --transport nanomsg" +#SAMPLER+=" --severity WARN" +SAMPLER+=" --severity INFO" +SAMPLER+=" --file-severity INFO" +#SAMPLER+=" --severity DEBUG" +SAMPLER+=" --SelectComponents 0" +if [[ $_batch = 1 ]]; then +SAMPLER+=" --log-to-file Sampl.out" +SAMPLER+=" --control static" +nohup ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER & +else +xterm -geometry 80x23+0+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/source/$SAMPLER & +fi + +while (( _iUnp > 0 )); do +UNPACKER="UnpackTofCri" +UNPACKER+=" --id unpack$_iUnp" +UNPACKER+=" --channel-config name=tofcomponent,type=pull,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5655" +UNPACKER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005" +UNPACKER+=" --channel-config name=tofdigis,type=push,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5656" +UNPACKER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5666" +#UNPACKER+=" --transport shmem" +#UNPACKER+=" --severity DEBUG" +#UNPACKER+=" --severity INFO" +UNPACKER+=" --file-severity info" +UNPACKER+=" --SelectComponents 0" +UNPACKER+=" --ReqMode $_reqmod" +UNPACKER+=" --ReqTint $_reqtint" +UNPACKER+=" --PulserMode $_pulmode" +UNPACKER+=" --PulMulMin $_pulmulmin" +UNPACKER+=" --PulTotMin $_pultotmin" +UNPACKER+=" --PulTotMax $_pultotmax" +UNPACKER+=" --ToffTof $_tofftof" +UNPACKER+=" --RefModType -1" +UNPACKER+=" --RefModId 0" +UNPACKER+=" --RefCtrType 0" +UNPACKER+=" --RefCtrId 0" +if [[ $_batch = 1 ]]; then +UNPACKER+=" --control static" +UNPACKER+=" --log-to-file Unp$_iUnp.out" +nohup ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER & +else +xterm -geometry 110x23+520+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/unpacker/$UNPACKER & +fi + +(( _iUnp -= 1 )) +done + +HITBUILDER="HitBuilderTof" +HITBUILDER+=" --id hitbuilder1" +HITBUILDER+=" --channel-config name=tofdigis,type=pull,method=bind,rateLogging=0,transport=zeromq,address=tcp://*:5656" +HITBUILDER+=" --channel-config name=parameters,type=req,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5005" +HITBUILDER+=" --channel-config name=syscmd,type=sub,method=connect,rateLogging=0,transport=zeromq,address=tcp://127.0.0.1:5666" +#HITBUILDER+=" --channel-config name=tofhits,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5557" +#HITBUILDER+=" --channel-config name=tofcalib,type=push,method=bind,transport=shmem,address=tcp://127.0.0.1:5558" +#HITBUILDER+=" --transport shmem" +#HITBUILDER+=" --severity DEBUG" +HITBUILDER+=" --severity INFO" +HITBUILDER+=" --file-severity INFO" +#HITBUILDER+=" --severity WARN" +HITBUILDER+=" --OutRootFile $_outdir$_digifile" +#HITBUILDER+=" --MaxEvent 10000000" +#HITBUILDER+=" --RunId 1581312162" # v20a +#HITBUILDER+=" --RunId 1597162455" # v20b +#HITBUILDER+=" --RunId 1621902311" # tof_mcbm_beam_2021_02.par.root +#HITBUILDER+=" --RunId 1629444189" # tof_mcbm_beam_2021_07.par.root +#HITBUILDER+=" --RunId 1639163969" # tof_mcbm_beam_2021_07_surveyed.par.root +HITBUILDER+=" --RunId 1647348218" # tof_mcbm_beam_2021_08.par.root +HITBUILDER+=" --PulserMode $_pulmode" +HITBUILDER+=" --PulMulMin $_pulmulmin" +HITBUILDER+=" --PulTotMin $_pultotmin" +HITBUILDER+=" --PulTotMax $_pultotmax" +HITBUILDER+=" --PulDetRef $_puldetref" +HITBUILDER+=" --ReqTint $_reqtint" +#HITBUILDER+=" --ReqBeam 20486" # diamond -> 0x00005006 +HITBUILDER+=" --BRefType -1" # -1 = no beam counter +HITBUILDER+=" --BRefSm 0" +HITBUILDER+=" --BRefDet -1" # -1 = use ModMask +HITBUILDER+=" --DutType 0" +HITBUILDER+=" --DutSm 1" +HITBUILDER+=" --DutRpc 2" +HITBUILDER+=" --SelType 0" +HITBUILDER+=" --SelSm 2" +HITBUILDER+=" --SelRpc 2" +HITBUILDER+=" --Sel2Type 2" +HITBUILDER+=" --Sel2Sm 0" +HITBUILDER+=" --Sel2Rpc 2" + +if [[ $_batch = 1 ]]; then +HITBUILDER+=" --control static" +HITBUILDER+=" --log-to-file HitBuild.out" +nohup ${VMCWORKDIR}/build/bin/MQ/hitbuilder/$HITBUILDER & +else +xterm -geometry 120x23+1400+0 -hold -e ${VMCWORKDIR}/build/bin/MQ/hitbuilder/$HITBUILDER & +fi diff --git a/MQ/unpacker/CMakeLists.txt b/MQ/unpacker/CMakeLists.txt index f86bf2a21f977fb377b2e1623ea4993c52799940..50b34ee200896d676dbfa43913275442d576f659 100644 --- a/MQ/unpacker/CMakeLists.txt +++ b/MQ/unpacker/CMakeLists.txt @@ -2,11 +2,14 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/startMQSamplerUnpackerParserver.sh.in set(INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR} + ${BASE_INCLUDE_DIRECTORIES} ${CBMROOT_SOURCE_DIR}/MQ/base # ${CBMROOT_SOURCE_DIR}/fles/mcbm2018/parameter ${CBMROOT_SOURCE_DIR}/fles/mcbm2018/dataformat ${CBMROOT_SOURCE_DIR}/fles/mcbm2018/unpacker ${CBMROOT_SOURCE_DIR}/fles/mcbm2018/commonMQ + ${CBMROOT_SOURCE_DIR}/reco/base + ${CBMROOT_SOURCE_DIR}/reco/detectors/tof/unpack ${CBMDATA_DIR} ${CBMDATA_DIR}/raw @@ -89,6 +92,22 @@ set(DEPENDENCIES Hist ) +set(EXE_NAME UnpackTofCri) +set(SRCS CbmTbDaqBuffer.cxx CbmDeviceUnpackTofCri.cxx runUnpackTofCri.cxx) +set(DEPENDENCIES + ${DEPENDENCIES_ALL} + external::fles_ipc + CbmFlibMcbm2018 + CbmTofBase + CbmBase + CbmData + CbmTofReco + Core + RIO + Net + Hist +) + # set the install dir set(BIN_DESTINATION bin/MQ/unpacker) GENERATE_EXECUTABLE() diff --git a/MQ/unpacker/CbmDeviceUnpackTofCri.cxx b/MQ/unpacker/CbmDeviceUnpackTofCri.cxx new file mode 100644 index 0000000000000000000000000000000000000000..ce258de709d821026b73e6b18ae1847fa60145b0 --- /dev/null +++ b/MQ/unpacker/CbmDeviceUnpackTofCri.cxx @@ -0,0 +1,1038 @@ +/* Copyright (C) 2018-2020 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Florian Uhlig, Norbert Herrmann [committer] */ + +/** + * CbmDeviceUnpackTofMcbm2018.cxx + * + * @since 2018-04-24 + * @author F. Uhlig + */ + +#include "CbmDeviceUnpackTofCri.h" + +#include "CbmDefs.h" +#include "CbmMQDefs.h" +#include "CbmMcbm2018TofPar.h" +#include "CbmTofUnpackAlgo.h" +#include "CbmTofUnpackConfig.h" +//#include "CbmHistManager.h" +#include "CbmTbDaqBuffer.h" +#include "CbmTimeSlice.h" +#include "CbmTofAddress.h" +#include "CbmTofDetectorId_v21a.h" // in cbmdata/tof +#include "CbmTofDigi.h" +//#include "CbmRawEvent.h" + +#include "StorableTimeslice.hpp" + +#include "FairMQLogger.h" +#include "FairMQProgOptions.h" // device->fConfig +#include "FairParGenericSet.h" +#include "FairRuntimeDb.h" + +#include "TH1.h" +#include "TH2.h" + +#include <boost/archive/binary_iarchive.hpp> +#include <boost/archive/binary_oarchive.hpp> + +// include this header to serialize vectors +#include <boost/serialization/vector.hpp> + +#include <array> +#include <iomanip> +#include <stdexcept> +#include <string> +struct InitTaskError : std::runtime_error { + using std::runtime_error::runtime_error; +}; + +using namespace std; + +static Int_t iReportMess = 0; + +//const Int_t DetMask = 0x001FFFFF; +std::shared_ptr<CbmTofUnpackConfig> fTofConfig = nullptr; //! + +CbmDeviceUnpackTofCri::CbmDeviceUnpackTofCri() + : fNumMessages(0) + , fiSelectComponents(0) + , fNumTint(0) + , fEventHeader() + , fiReqMode(0) + , fiReqTint(0) + , fiReqBeam(-1) + , fiReqDigiAddr() + , fiPulserMode(0) + , fiPulMulMin(0) + , fiPulTotMin(0) + , fiPulTotMax(1000) + , fuTotalMsNb(0) + , fuOverlapMsNb(0) + , fuCoreMs(0) + , fdMsSizeInNs(0) + , fdTsCoreSizeInNs(0) + , fuMinNbGdpb(0) + , fuNrOfGdpbs(0) + , fuNrOfFeePerGdpb(0) + , fuNrOfGet4PerFee(0) + , fuNrOfChannelsPerGet4(0) + , fuNrOfChannelsPerFee(0) + , fuNrOfGet4(0) + , fuNrOfGet4PerGdpb(0) + , fuNrOfChannelsPerGdpb(0) + , fuGdpbId(0) + , fuGdpbNr(0) + , fuGet4Id(0) + , fuGet4Nr(0) + , fMsgCounter(11, 0) // length of enum MessageTypes initialized with 0 + , fGdpbIdIndexMap() + , fvulCurrentEpoch() + , fvbFirstEpochSeen() + , fNofEpochs(0) + , fulCurrentEpochTime(0.) + //, fdMsIndex(0.) + , fdToffTof(0.) + , fiAddrRef(-1) + //, fuDiamondDpbIdx(3) + //, fbEpochSuppModeOn( kTRUE ) + //, fbGet4M24b( kFALSE ) + //, fbGet4v20( kTRUE ) + //, fbMergedEpochsOn( kTRUE ) + , fUnpackPar(nullptr) + , fdLastDigiTime(0.) + , fdFirstDigiTimeDif(0.) + //, fdEvTime0(0.) + , fhRawTDigEvT0(nullptr) + , fhRawTDigRef0(nullptr) + , fhRawTDigRef(nullptr) + , fhRawTRefDig0(nullptr) + , fhRawTRefDig1(nullptr) + , fhRawDigiLastDigi(nullptr) + , fhRawTotCh() + , fhChCount() + , fvbChanThere() + , fhChanCoinc() + , fhDetChanCoinc(nullptr) + , fvuPadiToGet4() + , fvuGet4ToPadi() + , fvuElinkToGet4() + , fvuGet4ToElink() + , fviRpcType() + , fviModuleId() + , fviNrOfRpc() + , fviRpcSide() + , fviRpcChUId() + , fBuffer(CbmTbDaqBuffer::Instance()) + , fUnpackerAlgo(nullptr) +{ + //fUnpackerAlgo = new CbmTofUnpackAlgo(); +} + +CbmDeviceUnpackTofCri::~CbmDeviceUnpackTofCri() {} + +void CbmDeviceUnpackTofCri::InitTask() +try { + // Get the information about created channels from the device + // Check if the defined channels from the topology (by name) + // are in the list of channels which are possible/allowed + // for the device + // The idea is to check at initilization if the devices are + // properly connected. For the time beeing this is done with a + // nameing convention. It is not avoided that someone sends other + // data on this channel. + //logger::SetLogLevel("INFO"); + + int noChannel = fChannels.size(); + LOG(info) << "Number of defined channels: " << noChannel; + for (auto const& entry : fChannels) { + LOG(info) << "Channel name: " << entry.first; + if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); + if (entry.first == "syscmd") { + OnData(entry.first, &CbmDeviceUnpackTofCri::HandleMessage); + continue; + } + //if(entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofCri::HandleData); + if (entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofCri::HandleParts); + else { + fChannelsToSend[0].push_back(entry.first); + LOG(info) << "Init to send data to channel " << fChannelsToSend[0][0]; + } + } + + // ---- TOF ---- + Int_t runid = 111; + + fTofConfig = std::make_shared<CbmTofUnpackConfig>("", runid); + // fTofConfig->SetDoWriteOutput(); + // fTofConfig->SetDoWriteOptOutA("CbmTofErrors"); + if (fTofConfig) { + LOG(info) << "Configure Tof Unpacker "; + fTofConfig->SetDebugState(); + fTofConfig->SetAlgo(); + fUnpackerAlgo = fTofConfig->GetUnpacker(); + InitContainers(); + //fTofConfig->InitUnpacker(); + } + else + LOG(fatal) << "Tof Unpacker not configured "; + + const Int_t iHeaderSize = 5; + fEventHeader.resize(iHeaderSize); // define size of eventheader int[] + for (int i = 0; i < iHeaderSize; i++) + fEventHeader[i] = 0; + LOG(info) << "Read config"; + fiSelectComponents = fConfig->GetValue<uint64_t>("SelectComponents"); + fiReqMode = fConfig->GetValue<uint64_t>("ReqMode"); + fiReqTint = fConfig->GetValue<uint64_t>("ReqTint"); + fiReqBeam = fConfig->GetValue<uint64_t>("ReqBeam"); + fiPulserMode = fConfig->GetValue<int64_t>("PulserMode"); + fiPulMulMin = fConfig->GetValue<uint64_t>("PulMulMin"); + fiPulTotMin = fConfig->GetValue<uint64_t>("PulTotMin"); + fiPulTotMax = fConfig->GetValue<uint64_t>("PulTotMax"); + fdToffTof = fConfig->GetValue<double_t>("ToffTof"); + Int_t iRefModType = fConfig->GetValue<int64_t>("RefModType"); + Int_t iRefModId = fConfig->GetValue<int64_t>("RefModId"); + Int_t iRefCtrType = fConfig->GetValue<int64_t>("RefCtrType"); + Int_t iRefCtrId = fConfig->GetValue<int64_t>("RefCtrId"); + if (iRefModType > -1) + fiAddrRef = CbmTofAddress::GetUniqueAddress(iRefModId, iRefCtrId, 0, 0, iRefModType, iRefCtrType); + LOG(info) << " Using reference counter address 0x" << std::hex << fiAddrRef << " and offset shift " << std::dec + << fdToffTof; + + // Int_t iMaxAsicInactive = fConfig->GetValue<uint64_t>("MaxAsicInactive"); + // fUnpackerAlgo->SetMaxAsicInactive( iMaxAsicInactive ); + Int_t iReqDet = 1; + Int_t iNReq = 0; + const Int_t iMaxReq = 50; + + while (iNReq < iMaxReq) { // FIXME, setup parameter hardwired! + iReqDet = fConfig->GetValue<uint64_t>(Form("ReqDet%d", iNReq)); + if (iReqDet == 0) break; + AddReqDigiAddr(iReqDet); + iNReq++; + } + LOG(info) << "Setup request"; + if (fiReqMode > 0) + if (iNReq == 0) { // take all defined detectors + for (UInt_t iGbtx = 0; iGbtx < fviNrOfRpc.size(); iGbtx++) { + switch (fviRpcType[iGbtx]) { + case 0: // mTof modules + case 1: // eTof modules + case 2: // M6 modules + if (iGbtx % 2 == 0) + for (Int_t iRpc = 0; iRpc < fviNrOfRpc[iGbtx]; iRpc++) { + Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]); + AddReqDigiAddr(iAddr); + } + break; + + case 4: + case 9: // HD 2-RPC boxes + for (Int_t iRpc = 0; iRpc < 2; iRpc++) { + Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]); + AddReqDigiAddr(iAddr); + } + break; + case 6: // Buc box + for (Int_t iRpc = 0; iRpc < 2; iRpc++) { + Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]); + AddReqDigiAddr(iAddr); + } + break; + + case 7: // CERN box + for (Int_t iRpc = 0; iRpc < 1; iRpc++) { + Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, 7); + AddReqDigiAddr(iAddr); + } + break; + case 8: // ceramics + for (Int_t iRpc = 0; iRpc < 8; iRpc++) { + Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], iRpc, 0, 0, fviRpcType[iGbtx]); + AddReqDigiAddr(iAddr); + } + break; + case 5: // add Diamond, single cell RPC + Int_t iAddr = CbmTofAddress::GetUniqueAddress(fviModuleId[iGbtx], 0, 0, 0, 5); + AddReqDigiAddr(iAddr); + break; + } + } + } + + LOG(info) << "ReqMode " << fiReqMode << " in " << fiReqTint << " ns " + << " with " << fiReqDigiAddr.size() << " detectors out of " << fviNrOfRpc.size() << " GBTx, PulserMode " + << fiPulserMode << " with Mul " << fiPulMulMin << ", TotMin " << fiPulTotMin; + LOG(info) << Form("ReqBeam 0x%08x", (uint) fiReqBeam); +} +catch (InitTaskError& e) { + LOG(error) << e.what(); + // Wrapper defined in CbmMQDefs.h to support different FairMQ versions + cbm::mq::ChangeState(this, cbm::mq::Transition::ErrorFound); +} + +bool CbmDeviceUnpackTofCri::IsChannelNameAllowed(std::string channelName) +{ + for (auto const& entry : fAllowedChannels) { + LOG(info) << "Inspect " << entry; + std::size_t pos1 = channelName.find(entry); + if (pos1 != std::string::npos) { + const vector<std::string>::const_iterator pos = + std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry); + const vector<std::string>::size_type idx = pos - fAllowedChannels.begin(); + LOG(info) << "Found " << entry << " in " << channelName; + LOG(info) << "Channel name " << channelName << " found in list of allowed channel names at position " << idx; + return true; + } + } + LOG(info) << "Channel name " << channelName << " not found in list of allowed channel names."; + LOG(error) << "Stop device."; + return false; +} + +Bool_t CbmDeviceUnpackTofCri::InitContainers() +{ + LOG(info) << "Init parameter containers for CbmDeviceUnpackTofCri"; + // FairRuntimeDb* fRtdb = FairRuntimeDb::instance(); + + // NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place). + // Should only be used for small data because of the cost of an additional copy + std::string message {"CbmMcbm2018TofPar,111"}; + LOG(info) << "Requesting parameter container CbmMcbm2018TofPar, sending message: " << message; + + FairMQMessagePtr req(NewSimpleMessage("CbmMcbm2018TofPar,111")); + FairMQMessagePtr rep(NewMessage()); + + if (Send(req, "parameters") > 0) { + if (Receive(rep, "parameters") >= 0) { + if (rep->GetSize() != 0) { + CbmMQTMessage tmsg(rep->GetData(), rep->GetSize()); + fUnpackPar = dynamic_cast<CbmMcbm2018TofPar*>(tmsg.ReadObject(tmsg.GetClass())); + LOG(info) << "Received unpack parameter from parmq server: " << fUnpackPar; + LOG(info) << "NrOfGdpbs: " << fUnpackPar->GetNrOfGdpbs(); + } + else { + LOG(error) << "Received empty reply. Parameter not available"; + } + } + } + + //FairParGenericSet* parset= + SetParContainers(); + + Bool_t initOK = kTRUE; + //Int_t fRunId=111; + //string fGeoSetupTag="v21c"; + //initOK &= fUnpackerAlgo->InitContainers(); + //auto reqparvec = fUnpackerAlgo->GetParContainerRequest(fGeoSetupTag, fRunId); + //initOk &= initParContainers(reqparvec); + initOK &= ReInitContainers(); // needed for TInt parameters + + // CreateHistograms(); + // initOK &= fUnpackerAlgo->CreateHistograms(); + + fvulCurrentEpoch.resize(fuNrOfGdpbs * fuNrOfGet4PerGdpb); + fvbFirstEpochSeen.resize(fuNrOfGdpbs * fuNrOfGet4PerGdpb); + fvbChanThere.resize(fviRpcChUId.size(), kFALSE); + for (UInt_t i = 0; i < fuNrOfGdpbs; ++i) { + for (UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j) { + fvulCurrentEpoch[GetArrayIndex(i, j)] = 0; + fvbFirstEpochSeen[GetArrayIndex(i, j)] = kFALSE; + } // for( UInt_t j = 0; j < fuNrOfGet4PerGdpb; ++j ) + } // for( UInt_t i = 0; i < fuNrOfGdpbs; ++i ) + + fNumTint = 0; + return initOK; +} + +void CbmDeviceUnpackTofCri::SetParContainers() +{ + //FairRuntimeDb* fRtdb = FairRuntimeDb::instance(); + LOG(info) << "NrOfGdpbs: " << fUnpackPar->GetNrOfGdpbs(); + + // PAL, 2022/07/05: use algo native pointer interface + sanity checks to set the parameter + auto reqparvec = fTofConfig->GetParContainerRequest(); + if (1 == reqparvec->size() && (reqparvec->at(0).second->IsA() == CbmMcbm2018TofPar::Class())) { + reqparvec->at(0).second.reset(fUnpackPar); + } + else { + LOG(fatal) << "CbmDeviceUnpackTofCri::SetParContainers => wronf number of parameters needed for the algo or wrong " + << "Parameter type"; + } + /* + TList* fParCList; // = fUnpackerAlgo->GetParList(); + + LOG(info) << "Setting parameter containers for " << fParCList->GetEntries() << " entries "; + + for (Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC) { + FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); + fParCList->Remove(tempObj); + + std::string sParamName {tempObj->GetName()}; + + FairParGenericSet* newObj = dynamic_cast<FairParGenericSet*>(fRtdb->getContainer(sParamName.data())); + LOG(info) << " - Get " << sParamName.data() << " at " << newObj; + if (nullptr == newObj) { + + LOG(error) << "Failed to obtain parameter container " << sParamName << ", for parameter index " << iparC; + return; + } // if( nullptr == newObj ) + if (iparC == 0) { + newObj = (FairParGenericSet*) fUnpackPar; + LOG(info) << " - Mod " << sParamName.data() << " to " << newObj; + } + fParCList->AddAt(newObj, iparC); + // delete tempObj; + } // for( Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC ) + */ +} + +void CbmDeviceUnpackTofCri::AddMsComponentToList(size_t /*component*/, UShort_t /*usDetectorId*/) +{ + //fUnpackerAlgo->AddMsComponentToList(component, usDetectorId); +} + +Bool_t CbmDeviceUnpackTofCri::ReInitContainers() +{ + LOG(info) << "ReInit parameter containers for CbmDeviceUnpackCriTofPar."; + + UInt_t uNrOfGbtx = fUnpackPar->GetNrOfGbtx(); + fviRpcType.resize(uNrOfGbtx); + fviModuleId.resize(uNrOfGbtx); + fviNrOfRpc.resize(uNrOfGbtx); + fviRpcSide.resize(uNrOfGbtx); + + for (UInt_t iGbtx = 0; iGbtx < uNrOfGbtx; ++iGbtx) { + fviNrOfRpc[iGbtx] = fUnpackPar->GetNrOfRpc(iGbtx); + fviRpcType[iGbtx] = fUnpackPar->GetRpcType(iGbtx); + fviRpcSide[iGbtx] = fUnpackPar->GetRpcSide(iGbtx); + fviModuleId[iGbtx] = fUnpackPar->GetModuleId(iGbtx); + } + return kTRUE; +} + +void CbmDeviceUnpackTofCri::CreateHistograms() +{ + LOG(info) << "create Histos for " << fuNrOfGdpbs << " gDPBs "; + + fhRawTDigEvT0 = + new TH1F(Form("Raw_TDig-EvT0"), Form("Raw digi time difference to 1st digi ; time [ns]; cts"), 500, 0, 100.); + // fHM->Add( Form("Raw_TDig-EvT0"), fhRawTDigEvT0); + + fhRawTDigRef0 = + new TH1F(Form("Raw_TDig-Ref0"), Form("Raw digi time difference to Ref ; time [ns]; cts"), 6000, -10000, 50000); + // fHM->Add( Form("Raw_TDig-Ref0"), fhRawTDigRef0); + + fhRawTDigRef = + new TH1F(Form("Raw_TDig-Ref"), Form("Raw digi time difference to Ref ; time [ns]; cts"), 6000, -1000, 5000); + // fHM->Add( Form("Raw_TDig-Ref"), fhRawTDigRef); + + fhRawTRefDig0 = new TH1F(Form("Raw_TRef-Dig0"), Form("Raw Ref time difference to last digi ; time [ns]; cts"), 9999, + -50000, 50000); + // fHM->Add( Form("Raw_TRef-Dig0"), fhRawTRefDig0); + + fhRawTRefDig1 = + new TH1F(Form("Raw_TRef-Dig1"), Form("Raw Ref time difference to last digi ; time [ns]; cts"), 9999, -5000, 5000); + // fHM->Add( Form("Raw_TRef-Dig1"), fhRawTRefDig1); + + fhRawDigiLastDigi = new TH1F(Form("Raw_Digi-LastDigi"), + Form("Raw Digi time difference to last digi ; time [ns]; cts"), 9999, -5000, 5000); + // 9999, -5000000, 5000000); + // fHM->Add( Form("Raw_Digi-LastDigi"), fhRawDigiLastDigi); + + fhRawTotCh.resize(fuNrOfGdpbs); + fhChCount.resize(fuNrOfGdpbs); + fhChanCoinc.resize(fuNrOfGdpbs * fuNrOfFeePerGdpb / 2); + for (UInt_t uGdpb = 0; uGdpb < fuNrOfGdpbs; uGdpb++) { + fhRawTotCh[uGdpb] = new TH2F(Form("Raw_Tot_gDPB_%02u", uGdpb), Form("Raw TOT gDPB %02u; channel; TOT [bin]", uGdpb), + fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, 256, 0., 256.); + // fHM->Add( Form("Raw_Tot_gDPB_%02u", uGdpb), fhRawTotCh[ uGdpb ]); + + fhChCount[uGdpb] = + new TH1I(Form("ChCount_gDPB_%02u", uGdpb), Form("Channel counts gDPB %02u; channel; Hits", uGdpb), + fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb); + // fHM->Add( Form("ChCount_gDPB_%02u", uGdpb), fhChCount[ uGdpb ]); + /* + for( UInt_t uLeftFeb = uGdpb*fuNrOfFebsPerGdpb / 2; + uLeftFeb < (uGdpb + 1 )*fuNrOfFebsPerGdpb / 2; + ++uLeftFeb ) + { + fhChanCoinc[ uLeftFeb ] = new TH2F( Form("fhChanCoinc_%02u", uLeftFeb), + Form("Channels Coincidence %02; Left; Right", uLeftFeb), + fuNrOfChannelsPerFee, 0., fuNrOfChannelsPerFee, + fuNrOfChannelsPerFee, 0., fuNrOfChannelsPerFee ); + } // for( UInt_t uLeftFeb = 0; uLeftFeb < fuNrOfFebsPerGdpb / 2; uLeftFeb ++ ) + */ + fhChanCoinc[uGdpb] = + new TH2F(Form("fhChanCoinc_%02u", uGdpb), Form("Channels Coincidence %02u; Left; Right", uGdpb), + fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb, fuNrOfChannelsPerGdpb, 0., fuNrOfChannelsPerGdpb); + } // for( UInt_t uGdpb = 0; uGdpb < fuMinNbGdpb; uGdpb ++) + fhDetChanCoinc = new TH2F("fhDetChanCoinc", "Det Channels Coincidence; Left; Right", 32, 0., 32, 32, 0., 32); +} + +// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) +bool CbmDeviceUnpackTofCri::HandleData(FairMQMessagePtr& msg, int /*index*/) +{ + // Don't do anything with the data + // Maybe add an message counter which counts the incomming messages and add + // an output + fNumMessages++; + LOG(debug) << "Received message number " << fNumMessages << " with size " << msg->GetSize(); + + std::string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize()); + std::istringstream iss(msgStr); + boost::archive::binary_iarchive inputArchive(iss); + + fles::StorableTimeslice component {0}; + inputArchive >> component; + + // CheckTimeslice(component); + + DoUnpack(component, 0); + + BuildTint(component.start_time(), 0); + + if (fNumMessages % 1000 == 0) LOG(info) << "Processed " << fNumMessages << " time slices"; + + return true; +} + +bool CbmDeviceUnpackTofCri::HandleParts(FairMQParts& parts, int /*index*/) +{ + // Don't do anything with the data + // Maybe add an message counter which counts the incomming messages and add + // an output + fNumMessages++; + LOG(debug) << "Received message number " << fNumMessages << " with " << parts.Size() << " parts"; + + fles::StorableTimeslice ts {0}; + uint64_t ulTsStartTime = 0; + + switch (fiSelectComponents) { + case 0: { + std::string msgStr(static_cast<char*>(parts.At(0)->GetData()), (parts.At(0))->GetSize()); + std::istringstream iss(msgStr); + boost::archive::binary_iarchive inputArchive(iss); + inputArchive >> ts; + //CheckTimeslice(ts); + for (size_t c {0}; c < ts.num_components(); c++) { + auto systemID = static_cast<int>(ts.descriptor(c, 0).sys_id); + if (1 == fNumMessages) { + LOG(info) << "Found systemID: " << std::hex << systemID << std::dec; + //fUnpackerAlgo->AddMsComponentToList(c, systemID); // TOF data + } + if (systemID == 0x60 || systemID == 0x90) { // FIXME hardwired numbers + //LOG(info) << "Call unpacker for component " << c; + DoUnpack(ts, c); + } + } + ulTsStartTime = ts.start_time(); + } break; + case 1: { + fles::StorableTimeslice component {0}; + + uint ncomp = parts.Size(); + for (uint i = 0; i < ncomp; i++) { + std::string msgStr(static_cast<char*>(parts.At(i)->GetData()), (parts.At(i))->GetSize()); + std::istringstream iss(msgStr); + boost::archive::binary_iarchive inputArchive(iss); + //fles::StorableTimeslice component{i}; + inputArchive >> component; + + // CheckTimeslice(component); + //fUnpackerAlgo->AddMsComponentToList(0, 0x60); // TOF data + LOG(debug) << "HandleParts message " << fNumMessages << ", component " << i << ",size " + << (parts.At(i))->GetSize(); + DoUnpack(component, 0); + } + ulTsStartTime = component.start_time(); + } break; + default:; + } + + BuildTint(ulTsStartTime, 0); + + if (fNumMessages % 100 == 0) LOG(info) << "Processed " << fNumMessages << " time slices"; + //LOG(info) << "HandleParts done with message number " << fNumMessages; + + return true; +} + +bool CbmDeviceUnpackTofCri::HandleMessage(FairMQMessagePtr& msg, int /*index*/) +{ + const char* cmd = (char*) (msg->GetData()); + const char cmda[4] = {*cmd}; + LOG(info) << "Handle message " << cmd << ", " << cmd[0]; + cbm::mq::LogState(this); + + // only one implemented so far "Stop" + + if (strcmp(cmda, "STOP")) { + LOG(info) << "STOP"; + fUnpackerAlgo->Finish(); + cbm::mq::ChangeState(this, cbm::mq::Transition::Ready); + cbm::mq::LogState(this); + cbm::mq::ChangeState(this, cbm::mq::Transition::DeviceReady); + cbm::mq::LogState(this); + cbm::mq::ChangeState(this, cbm::mq::Transition::Idle); + cbm::mq::LogState(this); + cbm::mq::ChangeState(this, cbm::mq::Transition::End); + cbm::mq::LogState(this); + } + return true; +} + +Bool_t CbmDeviceUnpackTofCri::DoUnpack(const fles::Timeslice& ts, size_t component) +{ + LOG(debug) << "Timeslice " << ts.index() << " contains " << ts.num_microslices(component) + << " microslices of component " << component << ", NCoreMs: " << ts.num_core_microslices(); + + fUnpackerAlgo->SetTsStartTime(ts.start_time()); + std::vector<CbmTofDigi> vDigi = fUnpackerAlgo->Unpack(&ts, component); + + LOG(debug) << "TS " << ts.index() << ", startTime " << ts.start_time() << ": insert " << vDigi.size() + << " digis of component " << component << " into DAQ buffer with size " << fBuffer->GetSize(); + + CbmTofDigi* fDigi = NULL; + CbmTofDigi* fDigiLast = NULL; + for (auto digi : vDigi) { + // Memorize last digi + if (NULL != fDigi) fDigiLast = fDigi; + // copy Digi for insertion into DAQ buffer + fDigi = new CbmTofDigi(digi); + + //if( (fDigi->GetAddress() & 0x000F00F ) != fiAddrRef ) fDigi->SetTime(fDigi->GetTime()+fdToffTof); // shift all Tof Times for v14a geometries + if ((fDigi->GetAddress() & 0x000780F) != fiAddrRef) + fDigi->SetTime(fDigi->GetTime() + fdToffTof); // shift all Tof Times for V21a + + LOG(debug) << "BufferInsert TSRCS " + << Form("%d%d%d%02d%d", (int) fDigi->GetType(), (int) fDigi->GetSm(), (int) fDigi->GetRpc(), + (int) fDigi->GetChannel(), (int) fDigi->GetSide()) + << Form(", 0x%08x, t %012.2f", fDigi->GetAddress(), fDigi->GetTime()) + << Form(", first %012.2f, last %012.2f, size %u", fBuffer->GetTimeFirst(), fBuffer->GetTimeLast(), + fBuffer->GetSize()); + if (NULL != fDigiLast) { + if ((fDigi->GetTime() * 1000) == (fDigiLast->GetTime() * 1000)) { + if (iReportMess++ < 1000) + LOG(warn) << "Successive digis with same time: " + << Form("%12.3f, TSRCS %d%d%d%02d%d - %d%d%d%02d%d", fDigi->GetTime(), (Int_t) fDigi->GetType(), + (Int_t) fDigi->GetSm(), (Int_t) fDigi->GetRpc(), (Int_t) fDigi->GetChannel(), + (Int_t) fDigi->GetSide(), (Int_t) fDigiLast->GetType(), (Int_t) fDigiLast->GetSm(), + (Int_t) fDigiLast->GetRpc(), (Int_t) fDigiLast->GetChannel(), (Int_t) fDigiLast->GetSide()); + } + else + fBuffer->InsertData<CbmTofDigi>(fDigi); + } + else + fBuffer->InsertData<CbmTofDigi>(fDigi); + + LOG(debug) << "I " + << " TSRC " << fDigi->GetType() << fDigi->GetSm() << fDigi->GetRpc() << fDigi->GetChannel() << " S " + << fDigi->GetSide() << " : " << Form("T %15.3f, Tot %5.1f", fDigi->GetTime(), fDigi->GetTot()); + } + vDigi.clear(); + //fUnpackerAlgo->ClearVector(); + + return kTRUE; +} + +void CbmDeviceUnpackTofCri::BuildTint(uint64_t ulTsStartTime, int iMode) +{ + // iMode - sending condition + // 0 (default)- build time interval only if last buffer entry is older the start + TSLength + // 1 (finish), empty buffer without checking + // Steering variables + double TSLENGTH = 1.E6; + double fdMaxDeltaT = (double) fiReqTint; // in ns + + LOG(debug) << "BuildTint: Buffer size " << fBuffer->GetSize() << ", DeltaT " + << (fBuffer->GetTimeLast() - fBuffer->GetTimeFirst()) / 1.E9 << " s"; + CbmTbDaqBuffer::Data data; + CbmTofDigi* digi; + + while (fBuffer->GetSize() > 0) { + Double_t fTimeBufferLast = fBuffer->GetTimeLast(); + + switch (iMode) { + case 0: + if (fTimeBufferLast - fBuffer->GetTimeFirst() < TSLENGTH) { + LOG(debug) << "BuildTint: refill DAQ buffer "; + return; + } + break; + case 1:; break; + } + + data = fBuffer->GetNextData(fTimeBufferLast); + digi = boost::any_cast<CbmTofDigi*>(data.first); + assert(digi); + + Double_t dTEnd = digi->GetTime() + fdMaxDeltaT; + Double_t dTEndMax = digi->GetTime() + 2 * fdMaxDeltaT; + LOG(debug) << Form("Next event at %f until %f, max %f ", digi->GetTime(), dTEnd, dTEndMax); + + if (dTEnd > fTimeBufferLast) { + LOG(warn) << Form("Remaining buffer < %f with %d entries is not " + "sufficient for digi ending at %f -> skipped ", + fTimeBufferLast, fBuffer->GetSize(), dTEnd); + return; + } + + LOG(debug) << "BuildTint0 with digi " << Form("0x%08x at %012.2f", digi->GetAddress(), digi->GetTime()); + + Bool_t bDet[fiReqDigiAddr.size()][2]; + for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++) + for (Int_t j = 0; j < 2; j++) + bDet[i][j] = kFALSE; //initialize + Bool_t bPul[fiReqDigiAddr.size()][2]; + for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++) + for (Int_t j = 0; j < 2; j++) + bPul[i][j] = kFALSE; //initialize + Bool_t bBeam = kFALSE; + + std::vector<CbmTofDigi*> vdigi; + UInt_t nDigi = 0; + //const Int_t AddrMask=0x003FFFFF; + const Int_t AddrMask = 0x001FFFFF; + Bool_t bOut = kFALSE; + Int_t iBucMul = 0; + + while (data.second != ECbmModuleId::kNotExist) { // build digi array + digi = boost::any_cast<CbmTofDigi*>(data.first); + LOG(debug) << "GetNextData " << digi << ", " << data.second << ", " << Form("%f %f", digi->GetTime(), dTEnd) + << ", Mul " << nDigi; + assert(digi); + + if (nDigi == vdigi.size()) vdigi.resize(nDigi + 100); + vdigi[nDigi++] = digi; + + Int_t iAddr = digi->GetAddress() & AddrMask; + if (iAddr == 0x00003006 || iAddr == 0x0000b006) { + iBucMul++; + LOG(debug) << Form("Event %10lu: BucMul %2d, addr 0x%08x, side %d, strip %2d, rpc %d", fEventHeader[0], iBucMul, + (uint) digi->GetAddress(), (Int_t) digi->GetSide(), (Int_t) digi->GetChannel(), + (int) digi->GetRpc()); + } + for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++) + if ((digi->GetAddress() & AddrMask) == fiReqDigiAddr[i]) { + Int_t j = ((CbmTofDigi*) digi)->GetSide(); + bDet[i][j] = kTRUE; + if (fiReqDigiAddr[i] == (Int_t) fiReqBeam) { + bBeam = kTRUE; + LOG(debug) << "Found ReqBeam at index " << nDigi - 1 << ", req " << i; + } + if ((UInt_t) fiReqDigiAddr[i] == fiAddrRef) bDet[i][1] = kTRUE; // diamond with pad readout + if ((fiReqDigiAddr[i] & 0x0000F00F) == 0x00004006) { // pad counters v21a + bDet[i][1] = kTRUE; + LOG(debug) << Form("Pad counter 0x%08x found in ev %10lu", fiReqDigiAddr[i], fEventHeader[0]); + } + Int_t str = ((CbmTofDigi*) digi)->GetChannel(); + + switch (j) { // treat both strip ends separately + case 0: { + switch (fiPulserMode) { + case 0: + case 1: + if (str == 31) + if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][0] = kTRUE; + if (str == 0) bPul[i][1] = kFALSE; + if ((UInt_t) fiReqDigiAddr[i] == fiAddrRef) { //special mapping for MAr2019 diamond (T0) + if (str == 0) bPul[i][0] = kTRUE; + if (str == 40) bPul[i][1] = kTRUE; + } + break; + case 2: + if (str == 0) { + if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) { + bPul[i][0] = kTRUE; + if ((fiReqDigiAddr[i] & 0x000FF00F) == 0x00078006) { + bPul[i][1] = kTRUE; // ceramic with pad readout + bDet[i][1] = kFALSE; // remove Hit flag + } + if (str == 31) bPul[i][1] = kFALSE; + } + } + default:; + } + } break; + + case 1: + switch (fiPulserMode) { + case 0: + case 1: + if (str == 31) bPul[i][0] = kFALSE; + if (str == 0) + if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][1] = kTRUE; + break; + case 2: + if (str == 0) bPul[i][0] = kFALSE; + if (str == 31) + if (digi->GetTot() > fiPulTotMin && digi->GetTot() < fiPulTotMax) bPul[i][1] = kTRUE; + break; + default:; + } + break; + default:; + } + } + //if(bOut) LOG(info)<<Form("Found 0x%08x, Req 0x%08x ", digi->GetAddress(), fiReqDigiAddr); + if (dTEnd - digi->GetTime() < fdMaxDeltaT * 0.5) { + if (digi->GetTime() + fdMaxDeltaT * 0.5 < dTEndMax) dTEnd = digi->GetTime() + fdMaxDeltaT * 0.5; + else + dTEnd = dTEndMax; + }; + data = fBuffer->GetNextData(dTEnd); + + } // end while + + LOG(debug) << Form(" %d digis associated to dTEnd = %15.9f", nDigi, dTEnd); + //for(UInt_t iDigi=0; iDigi<nDigi; iDigi++) LOG(debug)<<Form(" 0x%08x",vdigi[iDigi]->GetAddress()); + //for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++) LOG(debug) << vdigi[iDigi]->ToString(); + for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++) + LOG(debug) << "B " << iDigi << " TSRC " << vdigi[iDigi]->GetType() << vdigi[iDigi]->GetSm() + << vdigi[iDigi]->GetRpc() << vdigi[iDigi]->GetChannel() << " S " << vdigi[iDigi]->GetSide() << " : " + << Form("T %15.3f, Tot %5.1f", vdigi[iDigi]->GetTime(), vdigi[iDigi]->GetTot()); + + UInt_t iDetMul = 0; + if (fiReqDigiAddr.size() == 0) bOut = kTRUE; // output everything + else { + if (fiReqMode == 0) { // check for presence of requested detectors + for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++) + if (bDet[i][0] == kFALSE || bDet[i][1] == kFALSE) break; + else if (i == fiReqDigiAddr.size() - 1) { + bOut = kTRUE; + iDetMul = i; + } + } + else { // check for presence of any known detector + for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++) + if (bDet[i][0] == kTRUE && bDet[i][1] == kTRUE) { iDetMul++; } + if (iDetMul >= fiReqMode) { bOut = kTRUE; } + } + } + + if (bOut && fiReqDigiAddr.size() > 1) { + LOG(debug) << "Found Req coinc in event with " << nDigi << " digis in " << iDetMul + << " detectors, dTEnd = " << dTEnd; + } + + // determine Pulser status + UInt_t iPulMul = 0; // Count Potential Pulser Signals + for (UInt_t i = 0; i < fiReqDigiAddr.size(); i++) { + if (bPul[i][0] == kTRUE && bPul[i][1] == kTRUE) iPulMul++; + } + + if (fiPulserMode > 0 && iPulMul > fiPulMulMin) { + LOG(debug) << "@Event " << fEventHeader[0] << ": iPulMul = " << iPulMul; + bOut = kTRUE; + } + + LOG(debug) << "Process Ev " << fEventHeader[0] << " with iDetMul = " << iDetMul << ", iPulMul = " << iPulMul; + + fEventHeader[0]++; + + if ((Int_t) fiReqBeam > -1) { + if (bBeam) { LOG(debug) << "Beam counter is present "; } + else { + LOG(debug) << "Beam counter is not present"; + bOut = kFALSE; // request beam counter for event + } + } + + if (bOut) { + fEventHeader[1] = iDetMul; + fEventHeader[2] = fiReqMode; + fEventHeader[3] = iPulMul; + fEventHeader[4] = ulTsStartTime; // PAL, 2022/07/05: no need to go to algo to get this value + /* + LOG(info) << "Sevt # " << fEventHeader[0] + <<", DetMul "<< fEventHeader[1] + <<", ReqMod "<< fEventHeader[2] + <<", PulMul "<< fEventHeader[3] + <<", TsStart "<< fEventHeader[4]; + */ + vdigi.resize(nDigi); + const Int_t NDigiMax = 10000; //FIXME constant number in code + if (nDigi > NDigiMax) { + LOG(warn) << "Oversized event " << fEventHeader[0] << ", size " << nDigi << " truncated! "; + for (UInt_t iDigi = NDigiMax; iDigi < nDigi; iDigi++) { + LOG(debug) << "Discard digi " << iDigi << ": " << vdigi[iDigi]->ToString(); + delete vdigi[iDigi]; + } + nDigi = 1; //NDigiMax; + vdigi.resize(nDigi); + } + LOG(debug) << "Send " << nDigi << " digis to HitBuilder"; + SendDigis(vdigi, 0); + + for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++) + delete vdigi[iDigi]; + } + else { + LOG(debug) << " BuildTint cleanup of " << nDigi << " digis"; + for (UInt_t iDigi = 0; iDigi < nDigi; iDigi++) { + delete vdigi[iDigi]; + // vdigi[iDigi]->Delete(); + } + LOG(debug) << " Digis deleted "; + //vdigi.clear(); + //delete &vdigi; // crashes, since local variable, will be done at return (?) + } + } +} + +bool CbmDeviceUnpackTofCri::SendDigis(std::vector<CbmTofDigi*> vdigi, int idx) +{ + LOG(debug) << "Send Digis for event " << fNumTint << " with size " << vdigi.size() << Form(" at %p ", &vdigi); + LOG(debug) << "EventHeader: " << fEventHeader[0] << " " << fEventHeader[1] << " " << fEventHeader[2] << " " + << fEventHeader[3]; + + // Int_t NDigi=vdigi.size(); + + std::stringstream ossE; + boost::archive::binary_oarchive oaE(ossE); + oaE << fEventHeader; + std::string* strMsgE = new std::string(ossE.str()); + + std::stringstream oss; + boost::archive::binary_oarchive oa(oss); + oa << vdigi; + std::string* strMsg = new std::string(oss.str()); + + FairMQParts parts; + parts.AddPart(NewMessage( + const_cast<char*>(strMsgE->c_str()), // data + strMsgE->length(), // size + [](void*, void* object) { delete static_cast<std::string*>(object); }, + strMsgE)); // object that manages the data + + parts.AddPart(NewMessage( + const_cast<char*>(strMsg->c_str()), // data + strMsg->length(), // size + [](void*, void* object) { delete static_cast<std::string*>(object); }, + strMsg)); // object that manages the data + + + /* + std::vector<CbmTofDigi>vTofDigi; + vTofDigi.resize(vdigi.size()); + for (Int_t i=0; i<vdigi.size(); i++) { + CbmTofDigi *pdigi = (CbmTofDigi *) vdigi[i]; + CbmTofDigi digi = *pdigi; + vTofDigi[i] = digi; + LOG(debug) << vTofDigi[i].ToString()<<" bits "<<Form("0x%08x",vTofDigi[i].TestBits(0xFFFF)); + } + FairMQMessagePtr msg(NewMessage(static_cast<std::vector<CbmTofDigi>*> (&vTofDigi), // data + NDigi*sizeof(CbmTofDigi), // size + [](void* , void* object){ delete static_cast<CbmTofDigi*>(object); } + )); // object that manages the data + + // transfer of TofDigi array, ... works + CbmTofDigi aTofDigi[NDigi]; + // const Int_t iNDigiOut=100; + // NDigi=TMath::Min(NDigi,iNDigiOut); + // std::array<CbmTofDigi,iNDigiOut> aTofDigi; + for (Int_t i=0; i<NDigi; i++) { + aTofDigi[i] = *vdigi[i]; + LOG(debug) << aTofDigi[i].ToString()<<" bits "<<Form("0x%08x",aTofDigi[i].TestBits(0xFFFF)); + } + FairMQMessagePtr msg(NewMessage(static_cast<CbmTofDigi*> (&aTofDigi[0]), // data + NDigi*sizeof(CbmTofDigi), // size + [](void* , void* object){ delete static_cast<CbmTofDigi*>(object); } + )); // object that manages the data + + + LOG(info) << "Send aTofDigi sizes "<<NDigi<<", "<<sizeof(CbmTofDigi)<<", msg size "<<msg->GetSize(); + + // serialize the timeslice and create the message + + std::stringstream oss; + boost::archive::binary_oarchive oa(oss); + oa << vdigi; + std::string* strMsg = new std::string(oss.str()); + + LOG(debug) << "send strMsg with length " << strMsg->length()<<" "<<strMsg; + FairMQMessagePtr msg(NewMessage(const_cast<char*>(strMsg->c_str()), // data + strMsg->length(), // size + [](void* , void* object){ delete static_cast<std::string*>(object); }, + strMsg)); // object that manages the data + */ + /* + FairMQMessagePtr msg(NewMessage(static_cast<CbmTofDigi*> (vTofDigi.data()), // data + vTofDigi.size()*sizeof(CbmTofDigi), // size + [](void* , void* object){ delete static_cast<CbmTofDigi*>(object); } + )); // object that manages the data + */ + + /* --------------------------------------- compiles but crashes .... --------------------------------------------------- + const Int_t WSize=8; + FairMQMessagePtr msg(NewMessage(static_cast<std::vector<CbmTofDigi>*> (&vTofDigi), // data + vTofDigi.size()*sizeof(CbmTofDigi)*WSize, // size, FIXME, numerical value in code! + [](void* , void* object){ delete static_cast<std::vector<CbmTofDigi>*>(object); } + )); // object that manages the data + + LOG(info) << "Send TofDigi sizes "<<vTofDigi.size()<<", "<<sizeof(CbmTofDigi)<<", msg size "<<msg->GetSize(); + int *pData = static_cast <int *>(vTofDigi.data()); + + int *pData = static_cast <int *>(msg->GetData()); + const Int_t NBytes=4; + for (int iData=0; iData<msg->GetSize()/NBytes; iData++) { + LOG(info) << Form(" ind %d, poi %p, data: 0x%08x",iData,pData,*pData++); + } + */ + /* + auto msg = NewMessageFor("my_channel", 0, + static_cast<void*>(vTofDigi.data()), + vTofDigi.size() * sizeof(CbmTofDigi), + FairMQNoCleanup, nullptr); + */ + + // TODO: Implement sending same data to more than one channel + // Need to create new message (copy message??) + /* + if (fChannelsToSend[idx]>1) { + LOG(info) << "Need to copy FairMessage ?"; + } + */ + // in case of error or transfer interruption, + // return false to go to IDLE state + // successfull transfer will return number of bytes + // transfered (can be 0 if sending an empty message). + + LOG(debug) << "Send data to channel " << idx << " " << fChannelsToSend[idx][0]; + + + // if (Send(msg, fChannelsToSend[idx][0]) < 0) { + if (Send(parts, fChannelsToSend[idx][0]) < 0) { + LOG(error) << "Problem sending data " << fChannelsToSend[idx][0]; + return false; + } + + LOG(debug) << "Sent event # " << fNumTint << " from " << vdigi.size() << " Digis at " << vdigi.data() << ", " + << &vdigi; + + fNumTint++; + //if(fNumTint==100) FairMQStateMachine::ChangeState(PAUSE); //sleep(10000); // Stop for debugging ... + /* + LOG(info) << "Send message " << fNumTint << " with a size of " + << msg->GetSize(); + */ + return true; +} + +void CbmDeviceUnpackTofCri::AddReqDigiAddr(Int_t iAddr) +{ + UInt_t iNReq = fiReqDigiAddr.size(); + for (UInt_t i = 0; i < iNReq; i++) + if (fiReqDigiAddr[i] == iAddr) return; // det already present, avoid double counting + fiReqDigiAddr.resize(iNReq + 1); // hopefully the old entries are preserved ... + fiReqDigiAddr[iNReq] = iAddr; + LOG(info) << Form("Request Digi Address 0x%08x at index %d", iAddr, iNReq); +} + +void CbmDeviceUnpackTofCri::SetIgnoreOverlapMs(Bool_t bFlagIn) { fUnpackerAlgo->SetDoIgnoreOverlappMs(bFlagIn); } + +//void CbmDeviceUnpackTofCri::SetTimeOffsetNs(Double_t dOffsetIn) { fUnpackerAlgo->SetTimeOffsetNs(dOffsetIn); } +//void CbmDeviceUnpackTofCri::SetDiamondDpbIdx(UInt_t uIdx) { fUnpackerAlgo->SetDiamondDpbIdx(uIdx); } diff --git a/MQ/unpacker/CbmDeviceUnpackTofCri.h b/MQ/unpacker/CbmDeviceUnpackTofCri.h new file mode 100644 index 0000000000000000000000000000000000000000..1261beeb5d5f7a289ddbaad5e89691de0d30c233 --- /dev/null +++ b/MQ/unpacker/CbmDeviceUnpackTofCri.h @@ -0,0 +1,206 @@ +/* Copyright (C) 2018-2020 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Florian Uhlig, Norbert Herrmann [committer] */ + +/** + * CbmDeviceUnpackTofCri.h + * + * @since 2018-04-25 + * @author F. Uhlig + */ + +// TODO: (VF, 190914) Many unused private members were commented out. +// The class has to be revised. + +#ifndef CBMDEVICEUNPACKTOFCri_H_ +#define CBMDEVICEUNPACKTOFCri_H_ + +#include "CbmMcbm2018TofPar.h" + +#include "MicrosliceDescriptor.hpp" +#include "Timeslice.hpp" + +#include "FairMQDevice.h" + +#include "Rtypes.h" +#include "TMessage.h" + +#include <map> +#include <vector> + +#include "gDpbMessv100.h" + +class CbmTofUnpackAlgo; +class CbmMcbm2018TofPar; +class CbmTbDaqBuffer; +class CbmHistManager; +class CbmTofDigi; +class TH1; +class TH2; + +class CbmDeviceUnpackTofCri : public FairMQDevice { +public: + CbmDeviceUnpackTofCri(); + virtual ~CbmDeviceUnpackTofCri(); + +protected: + virtual void InitTask(); + bool HandleData(FairMQMessagePtr&, int); + bool HandleParts(FairMQParts&, int); + bool HandleMessage(FairMQMessagePtr&, int); + virtual void BuildTint(uint64_t ulTsStartTime, int iMode = 0); + virtual bool SendDigis(std::vector<CbmTofDigi*>, int); + +private: + uint64_t fNumMessages; + uint64_t fiSelectComponents; + uint64_t fNumTint; + std::vector<uint64_t> fEventHeader; + uint64_t fiReqMode; + uint64_t fiReqTint; + uint64_t fiReqBeam; + std::vector<Int_t> fiReqDigiAddr; + Int_t fiPulserMode; + uint64_t fiPulMulMin; + uint64_t fiPulTotMin; + uint64_t fiPulTotMax; + + std::vector<std::string> fAllowedChannels = {"tofcomponent", "parameters", "tofdigis", "syscmd"}; + std::vector<std::vector<std::string>> fChannelsToSend = {{}, {}, {}}; + + size_t fuTotalMsNb; /** Total nb of MS per link in timeslice **/ + size_t fuOverlapMsNb; /** Overlap Ms: all fuOverlapMsNb MS at the end of timeslice **/ + size_t fuCoreMs; /** Number of non overlap MS at beginning of TS **/ + Double_t fdMsSizeInNs; + Double_t fdTsCoreSizeInNs; + UInt_t fuMinNbGdpb; + UInt_t fuNrOfGdpbs; // Total number of GDPBs in the system + UInt_t fuNrOfFeePerGdpb; // Number of FEEs per GDPB + UInt_t fuNrOfGet4PerFee; // Number of GET4s per FEE + UInt_t fuNrOfChannelsPerGet4; // Number of channels in each GET4 + + UInt_t fuNrOfChannelsPerFee; // Number of channels in each FEET + UInt_t fuNrOfGet4; // Total number of Get4 chips in the system + UInt_t fuNrOfGet4PerGdpb; // Number of GET4s per GDPB + UInt_t fuNrOfChannelsPerGdpb; // Number of channels per GDPB + + const UInt_t kuNbFeePerGbtx = 5; + const UInt_t kuNbGbtxPerGdpb = 6; + + UInt_t fuGdpbId; // Id (hex number) of the GDPB for current message + UInt_t fuGdpbNr; // running number (0 to fNrOfGdpbs) of the GDPB for current message + UInt_t fuGet4Id; // running number (0 to fNrOfGet4PerGdpb) of the Get4 chip of a unique GDPB for current message + UInt_t fuGet4Nr; // running number (0 to fNrOfGet4) of the Get4 chip in the system for current message + + std::vector<int> fMsgCounter; + std::map<UInt_t, UInt_t> fGdpbIdIndexMap; + + // CbmHistManager* fHM; ///< Histogram manager + + /** Current epoch marker for each GDPB and GET4 + * (first epoch in the stream initializes the map item) + * pointer points to an array of size fNrOfGdpbs * fNrOfGet4PerGdpb + * The correct array index is calculated using the function + * GetArrayIndex(gdpbId, get4Id) + **/ + std::vector<ULong64_t> fvulCurrentEpoch; //! + std::vector<Bool_t> fvbFirstEpochSeen; //! + + Int_t fNofEpochs; /** Current epoch marker for each ROC **/ + ULong64_t fulCurrentEpochTime; /** Time stamp of current epoch **/ + + //Double_t fdMsIndex; + Double_t fdToffTof; + UInt_t fiAddrRef; + + //UInt_t fuDiamondDpbIdx; + //Bool_t fbEpochSuppModeOn; + //Bool_t fbGet4M24b; + //Bool_t fbGet4v20; + //Bool_t fbMergedEpochsOn; + + CbmMcbm2018TofPar* fUnpackPar; //! + + // Variables used for histo filling + Double_t fdLastDigiTime; + Double_t fdFirstDigiTimeDif; + //Double_t fdEvTime0; + TH1* fhRawTDigEvT0; + TH1* fhRawTDigRef0; + TH1* fhRawTDigRef; + TH1* fhRawTRefDig0; + TH1* fhRawTRefDig1; + TH1* fhRawDigiLastDigi; + std::vector<TH2*> fhRawTotCh; + std::vector<TH1*> fhChCount; + std::vector<Bool_t> fvbChanThere; + std::vector<TH2*> fhChanCoinc; + //Bool_t fbDetChanThere[64]; // FIXME + TH2* fhDetChanCoinc; + + inline Int_t GetArrayIndex(Int_t gdpbId, Int_t get4Id) { return gdpbId * fuNrOfGet4PerGdpb + get4Id; } + + ///* PADI channel to GET4 channel mapping and reverse */// + std::vector<UInt_t> fvuPadiToGet4; + std::vector<UInt_t> fvuGet4ToPadi; + + ///* GET4 to eLink mapping and reverse */// + static const UInt_t kuNbGet4PerGbtx = 5 * 8; /// 5 FEE with 8 GET4 each + std::vector<UInt_t> fvuElinkToGet4; + std::vector<UInt_t> fvuGet4ToElink; + inline UInt_t ConvertElinkToGet4(UInt_t uElinkIdx) + { + return fvuElinkToGet4[uElinkIdx % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uElinkIdx / kuNbGet4PerGbtx); + } + inline UInt_t ConvertGet4ToElink(UInt_t uGet4Idx) + { + return fvuGet4ToElink[uGet4Idx % kuNbGet4PerGbtx] + kuNbGet4PerGbtx * (uGet4Idx / kuNbGet4PerGbtx); + } + std::vector<Int_t> fviRpcType; + std::vector<Int_t> fviModuleId; + std::vector<Int_t> fviNrOfRpc; + std::vector<Int_t> fviRpcSide; + std::vector<Int_t> fviRpcChUId; + + CbmTbDaqBuffer* fBuffer; + + bool CheckTimeslice(const fles::Timeslice& ts); + void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); + bool IsChannelNameAllowed(std::string channelName); + + void SetParContainers(); + Bool_t InitContainers(); + Bool_t ReInitContainers(); + void CreateHistograms(); + void AddReqDigiAddr(int); + + Bool_t DoUnpack(const fles::Timeslice& ts, size_t component); + + /// Temp until we change from CbmMcbmUnpack to something else + void AddMsComponentToList(size_t component, UShort_t usDetectorId); + void SetNbMsInTs(size_t /*uCoreMsNb*/, size_t /*uOverlapMsNb*/) {}; + + /// Algo settings setters + void SetIgnoreOverlapMs(Bool_t bFlagIn = kTRUE); + void SetTimeOffsetNs(Double_t dOffsetIn = 0.0); + void SetDiamondDpbIdx(UInt_t uIdx = 2); + + /// Processing algo + std::shared_ptr<CbmTofUnpackAlgo> fUnpackerAlgo; + /// Control flags + // Bool_t fbMonitorMode; //! Switch ON the filling of a minimal set of histograms + // Bool_t fbDebugMonitorMode; //! Switch ON the filling of a additional set of histograms + // Bool_t fbSeparateArrayT0; //! If ON, T0 digis are saved in separate TClonesArray + // Bool_t fbWriteOutput; //! If ON the output TClonesArray of digi is written to disk + + CbmDeviceUnpackTofCri(const CbmDeviceUnpackTofCri&) = delete; + CbmDeviceUnpackTofCri operator=(const CbmDeviceUnpackTofCri&) = delete; +}; + +// special class to expose protected TMessage constructor +class CbmMQTMessage : public TMessage { +public: + CbmMQTMessage(void* buf, Int_t len) : TMessage(buf, len) { ResetBit(kIsOwner); } +}; + +#endif /* CBMDEVICEUNPACKTOFCri_H_ */ diff --git a/MQ/unpacker/runUnpackTofCri.cxx b/MQ/unpacker/runUnpackTofCri.cxx new file mode 100644 index 0000000000000000000000000000000000000000..981b160e77e7cac348aaa928214e12a9a1c3cb1c --- /dev/null +++ b/MQ/unpacker/runUnpackTofCri.cxx @@ -0,0 +1,39 @@ +/* Copyright (C) 2018-2020 PI-UHd, GSI + SPDX-License-Identifier: GPL-3.0-only + Authors: Norbert Herrmann [committer] */ + +#include "CbmDeviceUnpackTofCri.h" + +#include <iomanip> +#include <string> + +#include "runFairMQDevice.h" + +namespace bpo = boost::program_options; +using namespace std; + +void addCustomOptions(bpo::options_description& options) +{ + options.add_options()("ReqMode", bpo::value<uint64_t>()->default_value(0), "Time intervall selector"); + options.add_options()("SelectComponents", bpo::value<uint64_t>()->default_value(1), + "Select components for transport"); + options.add_options()("ReqTint", bpo::value<uint64_t>()->default_value(100), "Time intervall length in ns"); + options.add_options()("ReqBeam", bpo::value<uint64_t>()->default_value(-1), "Mandatory beam counter in event"); + options.add_options()("PulserMode", bpo::value<int64_t>()->default_value(0), "Choose pulser configuration"); + options.add_options()("PulMulMin", bpo::value<uint64_t>()->default_value(0), "Min number of pulsed detectors"); + options.add_options()("PulTotMin", bpo::value<uint64_t>()->default_value(0), "Min pulser TimeOverThreshold"); + options.add_options()("PulTotMax", bpo::value<uint64_t>()->default_value(1000), "Max pulser TimeOverThreshold"); + options.add_options()("ToffTof", bpo::value<double_t>()->default_value(0.), + "Time offset of Tof digis with respect to T0"); + options.add_options()("RefModType", bpo::value<int64_t>()->default_value(5), "Module type of reference counter"); + options.add_options()("RefModId", bpo::value<int64_t>()->default_value(0), "Module Id of reference counter"); + options.add_options()("RefCtrType", bpo::value<int64_t>()->default_value(4), "Counter type of reference counter"); + options.add_options()("RefCtrId", bpo::value<int64_t>()->default_value(0), "Counter Id of reference counter"); + options.add_options()("MaxAsicInactive", bpo::value<uint64_t>()->default_value(0), "Max number of disabled ASICs"); + + int iNDet = 36; + for (int i = 0; i < iNDet; i++) + options.add_options()(Form("ReqDet%d", i), bpo::value<uint64_t>()->default_value(0), Form("ReqDet%d", i)); +} + +FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceUnpackTofCri(); }