Skip to content
Snippets Groups Projects

WIP: Cleanup of STS unpacker

Closed Dominik Smith requested to merge d.smith/cbmroot:UnpackerNew into master
Compare and
9 files
+ 2339
64
Compare changes
  • Side-by-side
  • Inline
Files
9
+ 14
63
@@ -32,34 +32,19 @@
class TList;
class TNamed;
class TCanvas;
template<class T>
bool is_this_type(const boost::any& varValue)
bool IsThisType(const boost::any& varValue)
{
if (auto q = boost::any_cast<T>(&varValue)) return true;
else
return false;
}
template<class T>
class CbmUnpack {
public:
CbmUnpack()
: fParCList(nullptr)
, fvMsComponentsList()
, fuNbCoreMsPerTs(0)
, fuNbOverMsPerTs(0)
, fuNbMsLoop(0)
, fbIgnoreOverlapMs(kFALSE)
, fdMsSizeInNs(-1.0)
, fdTsCoreSizeInNs(-1.0)
, fdTsFullSizeInNs(-1.0)
, fvpAllHistoPointers()
, fDigiVect()
, fErrVect()
, fParameterMap() {};
CbmUnpack() : fParCList(nullptr), fuNbMsLoop(0), fDigiVect(), fErrVect() {};
virtual ~CbmUnpack() = default;
CbmUnpack(const CbmUnpack&) = delete;
CbmUnpack& operator=(const CbmUnpack&) = delete;
@@ -68,7 +53,7 @@ public:
virtual void Reset() = 0;
virtual void Finish() = 0;
virtual Bool_t ProcessTs(const fles::Timeslice& ts) = 0;
virtual Bool_t Unpack(const fles::Timeslice& ts, const UInt_t uMsComp) = 0;
// virtual Bool_t ProcessTs( const fles::Timeslice& ts, size_t component ) = 0;
// virtual Bool_t ProcessMs( const fles::Timeslice& ts, size_t uMsCompIdx, size_t uMsIdx ) = 0;
@@ -78,63 +63,29 @@ public:
virtual void SetParameter(std::string /*param*/) { ; }
virtual std::string GetParameter(std::string /*param*/) { return std::string {""}; }
/// For monitoring of internal processes.
void AddHistoToVector(TNamed* pointer, std::string sFolder = "")
{
fvpAllHistoPointers.push_back(std::pair<TNamed*, std::string>(pointer, sFolder));
}
std::vector<std::pair<TNamed*, std::string>> GetHistoVector() { return fvpAllHistoPointers; }
void AddCanvasToVector(TCanvas* pointer, std::string sFolder = "")
{
fvpAllCanvasPointers.push_back(std::pair<TCanvas*, std::string>(pointer, sFolder));
}
std::vector<std::pair<TCanvas*, std::string>> GetCanvasVector() { return fvpAllCanvasPointers; }
/// Output vector
void AssignOutputVector(std::vector<T>& rVect) { fDigiVect = rVect; }
void AssignErrorVector(std::vector<CbmErrorMessage>& rVect) { fErrVect = rVect; }
// void ClearVector() {fDigiVect->clear();}
// std::vector<T> * GetVector() {return fDigiVect;}
void AssignOutputVector(std::vector<T>* rVect) { fDigiVect = rVect; }
void AssignErrorVector(std::vector<CbmErrorMessage>* rVect) { fErrVect = rVect; }
/// For unpacker algos
void ClearVector() { fDigiVect->clear(); }
std::vector<T>* GetVector() { return fDigiVect; }
void ClearErrorVector() { fErrVect->clear(); }
std::vector<CbmErrorMessage>* GetErrorVector() { return fErrVect; }
/// Control flags
void SetIgnoreOverlapMs(Bool_t bFlagIn = kTRUE) { fbIgnoreOverlapMs = bFlagIn; }
void SetNbMsLoop(size_t uNbMsLoop) { fuNbMsLoop = uNbMsLoop; }
protected:
/// Parameter management
TList* fParCList = nullptr;
/// Parameters related to FLES containers
std::vector<size_t> fvMsComponentsList; //! List of components used in the TS, updated internaly by the Algos
size_t fuNbCoreMsPerTs; //! Number of Core MS in the TS
size_t fuNbOverMsPerTs; //! Number of Overlap MS at the end of the TS
size_t fuNbMsLoop; //! Number of MS for the loop in each MS, updated internaly by the Algos to read OverMS or not
Bool_t fbIgnoreOverlapMs; //! Ignore Overlap Ms: all fuOverlapMsNb MS at the end of timeslice
Double_t fdMsSizeInNs; //! Size of a single MS, [nanoseconds]
Double_t fdTsCoreSizeInNs; //! Total size of the core MS in a TS, [nanoseconds]
Double_t fdTsFullSizeInNs; //! Total size of the core MS in a TS, [nanoseconds]
/// For monitoring of internal processes.
/// => Pointers should be filled with TH1*, TH2*, TProfile*, ...
/// ==> To check if object N is of type T, use "T ObjectPointer = dynamic_cast<T>( fvpAllHistoPointers[N].first );" and check for nullptr
/// ==> To get back the original class name use "fvpAllHistoPointers[N].first->ClassName()" which returns a const char * (e.g. "TH1I")
/// ===> Usage example with feeding a THttpServer:
/// ===> #include "TH2.h"
/// ===> std::string sClassName = vHistos[ uHisto ].first.ClassName();
/// ===> if( !strncmp( sClassName, "TH1", 3 ) )
/// ===> server->Register( vHistos[ uHisto ].second.data(), dynamic_cast< TH1 * >(vHistos[ uHisto ].first) );
/// ===> else if( !strncmp( sClassName, "TH2", 3 ) )
/// ===> server->Register( vHistos[ uHisto ].second.data(), dynamic_cast< TH2 * >(vHistos[ uHisto ].first) );
std::vector<std::pair<TNamed*, std::string>>
fvpAllHistoPointers; //! Vector of pointers to histograms + optional folder name
std::vector<std::pair<TCanvas*, std::string>>
fvpAllCanvasPointers; //! Vector of pointers to canvases + optional folder name
/// Output vector
std::vector<T>& fDigiVect; //! Vector of digis FIXME: check that the reference works as expected
std::vector<CbmErrorMessage>& fErrVect = {}; //! Vector of error messages
/// For any algo
std::map<std::string, std::string> fParameterMap; //! Map of parameter name and type
std::vector<T>* fDigiVect = nullptr;
std::vector<CbmErrorMessage>* fErrVect = nullptr; //! Vector of error messages
Bool_t CheckParameterValidity(std::string /*parameterName*/, std::string /*parameterType*/) { return kTRUE; }
Loading