Commit cda923ab authored by Administrator's avatar Administrator
Browse files

Code formatting

Apply code formatting to all source/header files and root macros.
parent 68f6f883
......@@ -57,25 +57,25 @@ CbmRoot_Continuous:
- find . -name "all_*.par" -delete
- cd ..
#FormatCheck:
# stage: check
# tags:
# - CbmRoot
# only:
# refs:
# - merge_requests
# variables:
# - $CI_MERGE_REQUEST_PROJECT_PATH == "computing/cbmroot"
# script:
# - echo "export FAIRSOFT_VERSION=jun19p1" > env.sh
# - echo "export FAIRROOT_VERSION=v18.2.0" >> env.sh
# - echo "export SIMPATH=/cvmfs/fairroot.gsi.de/fairsoft/\${FAIRSOFT_VERSION}" >> env.sh
# - echo "export FAIRROOTPATH=/cvmfs/fairroot.gsi.de/fairroot/\${FAIRROOT_VERSION}_fairsoft-\${FAIRSOFT_VERSION}" >> env.sh
# - echo "export BUILDDIR=$PWD/build" >> env.sh
# - echo "export SOURCEDIR=$PWD" >> env.sh
# - echo "export PATH=/cvmfs/fairroot.gsi.de/clang-format-8.0.1:\$SIMPATH/bin:$PATH:/cvmfs/it.gsi.de/compiler/llvm/6.0.1/bin/" >> env.sh
# - echo "export LABEL=format-check_MR-\${CI_MERGE_REQUEST_IID}" >> env.sh
# - . ./env.sh && ctest -S cmake/scripts/checkformat.cmake -VV
FormatCheck:
stage: check
tags:
- CbmRoot
only:
refs:
- merge_requests
variables:
- $CI_MERGE_REQUEST_PROJECT_PATH == "computing/cbmroot"
script:
- echo "export FAIRSOFT_VERSION=jun19p1" > env.sh
- echo "export FAIRROOT_VERSION=v18.2.0" >> env.sh
- echo "export SIMPATH=/cvmfs/fairroot.gsi.de/fairsoft/\${FAIRSOFT_VERSION}" >> env.sh
- echo "export FAIRROOTPATH=/cvmfs/fairroot.gsi.de/fairroot/\${FAIRROOT_VERSION}_fairsoft-\${FAIRSOFT_VERSION}" >> env.sh
- echo "export BUILDDIR=$PWD/build" >> env.sh
- echo "export SOURCEDIR=$PWD" >> env.sh
- echo "export PATH=/cvmfs/fairroot.gsi.de/clang-format-8.0.1:\$SIMPATH/bin:$PATH:/cvmfs/it.gsi.de/compiler/llvm/6.0.1/bin/" >> env.sh
- echo "export LABEL=format-check_MR-\${CI_MERGE_REQUEST_IID}" >> env.sh
- . ./env.sh && ctest -S cmake/scripts/checkformat.cmake -VV
CbmRoot_Merge:
stage: build
......
......@@ -2,49 +2,49 @@
#include "FairMQDevice.h"
CbmMQChannels::CbmMQChannels(std::vector<std::string> allowedChannels)
: fAllowedChannels{allowedChannels}
{
fChannelsToSend.resize(fAllowedChannels.size());
for(auto &entry : fChannelsToSend) {
entry.push_back("");
}
fComponentsToSend.resize(fAllowedChannels.size());
}
bool CbmMQChannels::IsChannelNameAllowed(std::string channelName)
{
for(auto const &entry : fAllowedChannels) {
: fAllowedChannels {allowedChannels} {
fChannelsToSend.resize(fAllowedChannels.size());
for (auto& entry : fChannelsToSend) {
entry.push_back("");
}
fComponentsToSend.resize(fAllowedChannels.size());
}
bool CbmMQChannels::IsChannelNameAllowed(std::string channelName) {
for (auto const& entry : fAllowedChannels) {
std::size_t pos1 = channelName.find(entry);
if (pos1!=std::string::npos) {
if (pos1 != std::string::npos) {
const std::vector<std::string>::const_iterator pos =
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const std::vector<std::string>::size_type idx = pos-fAllowedChannels.begin();
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const std::vector<std::string>::size_type idx =
pos - fAllowedChannels.begin();
LOG(info) << "Found " << entry << " in " << channelName;
LOG(info) << "Channel name " << channelName
<< " found in list of allowed channel names at position " << idx;
<< " found in list of allowed channel names at position "
<< idx;
fComponentsToSend[idx]++;
// The array is initialized with one empty string. If the string has still teh value from initialization
// exchnge the value by the new channel name. In any other case add one more entry to the vector
if (fChannelsToSend[idx].size() == 1 && fChannelsToSend[idx].at(0).empty()) {
fChannelsToSend[idx].at(0) = channelName;
if (fChannelsToSend[idx].size() == 1
&& fChannelsToSend[idx].at(0).empty()) {
fChannelsToSend[idx].at(0) = channelName;
} else {
fChannelsToSend[idx].push_back(channelName);
fChannelsToSend[idx].push_back(channelName);
}
return true;
}
}
LOG(info) << "Channel name " << channelName
<< " not found in list of allowed channel names.";
<< " not found in list of allowed channel names.";
LOG(info) << "The allowed channels are: ";
for(auto const &entry : fAllowedChannels) {
LOG(info) << entry;
for (auto const& entry : fAllowedChannels) {
LOG(info) << entry;
}
LOG(error) << "Stop device.";
return false;
}
bool CbmMQChannels::CheckChannels(FairMQDevice* device)
{
bool CbmMQChannels::CheckChannels(FairMQDevice* device) {
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
......@@ -55,7 +55,7 @@ bool CbmMQChannels::CheckChannels(FairMQDevice* device)
// data on this channel.
int noChannel = device->fChannels.size();
LOG(info) << "Number of defined output channels: " << noChannel;
for(auto const &entry : device->fChannels) {
for (auto const& entry : device->fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) return false;
}
......
#ifndef CBMMQCHANNELS_H_
#define CBMMQCHANNELS_H_
#include <vector>
#include <string>
#include <vector>
class FairMQDevice;
class CbmMQChannels
{
public:
class CbmMQChannels {
public:
CbmMQChannels(std::vector<std::string>);
bool IsChannelNameAllowed(std::string channelName);
bool CheckChannels(FairMQDevice* device);
std::vector<int> GetComponentsToSend() { return fComponentsToSend; }
std::vector<std::vector<std::string>> GetChannelsToSend() { return fChannelsToSend; }
private:
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 { {} };
std::vector<std::vector<std::string>> fChannelsToSend {{}};
};
#endif
......@@ -14,16 +14,14 @@ namespace cbm {
ErrorFound
};
enum class State : int {
Running
};
enum class State : int { Running };
void ChangeState(FairMQDevice* device, cbm::mq::Transition transition) {
#ifdef HAVE_FAIRMQSTATEMACHINE
if(transition == cbm::mq::Transition::ErrorFound) {
device->ChangeState(FairMQStateMachine::Event::ERROR_FOUND);
if (transition == cbm::mq::Transition::ErrorFound) {
device->ChangeState(FairMQStateMachine::Event::ERROR_FOUND);
} else if (transition == cbm::mq::Transition::End) {
device->ChangeState(FairMQStateMachine::Event::END);
device->ChangeState(FairMQStateMachine::Event::END);
} else if (transition == cbm::mq::Transition::Ready) {
device->ChangeState(FairMQStateMachine::Event::internal_READY);
} else if (transition == cbm::mq::Transition::DeviceReady) {
......@@ -33,53 +31,52 @@ namespace cbm {
} else {
LOG(fatal) << "State Change not yet implemented";
device->ChangeState(FairMQStateMachine::Event::ERROR_FOUND);
}
}
#else
if(transition == cbm::mq::Transition::ErrorFound) {
device->ChangeState(fair::mq::Transition::ErrorFound);
} else if (transition == cbm::mq::Transition::End) {
if (transition == cbm::mq::Transition::ErrorFound) {
device->ChangeState(fair::mq::Transition::ErrorFound);
} else if (transition == cbm::mq::Transition::End) {
device->ChangeState(fair::mq::Transition::End);
} else if (transition == cbm::mq::Transition::Ready) {
} else if (transition == cbm::mq::Transition::Ready) {
device->ChangeState(fair::mq::Transition::ResetTask);
} else if (transition == cbm::mq::Transition::DeviceReady) {
} else if (transition == cbm::mq::Transition::DeviceReady) {
device->ChangeState(fair::mq::Transition::ResetDevice);
} else if (transition == cbm::mq::Transition::Idle) {
} else if (transition == cbm::mq::Transition::Idle) {
device->ChangeState(fair::mq::Transition::Stop);
} else {
LOG(fatal) << "State Change not yet implemented";
device->ChangeState(fair::mq::Transition::ErrorFound);
LOG(fatal) << "State Change not yet implemented";
device->ChangeState(fair::mq::Transition::ErrorFound);
}
#endif
}
void LogState(FairMQDevice* device) {
#ifdef HAVE_FAIRMQSTATEMACHINE
// LOG(info) << "Current State: " << FairMQStateMachine::GetCurrentStateName();
LOG(info) << "Current State: " << device->GetCurrentStateName();
#ifdef HAVE_FAIRMQSTATEMACHINE
// LOG(info) << "Current State: " << FairMQStateMachine::GetCurrentStateName();
LOG(info) << "Current State: " << device->GetCurrentStateName();
#else
LOG(info) << "Current State: " << device->GetCurrentStateName();
LOG(info) << "Current State: " << device->GetCurrentStateName();
#endif
}
bool CheckCurrentState(FairMQDevice* device, cbm::mq::State state) {
#ifdef HAVE_FAIRMQSTATEMACHINE
if(state == cbm::mq::State::Running) {
return device->CheckCurrentState(FairMQStateMachine::State::RUNNING);
} else {
LOG(fatal) << "State not yet implemented";
device->ChangeState(FairMQStateMachine::Event::ERROR_FOUND);
return 0;
}
#ifdef HAVE_FAIRMQSTATEMACHINE
if (state == cbm::mq::State::Running) {
return device->CheckCurrentState(FairMQStateMachine::State::RUNNING);
} else {
LOG(fatal) << "State not yet implemented";
device->ChangeState(FairMQStateMachine::Event::ERROR_FOUND);
return 0;
}
#else
if(state == cbm::mq::State::Running) {
return !(device->NewStatePending());
} else {
LOG(fatal) << "State not yet implemented";
device->ChangeState(fair::mq::Transition::ErrorFound);
return 0;
}
#endif
if (state == cbm::mq::State::Running) {
return !(device->NewStatePending());
} else {
LOG(fatal) << "State not yet implemented";
device->ChangeState(fair::mq::Transition::ErrorFound);
return 0;
}
#endif
}
}
}
} // namespace mq
} // namespace cbm
......@@ -8,91 +8,96 @@
#include "FairMQDevice.h"
#include "Timeslice.hpp"
#include "TMessage.h"
#include "Timeslice.hpp"
#include "TStopwatch.h"
class CbmStar2019EventBuilderEtofAlgo;
class CbmStar2019TofPar;
class CbmDeviceEventBuilderEtofStar2019: public FairMQDevice
{
public:
CbmDeviceEventBuilderEtofStar2019();
virtual ~CbmDeviceEventBuilderEtofStar2019();
virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
virtual void Reset();
virtual void Finish();
void SetParContainers();
Bool_t InitContainers();
Bool_t ReInitContainers();
void SetSandboxMode( Bool_t bSandboxMode = kTRUE ){ fbSandboxMode = bSandboxMode; }
void SetEventDumpEnable( Bool_t bDumpEna = kTRUE );
/// 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*/ ){};
CbmDeviceEventBuilderEtofStar2019(const CbmDeviceEventBuilderEtofStar2019&) = delete;
CbmDeviceEventBuilderEtofStar2019 operator=(const CbmDeviceEventBuilderEtofStar2019&) = delete;
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
bool HandleParts(FairMQParts&, int);
bool HandleMessage(FairMQMessagePtr&, int);
virtual bool SendEvent(std::vector<Int_t>, int);
virtual bool SendSubevent(uint,char*,int, int);
private:
uint64_t fNumMessages;
/// Control flags
Bool_t fbMonitorMode; //! Switch ON the filling of a minimal set of histograms
Bool_t fbDebugMonitorMode; //! Switch ON the filling of a additional set of histograms
Bool_t fbSandboxMode; //! Switch OFF the emission of data toward the STAR DAQ
Bool_t fbEventDumpEna; //! Switch ON the dumping of the events to a binary file
/// Parameters management
TList* fParCList;
/// Statistics & first TS rejection
uint64_t fulTsCounter;
uint64_t fNumEvt;
bool CheckTimeslice(const fles::Timeslice& ts);
bool IsChannelNameAllowed(std::string channelName);
std::vector<std::string> fAllowedChannels
= {"tofcomponent","parameters","etofevts","syscmd"};
std::vector<std::vector<std::string>> fChannelsToSend = { {},{},{} };
/// Processing algo
CbmStar2019EventBuilderEtofAlgo * fEventBuilderAlgo;
TStopwatch fTimer;
CbmStar2019TofPar* fUnpackPar; //!
/// Event dump to binary file
std::fstream * fpBinDumpFile;
const UInt_t kuBinDumpBegWord = 0xFEEDBEAF;
const UInt_t kuBinDumpEndWord = 0xFAEBDEEF;
class CbmDeviceEventBuilderEtofStar2019 : public FairMQDevice {
public:
CbmDeviceEventBuilderEtofStar2019();
virtual ~CbmDeviceEventBuilderEtofStar2019();
virtual Bool_t DoUnpack(const fles::Timeslice& ts, size_t component);
virtual void Reset();
virtual void Finish();
void SetParContainers();
Bool_t InitContainers();
Bool_t ReInitContainers();
void SetSandboxMode(Bool_t bSandboxMode = kTRUE) {
fbSandboxMode = bSandboxMode;
}
void SetEventDumpEnable(Bool_t bDumpEna = kTRUE);
/// 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*/) {};
CbmDeviceEventBuilderEtofStar2019(const CbmDeviceEventBuilderEtofStar2019&) =
delete;
CbmDeviceEventBuilderEtofStar2019
operator=(const CbmDeviceEventBuilderEtofStar2019&) = delete;
protected:
virtual void InitTask();
bool HandleData(FairMQMessagePtr&, int);
bool HandleParts(FairMQParts&, int);
bool HandleMessage(FairMQMessagePtr&, int);
virtual bool SendEvent(std::vector<Int_t>, int);
virtual bool SendSubevent(uint, char*, int, int);
private:
uint64_t fNumMessages;
/// Control flags
Bool_t
fbMonitorMode; //! Switch ON the filling of a minimal set of histograms
Bool_t
fbDebugMonitorMode; //! Switch ON the filling of a additional set of histograms
Bool_t fbSandboxMode; //! Switch OFF the emission of data toward the STAR DAQ
Bool_t
fbEventDumpEna; //! Switch ON the dumping of the events to a binary file
/// Parameters management
TList* fParCList;
/// Statistics & first TS rejection
uint64_t fulTsCounter;
uint64_t fNumEvt;
bool CheckTimeslice(const fles::Timeslice& ts);
bool IsChannelNameAllowed(std::string channelName);
std::vector<std::string> fAllowedChannels = {"tofcomponent",
"parameters",
"etofevts",
"syscmd"};
std::vector<std::vector<std::string>> fChannelsToSend = {{}, {}, {}};
/// Processing algo
CbmStar2019EventBuilderEtofAlgo* fEventBuilderAlgo;
TStopwatch fTimer;
CbmStar2019TofPar* fUnpackPar; //!
/// Event dump to binary file
std::fstream* fpBinDumpFile;
const UInt_t kuBinDumpBegWord = 0xFEEDBEAF;
const UInt_t kuBinDumpEndWord = 0xFAEBDEEF;
};
// special class to expose protected TMessage constructor
class CbmMQTMessage : public TMessage
{
public:
CbmMQTMessage(void* buf, Int_t len)
: TMessage(buf, len)
{
ResetBit(kIsOwner);
}
class CbmMQTMessage : public TMessage {
public:
CbmMQTMessage(void* buf, Int_t len) : TMessage(buf, len) {
ResetBit(kIsOwner);
}
};
#endif /* CBMDEVICEEVENTBUILDERETOFSTAR2019_H_ */
......@@ -8,85 +8,85 @@
#include "CbmDeviceTriggerHandlerEtof.h"
#include "CbmMQDefs.h"
#include "FairMQLogger.h"
#include "FairEventHeader.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairRuntimeDb.h"
#include "FairFileHeader.h"
#include "FairGeoParSet.h"
#include "FairRootManager.h"
#include "FairMQLogger.h"
#include "FairMQProgOptions.h" // device->fConfig
#include "FairRootFileSink.h"
#include "FairRootManager.h"
#include "FairRunOnline.h"
#include "FairFileHeader.h"
#include "FairRuntimeDb.h"
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <string>
#include <iomanip>
#include <thread> // this_thread::sleep_for
#include <chrono>
#include <iomanip>
#include <string>
#include <thread> // this_thread::sleep_for
#include <stdexcept>
struct InitTaskError : std::runtime_error { using std::runtime_error::runtime_error; };
struct InitTaskError : std::runtime_error {
using std::runtime_error::runtime_error;
};
static std::chrono::steady_clock::time_point dctime=std::chrono::steady_clock::now();
static double dSize=0.;
static std::chrono::steady_clock::time_point dctime =
std::chrono::steady_clock::now();
static double dSize = 0.;
using namespace std;
CbmDeviceTriggerHandlerEtof::CbmDeviceTriggerHandlerEtof()
: fNumMessages(0)
, fiMsgCnt(0)
, fbMonitorMode( kFALSE )
, fbDebugMonitorMode( kFALSE )
, fbSandboxMode( kFALSE )
, fbEventDumpEna( kFALSE )
, fdEvent(0.)
{
}
CbmDeviceTriggerHandlerEtof::~CbmDeviceTriggerHandlerEtof()
{
}
void CbmDeviceTriggerHandlerEtof::InitTask()
try
{
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
int noChannel = fChannels.size();
LOG(info) << "Number of defined input channels: " << noChannel;
for(auto const &entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first)) throw InitTaskError("Channel name does not match.");
if(entry.first!="syscmd") OnData(entry.first, &CbmDeviceTriggerHandlerEtof::HandleData);
else OnData(entry.first, &CbmDeviceTriggerHandlerEtof::HandleMessage);
}
InitWorkspace();
, fbMonitorMode(kFALSE)
, fbDebugMonitorMode(kFALSE)
, fbSandboxMode(kFALSE)
, fbEventDumpEna(kFALSE)
, fdEvent(0.) {}
CbmDeviceTriggerHandlerEtof::~CbmDeviceTriggerHandlerEtof() {}
void CbmDeviceTriggerHandlerEtof::InitTask() try {
// Get the information about created channels from the device
// Check if the defined channels from the topology (by name)
// are in the list of channels which are possible/allowed
// for the device
// The idea is to check at initilization if the devices are
// properly connected. For the time beeing this is done with a
// nameing convention. It is not avoided that someone sends other
// data on this channel.
int noChannel = fChannels.size();
LOG(info) << "Number of defined input channels: " << noChannel;
for (auto const& entry : fChannels) {
LOG(info) << "Channel name: " << entry.first;
if (!IsChannelNameAllowed(entry.first))
throw InitTaskError("Channel name does not match.");
if (entry.first != "syscmd")
OnData(entry.first, &CbmDeviceTriggerHandlerEtof::HandleData);
else
OnData(entry.first, &CbmDeviceTriggerHandlerEtof::HandleMessage);
}
InitWorkspace();
} catch (InitTaskError& e) {
LOG(error) << e.what();
cbm::mq::ChangeState(this,cbm::mq::Transition::ErrorFound);
LOG(error) << e.what();
cbm::mq::ChangeState(this, cbm::mq::Transition::ErrorFound);
}
bool CbmDeviceTriggerHandlerEtof::IsChannelNameAllowed(std::string channelName)
{
for(auto const &entry : fAllowedChannels) {
bool CbmDeviceTriggerHandlerEtof::IsChannelNameAllowed(
std::string channelName) {
for (auto const& entry : fAllowedChannels) {
std::size_t pos1 = channelName.find(entry);
if (pos1!=std::string::npos) {
if (pos1 != std::string::npos) {
const vector<std::string>::const_iterator pos =
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos-fAllowedChannels.begin();
std::find(fAllowedChannels.begin(), fAllowedChannels.end(), entry);
const vector<std::string>::size_type idx = pos - fAllowedChannels.begin();
LOG(info) << "Found " << entry << " in " << channelName;
LOG(info) << "Channel name " << channelName
<< " found in list of allowed channel names at position " << idx;
<< " found in list of allowed channel names at position "
<< idx;
return true;
}
}
......@@ -96,8 +96,7 @@ bool CbmDeviceTriggerHandlerEtof::IsChannelNameAllowed(std::string channelName)
return false;
}
Bool_t CbmDeviceTriggerHandlerEtof::InitWorkspace()
{
Bool_t CbmDeviceTriggerHandlerEtof::InitWorkspace() {
LOG(info) << "Init work space for CbmDeviceTriggerHandlerEtof.";
// steering variables
......@@ -108,54 +107,57 @@ Bool_t CbmDeviceTriggerHandlerEtof::InitWorkspace()