Skip to content
Snippets Groups Projects
Commit 0818c934 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau
Browse files

Reco: in unpacker algo base class and template, add support for Error IO...

Reco: in unpacker algo base class and template, add support for Error IO vector + Add DoUnpack template method
parent 05034c66
No related branches found
No related tags found
1 merge request!22Last mCBM merge: reco/base unpacking templates
...@@ -8,12 +8,18 @@ ...@@ -8,12 +8,18 @@
#ifndef CBMUNPACK_H #ifndef CBMUNPACK_H
#define CBMUNPACK_H #define CBMUNPACK_H
/// CbmRoot (+externals) headers
#include "Timeslice.hpp" #include "Timeslice.hpp"
#include "CbmErrorMessage.h"
/// FairRoot headers
/// Fairsoft (Root, Boost, ...) headers
#include "Rtypes.h" #include "Rtypes.h"
#include <boost/any.hpp> #include <boost/any.hpp>
/// C/C++ headers
#include <vector> #include <vector>
#include <string> #include <string>
#include <map> #include <map>
...@@ -50,6 +56,7 @@ class CbmUnpack ...@@ -50,6 +56,7 @@ class CbmUnpack
fdTsFullSizeInNs(-1.0), fdTsFullSizeInNs(-1.0),
fvpAllHistoPointers(), fvpAllHistoPointers(),
fDigiVect(), fDigiVect(),
fErrVect(),
fParameterMap() fParameterMap()
{}; {};
virtual ~CbmUnpack() = default; virtual ~CbmUnpack() = default;
...@@ -79,7 +86,8 @@ class CbmUnpack ...@@ -79,7 +86,8 @@ class CbmUnpack
std::vector< std::pair< TCanvas *, std::string > > GetCanvasVector() { return fvpAllCanvasPointers; } std::vector< std::pair< TCanvas *, std::string > > GetCanvasVector() { return fvpAllCanvasPointers; }
/// Output vector /// Output vector
void AssignOutputVector( std::vector<T> & rVect ){ fDigiVect = rVect; } void AssignOutputVector( std::vector< T > & rVect ){ fDigiVect = rVect; }
void AssignErrorVector( std::vector< CbmErrorMessage > & rVect ){ fErrVect = rVect; }
// void ClearVector() {fDigiVect->clear();} // void ClearVector() {fDigiVect->clear();}
// std::vector<T> * GetVector() {return fDigiVect;} // std::vector<T> * GetVector() {return fDigiVect;}
...@@ -116,6 +124,7 @@ class CbmUnpack ...@@ -116,6 +124,7 @@ class CbmUnpack
/// Output vector /// Output vector
std::vector<T> & fDigiVect; //! Vector of digis FIXME: check that the reference works as expected 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 /// For any algo
std::map<std::string, std::string> fParameterMap; //! Map of parameter name and type std::map<std::string, std::string> fParameterMap; //! Map of parameter name and type
......
...@@ -66,7 +66,8 @@ class CbmUnpackTask : public CbmUnpackTaskBase ...@@ -66,7 +66,8 @@ class CbmUnpackTask : public CbmUnpackTaskBase
uint64_t fulTsCounter = 0; //! TS counter, not same as TS index! uint64_t fulTsCounter = 0; //! TS counter, not same as TS index!
/// Input/Output vector /// Input/Output vector
std::vector< TDigi > * fvDigiIO = nullptr; //! IO vector of Digis, passed to algo for filling and propagated to framework for outpu std::vector< TDigi > * fvDigiIO = nullptr; //! IO vector of Digis, passed to algo for filling and propagated to framework for output
std::vector< CbmErrorMessage > * fvErrorIO = nullptr; //! IO vector of Errors, passed to algo for filling and propagated to framework for output
/// Histograms for vector monitoring? /// Histograms for vector monitoring?
// TH1* fhArraySize = nullptr; // TH1* fhArraySize = nullptr;
......
...@@ -36,7 +36,8 @@ CbmUnpackTask< TDigi, TAlgo, TParam >::CbmUnpackTask( TString sDigiBranchName, T ...@@ -36,7 +36,8 @@ CbmUnpackTask< TDigi, TAlgo, TParam >::CbmUnpackTask( TString sDigiBranchName, T
fsDigiBranchName( sDigiBranchName ), fsDigiBranchName( sDigiBranchName ),
fsDigiBranchDescr( sDigiBranchDescr ) fsDigiBranchDescr( sDigiBranchDescr )
{ {
fvDigiIO = new std::vector< TDigi >(); // fvDigiIO = new std::vector< TDigi >();
// fvErrorIO = new std::vector< CbmErrorMessage >();
fUnpackerAlgo = new TAlgo(); fUnpackerAlgo = new TAlgo();
} }
...@@ -49,6 +50,11 @@ CbmUnpackTask< TDigi, TAlgo, TParam >::~CbmUnpackTask() ...@@ -49,6 +50,11 @@ CbmUnpackTask< TDigi, TAlgo, TParam >::~CbmUnpackTask()
{ {
fvDigiIO.clear(); fvDigiIO.clear();
delete fvDigiIO; delete fvDigiIO;
};
if( nullptr != fvErrorIO )
{
fvErrorIO.clear();
delete fvErrorIO;
} }
} }
...@@ -82,6 +88,24 @@ Bool_t CbmUnpackTask< TDigi, TAlgo, TParam >::Init() ...@@ -82,6 +88,24 @@ Bool_t CbmUnpackTask< TDigi, TAlgo, TParam >::Init()
fvDigiIO, fbWriteOutput); fvDigiIO, fbWriteOutput);
} // if( nullptr == fvDigiIO ) } // if( nullptr == fvDigiIO )
else LOG(info) << "--> Found existing IO vector, re-using it."; else LOG(info) << "--> Found existing IO vector, re-using it.";
fUnpackerAlgo->AssignOutputVector( fvDigiIO );
/// Check first if array not already existing due to other unpacker!
fvErrorIO = static_cast< std::vector< TDigi > *>(ioman->GetObject( "ErrorMessage" ));
if( nullptr == fvErrorIO )
{
/// No existing array => create it!
fvErrorIO = new std::vector< CbmErrorMessage >();
if( nullptr == fvErrorIO )
{
LOG(fatal) << "Failed creating the IO vector for error messages";
} // if( nullptr == fvErrorIO )
ioman->RegisterAny( "ErrorMessage",
// ( "" == fsDigiBranchDescr ? fsDigiBranchName : fsDigiBranchDescr),
fvErrorIO, fbWriteOutput);
} // if( nullptr == fvErrorIO )
else LOG(info) << "--> Found existing IO vector for error messages, re-using it.";
fUnpackerAlgo->AssignErrorVector( fvErrorIO );
return kTRUE; return kTRUE;
} }
...@@ -169,6 +193,27 @@ template< class TDigi, class TAlgo, class TParam > ...@@ -169,6 +193,27 @@ template< class TDigi, class TAlgo, class TParam >
void CbmUnpackTask< TDigi, TAlgo, TParam >::Reset() void CbmUnpackTask< TDigi, TAlgo, TParam >::Reset()
{ {
fvDigiIO->clear(); fvDigiIO->clear();
fvErrorIO->clear();
}
template< class TDigi, class TAlgo, class TParam >
Bool_t CbmUnpackTask< TDigi, TAlgo, TParam >::DoUnpack(const fles::Timeslice& ts, size_t /*component*/)
{
if( kFALSE == fUnpackerAlgo->ProcessTs( ts ) )
{
LOG(error) << "Failed processing TS " << ts.index()
<< " in unpacker algorithm class";
return kTRUE;
} // if( kFALSE == fUnpackerAlgo->ProcessTs( ts ) )
if( 0 == ts.index() % 10000 )
LOG(info) << "Processed TS with index " << std::setw( 9 ) << fulTsCounter;
if( 0 == fulTsCounter % 10000 )
LOG(info) << "Processed " << std::setw( 9 ) << fulTsCounter << " TS ";
fulTsCounter++;
return kTRUE;
} }
template< class TDigi, class TAlgo, class TParam > template< class TDigi, class TAlgo, class TParam >
......
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