CbmRoot
Loading...
Searching...
No Matches
KfMaterialMonitor.cxx
Go to the documentation of this file.
1/* Copyright (C) 2023-2024 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Sergey Gorbunov [committer], Sergei Zharko */
4
8
9#include "KfMaterialMonitor.h"
10
12
13#include <iomanip>
14#include <sstream>
15
16namespace cbm::algo::kf
17{
18 namespace
19 {
20 using namespace cbm::algo;
21 }
22
23 // -------------------------------------------------------------------------------------------------------------------
24 //
26 {
27 fMaterial = materialMap;
28
29 fActiveBinMap.resize(0);
30
31 if (fMaterial) {
32 fActiveBinMap.assign(fMaterial->GetNbins() * fMaterial->GetNbins(), 0);
33 }
34
35 // TODO: What do the hits mean here?
36 fNhitsTotal = 0;
37 fNhitsOutside = 0;
38
40 }
41
42 // -------------------------------------------------------------------------------------------------------------------
43 //
45 {
47 if (!fMaterial) {
48 LOG(fatal) << "MaterialMonitor: material map is not set";
49 return;
50 }
51 int i = fMaterial->GetBin(x, y);
53 if (i < 0) {
55 }
56 else {
57 fActiveBinMap[i] = 1;
58 }
59 }
60
61 // -------------------------------------------------------------------------------------------------------------------
62 //
64 {
66
67 fActiveNbins = 0;
68 fPassiveNbins = 0;
69
73
77
78 if (!fMaterial) {
79 return;
80 }
81
82 int nBins = fMaterial->GetNbins() * fMaterial->GetNbins();
83
84 if (nBins != (int) fActiveBinMap.size()) {
85 LOG(fatal) << "MaterialMonitor: map of active bins is not consistent with the material map: nbins "
86 << fActiveBinMap.size() << " != " << nBins;
87 return;
88 }
89
90 for (int i = 0; i < nBins; i++) {
91 double r = fMaterial->GetBinThicknessX0<double>(i);
92 if (fActiveBinMap[i]) { // active material
93 if (fActiveNbins == 0) {
97 }
98 else {
102 }
103 fActiveNbins++;
104 }
105 else {
106 // passive material
107 if (fPassiveNbins == 0) {
111 }
112 else {
116 }
118 }
119 }
120 if (fActiveNbins + fPassiveNbins != nBins) {
121 LOG(fatal) << "MaterialMonitor: wrong calculation of N passive / active bins ";
122 }
123 if (fActiveNbins > 0) {
125 }
126 if (fPassiveNbins > 0) {
128 }
129 }
130
131
132 // -------------------------------------------------------------------------------------------------------------------
133 //
135 {
137
139 // FIXME: a ToString method should not change data of its class, but only represent their current state. I would
140 // call EvaluateStatistics explicitly and provide a const ToString method inside it.
141
142 std::stringstream ss;
143 ss << std::setprecision(2) << std::fixed;
144 ss << "material map " << fName << ". ";
145
146 if (fActiveNbins > 0) {
147 ss << "Active material RL: min " << fActiveRadThickMin * 100. << "%, max " << fActiveRadThickMax * 100.
148 << "%, mean " << fActiveRadThickMean * 100. << "%. ";
149 }
150 else {
151 if (fNhitsTotal > 0) {
152 ss << "No active material. ";
153 }
154 else {
155 ss << "No hits yet to identify active areas. ";
156 }
157 }
158
159 if (fPassiveNbins > 0) {
160 ss << "Passive material RL: min " << fPassiveRadThickMin * 100. << "%, max " << fPassiveRadThickMax * 100.
161 << "%, mean " << fPassiveRadThickMean * 100. << "%. ";
162 }
163 else {
164 ss << "No passive material. ";
165 }
166
167 if (fNhitsTotal > 0) {
168 if (fNhitsOutside == 0) {
169 ss << "No hits outside of the map. ";
170 }
171 else {
172 ss << "There are " << (100. * fNhitsOutside) / fNhitsTotal << "% hits outside the map!!! ";
173 }
174 }
175 else {
176 ss << "No hit statistics yet. ";
177 }
178
179 return ss.str();
180 }
181
182} // namespace cbm::algo::kf
A class to collect statistics for kf::MaterialMap.
A map of station thickness in units of radiation length (X0) to the specific point in XY plane.
const MaterialMap * fMaterial
Pointer to the material map.
unsigned long fNhitsOutside
number of hits outside the material map
double fActiveRadThickMax
Active material: maximal thickness.
std::string fName
Name of the material map.
std::vector< char > fActiveBinMap
Map of active bins in the material map (bins where hits appear)
double fPassiveRadThickMin
Passive material: minimal thickness.
double fPassiveRadThickMean
Passive material: average thickness.
unsigned long fNhitsTotal
number of hits in statistics
void EvaluateStatistics()
Update values of statistical variables with respect to the active map.
std::string ToString()
Print statistics to a string.
int fPassiveNbins
Passive material: number of bins.
int fActiveNbins
Active material: number of bins.
void MarkActiveBin(float x, float y)
Mark a bin as active.
void SetMaterial(const MaterialMap *materialMap)
Set a material budget map.
double fActiveRadThickMin
Active material: minimal thickness.
double fPassiveRadThickMax
Passive material: maximal thickness.
double fActiveRadThickMean
Active material: average thickness.
constexpr T2 Undef
Undefined values.
Definition KfDefs.h:218