Skip to content

Commit

Permalink
ctpdev: CTP RunManager class in separate file (#11584)
Browse files Browse the repository at this point in the history
* 1 RunManager class to separate file. 2 Configuration improvements

* clang

* fix:typo in define

* fixxing RunManager.h dependences

* fixxing RunManager.h dependences
  • Loading branch information
lietava authored Jul 2, 2023
1 parent 8fafee8 commit 0d29b94
Show file tree
Hide file tree
Showing 6 changed files with 517 additions and 467 deletions.
4 changes: 3 additions & 1 deletion DataFormats/Detectors/CTP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ o2_add_library(DataFormatsCTP
src/Scalers.cxx
src/CTF.cxx
src/TriggerOffsetsParam.cxx
src/RunManager.cxx
PUBLIC_LINK_LIBRARIES O2::CommonDataFormat
O2::Headers
O2::CommonUtils
Expand All @@ -27,5 +28,6 @@ o2_target_root_dictionary(DataFormatsCTP
include/DataFormatsCTP/Configuration.h
include/DataFormatsCTP/Scalers.h
include/DataFormatsCTP/LumiInfo.h
include/DataFormatsCTP/TriggerOffsetsParam.h)
include/DataFormatsCTP/TriggerOffsetsParam.h
include/DataFormatsCTP/RunManager.h)

46 changes: 2 additions & 44 deletions DataFormats/Detectors/CTP/include/DataFormatsCTP/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class CTPConfiguration
UNKNOWN };
int loadConfigurationRun3(const std::string& ctpconfiguartion);
void printStream(std::ostream& stream) const;
void setRunNumber(uint32_t runnumber) { mRunNumber = runnumber; }
std::vector<CTPInput>& getCTPInputs() { return mInputs; }
std::vector<CTPClass>& getCTPClasses() { return mCTPClasses; }
const std::vector<CTPInput>& getCTPInputs() const { return mInputs; } // Read-only interface
Expand Down Expand Up @@ -194,50 +195,7 @@ class CTPConfiguration
int processConfigurationLineRun3v2(std::string& line, int& level, std::map<int, std::vector<int>>& descInputsIndex);
ClassDefNV(CTPConfiguration, 6);
};
// Run Manager
struct CTPActiveRun {
CTPActiveRun() = default;
long timeStart;
long timeStop;
CTPConfiguration cfg;
CTPRunScalers scalers;
};
class CTPRunManager
{
public:
CTPRunManager() = default;
void init();
int loadRun(const std::string& cfg);
int startRun(const std::string& cfg);
int stopRun(uint32_t irun, long timeStamp);
int addScalers(uint32_t irun, std::time_t time);
int processMessage(std::string& topic, const std::string& message);
void printActiveRuns() const;
int saveRunScalersToCCDB(int i);
int saveRunConfigToCCDB(CTPConfiguration* cfg, long timeStart);
static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run);
CTPRunScalers getScalersFromCCDB(long timestamp, std::string, bool& ok);
int loadScalerNames();
// void setCCDBPathConfig(std::string path) { mCCDBPathCTPConfig = path;};
void setCCDBPathScalers(std::string path) { mCCDBPathCTPScalers = path; };
static void setCCDBHost(std::string host) { mCCDBHost = host; };
void printCounters();

private:
/// Database constants
// std::string mCCDBHost = "http://ccdb-test.cern.ch:8080";
static std::string mCCDBHost;
std::string mCCDBPathCTPScalers = "CTP/Calib/Scalers";
std::array<CTPActiveRun*, NRUNS> mActiveRuns;
std::array<std::uint32_t, NRUNS> mActiveRunNumbers;
std::array<uint32_t, CTPRunScalers::NCOUNTERS> mCounters;
std::map<std::string, uint32_t> mScalerName2Position;
std::map<uint32_t, CTPActiveRun*> mRunsLoaded;
int mEOX = 0; // redundancy check
int mNew = 1; // 1 - no CCDB: used for QC
ClassDefNV(CTPRunManager, 5);
};

} // namespace ctp
} // namespace o2
#include "DataFormatsCTP/RunManager.h"
#endif //_CTP_CONFIGURATION_H_
66 changes: 66 additions & 0 deletions DataFormats/Detectors/CTP/include/DataFormatsCTP/RunManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

/// \file RunManager.h
/// \brief Managing runs for config and scalers
/// \author Roman Lietava
#ifndef _CTP_RUNMANAGER_H_
#define _CTP_RUNMANAGER_H_
#include "DataFormatsCTP/Configuration.h"
namespace o2
{
namespace ctp
{
struct CTPActiveRun {
CTPActiveRun() = default;
long timeStart;
long timeStop;
CTPConfiguration cfg;
CTPRunScalers scalers;
};
class CTPRunManager
{
public:
CTPRunManager() = default;
void init();
int loadRun(const std::string& cfg);
int startRun(const std::string& cfg);
int stopRun(uint32_t irun, long timeStamp);
int addScalers(uint32_t irun, std::time_t time);
int processMessage(std::string& topic, const std::string& message);
void printActiveRuns() const;
int saveRunScalersToCCDB(int i);
int saveRunConfigToCCDB(CTPConfiguration* cfg, long timeStart);
static CTPConfiguration getConfigFromCCDB(long timestamp, std::string run);
CTPRunScalers getScalersFromCCDB(long timestamp, std::string, bool& ok);
int loadScalerNames();
// void setCCDBPathConfig(std::string path) { mCCDBPathCTPConfig = path;};
void setCCDBPathScalers(std::string path) { mCCDBPathCTPScalers = path; };
static void setCCDBHost(std::string host) { mCCDBHost = host; };
void printCounters();

private:
/// Database constants
// std::string mCCDBHost = "http://ccdb-test.cern.ch:8080";
static std::string mCCDBHost;
std::string mCCDBPathCTPScalers = "CTP/Calib/Scalers";
std::array<CTPActiveRun*, NRUNS> mActiveRuns;
std::array<std::uint32_t, NRUNS> mActiveRunNumbers;
std::array<uint32_t, CTPRunScalers::NCOUNTERS> mCounters;
std::map<std::string, uint32_t> mScalerName2Position;
std::map<uint32_t, CTPActiveRun*> mRunsLoaded;
int mEOX = 0; // redundancy check
int mNew = 1; // 1 - no CCDB: used for QC
ClassDefNV(CTPRunManager, 5);
};
} // namespace ctp
} // namespace o2
#endif //_CTP_RUNMANAGER_H_
Loading

0 comments on commit 0d29b94

Please sign in to comment.