Skip to content
Snippets Groups Projects
Commit 26080ec4 authored by Volker Friese's avatar Volker Friese Committed by Pierre-Alain Loizeau
Browse files

Revised CbmDevEventSink. Remove histogramming and timeslice buffering.

parent 803ed31c
No related branches found
No related tags found
1 merge request!860Revised CbmDevEventSink. Remove histogramming and timeslice buffering.
Pipeline #17899 passed
This diff is collapsed.
/* Copyright (C) 2020-2022 Facility for Antiproton and Ion Research in Europe, Darmstadt /* Copyright (C) 2022 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only SPDX-License-Identifier: GPL-3.0-only
Authors: Pierre-Alain Loizeau [committer], Dominik Smith */ Authors: Dominik Smith [committer], Pierre-Alain Loizeau, Volker Friese */
#ifndef CBMDEVICEEVTSINK_H_ #ifndef CBMDEVICEEVTSINK_H_
#define CBMDEVICEEVTSINK_H_ #define CBMDEVICEEVTSINK_H_
/// CBM headers
#include "CbmDigiEvent.h" #include "CbmDigiEvent.h"
#include "CbmEvent.h"
#include "CbmMqTMessage.h"
#include "CbmMuchDigi.h"
#include "CbmPsdDigi.h"
#include "CbmRichDigi.h"
#include "CbmStsDigi.h"
#include "CbmTofDigi.h"
#include "CbmTrdDigi.h"
#include "TimesliceMetaData.h"
/// FAIRROOT headers
#include "FairMQDevice.h"
/// FAIRSOFT headers (geant, boost, ...) #include "FairMQDevice.h"
#include "Rtypes.h"
#include "TClonesArray.h"
#include "TObjArray.h"
/// C/C++ headers
#include <chrono>
#include <map>
#include <vector> #include <vector>
class TFile; class TimesliceMetaData;
class TList;
class TClonesArray;
class FairRunOnline; class FairRunOnline;
class FairRootManager; class FairRootManager;
class CbmEventTimeslice {
/// TODO: rename to CbmTsWithEvents
public:
CbmEventTimeslice(FairMQParts& parts);
~CbmEventTimeslice();
std::vector<CbmDigiEvent> GetSelectedData();
TimesliceMetaData fTsMetaData;
std::vector<CbmDigiEvent> fvEvents;
};
/** @class CbmDefEventSink
** @brief MQ device class to write CbmDigiEvents to a ROOT file
** @author Dominik Smith <d.smith@gsi.de>
**
** Based on previous, similar implementations by P.-A. Loizeau
**
** The event sink device receives data (vector of CbmDigiEvents for a given timeslice) in the
** respective input channel and fills a ROOT tree/file with these data.
**/
class CbmDevEventSink : public FairMQDevice { class CbmDevEventSink : public FairMQDevice {
public: public:
CbmDevEventSink(); /** @brief Constructor **/
CbmDevEventSink() {};
/** @brief Destructor **/
virtual ~CbmDevEventSink(); virtual ~CbmDevEventSink();
protected: protected:
/** @brief Action on command messages
** @param parts Message
** @param flag Not used; ignored
** @return Success
**/
bool HandleCommand(FairMQMessagePtr&, int flag);
/** @brief Action on data messages
** @param parts Message
** @param flag Not used; ignored
** @return Success
*/
bool HandleData(FairMQParts& parts, int flag);
/** @brief Initialization **/
virtual void InitTask(); virtual void InitTask();
bool HandleMissTsData(FairMQMessagePtr&, int);
bool HandleData(FairMQParts&, int);
bool HandleCommand(FairMQMessagePtr&, int); private: // methods
/** @brief Finishing run **/
private:
/// Constants
/// Control flags
Bool_t fbFillHistos = false; //! Switch ON/OFF filling of histograms
Bool_t fbFinishDone = false; //! Keep track of whether the Finish was already called
/// User settings parameters
/// Algo enum settings
std::string fsOutputFileName = "mcbm_digis_events.root";
/// message queues
std::string fsChannelNameMissedTs = "missedts";
std::string fsChannelNameDataInput = "events";
std::string fsChannelNameCommands = "commands";
std::string fsChannelNameHistosInput = "histogram-in";
/// Histograms management
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};
/// Statistics & missed TS detection
uint64_t fuPrevTsIndex = 0;
uint64_t fulNumMessages = 0;
uint64_t fulTsCounter = 0;
uint64_t fulMissedTsCounter = 0;
std::chrono::system_clock::time_point fLastPublishTime = std::chrono::system_clock::now();
/// Control Commands reception
bool fbReceivedEof = false;
uint64_t fuLastTsIndex = 0;
uint64_t fuTotalTsCount = 0;
/// Data reception
/// TS MetaData storage
TClonesArray* fTimeSliceMetaDataArray = nullptr; //!
TimesliceMetaData* fTsMetaData = nullptr;
/// CbmEvents
std::vector<CbmDigiEvent>* fEventsSel = nullptr; //! output container of CbmEvents
/// Storage for re-ordering
/// Missed TS vector
std::vector<uint64_t> fvulMissedTsIndices = {};
/// Buffered TS
std::map<uint64_t, CbmEventTimeslice> fmFullTsStorage = {};
/// Data storage
FairRunOnline* fpRun = nullptr;
FairRootManager* fpFairRootMgr = nullptr;
/// Array of histograms to send to the histogram server
TObjArray fArrayHisto = {};
/// Vector of string pairs with ( HistoName, FolderPath ) to send to the histogram server
std::vector<std::pair<std::string, std::string>> fvpsHistosFolder = {};
/// Vector of string pairs with ( CanvasName, CanvasConfig ) to send to the histogram server
/// Format of Can config is "NbPadX(U);NbPadY(U);ConfigPad1(s);....;ConfigPadXY(s)"
/// Format of Pad config is "GrixX(b),GridY(b),LogX(b),LogY(b),LogZ(b),HistoName(s),DrawOptions(s)"
std::vector<std::pair<std::string, std::string>> fvpsCanvasConfig = {};
/// Flag indicating whether the histograms and canvases configurations were already published
bool fbConfigSent = false;
/// Internal methods
bool IsChannelNameAllowed(std::string channelName);
bool InitHistograms();
void CheckTsQueues();
void PrepareTreeEntry(CbmEventTimeslice unpTs);
void DumpTreeEntry();
bool SendHistoConfAndData();
bool SendHistograms();
void Finish(); void Finish();
private: // members
// --- Counters and status flags
size_t fNumMessages = 0; ///< Number of received data messages
size_t fNumTs = 0; ///< Number of processed timeslices
uint64_t fPrevTsIndex = 0; ///< Index of last processed timeslice
bool fFinishDone = false; ///< Keep track of whether the Finish method was already called
TimesliceMetaData* fTsMetaData = nullptr; ///< Data output: TS meta data
std::vector<CbmDigiEvent>* fEventVec = nullptr; ///< Data output: events
FairRunOnline* fFairRun = nullptr; ///< FairRunOnline to instantiate FairRootManager
FairRootManager* fFairRootMgr = nullptr; ///< FairRootManager used for ROOT file I/O
}; };
#endif /* CBMDEVICEEVTSINK_H_ */ #endif /* CBMDEVICEEVTSINK_H_ */
...@@ -14,22 +14,12 @@ using namespace std; ...@@ -14,22 +14,12 @@ using namespace std;
void addCustomOptions(bpo::options_description& options) void addCustomOptions(bpo::options_description& options)
{ {
options.add_options()("StoreFullTs", bpo::value<bool>()->default_value(false), options.add_options()("OutFileName", bpo::value<std::string>()->default_value(""),
"Store digis vectors with full TS in addition to selected events if true");
options.add_options()("OutFileName", bpo::value<std::string>()->default_value("mcbm_digis_events.root"),
"Name (full or relative path) of the output .root file "); "Name (full or relative path) of the output .root file ");
options.add_options()("EvtNameIn", bpo::value<std::string>()->default_value("events"), options.add_options()("ChannelNameDataInput", bpo::value<std::string>()->default_value("events"),
"MQ channel name for built events"); "MQ channel name for digi events");
options.add_options()("FillHistos", bpo::value<bool>()->default_value(false), options.add_options()("ChannelNameCommands", bpo::value<std::string>()->default_value("commands"),
"Fill histograms and send them to histo server if true"); "MQ channel name for commands");
options.add_options()("PubFreqTs", bpo::value<uint32_t>()->default_value(100), "Histo publishing frequency in TS");
options.add_options()("PubTimeMin", bpo::value<double_t>()->default_value(1.0),
"Minimal time between two publishing");
options.add_options()("PubTimeMax", bpo::value<double_t>()->default_value(10.0),
"Maximal time between two publishing");
options.add_options()("ChNameIn", bpo::value<std::string>()->default_value("histogram-in"),
"MQ channel name for histos");
} }
FairMQDevicePtr getDevice(const FairMQProgOptions& /*config*/) { return new CbmDevEventSink(); } FairMQDevicePtr getDevice(const FairMQProgOptions&) { return new CbmDevEventSink(); }
...@@ -194,17 +194,10 @@ EVTSINK="MqDevEventSink" ...@@ -194,17 +194,10 @@ EVTSINK="MqDevEventSink"
EVTSINK+=" --id evtsink1" EVTSINK+=" --id evtsink1"
EVTSINK+=" --severity info" EVTSINK+=" --severity info"
#EVTSINK+=" --severity debug" #EVTSINK+=" --severity debug"
#EVTSINK+=" --StoreFullTs 1"
EVTSINK+=" --OutFileName mcbm_digis_events.root" EVTSINK+=" --OutFileName mcbm_digis_events.root"
EVTSINK+=" --FillHistos false" EVTSINK+=" --ChannelNameDataInput events"
EVTSINK+=" --PubFreqTs $_pubfreqts"
EVTSINK+=" --PubTimeMin $_pubminsec"
EVTSINK+=" --PubTimeMax $_pubmaxsec"
EVTSINK+=" --EvtNameIn events"
EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,address=tcp://127.0.0.1:11557" EVTSINK+=" --channel-config name=events,type=pull,method=bind,transport=zeromq,address=tcp://127.0.0.1:11557"
EVTSINK+=" --channel-config name=missedts,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11006"
EVTSINK+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007" EVTSINK+=" --channel-config name=commands,type=sub,method=connect,transport=zeromq,address=tcp://127.0.0.1:11007"
EVTSINK+=" --channel-config name=histogram-in,type=sub,method=bind,transport=zeromq,address=tcp://127.0.0.1:11666"
# Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX # Replaces log filename Xterm.log.hostname.yyyy.mm.dd.hh.mm.ss.XXXXXX
# with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log # with ProcessName_hostname_yyyy_mm_dd_hh_mm_ss.log
EVTSINK_LOG="evtsink1_$LOGFILETAG" EVTSINK_LOG="evtsink1_$LOGFILETAG"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment