CbmRoot
Loading...
Searching...
No Matches
CbmStsParSetSensor.cxx
Go to the documentation of this file.
1/* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
10
11#include <Logger.h> // for LOG, Logger
12
13#include <cassert> // for assert
14#include <sstream> // for operator<<, basic_ostream, stringstream
15#include <string> // for char_traits
16
18
19 // ----- Constructor ----------------------------------------------------
20 CbmStsParSetSensor::CbmStsParSetSensor(const char* name, const char* title, const char* context)
21 : FairParGenericSet(name, title, context)
22{
23 LOG(info) << "Constructor";
24}
25// --------------------------------------------------------------------------
26
27
28// ----- Destructor -----------------------------------------------------
30// --------------------------------------------------------------------------
31
32
33// ----- Reset ----------------------------------------------------------
35{
36 fUseGlobal = kFALSE;
37 fParams.clear();
38 status = kFALSE;
39 resetInputVersions();
40}
41// --------------------------------------------------------------------------
42
43
44// ----- Read parameters from ASCII file --------------------------------
45Bool_t CbmStsParSetSensor::getParams(FairParamList*)
46{
47 LOG(fatal) << GetName() << ": ASCII input is not defined!";
48 return kFALSE;
49}
50// --------------------------------------------------------------------------
51
52
53// ----- Get parameters of a sensor -------------------------------------
55{
56 if (fUseGlobal) return fGlobalParams;
57 LOG_IF(fatal, fParams.count(address) == 0)
58 << GetName() << ": Parameters for sensor address " << std::hex << address << std::dec << " not found!";
59 return fParams[address];
60}
61// --------------------------------------------------------------------------
62
63
64// ----- Write parameters from ASCII file -------------------------------
65void CbmStsParSetSensor::putParams(FairParamList*) { LOG(fatal) << GetName() << ": ASCII output is not defined!"; }
66// --------------------------------------------------------------------------
67
68
69// ----- Set sensor parameters ------------------------------------------
70void CbmStsParSetSensor::SetParSensor(UInt_t address, const CbmStsParSensor& par)
71{
72 if (fParams.count(address)) LOG(fatal) << GetName() << ": Replacing parameters for sensor address " << address;
73 fParams[address] = par;
74}
75// --------------------------------------------------------------------------
76
77
78// ----- Info to string ------------------------------------------------
80{
81 std::stringstream ss;
82 if (fUseGlobal)
83 ss << "(Global) " << fGlobalParams.ToString();
84 else {
85 if (fParams.empty())
86 ss << "Empty";
87 else
88 ss << "Parameters for " << fParams.size() << " sensors:\n";
89 uint32_t uSensorCount = 0;
90 for (const auto& [address, par] : fParams) {
91 ss << "0x" << std::hex << address << std::dec << (0 < uSensorCount && 0 == uSensorCount % 16 ? "\n" : " ");
92 ++uSensorCount;
93 }
94 }
95 return ss.str();
96}
97// -------------------------------------------------------------------------
ClassImp(CbmStsParSetSensor) CbmStsParSetSensor
Constructional parameters of a STS sensor.
std::string ToString() const
Info to string.
Parameters container for CbmStsParSensor.
virtual Bool_t getParams(FairParamList *parList)
Reading parameters from ASCII. Abstract in base class.
std::map< UInt_t, CbmStsParSensor > fParams
Map of parameters. Key is sensor address.
CbmStsParSetSensor(const char *name="CbmParSetSensor", const char *title="STS parameters", const char *context="Default")
Constructor.
void SetParSensor(UInt_t address, const CbmStsParSensor &par)
Set the parameters for a sensor.
std::string ToString() const
Info to string.
Bool_t fUseGlobal
Flag for using global parameters.
const CbmStsParSensor & GetParSensor(UInt_t address)
Get condition parameters of a sensor.
virtual void clear()
Reset all parameters.
virtual ~CbmStsParSetSensor()
Destructor.
CbmStsParSensor fGlobalParams
Global parameters, used for all modules.
virtual void putParams(FairParamList *parList)
Writing parameters to ASCII. Abstract in base class.