Skip to content
Snippets Groups Projects
Commit c3003643 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau Committed by Florian Uhlig
Browse files

Restore possibility of semicolon separated list of streams for TSA input

- Add vector constructor to CbmSourceTsArchive
- Call string constructor of FLES IPC TimesliceAutoSource if vector of size 1
- Make vector input default in run_unpack macro
- Add alternative call with single string to run_unpack_macro to keep legacy interface available
parent 332d40d2
No related branches found
No related tags found
1 merge request!500Improve usage of FLES IPC TimesliceAutoSource interface
Pipeline #13173 passed
......@@ -32,8 +32,8 @@ std::shared_ptr<CbmTrdUnpackMonitor> GetTrdMonitor(std::string treefilename);
std::shared_ptr<CbmTrdSpadic> GetTrdSpadic(bool useAvgBaseline = false);
std::shared_ptr<CbmStsUnpackMonitor> GetStsMonitor(std::string treefilename);
void run_unpack_tsa(std::string infile = "test.tsa", UInt_t runid = 0, const char* setupName = "mcbm_beam_2021_03",
std::int32_t nevents = -1, std::string outpath = "")
void run_unpack_tsa(std::vector<std::string> infile = {"test.tsa"}, UInt_t runid = 0,
const char* setupName = "mcbm_beam_2021_03", std::int32_t nevents = -1, std::string outpath = "")
{
// ========================================================================
......@@ -58,13 +58,13 @@ void run_unpack_tsa(std::string infile = "test.tsa", UInt_t runid = 0, const cha
// ----- Output filename ----------------------------------------------
std::string outfilename = infile;
auto filenamepos = infile.find_last_of("/");
std::string outfilename = infile[0];
auto filenamepos = infile[0].find_last_of("/");
filenamepos++;
std::string filename = infile.substr(filenamepos);
if (filename.find("*") != infile.npos) filename = std::to_string(runid) + ".tsa";
if (filename.find(";") != infile.npos) filename = std::to_string(runid) + "_merged" + ".tsa";
if (outpath.empty()) { outpath = infile.substr(0, filenamepos); }
std::string filename = infile[0].substr(filenamepos);
if (filename.find("*") != infile[0].npos) filename = std::to_string(runid) + ".tsa";
if (filename.find(";") != infile[0].npos) filename = std::to_string(runid) + "_merged" + ".tsa";
if (outpath.empty()) { outpath = infile[0].substr(0, filenamepos); }
outfilename = outpath + filename;
outfilename.replace(outfilename.find(".tsa"), 4, ".digi.root");
std::cout << "-I- " << myName << ": Output file will be " << outfilename << std::endl;
......@@ -198,7 +198,7 @@ void run_unpack_tsa(std::string infile = "test.tsa", UInt_t runid = 0, const cha
// ----- CbmSourceTsArchive -------------------------------------------
auto source = new CbmSourceTsArchive(infile.data());
auto source = new CbmSourceTsArchive(infile);
auto unpack = source->GetRecoUnpack();
unpack->SetDoPerfProfiling(doPerfProfiling);
unpack->SetOutputFilename(perfProfFileName);
......@@ -361,3 +361,10 @@ std::shared_ptr<CbmStsUnpackMonitor> GetStsMonitor(std::string treefilename)
//monitor->SetDebugMode(true);
return monitor;
}
void run_unpack_tsa(std::string infile = "test.tsa", UInt_t runid = 0, const char* setupName = "mcbm_beam_2021_03",
std::int32_t nevents = -1, std::string outpath = "")
{
std::vector<std::string> vInFile = {infile};
return run_unpack_tsa(vInFile, runid, setupName, nevents, outpath);
}
/** @file CbmSourceTsArchive.cxx
** @copyright Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
** @license SPDX-License-Identifier: GPL-3.0-only
** @author Volker Friese [originator]
**/
/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Jan de Cuveland, Volker Friese[committer], Pierre-Alain Loizeau */
#include "CbmSourceTsArchive.h"
......@@ -22,6 +19,10 @@ using std::unique_ptr;
CbmSourceTsArchive::CbmSourceTsArchive(const char* fileName) { AddInputFile(fileName); }
// ----------------------------------------------------------------------------
// ----- Constructor ------------------------------------------------------
CbmSourceTsArchive::CbmSourceTsArchive(std::vector<std::string> fileNames) : fFileNames(fileNames) {}
// ----------------------------------------------------------------------------
// ----- Add an input file ------------------------------------------------
size_t CbmSourceTsArchive::AddInputFile(const char* fileName)
......@@ -45,7 +46,16 @@ void CbmSourceTsArchive::Close()
// ----- Initialisation ---------------------------------------------------
Bool_t CbmSourceTsArchive::Init()
{
fTsSource = new fles::TimesliceAutoSource(fFileNames);
if (1 == fFileNames.size()) {
LOG(info) << "SourceTsArchive::Init() calling string constructor with ";
LOG(info) << fFileNames[0];
fTsSource = new fles::TimesliceAutoSource(fFileNames[0]);
}
else {
LOG(info) << "SourceTsArchive::Init() calling vector constructor with size ";
LOG(info) << fFileNames.size();
fTsSource = new fles::TimesliceAutoSource(fFileNames);
}
// Initialise unpacker
fUnpack.Init();
......
/** @file CbmSourceTsArchive.h
** @copyright Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
** @license SPDX-License-Identifier: GPL-3.0-only
** @author Volker Friese [originator]
**/
/* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Jan de Cuveland, Volker Friese[committer], Pierre-Alain Loizeau */
#ifndef CBMSOURCETSARCHIVE_H
#define CBMSOURCETSARCHIVE_H 1
......@@ -36,6 +33,13 @@ public:
*/
CbmSourceTsArchive(const char* fileName = "");
/** @brief Constructor
** @param fileName Vector with name(s) of input file(s).
**
** More input files can be added by the method AddInputFile.
*/
CbmSourceTsArchive(std::vector<std::string> fileNames);
/** @brief Destructor **/
virtual ~CbmSourceTsArchive() {};
......@@ -67,7 +71,7 @@ public:
/**
* @brief Get the Reco Unpack
* Access the CbmRecoUnpack class to add unpacker configs
* @return CbmRecoUnpack*
* @return CbmRecoUnpack*
*/
CbmRecoUnpack* GetRecoUnpack() { return &fUnpack; }
......
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