CbmRoot
Loading...
Searching...
No Matches
CbmStsParModule.cxx
Go to the documentation of this file.
1/* Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese [committer] */
4
5
6#include "CbmStsParModule.h"
7
8#include <cassert> // for assert
9#include <iostream> // for operator<<, basic_ostream, stringstream
10#include <sstream> // for stringstream
11#include <string> // for char_traits
12
13using std::string;
14using std::stringstream;
15
16
17// ----- Constructor ---------------------------------------------------
18CbmStsParModule::CbmStsParModule(uint32_t nChannels, uint32_t nAsicChannels)
19 : fNofChannels(nChannels)
20 , fNofAsicChannels(nAsicChannels)
21{
22 uint32_t nAsics = (nChannels % nAsicChannels ? nChannels / nAsicChannels + 1 : nChannels / nAsicChannels);
23 fAsicPars.resize(nAsics);
24}
25// -------------------------------------------------------------------------
26
27
28// ----- Copy constructor ----------------------------------------------
35// -------------------------------------------------------------------------
36
37
38// ----- Copy assignment operator --------------------------------------
46// -------------------------------------------------------------------------
47
48
49// ----- Randomly deactivate channels ----------------------------------
51{
52 if (fraction <= 0.) return 0;
53 uint32_t nDeactivated = 0;
54 for (auto& asic : fAsicPars) {
55 nDeactivated += asic.DeactivateRandomChannels(fraction);
56 }
57 return nDeactivated;
58}
59// -------------------------------------------------------------------------
60
61
62// ----- Get ASIC parameters -------------------------------------------
63const CbmStsParAsic& CbmStsParModule::GetParAsic(uint32_t channel) const
64{
65 assert(!fAsicPars.empty());
66 assert(channel < fNofChannels);
67 uint32_t nAsic = channel / fNofAsicChannels;
68 assert(nAsic < GetNofAsics());
69 return fAsicPars[nAsic];
70}
71// -------------------------------------------------------------------------
72
73
74// ----- Check for a channel being active ------------------------------
75Bool_t CbmStsParModule::IsChannelActive(uint32_t channel) const
76{
77 const CbmStsParAsic& parAsic = GetParAsic(channel);
78 uint32_t asicChannel = channel % fNofAsicChannels;
79 return parAsic.IsChannelActive(asicChannel);
80}
81// -------------------------------------------------------------------------
82
83
84// ----- Set parameters for all ASICs ----------------------------------
86{
87 assert(asicPar.GetNofChannels() == fNofAsicChannels);
88 for (auto& par : fAsicPars) {
89 par = asicPar;
90 par.Init();
91 }
92}
93// -------------------------------------------------------------------------
94
95
96// ----- Set parameters for one ASIC -----------------------------------
97void CbmStsParModule::SetAsic(uint32_t asicNr, const CbmStsParAsic& asicPar)
98{
99 assert(asicNr < fAsicPars.size());
100 fAsicPars[asicNr] = asicPar;
101}
102// -------------------------------------------------------------------------
103
104
105// ----- String output -------------------------------------------------
107{
108 stringstream ss;
109 ss << "Channels " << fNofChannels << " | ASICS " << GetNofAsics() << " | Channels per ASIC " << fNofAsicChannels;
110 return ss.str();
111}
112// -------------------------------------------------------------------------
113
114
ClassImp(CbmConverterManager)
Parameters of the STS readout ASIC.
uint16_t GetNofChannels() const
Number of readout channels.
Bool_t IsChannelActive(uint16_t channel) const
Check for a channel being active.
void Init()
Initialisation.
Parameters for one STS module.
uint32_t GetNofChannels() const
Number of channels.
uint32_t DeactivateRandomChannels(double fraction)
Randomly deactivate a fraction of the channels.
std::vector< CbmStsParAsic > fAsicPars
ASIC parameters.
uint32_t GetNofAsics() const
Number of ASICs.
void SetAllAsics(const CbmStsParAsic &asicPar)
Set all ASICs with the same parameter set.
CbmStsParModule()
Default constructor.
uint32_t GetNofAsicChannels() const
Number of channels per ASIC.
uint32_t fNofAsicChannels
Number of channels per ASIC.
bool IsChannelActive(uint32_t channel) const
Check for a channel being active.
CbmStsParModule & operator=(const CbmStsParModule &other)
Copy assignment operator.
uint32_t fNofChannels
Number of readout channels.
std::string ToString() const
String output.
const std::vector< CbmStsParAsic > & GetAsicParams() const
All ASIC parameters.
void SetAsic(uint32_t asicNr, const CbmStsParAsic &asicPar)
Set parameters for a single ASIC.
const CbmStsParAsic & GetParAsic(uint32_t channel) const
ASIC parameters for a given channel.