CbmRoot
Loading...
Searching...
No Matches
CbmStsParSetModule.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 "CbmStsParModule.h" // for CbmStsParModule
12
13#include <Logger.h> // for LOG, Logger
14
15#include <cassert> // for assert
16#include <sstream> // for operator<<, basic_ostream, stringstream
17#include <string> // for char_traits
18
19
21
22 // ----- Constructor ----------------------------------------------------
23 CbmStsParSetModule::CbmStsParSetModule(const char* name, const char* title, const char* context)
24 : FairParGenericSet(name, title, context)
25{
26}
27// --------------------------------------------------------------------------
28
29
30// ----- Destructor -----------------------------------------------------
32// --------------------------------------------------------------------------
33
34
35// ----- Reset ----------------------------------------------------------
37{
38 fUseGlobal = kFALSE;
39 fParams.clear();
40 status = kFALSE;
41 resetInputVersions();
42}
43// --------------------------------------------------------------------------
44
45
46// ----- Randomly deactivate channels -----------------------------------
48{
49 if (fraction <= 0.) return 0;
50 UInt_t nDeactivated = 0;
51 for (auto& entry : fParams) {
52 nDeactivated += entry.second.DeactivateRandomChannels(fraction);
53 }
54 return nDeactivated;
55}
56// --------------------------------------------------------------------------
57
58
59// ----- Read parameters from ASCII file --------------------------------
60Bool_t CbmStsParSetModule::getParams(FairParamList*)
61{
62 LOG(fatal) << GetName() << ": ASCII input is not defined!";
63 return kFALSE;
64}
65// --------------------------------------------------------------------------
66
67
68// ----- Get condition parameters of a module ---------------------------
70{
71 if (fUseGlobal) return fGlobalParams;
72 assert(fParams.count(address));
73 return fParams[address];
74}
75// --------------------------------------------------------------------------
76
77
78// ----- Write parameters from ASCII file -------------------------------
79void CbmStsParSetModule::putParams(FairParamList*) { LOG(fatal) << GetName() << ": ASCII output is not defined!"; }
80// --------------------------------------------------------------------------
81
82
83// ----- Set module parameters ------------------------------------------
84void CbmStsParSetModule::SetParModule(UInt_t address, const CbmStsParModule& par)
85{
86 if (fParams.count(address)) LOG(fatal) << GetName() << ": Replacing parameters for sensor address " << address;
87 fParams[address] = par;
88}
89// --------------------------------------------------------------------------
90
91
92// ----- Info to string ------------------------------------------------
94{
95 std::stringstream ss;
96 if (fUseGlobal) ss << "(Global) " << fGlobalParams.ToString();
97 else {
98 if (fParams.empty()) ss << "Empty";
99 else
100 ss << "Parameters for " << fParams.size() << " sensors";
101 }
102 return ss.str();
103}
104// -------------------------------------------------------------------------
ClassImp(CbmStsParSetModule) CbmStsParSetModule
Parameters for one STS module.
std::string ToString() const
String output.
Parameters container for CbmStsParModule.
virtual void putParams(FairParamList *parList)
virtual Bool_t getParams(FairParamList *parList)
Reading parameters from ASCII. Abstract in base class.
CbmStsParModule fGlobalParams
Global parameters, used for all modules.
std::map< UInt_t, CbmStsParModule > fParams
Map of parameters. Key is module address.
Bool_t fUseGlobal
Flag for using global parameters.
CbmStsParSetModule(const char *name="CbmParSetModule", const char *title="STS parameters", const char *context="Default")
Constructor.
const CbmStsParModule & GetParModule(UInt_t address)
Get condition parameters of a sensor.
virtual void clear()
Reset all parameters.
void SetParModule(UInt_t address, const CbmStsParModule &par)
Set the parameters for a module.
UInt_t DeactivateRandomChannels(Double_t fraction)
Randomly deactivate a fraction of the channels.
std::string ToString() const
Info to string.
virtual ~CbmStsParSetModule()
Destructor.