CbmRoot
CbmStsParSetSensor.cxx
Go to the documentation of this file.
1 
5 #include "CbmStsParSetSensor.h"
6 
7 #include <FairLogger.h> // for LOG, Logger
8 
9 #include <cassert> // for assert
10 #include <sstream> // for operator<<, basic_ostream, stringstream
11 #include <string> // for char_traits
12 
14 
15  // ----- Constructor ----------------------------------------------------
17  const char* title,
18  const char* context)
19  : FairParGenericSet(name, title, context) {
20  LOG(info) << "Constructor";
21 }
22 // --------------------------------------------------------------------------
23 
24 
25 // ----- Destructor -----------------------------------------------------
27 // --------------------------------------------------------------------------
28 
29 
30 // ----- Reset ----------------------------------------------------------
32  fUseGlobal = kFALSE;
33  fParams.clear();
34  status = kFALSE;
35  resetInputVersions();
36 }
37 // --------------------------------------------------------------------------
38 
39 
40 // ----- Read parameters from ASCII file --------------------------------
41 Bool_t CbmStsParSetSensor::getParams(FairParamList*) {
42  LOG(fatal) << GetName() << ": ASCII input is not defined!";
43  return kFALSE;
44 }
45 // --------------------------------------------------------------------------
46 
47 
48 // ----- Get parameters of a sensor -------------------------------------
50  if (fUseGlobal) return fGlobalParams;
51  assert(fParams.count(address));
52  return fParams[address];
53 }
54 // --------------------------------------------------------------------------
55 
56 
57 // ----- Write parameters from ASCII file -------------------------------
58 void CbmStsParSetSensor::putParams(FairParamList*) {
59  LOG(fatal) << GetName() << ": ASCII output is not defined!";
60 }
61 // --------------------------------------------------------------------------
62 
63 
64 // ----- Set sensor parameters ------------------------------------------
66  const CbmStsParSensor& par) {
67  if (fParams.count(address))
68  LOG(fatal) << GetName() << ": Replacing parameters for sensor address "
69  << address;
70  fParams[address] = par;
71 }
72 // --------------------------------------------------------------------------
73 
74 
75 // ----- Info to string ------------------------------------------------
76 std::string CbmStsParSetSensor::ToString() const {
77  std::stringstream ss;
78  if (fUseGlobal)
79  ss << "(Global) " << fGlobalParams.ToString();
80  else {
81  if (fParams.empty())
82  ss << "Empty";
83  else
84  ss << "Parameters for " << fParams.size() << " sensors";
85  }
86  return ss.str();
87 }
88 // -------------------------------------------------------------------------
CbmStsParSetSensor::clear
virtual void clear()
Reset all parameters.
Definition: CbmStsParSetSensor.cxx:31
CbmStsParSetSensor::CbmStsParSetSensor
CbmStsParSetSensor(const char *name="CbmParSetSensor", const char *title="STS parameters", const char *context="Default")
Constructor.
CbmStsParSetSensor.h
ClassImp
ClassImp(CbmStsParSetSensor) CbmStsParSetSensor
Definition: CbmStsParSetSensor.cxx:13
CbmStsParSetSensor::ToString
std::string ToString() const
Info to string.
Definition: CbmStsParSetSensor.cxx:76
CbmStsParSetSensor::fUseGlobal
Bool_t fUseGlobal
Flag for using global parameters.
Definition: CbmStsParSetSensor.h:110
CbmStsParSetSensor::SetParSensor
void SetParSensor(UInt_t address, const CbmStsParSensor &par)
Set the parameters for a sensor.
Definition: CbmStsParSetSensor.cxx:65
CbmStsParSensor
Constructional parameters of a STS sensor.
Definition: CbmStsParSensor.h:38
CbmStsParSetSensor::GetParSensor
const CbmStsParSensor & GetParSensor(UInt_t address)
Get condition parameters of a sensor.
Definition: CbmStsParSetSensor.cxx:49
CbmStsParSetSensor
Parameters container for CbmStsParSensor.
Definition: CbmStsParSetSensor.h:30
CbmStsParSetSensor::~CbmStsParSetSensor
virtual ~CbmStsParSetSensor()
Destructor.
Definition: CbmStsParSetSensor.cxx:26
CbmStsParSetSensor::getParams
virtual Bool_t getParams(FairParamList *parList)
Reading parameters from ASCII. Abstract in base class.
Definition: CbmStsParSetSensor.cxx:41
CbmStsParSetSensor::fParams
std::map< UInt_t, CbmStsParSensor > fParams
Map of parameters. Key is sensor address.
Definition: CbmStsParSetSensor.h:116
CbmStsParSetSensor::fGlobalParams
CbmStsParSensor fGlobalParams
Global parameters, used for all modules.
Definition: CbmStsParSetSensor.h:113
CbmStsParSensor::ToString
std::string ToString() const
Info to string.
Definition: CbmStsParSensor.cxx:38
CbmStsParSetSensor::putParams
virtual void putParams(FairParamList *parList)
Writing parameters to ASCII. Abstract in base class.
Definition: CbmStsParSetSensor.cxx:58