From 2dc858da64ee1be8cd5f23f43992f9e4946eecbb Mon Sep 17 00:00:00 2001 From: "P.-A. Loizeau" <p.-a.loizeau@gsi.de> Date: Thu, 22 Apr 2021 13:14:53 +0200 Subject: [PATCH] Apply clang format --- MQ/histoServer/CbmMqHistoServer.cxx | 34 ++++++++---------- MQ/monitor/CbmDeviceMonitorT0.cxx | 34 ++++++++++-------- MQ/monitor/CbmDeviceMonitorTof.cxx | 33 ++++++++++-------- MQ/source/CbmMQTsaMultiSampler.cxx | 54 ++++++++++++----------------- fles/mcbm2018/CbmMcbm2018Source.cxx | 2 +- 5 files changed, 78 insertions(+), 79 deletions(-) diff --git a/MQ/histoServer/CbmMqHistoServer.cxx b/MQ/histoServer/CbmMqHistoServer.cxx index d9f8cd04aa..105efdd170 100644 --- a/MQ/histoServer/CbmMqHistoServer.cxx +++ b/MQ/histoServer/CbmMqHistoServer.cxx @@ -219,49 +219,45 @@ bool CbmMqHistoServer::ReceiveCanvasConfig(FairMQMessagePtr& msg, int /*index*/) bool CbmMqHistoServer::ReceiveConfigAndData(FairMQParts& parts, int /*index*/) { /// Reject anything but a at least Header + Histo Config + Canvas Config + Histo Data - if( parts.Size() < 4 ) - { - if( 1 == parts.Size() ) - { + if (parts.Size() < 4) { + if (1 == parts.Size()) { /// PAL, 09/04/2021, Debug message catching missed method overlad/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 LOG(debug) << "CbmMqHistoServer::ReceiveConfigAndData => only 1 parts found in input, " - << "assuming data only message routed to wrong method!"; - return ReceiveData( parts.At(0), 0 ); - } // if( 1 == parts.Size() ) + << "assuming data only message routed to wrong method!"; + return ReceiveData(parts.At(0), 0); + } // if( 1 == parts.Size() ) LOG(fatal) << "CbmMqHistoServer::ReceiveConfigAndData => Wrong number of parts: " << parts.Size() << " instead of at least 4 (Header + Histo Config + Canvas config + Data)!"; - } // if( parts.Size() < 4 ) + } // if( parts.Size() < 4 ) - LOG(info) << "CbmMqHistoServer::ReceiveConfigAndData => Received composed message with " - << parts.Size() << " parts"; + LOG(info) << "CbmMqHistoServer::ReceiveConfigAndData => Received composed message with " << parts.Size() << " parts"; /// Header contains a pair of std::pair<uint32_t, uint32_t> pairHeader; - Deserialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*parts.At(0),pairHeader); + Deserialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*parts.At(0), pairHeader); LOG(info) << "CbmMqHistoServer::ReceiveConfigAndData => Received configuration for " << pairHeader.first << " histos and " << pairHeader.second << " canvases"; - if( parts.Size() != 1 + pairHeader.first + pairHeader.second + 1 ) - { + if (parts.Size() != 1 + pairHeader.first + pairHeader.second + 1) { LOG(fatal) << "CbmMqHistoServer::ReceiveConfigAndData => Number of parts not matching header: " << parts.Size() << " instead of " << 1 + pairHeader.first + pairHeader.second + 1; - } // if( parts.Size() != 1 + pairHeader.first + pairHeader.second ) + } // if( parts.Size() != 1 + pairHeader.first + pairHeader.second ) /// Decode parts for histograms configuration for (uint32_t uHisto = 0; uHisto < pairHeader.first; ++uHisto) { - ReceiveHistoConfig( parts.At(1 + uHisto), 0 ); - } // for (UInt_t uHisto = 0; uHisto < pairHeader.first; ++uHisto) + ReceiveHistoConfig(parts.At(1 + uHisto), 0); + } // for (UInt_t uHisto = 0; uHisto < pairHeader.first; ++uHisto) /// Decode parts for histograms configuration for (uint32_t uCanv = 0; uCanv < pairHeader.second; ++uCanv) { - ReceiveCanvasConfig( parts.At(1 + pairHeader.first + uCanv), 0 ); - } // for (UInt_t uCanv = 0; uCanv < pairHeader.second; ++uCanv) + ReceiveCanvasConfig(parts.At(1 + pairHeader.first + uCanv), 0); + } // for (UInt_t uCanv = 0; uCanv < pairHeader.second; ++uCanv) /// Decode the histograms data now that the configuration is loaded - ReceiveData( parts.At(1 + pairHeader.first + pairHeader.second), 0 ); + ReceiveData(parts.At(1 + pairHeader.first + pairHeader.second), 0); return true; } diff --git a/MQ/monitor/CbmDeviceMonitorT0.cxx b/MQ/monitor/CbmDeviceMonitorT0.cxx index 5b37350e05..4cfb01dad6 100644 --- a/MQ/monitor/CbmDeviceMonitorT0.cxx +++ b/MQ/monitor/CbmDeviceMonitorT0.cxx @@ -209,7 +209,8 @@ bool CbmDeviceMonitorT0::InitContainers() return initOK; } -bool CbmDeviceMonitorT0::InitHistograms() { +bool CbmDeviceMonitorT0::InitHistograms() +{ /// Histos creation and obtain pointer on them /// Trigger histo creation on all associated algos bool initOK = fMonitorAlgo->CreateHistograms(); @@ -258,14 +259,17 @@ bool CbmDeviceMonitorT0::InitHistograms() { bool CbmDeviceMonitorT0::HandleData(FairMQMessagePtr& msg, int /*index*/) { - if( 0 == fulNumMessages) try { - InitContainers(); - } catch (InitTaskError& e) { - LOG(error) << e.what(); - ChangeState(fair::mq::Transition::ErrorFound); - } + if (0 == fulNumMessages) { + try { + InitContainers(); + } + catch (InitTaskError& e) { + LOG(error) << e.what(); + ChangeState(fair::mq::Transition::ErrorFound); + } + } // if( 0 == fulNumMessages) - if( 0 == fulNumMessages) InitHistograms(); + if (0 == fulNumMessages) InitHistograms(); fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with size " << msg->GetSize(); @@ -291,9 +295,11 @@ bool CbmDeviceMonitorT0::HandleData(FairMQMessagePtr& msg, int /*index*/) if ((fdMaxPublishTime < elapsedSeconds.count()) || (0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count())) { if (!fbConfigSent) { + // Send the configuration only once per run! fbConfigSent = SendHistoConfAndData(); - } // if( !fbConfigSent ) - else SendHistograms(); + } // if( !fbConfigSent ) + else + SendHistograms(); fLastPublishTime = std::chrono::system_clock::now(); } // if( ( fdMaxPublishTime < elapsedSeconds.count() ) || ( 0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count() ) ) @@ -304,9 +310,9 @@ bool CbmDeviceMonitorT0::HandleData(FairMQMessagePtr& msg, int /*index*/) bool CbmDeviceMonitorT0::SendHistoConfAndData() { /// Prepare multiparts message and header - std::pair<uint32_t, uint32_t> pairHeader( fvpsHistosFolder.size(), fvpsCanvasConfig.size() ); + std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); FairMQMessagePtr messageHeader(NewMessage()); - Serialize< BoostSerializer< std::pair< uint32_t, uint32_t > > >(*messageHeader, pairHeader); + Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); FairMQParts partsOut; partsOut.AddPart(std::move(messageHeader)); @@ -317,7 +323,7 @@ bool CbmDeviceMonitorT0::SendHistoConfAndData() Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); partsOut.AddPart(std::move(messageHist)); - } // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) + } // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message @@ -325,7 +331,7 @@ bool CbmDeviceMonitorT0::SendHistoConfAndData() Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); partsOut.AddPart(std::move(messageCan)); - } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) + } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) /// Serialize the array of histos into a single MQ message FairMQMessagePtr msgHistos(NewMessage()); diff --git a/MQ/monitor/CbmDeviceMonitorTof.cxx b/MQ/monitor/CbmDeviceMonitorTof.cxx index 1b9e16975e..a176266ea5 100644 --- a/MQ/monitor/CbmDeviceMonitorTof.cxx +++ b/MQ/monitor/CbmDeviceMonitorTof.cxx @@ -217,14 +217,17 @@ 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*/) { - if( 0 == fulNumMessages) try { - InitContainers(); - } catch (InitTaskError& e) { - LOG(error) << e.what(); - ChangeState(fair::mq::Transition::ErrorFound); - } - - if( 0 == fulNumMessages) InitHistograms(); + if (0 == fulNumMessages) { + try { + InitContainers(); + } + catch (InitTaskError& e) { + LOG(error) << e.what(); + ChangeState(fair::mq::Transition::ErrorFound); + } + } // if( 0 == fulNumMessages) + + if (0 == fulNumMessages) InitHistograms(); fulNumMessages++; LOG(debug) << "Received message number " << fulNumMessages << " with size " << msg->GetSize(); @@ -250,9 +253,11 @@ bool CbmDeviceMonitorTof::HandleData(FairMQMessagePtr& msg, int /*index*/) if ((fdMaxPublishTime < elapsedSeconds.count()) || (0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count())) { if (!fbConfigSent) { + // Send the configuration only once per run! fbConfigSent = SendHistoConfAndData(); - } // if( !fbConfigSent ) - else SendHistograms(); + } // if( !fbConfigSent ) + else + SendHistograms(); fLastPublishTime = std::chrono::system_clock::now(); } // if( ( fdMaxPublishTime < elapsedSeconds.count() ) || ( 0 == fulNumMessages % fuPublishFreqTs && fdMinPublishTime < elapsedSeconds.count() ) ) @@ -263,9 +268,9 @@ bool CbmDeviceMonitorTof::HandleData(FairMQMessagePtr& msg, int /*index*/) bool CbmDeviceMonitorTof::SendHistoConfAndData() { /// Prepare multiparts message and header - std::pair<uint32_t, uint32_t> pairHeader( fvpsHistosFolder.size(), fvpsCanvasConfig.size() ); + std::pair<uint32_t, uint32_t> pairHeader(fvpsHistosFolder.size(), fvpsCanvasConfig.size()); FairMQMessagePtr messageHeader(NewMessage()); - Serialize< BoostSerializer< std::pair< uint32_t, uint32_t > > >(*messageHeader, pairHeader); + Serialize<BoostSerializer<std::pair<uint32_t, uint32_t>>>(*messageHeader, pairHeader); FairMQParts partsOut; partsOut.AddPart(std::move(messageHeader)); @@ -276,7 +281,7 @@ bool CbmDeviceMonitorTof::SendHistoConfAndData() Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, fvpsHistosFolder[uHisto]); partsOut.AddPart(std::move(messageHist)); - } // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) + } // for (UInt_t uHisto = 0; uHisto < fvpsHistosFolder.size(); ++uHisto) for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) { /// Serialize the vector of canvas config into a single MQ message @@ -284,7 +289,7 @@ bool CbmDeviceMonitorTof::SendHistoConfAndData() Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, fvpsCanvasConfig[uCanv]); partsOut.AddPart(std::move(messageCan)); - } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) + } // for (UInt_t uCanv = 0; uCanv < fvpsCanvasConfig.size(); ++uCanv) /// Serialize the array of histos into a single MQ message FairMQMessagePtr msgHistos(NewMessage()); diff --git a/MQ/source/CbmMQTsaMultiSampler.cxx b/MQ/source/CbmMQTsaMultiSampler.cxx index b810a9f542..3564ccfe3f 100644 --- a/MQ/source/CbmMQTsaMultiSampler.cxx +++ b/MQ/source/CbmMQTsaMultiSampler.cxx @@ -386,23 +386,20 @@ bool CbmMQTsaMultiSampler::InitHistograms() // LOG(info) << "Registering " << vHistos[ uHisto ].first->GetName() // << " in " << vHistos[ uHisto ].second.data() // ; - fArrayHisto.Add( vHistos[ uHisto ].first ); - std::pair< std::string, std::string > psHistoConfig( vHistos[ uHisto ].first->GetName(), - vHistos[ uHisto ].second ); - fvpsHistosFolder.push_back( psHistoConfig ); + fArrayHisto.Add(vHistos[uHisto].first); + std::pair<std::string, std::string> psHistoConfig(vHistos[uHisto].first->GetName(), vHistos[uHisto].second); + fvpsHistosFolder.push_back(psHistoConfig); /// Serialize the vector of histo config into a single MQ message - FairMQMessagePtr messageHist( NewMessage() ); - Serialize< BoostSerializer < std::pair< std::string, std::string > > >( *messageHist, psHistoConfig ); + FairMQMessagePtr messageHist(NewMessage()); + Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageHist, psHistoConfig); /// Send message to the common histogram config messages queue - if( Send( messageHist, fsChannelNameHistosConfig ) < 0 ) - { + if (Send(messageHist, fsChannelNameHistosConfig) < 0) { LOG(fatal) << "Problem sending histo config"; - } // if( Send( messageHist, fsChannelNameHistosConfig ) < 0 ) + } // if( Send( messageHist, fsChannelNameHistosConfig ) < 0 ) - LOG(info) << "Config of hist " << psHistoConfig.first.data() - << " in folder " << psHistoConfig.second.data() ; + LOG(info) << "Config of hist " << psHistoConfig.first.data() << " in folder " << psHistoConfig.second.data(); } // for( UInt_t uHisto = 0; uHisto < vHistos.size(); ++uHisto ) /// Create canvas config vector @@ -411,25 +408,23 @@ bool CbmMQTsaMultiSampler::InitHistograms() for (UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv) { // LOG(info) << "Registering " << vCanvases[ uCanv ].first->GetName() // << " in " << vCanvases[ uCanv ].second.data(); - std::string sCanvName = (vCanvases[ uCanv ].first)->GetName(); - std::string sCanvConf = GenerateCanvasConfigString( vCanvases[ uCanv ].first ); + std::string sCanvName = (vCanvases[uCanv].first)->GetName(); + std::string sCanvConf = GenerateCanvasConfigString(vCanvases[uCanv].first); - std::pair< std::string, std::string > psCanvConfig( sCanvName, sCanvConf ); + std::pair<std::string, std::string> psCanvConfig(sCanvName, sCanvConf); - fvpsCanvasConfig.push_back( psCanvConfig ); + fvpsCanvasConfig.push_back(psCanvConfig); /// Serialize the vector of canvas config into a single MQ message - FairMQMessagePtr messageCan( NewMessage() ); - Serialize< BoostSerializer < std::pair< std::string, std::string > > >( *messageCan, psCanvConfig ); + FairMQMessagePtr messageCan(NewMessage()); + Serialize<BoostSerializer<std::pair<std::string, std::string>>>(*messageCan, psCanvConfig); /// Send message to the common canvas config messages queue - if( Send( messageCan, fsChannelNameCanvasConfig ) < 0 ) - { + if (Send(messageCan, fsChannelNameCanvasConfig) < 0) { LOG(fatal) << "Problem sending canvas config"; - } // if( Send( messageCan, fsChannelNameCanvasConfig ) < 0 ) + } // if( Send( messageCan, fsChannelNameCanvasConfig ) < 0 ) - LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() - << " is " << psCanvConfig.second.data() ; + LOG(info) << "Config string of Canvas " << psCanvConfig.first.data() << " is " << psCanvConfig.second.data(); } // for( UInt_t uCanv = 0; uCanv < vCanvases.size(); ++uCanv ) return true; @@ -437,15 +432,12 @@ 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) ) - { - dynamic_cast< fles::TimesliceMultiSubscriber *>(fSource)->InitTimesliceSubscriber(); - } // if( 0 == fTSCounter && nullptr != dynamic_cast< fles::TimesliceMultiSubscriber >(fSource) ) + if (0 == fTSCounter && nullptr != dynamic_cast<fles::TimesliceMultiSubscriber*>(fSource)) { + dynamic_cast<fles::TimesliceMultiSubscriber*>(fSource)->InitTimesliceSubscriber(); + } // if( 0 == fTSCounter && nullptr != dynamic_cast< fles::TimesliceMultiSubscriber >(fSource) ) auto timeslice = fSource->get(); if (timeslice) { @@ -490,7 +482,7 @@ bool CbmMQTsaMultiSampler::ConditionalRun() LOG(info) << "Missed Timeslices. Old TS Index was " << fuPrevTsIndex << " New TS Index is " << uTsIndex << " diff is " << uTsIndex - fuPrevTsIndex << " Missing are " << uTsIndex - fuPrevTsIndex - 1; - if( "" != fsChannelNameMissedTs ) { + if ("" != fsChannelNameMissedTs) { /// Add missing TS indices to a vector and send it in appropriate channel std::vector<uint64_t> vulMissedIndices; for (uint64_t ulMiss = fuPrevTsIndex + 1; ulMiss < uTsIndex; ++ulMiss) { @@ -506,7 +498,7 @@ bool CbmMQTsaMultiSampler::ConditionalRun() return false; } // if( !SendMissedTsIdx( vulMissedIndices ) ) - } // if( "" != fsChannelNameMissedTs ) + } // if( "" != fsChannelNameMissedTs ) if (0 < fuPublishFreqTs) { fhMissedTS->Fill(1, uTsIndex - fuPrevTsIndex - 1); diff --git a/fles/mcbm2018/CbmMcbm2018Source.cxx b/fles/mcbm2018/CbmMcbm2018Source.cxx index 53a7328adb..2135df8022 100644 --- a/fles/mcbm2018/CbmMcbm2018Source.cxx +++ b/fles/mcbm2018/CbmMcbm2018Source.cxx @@ -73,7 +73,7 @@ Bool_t CbmMcbm2018Source::Init() /// Initialize the Multisubscriber /// (This restores the original behavior after modifications needed to make the MQ version - dynamic_cast< fles::TimesliceMultiSubscriber *>(fSource.get())->InitTimesliceSubscriber(); + dynamic_cast<fles::TimesliceMultiSubscriber*>(fSource.get())->InitTimesliceSubscriber(); if (!fSource) { LOG(fatal) << "Could not connect to publisher."; } } -- GitLab