CbmRoot
Loading...
Searching...
No Matches
CbmStsUtils.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Dario Ramirez [committer] */
4
5#include "CbmStsUtils.h"
6
7#include "CbmStsAddress.h"
8#include "CbmStsCluster.h"
10
11#include <cassert>
12
13int32_t cbm_sts_utils::GetHitCluSizeF(CbmStsHit* hit, TClonesArray* sts_clu_array)
14{
15 if (hit == nullptr || sts_clu_array == nullptr) {
16 return -1;
17 }
18 return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetFrontClusterId()))->GetSize();
19}
20int32_t cbm_sts_utils::GetHitCluSizeB(CbmStsHit* hit, TClonesArray* sts_clu_array)
21{
22 if (hit == nullptr || sts_clu_array == nullptr) {
23 return -1;
24 }
25 return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetBackClusterId()))->GetSize();
26}
27/* Get StsHit charge as average of front and back cluster charges */
28double cbm_sts_utils::GetHitChargeF(CbmStsHit* hit, TClonesArray* sts_clu_array)
29{
30 if (hit == nullptr || sts_clu_array == nullptr) {
31 return -1;
32 }
33 return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetFrontClusterId()))->GetCharge();
34}
35
36double cbm_sts_utils::GetHitChargeB(CbmStsHit* hit, TClonesArray* sts_clu_array)
37{
38 if (hit == nullptr || sts_clu_array == nullptr) {
39 return -1;
40 }
41 return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetBackClusterId()))->GetCharge();
42}
43
44/* Get StsHit cluster time */
45double cbm_sts_utils::GetHitTimeF(CbmStsHit* hit, TClonesArray* sts_clu_array)
46{
47 if (hit == nullptr || sts_clu_array == nullptr) {
48 return -1;
49 }
50 return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetFrontClusterId()))->GetTime();
51}
52
53double cbm_sts_utils::GetHitTimeB(CbmStsHit* hit, TClonesArray* sts_clu_array)
54{
55 if (hit == nullptr || sts_clu_array == nullptr) {
56 return -1;
57 }
58 return ((CbmStsCluster*) sts_clu_array->UncheckedAt(hit->GetBackClusterId()))->GetTime();
59}
60/* ---- ------------- ---- */
61
62double cbm_sts_utils::GetHitCharge(CbmStsHit* hit, TClonesArray* sts_clu_array)
63{
64 if (hit == nullptr || sts_clu_array == nullptr) {
65 return -1;
66 }
67 double cluster_charge_f = GetHitChargeF(hit, sts_clu_array);
68 double cluster_charge_b = GetHitChargeB(hit, sts_clu_array);
69 return 0.5 * (cluster_charge_f + cluster_charge_b);
70}
71
72/* Get charge asymmetry */
73double cbm_sts_utils::GetHitChargeAsy(CbmStsHit* hit, TClonesArray* sts_clu_array)
74{
75 if (hit == nullptr || sts_clu_array == nullptr) {
76 return -1;
77 }
78 double cluster_charge_f = GetHitChargeF(hit, sts_clu_array);
79 double cluster_charge_b = GetHitChargeB(hit, sts_clu_array);
80 return (cluster_charge_f - cluster_charge_b) / (cluster_charge_f + cluster_charge_b);
81}
82
84std::pair<cbm_sts_utils::HBinning, cbm_sts_utils::HBinning>
85cbm_sts_utils::ChargeBinning(const CbmStsParModule& par_module, const uint32_t max_clu_size)
86{
87 assert((max_clu_size > 0) && "Maximum cluster size must be greater than 0");
88
89 auto par_asic = par_module.GetAsicParams();
90
91 double n_side_q_thr = par_asic[0].GetThreshold();
92 double n_side_q_dyn = par_asic[0].GetDynRange();
93 double p_side_q_thr = par_asic[8].GetThreshold();
94 double p_side_q_dyn = par_asic[8].GetDynRange();
95
96 for (int asic_idx = 0; asic_idx < 16; asic_idx++) {
97 auto asic = par_asic[asic_idx];
98 if (asic_idx < 7) { // n-side
99 n_side_q_thr = std::min(n_side_q_thr, asic.GetThreshold());
100 n_side_q_dyn = std::max(n_side_q_dyn, asic.GetDynRange());
101 }
102 else { // p-side
103 p_side_q_thr = std::min(p_side_q_thr, asic.GetThreshold());
104 p_side_q_dyn = std::max(p_side_q_dyn, asic.GetDynRange());
105 }
106 }
107
108 double n_side_q_bin = n_side_q_dyn / 31;
109 double p_side_q_bin = p_side_q_dyn / 31;
110
111 double n_side_q_min = n_side_q_thr;
112 double p_side_q_min = p_side_q_thr;
113
114 double n_side_q_max = (n_side_q_dyn * (31.5 / 31) + 0.5 * n_side_q_bin) * max_clu_size + n_side_q_min;
115 double p_side_q_max = (p_side_q_dyn * (31.5 / 31) + 0.5 * p_side_q_bin) * max_clu_size + p_side_q_min;
116
117 uint32_t n_side_n_bin = 32 * max_clu_size;
118 uint32_t p_side_n_bin = 32 * max_clu_size;
119
120 return std::make_pair(cbm_sts_utils::HBinning{n_side_n_bin, n_side_q_min, n_side_q_max},
121 cbm_sts_utils::HBinning{p_side_n_bin, p_side_q_min, p_side_q_max});
122}
123
124
125std::set<int> cbm_sts_utils::GetUnits(const std::vector<int32_t> addresses)
126{
127 std::set<int> units;
128 for (int32_t address : addresses) {
129 units.insert(CbmStsAddress::GetElementId(address, kStsUnit));
130 }
131 return units;
132}
133
134std::vector<int32_t> cbm_sts_utils::GetUnitModules(const std::vector<int32_t> addresses, const uint32_t unit)
135{
136 std::vector<int32_t> unit_modules;
137 for (int32_t address : addresses) {
138 if (CbmStsAddress::GetElementId(address, kStsUnit) == unit) {
139 unit_modules.push_back(address);
140 }
141 }
142 return unit_modules;
143}
@ kStsUnit
Data class for STS clusters.
static const CbmStsParAsic par_asic(128, 31, 75000, 3000, 5, 800, 0, 0)
Data class for STS clusters.
data class for a reconstructed 3-d hit in the STS
Definition CbmStsHit.h:35
int32_t GetFrontClusterId() const
Definition CbmStsHit.h:105
int32_t GetBackClusterId() const
Definition CbmStsHit.h:65
Parameters for one STS module.
const std::vector< CbmStsParAsic > & GetAsicParams() const
All ASIC parameters.
uint32_t GetElementId(int32_t address, int32_t level)
Get the index of an element.
int32_t GetHitCluSizeB(CbmStsHit *hit=nullptr, TClonesArray *clusters=nullptr)
Get the cluster size of a hit from the back side.
double GetHitChargeAsy(CbmStsHit *hit=nullptr, TClonesArray *clusters=nullptr)
Get the charge asymmetry of a hit.
double GetHitChargeF(CbmStsHit *hit=nullptr, TClonesArray *clusters=nullptr)
Get the charge of a hit from the front side.
double GetHitTimeB(CbmStsHit *hit=nullptr, TClonesArray *clusters=nullptr)
Get the charge of a hit from the back side.
std::pair< HBinning, HBinning > ChargeBinning(const CbmStsParModule &par_module, const uint32_t max_clu_size=1)
Generate the charge binning from module config obj.
double GetHitChargeB(CbmStsHit *hit=nullptr, TClonesArray *clusters=nullptr)
Get the charge of a hit from the back side.
std::set< int > GetUnits(const std::vector< int32_t > addresses)
Return the STS units from a list of addresses.
double GetHitCharge(CbmStsHit *hit=nullptr, TClonesArray *clusters=nullptr)
Get the charge of a hit as the average of front and back cluster charges.
double GetHitTimeF(CbmStsHit *hit=nullptr, TClonesArray *clusters=nullptr)
Get the charge of a hit from the front side.
std::vector< int32_t > GetUnitModules(const std::vector< int32_t > addresses, const uint32_t unit)
From a list of module address, return those that belong to a selected unit.
int32_t GetHitCluSizeF(CbmStsHit *hit=nullptr, TClonesArray *clusters=nullptr)
Get the cluster size of a hit from the front side.
Structure to hold the binning for 1D histogram.
Definition CbmStsUtils.h:92