CbmRoot
Loading...
Searching...
No Matches
CbmTrdParAsic.cxx
Go to the documentation of this file.
1/* Copyright (C) 2018-2020 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Florian Uhlig [committer] */
4
5#include "CbmTrdParAsic.h"
6
7#include <Logger.h> // for Logger, LOG
8
9#include <stdio.h> // for printf
10
11//___________________________________________________________________
12CbmTrdParAsic::CbmTrdParAsic(Int_t address, Int_t FebGrouping, Double_t x, Double_t y, Double_t z, size_t compId)
13 : CbmTrdParMod("CbmTrdParAsic", "TRD ASIC definition")
14 , fAddress(address)
15 , fX(x)
16 , fY(y)
17 , fZ(z)
18 , fFebGrouping(FebGrouping)
19 , fComponentId(compId)
20 , fChannelAddresses()
21{
22}
23
24//___________________________________________________________________
25void CbmTrdParAsic::Print(Option_t* opt) const
26{
27 printf("%s @ %d pos[%5.2f %5.2f]\n", (opt ? opt : GetName()), fAddress, fX, fY);
28}
29
30//___________________________________________________________________
31Int_t CbmTrdParAsic::QueryChannel(Int_t chAddress) const
32{
33 Int_t ich(0);
34 for (std::vector<Int_t>::const_iterator it = fChannelAddresses.begin(); it != fChannelAddresses.end(); it++, ich++) {
35 if (chAddress == (*it)) return ich;
36 }
37 return -1;
38}
39
40//___________________________________________________________________
42{
43 if (QueryChannel(address) >= 0) {
44 LOG(warn) << GetName() << "::SetChannelAddress : pad address " << address << " already allocated";
45 return;
46 }
47 fChannelAddresses.push_back(address);
48}
49
50//___________________________________________________________________
51void CbmTrdParAsic::SetChannelAddresses(std::vector<Int_t> addresses)
52{
53 Int_t nofChannels = addresses.size();
54 if (nofChannels != GetNchannels()) {
55 LOG(warn) << GetName() << "::SetChannelAddresses : input N channels:" << nofChannels << "differs from definition "
56 << GetNchannels() << ". Input will be truncated.";
57 }
58 fChannelAddresses = addresses;
59
60 // I do not see the reason for not directly copying the vector like above - PR - 03/25/2020 - The original code below contains a bug creating 63 channels...
61 // for (Int_t i = 0; i < TMath::Min(nofChannels, GetNchannels()); i++) SetChannelAddress(addresses[i]);
62 // addresses.clear();
63}
64
ClassImp(CbmConverterManager)
Definition of ASIC parameters.
virtual Int_t QueryChannel(Int_t ch) const
Query ASIC for specific pad address.
Double_t fX
center of asic in global c.s. [cm]
std::vector< Int_t > fChannelAddresses
addresses of individual output channels
Double_t fY
center of asic in global c.s. [cm]
Int_t fAddress
unique ASIC ID
virtual void SetChannelAddress(Int_t address)
virtual void SetChannelAddresses(std::vector< Int_t > addresses)
virtual void Print(Option_t *opt="") const
CbmTrdParAsic(Int_t address=0, Int_t FebGrouping=-1, Double_t x=0, Double_t y=0, Double_t z=0, size_t compId=0)
virtual Int_t GetNchannels() const =0
Definition of generic parameters for one TRD module.