diff --git a/MQ/base/CbmMQChannels.cxx b/MQ/base/CbmMQChannels.cxx index 369285446618695112d2fb79d87715aa381b90cf..68b1f2f33ff9e5c9b9548e28e3c19219ae2902b3 100644 --- a/MQ/base/CbmMQChannels.cxx +++ b/MQ/base/CbmMQChannels.cxx @@ -6,7 +6,7 @@ #include "FairMQDevice.h" -CbmMQChannels::CbmMQChannels(std::vector<std::string> allowedChannels) : fAllowedChannels {allowedChannels} +CbmMQChannels::CbmMQChannels(std::vector<std::string> allowedChannels) : fAllowedChannels{allowedChannels} { fChannelsToSend.resize(fAllowedChannels.size()); for (auto& entry : fChannelsToSend) { @@ -46,7 +46,7 @@ bool CbmMQChannels::IsChannelNameAllowed(std::string channelName) return false; } -bool CbmMQChannels::CheckChannels(FairMQDevice* device) +bool CbmMQChannels::CheckChannels(fair::mq::Device* device) { // Get the information about created channels from the device // Check if the defined channels from the topology (by name) @@ -56,9 +56,9 @@ bool CbmMQChannels::CheckChannels(FairMQDevice* device) // 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. - int noChannel = device->fChannels.size(); + int noChannel = device->GetChannels().size(); LOG(info) << "Number of defined output channels: " << noChannel; - for (auto const& entry : device->fChannels) { + for (auto const& entry : device->GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) return false; } diff --git a/MQ/base/CbmMQChannels.h b/MQ/base/CbmMQChannels.h index 18358e31aeec7e32de09c542364928880fa70ed2..77ec51d25afbafb7677c6c23abcf027ca8d4e80a 100644 --- a/MQ/base/CbmMQChannels.h +++ b/MQ/base/CbmMQChannels.h @@ -12,19 +12,19 @@ class CbmMQChannels { -public: + public: CbmMQChannels(std::vector<std::string>); bool IsChannelNameAllowed(std::string channelName); - bool CheckChannels(FairMQDevice* device); + bool CheckChannels(fair::mq::Device* device); std::vector<int> GetComponentsToSend() { return fComponentsToSend; } std::vector<std::vector<std::string>> GetChannelsToSend() { return fChannelsToSend; } -private: - std::vector<std::string> fAllowedChannels {}; - std::vector<int> fComponentsToSend {}; - std::vector<std::vector<std::string>> fChannelsToSend {{}}; + private: + std::vector<std::string> fAllowedChannels{}; + std::vector<int> fComponentsToSend{}; + std::vector<std::vector<std::string>> fChannelsToSend{{}}; }; #endif diff --git a/MQ/base/CbmMQDefs.h b/MQ/base/CbmMQDefs.h index 03c43516837d2967662d4d934255db9ed130e87c..6c6718f6013b43c61bfbd2374bb6db78372cc25d 100644 --- a/MQ/base/CbmMQDefs.h +++ b/MQ/base/CbmMQDefs.h @@ -23,38 +23,46 @@ namespace cbm Running }; - void ChangeState(FairMQDevice* device, cbm::mq::Transition transition) + void ChangeState(fair::mq::Device* device, cbm::mq::Transition transition) { - if (transition == cbm::mq::Transition::ErrorFound) { device->ChangeState(fair::mq::Transition::ErrorFound); } + bool success; + if (transition == cbm::mq::Transition::ErrorFound) { + success = device->ChangeState(fair::mq::Transition::ErrorFound); + } else if (transition == cbm::mq::Transition::End) { - device->ChangeState(fair::mq::Transition::End); + success = device->ChangeState(fair::mq::Transition::End); } else if (transition == cbm::mq::Transition::Ready) { - device->ChangeState(fair::mq::Transition::ResetTask); + success = device->ChangeState(fair::mq::Transition::ResetTask); } else if (transition == cbm::mq::Transition::DeviceReady) { - device->ChangeState(fair::mq::Transition::ResetDevice); + success = device->ChangeState(fair::mq::Transition::ResetDevice); } else if (transition == cbm::mq::Transition::Idle) { - device->ChangeState(fair::mq::Transition::Stop); + success = device->ChangeState(fair::mq::Transition::Stop); } else { LOG(fatal) << "State Change not yet implemented"; - device->ChangeState(fair::mq::Transition::ErrorFound); + success = device->ChangeState(fair::mq::Transition::ErrorFound); + } + if (!success) { + LOG(warn) << "The transition wasnt successful"; } } - void LogState(FairMQDevice* device) - { - LOG(info) << "Current State: " << device->GetCurrentStateName(); - } + void LogState(fair::mq::Device* device) { LOG(info) << "Current State: " << device->GetCurrentStateName(); } - bool CheckCurrentState(FairMQDevice* device, cbm::mq::State state) + bool CheckCurrentState(fair::mq::Device* device, cbm::mq::State state) { - if (state == cbm::mq::State::Running) { return !(device->NewStatePending()); } + if (state == cbm::mq::State::Running) { + return !(device->NewStatePending()); + } else { LOG(fatal) << "State not yet implemented"; - device->ChangeState(fair::mq::Transition::ErrorFound); + bool success = device->ChangeState(fair::mq::Transition::ErrorFound); + if (!success) { + LOG(warn) << "The transition wasnt successful"; + } return 0; } } diff --git a/MQ/histoServer/CbmHistoServer.cxx b/MQ/histoServer/CbmHistoServer.cxx index dd083d290518b07df4db917ef0a379d8434f01f2..a03b5b434dab4215fcddde201db478f60b51e202 100644 --- a/MQ/histoServer/CbmHistoServer.cxx +++ b/MQ/histoServer/CbmHistoServer.cxx @@ -6,14 +6,13 @@ #include <mutex> //#include "CbmHistoCanvasDrawer.h" -#include <Logger.h> - +#include "RootSerializer.h" #include "TH1.h" #include "THttpServer.h" #include "TMessage.h" #include "TObjArray.h" -#include "RootSerializer.h" +#include <Logger.h> std::mutex mtx; @@ -42,7 +41,7 @@ void CbmHistoServer::InitTask() */ } -bool CbmHistoServer::ReceiveData(FairMQMessagePtr& msg, int /*index*/) +bool CbmHistoServer::ReceiveData(fair::mq::MessagePtr& msg, int /*index*/) { TObject* tempObject = nullptr; RootSerializer().Deserialize(*msg, tempObject); @@ -110,7 +109,9 @@ int CbmHistoServer::FindHistogram(const std::string& name) { for (int i = 0; i < fArrayHisto.GetEntriesFast(); i++) { TObject* obj = fArrayHisto.At(i); - if (TString(obj->GetName()).EqualTo(name)) { return i; } + if (TString(obj->GetName()).EqualTo(name)) { + return i; + } } return -1; } diff --git a/MQ/histoServer/CbmHistoServer.h b/MQ/histoServer/CbmHistoServer.h index ac3c7fa99ce22ddbbea0a5dd54ea4d565ff599e6..3b5c0a16a02f2cfe30d4bf5c8a04e94c8f5ea338 100644 --- a/MQ/histoServer/CbmHistoServer.h +++ b/MQ/histoServer/CbmHistoServer.h @@ -6,18 +6,17 @@ #define FAIRMQEXHISTOSERVER #include "FairMQDevice.h" - #include "THttpServer.h" #include "TObjArray.h" -#include <thread> #include <memory> #include <string> +#include <thread> //class FairMQExHistoCanvasDrawer; -class CbmHistoServer : public FairMQDevice { -public: +class CbmHistoServer : public fair::mq::Device { + public: CbmHistoServer(); @@ -32,16 +31,16 @@ public: } */ -protected: + protected: virtual void InitTask(); - bool ReceiveData(FairMQMessagePtr& msg, int index); + bool ReceiveData(fair::mq::MessagePtr& msg, int index); virtual void PreRun(); virtual void PostRun(); -private: + private: std::string fInputChannelName; TObjArray fArrayHisto; diff --git a/MQ/histoServer/CbmMqHistoServer.cxx b/MQ/histoServer/CbmMqHistoServer.cxx index 21009b9f8963e22ffbfa8b90346b6a8a897e23ff..87b5ff9053de4716f4fc83caece471f9450471ee 100644 --- a/MQ/histoServer/CbmMqHistoServer.cxx +++ b/MQ/histoServer/CbmMqHistoServer.cxx @@ -4,11 +4,10 @@ #include "CbmMqHistoServer.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" - #include "FairMQProgOptions.h" // device->fConfig -#include <Logger.h> - +#include "RootSerializer.h" #include "TCanvas.h" #include "TEnv.h" #include "TFile.h" @@ -21,23 +20,18 @@ #include "TRootSniffer.h" #include "TSystem.h" -#include "BoostSerializer.h" +#include <Logger.h> + #include <boost/serialization/utility.hpp> #include <mutex> -#include "RootSerializer.h" - std::mutex mtx; /* Bool_t bMqHistoServerResetHistos = kFALSE; Bool_t bMqHistoServerSaveHistos = kFALSE; */ -CbmMqHistoServer::CbmMqHistoServer() - : FairMQDevice() - , fArrayHisto() -{ -} +CbmMqHistoServer::CbmMqHistoServer() : FairMQDevice(), fArrayHisto() {} CbmMqHistoServer::~CbmMqHistoServer() {} @@ -73,7 +67,7 @@ void CbmMqHistoServer::InitTask() //fServer->Restrict("/Save_Hist", "allow=admin"); } -bool CbmMqHistoServer::ReceiveData(FairMQMessagePtr& msg, int /*index*/) +bool CbmMqHistoServer::ReceiveData(fair::mq::MessagePtr& msg, int /*index*/) { LOG(debug) << "CbmMqHistoServer::ReceiveData => Processing histograms update"; TObject* tempObject = nullptr; @@ -145,7 +139,7 @@ bool CbmMqHistoServer::ReceiveData(FairMQMessagePtr& msg, int /*index*/) return true; } -bool CbmMqHistoServer::ReceiveHistoConfig(FairMQMessagePtr& msg, int /*index*/) +bool CbmMqHistoServer::ReceiveHistoConfig(fair::mq::MessagePtr& msg, int /*index*/) { std::pair<std::string, std::string> tempObject; @@ -177,7 +171,7 @@ bool CbmMqHistoServer::ReceiveHistoConfig(FairMQMessagePtr& msg, int /*index*/) return true; } -bool CbmMqHistoServer::ReceiveCanvasConfig(FairMQMessagePtr& msg, int /*index*/) +bool CbmMqHistoServer::ReceiveCanvasConfig(fair::mq::MessagePtr& msg, int /*index*/) { std::pair<std::string, std::string> tempObject; @@ -210,14 +204,14 @@ bool CbmMqHistoServer::ReceiveCanvasConfig(FairMQMessagePtr& msg, int /*index*/) return true; } -bool CbmMqHistoServer::ReceiveConfigAndData(FairMQParts& parts, int /*index*/) +bool CbmMqHistoServer::ReceiveConfigAndData(fair::mq::Parts& parts, int /*index*/) { /// Reject anything but a at least Header + Histo Config + Canvas Config + Histo Data if (parts.Size() < 4) { if (1 == parts.Size()) { /// PAL, 09/04/2021, Debug message catching missed method overload/polymorphism: - /// contrary to my expectation, if 2 method bound to same channel, one with FairMQMessagePtr and one with - /// FairMQParts, all messages go to multipart version and FairMQMessagePtr is converted to size 1 FairMQParts + /// contrary to my expectation, if 2 method bound to same channel, one with fair::mq::MessagePtr and one with + /// fair::mq::Parts, all messages go to multipart version and fair::mq::MessagePtr is converted to size 1 fair::mq::Parts LOG(debug) << "CbmMqHistoServer::ReceiveConfigAndData => only 1 parts found in input, " << "assuming data only message routed to wrong method!"; return ReceiveData(parts.At(0), 0); @@ -359,8 +353,10 @@ int CbmMqHistoServer::FindHistogram(const std::string& name) { for (int iHist = 0; iHist < fArrayHisto.GetEntriesFast(); ++iHist) { TObject* obj = fArrayHisto.At(iHist); - if (TString(obj->GetName()).EqualTo(name)) { return iHist; } // if( TString( obj->GetName() ).EqualTo( name ) ) - } // for( int iHist = 0; iHist < fArrayHisto.GetEntriesFast(); ++iHist ) + if (TString(obj->GetName()).EqualTo(name)) { + return iHist; + } // if( TString( obj->GetName() ).EqualTo( name ) ) + } // for( int iHist = 0; iHist < fArrayHisto.GetEntriesFast(); ++iHist ) return -1; } diff --git a/MQ/histoServer/CbmMqHistoServer.h b/MQ/histoServer/CbmMqHistoServer.h index 5cbd8cdf0876564f7dbeae08b29bcdfe86a54af5..729dc9f2a84693478a5775356328d7471f53d882 100644 --- a/MQ/histoServer/CbmMqHistoServer.h +++ b/MQ/histoServer/CbmMqHistoServer.h @@ -6,41 +6,40 @@ #define CBMMQHISTOSERVER_H #include "FairMQDevice.h" - #include "THttpServer.h" #include "TObjArray.h" -#include <thread> #include <memory> #include <string> +#include <thread> class TNamed; class TCanvas; -class CbmMqHistoServer : public FairMQDevice { -public: +class CbmMqHistoServer : public fair::mq::Device { + public: CbmMqHistoServer(); virtual ~CbmMqHistoServer(); void UpdateHttpServer(); -protected: + protected: virtual void InitTask(); - bool ReceiveData(FairMQMessagePtr& msg, int index); + bool ReceiveData(fair::mq::MessagePtr& msg, int index); - bool ReceiveHistoConfig(FairMQMessagePtr& msg, int index); + bool ReceiveHistoConfig(fair::mq::MessagePtr& msg, int index); - bool ReceiveCanvasConfig(FairMQMessagePtr& msg, int index); + bool ReceiveCanvasConfig(fair::mq::MessagePtr& msg, int index); - bool ReceiveConfigAndData(FairMQParts& msg, int index); + bool ReceiveConfigAndData(fair::mq::Parts& msg, int index); virtual void PreRun(); virtual void PostRun(); -private: + private: /// Parameters std::string fsChannelNameHistosInput = "histogram-in"; std::string fsChannelNameHistosConfig = "histo-conf"; diff --git a/MQ/histoServer/runCbmHistoServer.cxx b/MQ/histoServer/runCbmHistoServer.cxx index 6beb33723fde0c2793dad163a04c066c6a3c1eb7..246276e8589ccd9d2615c2e612862ecc1bdaa480 100644 --- a/MQ/histoServer/runCbmHistoServer.cxx +++ b/MQ/histoServer/runCbmHistoServer.cxx @@ -3,18 +3,17 @@ Authors: Florian Uhlig [committer] */ #include "CbmHistoServer.h" +#include "runFairMQDevice.h" #include <memory> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; void addCustomOptions(bpo::options_description& /*options*/) {} //std::unique_ptr<FairMQExHistoCanvasDrawer> getCanvasDrawer(); -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { CbmHistoServer* histoServer = new CbmHistoServer(); diff --git a/MQ/histoServer/runCbmMqHistoServer.cxx b/MQ/histoServer/runCbmMqHistoServer.cxx index 3836861741f3e94355b0410f4f64d6fc38d1feb6..640bab7e6446dce521631f2a32bae54bc18547ac 100644 --- a/MQ/histoServer/runCbmMqHistoServer.cxx +++ b/MQ/histoServer/runCbmMqHistoServer.cxx @@ -23,7 +23,7 @@ void addCustomOptions(bpo::options_description& options) options.add_options()("histport", bpo::value<uint32_t>()->default_value(8080), "port for histos http server"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { CbmMqHistoServer* histoServer = new CbmMqHistoServer(); diff --git a/MQ/hitbuilder/CbmDeviceHitBuilderTof.cxx b/MQ/hitbuilder/CbmDeviceHitBuilderTof.cxx index b7f333053fa41bee0fa84bb9d95c7fa51f56f581..22aaf904f9e9b845269fbd08152dc45dc1a2d5e6 100644 --- a/MQ/hitbuilder/CbmDeviceHitBuilderTof.cxx +++ b/MQ/hitbuilder/CbmDeviceHitBuilderTof.cxx @@ -29,7 +29,6 @@ #include "CbmTofGeoHandler.h" // in tof/TofTools #include "CbmTofHit.h" // in cbmdata/tof #include "CbmTofPoint.h" // in cbmdata/tof - #include "FairEventHeader.h" #include "FairFileHeader.h" #include "FairGeoParSet.h" @@ -255,12 +254,13 @@ try { // 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. - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined input channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); - if (entry.first != "syscmd") OnData(entry.first, &CbmDeviceHitBuilderTof::HandleData); + if (entry.first != "syscmd") + OnData(entry.first, &CbmDeviceHitBuilderTof::HandleData); else OnData(entry.first, &CbmDeviceHitBuilderTof::HandleMessage); } @@ -372,7 +372,9 @@ Bool_t CbmDeviceHitBuilderTof::InitRootOutput() fEvtHeader->SetRunId(iRunId); rootMgr->Register("EventHeader.", "Event", fEvtHeader, kTRUE); auto source = rootMgr->GetSource(); - if (source) { source->FillEventHeader(fEvtHeader); } + if (source) { + source->FillEventHeader(fEvtHeader); + } // rootMgr->Register("CbmTofDigi", "Tof raw Digi", fTofCalDigisColl, kTRUE); // fOutRootFile->cd(); @@ -430,9 +432,9 @@ Bool_t CbmDeviceHitBuilderTof::InitContainers() std::string message = parSet[iSet] + "," + to_string(fiRunId); LOG(info) << "Requesting parameter container, sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - //FairMQMessagePtr req(NewSimpleMessage( "CbmTofDigiBdfPar,111" )); //original format - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + //fair::mq::MessagePtr req(NewSimpleMessage( "CbmTofDigiBdfPar,111" )); //original format + fair::mq::MessagePtr rep(NewMessage()); CbmTofCreateDigiPar* tofDigiPar = NULL; if (Send(req, Channel) > 0) { @@ -540,8 +542,8 @@ Bool_t CbmDeviceHitBuilderTof::ReInitContainers() } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -//bool CbmDeviceHitBuilderTof::HandleData(FairMQMessagePtr& msg, int /*index*/) -bool CbmDeviceHitBuilderTof::HandleData(FairMQParts& parts, int /*index*/) +//bool CbmDeviceHitBuilderTof::HandleData(fair::mq::MessagePtr& msg, int /*index*/) +bool CbmDeviceHitBuilderTof::HandleData(fair::mq::Parts& parts, int /*index*/) { // Don't do anything with the data // Maybe add an message counter which counts the incomming messages and add @@ -697,7 +699,9 @@ bool CbmDeviceHitBuilderTof::HandleData(FairMQParts& parts, int /*index*/) if (NULL != fOutRootFile) { // CbmEvent output to root file fEvtHeader->SetEventTime((double) fEventHeader[4]); auto source = rootMgr->GetSource(); - if (source) { source->FillEventHeader(fEvtHeader); } + if (source) { + source->FillEventHeader(fEvtHeader); + } //LOG(info) << "Fill WriteOutBuffer with rootMgr at " << rootMgr; fOutRootFile->cd(); rootMgr->Fill(); @@ -722,7 +726,7 @@ bool CbmDeviceHitBuilderTof::HandleData(FairMQParts& parts, int /*index*/) /************************************************************************************/ -bool CbmDeviceHitBuilderTof::HandleMessage(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceHitBuilderTof::HandleMessage(fair::mq::MessagePtr& msg, int /*index*/) { const char* cmd = (char*) (msg->GetData()); const char cmda[4] = {*cmd}; @@ -904,7 +908,9 @@ Bool_t CbmDeviceHitBuilderTof::InitCalibParameter() for (Int_t iSide = 0; iSide < 2; iSide++) { Double_t TotMean = htempTot_Mean->GetBinContent(iCh * 2 + 1 + iSide); //nh +1 empirical(?) - if (0.001 < TotMean) { fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *= fdTTotMean / TotMean; } + if (0.001 < TotMean) { + fvCPTotGain[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] *= fdTTotMean / TotMean; + } fvCPTotOff[iSmType][iSm * iNbRpc + iRpc][iCh][iSide] = htempTot_Off->GetBinContent(iCh * 2 + 1 + iSide); } @@ -1079,7 +1085,9 @@ void CbmDeviceHitBuilderTof::CreateHistograms() // Retrieve geometry information from the first module of a certain // module type that is found in the geometry file. - if (NULL != fChannelInfo) { break; } + if (NULL != fChannelInfo) { + break; + } } if (NULL == fChannelInfo) { @@ -1529,7 +1537,8 @@ Bool_t CbmDeviceHitBuilderTof::InspectRawDigis() if (fiBeamRefAddr < 0 || iAddr == fiBeamRefAddr) { //LOG(debug) << Form("Ref digi found for 0x%08x, Mask 0x%08x ", fiBeamRefAddr, DetMask); - if (NULL == pRef) pRef = pDigi; + if (NULL == pRef) + pRef = pDigi; else { if (pDigi->GetTime() < pRef->GetTime()) pRef = pDigi; } @@ -1554,7 +1563,9 @@ 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 != 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(), @@ -2058,11 +2069,13 @@ Bool_t CbmDeviceHitBuilderTof::BuildHits() CbmTofDigi* xDigiC = fStorDigi[iSmType][iSm * iNbRpc + iRpc][iCh][2]; Double_t dPosYN = 0.; Double_t dTimeDifN = 0; - if (xDigiC->GetSide() == xDigiA->GetSide()) dTimeDifN = xDigiC->GetTime() - xDigiB->GetTime(); + if (xDigiC->GetSide() == xDigiA->GetSide()) + dTimeDifN = xDigiC->GetTime() - xDigiB->GetTime(); else dTimeDifN = xDigiA->GetTime() - xDigiC->GetTime(); - if (1 == xDigiA->GetSide()) dPosYN = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * dTimeDifN * 0.5; + if (1 == xDigiA->GetSide()) + dPosYN = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * dTimeDifN * 0.5; else dPosYN = -fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * dTimeDifN * 0.5; @@ -2240,7 +2253,9 @@ Bool_t CbmDeviceHitBuilderTof::BuildHits() // output hit new ((*fTofHitsColl)[fiNbHits]) CbmTofHit(*pHit); // memorize hit - if (fdMemoryTime > 0.) { LH_store(iSmType, iSm, iRpc, iChm, pHit); } + if (fdMemoryTime > 0.) { + LH_store(iSmType, iSm, iRpc, iChm, pHit); + } else { pHit->Delete(); } @@ -2431,7 +2446,9 @@ Bool_t CbmDeviceHitBuilderTof::BuildHits() // output hit new ((*fTofHitsColl)[fiNbHits]) CbmTofHit(*pHit); // memorize hit - if (fdMemoryTime > 0.) { LH_store(iSmType, iSm, iRpc, iChm, pHit); } + if (fdMemoryTime > 0.) { + LH_store(iSmType, iSm, iRpc, iChm, pHit); + } else { pHit->Delete(); } @@ -2473,7 +2490,8 @@ Bool_t CbmDeviceHitBuilderTof::MergeClusters() { return kTRUE; } void CbmDeviceHitBuilderTof::LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit* pHit) { - if (fvLastHits[iSmType][iSm][iRpc][iChm].size() == 0) fvLastHits[iSmType][iSm][iRpc][iChm].push_back(pHit); + if (fvLastHits[iSmType][iSm][iRpc][iChm].size() == 0) + fvLastHits[iSmType][iSm][iRpc][iChm].push_back(pHit); else { Double_t dLastTime = pHit->GetTime(); if (dLastTime >= fvLastHits[iSmType][iSm][iRpc][iChm].back()->GetTime()) { @@ -2627,7 +2645,8 @@ Bool_t CbmDeviceHitBuilderTof::AddNextChan(Int_t iSmType, Int_t iSm, Int_t iRpc, Double_t dTimeDif = xDigiA->GetTime() - xDigiB->GetTime(); Double_t dPosY = 0.; - if (1 == xDigiA->GetSide()) dPosY = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * dTimeDif * 0.5; + if (1 == xDigiA->GetSide()) + dPosY = fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * dTimeDif * 0.5; else dPosY = -fDigiBdfPar->GetSigVel(iSmType, iSm, iRpc) * dTimeDif * 0.5; @@ -2752,7 +2771,9 @@ void CbmDeviceHitBuilderTof::fit_ybox(const char* hname) { TH1* h1; h1 = (TH1*) gROOT->FindObjectAny(hname); - if (NULL != h1) { fit_ybox(h1, 0.); } + if (NULL != h1) { + fit_ybox(h1, 0.); + } } void CbmDeviceHitBuilderTof::fit_ybox(TH1* h1, Double_t ysize) @@ -3027,7 +3048,7 @@ Bool_t CbmDeviceHitBuilderTof::SendHits() oa << vhit; std::string* strMsg = new std::string(oss.str()); - FairMQParts parts; + fair::mq::Parts parts; parts.AddPart(NewMessage( const_cast<char*>(strMsgE->c_str()), // data strMsgE->length(), // size @@ -3200,7 +3221,9 @@ Bool_t CbmDeviceHitBuilderTof::FillHistos() if (TotSum > fhRpcCluTot[iIndexDut]->GetYaxis()->GetXmax()) continue; // ignore too large clusters fTRefHits = 1; - if (pHit->GetTime() < dTRef) { dTRef = pHit->GetTime(); } + if (pHit->GetTime() < dTRef) { + dTRef = pHit->GetTime(); + } iBeamRefMul++; } else { //additional reference type multiplicity @@ -3291,7 +3314,9 @@ Bool_t CbmDeviceHitBuilderTof::FillHistos() default: LOG(info) << "FillHistos: selection not implemented " << iSel; ; } // switch end - if (fTRefMode > 10) { dTTrig[iSel] = dTRef; } + if (fTRefMode > 10) { + dTTrig[iSel] = dTRef; + } } // iSel - loop end if (fSel2Id > 0) { // confirm selector by independent match @@ -3338,7 +3363,9 @@ Bool_t CbmDeviceHitBuilderTof::FillHistos() if (BSel[iSel]) { if (dTRef != 0. && fTRefHits > 0) { for (UInt_t uChannel = 0; uChannel < 16; uChannel++) { - if (uTriggerPattern & (0x1 << uChannel)) { fhSeldT[iSel]->Fill(dTTrig[iSel] - dTRef, uChannel); } + if (uTriggerPattern & (0x1 << uChannel)) { + fhSeldT[iSel]->Fill(dTTrig[iSel] - dTRef, uChannel); + } } } } @@ -3362,7 +3389,8 @@ Bool_t CbmDeviceHitBuilderTof::FillHistos() for (Int_t iSel = 0; iSel < iNSel; iSel++) if (BSel[iSel]) { Double_t w = fviClusterMul[iSmType][iSm][iRpc]; - if (w == 0.) w = 1.; + if (w == 0.) + w = 1.; else w = 1. / w; fhTRpcCluMul[iDetIndx][iSel]->Fill(fviClusterMul[iSmType][iSm][iRpc], w); diff --git a/MQ/hitbuilder/CbmDeviceHitBuilderTof.h b/MQ/hitbuilder/CbmDeviceHitBuilderTof.h index 84b59dc31cc5a2ab810ec2083d301a8c78d87785..92bc6ebf14c982d9373999a1c3f8bcdfd0c60c8f 100644 --- a/MQ/hitbuilder/CbmDeviceHitBuilderTof.h +++ b/MQ/hitbuilder/CbmDeviceHitBuilderTof.h @@ -15,18 +15,15 @@ #include "CbmMqTMessage.h" #include "CbmTofAddress.h" // in cbmdata/tof #include "CbmTofGeoHandler.h" // in tof/TofTools - -#include "MicrosliceDescriptor.hpp" -#include "Timeslice.hpp" - #include "FairEventHeader.h" #include "FairMQDevice.h" - +#include "MicrosliceDescriptor.hpp" #include "Rtypes.h" #include "TFile.h" #include "TGeoManager.h" #include "TMessage.h" #include "TTree.h" +#include "Timeslice.hpp" #include <map> #include <vector> @@ -58,16 +55,16 @@ class TString; #include <map> #include <vector> -class CbmDeviceHitBuilderTof : public FairMQDevice { -public: +class CbmDeviceHitBuilderTof : public fair::mq::Device { + public: CbmDeviceHitBuilderTof(); virtual ~CbmDeviceHitBuilderTof(); -protected: + protected: virtual void InitTask(); - //bool HandleData(FairMQMessagePtr&, int); - bool HandleData(FairMQParts&, int); - bool HandleMessage(FairMQMessagePtr&, int); + //bool HandleData(fair::mq::MessagePtr&, int); + bool HandleData(fair::mq::Parts&, int); + bool HandleMessage(fair::mq::MessagePtr&, int); virtual void fit_ybox(const char* hname); // Fit virtual void fit_ybox(TH1* h, Double_t dy); // Fit @@ -79,7 +76,7 @@ protected: Double_t dLastTot); // needed for time based data virtual void LH_store(Int_t iSmType, Int_t iSm, Int_t iRpc, Int_t iChm, CbmTofHit* pHit); -private: + private: // Variables used for histo filling Bool_t IsChannelNameAllowed(std::string channelName); diff --git a/MQ/hitbuilder/runHitBuilderTof.cxx b/MQ/hitbuilder/runHitBuilderTof.cxx index d59e7f940174f7ec7e92d29bc34c0601e7312f50..edfe7c8329ae597f36a2b7ae2c2b9f6b13c8e29e 100644 --- a/MQ/hitbuilder/runHitBuilderTof.cxx +++ b/MQ/hitbuilder/runHitBuilderTof.cxx @@ -56,4 +56,4 @@ void addCustomOptions(bpo::options_description& options) options.add_options()("OutParFile", bpo::value<std::string>()->default_value(""), "parameter histogram file name"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceHitBuilderTof(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceHitBuilderTof(); } diff --git a/MQ/mcbm/CbmDeviceBmonMonitor.cxx b/MQ/mcbm/CbmDeviceBmonMonitor.cxx index 4a335b9fd0c479eb694d2c96cfc7e53be163b7bb..bc7f0406da34fe5898433b1d53dadb65eb194fe4 100644 --- a/MQ/mcbm/CbmDeviceBmonMonitor.cxx +++ b/MQ/mcbm/CbmDeviceBmonMonitor.cxx @@ -11,6 +11,7 @@ #include "CbmDeviceBmonMonitor.h" +#include "BoostSerializer.h" #include "CbmBmonUnpackConfig.h" #include "CbmFlesCanvasTools.h" #include "CbmMQDefs.h" @@ -23,21 +24,18 @@ #include "CbmTofUnpackMonitor.h" #include "CbmTrdUnpackConfig.h" #include "CbmTrdUnpackFaspConfig.h" - -#include "StorableTimeslice.hpp" -#include "TimesliceMetaData.h" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" +#include "TimesliceMetaData.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -46,8 +44,6 @@ #include <stdexcept> #include <string> #include <utility> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -92,8 +88,8 @@ Bool_t CbmDeviceBmonMonitor::InitContainers() // ----- CbmSetup ----------------------------------------------------- // TODO: support for multiple setups on Par Server? with request containing setup name? CbmSetup* cbmsetup = CbmSetup::Instance(); - FairMQMessagePtr req(NewSimpleMessage("setup")); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage("setup")); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, "parameters") > 0) { if (Receive(rep, "parameters") >= 0) { @@ -214,7 +210,7 @@ CbmDeviceBmonMonitor::InitParameters(std::vector<std::pair<std::string, std::sha if (asciiInput.open(filepath.data())) { parset->init(&asciiInput); } } * */ - std::string paramName {pair.second->GetName()}; + std::string paramName{pair.second->GetName()}; // 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 @@ -222,8 +218,8 @@ CbmDeviceBmonMonitor::InitParameters(std::vector<std::pair<std::string, std::sha std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -316,8 +312,8 @@ bool CbmDeviceBmonMonitor::ConditionalRun() /// Request the start time std::string message = "SendFirstTimesliceIndex"; LOG(debug) << "Requesting start time by sending message: SendFirstTimesliceIndex" << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, fsChannelNameDataInput) <= 0) { LOG(error) << "Failed to send the request! message was " << message; @@ -344,8 +340,8 @@ bool CbmDeviceBmonMonitor::ConditionalRun() /// First request a new TS (full one) std::string message = "full"; LOG(debug) << "Requesting new TS by sending message: full" << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, fsChannelNameDataInput) <= 0) { LOG(error) << "Failed to send the request! message was " << message; @@ -370,7 +366,7 @@ bool CbmDeviceBmonMonitor::ConditionalRun() boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice ts {0}; + fles::StorableTimeslice ts{0}; inputArchive >> ts; /// On first TS, extract the TS parameters from header (by definition stable over time) @@ -424,10 +420,10 @@ bool CbmDeviceBmonMonitor::ConditionalRun() bool CbmDeviceBmonMonitor::SendUnpData() { - FairMQParts parts; + fair::mq::Parts parts; /// Prepare serialized versions of the TS Event header - FairMQMessagePtr messTsHeader(NewMessage()); + fair::mq::MessagePtr messTsHeader(NewMessage()); // Serialize<RootSerializer>(*messTsHeader, fCbmTsEventHeader); RootSerializer().Serialize(*messTsHeader, fCbmTsEventHeader); @@ -453,7 +449,7 @@ bool CbmDeviceBmonMonitor::SendUnpData() /// Prepare serialized versions of the TS Meta /// FIXME: only for TS duration and overlap, should be sent to parameter service instead as stable values in run /// Index and start time are already included in the TsHeader object! - FairMQMessagePtr messTsMeta(NewMessage()); + fair::mq::MessagePtr messTsMeta(NewMessage()); // Serialize<RootSerializer>(*messTsMeta, fTsMetaData); RootSerializer().Serialize(*messTsMeta, fTsMetaData); parts.AddPart(std::move(messTsMeta)); @@ -471,15 +467,15 @@ bool CbmDeviceBmonMonitor::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); @@ -489,13 +485,13 @@ bool CbmDeviceBmonMonitor::SendHistoConfAndData() /// Catch case where no histos are registered! /// => Add empty message if (0 == fvpsHistosFolder.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); @@ -505,12 +501,12 @@ bool CbmDeviceBmonMonitor::SendHistoConfAndData() /// Catch case where no Canvases are registered! /// => Add empty message if (0 == fvpsCanvasConfig.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); partsOut.AddPart(std::move(msgHistos)); @@ -532,7 +528,7 @@ bool CbmDeviceBmonMonitor::SendHistoConfAndData() bool CbmDeviceBmonMonitor::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/mcbm/CbmDeviceBmonMonitor.h b/MQ/mcbm/CbmDeviceBmonMonitor.h index d9ea1bd0d9bea29a21c96d18d45e077adc1fed98..a597906430e23d38ba954fc17369bcba68333f71 100644 --- a/MQ/mcbm/CbmDeviceBmonMonitor.h +++ b/MQ/mcbm/CbmDeviceBmonMonitor.h @@ -14,14 +14,11 @@ #include "CbmMqTMessage.h" #include "CbmTsEventHeader.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" #include "FairParGenericSet.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <chrono> #include <map> @@ -34,20 +31,20 @@ class TimesliceMetaData; class CbmTrdSpadic; -class CbmDeviceBmonMonitor : public FairMQDevice { -public: +class CbmDeviceBmonMonitor : public fair::mq::Device { + public: CbmDeviceBmonMonitor(); virtual ~CbmDeviceBmonMonitor(); -protected: + protected: virtual void InitTask(); bool ConditionalRun(); - bool HandleCommand(FairMQMessagePtr&, int); + bool HandleCommand(fair::mq::MessagePtr&, int); /** @brief Set the Bmon Unpack Config @param config */ void SetUnpackConfig(std::shared_ptr<CbmBmonUnpackConfig> config) { fBmonConfig = config; } -private: + private: /// Constants static constexpr std::uint16_t fkFlesBmon = static_cast<std::uint16_t>(fles::Subsystem::BMON); @@ -185,8 +182,12 @@ private: auto algo = config->GetUnpacker(); std::vector<TOptOutA> optoutAvec = {}; std::vector<TOptOutB> optoutBvec = {}; - if (optouttargetvecA) { algo->SetOptOutAVec(&optoutAvec); } - if (optouttargetvecB) { algo->SetOptOutBVec(&optoutBvec); } + if (optouttargetvecA) { + algo->SetOptOutAVec(&optoutAvec); + } + if (optouttargetvecB) { + algo->SetOptOutBVec(&optoutBvec); + } // Set the start time of the current TS for this algorithm algo->SetTsStartTime(ts->start_time()); diff --git a/MQ/mcbm/CbmDeviceBuildDigiEvents.cxx b/MQ/mcbm/CbmDeviceBuildDigiEvents.cxx index 16210f626b099ee196ecc811ad07dd3fe1c6dbae..9e7b859706c96cc4f915f99a69d8d0bdb0158124 100644 --- a/MQ/mcbm/CbmDeviceBuildDigiEvents.cxx +++ b/MQ/mcbm/CbmDeviceBuildDigiEvents.cxx @@ -19,17 +19,14 @@ #include "CbmMatch.h" #include "CbmMvdDigi.h" #include "CbmTsEventHeader.h" - #include "TimesliceMetaData.h" /// FAIRROOT headers +#include "BoostSerializer.h" #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" #include "FairRunOnline.h" - -#include "BoostSerializer.h" - #include "RootSerializer.h" /// FAIRSOFT headers (geant, boost, ...) @@ -92,9 +89,9 @@ try { // nameing convention. It is not avoided that someone sends other // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); @@ -359,16 +356,22 @@ try { //std::vector<CbmMvdDigi>* pMvdDigi = new std::vector<CbmMvdDigi>(); fTimeSliceMetaDataArray = new TClonesArray("TimesliceMetaData", 1); - if (NULL == fTimeSliceMetaDataArray) { throw InitTaskError("Failed creating the TS meta data TClonesarray "); } + if (NULL == fTimeSliceMetaDataArray) { + throw InitTaskError("Failed creating the TS meta data TClonesarray "); + } fpAlgo->SetTimeSliceMetaDataArray(fTimeSliceMetaDataArray); /// Now that everything is set, initialize the Algorithm - if (kFALSE == fpAlgo->InitAlgo()) { throw InitTaskError("Failed to initialize the algorithm class."); } + if (kFALSE == fpAlgo->InitAlgo()) { + throw InitTaskError("Failed to initialize the algorithm class."); + } /// Histograms management if (kTRUE == fbFillHistos) { /// Comment to prevent clang format single lining - if (kFALSE == InitHistograms()) { throw InitTaskError("Failed to initialize the histograms."); } + if (kFALSE == InitHistograms()) { + throw InitTaskError("Failed to initialize the histograms."); + } } } catch (InitTaskError& e) { @@ -476,7 +479,7 @@ bool CbmDeviceBuildDigiEvents::InitHistograms() } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceBuildDigiEvents::HandleData(FairMQParts& parts, int /*index*/) +bool CbmDeviceBuildDigiEvents::HandleData(fair::mq::Parts& parts, int /*index*/) { fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with " << parts.Size() << " parts" @@ -626,7 +629,7 @@ bool CbmDeviceBuildDigiEvents::HandleData(FairMQParts& parts, int /*index*/) return true; } -bool CbmDeviceBuildDigiEvents::SendEvents(FairMQParts& partsIn) +bool CbmDeviceBuildDigiEvents::SendEvents(fair::mq::Parts& partsIn) { /// Get vector reference from algo std::vector<CbmEvent*> vEvents = fpAlgo->GetEventVector(); @@ -642,7 +645,7 @@ bool CbmDeviceBuildDigiEvents::SendEvents(FairMQParts& partsIn) /// Serialize the array of events into a single MQ message /// FIXME: Find out if possible to use only the boost serializer - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &(vOutEvents)); RootSerializer().Serialize(*message, &(vOutEvents)); /* @@ -654,7 +657,7 @@ bool CbmDeviceBuildDigiEvents::SendEvents(FairMQParts& partsIn) /// Add it at the end of the input composed message /// FIXME: Find out if possible to use only the boost serializer - FairMQParts partsOut(std::move(partsIn)); + fair::mq::Parts partsOut(std::move(partsIn)); partsOut.AddPart(std::move(message)); /* partsOut.AddPart(NewMessage( @@ -673,7 +676,7 @@ bool CbmDeviceBuildDigiEvents::SendEvents(FairMQParts& partsIn) return true; } -bool CbmDeviceBuildDigiEvents::SendDigiEvents(FairMQParts& partsIn) +bool CbmDeviceBuildDigiEvents::SendDigiEvents(fair::mq::Parts& partsIn) { /// Get vector reference from algo std::vector<CbmEvent*> vEvents = fpAlgo->GetEventVector(); @@ -771,7 +774,7 @@ bool CbmDeviceBuildDigiEvents::SendDigiEvents(FairMQParts& partsIn) boost::archive::binary_oarchive oaEvt(ossEvt); oaEvt << vOutEvents; std::string* strMsgEvt = new std::string(ossEvt.str()); - FairMQMessagePtr message(NewMessage( + fair::mq::MessagePtr message(NewMessage( const_cast<char*>(strMsgEvt->c_str()), // data strMsgEvt->length(), // size [](void*, void* object) { delete static_cast<std::string*>(object); }, @@ -780,7 +783,7 @@ bool CbmDeviceBuildDigiEvents::SendDigiEvents(FairMQParts& partsIn) /// Make a new composed messaged with TsHeader + vector of Digi Event + TsMetaData /// FIXME: Find out if possible to use only the boost serializer - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(partsIn.At(0))); // TsHeader partsOut.AddPart(std::move(partsIn.At(partsIn.Size() - 1))); // TsMetaData partsOut.AddPart(std::move(message)); // DigiEvent vector @@ -800,15 +803,15 @@ bool CbmDeviceBuildDigiEvents::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); partsOut.AddPart(std::move(messageHist)); @@ -817,13 +820,13 @@ bool CbmDeviceBuildDigiEvents::SendHistoConfAndData() /// Catch case where no histos are registered! /// => Add empty message if (0 == fvpsHistosFolder.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); partsOut.AddPart(std::move(messageCan)); @@ -832,12 +835,12 @@ bool CbmDeviceBuildDigiEvents::SendHistoConfAndData() /// Catch case where no Canvases are registered! /// => Add empty message if (0 == fvpsCanvasConfig.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); partsOut.AddPart(std::move(msgHistos)); @@ -857,7 +860,7 @@ bool CbmDeviceBuildDigiEvents::SendHistoConfAndData() bool CbmDeviceBuildDigiEvents::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); /// Send message to the common histogram messages queue diff --git a/MQ/mcbm/CbmDeviceBuildDigiEvents.h b/MQ/mcbm/CbmDeviceBuildDigiEvents.h index bbf2166c5441bbbf697364ee8a3990d5e4f3a236..308b44640743f6059c455c2d27aceb3dbf457dba 100644 --- a/MQ/mcbm/CbmDeviceBuildDigiEvents.h +++ b/MQ/mcbm/CbmDeviceBuildDigiEvents.h @@ -39,17 +39,17 @@ class TClonesArray; class FairRunOnline; class CbmTsEventHeader; -class CbmDeviceBuildDigiEvents : public FairMQDevice { -public: +class CbmDeviceBuildDigiEvents : public fair::mq::Device { + public: CbmDeviceBuildDigiEvents(); virtual ~CbmDeviceBuildDigiEvents(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQParts&, int); - bool HandleCommand(FairMQMessagePtr&, int); + bool HandleData(fair::mq::Parts&, int); + bool HandleCommand(fair::mq::MessagePtr&, int); -private: + private: /// Constants /// Control flags @@ -134,8 +134,8 @@ private: bool InitHistograms(); void Finish(); - bool SendEvents(FairMQParts& partsIn); - bool SendDigiEvents(FairMQParts& partsIn); + bool SendEvents(fair::mq::Parts& partsIn); + bool SendDigiEvents(fair::mq::Parts& partsIn); bool SendHistoConfAndData(); bool SendHistograms(); }; diff --git a/MQ/mcbm/CbmDeviceBuildRawEvents.cxx b/MQ/mcbm/CbmDeviceBuildRawEvents.cxx index 606d42d6449bc2e5df40e11f695aba66294a69d8..b0baa421553348a74786af5f4a027e713e6dc3b5 100644 --- a/MQ/mcbm/CbmDeviceBuildRawEvents.cxx +++ b/MQ/mcbm/CbmDeviceBuildRawEvents.cxx @@ -17,17 +17,14 @@ #include "CbmMQDefs.h" #include "CbmMatch.h" #include "CbmMvdDigi.h" - #include "TimesliceMetaData.h" /// FAIRROOT headers +#include "BoostSerializer.h" #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" #include "FairRunOnline.h" - -#include "BoostSerializer.h" - #include "RootSerializer.h" /// FAIRSOFT headers (geant, boost, ...) @@ -87,9 +84,9 @@ try { // nameing convention. It is not avoided that someone sends other // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); @@ -277,7 +274,9 @@ try { fvDigiPsd = new std::vector<CbmPsdDigi>(); fTimeSliceMetaDataArray = new TClonesArray("TimesliceMetaData", 1); - if (NULL == fTimeSliceMetaDataArray) { throw InitTaskError("Failed creating the TS meta data TClonesarray "); } + if (NULL == fTimeSliceMetaDataArray) { + throw InitTaskError("Failed creating the TS meta data TClonesarray "); + } fpAlgo->SetTimeSliceMetaDataArray(fTimeSliceMetaDataArray); /// Digis storage @@ -296,7 +295,9 @@ try { fEvents = new TClonesArray("CbmEvent", 500); /// Now that everything is set, initialize the Algorithm - if (kFALSE == fpAlgo->InitAlgo()) { throw InitTaskError("Failed to initilize the algorithm class."); } + if (kFALSE == fpAlgo->InitAlgo()) { + throw InitTaskError("Failed to initilize the algorithm class."); + } /// Histograms management if (kTRUE == fbFillHistos) { @@ -318,12 +319,14 @@ try { fvpsHistosFolder.push_back(psHistoConfig); /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, psHistoConfig); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, psHistoConfig); /// Send message to the common histogram config messages queue - if (Send(messageHist, fsChannelNameHistosConfig) < 0) { throw InitTaskError("Problem sending histo config"); } + if (Send(messageHist, fsChannelNameHistosConfig) < 0) { + throw InitTaskError("Problem sending histo config"); + } LOG(info) << "Config of hist " << psHistoConfig.first.data() << " in folder " << psHistoConfig.second.data(); } @@ -341,12 +344,14 @@ try { fvpsCanvasConfig.push_back(psCanvConfig); /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, psCanvConfig); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, psCanvConfig); /// Send message to the common canvas config messages queue - if (Send(messageCan, fsChannelNameCanvasConfig) < 0) { throw InitTaskError("Problem sending canvas config"); } + if (Send(messageCan, fsChannelNameCanvasConfig) < 0) { + throw InitTaskError("Problem sending canvas config"); + } LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() << " is " << psCanvConfig.second.data(); } @@ -377,7 +382,7 @@ bool CbmDeviceBuildRawEvents::IsChannelNameAllowed(std::string channelName) } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceBuildRawEvents::HandleData(FairMQParts& parts, int /*index*/) +bool CbmDeviceBuildRawEvents::HandleData(fair::mq::Parts& parts, int /*index*/) { fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with " << parts.Size() << " parts" @@ -483,7 +488,7 @@ bool CbmDeviceBuildRawEvents::HandleData(FairMQParts& parts, int /*index*/) return true; } -bool CbmDeviceBuildRawEvents::SendEvents(FairMQParts& partsIn) +bool CbmDeviceBuildRawEvents::SendEvents(fair::mq::Parts& partsIn) { /// Clear events TClonesArray before usage. fEvents->Delete(); @@ -499,12 +504,12 @@ bool CbmDeviceBuildRawEvents::SendEvents(FairMQParts& partsIn) } /// Serialize the array of events into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, fEvents); RootSerializer().Serialize(*message, fEvents); /// Add it at the end of the input composed message - FairMQParts partsOut(std::move(partsIn)); + fair::mq::Parts partsOut(std::move(partsIn)); partsOut.AddPart(std::move(message)); if (Send(partsOut, fsChannelNameDataOutput) < 0) { @@ -518,7 +523,7 @@ bool CbmDeviceBuildRawEvents::SendEvents(FairMQParts& partsIn) bool CbmDeviceBuildRawEvents::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/mcbm/CbmDeviceBuildRawEvents.h b/MQ/mcbm/CbmDeviceBuildRawEvents.h index 5b79678f85b25836cc4fdf572e13a23c65481029..3335f98ff0142baaf9aed252339ae9bd693a510e 100644 --- a/MQ/mcbm/CbmDeviceBuildRawEvents.h +++ b/MQ/mcbm/CbmDeviceBuildRawEvents.h @@ -39,17 +39,17 @@ class TClonesArray; class FairRunOnline; class TimesliceMetaData; -class CbmDeviceBuildRawEvents : public FairMQDevice { -public: +class CbmDeviceBuildRawEvents : public fair::mq::Device { + public: CbmDeviceBuildRawEvents(); virtual ~CbmDeviceBuildRawEvents(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQParts&, int); - bool HandleCommand(FairMQMessagePtr&, int); + bool HandleData(fair::mq::Parts&, int); + bool HandleCommand(fair::mq::MessagePtr&, int); -private: + private: /// Constants /// Control flags @@ -125,7 +125,7 @@ private: bool IsChannelNameAllowed(std::string channelName); void Finish(); - bool SendEvents(FairMQParts& partsIn); + bool SendEvents(fair::mq::Parts& partsIn); bool SendHistograms(); }; diff --git a/MQ/mcbm/CbmDeviceDigiEventSink.cxx b/MQ/mcbm/CbmDeviceDigiEventSink.cxx index f370b9790db6454ca8ff37d8e139252ee7d8f0da..c4e0094d4bb787cb6cacb14aa4d03ece730d1e2c 100644 --- a/MQ/mcbm/CbmDeviceDigiEventSink.cxx +++ b/MQ/mcbm/CbmDeviceDigiEventSink.cxx @@ -16,10 +16,10 @@ #include "CbmEvent.h" #include "CbmFlesCanvasTools.h" #include "CbmMQDefs.h" - #include "TimesliceMetaData.h" /// FAIRROOT headers +#include "BoostSerializer.h" #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" @@ -27,9 +27,6 @@ #include "FairRootManager.h" #include "FairRunOnline.h" #include "FairSource.h" - -#include "BoostSerializer.h" - #include "RootSerializer.h" /// FAIRSOFT headers (geant, boost, ...) @@ -100,15 +97,15 @@ try { // nameing convention. It is not avoided that someone sends other // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmDeviceDigiEventSink::HandleData); } // if( entry.first.find( "ts" ) - } // for( auto const &entry : fChannels ) + } // for( auto const &entry : GetChannels() ) // InitContainers(); @@ -180,7 +177,9 @@ try { /// Histograms management if (kTRUE == fbFillHistos) { /// Comment to prevent clang format single lining - if (kFALSE == InitHistograms()) { throw InitTaskError("Failed to initialize the histograms."); } + if (kFALSE == InitHistograms()) { + throw InitTaskError("Failed to initialize the histograms."); + } } // if( kTRUE == fbFillHistos ) fbInitDone = true; } @@ -338,7 +337,7 @@ bool CbmDeviceDigiEventSink::ResetHistograms(bool bResetStartTime) //--------------------------------------------------------------------// // handler is called whenever a message arrives on fsChannelNameMissedTs, with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceDigiEventSink::HandleMissTsData(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceDigiEventSink::HandleMissTsData(fair::mq::MessagePtr& msg, int /*index*/) { std::vector<uint64_t> vIndices; std::string msgStrMissTs(static_cast<char*>(msg->GetData()), msg->GetSize()); @@ -358,7 +357,7 @@ bool CbmDeviceDigiEventSink::HandleMissTsData(FairMQMessagePtr& msg, int /*index } //--------------------------------------------------------------------// // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceDigiEventSink::HandleData(FairMQParts& parts, int /*index*/) +bool CbmDeviceDigiEventSink::HandleData(fair::mq::Parts& parts, int /*index*/) { fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with " << parts.Size() << " parts" @@ -474,7 +473,7 @@ bool CbmDeviceDigiEventSink::HandleData(FairMQParts& parts, int /*index*/) return true; } //--------------------------------------------------------------------// -bool CbmDeviceDigiEventSink::HandleCommand(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceDigiEventSink::HandleCommand(fair::mq::MessagePtr& msg, int /*index*/) { /* std::string sCommand( static_cast< char * >( msg->GetData() ), @@ -657,7 +656,9 @@ void CbmDeviceDigiEventSink::DumpTreeEntry() /// FairRunOnline style fpFairRootMgr->StoreWriteoutBufferData(fpFairRootMgr->GetEventTime()); auto source = fpFairRootMgr->GetSource(); - if (source) { source->FillEventHeader(fEvtHeader); } + if (source) { + source->FillEventHeader(fEvtHeader); + } fpFairRootMgr->Fill(); fpFairRootMgr->DeleteOldWriteoutBufferData(); // fpFairRootMgr->Write(); @@ -685,16 +686,16 @@ bool CbmDeviceDigiEventSink::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); @@ -704,13 +705,13 @@ bool CbmDeviceDigiEventSink::SendHistoConfAndData() /// Catch case where no histos are registered! /// => Add empty message if (0 == fvpsHistosFolder.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); @@ -720,12 +721,12 @@ bool CbmDeviceDigiEventSink::SendHistoConfAndData() /// Catch case where no Canvases are registered! /// => Add empty message if (0 == fvpsCanvasConfig.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); RootSerializer().Serialize(*msgHistos, &fArrayHisto); partsOut.AddPart(std::move(msgHistos)); @@ -745,7 +746,7 @@ bool CbmDeviceDigiEventSink::SendHistoConfAndData() bool CbmDeviceDigiEventSink::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); RootSerializer().Serialize(*message, &fArrayHisto); /// Send message to the common histogram messages queue @@ -809,7 +810,7 @@ void CbmDeviceDigiEventSink::Finish() } -CbmEventTimeslice::CbmEventTimeslice(FairMQParts& parts, bool bDigiEvtInput) +CbmEventTimeslice::CbmEventTimeslice(fair::mq::Parts& parts, bool bDigiEvtInput) { fbDigiEvtInput = bDigiEvtInput; diff --git a/MQ/mcbm/CbmDeviceDigiEventSink.h b/MQ/mcbm/CbmDeviceDigiEventSink.h index 3add31512859e0ce51d0c854cf4940adccecb558..0b539fe96e0824644c35af16f64cd88a9082b93f 100644 --- a/MQ/mcbm/CbmDeviceDigiEventSink.h +++ b/MQ/mcbm/CbmDeviceDigiEventSink.h @@ -24,7 +24,6 @@ #include "CbmTofDigi.h" #include "CbmTrdDigi.h" #include "CbmTsEventHeader.h" - #include "TimesliceMetaData.h" /// FAIRROOT headers @@ -52,8 +51,8 @@ class FairRootManager; class CbmEventTimeslice { /// TODO: rename to CbmTsWithEvents -public: - CbmEventTimeslice(FairMQParts& parts, bool bDigiEvtInput = false); + public: + CbmEventTimeslice(fair::mq::Parts& parts, bool bDigiEvtInput = false); ~CbmEventTimeslice(); void ExtractSelectedData(bool bExclusiveTrdExtract = true); @@ -83,19 +82,19 @@ public: std::vector<CbmDigiEvent> fvDigiEvents; }; -class CbmDeviceDigiEventSink : public FairMQDevice { -public: +class CbmDeviceDigiEventSink : public fair::mq::Device { + public: CbmDeviceDigiEventSink(); virtual ~CbmDeviceDigiEventSink(); -protected: + protected: virtual void InitTask(); - bool HandleMissTsData(FairMQMessagePtr&, int); - bool HandleData(FairMQParts&, int); - bool HandleCommand(FairMQMessagePtr&, int); + bool HandleMissTsData(fair::mq::MessagePtr&, int); + bool HandleData(fair::mq::Parts&, int); + bool HandleCommand(fair::mq::MessagePtr&, int); virtual void PostRun(); -private: + private: /// Constants /// Control flags diff --git a/MQ/mcbm/CbmDeviceMcbmEventBuilderWin.cxx b/MQ/mcbm/CbmDeviceMcbmEventBuilderWin.cxx index fde19fafdf78b994e3ce32f8f4cd148ed17f0595..86ac52c2655ee683d80553bf169abf0614e249ae 100644 --- a/MQ/mcbm/CbmDeviceMcbmEventBuilderWin.cxx +++ b/MQ/mcbm/CbmDeviceMcbmEventBuilderWin.cxx @@ -18,17 +18,14 @@ #include "CbmMQDefs.h" #include "CbmMatch.h" #include "CbmMvdDigi.h" - #include "TimesliceMetaData.h" /// FAIRROOT headers +#include "BoostSerializer.h" #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" #include "FairRunOnline.h" - -#include "BoostSerializer.h" - #include "RootSerializer.h" /// FAIRSOFT headers (geant, boost, ...) @@ -90,15 +87,15 @@ try { // nameing convention. It is not avoided that someone sends other // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmDeviceMcbmEventBuilderWin::HandleData); } // if( entry.first.find( "ts" ) - } // for( auto const &entry : fChannels ) + } // for( auto const &entry : GetChannels() ) // InitContainers(); @@ -285,9 +282,13 @@ try { fpRun = new FairRunOnline(0); FairRootManager* ioman = nullptr; ioman = FairRootManager::Instance(); - if (NULL == ioman) { throw InitTaskError("No FairRootManager instance"); } + if (NULL == ioman) { + throw InitTaskError("No FairRootManager instance"); + } fTimeSliceMetaDataArray = new TClonesArray("TimesliceMetaData", 1); - if (NULL == fTimeSliceMetaDataArray) { throw InitTaskError("Failed creating the TS meta data TClonesarray "); } + if (NULL == fTimeSliceMetaDataArray) { + throw InitTaskError("Failed creating the TS meta data TClonesarray "); + } ioman->Register("TimesliceMetaData", "TS Meta Data", fTimeSliceMetaDataArray, kFALSE); /// Digis storage ioman->RegisterAny("BmonDigi", fvDigiBmon, kFALSE); @@ -339,7 +340,7 @@ try { fvpsHistosFolder.push_back(psHistoConfig); /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, psHistoConfig); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, psHistoConfig); @@ -365,7 +366,7 @@ try { fvpsCanvasConfig.push_back(psCanvConfig); /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, psCanvConfig); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, psCanvConfig); @@ -433,8 +434,8 @@ Bool_t CbmDeviceMcbmEventBuilderWin::InitParameters( TList* fParCList ) std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req( NewSimpleMessage(message) ); - FairMQMessagePtr rep( NewMessage() ); + fair::mq::MessagePtr req( NewSimpleMessage(message) ); + fair::mq::MessagePtr rep( NewMessage() ); FairParGenericSet* newObj = nullptr; @@ -464,7 +465,7 @@ Bool_t CbmDeviceMcbmEventBuilderWin::InitParameters( TList* fParCList ) } */ // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceMcbmEventBuilderWin::HandleData(FairMQParts& parts, int /*index*/) +bool CbmDeviceMcbmEventBuilderWin::HandleData(fair::mq::Parts& parts, int /*index*/) { fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with " << parts.Size() << " parts" @@ -582,7 +583,7 @@ bool CbmDeviceMcbmEventBuilderWin::HandleData(FairMQParts& parts, int /*index*/) return true; } -bool CbmDeviceMcbmEventBuilderWin::SendEvents(FairMQParts& partsIn) +bool CbmDeviceMcbmEventBuilderWin::SendEvents(fair::mq::Parts& partsIn) { /// Clear events TClonesArray before usage. fEvents->Delete(); @@ -600,13 +601,13 @@ bool CbmDeviceMcbmEventBuilderWin::SendEvents(FairMQParts& partsIn) } // for( CbmEvent* event: vEvents ) /// Serialize the array of events into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, fEvents); RootSerializer().Serialize(*message, fEvents); /// Add it at the end of the input composed message /// FIXME: use move or fix addition of new part to avoid full message copy - FairMQParts partsOut(std::move(partsIn)); + fair::mq::Parts partsOut(std::move(partsIn)); partsOut.AddPart(std::move(message)); // /// Get vector from algo @@ -619,7 +620,7 @@ bool CbmDeviceMcbmEventBuilderWin::SendEvents(FairMQParts& partsIn) // std::string* strMsgEvents = new std::string(ossEvents.str()); // // /// Create message - // FairMQMessagePtr msg( NewMessage( const_cast< char * >( strMsgEvents->c_str() ), // data + // fair::mq::MessagePtr msg( NewMessage( const_cast< char * >( strMsgEvents->c_str() ), // data // strMsgEvents->length(), // size // []( void * /*data*/, void* object ){ delete static_cast< std::string * >( object ); }, // strMsgEvents ) ); // object that manages the data @@ -637,7 +638,7 @@ bool CbmDeviceMcbmEventBuilderWin::SendEvents(FairMQParts& partsIn) bool CbmDeviceMcbmEventBuilderWin::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/mcbm/CbmDeviceMcbmEventBuilderWin.h b/MQ/mcbm/CbmDeviceMcbmEventBuilderWin.h index e3af2741ceaf76dde758ec71b1548369bde60cb2..348476f70d475946c3321e1c27f901d7a4b42824 100644 --- a/MQ/mcbm/CbmDeviceMcbmEventBuilderWin.h +++ b/MQ/mcbm/CbmDeviceMcbmEventBuilderWin.h @@ -39,17 +39,17 @@ class TClonesArray; class FairRunOnline; class TimesliceMetaData; -class CbmDeviceMcbmEventBuilderWin : public FairMQDevice { -public: +class CbmDeviceMcbmEventBuilderWin : public fair::mq::Device { + public: CbmDeviceMcbmEventBuilderWin(); virtual ~CbmDeviceMcbmEventBuilderWin(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQParts&, int); - bool HandleCommand(FairMQMessagePtr&, int); + bool HandleData(fair::mq::Parts&, int); + bool HandleCommand(fair::mq::MessagePtr&, int); -private: + private: /// Constants /// Control flags @@ -130,7 +130,7 @@ private: bool IsChannelNameAllowed(std::string channelName); // Bool_t InitContainers(); void Finish(); - bool SendEvents(FairMQParts& partsIn); + bool SendEvents(fair::mq::Parts& partsIn); bool SendHistograms(); }; diff --git a/MQ/mcbm/CbmDeviceMcbmEventSink.cxx b/MQ/mcbm/CbmDeviceMcbmEventSink.cxx index aa62abde5699aa1ed34e989f1418ff2d58d4551c..23697777b3b166b3bbd7a0978d84c718b6319a18 100644 --- a/MQ/mcbm/CbmDeviceMcbmEventSink.cxx +++ b/MQ/mcbm/CbmDeviceMcbmEventSink.cxx @@ -16,19 +16,16 @@ #include "CbmEvent.h" #include "CbmFlesCanvasTools.h" #include "CbmMQDefs.h" - #include "TimesliceMetaData.h" /// FAIRROOT headers +#include "BoostSerializer.h" #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" #include "FairRootFileSink.h" #include "FairRootManager.h" #include "FairRunOnline.h" - -#include "BoostSerializer.h" - #include "RootSerializer.h" /// FAIRSOFT headers (geant, boost, ...) @@ -42,12 +39,11 @@ #include <boost/serialization/utility.hpp> /// C/C++ headers -#include <thread> // this_thread::sleep_for - #include <array> #include <iomanip> #include <stdexcept> #include <string> +#include <thread> // this_thread::sleep_for struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -92,15 +88,15 @@ try { // nameing convention. It is not avoided that someone sends other // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmDeviceMcbmEventSink::HandleData); } // if( entry.first.find( "ts" ) - } // for( auto const &entry : fChannels ) + } // for( auto const &entry : GetChannels() ) // InitContainers(); @@ -193,7 +189,7 @@ try { fvpsHistosFolder.push_back( psHistoConfig ); /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist( NewMessage() ); + fair::mq::MessagePtr messageHist( NewMessage() ); // Serialize< BoostSerializer < std::pair< std::string, std::string > > >( *messageHist, psHistoConfig ); BoostSerializer < std::pair< std::string, std::string > >.Serialize( *messageHist, psHistoConfig ); @@ -222,7 +218,7 @@ try { fvpsCanvasConfig.push_back( psCanvConfig ); /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan( NewMessage() ); + fair::mq::MessagePtr messageCan( NewMessage() ); // Serialize< BoostSerializer < std::pair< std::string, std::string > > >( *messageCan, psCanvConfig ); BoostSerializer < std::pair< std::string, std::string > >.Serialize( *messageCan, psCanvConfig ); @@ -293,8 +289,8 @@ Bool_t CbmDeviceMcbmEventSink::InitParameters( TList* fParCList ) std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req( NewSimpleMessage(message) ); - FairMQMessagePtr rep( NewMessage() ); + fair::mq::MessagePtr req( NewSimpleMessage(message) ); + fair::mq::MessagePtr rep( NewMessage() ); FairParGenericSet* newObj = nullptr; @@ -325,7 +321,7 @@ Bool_t CbmDeviceMcbmEventSink::InitParameters( TList* fParCList ) */ //--------------------------------------------------------------------// // handler is called whenever a message arrives on fsChannelNameMissedTs, with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceMcbmEventSink::HandleMissTsData(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceMcbmEventSink::HandleMissTsData(fair::mq::MessagePtr& msg, int /*index*/) { std::vector<uint64_t> vIndices; std::string msgStrMissTs(static_cast<char*>(msg->GetData()), msg->GetSize()); @@ -342,7 +338,7 @@ bool CbmDeviceMcbmEventSink::HandleMissTsData(FairMQMessagePtr& msg, int /*index } //--------------------------------------------------------------------// // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceMcbmEventSink::HandleData(FairMQParts& parts, int /*index*/) +bool CbmDeviceMcbmEventSink::HandleData(fair::mq::Parts& parts, int /*index*/) { fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with " << parts.Size() << " parts" @@ -410,7 +406,7 @@ bool CbmDeviceMcbmEventSink::HandleData(FairMQParts& parts, int /*index*/) return true; } //--------------------------------------------------------------------// -bool CbmDeviceMcbmEventSink::HandleCommand(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceMcbmEventSink::HandleCommand(fair::mq::MessagePtr& msg, int /*index*/) { /* std::string sCommand( static_cast< char * >( msg->GetData() ), @@ -615,7 +611,7 @@ void CbmDeviceMcbmEventSink::DumpTreeEntry() bool CbmDeviceMcbmEventSink::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); @@ -681,7 +677,7 @@ void CbmDeviceMcbmEventSink::Finish() fbFinishDone = kTRUE; } -CbmUnpackedTimeslice::CbmUnpackedTimeslice(FairMQParts& parts) : fEventsArray("CbmEvent", 500) +CbmUnpackedTimeslice::CbmUnpackedTimeslice(fair::mq::Parts& parts) : fEventsArray("CbmEvent", 500) { /// Extract unpacked data from input message uint32_t uPartIdx = 0; diff --git a/MQ/mcbm/CbmDeviceMcbmEventSink.h b/MQ/mcbm/CbmDeviceMcbmEventSink.h index cdac88dc83fe227942cffdc40e2d45f89420536c..05dfc3786ab185f3b9103c3792f9f65083c5d4ac 100644 --- a/MQ/mcbm/CbmDeviceMcbmEventSink.h +++ b/MQ/mcbm/CbmDeviceMcbmEventSink.h @@ -21,7 +21,6 @@ #include "CbmStsDigi.h" #include "CbmTofDigi.h" #include "CbmTrdDigi.h" - #include "TimesliceMetaData.h" /// FAIRROOT headers @@ -46,8 +45,8 @@ class FairRootManager; class CbmUnpackedTimeslice { /// TODO: rename to CbmTsWithEvents -public: - CbmUnpackedTimeslice(FairMQParts& parts); + public: + CbmUnpackedTimeslice(fair::mq::Parts& parts); ~CbmUnpackedTimeslice(); TimesliceMetaData fTsMetaData; @@ -61,18 +60,18 @@ public: TClonesArray fEventsArray; }; -class CbmDeviceMcbmEventSink : public FairMQDevice { -public: +class CbmDeviceMcbmEventSink : public fair::mq::Device { + public: CbmDeviceMcbmEventSink(); virtual ~CbmDeviceMcbmEventSink(); -protected: + protected: virtual void InitTask(); - bool HandleMissTsData(FairMQMessagePtr&, int); - bool HandleData(FairMQParts&, int); - bool HandleCommand(FairMQMessagePtr&, int); + bool HandleMissTsData(fair::mq::MessagePtr&, int); + bool HandleData(fair::mq::Parts&, int); + bool HandleCommand(fair::mq::MessagePtr&, int); -private: + private: /// Constants /// Control flags diff --git a/MQ/mcbm/CbmDeviceMcbmMonitorPulser.cxx b/MQ/mcbm/CbmDeviceMcbmMonitorPulser.cxx index 6b3eb7b0f873678fde1fda83bb30926a5c9f3bbf..48c5cbeb3a4fe4f67185af554e2aff5a6296f26a 100644 --- a/MQ/mcbm/CbmDeviceMcbmMonitorPulser.cxx +++ b/MQ/mcbm/CbmDeviceMcbmMonitorPulser.cxx @@ -12,25 +12,22 @@ #include "CbmDeviceMcbmMonitorPulser.h" #include "CbmMQDefs.h" - #include "TimesliceMetaData.h" //#include "CbmMcbm2018MonitorAlgoTof.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -38,8 +35,6 @@ #include <iomanip> #include <stdexcept> #include <string> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -89,15 +84,15 @@ try { // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmDeviceMcbmMonitorPulser::HandleData); } // if( std::string::npos != entry.first.find( fsChannelNameDataInput ) ) - } // for( auto const &entry : fChannels ) + } // for( auto const &entry : GetChannels() ) InitContainers(); } catch (InitTaskError& e) { @@ -142,8 +137,8 @@ Bool_t CbmDeviceMcbmMonitorPulser::InitContainers() std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req( NewSimpleMessage(message) ); - FairMQMessagePtr rep( NewMessage() ); + fair::mq::MessagePtr req( NewSimpleMessage(message) ); + fair::mq::MessagePtr rep( NewMessage() ); FairParGenericSet* newObj = nullptr; @@ -200,7 +195,7 @@ Bool_t CbmDeviceMcbmMonitorPulser::InitContainers() fvpsHistosFolder.push_back( psHistoConfig ); /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist( NewMessage() ); + fair::mq::MessagePtr messageHist( NewMessage() ); // Serialize< BoostSerializer < std::pair< std::string, std::string > > >( *messageHist, psHistoConfig ); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist,psHistoConfig); @@ -230,7 +225,7 @@ Bool_t CbmDeviceMcbmMonitorPulser::InitContainers() fvpsCanvasConfig.push_back( psCanvConfig ); /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan( NewMessage() ); + fair::mq::MessagePtr messageCan( NewMessage() ); // Serialize< BoostSerializer < std::pair< std::string, std::string > > >( *messageCan, psCanvConfig ); BoostSerializer < std::pair< std::string, std::string > >().Serialize( *messageCan, psCanvConfig ); @@ -250,7 +245,7 @@ Bool_t CbmDeviceMcbmMonitorPulser::InitContainers() // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceMcbmMonitorPulser::HandleData(FairMQParts& parts, int /*index*/) +bool CbmDeviceMcbmMonitorPulser::HandleData(fair::mq::Parts& parts, int /*index*/) { fulNumMessages++; @@ -362,7 +357,7 @@ bool CbmDeviceMcbmMonitorPulser::HandleData(FairMQParts& parts, int /*index*/) bool CbmDeviceMcbmMonitorPulser::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/mcbm/CbmDeviceMcbmMonitorPulser.h b/MQ/mcbm/CbmDeviceMcbmMonitorPulser.h index 181b3185f5f2f04790d33aa3d914629b42804ee3..2008ffad0d299d4204bfb169d965dc16d1d3ad2e 100644 --- a/MQ/mcbm/CbmDeviceMcbmMonitorPulser.h +++ b/MQ/mcbm/CbmDeviceMcbmMonitorPulser.h @@ -19,9 +19,7 @@ #include "CbmStsDigi.h" #include "CbmTofDigi.h" #include "CbmTrdDigi.h" - #include "FairMQDevice.h" - #include "Rtypes.h" #include "TObjArray.h" @@ -36,16 +34,16 @@ class TList; //class CbmMcbm2018MonitorAlgoTof; class TimesliceMetaData; -class CbmDeviceMcbmMonitorPulser : public FairMQDevice { -public: +class CbmDeviceMcbmMonitorPulser : public fair::mq::Device { + public: CbmDeviceMcbmMonitorPulser(); virtual ~CbmDeviceMcbmMonitorPulser(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQParts&, int); + bool HandleData(fair::mq::Parts&, int); -private: + private: /// Constants /*********************** SHOULD GO IN ALGO ****************************/ static const UInt_t kuNbChanSMX = 128; @@ -206,7 +204,7 @@ private: TH2* fBmonRichDiffEvoLong = nullptr; TH2* fBmonPsdDiffEvoLong = nullptr; - Double_t fdStartTime = -1; + Double_t fdStartTime = -1; TProfile* fBmonStsMeanEvo = nullptr; TProfile* fBmonMuchMeanEvo = nullptr; TProfile* fBmonTrdMeanEvo = nullptr; diff --git a/MQ/mcbm/CbmDeviceMcbmUnpack.cxx b/MQ/mcbm/CbmDeviceMcbmUnpack.cxx index 219e3bc9ba6614bc98cb313a3e3d027a325d56cd..076c6132aad5c52f0325b38510944fb810da7f79 100644 --- a/MQ/mcbm/CbmDeviceMcbmUnpack.cxx +++ b/MQ/mcbm/CbmDeviceMcbmUnpack.cxx @@ -11,6 +11,7 @@ #include "CbmDeviceMcbmUnpack.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" #include "CbmMQDefs.h" #include "CbmMcbm2018UnpackerAlgoMuch.h" @@ -19,21 +20,18 @@ #include "CbmMcbm2018UnpackerAlgoSts.h" #include "CbmMcbm2018UnpackerAlgoTof.h" #include "CbmMcbm2018UnpackerAlgoTrdR.h" - -#include "StorableTimeslice.hpp" -#include "TimesliceMetaData.h" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" +#include "TimesliceMetaData.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -41,8 +39,6 @@ #include <iomanip> #include <stdexcept> #include <string> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -82,15 +78,15 @@ try { // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmDeviceMcbmUnpack::HandleData); } // if( entry.first.find( "ts" ) - } // for( auto const &entry : fChannels ) + } // for( auto const &entry : GetChannels() ) InitContainers(); } catch (InitTaskError& e) { @@ -152,7 +148,9 @@ Bool_t CbmDeviceMcbmUnpack::InitContainers() charPosDel++; Double_t dOffset = std::stod((*itStrOffs).substr(charPosDel)); - if ("kSTS" == sSelDet) { fUnpAlgoSts->SetTimeOffsetNs(dOffset); } // if( "kSTS" == sSelDet ) + if ("kSTS" == sSelDet) { + fUnpAlgoSts->SetTimeOffsetNs(dOffset); + } // if( "kSTS" == sSelDet ) else if ("kMUCH" == sSelDet) { fUnpAlgoMuch->SetTimeOffsetNs(dOffset); } // else if( "kMUCH" == sSelDet ) @@ -203,7 +201,7 @@ Bool_t CbmDeviceMcbmUnpack::InitParameters(TList* fParCList) for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) { FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); fParCList->Remove(tempObj); - std::string paramName {tempObj->GetName()}; + std::string paramName{tempObj->GetName()}; // 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 @@ -211,8 +209,8 @@ Bool_t CbmDeviceMcbmUnpack::InitParameters(TList* fParCList) std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -238,7 +236,7 @@ Bool_t CbmDeviceMcbmUnpack::InitParameters(TList* fParCList) } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceMcbmUnpack::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceMcbmUnpack::HandleData(fair::mq::MessagePtr& msg, int /*index*/) { fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with size " << msg->GetSize(); @@ -250,7 +248,7 @@ bool CbmDeviceMcbmUnpack::HandleData(FairMQMessagePtr& msg, int /*index*/) boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice ts {0}; + fles::StorableTimeslice ts{0}; inputArchive >> ts; /// On first TS, extract the TS parameters from header (by definition stable over time) @@ -304,7 +302,7 @@ bool CbmDeviceMcbmUnpack::SendUnpData() oaTsMeta << *(fTsMetaData); std::string* strMsgTsMetaE = new std::string(ossTsMeta.str()); */ - FairMQMessagePtr messTsMeta(NewMessage()); + fair::mq::MessagePtr messTsMeta(NewMessage()); // Serialize<RootSerializer>(*messTsMeta, fTsMetaData); RootSerializer().Serialize(*messTsMeta, fTsMetaData); @@ -325,7 +323,7 @@ bool CbmDeviceMcbmUnpack::SendUnpData() /// Split TOF vector in TOF and Bmon std::vector<CbmTofDigi>& vDigiTofBmon = fUnpAlgoTof->GetVector(); - std::vector<CbmTofDigi> vDigiTof = {}; + std::vector<CbmTofDigi> vDigiTof = {}; std::vector<CbmTofDigi> vDigiBmon = {}; for (auto digi : vDigiTofBmon) { @@ -359,7 +357,7 @@ bool CbmDeviceMcbmUnpack::SendUnpData() oaPsd << fUnpAlgoPsd->GetVector(); std::string* strMsgPsd = new std::string(ossPsd.str()); - FairMQParts parts; + fair::mq::Parts parts; parts.AddPart(std::move(messTsMeta)); /* diff --git a/MQ/mcbm/CbmDeviceMcbmUnpack.h b/MQ/mcbm/CbmDeviceMcbmUnpack.h index 0745a58040c0a4568524adc8dc4e5450fb1d04d4..08609f847b0ba32fe900ebdfe2773b3fcd6a41c8 100644 --- a/MQ/mcbm/CbmDeviceMcbmUnpack.h +++ b/MQ/mcbm/CbmDeviceMcbmUnpack.h @@ -13,13 +13,10 @@ #define CBMDEVICEMCBMUNPACK_H_ #include "CbmMqTMessage.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <map> #include <vector> @@ -33,17 +30,17 @@ class CbmMcbm2018UnpackerAlgoRich; class CbmMcbm2018UnpackerAlgoPsd; class TimesliceMetaData; -class CbmDeviceMcbmUnpack : public FairMQDevice { -public: +class CbmDeviceMcbmUnpack : public fair::mq::Device { + public: CbmDeviceMcbmUnpack(); virtual ~CbmDeviceMcbmUnpack(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQMessagePtr&, int); - bool HandleCommand(FairMQMessagePtr&, int); + bool HandleData(fair::mq::MessagePtr&, int); + bool HandleCommand(fair::mq::MessagePtr&, int); -private: + private: /// Constants static const uint16_t kusSysIdSts = 0x10; static const uint16_t kusSysIdMuch = 0x50; diff --git a/MQ/mcbm/CbmDeviceUnpack.cxx b/MQ/mcbm/CbmDeviceUnpack.cxx index 473bac0069dd339472b04ceb131bc2fc86c79c62..6dce2b2524359c76afdbf25959dfbda709ecd567 100644 --- a/MQ/mcbm/CbmDeviceUnpack.cxx +++ b/MQ/mcbm/CbmDeviceUnpack.cxx @@ -11,6 +11,7 @@ #include "CbmDeviceUnpack.h" +#include "BoostSerializer.h" #include "CbmBmonUnpackConfig.h" #include "CbmFlesCanvasTools.h" #include "CbmMQDefs.h" @@ -22,21 +23,18 @@ #include "CbmTofUnpackConfig.h" #include "CbmTrdUnpackConfig.h" #include "CbmTrdUnpackFaspConfig.h" - -#include "StorableTimeslice.hpp" -#include "TimesliceMetaData.h" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" +#include "TimesliceMetaData.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -45,8 +43,6 @@ #include <stdexcept> #include <string> #include <utility> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -98,8 +94,8 @@ Bool_t CbmDeviceUnpack::InitContainers() // ----- CbmSetup ----------------------------------------------------- // TODO: support for multiple setups on Par Server? with request containing setup name? CbmSetup* cbmsetup = CbmSetup::Instance(); - FairMQMessagePtr req(NewSimpleMessage("setup")); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage("setup")); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, "parameters") > 0) { if (Receive(rep, "parameters") >= 0) { @@ -220,7 +216,9 @@ Bool_t CbmDeviceUnpack::InitContainers() std::cout << Form("Setting time-walk parametersfor: module %x, ASIC %u\n", sensor, asic); parAsic->SetWalkCoef({p0, p1, p2, p3}); - if (walkMap.find(sensor) == walkMap.end()) { walkMap[sensor] = CbmStsParModule(*parMod); } + if (walkMap.find(sensor) == walkMap.end()) { + walkMap[sensor] = CbmStsParModule(*parMod); + } walkMap[sensor].SetAsic(asic, *parAsic); } @@ -621,7 +619,7 @@ CbmDeviceUnpack::InitParameters(std::vector<std::pair<std::string, std::shared_p if (asciiInput.open(filepath.data())) { parset->init(&asciiInput); } } * */ - std::string paramName {pair.second->GetName()}; + std::string paramName{pair.second->GetName()}; // 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 @@ -629,8 +627,8 @@ CbmDeviceUnpack::InitParameters(std::vector<std::pair<std::string, std::shared_p std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -721,8 +719,8 @@ bool CbmDeviceUnpack::ConditionalRun() /// First request a new TS (full one) std::string message = "full"; LOG(debug) << "Requesting new TS by sending message: full" << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, fsChannelNameDataInput) <= 0) { LOG(error) << "Failed to send the request! message was " << message; @@ -747,7 +745,7 @@ bool CbmDeviceUnpack::ConditionalRun() boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice ts {0}; + fles::StorableTimeslice ts{0}; inputArchive >> ts; /// On first TS, extract the TS parameters from header (by definition stable over time) @@ -820,10 +818,10 @@ bool CbmDeviceUnpack::ConditionalRun() bool CbmDeviceUnpack::SendUnpData() { - FairMQParts parts; + fair::mq::Parts parts; /// Prepare serialized versions of the TS Event header - FairMQMessagePtr messTsHeader(NewMessage()); + fair::mq::MessagePtr messTsHeader(NewMessage()); // Serialize<RootSerializer>(*messTsHeader, fCbmTsEventHeader); RootSerializer().Serialize(*messTsHeader, fCbmTsEventHeader); @@ -952,7 +950,7 @@ bool CbmDeviceUnpack::SendUnpData() /// Prepare serialized versions of the TS Meta /// FIXME: only for TS duration and overlap, should be sent to parameter service instead as stable values in run /// Index and start time are already included in the TsHeader object! - FairMQMessagePtr messTsMeta(NewMessage()); + fair::mq::MessagePtr messTsMeta(NewMessage()); // Serialize<RootSerializer>(*messTsMeta, fTsMetaData); RootSerializer().Serialize(*messTsMeta, fTsMetaData); parts.AddPart(std::move(messTsMeta)); @@ -970,15 +968,15 @@ bool CbmDeviceUnpack::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); @@ -988,13 +986,13 @@ bool CbmDeviceUnpack::SendHistoConfAndData() /// Catch case where no histos are registered! /// => Add empty message if (0 == fvpsHistosFolder.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); @@ -1004,12 +1002,12 @@ bool CbmDeviceUnpack::SendHistoConfAndData() /// Catch case where no Canvases are registered! /// => Add empty message if (0 == fvpsCanvasConfig.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); partsOut.AddPart(std::move(msgHistos)); @@ -1029,7 +1027,7 @@ bool CbmDeviceUnpack::SendHistoConfAndData() bool CbmDeviceUnpack::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); @@ -1140,24 +1138,56 @@ Bool_t CbmDeviceUnpack::DoUnpack(const fles::Timeslice& ts, size_t /*component*/ if (fbOutputFullTimeSorting) { /// Time sort the output vectors of all unpackers present - if (fBmonConfig && fBmonConfig->GetOutputVec()) { timesort(fBmonConfig->GetOutputVec()); } - if (fStsConfig && fStsConfig->GetOutputVec()) { timesort(fStsConfig->GetOutputVec()); } - if (fMuchConfig && fMuchConfig->GetOutputVec()) { timesort(fMuchConfig->GetOutputVec()); } - if (fTrd1DConfig && fTrd1DConfig->GetOutputVec()) { timesort(fTrd1DConfig->GetOutputVec()); } - if (fTrd2DConfig && fTrd2DConfig->GetOutputVec()) { timesort(fTrd2DConfig->GetOutputVec()); } - if (fTofConfig && fTofConfig->GetOutputVec()) { timesort(fTofConfig->GetOutputVec()); } - if (fRichConfig && fRichConfig->GetOutputVec()) { timesort(fRichConfig->GetOutputVec()); } - if (fPsdConfig && fPsdConfig->GetOutputVec()) { timesort(fPsdConfig->GetOutputVec()); } + if (fBmonConfig && fBmonConfig->GetOutputVec()) { + timesort(fBmonConfig->GetOutputVec()); + } + if (fStsConfig && fStsConfig->GetOutputVec()) { + timesort(fStsConfig->GetOutputVec()); + } + if (fMuchConfig && fMuchConfig->GetOutputVec()) { + timesort(fMuchConfig->GetOutputVec()); + } + if (fTrd1DConfig && fTrd1DConfig->GetOutputVec()) { + timesort(fTrd1DConfig->GetOutputVec()); + } + if (fTrd2DConfig && fTrd2DConfig->GetOutputVec()) { + timesort(fTrd2DConfig->GetOutputVec()); + } + if (fTofConfig && fTofConfig->GetOutputVec()) { + timesort(fTofConfig->GetOutputVec()); + } + if (fRichConfig && fRichConfig->GetOutputVec()) { + timesort(fRichConfig->GetOutputVec()); + } + if (fPsdConfig && fPsdConfig->GetOutputVec()) { + timesort(fPsdConfig->GetOutputVec()); + } /// Time sort the output vectors of all unpackers present - if (fBmonConfig && fBmonConfig->GetOptOutAVec()) { timesort(fBmonConfig->GetOptOutAVec()); } - if (fStsConfig && fStsConfig->GetOptOutAVec()) { timesort(fStsConfig->GetOptOutAVec()); } - if (fMuchConfig && fMuchConfig->GetOptOutAVec()) { timesort(fMuchConfig->GetOptOutAVec()); } - if (fTrd1DConfig && fTrd1DConfig->GetOptOutAVec()) { timesort(fTrd1DConfig->GetOptOutAVec()); } - if (fTrd2DConfig && fTrd2DConfig->GetOptOutAVec()) { timesort(fTrd2DConfig->GetOptOutAVec()); } - if (fTofConfig && fTofConfig->GetOptOutAVec()) { timesort(fTofConfig->GetOptOutAVec()); } - if (fRichConfig && fRichConfig->GetOptOutAVec()) { timesort(fRichConfig->GetOptOutAVec()); } - if (fPsdConfig && fPsdConfig->GetOptOutAVec()) { timesort(fPsdConfig->GetOptOutAVec()); } + if (fBmonConfig && fBmonConfig->GetOptOutAVec()) { + timesort(fBmonConfig->GetOptOutAVec()); + } + if (fStsConfig && fStsConfig->GetOptOutAVec()) { + timesort(fStsConfig->GetOptOutAVec()); + } + if (fMuchConfig && fMuchConfig->GetOptOutAVec()) { + timesort(fMuchConfig->GetOptOutAVec()); + } + if (fTrd1DConfig && fTrd1DConfig->GetOptOutAVec()) { + timesort(fTrd1DConfig->GetOptOutAVec()); + } + if (fTrd2DConfig && fTrd2DConfig->GetOptOutAVec()) { + timesort(fTrd2DConfig->GetOptOutAVec()); + } + if (fTofConfig && fTofConfig->GetOptOutAVec()) { + timesort(fTofConfig->GetOptOutAVec()); + } + if (fRichConfig && fRichConfig->GetOptOutAVec()) { + timesort(fRichConfig->GetOptOutAVec()); + } + if (fPsdConfig && fPsdConfig->GetOptOutAVec()) { + timesort(fPsdConfig->GetOptOutAVec()); + } } if (0 == fulTsCounter % 10000) LOG(info) << "Processed " << fulTsCounter << " time slices"; diff --git a/MQ/mcbm/CbmDeviceUnpack.h b/MQ/mcbm/CbmDeviceUnpack.h index acfdfdb719f7210475acb9f63d0854ac9022588f..a0b7f7131f8b89355341f508bfd9a235abd59193 100644 --- a/MQ/mcbm/CbmDeviceUnpack.h +++ b/MQ/mcbm/CbmDeviceUnpack.h @@ -14,14 +14,11 @@ #include "CbmMqTMessage.h" #include "CbmTsEventHeader.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" #include "FairParGenericSet.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <chrono> #include <map> @@ -41,15 +38,15 @@ class TimesliceMetaData; class CbmTrdSpadic; -class CbmDeviceUnpack : public FairMQDevice { -public: +class CbmDeviceUnpack : public fair::mq::Device { + public: CbmDeviceUnpack(); virtual ~CbmDeviceUnpack(); -protected: + protected: virtual void InitTask(); bool ConditionalRun(); - bool HandleCommand(FairMQMessagePtr&, int); + bool HandleCommand(fair::mq::MessagePtr&, int); /** @brief Set the Bmon Unpack Config @param config */ void SetUnpackConfig(std::shared_ptr<CbmBmonUnpackConfig> config) { fBmonConfig = config; } @@ -75,7 +72,7 @@ protected: /** @brief Set the Psd Unpack Config @param config */ void SetUnpackConfig(std::shared_ptr<CbmPsdUnpackConfig> config) { fPsdConfig = config; } -private: + private: /// Constants static constexpr std::uint16_t fkFlesBmon = static_cast<std::uint16_t>(fles::Subsystem::BMON); static constexpr std::uint16_t fkFlesMvd = static_cast<std::uint16_t>(fles::Subsystem::MVD); @@ -233,8 +230,12 @@ private: auto algo = config->GetUnpacker(); std::vector<TOptOutA> optoutAvec = {}; std::vector<TOptOutB> optoutBvec = {}; - if (optouttargetvecA) { algo->SetOptOutAVec(&optoutAvec); } - if (optouttargetvecB) { algo->SetOptOutBVec(&optoutBvec); } + if (optouttargetvecA) { + algo->SetOptOutAVec(&optoutAvec); + } + if (optouttargetvecB) { + algo->SetOptOutBVec(&optoutBvec); + } // Set the start time of the current TS for this algorithm algo->SetTsStartTime(ts->start_time()); diff --git a/MQ/mcbm/runBmonMonitor.cxx b/MQ/mcbm/runBmonMonitor.cxx index 43177e5238d933b04558b062238c2fadf3531f9c..f6bcdb2eed3e0ece0f56577dc993f4606eb675b1 100644 --- a/MQ/mcbm/runBmonMonitor.cxx +++ b/MQ/mcbm/runBmonMonitor.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceBmonMonitor.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -38,4 +37,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceBmonMonitor(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceBmonMonitor(); } diff --git a/MQ/mcbm/runBuildDigiEvents.cxx b/MQ/mcbm/runBuildDigiEvents.cxx index 770e1484bb8648f792b23cdf546ede2dda8351ec..b1c38d3bf7a3ad2b002df5aa22334a795a13ff3c 100644 --- a/MQ/mcbm/runBuildDigiEvents.cxx +++ b/MQ/mcbm/runBuildDigiEvents.cxx @@ -3,12 +3,11 @@ Authors: Dominik Smith [committer] */ #include "CbmDeviceBuildDigiEvents.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -61,4 +60,4 @@ void addCustomOptions(bpo::options_description& options) "Maximal time between two publishing"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceBuildDigiEvents(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceBuildDigiEvents(); } diff --git a/MQ/mcbm/runBuildRawEvents.cxx b/MQ/mcbm/runBuildRawEvents.cxx index 4857f2fd4e221db3604e1236abce9d6213768589..325776fdced26ce976f862aacde98c4d7e6a6aec 100644 --- a/MQ/mcbm/runBuildRawEvents.cxx +++ b/MQ/mcbm/runBuildRawEvents.cxx @@ -3,12 +3,11 @@ Authors: Dominik Smith [committer] */ #include "CbmDeviceBuildRawEvents.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -49,4 +48,4 @@ void addCustomOptions(bpo::options_description& options) "Maximal time between two publishing"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceBuildRawEvents(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceBuildRawEvents(); } diff --git a/MQ/mcbm/runDigiEventSink.cxx b/MQ/mcbm/runDigiEventSink.cxx index 450a156b7dd485e4d53c03c3e6fdabdf604998e9..77c5f39d3ed7064fa1c10d5626493c57fc716952 100644 --- a/MQ/mcbm/runDigiEventSink.cxx +++ b/MQ/mcbm/runDigiEventSink.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceDigiEventSink.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -50,4 +49,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceDigiEventSink(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceDigiEventSink(); } diff --git a/MQ/mcbm/runMcbmEventSink.cxx b/MQ/mcbm/runMcbmEventSink.cxx index 1577c2491cbb968dda83587b7415a35cfc2fdee4..26669a1f03065770fb9ed61135ad93f681965742 100644 --- a/MQ/mcbm/runMcbmEventSink.cxx +++ b/MQ/mcbm/runMcbmEventSink.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceMcbmEventSink.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -33,4 +32,4 @@ void addCustomOptions(bpo::options_description& options) "Maximal time between two publishing"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMcbmEventSink(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMcbmEventSink(); } diff --git a/MQ/mcbm/runMcbmEvtBuilderWin.cxx b/MQ/mcbm/runMcbmEvtBuilderWin.cxx index 1ab51c9600b29f37b5341cb27a038686a6d34b43..a2ac42a758afdb948de9b77b9b96e99de26828b5 100644 --- a/MQ/mcbm/runMcbmEvtBuilderWin.cxx +++ b/MQ/mcbm/runMcbmEvtBuilderWin.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceMcbmEventBuilderWin.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -49,4 +48,4 @@ void addCustomOptions(bpo::options_description& options) "Maximal time between two publishing"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMcbmEventBuilderWin(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMcbmEventBuilderWin(); } diff --git a/MQ/mcbm/runMcbmMonitorPulser.cxx b/MQ/mcbm/runMcbmMonitorPulser.cxx index 215a3a373fdf81ddb9098508a2784d9ff7e86e6b..f864dc1869648c9e7a5c73e0971078ba37faf7ca 100644 --- a/MQ/mcbm/runMcbmMonitorPulser.cxx +++ b/MQ/mcbm/runMcbmMonitorPulser.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceMcbmMonitorPulser.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -33,4 +32,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for canvases config"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMcbmMonitorPulser(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMcbmMonitorPulser(); } diff --git a/MQ/mcbm/runMcbmUnpack.cxx b/MQ/mcbm/runMcbmUnpack.cxx index 7b88b34d7042b4fd58b322f2bb29c516ccb92037..29d0288f584cc483fa41031d2e2bd8d1ac0e241c 100644 --- a/MQ/mcbm/runMcbmUnpack.cxx +++ b/MQ/mcbm/runMcbmUnpack.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceMcbmUnpack.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -24,4 +23,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for unpacked TS data"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMcbmUnpack(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMcbmUnpack(); } diff --git a/MQ/mcbm/runUnpack.cxx b/MQ/mcbm/runUnpack.cxx index 95332c747918c29c4feb32ae2b341c464db89d34..3865593447dda00dc7eed6eb51c20264201487d7 100644 --- a/MQ/mcbm/runUnpack.cxx +++ b/MQ/mcbm/runUnpack.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceUnpack.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -45,4 +44,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceUnpack(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceUnpack(); } diff --git a/MQ/monitor/CbmDeviceMonitorBmon.cxx b/MQ/monitor/CbmDeviceMonitorBmon.cxx index f87f44169a01f20d69063604ccac3a55e69aa39d..14ec250b2201e11152a4b1a1a407270cd11d4d66 100644 --- a/MQ/monitor/CbmDeviceMonitorBmon.cxx +++ b/MQ/monitor/CbmDeviceMonitorBmon.cxx @@ -11,22 +11,20 @@ #include "CbmDeviceMonitorBmon.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" #include "CbmMcbm2018MonitorAlgoBmon.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -34,8 +32,6 @@ #include <iomanip> #include <stdexcept> #include <string> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -44,28 +40,28 @@ using namespace std; CbmDeviceMonitorBmon::CbmDeviceMonitorBmon() - : fbIgnoreOverlapMs {false} - , fsChannelNameDataInput {"t0component"} - , fsChannelNameHistosInput {"histogram-in"} - , fuHistoryHistoSize {3600} - , fuMinTotPulser {185} - , fuMaxTotPulser {195} - , fuOffSpillCountLimit {25} - , fuOffSpillCountLimitNonPulser {10} - , fdSpillCheckInterval {0.0128} - , fvuChanMap {0, 1, 2, 3, 4, 5, 6, 7} - , fuPublishFreqTs {100} - , fdMinPublishTime {0.5} - , fdMaxPublishTime {5.0} - , fsAllowedChannels {fsChannelNameDataInput} - , fParCList {nullptr} - , fulNumMessages {0} - , fulTsCounter {0} - , fLastPublishTime {std::chrono::system_clock::now()} - , fMonitorAlgo {new CbmMcbm2018MonitorAlgoBmon()} - , fArrayHisto {} - , fvpsHistosFolder {} - , fvpsCanvasConfig {} + : fbIgnoreOverlapMs{false} + , fsChannelNameDataInput{"t0component"} + , fsChannelNameHistosInput{"histogram-in"} + , fuHistoryHistoSize{3600} + , fuMinTotPulser{185} + , fuMaxTotPulser{195} + , fuOffSpillCountLimit{25} + , fuOffSpillCountLimitNonPulser{10} + , fdSpillCheckInterval{0.0128} + , fvuChanMap{0, 1, 2, 3, 4, 5, 6, 7} + , fuPublishFreqTs{100} + , fdMinPublishTime{0.5} + , fdMaxPublishTime{5.0} + , fsAllowedChannels{fsChannelNameDataInput} + , fParCList{nullptr} + , fulNumMessages{0} + , fulTsCounter{0} + , fLastPublishTime{std::chrono::system_clock::now()} + , fMonitorAlgo{new CbmMcbm2018MonitorAlgoBmon()} + , fArrayHisto{} + , fvpsHistosFolder{} + , fvpsCanvasConfig{} { } @@ -119,15 +115,15 @@ try { // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmDeviceMonitorBmon::HandleData); } // if( entry.first.find( "ts" ) - } // for( auto const &entry : fChannels ) + } // for( auto const &entry : GetChannels() ) } catch (InitTaskError& e) { LOG(error) << e.what(); @@ -161,7 +157,7 @@ bool CbmDeviceMonitorBmon::InitContainers() for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) { FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); fParCList->Remove(tempObj); - std::string paramName {tempObj->GetName()}; + std::string paramName{tempObj->GetName()}; // 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 @@ -169,8 +165,8 @@ bool CbmDeviceMonitorBmon::InitContainers() std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -256,7 +252,7 @@ bool CbmDeviceMonitorBmon::InitHistograms() // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceMonitorBmon::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceMonitorBmon::HandleData(fair::mq::MessagePtr& msg, int /*index*/) { if (0 == fulNumMessages) { @@ -281,7 +277,7 @@ bool CbmDeviceMonitorBmon::HandleData(FairMQMessagePtr& msg, int /*index*/) boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; /// Process the Timeslice @@ -311,16 +307,16 @@ bool CbmDeviceMonitorBmon::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); @@ -329,7 +325,7 @@ bool CbmDeviceMonitorBmon::SendHistoConfAndData() for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); @@ -337,7 +333,7 @@ bool CbmDeviceMonitorBmon::SendHistoConfAndData() } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); @@ -358,7 +354,7 @@ bool CbmDeviceMonitorBmon::SendHistoConfAndData() bool CbmDeviceMonitorBmon::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/monitor/CbmDeviceMonitorBmon.h b/MQ/monitor/CbmDeviceMonitorBmon.h index 70e23122e0a650f201c741ff58d376b2102270d0..48a988b5469c280e768f64500f27d72066c1204f 100644 --- a/MQ/monitor/CbmDeviceMonitorBmon.h +++ b/MQ/monitor/CbmDeviceMonitorBmon.h @@ -13,13 +13,10 @@ #define CBMDEVICEMONITORBmon_H_ #include "CbmMqTMessage.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <chrono> #include <map> @@ -28,16 +25,16 @@ class TList; class CbmMcbm2018MonitorAlgoBmon; -class CbmDeviceMonitorBmon : public FairMQDevice { -public: +class CbmDeviceMonitorBmon : public fair::mq::Device { + public: CbmDeviceMonitorBmon(); virtual ~CbmDeviceMonitorBmon(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQMessagePtr&, int); + bool HandleData(fair::mq::MessagePtr&, int); -private: + private: /// Constants static const uint16_t kusSysId = 0x90; diff --git a/MQ/monitor/CbmDeviceMonitorPsd.cxx b/MQ/monitor/CbmDeviceMonitorPsd.cxx index 9748da2d16fa36768c893a0b5d515583658d270c..a78f8e22e10f91a826b8982031441ac849675d94 100644 --- a/MQ/monitor/CbmDeviceMonitorPsd.cxx +++ b/MQ/monitor/CbmDeviceMonitorPsd.cxx @@ -12,23 +12,21 @@ #include "CbmDeviceMonitorPsd.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" #include "CbmMQDefs.h" #include "CbmMcbm2018MonitorAlgoPsd.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -36,8 +34,6 @@ #include <iomanip> #include <stdexcept> #include <string> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -45,27 +41,27 @@ struct InitTaskError : std::runtime_error { using namespace std; CbmDeviceMonitorPsd::CbmDeviceMonitorPsd() - : fbIgnoreOverlapMs {false} - , fsChannelNameDataInput {"psdcomponent"} - , fsChannelNameHistosInput {"histogram-in"} - , fsChannelNameHistosConfig {"histo-conf"} - , fsChannelNameCanvasConfig {"canvas-conf"} - , fuPublishFreqTs {100} - , fdMinPublishTime {0.5} - , fdMaxPublishTime {5.0} - , fuHistoryHistoSize {3600} + : fbIgnoreOverlapMs{false} + , fsChannelNameDataInput{"psdcomponent"} + , fsChannelNameHistosInput{"histogram-in"} + , fsChannelNameHistosConfig{"histo-conf"} + , fsChannelNameCanvasConfig{"canvas-conf"} + , fuPublishFreqTs{100} + , fdMinPublishTime{0.5} + , fdMaxPublishTime{5.0} + , fuHistoryHistoSize{3600} , fviHistoChargeArgs(3, 0) , fviHistoAmplArgs(3, 0) , fviHistoZLArgs(3, 0) - , fsAllowedChannels {fsChannelNameDataInput} - , fParCList {nullptr} - , fulNumMessages {0} - , fulTsCounter {0} - , fLastPublishTime {std::chrono::system_clock::now()} - , fMonitorAlgo {new CbmMcbm2018MonitorAlgoPsd()} - , fArrayHisto {} - , fvpsHistosFolder {} - , fvpsCanvasConfig {} + , fsAllowedChannels{fsChannelNameDataInput} + , fParCList{nullptr} + , fulNumMessages{0} + , fulTsCounter{0} + , fLastPublishTime{std::chrono::system_clock::now()} + , fMonitorAlgo{new CbmMcbm2018MonitorAlgoPsd()} + , fArrayHisto{} + , fvpsHistosFolder{} + , fvpsCanvasConfig{} { } @@ -105,15 +101,15 @@ try { // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmDeviceMonitorPsd::HandleData); } // if( entry.first.find( "ts" ) - } // for( auto const &entry : fChannels ) + } // for( auto const &entry : GetChannels() ) InitContainers(); } catch (InitTaskError& e) { @@ -149,7 +145,7 @@ Bool_t CbmDeviceMonitorPsd::InitContainers() for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) { FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); fParCList->Remove(tempObj); - std::string paramName {tempObj->GetName()}; + std::string paramName{tempObj->GetName()}; // 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 @@ -157,8 +153,8 @@ Bool_t CbmDeviceMonitorPsd::InitContainers() std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -217,7 +213,7 @@ Bool_t CbmDeviceMonitorPsd::InitContainers() fvpsHistosFolder.push_back(psHistoConfig); /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, psHistoConfig); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, psHistoConfig); @@ -244,7 +240,7 @@ Bool_t CbmDeviceMonitorPsd::InitContainers() fvpsCanvasConfig.push_back(psCanvConfig); /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, psCanvConfig); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, psCanvConfig); @@ -262,7 +258,7 @@ Bool_t CbmDeviceMonitorPsd::InitContainers() // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceMonitorPsd::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceMonitorPsd::HandleData(fair::mq::MessagePtr& msg, int /*index*/) { fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with size " << msg->GetSize(); @@ -274,7 +270,7 @@ bool CbmDeviceMonitorPsd::HandleData(FairMQMessagePtr& msg, int /*index*/) boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; /// Process the Timeslice @@ -297,7 +293,7 @@ bool CbmDeviceMonitorPsd::HandleData(FairMQMessagePtr& msg, int /*index*/) bool CbmDeviceMonitorPsd::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/monitor/CbmDeviceMonitorPsd.h b/MQ/monitor/CbmDeviceMonitorPsd.h index dc9e8413cab7897ac3aed378962882692ed1ac4a..c54d48c98a2b0baba0547affe7d70c3fa3f9fc0c 100644 --- a/MQ/monitor/CbmDeviceMonitorPsd.h +++ b/MQ/monitor/CbmDeviceMonitorPsd.h @@ -14,13 +14,10 @@ #define CBMDEVICEMONITORPSD_H_ #include "CbmMqTMessage.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <chrono> #include <map> @@ -29,16 +26,16 @@ class TList; class CbmMcbm2018MonitorAlgoPsd; -class CbmDeviceMonitorPsd : public FairMQDevice { -public: +class CbmDeviceMonitorPsd : public fair::mq::Device { + public: CbmDeviceMonitorPsd(); virtual ~CbmDeviceMonitorPsd(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQMessagePtr&, int); + bool HandleData(fair::mq::MessagePtr&, int); -private: + private: /// Constants static const uint16_t kusSysId = 0x80; Bool_t fbComponentsAddedToList = kFALSE; diff --git a/MQ/monitor/CbmDeviceMonitorReqBmon.cxx b/MQ/monitor/CbmDeviceMonitorReqBmon.cxx index 93aba473b5f608d7f72fe0771539180a7cabc2bf..be2ebfb06026001782cc89d03d1d03f373f6124d 100644 --- a/MQ/monitor/CbmDeviceMonitorReqBmon.cxx +++ b/MQ/monitor/CbmDeviceMonitorReqBmon.cxx @@ -4,22 +4,20 @@ #include "CbmDeviceMonitorReqBmon.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" #include "CbmMcbm2018MonitorAlgoBmon.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -27,8 +25,6 @@ #include <iomanip> #include <stdexcept> #include <string> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -36,7 +32,7 @@ struct InitTaskError : std::runtime_error { using namespace std; -CbmDeviceMonitorReqBmon::CbmDeviceMonitorReqBmon() : fMonitorAlgo {new CbmMcbm2018MonitorAlgoBmon()} {} +CbmDeviceMonitorReqBmon::CbmDeviceMonitorReqBmon() : fMonitorAlgo{new CbmMcbm2018MonitorAlgoBmon()} {} void CbmDeviceMonitorReqBmon::InitTask() try { @@ -96,7 +92,7 @@ bool CbmDeviceMonitorReqBmon::InitContainers() for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) { FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); fParCList->Remove(tempObj); - std::string paramName {tempObj->GetName()}; + std::string paramName{tempObj->GetName()}; // 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 @@ -104,8 +100,8 @@ bool CbmDeviceMonitorReqBmon::InitContainers() std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -196,8 +192,8 @@ bool CbmDeviceMonitorReqBmon::ConditionalRun() std::string message = fsTsBlockName; if ("" == message) message = std::to_string(kusSysId); LOG(debug) << "Requesting new TS by sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, fsChannelNameDataInput) <= 0) { LOG(error) << "Failed to send the request! message was " << message; @@ -235,7 +231,7 @@ bool CbmDeviceMonitorReqBmon::ConditionalRun() boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; /// Process the Timeslice @@ -265,16 +261,16 @@ bool CbmDeviceMonitorReqBmon::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); partsOut.AddPart(std::move(messageHist)); @@ -282,14 +278,14 @@ bool CbmDeviceMonitorReqBmon::SendHistoConfAndData() for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); partsOut.AddPart(std::move(messageCan)); } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); @@ -310,7 +306,7 @@ bool CbmDeviceMonitorReqBmon::SendHistoConfAndData() bool CbmDeviceMonitorReqBmon::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/monitor/CbmDeviceMonitorReqBmon.h b/MQ/monitor/CbmDeviceMonitorReqBmon.h index 24040b4319f0ff30ac5b80d9b80b5c6e87b7aae2..2cad03b30be46a7cfea32b7358ff995f7e458078 100644 --- a/MQ/monitor/CbmDeviceMonitorReqBmon.h +++ b/MQ/monitor/CbmDeviceMonitorReqBmon.h @@ -6,13 +6,10 @@ #define CBMDEVICEMONITORREQBmon_H_ #include "CbmMqTMessage.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <chrono> #include <map> @@ -21,16 +18,16 @@ class TList; class CbmMcbm2018MonitorAlgoBmon; -class CbmDeviceMonitorReqBmon : public FairMQDevice { -public: +class CbmDeviceMonitorReqBmon : public fair::mq::Device { + public: CbmDeviceMonitorReqBmon(); virtual ~CbmDeviceMonitorReqBmon(); -protected: + protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: /// Constants static const uint16_t kusSysId = 0x90; diff --git a/MQ/monitor/CbmDeviceMonitorReqTof.cxx b/MQ/monitor/CbmDeviceMonitorReqTof.cxx index 6a0863cda0842eb9a7f74eaec7bc3db186ab066a..5b1d89b4ad87ec0a0d5bdc0069c63b7e2eb7899f 100644 --- a/MQ/monitor/CbmDeviceMonitorReqTof.cxx +++ b/MQ/monitor/CbmDeviceMonitorReqTof.cxx @@ -4,23 +4,21 @@ #include "CbmDeviceMonitorReqTof.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" #include "CbmMQDefs.h" #include "CbmMcbm2018MonitorAlgoTof.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -28,15 +26,13 @@ #include <iomanip> #include <stdexcept> #include <string> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; using namespace std; -CbmDeviceMonitorReqTof::CbmDeviceMonitorReqTof() : fMonitorAlgo {new CbmMcbm2018MonitorAlgoTof()} {} +CbmDeviceMonitorReqTof::CbmDeviceMonitorReqTof() : fMonitorAlgo{new CbmMcbm2018MonitorAlgoTof()} {} void CbmDeviceMonitorReqTof::InitTask() try { @@ -80,7 +76,7 @@ Bool_t CbmDeviceMonitorReqTof::InitContainers() for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) { FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); fParCList->Remove(tempObj); - std::string paramName {tempObj->GetName()}; + std::string paramName{tempObj->GetName()}; // 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 @@ -88,8 +84,8 @@ Bool_t CbmDeviceMonitorReqTof::InitContainers() std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -175,8 +171,8 @@ bool CbmDeviceMonitorReqTof::ConditionalRun() std::string message = fsTsBlockName; if ("" == message) message = std::to_string(kusSysIdTof); LOG(debug) << "Requesting new TS by sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, fsChannelNameDataInput) <= 0) { LOG(error) << "Failed to send the request! message was " << message; @@ -215,7 +211,7 @@ bool CbmDeviceMonitorReqTof::ConditionalRun() boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; /// Process the Timeslice @@ -245,16 +241,16 @@ bool CbmDeviceMonitorReqTof::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); @@ -263,7 +259,7 @@ bool CbmDeviceMonitorReqTof::SendHistoConfAndData() for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); @@ -271,7 +267,7 @@ bool CbmDeviceMonitorReqTof::SendHistoConfAndData() } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); @@ -292,7 +288,7 @@ bool CbmDeviceMonitorReqTof::SendHistoConfAndData() bool CbmDeviceMonitorReqTof::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/monitor/CbmDeviceMonitorReqTof.h b/MQ/monitor/CbmDeviceMonitorReqTof.h index 9c9099074b9fa2000854d8e5c41c349546f3bedd..857bab38ad6e35ee67475cee74ea89f7598f290e 100644 --- a/MQ/monitor/CbmDeviceMonitorReqTof.h +++ b/MQ/monitor/CbmDeviceMonitorReqTof.h @@ -6,13 +6,10 @@ #define CBMDEVICEMONITORREQTOF_H_ #include "CbmMqTMessage.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <chrono> #include <map> @@ -21,18 +18,18 @@ class TList; class CbmMcbm2018MonitorAlgoTof; -class CbmDeviceMonitorReqTof : public FairMQDevice { -public: +class CbmDeviceMonitorReqTof : public fair::mq::Device { + public: CbmDeviceMonitorReqTof(); virtual ~CbmDeviceMonitorReqTof(); -protected: + protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: /// Constants - static const uint16_t kusSysIdTof = 0x60; + static const uint16_t kusSysIdTof = 0x60; static const uint16_t kusSysIdBmon = 0x90; /// Control flags diff --git a/MQ/monitor/CbmDeviceMonitorTof.cxx b/MQ/monitor/CbmDeviceMonitorTof.cxx index e087f7d5e62c2a22448ba2395a5f87363b4fd675..0dddec417205cf572e4981d8b00f340e8a5f7522 100644 --- a/MQ/monitor/CbmDeviceMonitorTof.cxx +++ b/MQ/monitor/CbmDeviceMonitorTof.cxx @@ -11,23 +11,21 @@ #include "CbmDeviceMonitorTof.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" #include "CbmMQDefs.h" #include "CbmMcbm2018MonitorAlgoTof.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -35,15 +33,13 @@ #include <iomanip> #include <stdexcept> #include <string> - -#include "RootSerializer.h" struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; using namespace std; -CbmDeviceMonitorTof::CbmDeviceMonitorTof() : fMonitorAlgo {new CbmMcbm2018MonitorAlgoTof()} {} +CbmDeviceMonitorTof::CbmDeviceMonitorTof() : fMonitorAlgo{new CbmMcbm2018MonitorAlgoTof()} {} void CbmDeviceMonitorTof::InitTask() try { @@ -58,12 +54,12 @@ try { fuMaxTotPulser = fConfig->GetValue<uint32_t>("PulsTotMax"); fiGdpbIndex = fConfig->GetValue<int32_t>("GdpbIdx"); - fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs"); - fdMinPublishTime = fConfig->GetValue<double_t>("PubTimeMin"); - fdMaxPublishTime = fConfig->GetValue<double_t>("PubTimeMax"); - fsChannelNameDataInput = fConfig->GetValue<std::string>("TsNameIn"); - fsChannelNameHistosInput = fConfig->GetValue<std::string>("ChNameIn"); - fsAllowedChannels[0] = fsChannelNameDataInput; + fuPublishFreqTs = fConfig->GetValue<uint32_t>("PubFreqTs"); + fdMinPublishTime = fConfig->GetValue<double_t>("PubTimeMin"); + fdMaxPublishTime = fConfig->GetValue<double_t>("PubTimeMax"); + fsChannelNameDataInput = fConfig->GetValue<std::string>("TsNameIn"); + fsChannelNameHistosInput = fConfig->GetValue<std::string>("ChNameIn"); + fsAllowedChannels[0] = fsChannelNameDataInput; LOG(info) << "Histograms publication frequency in TS: " << fuPublishFreqTs; LOG(info) << "Histograms publication min. interval in s: " << fdMinPublishTime; @@ -82,15 +78,15 @@ try { // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (std::string::npos != entry.first.find(fsChannelNameDataInput)) { if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmDeviceMonitorTof::HandleData); } // if( std::string::npos != entry.first.find( fsChannelNameDataInput ) ) - } // for( auto const &entry : fChannels ) + } // for( auto const &entry : GetChannels() ) } catch (InitTaskError& e) { LOG(error) << e.what(); @@ -125,7 +121,7 @@ Bool_t CbmDeviceMonitorTof::InitContainers() for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) { FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); fParCList->Remove(tempObj); - std::string paramName {tempObj->GetName()}; + std::string paramName{tempObj->GetName()}; // 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 @@ -133,8 +129,8 @@ Bool_t CbmDeviceMonitorTof::InitContainers() std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -215,7 +211,7 @@ bool CbmDeviceMonitorTof::InitHistograms() // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceMonitorTof::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceMonitorTof::HandleData(fair::mq::MessagePtr& msg, int /*index*/) { if (0 == fulNumMessages) { try { @@ -239,7 +235,7 @@ bool CbmDeviceMonitorTof::HandleData(FairMQMessagePtr& msg, int /*index*/) boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; /// Process the Timeslice @@ -269,16 +265,16 @@ bool CbmDeviceMonitorTof::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); @@ -287,7 +283,7 @@ bool CbmDeviceMonitorTof::SendHistoConfAndData() for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); @@ -295,7 +291,7 @@ bool CbmDeviceMonitorTof::SendHistoConfAndData() } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); @@ -316,7 +312,7 @@ bool CbmDeviceMonitorTof::SendHistoConfAndData() bool CbmDeviceMonitorTof::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/monitor/CbmDeviceMonitorTof.h b/MQ/monitor/CbmDeviceMonitorTof.h index 7a174c4d3ba1b4ab043ad23739250619fa55bddf..d4f28539f3aeb9748e61fbf3441ac45ef485366a 100644 --- a/MQ/monitor/CbmDeviceMonitorTof.h +++ b/MQ/monitor/CbmDeviceMonitorTof.h @@ -13,13 +13,10 @@ #define CBMDEVICEMONITORTOF_H_ #include "CbmMqTMessage.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <chrono> #include <map> @@ -28,18 +25,18 @@ class TList; class CbmMcbm2018MonitorAlgoTof; -class CbmDeviceMonitorTof : public FairMQDevice { -public: +class CbmDeviceMonitorTof : public fair::mq::Device { + public: CbmDeviceMonitorTof(); virtual ~CbmDeviceMonitorTof(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQMessagePtr&, int); + bool HandleData(fair::mq::MessagePtr&, int); -private: + private: /// Constants - static const uint16_t kusSysIdTof = 0x60; + static const uint16_t kusSysIdTof = 0x60; static const uint16_t kusSysIdBmon = 0x90; /// Control flags @@ -49,15 +46,15 @@ private: Bool_t fbComponentsAddedToList = kFALSE; /// User settings parameters - std::string fsChannelNameDataInput = "tofcomponent"; - std::string fsChannelNameHistosInput = "histogram-in"; - uint32_t fuHistoryHistoSize = 3600; - uint32_t fuMinTotPulser = 185; - uint32_t fuMaxTotPulser = 195; - int32_t fiGdpbIndex = -1; - uint32_t fuPublishFreqTs = 100; - double_t fdMinPublishTime = 0.5; - double_t fdMaxPublishTime = 5.0; + std::string fsChannelNameDataInput = "tofcomponent"; + std::string fsChannelNameHistosInput = "histogram-in"; + uint32_t fuHistoryHistoSize = 3600; + uint32_t fuMinTotPulser = 185; + uint32_t fuMaxTotPulser = 195; + int32_t fiGdpbIndex = -1; + uint32_t fuPublishFreqTs = 100; + double_t fdMinPublishTime = 0.5; + double_t fdMaxPublishTime = 5.0; /// List of MQ channels names std::vector<std::string> fsAllowedChannels = {fsChannelNameDataInput}; diff --git a/MQ/monitor/runMonitorBmon.cxx b/MQ/monitor/runMonitorBmon.cxx index 240419241d0aea38ada9e7b90a2474ed4ce589e5..77f004857be05b768ab7ae05156c2e733a7338ed 100644 --- a/MQ/monitor/runMonitorBmon.cxx +++ b/MQ/monitor/runMonitorBmon.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau, Florian Uhlig [committer] */ #include "CbmDeviceMonitorBmon.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -37,4 +36,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMonitorBmon(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMonitorBmon(); } diff --git a/MQ/monitor/runMonitorPsd.cxx b/MQ/monitor/runMonitorPsd.cxx index cb07240ae68382d4a1477d642b71833a1fd145d4..e50cb0e22a54b6b13be99347f4ed2349e03b326e 100644 --- a/MQ/monitor/runMonitorPsd.cxx +++ b/MQ/monitor/runMonitorPsd.cxx @@ -3,12 +3,11 @@ Authors: Nikolay Karpushkin [committer] */ #include "CbmDeviceMonitorPsd.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -39,4 +38,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for canvases config"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMonitorPsd(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMonitorPsd(); } diff --git a/MQ/monitor/runMonitorReqBmon.cxx b/MQ/monitor/runMonitorReqBmon.cxx index 7a1b6267d84947c6a359e26739034d1465fbf3a3..3dc356924f908f184eaac444aca1781b1c8da78c 100644 --- a/MQ/monitor/runMonitorReqBmon.cxx +++ b/MQ/monitor/runMonitorReqBmon.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceMonitorReqBmon.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -39,4 +38,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMonitorReqBmon(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMonitorReqBmon(); } diff --git a/MQ/monitor/runMonitorReqTof.cxx b/MQ/monitor/runMonitorReqTof.cxx index cc0a5ed50aaf11436fc36aa9a17db2e9a2aac3d7..c91c4bf07e033dca6726a383ce06c7cb5ac13007 100644 --- a/MQ/monitor/runMonitorReqTof.cxx +++ b/MQ/monitor/runMonitorReqTof.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceMonitorReqTof.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -36,4 +35,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMonitorReqTof(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMonitorReqTof(); } diff --git a/MQ/monitor/runMonitorTof.cxx b/MQ/monitor/runMonitorTof.cxx index 985fbfff92b086274e2a85569fb7ba0a65b24531..e6e942fb5ae7004a09df0112d68698d5a83f9460 100644 --- a/MQ/monitor/runMonitorTof.cxx +++ b/MQ/monitor/runMonitorTof.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmDeviceMonitorTof.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -34,4 +33,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDeviceMonitorTof(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceMonitorTof(); } diff --git a/MQ/parmq/ParameterMQServer.cxx b/MQ/parmq/ParameterMQServer.cxx index 8703861ca11f2ead02b2c07ca4bff70faa90a18d..78e3e86232d97f75746c53ec387833346c6f2ca5 100644 --- a/MQ/parmq/ParameterMQServer.cxx +++ b/MQ/parmq/ParameterMQServer.cxx @@ -16,14 +16,12 @@ #include "CbmMQDefs.h" #include "CbmSetup.h" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" #include "FairParAsciiFileIo.h" #include "FairParGenericSet.h" #include "FairParRootFileIo.h" #include "FairRuntimeDb.h" - #include "Rtypes.h" #include "TGeoManager.h" #include "TList.h" @@ -33,10 +31,7 @@ using namespace std; -ParameterMQServer::ParameterMQServer() - : fRtdb(FairRuntimeDb::instance()) -{ -} +ParameterMQServer::ParameterMQServer() : fRtdb(FairRuntimeDb::instance()) {} void ParameterMQServer::InitTask() { @@ -159,7 +154,7 @@ void ParameterMQServer::Run() FairParGenericSet* par = nullptr; while (cbm::mq::CheckCurrentState(this, cbm::mq::State::Running)) { - FairMQMessagePtr req(NewMessage()); + fair::mq::MessagePtr req(NewMessage()); if (Receive(req, fChannelName, 0) > 0) { string reqStr(static_cast<char*>(req->GetData()), req->GetSize()); @@ -174,7 +169,7 @@ void ParameterMQServer::Run() TMessage* tmsg = new TMessage(kMESS_OBJECT); tmsg->WriteObject(&exchangableSetup); - FairMQMessagePtr rep(NewMessage( + fair::mq::MessagePtr rep(NewMessage( tmsg->Buffer(), tmsg->BufferSize(), [](void* /*data*/, void* object) { delete static_cast<TMessage*>(object); }, tmsg)); @@ -186,7 +181,7 @@ void ParameterMQServer::Run() else { LOG(error) << "CbmSetup uninitialized!"; // Send an empty message back to keep the REQ/REP cycle - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr rep(NewMessage()); if (Send(rep, fChannelName, 0) < 0) { LOG(error) << "failed sending reply to Setup request"; break; @@ -208,7 +203,9 @@ void ParameterMQServer::Run() } LOG(info) << "Retrieving parameter...Done"; - if (-1 != runId) { fRtdb->initContainers(runId); } + if (-1 != runId) { + fRtdb->initContainers(runId); + } LOG(info) << "Sending following parameter to the client:"; if (par) { @@ -217,7 +214,7 @@ void ParameterMQServer::Run() TMessage* tmsg = new TMessage(kMESS_OBJECT); tmsg->WriteObject(par); - FairMQMessagePtr rep(NewMessage( + fair::mq::MessagePtr rep(NewMessage( tmsg->Buffer(), tmsg->BufferSize(), [](void* /*data*/, void* object) { delete static_cast<TMessage*>(object); }, tmsg)); @@ -229,7 +226,7 @@ void ParameterMQServer::Run() else { LOG(error) << "Parameter uninitialized!"; // Send an empty message back to keep the REQ/REP cycle - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr rep(NewMessage()); if (Send(rep, fChannelName, 0) < 0) { LOG(error) << "failed sending reply"; break; diff --git a/MQ/parmq/ParameterMQServer.h b/MQ/parmq/ParameterMQServer.h index 949b293e08e5ceab0462b558bc09007afe8e86ee..b7aeabce49ed3a80e44f221716c8a50c647d2de0 100644 --- a/MQ/parmq/ParameterMQServer.h +++ b/MQ/parmq/ParameterMQServer.h @@ -22,8 +22,8 @@ class FairRuntimeDb; class CbmSetup; -class ParameterMQServer : public FairMQDevice { -public: +class ParameterMQServer : public fair::mq::Device { + public: ParameterMQServer(); ParameterMQServer(const ParameterMQServer&) = delete; @@ -50,7 +50,7 @@ public: void SetChannelName(const std::string& channelName) { fChannelName = channelName; } std::string GetChannelName() { return fChannelName; } -private: + private: FairRuntimeDb* fRtdb = nullptr; CbmSetup* fSetup = nullptr; diff --git a/MQ/parmq/runParameterMQServer.cxx b/MQ/parmq/runParameterMQServer.cxx index e9d58b2a60517e2306ff77125f36cd52ab179ea7..34a4329c83f695f8ca706695b16496e9650f6ba4 100644 --- a/MQ/parmq/runParameterMQServer.cxx +++ b/MQ/parmq/runParameterMQServer.cxx @@ -38,4 +38,4 @@ void addCustomOptions(bpo::options_description& options) options.add_options()("setup", bpo::value<std::string>()->default_value(""), "Name/tag of the geomatry setup"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new ParameterMQServer(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new ParameterMQServer(); } diff --git a/MQ/sink/CbmDevNullSink.cxx b/MQ/sink/CbmDevNullSink.cxx index 35ece92be3c725dcf443d5b0f7202b97e8086925..904cb16b08b17bd8150394fa62f700fe6efd7e61 100644 --- a/MQ/sink/CbmDevNullSink.cxx +++ b/MQ/sink/CbmDevNullSink.cxx @@ -16,23 +16,23 @@ using namespace std; -CbmDevNullSink::CbmDevNullSink() : FairMQDevice {}, fNumMessages {0} {} +CbmDevNullSink::CbmDevNullSink() : FairMQDevice{}, fNumMessages{0} {} void CbmDevNullSink::Init() {} void CbmDevNullSink::InitTask() { // register a handler for data arriving on any channel - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined input channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; OnData(entry.first, &CbmDevNullSink::HandleData); } } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDevNullSink::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool CbmDevNullSink::HandleData(fair::mq::MessagePtr& msg, int /*index*/) { // Don't do anything with the data // Maybe add an message counter which counts the incomming messages and add diff --git a/MQ/sink/CbmDevNullSink.h b/MQ/sink/CbmDevNullSink.h index 9e8f0e9bdf5fe739e97f552e6b2511f7ec57cd54..aceda587a0851f85e4b795659064c9f26663f99e 100644 --- a/MQ/sink/CbmDevNullSink.h +++ b/MQ/sink/CbmDevNullSink.h @@ -14,17 +14,17 @@ #include "FairMQDevice.h" -class CbmDevNullSink : public FairMQDevice { -public: +class CbmDevNullSink : public fair::mq::Device { + public: CbmDevNullSink(); virtual ~CbmDevNullSink(); -protected: + protected: virtual void InitTask(); virtual void Init(); - bool HandleData(FairMQMessagePtr&, int); + bool HandleData(fair::mq::MessagePtr&, int); -private: + private: uint64_t fNumMessages; }; diff --git a/MQ/sink/CbmTsaComponentSink.cxx b/MQ/sink/CbmTsaComponentSink.cxx index a05c0344b1cc3ab90d5332afcc819e153fb447c5..a05e2b1624c735a64a769d723c6c627175aa94e7 100644 --- a/MQ/sink/CbmTsaComponentSink.cxx +++ b/MQ/sink/CbmTsaComponentSink.cxx @@ -12,11 +12,9 @@ #include "CbmTsaComponentSink.h" #include "CbmMQDefs.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig +#include "StorableTimeslice.hpp" #include <boost/archive/binary_iarchive.hpp> @@ -40,9 +38,9 @@ try { // 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. - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined input channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); OnData(entry.first, &CbmTsaComponentSink::HandleData); @@ -75,7 +73,7 @@ bool CbmTsaComponentSink::IsChannelNameAllowed(std::string channelName) // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmTsaComponentSink::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool CbmTsaComponentSink::HandleData(fair::mq::MessagePtr& msg, int /*index*/) { // Don't do anything with the data // Maybe add an message counter which counts the incomming messages and add @@ -87,7 +85,7 @@ bool CbmTsaComponentSink::HandleData(FairMQMessagePtr& msg, int /*index*/) std::istringstream iss(msgStr); boost::archive::binary_iarchive inputArchive(iss); - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; CheckTimeslice(component); diff --git a/MQ/sink/CbmTsaComponentSink.h b/MQ/sink/CbmTsaComponentSink.h index d7d0aa2a90d6e89b726bac8e0d9621438c050a4a..93d026b60832fc7a9b3835af05c73bda7a51277c 100644 --- a/MQ/sink/CbmTsaComponentSink.h +++ b/MQ/sink/CbmTsaComponentSink.h @@ -12,21 +12,20 @@ #ifndef CBMTSACOMPONENTSINK_H_ #define CBMTSACOMPONENTSINK_H_ +#include "FairMQDevice.h" #include "MicrosliceDescriptor.hpp" #include "Timeslice.hpp" -#include "FairMQDevice.h" - -class CbmTsaComponentSink : public FairMQDevice { -public: +class CbmTsaComponentSink : public fair::mq::Device { + public: CbmTsaComponentSink(); virtual ~CbmTsaComponentSink(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQMessagePtr&, int); + bool HandleData(fair::mq::MessagePtr&, int); -private: + private: uint64_t fNumMessages; std::vector<std::string> fAllowedChannels = {"stscomponent", "tofcomponent", "trdcomponent"}; diff --git a/MQ/sink/runDevNullSink.cxx b/MQ/sink/runDevNullSink.cxx index 6ef22271a5d26f872faf556ef26f0456a342cd6a..199aa7b9c6cd3404a065402814e363bb5f5462d3 100644 --- a/MQ/sink/runDevNullSink.cxx +++ b/MQ/sink/runDevNullSink.cxx @@ -3,7 +3,6 @@ Authors: Florian Uhlig [committer] */ #include "CbmDevNullSink.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; @@ -14,4 +13,4 @@ void addCustomOptions(bpo::options_description& /*options*/) // ("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDevNullSink(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDevNullSink(); } diff --git a/MQ/sink/runTsaComponentSink.cxx b/MQ/sink/runTsaComponentSink.cxx index 43df1af2b1a05b3c4f0073cbfbdd7cdb3b6024eb..a93011889a198770e80bbc6e5980d5bd06f73113 100644 --- a/MQ/sink/runTsaComponentSink.cxx +++ b/MQ/sink/runTsaComponentSink.cxx @@ -3,11 +3,10 @@ Authors: Florian Uhlig [committer] */ #include "CbmTsaComponentSink.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; void addCustomOptions(bpo::options_description& /*options*/) {} -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmTsaComponentSink(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmTsaComponentSink(); } diff --git a/MQ/source/CbmMQTsSamplerRepReq.cxx b/MQ/source/CbmMQTsSamplerRepReq.cxx index b8fa2f6a50d5054312ff9f37615e20f4e78fab55..c81ec85c2f4e86505403d9b61abf56fd37228ee1 100644 --- a/MQ/source/CbmMQTsSamplerRepReq.cxx +++ b/MQ/source/CbmMQTsSamplerRepReq.cxx @@ -4,41 +4,38 @@ #include "CbmMQTsSamplerRepReq.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" #include "CbmFormatDecHexPrintout.h" - +#include "FairMQLogger.h" +#include "FairMQProgOptions.h" // device->fConfig #include "TimesliceInputArchive.hpp" #include "TimesliceMultiInputArchive.hpp" #include "TimesliceMultiSubscriber.hpp" #include "TimesliceSubscriber.hpp" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig - #include <TCanvas.h> #include <TH1F.h> #include <TH1I.h> #include <TProfile.h> -#include "BoostSerializer.h" #include <boost/algorithm/string.hpp> #include <boost/archive/binary_oarchive.hpp> //#include <boost/filesystem.hpp> +#include "RootSerializer.h" + #include <boost/regex.hpp> #include <boost/serialization/utility.hpp> -#include "RootSerializer.h" - //namespace filesys = boost::filesystem; -#include <thread> // this_thread::sleep_for - #include <algorithm> #include <chrono> #include <ctime> #include <iomanip> #include <sstream> #include <string> +#include <thread> // this_thread::sleep_for #include <stdio.h> @@ -51,9 +48,9 @@ struct InitTaskError : std::runtime_error { }; CbmMQTsSamplerRepReq::CbmMQTsSamplerRepReq() - : FairMQDevice() + : fair::mq::Device() , fTime() - , fLastPublishTime {std::chrono::system_clock::now()} + , fLastPublishTime{std::chrono::system_clock::now()} { } @@ -128,7 +125,8 @@ try { std::string sSysId = vSysIdBlockPairs[uPair].substr(sep + 1); const size_t hexPos = sSysId.find("0x"); uint16_t usSysId; - if (string::npos == hexPos) usSysId = std::stoi(sSysId); + if (string::npos == hexPos) + usSysId = std::stoi(sSysId); else usSysId = std::stoi(sSysId.substr(hexPos + 2), nullptr, 16); @@ -137,8 +135,11 @@ try { /// Check if SysId already in use uint32_t uSysIdIdx = 0; - for (; uSysIdIdx < fSysId.size() && fSysId[uSysIdIdx] != usSysId; ++uSysIdIdx) {} - if (uSysIdIdx == fSysId.size()) { throw InitTaskError("Unknown System ID for " + vSysIdBlockPairs[uPair]); } + for (; uSysIdIdx < fSysId.size() && fSysId[uSysIdIdx] != usSysId; ++uSysIdIdx) { + } + if (uSysIdIdx == fSysId.size()) { + throw InitTaskError("Unknown System ID for " + vSysIdBlockPairs[uPair]); + } else if (true == fComponentActive[uSysIdIdx]) { throw InitTaskError("System ID already in use by another block for " + vSysIdBlockPairs[uPair]); } @@ -170,7 +171,7 @@ try { // filename && ! dirname : single file // filename with wildcards && dirname : all files with filename regex in the directory // host && port : connect to the flesnet server - bool isGoodInputCombi {false}; + bool isGoodInputCombi{false}; if (0 != fsFileName.size() && 0 == fsDirName.size() && 0 == fsHost.size() && 0 == fusPort) { isGoodInputCombi = true; fvsInputFileList.push_back(fsFileName); @@ -213,7 +214,7 @@ try { } else { // Create a ";" separated string with all file names - std::string fileList {""}; + std::string fileList{""}; for (const auto& obj : fvsInputFileList) { std::string fileName = obj; fileList += fileName; @@ -222,12 +223,16 @@ try { fileList.pop_back(); // Remove the last ; LOG(info) << "Input File String: " << fileList; fSource = new fles::TimesliceMultiInputArchive(fileList, fsDirName); - if (!fSource) { throw InitTaskError("Could open files from file list."); } + if (!fSource) { + throw InitTaskError("Could open files from file list."); + } } LOG(info) << "High-Water Mark: " << fulHighWaterMark; LOG(info) << "Max. Timeslices: " << fulMaxTimeslices; - if (fbNoSplitTs) { LOG(info) << "Sending TS copies in no-split mode"; } // if( fbNoSplitTs ) + if (fbNoSplitTs) { + LOG(info) << "Sending TS copies in no-split mode"; + } // if( fbNoSplitTs ) else if (fbSendTsPerSysId) { LOG(info) << "Sending components in separate TS per SysId"; } // else if( fbSendTsPerSysId ) of if( fbNoSplitTs ) @@ -368,10 +373,12 @@ bool CbmMQTsSamplerRepReq::InitHistograms() return true; } -bool CbmMQTsSamplerRepReq::HandleRequest(FairMQMessagePtr& msgReq, int) +bool CbmMQTsSamplerRepReq::HandleRequest(fair::mq::MessagePtr& msgReq, int) { /// Initialize the histograms - if (0 < fuPublishFreqTs && 0 == fulTsCounter) { InitHistograms(); } // if( 0 < fuPublishFreqTs ) + if (0 < fuPublishFreqTs && 0 == fulTsCounter) { + InitHistograms(); + } // if( 0 < fuPublishFreqTs ) if (fbEofFound) { /// Ignore all requests if EOS reached @@ -551,7 +558,9 @@ std::unique_ptr<fles::Timeslice> CbmMQTsSamplerRepReq::GetNewTs() fulTsCounter++; fulPrevTsIndex = uTsIndex; - if (fulTsCounter % 10000 == 0) { LOG(info) << "Received TS " << fulTsCounter << " with index " << uTsIndex; } + if (fulTsCounter % 10000 == 0) { + LOG(info) << "Received TS " << fulTsCounter << " with index " << uTsIndex; + } LOG(debug) << "Found " << ts.num_components() << " different components in timeslice"; return timeslice; @@ -574,7 +583,7 @@ std::unique_ptr<fles::Timeslice> CbmMQTsSamplerRepReq::GetNewTs() return nullptr; } // else of if (fulTsCounter < fulMaxTimeslices) - } // if (timeslice) + } // if (timeslice) else { CalcRuntime(); @@ -612,7 +621,9 @@ bool CbmMQTsSamplerRepReq::AddNewTsInBuffer() /// Now that we got the TS, we can add the corresponding list of "Sent" flags, /// with the proper dimension - if (fbSendTsPerBlock) { fdbCompSentFlags.push_back(std::vector<bool>(fvBlocksToSend.size(), false)); } + if (fbSendTsPerBlock) { + fdbCompSentFlags.push_back(std::vector<bool>(fvBlocksToSend.size(), false)); + } else { fdbCompSentFlags.push_back(std::vector<bool>(fComponentActive.size(), false)); } @@ -625,7 +636,7 @@ bool CbmMQTsSamplerRepReq::CreateAndSendFullTs() if (timeslice) { /// Send full TS as response to the request const fles::Timeslice& ts = *timeslice; - fles::StorableTimeslice fullTs {ts}; + fles::StorableTimeslice fullTs{ts}; if (!SendData(fullTs)) { /// If command channel defined, send command to all "slaves" if ("" != fsChannelNameCommands) { @@ -735,8 +746,8 @@ bool CbmMQTsSamplerRepReq::CreateCombinedComponentsPerSysId(uint uCompIndex) } // if( fdpTimesliceBuffer.size() == uTsIndex ) /// Prepare the custom TS and send it - fles::StorableTimeslice component {static_cast<uint32_t>(fdpTimesliceBuffer[uTsIndex]->num_core_microslices()), - fdpTimesliceBuffer[uTsIndex]->index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(fdpTimesliceBuffer[uTsIndex]->num_core_microslices()), + fdpTimesliceBuffer[uTsIndex]->index()}; for (uint32_t uComp = 0; uComp < fvvCompPerSysId[uCompIndex].size(); ++uComp) { uint32_t uNumMsInComp = fdpTimesliceBuffer[uTsIndex]->num_microslices(fvvCompPerSysId[uCompIndex][uComp]); @@ -822,8 +833,8 @@ bool CbmMQTsSamplerRepReq::CreateCombinedComponentsPerBlock(std::string sBlockNa } // if( fdpTimesliceBuffer.size() == uTsIndex ) /// Prepare the custom TS and send it - fles::StorableTimeslice component {static_cast<uint32_t>(fdpTimesliceBuffer[uTsIndex]->num_core_microslices()), - fdpTimesliceBuffer[uTsIndex]->index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(fdpTimesliceBuffer[uTsIndex]->num_core_microslices()), + fdpTimesliceBuffer[uTsIndex]->index()}; for (uint32_t uComp = 0; uComp < fvvCompPerBlock[uBlockIdx].size(); ++uComp) { uint32_t uNumMsInComp = fdpTimesliceBuffer[uTsIndex]->num_microslices(fvvCompPerBlock[uBlockIdx][uComp]); @@ -864,7 +875,7 @@ bool CbmMQTsSamplerRepReq::SendFirstTsIndex() oa << sIndex; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -892,7 +903,7 @@ bool CbmMQTsSamplerRepReq::SendData(const fles::StorableTimeslice& component) oa << component; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -920,7 +931,7 @@ bool CbmMQTsSamplerRepReq::SendMissedTsIdx(std::vector<uint64_t> vIndices) oa << vIndices; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -946,13 +957,13 @@ bool CbmMQTsSamplerRepReq::SendCommand(std::string sCommand) oa << sCommand; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, strMsg)); // object that manages the data - // FairMQMessagePtr msg( NewMessage( const_cast<char*>( sCommand.c_str() ), // data + // fair::mq::MessagePtr msg( NewMessage( const_cast<char*>( sCommand.c_str() ), // data // sCommand.length(), // size // []( void* /*data*/, void* object ){ delete static_cast< std::string * >( object ); }, // &sCommand ) ); // object that manages the data @@ -973,16 +984,16 @@ bool CbmMQTsSamplerRepReq::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); @@ -992,13 +1003,13 @@ bool CbmMQTsSamplerRepReq::SendHistoConfAndData() /// Catch case where no histos are registered! /// => Add empty message if (0 == fvpsHistosFolder.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); @@ -1008,12 +1019,12 @@ bool CbmMQTsSamplerRepReq::SendHistoConfAndData() /// Catch case where no Canvases are registered! /// => Add empty message if (0 == fvpsCanvasConfig.size()) { - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); partsOut.AddPart(std::move(messageHist)); } /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); @@ -1034,7 +1045,7 @@ bool CbmMQTsSamplerRepReq::SendHistoConfAndData() bool CbmMQTsSamplerRepReq::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/source/CbmMQTsSamplerRepReq.h b/MQ/source/CbmMQTsSamplerRepReq.h index 21d9426148e53595bc0c53a6c1eb797ebf82a075..7cfaeae42512e5005544cf3ee39208012f6854d0 100644 --- a/MQ/source/CbmMQTsSamplerRepReq.h +++ b/MQ/source/CbmMQTsSamplerRepReq.h @@ -14,13 +14,12 @@ #define CBMMQTSSAMPLERREPREQ_H_ +#include "FairMQDevice.h" #include "MicrosliceDescriptor.hpp" #include "StorableTimeslice.hpp" #include "Timeslice.hpp" #include "TimesliceSource.hpp" -#include "FairMQDevice.h" - class TCanvas; class TH1F; class TH1I; @@ -33,12 +32,12 @@ class TProfile; #include <utility> #include <vector> -class CbmMQTsSamplerRepReq : public FairMQDevice { -public: +class CbmMQTsSamplerRepReq : public fair::mq::Device { + public: CbmMQTsSamplerRepReq(); virtual ~CbmMQTsSamplerRepReq(); -protected: + protected: uint64_t fulMaxTimeslices; std::string fsFileName = ""; @@ -66,9 +65,9 @@ protected: uint64_t fulMessageCounter = 0; virtual void InitTask(); - bool HandleRequest(FairMQMessagePtr&, int); + bool HandleRequest(fair::mq::MessagePtr&, int); -private: + private: void CalcRuntime(); bool IsChannelNameAllowed(std::string); diff --git a/MQ/source/CbmMQTsaInfo.cxx b/MQ/source/CbmMQTsaInfo.cxx index f6271cc69833c5f257fc3a6ee48cb01b0d842391..b6ad8c9b35b8e469aa5226167347e92755384cef 100644 --- a/MQ/source/CbmMQTsaInfo.cxx +++ b/MQ/source/CbmMQTsaInfo.cxx @@ -13,19 +13,16 @@ #include "CbmMQTsaInfo.h" #include "CbmMQDefs.h" - -#include "TimesliceInputArchive.hpp" -#include "TimesliceSubscriber.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig - -#include <thread> // this_thread::sleep_for +#include "TimesliceInputArchive.hpp" +#include "TimesliceSubscriber.hpp" #include <boost/archive/binary_oarchive.hpp> #include <chrono> #include <ctime> +#include <thread> // this_thread::sleep_for #include <stdio.h> @@ -39,7 +36,7 @@ struct InitTaskError : std::runtime_error { CbmMQTsaInfo::CbmMQTsaInfo() - : FairMQDevice() + : fair::mq::Device() , fMaxTimeslices(0) , fFileName("") , fInputFileList() @@ -76,9 +73,9 @@ try { // 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. - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined output channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); } @@ -87,16 +84,22 @@ try { std::string connector = "tcp://" + fHost + ":" + std::to_string(fPort); LOG(info) << "Open TSPublisher at " << connector; fSource = new fles::TimesliceSubscriber(connector, 1); - if (!fSource) { throw InitTaskError("Could not connect to publisher."); } + if (!fSource) { + throw InitTaskError("Could not connect to publisher."); + } } else { LOG(info) << "Open the Flib input file " << fFileName; // Check if the input file exist FILE* inputFile = fopen(fFileName.c_str(), "r"); - if (!inputFile) { throw InitTaskError("Input file doesn't exist."); } + if (!inputFile) { + throw InitTaskError("Input file doesn't exist."); + } fclose(inputFile); fSource = new fles::TimesliceInputArchive(fFileName); - if (!fSource) { throw InitTaskError("Could not open input file."); } + if (!fSource) { + throw InitTaskError("Could not open input file."); + } } fTime = std::chrono::steady_clock::now(); } @@ -137,7 +140,9 @@ bool CbmMQTsaInfo::ConditionalRun() CheckTimeslice(ts); - if (fTSCounter < fMaxTimeslices) { return true; } + if (fTSCounter < fMaxTimeslices) { + return true; + } else { CalcRuntime(); return false; diff --git a/MQ/source/CbmMQTsaInfo.h b/MQ/source/CbmMQTsaInfo.h index e87ffb419ee2db2cedcaca3632307d1f8cace92d..b2bb8e02300b8ddeddd68ee432a1a03a40b29993 100644 --- a/MQ/source/CbmMQTsaInfo.h +++ b/MQ/source/CbmMQTsaInfo.h @@ -25,12 +25,12 @@ #include <string> #include <vector> -class CbmMQTsaInfo : public FairMQDevice { -public: +class CbmMQTsaInfo : public fair::mq::Device { + public: CbmMQTsaInfo(); virtual ~CbmMQTsaInfo(); -protected: + protected: uint64_t fMaxTimeslices; std::string fFileName; @@ -48,7 +48,7 @@ protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: bool CheckTimeslice(const fles::Timeslice& ts); void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); bool SendData(const fles::StorableTimeslice& component); diff --git a/MQ/source/CbmMQTsaMultiSampler.cxx b/MQ/source/CbmMQTsaMultiSampler.cxx index d2c45e248ba623a1542000beee32df77965eee95..cbc6b57b6e56737216fd42b15521bbb8cb0d6989 100644 --- a/MQ/source/CbmMQTsaMultiSampler.cxx +++ b/MQ/source/CbmMQTsaMultiSampler.cxx @@ -12,41 +12,38 @@ #include "CbmMQTsaMultiSampler.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" #include "CbmFormatDecHexPrintout.h" - +#include "FairMQLogger.h" +#include "FairMQProgOptions.h" // device->fConfig +#include "RootSerializer.h" +#include "TimesliceAutoSource.hpp" #include "TimesliceInputArchive.hpp" #include "TimesliceMultiInputArchive.hpp" #include "TimesliceMultiSubscriber.hpp" #include "TimesliceSubscriber.hpp" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig - #include <TCanvas.h> #include <TH1F.h> #include <TH1I.h> #include <TProfile.h> -#include "BoostSerializer.h" #include <boost/algorithm/string.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/filesystem.hpp> #include <boost/regex.hpp> #include <boost/serialization/utility.hpp> -#include "RootSerializer.h" - namespace filesys = boost::filesystem; -#include <thread> // this_thread::sleep_for - #include <algorithm> #include <chrono> #include <ctime> #include <iomanip> #include <sstream> #include <string> +#include <thread> // this_thread::sleep_for #include <stdio.h> @@ -72,7 +69,7 @@ CbmMQTsaMultiSampler::CbmMQTsaMultiSampler() , fMessageCounter(0) , fSource(nullptr) , fTime() - , fLastPublishTime {std::chrono::system_clock::now()} + , fLastPublishTime{std::chrono::system_clock::now()} { } @@ -131,7 +128,8 @@ try { std::string sSysId = vSysIdChanPairs[uPair].substr(0, sep); const size_t hexPos = sSysId.find("0x"); int iSysId; - if (string::npos == hexPos) iSysId = std::stoi(sSysId); + if (string::npos == hexPos) + iSysId = std::stoi(sSysId); else iSysId = std::stoi(sSysId.substr(hexPos + 2), nullptr, 16); @@ -162,7 +160,7 @@ try { // filename with wildcards && diranme : all files with filename regex in the directory // host && port : connect to the flim server - bool isGoodInputCombi {false}; + bool isGoodInputCombi{false}; if (0 != fFileName.size() && 0 == fDirName.size() && 0 == fHost.size() && 0 == fPort) { isGoodInputCombi = true; fInputFileList.push_back(fFileName); @@ -201,9 +199,9 @@ try { // 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. - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined output channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { /// Catches and ignores the channels for missing TS indices and commands /// Same for the histogram channels if (entry.first == fsChannelNameMissedTs || entry.first == fsChannelNameCommands @@ -240,7 +238,7 @@ try { } else { // Create a ";" separated string with all file names - std::string fileList {""}; + std::string fileList{""}; for (const auto& obj : fInputFileList) { std::string fileName = obj; fileList += fileName; @@ -249,12 +247,16 @@ try { fileList.pop_back(); // Remove the last ; LOG(info) << "Input File String: " << fileList; fSource = new fles::TimesliceMultiInputArchive(fileList, fDirName); - if (!fSource) { throw InitTaskError("Could open files from file list."); } + if (!fSource) { + throw InitTaskError("Could open files from file list."); + } } LOG(info) << "High-Water Mark: " << fHighWaterMark; LOG(info) << "Max. Timeslices: " << fMaxTimeslices; - if (fbNoSplitTs) { LOG(info) << "Sending TS copies in no-split mode"; } // if( fbNoSplitTs ) + if (fbNoSplitTs) { + LOG(info) << "Sending TS copies in no-split mode"; + } // if( fbNoSplitTs ) else if (fbSendTsPerSysId) { LOG(info) << "Sending components in separate TS per SysId"; } // else if( fbSendTsPerSysId && fbSendTsPerSysId ) of if( fbNoSplitTs @@ -297,7 +299,8 @@ bool CbmMQTsaMultiSampler::IsChannelNameAllowed(std::string channelName) fChannelsToSend[idx].push_back(channelName); /// If sending per channel, do not stop the loop as we allow more than 1 comp type per channel - if (fbSendTsPerChannel) bFoundMatch = true; + if (fbSendTsPerChannel) + bFoundMatch = true; else return true; } // if (pos1!=std::string::npos) @@ -391,7 +394,7 @@ bool CbmMQTsaMultiSampler::InitHistograms() fvpsHistosFolder.push_back(psHistoConfig); /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, psHistoConfig); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, psHistoConfig); @@ -417,7 +420,7 @@ bool CbmMQTsaMultiSampler::InitHistograms() fvpsCanvasConfig.push_back(psCanvConfig); /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, psCanvConfig); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, psCanvConfig); @@ -434,7 +437,9 @@ bool CbmMQTsaMultiSampler::InitHistograms() bool CbmMQTsaMultiSampler::ConditionalRun() { - if (0 < fuPublishFreqTs && 0 == fTSCounter) { InitHistograms(); } // if( 0 < fuPublishFreqTs ) + if (0 < fuPublishFreqTs && 0 == fTSCounter) { + InitHistograms(); + } // if( 0 < fuPublishFreqTs ) /// initialize the source (connect to emitter, ...) if (0 == fTSCounter && nullptr != dynamic_cast<fles::TimesliceMultiSubscriber*>(fSource)) { @@ -451,7 +456,9 @@ bool CbmMQTsaMultiSampler::ConditionalRun() if (0 < fuPublishFreqTs) { uint64_t uTsTime = ts.descriptor(0, 0).idx; - if (0 == fuStartTime) { fuStartTime = uTsTime; } // if( 0 == fuStartTime ) + if (0 == fuStartTime) { + fuStartTime = uTsTime; + } // if( 0 == fuStartTime ) fdTimeToStart = static_cast<double_t>(uTsTime - fuStartTime) / 1e9; uint64_t uSizeMb = 0; @@ -516,7 +523,9 @@ bool CbmMQTsaMultiSampler::ConditionalRun() fuPrevTsIndex = uTsIndex; - if (fTSCounter % 10000 == 0) { LOG(info) << "Received TS " << fTSCounter << " with index " << uTsIndex; } + if (fTSCounter % 10000 == 0) { + LOG(info) << "Received TS " << fTSCounter << " with index " << uTsIndex; + } LOG(debug) << "Found " << ts.num_components() << " different components in timeslice"; @@ -645,7 +654,7 @@ bool CbmMQTsaMultiSampler::CreateAndSendComponent(const fles::Timeslice& ts, int if (fComponentsToSend[idx] > 0) { LOG(debug) << "Create timeslice component for link " << nrComp; - fles::StorableTimeslice component {static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; component.append_component(ts.num_microslices(0)); for (size_t m = 0; m < ts.num_microslices(nrComp); ++m) { @@ -699,7 +708,7 @@ bool CbmMQTsaMultiSampler::CreateAndCombineComponentsPerSysId(const fles::Timesl LOG(debug) << "Create timeslice with components for SysId " << std::hex << fSysId[uSysIdx] << std::dec; if (0 < fvvCompPerSysId[uSysIdx].size()) { - fles::StorableTimeslice component {static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; for (uint32_t uComp = 0; uComp < fvvCompPerSysId[uSysIdx].size(); ++uComp) { uint32_t uNumMsInComp = ts.num_microslices(fvvCompPerSysId[uSysIdx][uComp]); @@ -792,7 +801,7 @@ bool CbmMQTsaMultiSampler::CreateAndCombineComponentsPerChannel(const fles::Time LOG(debug) << "Create timeslice with components for channel " << fvChannelsToSend[uChanIdx]; if (0 < fvvCompPerChannel[uChanIdx].size()) { - fles::StorableTimeslice component {static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; for (uint32_t uComp = 0; uComp < fvvCompPerChannel[uChanIdx].size(); ++uComp) { uint32_t uNumMsInComp = ts.num_microslices(fvvCompPerChannel[uChanIdx][uComp]); @@ -825,7 +834,7 @@ bool CbmMQTsaMultiSampler::CreateAndSendFullTs(const fles::Timeslice& ts) if (0 < fComponentsToSend[uChanIdx]) { LOG(debug) << "Copy timeslice component for channel " << fChannelsToSend[uChanIdx][0]; - fles::StorableTimeslice fullTs {ts}; + fles::StorableTimeslice fullTs{ts}; if (!SendData(fullTs, uChanIdx)) return false; } // if( 0 < fComponentsToSend[ uChanIdx ] ) } // for( uint32_t uChanIdx = 0; uChanIdx < fChannelsToSend.size(); ++uChanIdx ) @@ -840,7 +849,7 @@ bool CbmMQTsaMultiSampler::SendData(const fles::StorableTimeslice& component, in oa << component; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -848,7 +857,9 @@ bool CbmMQTsaMultiSampler::SendData(const fles::StorableTimeslice& component, in // TODO: Implement sending same data to more than one channel // Need to create new message (copy message??) - if (fComponentsToSend[idx] > 1) { LOG(info) << "Need to copy FairMessage"; } + if (fComponentsToSend[idx] > 1) { + LOG(info) << "Need to copy FairMessage"; + } // in case of error or transfer interruption, // return false to go to IDLE state @@ -875,7 +886,7 @@ bool CbmMQTsaMultiSampler::SendData(const fles::StorableTimeslice& component, st oa << component; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -904,7 +915,7 @@ bool CbmMQTsaMultiSampler::SendMissedTsIdx(std::vector<uint64_t> vIndices) oa << vIndices; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -930,13 +941,13 @@ bool CbmMQTsaMultiSampler::SendCommand(std::string sCommand) oa << sCommand; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, strMsg)); // object that manages the data - // FairMQMessagePtr msg( NewMessage( const_cast<char*>( sCommand.c_str() ), // data + // fair::mq::MessagePtr msg( NewMessage( const_cast<char*>( sCommand.c_str() ), // data // sCommand.length(), // size // []( void* /*data*/, void* object ){ delete static_cast< std::string * >( object ); }, // &sCommand ) ); // object that manages the data @@ -957,7 +968,7 @@ bool CbmMQTsaMultiSampler::SendCommand(std::string sCommand) bool CbmMQTsaMultiSampler::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/source/CbmMQTsaMultiSampler.h b/MQ/source/CbmMQTsaMultiSampler.h index ca71268948cbd8db07a1658402edcda4d8f1b213..54edbea44dcac3ca180f2ee4255a3b0843c47c80 100644 --- a/MQ/source/CbmMQTsaMultiSampler.h +++ b/MQ/source/CbmMQTsaMultiSampler.h @@ -13,13 +13,12 @@ #define CBMMQTSAMULTISAMPLER_H_ +#include "FairMQDevice.h" #include "MicrosliceDescriptor.hpp" #include "StorableTimeslice.hpp" #include "Timeslice.hpp" #include "TimesliceSource.hpp" -#include "FairMQDevice.h" - class TCanvas; class TH1F; class TH1I; @@ -31,12 +30,12 @@ class TProfile; #include <utility> #include <vector> -class CbmMQTsaMultiSampler : public FairMQDevice { -public: +class CbmMQTsaMultiSampler : public fair::mq::Device { + public: CbmMQTsaMultiSampler(); virtual ~CbmMQTsaMultiSampler(); -protected: + protected: uint64_t fMaxTimeslices; std::string fFileName; @@ -68,7 +67,7 @@ protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: bool InitHistograms(); bool CheckTimeslice(const fles::Timeslice& ts); void PrintMicroSliceDescriptor(const fles::MicrosliceDescriptor& mdsc); diff --git a/MQ/source/CbmMQTsaMultiSamplerTof.cxx b/MQ/source/CbmMQTsaMultiSamplerTof.cxx index 4a42a9dea00550e3f827b134d07b039bf3f6c8d1..e64c40d59880882c6e04c891e6ebb27b18739fea 100644 --- a/MQ/source/CbmMQTsaMultiSamplerTof.cxx +++ b/MQ/source/CbmMQTsaMultiSamplerTof.cxx @@ -13,16 +13,14 @@ #include "CbmMQTsaMultiSamplerTof.h" #include "CbmMQDefs.h" - +#include "FairMQLogger.h" +#include "FairMQProgOptions.h" // device->fConfig #include "StorableTimeslice.hpp" #include "TimesliceInputArchive.hpp" #include "TimesliceMultiInputArchive.hpp" #include "TimesliceMultiSubscriber.hpp" #include "TimesliceSubscriber.hpp" -#include "FairMQLogger.h" -#include "FairMQProgOptions.h" // device->fConfig - #include <boost/algorithm/string.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/filesystem.hpp> @@ -30,12 +28,11 @@ namespace filesys = boost::filesystem; -#include <thread> // this_thread::sleep_for - #include <algorithm> #include <chrono> #include <ctime> #include <string> +#include <thread> // this_thread::sleep_for #include <stdio.h> @@ -50,7 +47,7 @@ struct InitTaskError : std::runtime_error { }; CbmMQTsaMultiSamplerTof::CbmMQTsaMultiSamplerTof() - : FairMQDevice() + : fair::mq::Device() , fMaxTimeslices(0) , fFileName("") , fDirName("") @@ -87,7 +84,7 @@ try { // filename with wildcards && diranme : all files with filename regex in the directory // host && port : connect to the flim server - bool isGoodInputCombi {false}; + bool isGoodInputCombi{false}; if (0 != fFileName.size() && 0 == fDirName.size() && 0 == fHost.size() && 0 == fPort) { isGoodInputCombi = true; fInputFileList.push_back(fFileName); @@ -130,9 +127,9 @@ try { // 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. - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined output channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); } @@ -160,7 +157,7 @@ try { } else { // Create a ";" separated string with all file names - std::string fileList {""}; + std::string fileList{""}; for (const auto& obj : fInputFileList) { std::string fileName = obj; fileList += fileName; @@ -169,7 +166,9 @@ try { fileList.pop_back(); // Remove the last ; LOG(info) << "Input File String: " << fileList; fSource = new fles::TimesliceMultiInputArchive(fileList, fDirName); - if (!fSource) { throw InitTaskError("Could open files from file list."); } + if (!fSource) { + throw InitTaskError("Could open files from file list."); + } } fTime = std::chrono::steady_clock::now(); @@ -206,7 +205,7 @@ bool CbmMQTsaMultiSamplerTof::IsChannelNameAllowed(std::string channelName) bool CbmMQTsaMultiSamplerTof::IsChannelUp(std::string channelName) { - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Inspect " << entry.first; std::size_t pos1 = channelName.find(entry.first); if (pos1 != std::string::npos) { @@ -242,7 +241,7 @@ bool CbmMQTsaMultiSamplerTof::ConditionalRun() } */ // keep components together - std::vector<FairMQParts> parts; + std::vector<fair::mq::Parts> parts; std::vector<bool> bparts; parts.resize(fComponentsToSend.size()); bparts.resize(parts.size()); @@ -290,7 +289,7 @@ bool CbmMQTsaMultiSamplerTof::ConditionalRun() if (fComponentsToSend[idx] > 0) { LOG(debug) << "Append timeslice component of link " << nrComp << " to idx " << idx; - fles::StorableTimeslice component {static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; component.append_component(ts.num_microslices(0)); for (size_t m = 0; m < ts.num_microslices(nrComp); ++m) { @@ -437,7 +436,7 @@ bool CbmMQTsaMultiSamplerTof::CreateAndSendComponent(const fles::Timeslice& ts, if (fComponentsToSend[idx] > 0) { LOG(debug) << "Create timeslice component for link " << nrComp; - fles::StorableTimeslice component {static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; component.append_component(ts.num_microslices(nrComp)); for (size_t m = 0; m < ts.num_microslices(nrComp); ++m) { @@ -458,7 +457,7 @@ bool CbmMQTsaMultiSamplerTof::SendData(const fles::StorableTimeslice& component, oa << component; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -466,7 +465,9 @@ bool CbmMQTsaMultiSamplerTof::SendData(const fles::StorableTimeslice& component, // TODO: Implement sending same data to more than one channel // Need to create new message (copy message??) - if (fComponentsToSend[idx] > 1) { LOG(debug) << "Need to copy FairMessage"; } + if (fComponentsToSend[idx] > 1) { + LOG(debug) << "Need to copy FairMessage"; + } // in case of error or transfer interruption, // return false to go to IDLE state @@ -549,14 +550,18 @@ void CbmMQTsaMultiSamplerTof::SendSysCmdStop() LOG(info) << "stop subscribers in 10 sec"; std::this_thread::sleep_for(std::chrono::milliseconds(10000)); - FairMQMessagePtr pub(NewSimpleMessage("STOP")); - if (Send(pub, "syscmd") < 0) { LOG(error) << "Sending STOP message failed"; } + fair::mq::MessagePtr pub(NewSimpleMessage("STOP")); + if (Send(pub, "syscmd") < 0) { + LOG(error) << "Sending STOP message failed"; + } LOG(info) << "task reset subscribers in 1 sec"; std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - FairMQMessagePtr task_reset(NewSimpleMessage("TASK_RESET")); + fair::mq::MessagePtr task_reset(NewSimpleMessage("TASK_RESET")); - if (Send(task_reset, "syscmd") < 0) { LOG(error) << "Sending Task_Reset message failed"; } + if (Send(task_reset, "syscmd") < 0) { + LOG(error) << "Sending Task_Reset message failed"; + } } // FairMQStateMachine::ChangeState(STOP); } diff --git a/MQ/source/CbmMQTsaMultiSamplerTof.h b/MQ/source/CbmMQTsaMultiSamplerTof.h index d78897fc14a91add3c8e2c971cac116fa2592de4..a0a25dd377960617b613a0f220be317a8639f3cc 100644 --- a/MQ/source/CbmMQTsaMultiSamplerTof.h +++ b/MQ/source/CbmMQTsaMultiSamplerTof.h @@ -13,23 +13,22 @@ #define CBMMQTSAMULTISAMPLERTOF_H_ +#include "FairMQDevice.h" #include "MicrosliceDescriptor.hpp" #include "StorableTimeslice.hpp" #include "Timeslice.hpp" #include "TimesliceSource.hpp" -#include "FairMQDevice.h" - #include <ctime> #include <string> #include <vector> -class CbmMQTsaMultiSamplerTof : public FairMQDevice { -public: +class CbmMQTsaMultiSamplerTof : public fair::mq::Device { + public: CbmMQTsaMultiSamplerTof(); virtual ~CbmMQTsaMultiSamplerTof(); -protected: + protected: uint64_t fMaxTimeslices; std::string fFileName; @@ -50,7 +49,7 @@ protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: bool OpenNextFile(); bool CheckTimeslice(const fles::Timeslice& ts); diff --git a/MQ/source/CbmMQTsaSampler.cxx b/MQ/source/CbmMQTsaSampler.cxx index f129557d5f2a635f9ceaa481047ceb9c48044068..a7bf13419b9b1e3b7efc2877ef25dc41bbc43718 100644 --- a/MQ/source/CbmMQTsaSampler.cxx +++ b/MQ/source/CbmMQTsaSampler.cxx @@ -13,12 +13,10 @@ #include "CbmMQTsaSampler.h" #include "CbmMQDefs.h" - -#include "TimesliceInputArchive.hpp" -#include "TimesliceSubscriber.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig +#include "TimesliceInputArchive.hpp" +#include "TimesliceSubscriber.hpp" #include <boost/algorithm/string.hpp> #include <boost/archive/binary_oarchive.hpp> @@ -27,12 +25,11 @@ namespace filesys = boost::filesystem; -#include <thread> // this_thread::sleep_for - #include <algorithm> #include <chrono> #include <ctime> #include <string> +#include <thread> // this_thread::sleep_for #include <stdio.h> @@ -76,23 +73,29 @@ try { // filename with wildcards && diranme : all files with filename regex in the directory // host && port : connect to the flim server - bool isGoodInputCombi {false}; + bool isGoodInputCombi{false}; if (0 != fFileName.size() && 0 == fDirName.size() && 0 == fHost.size() && 0 == fPort) { isGoodInputCombi = true; // Create a Path object from given path string filesys::path pathObj(fFileName); - if (!filesys::is_regular_file(pathObj)) { throw InitTaskError("Passed file name is no valid file"); } + if (!filesys::is_regular_file(pathObj)) { + throw InitTaskError("Passed file name is no valid file"); + } fInputFileList.push_back(fFileName); LOG(info) << "Filename: " << fFileName; } else if (0 != fFileName.size() && 0 != fDirName.size() && 0 == fHost.size() && 0 == fPort) { isGoodInputCombi = true; filesys::path pathObj = fDirName; - if (!filesys::is_directory(pathObj)) { throw InitTaskError("Passed directory name is no valid directory"); } + if (!filesys::is_directory(pathObj)) { + throw InitTaskError("Passed directory name is no valid directory"); + } if (fFileName.find("*") == std::string::npos) { // Normal file without wildcards pathObj += fFileName; - if (!filesys::is_regular_file(pathObj)) { throw InitTaskError("Passed file name is no valid file"); } + if (!filesys::is_regular_file(pathObj)) { + throw InitTaskError("Passed file name is no valid file"); + } fInputFileList.push_back(pathObj.string()); LOG(info) << "Filename: " << fInputFileList[0]; } @@ -119,7 +122,8 @@ try { // filename or directory name and convert it to a string to be // used in the regex:match boost::smatch what; - if (!boost::regex_match(x.path().leaf().string(), what, my_filter)) continue; + // if (!boost::regex_match(x.path().leaf().string(), what, my_filter)) continue; + if (!boost::regex_match(x.path().filename().string(), what, my_filter)) continue; v.push_back(x.path()); } @@ -161,9 +165,9 @@ try { // 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. - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined output channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); } @@ -180,7 +184,9 @@ try { std::string connector = "tcp://" + fHost + ":" + std::to_string(fPort); LOG(info) << "Open TSPublisher at " << connector; fSource = new fles::TimesliceSubscriber(connector, 1); - if (!fSource) { throw InitTaskError("Could not connect to publisher."); } + if (!fSource) { + throw InitTaskError("Could not connect to publisher."); + } } else { if (false == OpenNextFile()) { @@ -305,7 +311,7 @@ bool CbmMQTsaSampler::CreateAndSendComponent(const fles::Timeslice& ts, int nrCo if (fComponentsToSend[idx] > 0) { LOG(info) << "Create timeslice component for link " << nrComp; - fles::StorableTimeslice component {static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; component.append_component(ts.num_microslices(0)); for (size_t m = 0; m < ts.num_microslices(nrComp); ++m) { @@ -326,7 +332,7 @@ bool CbmMQTsaSampler::SendData(const fles::StorableTimeslice& component, int idx oa << component; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -334,7 +340,9 @@ bool CbmMQTsaSampler::SendData(const fles::StorableTimeslice& component, int idx // TODO: Implement sending same data to more than one channel // Need to create new message (copy message??) - if (fComponentsToSend[idx] > 1) { LOG(info) << "Need to copy FairMessage"; } + if (fComponentsToSend[idx] > 1) { + LOG(info) << "Need to copy FairMessage"; + } // in case of error or transfer interruption, // return false to go to IDLE state diff --git a/MQ/source/CbmMQTsaSampler.h b/MQ/source/CbmMQTsaSampler.h index 5c84b9122949393aaaeb89c5c489e62373d3ba8f..2e0a420a9973387fd1afd41c3c8a682956051bf8 100644 --- a/MQ/source/CbmMQTsaSampler.h +++ b/MQ/source/CbmMQTsaSampler.h @@ -25,12 +25,12 @@ #include <string> #include <vector> -class CbmMQTsaSampler : public FairMQDevice { -public: +class CbmMQTsaSampler : public fair::mq::Device { + public: CbmMQTsaSampler(); virtual ~CbmMQTsaSampler(); -protected: + protected: uint64_t fMaxTimeslices; std::string fFileName; @@ -50,7 +50,7 @@ protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: bool OpenNextFile(); bool CheckTimeslice(const fles::Timeslice& ts); diff --git a/MQ/source/CbmMQTsaSamplerTof.cxx b/MQ/source/CbmMQTsaSamplerTof.cxx index 74af486b71c129697f795d539e765267ccca71eb..0bc2856caa73cdad59086a1c96220f1d591453d7 100644 --- a/MQ/source/CbmMQTsaSamplerTof.cxx +++ b/MQ/source/CbmMQTsaSamplerTof.cxx @@ -13,12 +13,10 @@ #include "CbmMQTsaSamplerTof.h" #include "CbmMQDefs.h" - -#include "TimesliceInputArchive.hpp" -#include "TimesliceSubscriber.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig +#include "TimesliceInputArchive.hpp" +#include "TimesliceSubscriber.hpp" #include <boost/algorithm/string.hpp> #include <boost/archive/binary_oarchive.hpp> @@ -27,12 +25,11 @@ namespace filesys = boost::filesystem; -#include <thread> // this_thread::sleep_for - #include <algorithm> #include <chrono> #include <ctime> #include <string> +#include <thread> // this_thread::sleep_for #include <stdio.h> @@ -46,7 +43,7 @@ struct InitTaskError : std::runtime_error { CbmMQTsaSamplerTof::CbmMQTsaSamplerTof() - : FairMQDevice() + : fair::mq::Device() , fMaxTimeslices(0) , fFileName("") , fDirName("") @@ -77,23 +74,29 @@ try { // filename with wildcards && diranme : all files with filename regex in the directory // host && port : connect to the flim server - bool isGoodInputCombi {false}; + bool isGoodInputCombi{false}; if (0 != fFileName.size() && 0 == fDirName.size() && 0 == fHost.size() && 0 == fPort) { isGoodInputCombi = true; // Create a Path object from given path string filesys::path pathObj(fFileName); - if (!filesys::is_regular_file(pathObj)) { throw InitTaskError("Passed file name is no valid file"); } + if (!filesys::is_regular_file(pathObj)) { + throw InitTaskError("Passed file name is no valid file"); + } fInputFileList.push_back(fFileName); LOG(info) << "Filename: " << fFileName; } else if (0 != fFileName.size() && 0 != fDirName.size() && 0 == fHost.size() && 0 == fPort) { isGoodInputCombi = true; filesys::path pathObj = fDirName; - if (!filesys::is_directory(pathObj)) { throw InitTaskError("Passed directory name is no valid directory"); } + if (!filesys::is_directory(pathObj)) { + throw InitTaskError("Passed directory name is no valid directory"); + } if (fFileName.find("*") == std::string::npos) { // Normal file without wildcards pathObj += fFileName; - if (!filesys::is_regular_file(pathObj)) { throw InitTaskError("Passed file name is no valid file"); } + if (!filesys::is_regular_file(pathObj)) { + throw InitTaskError("Passed file name is no valid file"); + } fInputFileList.push_back(pathObj.string()); LOG(info) << "Filename: " << fInputFileList[0]; } @@ -120,7 +123,7 @@ try { // filename or directory name and convert it to a string to be // used in the regex:match boost::smatch what; - if (!boost::regex_match(x.path().leaf().string(), what, my_filter)) continue; + if (!boost::regex_match(x.path().filename().string(), what, my_filter)) continue; v.push_back(x.path()); } @@ -163,9 +166,9 @@ try { // 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. - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined output channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); } @@ -182,7 +185,9 @@ try { std::string connector = "tcp://" + fHost + ":" + std::to_string(fPort); LOG(info) << "Open TSPublisher at " << connector; fSource = new fles::TimesliceSubscriber(connector, 1); - if (!fSource) { throw InitTaskError("Could not connect to publisher."); } + if (!fSource) { + throw InitTaskError("Could not connect to publisher."); + } } else { if (false == OpenNextFile()) { @@ -251,7 +256,7 @@ bool CbmMQTsaSamplerTof::IsChannelNameAllowed(std::string channelName) bool CbmMQTsaSamplerTof::IsChannelUp(std::string channelName) { - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Inspect " << entry.first; std::size_t pos1 = channelName.find(entry.first); if (pos1 != std::string::npos) { @@ -288,7 +293,7 @@ bool CbmMQTsaSamplerTof::ConditionalRun() } */ // keep components together - std::vector<FairMQParts> parts; + std::vector<fair::mq::Parts> parts; std::vector<bool> bparts; parts.resize(fComponentsToSend.size()); bparts.resize(parts.size()); @@ -306,7 +311,7 @@ bool CbmMQTsaSamplerTof::ConditionalRun() if (fComponentsToSend[idx] > 0) { LOG(debug) << "Append timeslice component of link " << nrComp << " to idx " << idx; - fles::StorableTimeslice component {static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; component.append_component(ts.num_microslices(0)); for (size_t m = 0; m < ts.num_microslices(nrComp); ++m) { @@ -462,7 +467,7 @@ bool CbmMQTsaSamplerTof::CreateAndSendComponent(const fles::Timeslice& ts, int n if (fComponentsToSend[idx] > 0) { LOG(debug) << "Create timeslice component for link " << nrComp; - fles::StorableTimeslice component {static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; + fles::StorableTimeslice component{static_cast<uint32_t>(ts.num_core_microslices()), ts.index()}; component.append_component(ts.num_microslices(0)); for (size_t m = 0; m < ts.num_microslices(nrComp); ++m) { @@ -483,7 +488,7 @@ bool CbmMQTsaSamplerTof::SendData(const fles::StorableTimeslice& component, int oa << component; std::string* strMsg = new std::string(oss.str()); - FairMQMessagePtr msg(NewMessage( + fair::mq::MessagePtr msg(NewMessage( const_cast<char*>(strMsg->c_str()), // data strMsg->length(), // size [](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, @@ -491,7 +496,9 @@ bool CbmMQTsaSamplerTof::SendData(const fles::StorableTimeslice& component, int // TODO: Implement sending same data to more than one channel // Need to create new message (copy message??) - if (fComponentsToSend[idx] > 1) { LOG(debug) << "Need to copy FairMessage"; } + if (fComponentsToSend[idx] > 1) { + LOG(debug) << "Need to copy FairMessage"; + } // in case of error or transfer interruption, // return false to go to IDLE state @@ -569,14 +576,18 @@ void CbmMQTsaSamplerTof::SendSysCmdStop() LOG(info) << "stop subscribers in 100 sec"; std::this_thread::sleep_for(std::chrono::milliseconds(100000)); - FairMQMessagePtr pub(NewSimpleMessage("STOP")); - if (Send(pub, "syscmd") < 0) { LOG(error) << "Sending STOP message failed"; } + fair::mq::MessagePtr pub(NewSimpleMessage("STOP")); + if (Send(pub, "syscmd") < 0) { + LOG(error) << "Sending STOP message failed"; + } LOG(info) << "task reset subscribers in 1 sec"; std::this_thread::sleep_for(std::chrono::milliseconds(1000)); - FairMQMessagePtr task_reset(NewSimpleMessage("TASK_RESET")); + fair::mq::MessagePtr task_reset(NewSimpleMessage("TASK_RESET")); - if (Send(task_reset, "syscmd") < 0) { LOG(error) << "Sending Task_Reset message failed"; } + if (Send(task_reset, "syscmd") < 0) { + LOG(error) << "Sending Task_Reset message failed"; + } } // FairMQStateMachine::ChangeState(STOP); } diff --git a/MQ/source/CbmMQTsaSamplerTof.h b/MQ/source/CbmMQTsaSamplerTof.h index ce72f84f89dd4d20a22008f2b487fc2afaeb98dc..41ff1c340edfa5f0bead14e17c31865cb032a631 100644 --- a/MQ/source/CbmMQTsaSamplerTof.h +++ b/MQ/source/CbmMQTsaSamplerTof.h @@ -25,12 +25,12 @@ #include <string> #include <vector> -class CbmMQTsaSamplerTof : public FairMQDevice { -public: +class CbmMQTsaSamplerTof : public fair::mq::Device { + public: CbmMQTsaSamplerTof(); virtual ~CbmMQTsaSamplerTof(); -protected: + protected: uint64_t fMaxTimeslices; std::string fFileName; @@ -50,7 +50,7 @@ protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: bool OpenNextFile(); bool CheckTimeslice(const fles::Timeslice& ts); diff --git a/MQ/source/CbmStsDigiSource.cxx b/MQ/source/CbmStsDigiSource.cxx index 1986e448d5d80a92612320890e735c80d746cc0a..b1576bfa84f37cb1d86c23794739e52f572a794b 100644 --- a/MQ/source/CbmStsDigiSource.cxx +++ b/MQ/source/CbmStsDigiSource.cxx @@ -15,20 +15,18 @@ #include "CbmDigiManager.h" #include "CbmMQDefs.h" #include "CbmStsDigi.h" - #include "FairFileSource.h" #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairRootManager.h" #include "FairRunAna.h" -#include <thread> // this_thread::sleep_for - #include <boost/archive/binary_oarchive.hpp> #include <chrono> #include <ctime> #include <stdexcept> +#include <thread> // this_thread::sleep_for #include <stdio.h> @@ -40,7 +38,7 @@ struct InitTaskError : std::runtime_error { CbmStsDigiSource::CbmStsDigiSource() - : FairMQDevice() + : fair::mq::Device() , fMaxEvents(0) , fFileName("") , fInputFileList() @@ -70,9 +68,9 @@ try { // 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. - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined output channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); } @@ -84,15 +82,21 @@ try { LOG(info) << "Open the ROOT input file " << fFileName; // Check if the input file exist FILE* inputFile = fopen(fFileName.c_str(), "r"); - if (!inputFile) { throw InitTaskError("Input file doesn't exist."); } + if (!inputFile) { + throw InitTaskError("Input file doesn't exist."); + } fclose(inputFile); FairFileSource* source = new FairFileSource(fFileName); - if (!source) { throw InitTaskError("Could not open input file."); } + if (!source) { + throw InitTaskError("Could not open input file."); + } rootman->SetSource(source); rootman->InitSource(); CbmDigiManager* digiMan = CbmDigiManager::Instance(); digiMan->Init(); - if (!digiMan->IsPresent(ECbmModuleId::kSts)) { throw InitTaskError("No StsDigi branch in input!"); } + if (!digiMan->IsPresent(ECbmModuleId::kSts)) { + throw InitTaskError("No StsDigi branch in input!"); + } } else { throw InitTaskError("No input file specified"); @@ -101,7 +105,9 @@ try { Int_t MaxAllowed = FairRootManager::Instance()->CheckMaxEventNo(fMaxEvents); if (MaxAllowed != -1) { - if (fMaxEvents == 0) { fMaxEvents = MaxAllowed; } + if (fMaxEvents == 0) { + fMaxEvents = MaxAllowed; + } else { if (static_cast<Int_t>(fMaxEvents) > MaxAllowed) { LOG(warn) << "-------------------Warning---------------------------"; @@ -165,7 +171,9 @@ bool CbmStsDigiSource::ConditionalRun() LOG(info) << "Counter: " << fEventCounter << " Events: " << fMaxEvents; - if (fEventCounter < fMaxEvents) { return true; } + if (fEventCounter < fMaxEvents) { + return true; + } else { CalcRuntime(); return false; diff --git a/MQ/source/CbmStsDigiSource.h b/MQ/source/CbmStsDigiSource.h index 4a80c8cff41abc6b01754765a446c514a3d84851..90ee5e4b72fc389f1b26ef487a965336d33afb42 100644 --- a/MQ/source/CbmStsDigiSource.h +++ b/MQ/source/CbmStsDigiSource.h @@ -19,12 +19,12 @@ class CbmStsDigi; -class CbmStsDigiSource : public FairMQDevice { -public: +class CbmStsDigiSource : public fair::mq::Device { + public: CbmStsDigiSource(); virtual ~CbmStsDigiSource(); -protected: + protected: uint64_t fMaxEvents; std::string fFileName; @@ -40,7 +40,7 @@ protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: void PrintStsDigi(const CbmStsDigi*); bool SendData(); void CalcRuntime(); diff --git a/MQ/source/CbmTsConsumerReqDevExample.cxx b/MQ/source/CbmTsConsumerReqDevExample.cxx index 0488fcd46bdceafdebd753775cb91b3d12ad0af4..4e06d565ca2a1f16662fe8981e9b163d424ef83c 100644 --- a/MQ/source/CbmTsConsumerReqDevExample.cxx +++ b/MQ/source/CbmTsConsumerReqDevExample.cxx @@ -4,22 +4,19 @@ #include "CbmTsConsumerReqDevExample.h" +#include "BoostSerializer.h" #include "CbmFlesCanvasTools.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" - +#include "RootSerializer.h" +#include "StorableTimeslice.hpp" #include "TCanvas.h" #include "TFile.h" #include "TH1.h" #include "TList.h" #include "TNamed.h" -#include <thread> -#include "BoostSerializer.h" #include <boost/archive/binary_iarchive.hpp> #include <boost/serialization/utility.hpp> @@ -27,8 +24,7 @@ #include <iomanip> #include <stdexcept> #include <string> - -#include "RootSerializer.h" +#include <thread> struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; }; @@ -72,7 +68,7 @@ bool CbmTsConsumerReqDevExample::InitContainers() for (int iparC = 0; iparC < fParCList->GetEntries(); iparC++) { FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); fParCList->Remove(tempObj); - std::string paramName {tempObj->GetName()}; + std::string paramName{tempObj->GetName()}; // 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 @@ -80,8 +76,8 @@ bool CbmTsConsumerReqDevExample::InitContainers() std::string message = paramName + ",111"; LOG(info) << "Requesting parameter container " << paramName << ", sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); FairParGenericSet* newObj = nullptr; @@ -168,8 +164,8 @@ bool CbmTsConsumerReqDevExample::ConditionalRun() std::string message = fsTsBlockName; if ("" == message) message = std::to_string(kusSysId); LOG(debug) << "Requesting new TS by sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage(message)); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage(message)); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, fsChannelNameDataInput) <= 0) { LOG(error) << "Failed to send the request! message was " << message; @@ -207,7 +203,7 @@ bool CbmTsConsumerReqDevExample::ConditionalRun() boost::archive::binary_iarchive inputArchive(iss); /// Create an empty TS and fill it with the incoming message - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; /// Process the Timeslice @@ -237,16 +233,16 @@ bool CbmTsConsumerReqDevExample::SendHistoConfAndData() { /// Prepare multiparts message and header std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); - FairMQMessagePtr messageHeader(NewMessage()); + fair::mq::MessagePtr messageHeader(NewMessage()); // Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); BoostSerializer<std::pair<uint32_t, uint32_t>>().Serialize(*messageHeader, pairHeader); - FairMQParts partsOut; + fair::mq::Parts partsOut; partsOut.AddPart(std::move(messageHeader)); for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) { /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist(NewMessage()); + fair::mq::MessagePtr messageHist(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageHist, fvpsHistosFolder[uHisto]); @@ -255,7 +251,7 @@ bool CbmTsConsumerReqDevExample::SendHistoConfAndData() for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan(NewMessage()); + fair::mq::MessagePtr messageCan(NewMessage()); // Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); BoostSerializer<std::pair<std::string, std::string>>().Serialize(*messageCan, fvpsCanvasConfig[uCanv]); @@ -263,7 +259,7 @@ bool CbmTsConsumerReqDevExample::SendHistoConfAndData() } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) /// Serialize the array of histos into a single MQ message - FairMQMessagePtr msgHistos(NewMessage()); + fair::mq::MessagePtr msgHistos(NewMessage()); // Serialize<RootSerializer>(*msgHistos, &fArrayHisto); RootSerializer().Serialize(*msgHistos, &fArrayHisto); @@ -284,7 +280,7 @@ bool CbmTsConsumerReqDevExample::SendHistoConfAndData() bool CbmTsConsumerReqDevExample::SendHistograms() { /// Serialize the array of histos into a single MQ message - FairMQMessagePtr message(NewMessage()); + fair::mq::MessagePtr message(NewMessage()); // Serialize<RootSerializer>(*message, &fArrayHisto); RootSerializer().Serialize(*message, &fArrayHisto); diff --git a/MQ/source/CbmTsConsumerReqDevExample.h b/MQ/source/CbmTsConsumerReqDevExample.h index e309f84b1df9f44807bfccc3a54edc54a2ce5340..dd7755ca1c8210d01e905c6d9f3c802eb5f04aa2 100644 --- a/MQ/source/CbmTsConsumerReqDevExample.h +++ b/MQ/source/CbmTsConsumerReqDevExample.h @@ -6,13 +6,10 @@ #define CBMTSCONSUMERREQDEVEXPL_H_ #include "CbmMqTMessage.h" - -#include "Timeslice.hpp" - #include "FairMQDevice.h" - #include "Rtypes.h" #include "TObjArray.h" +#include "Timeslice.hpp" #include <chrono> #include <map> @@ -20,16 +17,16 @@ class TList; -class CbmTsConsumerReqDevExample : public FairMQDevice { -public: +class CbmTsConsumerReqDevExample : public fair::mq::Device { + public: CbmTsConsumerReqDevExample(); virtual ~CbmTsConsumerReqDevExample(); -protected: + protected: virtual void InitTask(); virtual bool ConditionalRun(); -private: + private: /// Constants static const uint16_t kusSysId = 0xFF; diff --git a/MQ/source/runStsDigiSource.cxx b/MQ/source/runStsDigiSource.cxx index 9ce5c7b4dfb42a70e4616e5c73d0a29646db03e8..ce7172fc3da52d916a2b228ac0eb4ac61e265104 100644 --- a/MQ/source/runStsDigiSource.cxx +++ b/MQ/source/runStsDigiSource.cxx @@ -3,7 +3,6 @@ Authors: Florian Uhlig [committer] */ #include "CbmStsDigiSource.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; @@ -16,4 +15,4 @@ void addCustomOptions(bpo::options_description& options) "- infinite)"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmStsDigiSource(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmStsDigiSource(); } diff --git a/MQ/source/runTsConsumerReqExample.cxx b/MQ/source/runTsConsumerReqExample.cxx index 5732fa7384f9adff2b37b3408aa4b185a4013262..c43711b475899d1e6a841a46c8c8c58c888b2187 100644 --- a/MQ/source/runTsConsumerReqExample.cxx +++ b/MQ/source/runTsConsumerReqExample.cxx @@ -3,12 +3,11 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmTsConsumerReqDevExample.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -28,4 +27,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmTsConsumerReqDevExample(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmTsConsumerReqDevExample(); } diff --git a/MQ/source/runTsSamplerRepReq.cxx b/MQ/source/runTsSamplerRepReq.cxx index 69bb37c408dd4d6c910e7c5f673b4f01b52b6b3e..c3105c1517db269a63a125dc745eb305447ba3a5 100644 --- a/MQ/source/runTsSamplerRepReq.cxx +++ b/MQ/source/runTsSamplerRepReq.cxx @@ -3,7 +3,6 @@ Authors: Pierre-Alain Loizeau [committer] */ #include "CbmMQTsSamplerRepReq.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; @@ -49,4 +48,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for histos"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmMQTsSamplerRepReq(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmMQTsSamplerRepReq(); } diff --git a/MQ/source/runTsaInfo.cxx b/MQ/source/runTsaInfo.cxx index 8fc2cb0b6b2d6c2dab1069d7bbee89247990596c..3590f2f9b2d6cf486f5898844d4c19c85a4685a1 100644 --- a/MQ/source/runTsaInfo.cxx +++ b/MQ/source/runTsaInfo.cxx @@ -3,7 +3,6 @@ Authors: Florian Uhlig [committer] */ #include "CbmMQTsaInfo.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; @@ -17,4 +16,4 @@ void addCustomOptions(bpo::options_description& options) "- infinite)")("flib-port", bpo::value<uint64_t>()->default_value(0), "Port where the timeslice server is running"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmMQTsaInfo(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmMQTsaInfo(); } diff --git a/MQ/source/runTsaMultiSampler.cxx b/MQ/source/runTsaMultiSampler.cxx index 13caf762dce3a883964361ce0286ea7a98008ad5..491dc6e9a40fed7d04ce304f746a02efce1c1d4a 100644 --- a/MQ/source/runTsaMultiSampler.cxx +++ b/MQ/source/runTsaMultiSampler.cxx @@ -3,7 +3,6 @@ Authors: Florian Uhlig [committer], Pierre-Alain Loizeau */ #include "CbmMQTsaMultiSampler.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; @@ -43,4 +42,4 @@ void addCustomOptions(bpo::options_description& options) "MQ channel name for canvases config"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmMQTsaMultiSampler(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmMQTsaMultiSampler(); } diff --git a/MQ/source/runTsaMultiSamplerTof.cxx b/MQ/source/runTsaMultiSamplerTof.cxx index 441237d3d5bad40a6e7b6c9c32bb4c5faf15cc30..d3e8e5f4f0dcbd771b57a5910c5a4424d7a65dd6 100644 --- a/MQ/source/runTsaMultiSamplerTof.cxx +++ b/MQ/source/runTsaMultiSamplerTof.cxx @@ -3,7 +3,6 @@ Authors: Norbert Herrmann [committer] */ #include "CbmMQTsaMultiSamplerTof.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; @@ -19,4 +18,4 @@ void addCustomOptions(bpo::options_description& options) "SelectComponents", bpo::value<uint64_t>()->default_value(0), "Select components for transport"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmMQTsaMultiSamplerTof(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmMQTsaMultiSamplerTof(); } diff --git a/MQ/source/runTsaSampler.cxx b/MQ/source/runTsaSampler.cxx index 3cf6ac664c82e8f5ec508a3e953d723a2e241f63..701c4b0c32cb914e5ac3093c0cffe484e9cef1bd 100644 --- a/MQ/source/runTsaSampler.cxx +++ b/MQ/source/runTsaSampler.cxx @@ -3,7 +3,6 @@ Authors: Florian Uhlig [committer] */ #include "CbmMQTsaSampler.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; @@ -18,4 +17,4 @@ void addCustomOptions(bpo::options_description& options) "- infinite)")("flib-port", bpo::value<uint64_t>()->default_value(0), "Port where the timeslice server is running"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmMQTsaSampler(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmMQTsaSampler(); } diff --git a/MQ/source/runTsaSamplerTof.cxx b/MQ/source/runTsaSamplerTof.cxx index f48873b0b87e0f295fd2036b2385759ff7dc93ba..63a707fa01ba1eb9e076e79bebb5c05372612fff 100644 --- a/MQ/source/runTsaSamplerTof.cxx +++ b/MQ/source/runTsaSamplerTof.cxx @@ -3,7 +3,6 @@ Authors: Norbert Herrmann [committer] */ #include "CbmMQTsaSamplerTof.h" - #include "runFairMQDevice.h" namespace bpo = boost::program_options; @@ -18,4 +17,4 @@ void addCustomOptions(bpo::options_description& options) "- infinite)")("flib-port", bpo::value<uint64_t>()->default_value(0), "Port where the timeslice server is running"); } -FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmMQTsaSamplerTof(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmMQTsaSamplerTof(); } diff --git a/MQ/unpacker/CbmDeviceUnpackTofCri.cxx b/MQ/unpacker/CbmDeviceUnpackTofCri.cxx index a04f0cd592d1eb7c65d14f736cb8a465db99188a..32b2e8be297b28c639199a2a7b6d93b19118c68f 100644 --- a/MQ/unpacker/CbmDeviceUnpackTofCri.cxx +++ b/MQ/unpacker/CbmDeviceUnpackTofCri.cxx @@ -24,13 +24,11 @@ #include "CbmTofDigi.h" //#include "CbmRawEvent.h" -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" #include "FairRuntimeDb.h" - +#include "StorableTimeslice.hpp" #include "TH1.h" #include "TH2.h" @@ -144,9 +142,9 @@ try { // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); if (entry.first == "syscmd") { @@ -154,7 +152,8 @@ try { continue; } //if(entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofCri::HandleData); - if (entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofCri::HandleParts); + 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]; @@ -299,11 +298,11 @@ Bool_t CbmDeviceUnpackTofCri::InitContainers() // 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"}; + std::string message{"CbmMcbm2018TofPar,111"}; LOG(info) << "Requesting parameter container CbmMcbm2018TofPar, sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage("CbmMcbm2018TofPar,111")); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage("CbmMcbm2018TofPar,111")); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, "parameters") > 0) { if (Receive(rep, "parameters") >= 0) { @@ -473,7 +472,7 @@ void CbmDeviceUnpackTofCri::CreateHistograms() } // 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*/) +bool CbmDeviceUnpackTofCri::HandleData(fair::mq::MessagePtr& msg, int /*index*/) { // Don't do anything with the data // Maybe add an message counter which counts the incomming messages and add @@ -485,7 +484,7 @@ bool CbmDeviceUnpackTofCri::HandleData(FairMQMessagePtr& msg, int /*index*/) std::istringstream iss(msgStr); boost::archive::binary_iarchive inputArchive(iss); - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; // CheckTimeslice(component); @@ -499,7 +498,7 @@ bool CbmDeviceUnpackTofCri::HandleData(FairMQMessagePtr& msg, int /*index*/) return true; } -bool CbmDeviceUnpackTofCri::HandleParts(FairMQParts& parts, int /*index*/) +bool CbmDeviceUnpackTofCri::HandleParts(fair::mq::Parts& parts, int /*index*/) { // Don't do anything with the data // Maybe add an message counter which counts the incomming messages and add @@ -507,7 +506,7 @@ bool CbmDeviceUnpackTofCri::HandleParts(FairMQParts& parts, int /*index*/) fNumMessages++; LOG(debug) << "Received message number " << fNumMessages << " with " << parts.Size() << " parts"; - fles::StorableTimeslice ts {0}; + fles::StorableTimeslice ts{0}; uint64_t ulTsStartTime = 0; switch (fiSelectComponents) { @@ -517,7 +516,7 @@ bool CbmDeviceUnpackTofCri::HandleParts(FairMQParts& parts, int /*index*/) boost::archive::binary_iarchive inputArchive(iss); inputArchive >> ts; //CheckTimeslice(ts); - for (size_t c {0}; c < ts.num_components(); c++) { + 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; @@ -531,7 +530,7 @@ bool CbmDeviceUnpackTofCri::HandleParts(FairMQParts& parts, int /*index*/) ulTsStartTime = ts.start_time(); } break; case 1: { - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; uint ncomp = parts.Size(); for (uint i = 0; i < ncomp; i++) { @@ -560,7 +559,7 @@ bool CbmDeviceUnpackTofCri::HandleParts(FairMQParts& parts, int /*index*/) return true; } -bool CbmDeviceUnpackTofCri::HandleMessage(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceUnpackTofCri::HandleMessage(fair::mq::MessagePtr& msg, int /*index*/) { const char* cmd = (char*) (msg->GetData()); const char cmda[4] = {*cmd}; @@ -779,7 +778,8 @@ void CbmDeviceUnpackTofCri::BuildTint(uint64_t ulTsStartTime, int iMode) } //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; + if (digi->GetTime() + fdMaxDeltaT * 0.5 < dTEndMax) + dTEnd = digi->GetTime() + fdMaxDeltaT * 0.5; else dTEnd = dTEndMax; }; @@ -796,11 +796,13 @@ void CbmDeviceUnpackTofCri::BuildTint(uint64_t ulTsStartTime, int iMode) << 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 + 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; + if (bDet[i][0] == kFALSE || bDet[i][1] == kFALSE) + break; else if (i == fiReqDigiAddr.size() - 1) { bOut = kTRUE; iDetMul = i; @@ -808,8 +810,12 @@ void CbmDeviceUnpackTofCri::BuildTint(uint64_t ulTsStartTime, int iMode) } 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 (bDet[i][0] == kTRUE && bDet[i][1] == kTRUE) { + iDetMul++; + } + if (iDetMul >= fiReqMode) { + bOut = kTRUE; + } } } @@ -834,7 +840,9 @@ void CbmDeviceUnpackTofCri::BuildTint(uint64_t ulTsStartTime, int iMode) fEventHeader[0]++; if ((Int_t) fiReqBeam > -1) { - if (bBeam) { LOG(debug) << "Beam counter is present "; } + if (bBeam) { + LOG(debug) << "Beam counter is present "; + } else { LOG(debug) << "Beam counter is not present"; bOut = kFALSE; // request beam counter for event @@ -901,7 +909,7 @@ bool CbmDeviceUnpackTofCri::SendDigis(std::vector<CbmTofDigi*> vdigi, int idx) oa << vdigi; std::string* strMsg = new std::string(oss.str()); - FairMQParts parts; + fair::mq::Parts parts; parts.AddPart(NewMessage( const_cast<char*>(strMsgE->c_str()), // data strMsgE->length(), // size @@ -924,7 +932,7 @@ bool CbmDeviceUnpackTofCri::SendDigis(std::vector<CbmTofDigi*> vdigi, int idx) 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 + fair::mq::MessagePtr 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 @@ -938,7 +946,7 @@ bool CbmDeviceUnpackTofCri::SendDigis(std::vector<CbmTofDigi*> vdigi, int idx) 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 + fair::mq::MessagePtr 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 @@ -954,13 +962,13 @@ bool CbmDeviceUnpackTofCri::SendDigis(std::vector<CbmTofDigi*> vdigi, int idx) 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 + fair::mq::MessagePtr 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 + fair::mq::MessagePtr 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 @@ -968,7 +976,7 @@ bool CbmDeviceUnpackTofCri::SendDigis(std::vector<CbmTofDigi*> vdigi, int idx) /* --------------------------------------- compiles but crashes .... --------------------------------------------------- const Int_t WSize=8; - FairMQMessagePtr msg(NewMessage(static_cast<std::vector<CbmTofDigi>*> (&vTofDigi), // data + fair::mq::MessagePtr 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 diff --git a/MQ/unpacker/CbmDeviceUnpackTofCri.h b/MQ/unpacker/CbmDeviceUnpackTofCri.h index d177f565d6bb7e3085e4b74c84563aec3dd40ee5..7366df4d14b566206713b666a2e0c275fbfd8554 100644 --- a/MQ/unpacker/CbmDeviceUnpackTofCri.h +++ b/MQ/unpacker/CbmDeviceUnpackTofCri.h @@ -16,20 +16,16 @@ #define CBMDEVICEUNPACKTOFCri_H_ #include "CbmMcbm2018TofPar.h" - -#include "MicrosliceDescriptor.hpp" -#include "Timeslice.hpp" - #include "FairMQDevice.h" - +#include "MicrosliceDescriptor.hpp" #include "Rtypes.h" #include "TMessage.h" +#include "Timeslice.hpp" +#include "gDpbMessv100.h" #include <map> #include <vector> -#include "gDpbMessv100.h" - class CbmTofUnpackAlgo; class CbmMcbm2018TofPar; class CbmTbDaqBuffer; @@ -38,20 +34,20 @@ class CbmTofDigi; class TH1; class TH2; -class CbmDeviceUnpackTofCri : public FairMQDevice { -public: +class CbmDeviceUnpackTofCri : public fair::mq::Device { + public: CbmDeviceUnpackTofCri(); virtual ~CbmDeviceUnpackTofCri(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQMessagePtr&, int); - bool HandleParts(FairMQParts&, int); - bool HandleMessage(FairMQMessagePtr&, int); + bool HandleData(fair::mq::MessagePtr&, int); + bool HandleParts(fair::mq::Parts&, int); + bool HandleMessage(fair::mq::MessagePtr&, int); virtual void BuildTint(uint64_t ulTsStartTime, int iMode = 0); virtual bool SendDigis(std::vector<CbmTofDigi*>, int); -private: + private: uint64_t fNumMessages; uint64_t fiSelectComponents; uint64_t fNumTint; @@ -178,7 +174,7 @@ private: /// 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*/) {}; + void SetNbMsInTs(size_t /*uCoreMsNb*/, size_t /*uOverlapMsNb*/){}; /// Algo settings setters void SetIgnoreOverlapMs(Bool_t bFlagIn = kTRUE); @@ -199,7 +195,7 @@ private: // special class to expose protected TMessage constructor class CbmMQTMessage : public TMessage { -public: + public: CbmMQTMessage(void* buf, Int_t len) : TMessage(buf, len) { ResetBit(kIsOwner); } }; diff --git a/MQ/unpacker/CbmDeviceUnpackTofMcbm2018.cxx b/MQ/unpacker/CbmDeviceUnpackTofMcbm2018.cxx index d0b32871b3ac9dbd573e0c206f04f8b24c584b8a..fd37e30a680300092024478e13977eda0382d231 100644 --- a/MQ/unpacker/CbmDeviceUnpackTofMcbm2018.cxx +++ b/MQ/unpacker/CbmDeviceUnpackTofMcbm2018.cxx @@ -20,14 +20,11 @@ #include "CbmTofAddress.h" #include "CbmTofDetectorId_v21a.h" // in cbmdata/tof #include "CbmTofDigi.h" - -#include "StorableTimeslice.hpp" - #include "FairMQLogger.h" #include "FairMQProgOptions.h" // device->fConfig #include "FairParGenericSet.h" #include "FairRuntimeDb.h" - +#include "StorableTimeslice.hpp" #include "TH1.h" #include "TH2.h" @@ -139,9 +136,9 @@ try { // data on this channel. //logger::SetLogLevel("INFO"); - int noChannel = fChannels.size(); + int noChannel = GetChannels().size(); LOG(info) << "Number of defined channels: " << noChannel; - for (auto const& entry : fChannels) { + for (auto const& entry : GetChannels()) { LOG(info) << "Channel name: " << entry.first; if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match."); if (entry.first == "syscmd") { @@ -149,7 +146,8 @@ try { continue; } //if(entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleData); - if (entry.first != "tofdigis") OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleParts); + if (entry.first != "tofdigis") + OnData(entry.first, &CbmDeviceUnpackTofMcbm2018::HandleParts); else { fChannelsToSend[0].push_back(entry.first); LOG(info) << "Init to send data to channel " << fChannelsToSend[0][0]; @@ -275,11 +273,11 @@ Bool_t CbmDeviceUnpackTofMcbm2018::InitContainers() // 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"}; + std::string message{"CbmMcbm2018TofPar,111"}; LOG(info) << "Requesting parameter container CbmMcbm2018TofPar, sending message: " << message; - FairMQMessagePtr req(NewSimpleMessage("CbmMcbm2018TofPar,111")); - FairMQMessagePtr rep(NewMessage()); + fair::mq::MessagePtr req(NewSimpleMessage("CbmMcbm2018TofPar,111")); + fair::mq::MessagePtr rep(NewMessage()); if (Send(req, "parameters") > 0) { if (Receive(rep, "parameters") >= 0) { @@ -331,7 +329,7 @@ void CbmDeviceUnpackTofMcbm2018::SetParContainers() FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC)); fParCList->Remove(tempObj); - std::string sParamName {tempObj->GetName()}; + std::string sParamName{tempObj->GetName()}; FairParGenericSet* newObj = dynamic_cast<FairParGenericSet*>(fRtdb->getContainer(sParamName.data())); LOG(info) << " - Get " << sParamName.data() << " at " << newObj; @@ -769,7 +767,7 @@ void CbmDeviceUnpackTofMcbm2018::CreateHistograms() } // handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0) -bool CbmDeviceUnpackTofMcbm2018::HandleData(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceUnpackTofMcbm2018::HandleData(fair::mq::MessagePtr& msg, int /*index*/) { // Don't do anything with the data // Maybe add an message counter which counts the incomming messages and add @@ -781,7 +779,7 @@ bool CbmDeviceUnpackTofMcbm2018::HandleData(FairMQMessagePtr& msg, int /*index*/ std::istringstream iss(msgStr); boost::archive::binary_iarchive inputArchive(iss); - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; inputArchive >> component; // CheckTimeslice(component); @@ -795,7 +793,7 @@ bool CbmDeviceUnpackTofMcbm2018::HandleData(FairMQMessagePtr& msg, int /*index*/ return true; } -bool CbmDeviceUnpackTofMcbm2018::HandleParts(FairMQParts& parts, int /*index*/) +bool CbmDeviceUnpackTofMcbm2018::HandleParts(fair::mq::Parts& parts, int /*index*/) { // Don't do anything with the data // Maybe add an message counter which counts the incomming messages and add @@ -803,7 +801,7 @@ bool CbmDeviceUnpackTofMcbm2018::HandleParts(FairMQParts& parts, int /*index*/) fNumMessages++; LOG(debug) << "Received message number " << fNumMessages << " with " << parts.Size() << " parts"; - fles::StorableTimeslice ts {0}; + fles::StorableTimeslice ts{0}; switch (fiSelectComponents) { case 0: { @@ -814,7 +812,7 @@ bool CbmDeviceUnpackTofMcbm2018::HandleParts(FairMQParts& parts, int /*index*/) //CheckTimeslice(ts); if (1 == fNumMessages) { LOG(info) << "Initialize TS components list to " << ts.num_components(); - for (size_t c {0}; c < ts.num_components(); c++) { + for (size_t c{0}; c < ts.num_components(); c++) { auto systemID = static_cast<int>(ts.descriptor(c, 0).sys_id); LOG(info) << "Found systemID: " << std::hex << systemID << std::dec; fUnpackerAlgo->AddMsComponentToList(c, systemID); // TOF data @@ -823,7 +821,7 @@ bool CbmDeviceUnpackTofMcbm2018::HandleParts(FairMQParts& parts, int /*index*/) DoUnpack(ts, 0); } break; case 1: { - fles::StorableTimeslice component {0}; + fles::StorableTimeslice component{0}; uint ncomp = parts.Size(); for (uint i = 0; i < ncomp; i++) { @@ -849,7 +847,7 @@ bool CbmDeviceUnpackTofMcbm2018::HandleParts(FairMQParts& parts, int /*index*/) return true; } -bool CbmDeviceUnpackTofMcbm2018::HandleMessage(FairMQMessagePtr& msg, int /*index*/) +bool CbmDeviceUnpackTofMcbm2018::HandleMessage(fair::mq::MessagePtr& msg, int /*index*/) { const char* cmd = (char*) (msg->GetData()); const char cmda[4] = {*cmd}; @@ -1051,7 +1049,8 @@ void CbmDeviceUnpackTofMcbm2018::BuildTint(int iMode = 0) } //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; + if (digi->GetTime() + fdMaxDeltaT * 0.5 < dTEndMax) + dTEnd = digi->GetTime() + fdMaxDeltaT * 0.5; else dTEnd = dTEndMax; }; @@ -1065,11 +1064,13 @@ void CbmDeviceUnpackTofMcbm2018::BuildTint(int iMode = 0) LOG(debug) << vdigi[iDigi]->ToString(); UInt_t iDetMul = 0; - if (fiReqDigiAddr.size() == 0) bOut = kTRUE; // output everything + 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; + if (bDet[i][0] == kFALSE || bDet[i][1] == kFALSE) + break; else if (i == fiReqDigiAddr.size() - 1) { bOut = kTRUE; iDetMul = i; @@ -1077,8 +1078,12 @@ void CbmDeviceUnpackTofMcbm2018::BuildTint(int iMode = 0) } 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 (bDet[i][0] == kTRUE && bDet[i][1] == kTRUE) { + iDetMul++; + } + if (iDetMul >= fiReqMode) { + bOut = kTRUE; + } } } @@ -1102,7 +1107,9 @@ void CbmDeviceUnpackTofMcbm2018::BuildTint(int iMode = 0) fEventHeader[0]++; if ((Int_t) fiReqBeam > -1) { - if (bBeam) { LOG(debug) << "Beam counter is present "; } + if (bBeam) { + LOG(debug) << "Beam counter is present "; + } else { LOG(debug) << "Beam counter is not present"; bOut = kFALSE; // request beam counter for event @@ -1157,7 +1164,7 @@ bool CbmDeviceUnpackTofMcbm2018::SendDigis(std::vector<CbmTofDigi*> vdigi, int i oa << vdigi; std::string* strMsg = new std::string(oss.str()); - FairMQParts parts; + fair::mq::Parts parts; parts.AddPart(NewMessage( const_cast<char*>(strMsgE->c_str()), // data strMsgE->length(), // size @@ -1180,7 +1187,7 @@ bool CbmDeviceUnpackTofMcbm2018::SendDigis(std::vector<CbmTofDigi*> vdigi, int i 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 + fair::mq::MessagePtr 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 @@ -1194,7 +1201,7 @@ bool CbmDeviceUnpackTofMcbm2018::SendDigis(std::vector<CbmTofDigi*> vdigi, int 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 + fair::mq::MessagePtr 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 @@ -1210,13 +1217,13 @@ bool CbmDeviceUnpackTofMcbm2018::SendDigis(std::vector<CbmTofDigi*> vdigi, int i 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 + fair::mq::MessagePtr 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 + fair::mq::MessagePtr 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 @@ -1224,7 +1231,7 @@ bool CbmDeviceUnpackTofMcbm2018::SendDigis(std::vector<CbmTofDigi*> vdigi, int i /* --------------------------------------- compiles but crashes .... --------------------------------------------------- const Int_t WSize=8; - FairMQMessagePtr msg(NewMessage(static_cast<std::vector<CbmTofDigi>*> (&vTofDigi), // data + fair::mq::MessagePtr 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 diff --git a/MQ/unpacker/CbmDeviceUnpackTofMcbm2018.h b/MQ/unpacker/CbmDeviceUnpackTofMcbm2018.h index 58cc4fe8b39843531de6ec30b4fb05991a3a1411..5fa372d2af2032176b395e7f5485d4dc0994cef5 100644 --- a/MQ/unpacker/CbmDeviceUnpackTofMcbm2018.h +++ b/MQ/unpacker/CbmDeviceUnpackTofMcbm2018.h @@ -17,19 +17,15 @@ #include "CbmMcbm2018TofPar.h" #include "CbmMqTMessage.h" - -#include "MicrosliceDescriptor.hpp" -#include "Timeslice.hpp" - #include "FairMQDevice.h" - +#include "MicrosliceDescriptor.hpp" #include "Rtypes.h" +#include "Timeslice.hpp" +#include "gDpbMessv100.h" #include <map> #include <vector> -#include "gDpbMessv100.h" - class CbmMcbm2018UnpackerAlgoTof; class CbmMcbm2018TofPar; class CbmTbDaqBuffer; @@ -38,20 +34,20 @@ class CbmTofDigi; class TH1; class TH2; -class CbmDeviceUnpackTofMcbm2018 : public FairMQDevice { -public: +class CbmDeviceUnpackTofMcbm2018 : public fair::mq::Device { + public: CbmDeviceUnpackTofMcbm2018(); virtual ~CbmDeviceUnpackTofMcbm2018(); -protected: + protected: virtual void InitTask(); - bool HandleData(FairMQMessagePtr&, int); - bool HandleParts(FairMQParts&, int); - bool HandleMessage(FairMQMessagePtr&, int); + bool HandleData(fair::mq::MessagePtr&, int); + bool HandleParts(fair::mq::Parts&, int); + bool HandleMessage(fair::mq::MessagePtr&, int); virtual void BuildTint(int); virtual bool SendDigis(std::vector<CbmTofDigi*>, int); -private: + private: uint64_t fNumMessages; uint64_t fiSelectComponents; uint64_t fNumTint; @@ -178,7 +174,7 @@ private: /// 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*/) {}; + void SetNbMsInTs(size_t /*uCoreMsNb*/, size_t /*uOverlapMsNb*/){}; /// Algo settings setters void SetIgnoreOverlapMs(Bool_t bFlagIn = kTRUE); diff --git a/MQ/unpacker/runUnpackTofCri.cxx b/MQ/unpacker/runUnpackTofCri.cxx index c01c29340d8d4fec04709d3578bba2eaac5401ff..37f933c97cb8dab8ea83232e9fc39a3084cef346 100644 --- a/MQ/unpacker/runUnpackTofCri.cxx +++ b/MQ/unpacker/runUnpackTofCri.cxx @@ -3,12 +3,11 @@ Authors: Norbert Herrmann [committer] */ #include "CbmDeviceUnpackTofCri.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -36,4 +35,4 @@ void addCustomOptions(bpo::options_description& options) 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(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceUnpackTofCri(); } diff --git a/MQ/unpacker/runUnpackTofMcbm2018.cxx b/MQ/unpacker/runUnpackTofMcbm2018.cxx index 533a0696a43dd783c77750028b1a21bfc7956878..75708381fb2dac1c135e8137ec30a74c44d0c5e6 100644 --- a/MQ/unpacker/runUnpackTofMcbm2018.cxx +++ b/MQ/unpacker/runUnpackTofMcbm2018.cxx @@ -3,12 +3,11 @@ Authors: Norbert Herrmann [committer] */ #include "CbmDeviceUnpackTofMcbm2018.h" +#include "runFairMQDevice.h" #include <iomanip> #include <string> -#include "runFairMQDevice.h" - namespace bpo = boost::program_options; using namespace std; @@ -36,4 +35,4 @@ void addCustomOptions(bpo::options_description& options) 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 CbmDeviceUnpackTofMcbm2018(); } +FairMQDevicePtr getDevice(const fair::mq::ProgOptions& /*config*/) { return new CbmDeviceUnpackTofMcbm2018(); }