CbmRoot
Loading...
Searching...
No Matches
CbmStsEfficiency.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 "CbmStsEfficiency.h"
6
7#include "CbmStsAddress.h"
8#include "CbmStsUtils.h"
9
10CbmStsEfficiency::CbmStsEfficiency(uint32_t layer_idx) : fTestLayer(layer_idx)
11{
12 LOG(debug) << "Creating an instance of CbmStsEfficiency ...";
13}
14CbmStsEfficiency::CbmStsEfficiency(uint32_t test_layer, double max_dis_trg_vtx, double max_dca_trk_vtx,
15 double default_residual)
16 : fTestLayer(test_layer)
17 , fMaxDisTrgVtx(max_dis_trg_vtx)
18 , fMaxDCATrkVtx(max_dca_trk_vtx)
19 , fDefaultResidual(default_residual)
20{
21 LOG(debug) << "Creating an instance of CbmStsEfficiency ...";
22}
23
25{
26 // ---- Binning configuration ----
27 // Vertex
28 double vertex_x_min = -15;
29 double vertex_x_max = +15;
30 double vertex_y_min = -15;
31 double vertex_y_max = +15;
32 double vertex_z_min = -15;
33 double vertex_z_max = +15;
34 double vertex_dx = 0.1;
35 double vertex_dy = 0.1;
36 double vertex_dz = 0.1;
37
38 auto x_vtx_binning =
39 cbm_sts_utils::HBinning{uint32_t((vertex_x_max - vertex_x_min) / vertex_dx), vertex_x_min, vertex_x_max};
40 auto y_vtx_binning =
41 cbm_sts_utils::HBinning{uint32_t((vertex_y_max - vertex_y_min) / vertex_dy), vertex_y_min, vertex_y_max};
42 auto z_vtx_binning =
43 cbm_sts_utils::HBinning{uint32_t((vertex_z_max - vertex_z_min) / vertex_dz), vertex_z_min, vertex_z_max};
44
45 // DCA
46 double dca_dx = .001; // 10 um
47 double dca_min = -2.5 - 0.5 * dca_dx;
48 double dca_max = +2.5 + 0.5 * dca_dx;
49 auto r_dca_binning = cbm_sts_utils::HBinning{uint32_t((dca_max - dca_min) / dca_dx), dca_min, dca_max};
50
51 // Residuals track - hit
52 double res_dx = +0.001; // 10 um
53 double res_min = -2.50 - 0.5 * res_dx;
54 double res_max = +2.50 + 0.5 * res_dx;
55 auto r_sen_binning = cbm_sts_utils::HBinning{uint32_t((res_max - res_min) / res_dx), res_min, res_max};
56 // ---- --------------------- ----
57
58 std::string h_name;
59 for (auto& [element, geo] : fStsGeoInfo) {
60 std::string h_name_base = "";
61 if (element == static_cast<int32_t>(fTestLayer)) {
62 h_name_base = Form("Sts%d", element);
63 }
64 else if (element > 8) {
65 if (CbmStsAddress::GetElementId(element, kStsUnit) != fTestLayer) continue;
66 fDUTList.push_back(element);
67 h_name_base = Form("Sts0x%x", element);
68 }
69
70 if (!h_name_base.length()) continue;
71
72 auto x_sen_binning = cbm_sts_utils::HBinning{uint32_t((geo[1] - geo[0]) / cbm_sts_utils::kStsDx), geo[0], geo[1]};
73 auto y_sen_binning = cbm_sts_utils::HBinning{uint32_t((geo[3] - geo[2]) / cbm_sts_utils::kStsDy), geo[2], geo[3]};
74
75 // ---- efficiency ----
76 h_name = Form("%s_found", h_name_base.c_str());
77 fH2D[h_name] =
78 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
79 x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
80 fH2D[h_name]->GetXaxis()->SetTitle("StsHit^{rec}_{X} [cm]");
81 fH2D[h_name]->GetYaxis()->SetTitle("StsHit^{rec}_{Y} [cm]");
82
83 h_name = Form("%s_track", h_name_base.c_str());
84 fH2D[h_name] =
85 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
86 x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
87 fH2D[h_name]->GetXaxis()->SetTitle("StsHit^{ext}_{X} [cm]");
88 fH2D[h_name]->GetYaxis()->SetTitle("StsHit^{ext}_{Y} [cm]");
89
90 h_name = Form("%s_hit_map", h_name_base.c_str());
91 fH2D[h_name] =
92 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_sen_binning.n_of_bins, x_sen_binning.x_min,
93 x_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
94 fH2D[h_name]->GetXaxis()->SetTitle("StsHit_{X} [cm]");
95 fH2D[h_name]->GetYaxis()->SetTitle("StsHit_{Y} [cm]");
96 // ---- ---------- ----
97
98 // ---- residuals ----
99 for (const char* di : {"x", "y"}) {
100 h_name = Form("%s_d%s_vs_x", h_name_base.c_str(), di);
101 fH2D[h_name] =
102 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_sen_binning.n_of_bins, r_sen_binning.x_min,
103 r_sen_binning.x_max, x_sen_binning.n_of_bins, x_sen_binning.x_min, x_sen_binning.x_max);
104 fH2D[h_name]->GetYaxis()->SetTitle("X [cm]");
105 fH2D[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
106
107 h_name = Form("%s_d%s_vs_y", h_name_base.c_str(), di);
108 fH2D[h_name] =
109 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_sen_binning.n_of_bins, r_sen_binning.x_min,
110 r_sen_binning.x_max, y_sen_binning.n_of_bins, y_sen_binning.x_min, y_sen_binning.x_max);
111 fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
112 fH2D[h_name]->GetXaxis()->SetTitle(Form("\\rho_{%s} [cm]", di));
113 }
114 // ---- --------- ----
115 } // end geo loop
116
117 // ---- 3D vertex ----
118 h_name = "vertex_y_vs_x";
119 fH2D[h_name] =
120 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), x_vtx_binning.n_of_bins, x_vtx_binning.x_min,
121 x_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
122 fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{X} [cm]");
123 fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
124
125 h_name = "vertex_x_vs_z";
126 fH2D[h_name] =
127 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
128 z_vtx_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
129 fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
130 fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{X} [cm]");
131
132 h_name = "vertex_y_vs_z";
133 fH2D[h_name] =
134 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), z_vtx_binning.n_of_bins, z_vtx_binning.x_min,
135 z_vtx_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
136 fH2D[h_name]->GetXaxis()->SetTitle("Vertex_{Z} [cm]");
137 fH2D[h_name]->GetYaxis()->SetTitle("Vertex_{Y} [cm]");
138 // ---- ------------------ ----
139
140 // ---- DCA ----
141 for (const char* di : {"x", "y", "z"}) {
142 h_name = Form("dca_d%s_vs_x", di);
143 fH2D[h_name] =
144 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
145 r_dca_binning.x_max, x_vtx_binning.n_of_bins, x_vtx_binning.x_min, x_vtx_binning.x_max);
146 fH2D[h_name]->GetYaxis()->SetTitle("X [cm]");
147 fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
148
149 h_name = Form("dca_d%s_vs_y", di);
150 fH2D[h_name] =
151 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
152 r_dca_binning.x_max, y_vtx_binning.n_of_bins, y_vtx_binning.x_min, y_vtx_binning.x_max);
153 fH2D[h_name]->GetYaxis()->SetTitle("Y [cm]");
154 fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
155
156 h_name = Form("dca_d%s_vs_z", di);
157 fH2D[h_name] =
158 std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), r_dca_binning.n_of_bins, r_dca_binning.x_min,
159 r_dca_binning.x_max, z_vtx_binning.n_of_bins, z_vtx_binning.x_min, z_vtx_binning.x_max);
160 fH2D[h_name]->GetYaxis()->SetTitle(Form("Z [cm]"));
161 fH2D[h_name]->GetXaxis()->SetTitle(Form("DCA_{%s} [cm]", di));
162 }
163 // ---- ------------------ ----
164
165 // ---- Track multiplicity ----
166 for (const char* mod : {":all", ":sel"}) {
167 h_name = Form("ca_track_multiplicity%s", mod);
168 fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 50, 0, 50); // HARDCODE
169 fH1D[h_name]->GetXaxis()->SetTitle("N_{CATrack}");
170 fH1D[h_name]->GetYaxis()->SetTitle("Entries");
171
172 h_name = Form("ca_track_chi2%s", mod);
173 fH1D[h_name] = std::make_unique<TH1D>(h_name.c_str(), h_name.c_str(), 10000, 0, 10); // HARDCODE
174 fH1D[h_name]->GetXaxis()->SetTitle("Chi2");
175 fH1D[h_name]->GetYaxis()->SetTitle("Entries");
176 }
177 // ---- ------------------ ----
178}
179
181{
182 LOG(debug) << "Checking efficiency of STS station " << fTestLayer << " using " << fGlbTrks.size()
183 << " CbmGlobalTracks";
184 fVertexFinder->SetTracks(fGlbTrks);
185 const std::optional<CbmVertex> vertex = fVertexFinder->FindVertex();
186
187 if (!vertex.has_value()) return;
188
189 if (std::abs(vertex->GetZ()) > fMaxDisTrgVtx) return;
190
191 fH2D["vertex_y_vs_x"]->Fill(vertex->GetX(), vertex->GetY());
192 fH2D["vertex_x_vs_z"]->Fill(vertex->GetZ(), vertex->GetX());
193 fH2D["vertex_y_vs_z"]->Fill(vertex->GetZ(), vertex->GetY());
194
195 TVector3 vtx(vertex->GetX(), vertex->GetY(), vertex->GetZ());
196 std::map<int32_t, std::vector<bool>> hit_used;
197 for (auto trk : fGlbTrks) {
198 double trk_tx = trk->GetParamFirst()->GetTx();
199 double trk_ty = trk->GetParamFirst()->GetTy();
200 double trk_x0 = trk->GetParamFirst()->GetX();
201 double trk_y0 = trk->GetParamFirst()->GetY();
202 double trk_z0 = trk->GetParamFirst()->GetZ();
203
204 // Check if tack comes from vertex
205 TVector3 p(trk_x0, trk_y0, trk_z0);
206 TVector3 e(trk_tx, trk_ty, 1);
207 TVector3 trk_to_vtx = ((vtx - p).Cross(e)) * (1. / e.Mag());
208
209 fH2D["dca_dx_vs_x"]->Fill(trk_to_vtx.Px(), vtx.Px());
210 fH2D["dca_dx_vs_y"]->Fill(trk_to_vtx.Px(), vtx.Py());
211 fH2D["dca_dx_vs_z"]->Fill(trk_to_vtx.Px(), vtx.Pz());
212
213 fH2D["dca_dy_vs_x"]->Fill(trk_to_vtx.Py(), vtx.Px());
214 fH2D["dca_dy_vs_y"]->Fill(trk_to_vtx.Py(), vtx.Py());
215 fH2D["dca_dy_vs_z"]->Fill(trk_to_vtx.Py(), vtx.Pz());
216
217 fH2D["dca_dz_vs_x"]->Fill(trk_to_vtx.Pz(), vtx.Px());
218 fH2D["dca_dz_vs_y"]->Fill(trk_to_vtx.Pz(), vtx.Py());
219 fH2D["dca_dz_vs_z"]->Fill(trk_to_vtx.Pz(), vtx.Pz());
220
221 if (trk_to_vtx.Mag() > fMaxDCATrkVtx) continue;
222
223 for (int32_t& sensor : fDUTList) {
224 auto hits = fStsHits[sensor];
225 size_t n_of_hits = hits.size();
226
227 // Extrapolate to the current sensor z-plane
228 double sensor_z = 0.5 * (fStsGeoInfo[sensor][4] + fStsGeoInfo[sensor][5]);
229 double predicted_x = trk_x0 + trk_tx * (sensor_z - trk_z0);
230 double predicted_y = trk_y0 + trk_ty * (sensor_z - trk_z0);
231
232 // Check if the sensor contain the space point
233 if (predicted_x < fStsGeoInfo[sensor][0] || predicted_x > fStsGeoInfo[sensor][1]
234 || predicted_y < fStsGeoInfo[sensor][2] || predicted_y > fStsGeoInfo[sensor][3]) {
235 continue;
236 }
237
238 int unit = CbmStsAddress::GetElementId(sensor, kStsUnit);
239 fH2D[Form("Sts%d_track", unit)]->Fill(predicted_x, predicted_y);
240 fH2D[Form("Sts0x%x_track", sensor)]->Fill(predicted_x, predicted_y);
241
242 if (n_of_hits) {
243 /* Block to search in available hits */
244 double closest_id = 0;
245 double dx = hits[0]->GetX() - predicted_x - fResiduals[sensor].mean.Px();
246 double dy = hits[0]->GetY() - predicted_y - fResiduals[sensor].mean.Py();
247 double closest_rho = dx * dx + dy * dy;
248
249 for (size_t idx = 1; idx < n_of_hits; idx++) {
250 dx = hits[idx]->GetX() - predicted_x - fResiduals[sensor].mean.Px();
251 dy = hits[idx]->GetY() - predicted_y - fResiduals[sensor].mean.Py();
252 double rho = dx * dx + dy * dy;
253
254 if (rho < closest_rho) {
255 closest_id = idx;
256 closest_rho = rho;
257 }
258 }
259
260 dx = hits[closest_id]->GetX() - predicted_x - fResiduals[sensor].mean.Px();
261 dy = hits[closest_id]->GetY() - predicted_y - fResiduals[sensor].mean.Py();
262
263 fH2D[Form("Sts%d_dx_vs_x", unit)]->Fill(dx, hits[closest_id]->GetX());
264 fH2D[Form("Sts%d_dy_vs_x", unit)]->Fill(dy, hits[closest_id]->GetX());
265 fH2D[Form("Sts%d_dx_vs_y", unit)]->Fill(dx, hits[closest_id]->GetY());
266 fH2D[Form("Sts%d_dy_vs_y", unit)]->Fill(dy, hits[closest_id]->GetY());
267
268 fH2D[Form("Sts0x%x_dx_vs_x", sensor)]->Fill(dx, hits[closest_id]->GetX());
269 fH2D[Form("Sts0x%x_dy_vs_x", sensor)]->Fill(dy, hits[closest_id]->GetX());
270 fH2D[Form("Sts0x%x_dx_vs_y", sensor)]->Fill(dx, hits[closest_id]->GetY());
271 fH2D[Form("Sts0x%x_dy_vs_y", sensor)]->Fill(dy, hits[closest_id]->GetY());
272
273 double sensor_resolution =
274 fResiduals[sensor].sigma.Mag() != 0 ? fResiduals[sensor].sigma.Mag() : fDefaultResidual;
275 if (closest_rho <= 3.0 * sensor_resolution) {
276 fH2D[Form("Sts%d_found", unit)]->Fill(predicted_x, predicted_y);
277 fH2D[Form("Sts0x%x_found", sensor)]->Fill(predicted_x, predicted_y);
278 }
279 }
280
281
282 /* Block to search in avaliable hit */
283
284 } // end sensor under test lopp
285 } // end track loop
286}
287
288TH2D* FindInactiveArea(TH2D* h, int dead_size_x = 10, int dead_size_y = 10)
289{
290 TH2D* dead = (TH2D*) h->Clone();
291 dead->Reset();
292
293 for (int bin_y = 1; bin_y < dead->GetNbinsY(); bin_y++) {
294 for (int bin_x = dead_size_x; bin_x < dead->GetNbinsX() - dead_size_x; bin_x++) {
295
296 bool all_dead = true;
297 for (int test_bin = -dead_size_x; test_bin <= +dead_size_x; test_bin++) {
298 if (h->GetBinContent(bin_x + test_bin, bin_y)) {
299 all_dead = false;
300 break;
301 }
302 }
303 if (all_dead) {
304 for (int test_bin = -dead_size_x; test_bin <= +dead_size_x; test_bin++)
305 dead->SetBinContent(bin_x + test_bin, bin_y, 1);
306 }
307 }
308 }
309
310 for (int bin_x = 1; bin_x < dead->GetNbinsX(); bin_x++) {
311 for (int bin_y = dead_size_y; bin_y < dead->GetNbinsY() - dead_size_y; bin_y++) {
312
313 bool all_dead = true;
314 for (int test_bin = -dead_size_y; test_bin <= +dead_size_y; test_bin++) {
315 if (h->GetBinContent(bin_x, bin_y + test_bin)) {
316 all_dead = false;
317 break;
318 }
319 }
320 if (all_dead) {
321 for (int test_bin = -dead_size_y; test_bin <= +dead_size_y; test_bin++)
322 dead->SetBinContent(bin_x, bin_y + test_bin, 1);
323 }
324 }
325 }
326
327 return dead;
328}
329
330void CbmStsEfficiency::Efficiency(uint32_t sensor)
331{
332 std::string h_name_base = "";
333 if (sensor == fTestLayer) {
334 h_name_base = Form("Sts%d", sensor);
335 }
336 else if (sensor > 8) {
337 if (CbmStsAddress::GetElementId(sensor, kStsUnit) != fTestLayer) return;
338 h_name_base = Form("Sts0x%x", sensor);
339 }
340 auto found = fH2D[Form("%s_found", h_name_base.c_str())].get();
341 auto track = fH2D[Form("%s_track", h_name_base.c_str())].get();
342
343 if (found == nullptr || track == nullptr) return;
344
345 TH2D* inactive_area = FindInactiveArea(fH2D[Form("%s_hit_map", h_name_base.c_str())].get(), 50, 50);
346
347 // Manual integration
348 int n_of_found = 0;
349 int n_of_track = 0;
350 std::vector<double> samples;
351
352 for (int bin_y = 50; bin_y < inactive_area->GetNbinsY() - 50; bin_y++) {
353 for (int bin_x = 50; bin_x < inactive_area->GetNbinsX() - 50; bin_x++) {
354 if (!inactive_area->GetBinContent(bin_x, bin_y)) {
355 n_of_found += found->GetBinContent(bin_x, bin_y);
356 n_of_track += track->GetBinContent(bin_x, bin_y);
357 }
358 }
359 }
360 LOG(debug) << n_of_found << "\t" << n_of_track;
361 double efficiency = n_of_track != 0 ? double(n_of_found) / n_of_track : -1;
362 if (efficiency != -1) {
363 samples.push_back(efficiency);
364 }
365
366 double mean = 0;
367 double sigma = 0;
368 int n = samples.size();
369 if (n == 0) {
370 return;
371 }
372
373 // Take efficiency as mean value
374 for (double& val : samples) {
375 mean += val;
376 }
377 mean = double(mean / n);
378
379 // Take error as RMS of the values
380 for (double& val : samples) {
381 sigma += (val - mean) * (val - mean);
382 }
383 sigma = sqrt(double(sigma / n));
384
385 std::cout << Form("0x%x:\t%0.4f\t%0.4f\n", sensor, mean, sigma);
386}
387
389{
390 for (auto& [element, geo] : fStsGeoInfo) {
391 Efficiency(element);
392 }
393
394 SaveToFile();
395}
396
397
399{
400 int nb_sts_hits = evt->GetNofData(ECbmDataType::kStsHit);
401
402 for (int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
403 int sts_hit_idx = evt->GetIndex(ECbmDataType::kStsHit, hit_evt_idx);
404 CbmStsHit* hit = (CbmStsHit*) fStsHitArray->UncheckedAt(sts_hit_idx);
405 ProcessHit(hit);
406 }
407
408 int nb_of_glob_trk = evt->GetNofData(ECbmDataType::kGlobalTrack);
409 for (int evt_glob_trk_idx = 0; evt_glob_trk_idx < nb_of_glob_trk; evt_glob_trk_idx++) {
410 int glob_trk_idx = evt->GetIndex(ECbmDataType::kGlobalTrack, evt_glob_trk_idx);
411 CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glob_trk_idx);
412 ProcessGlobalTrack(glob_trk);
413 }
414
415 fH1D["ca_track_multiplicity:all"]->Fill(nb_of_glob_trk);
416 fH1D["ca_track_multiplicity:sel"]->Fill(fGlbTrks.size());
417
418 if (fGlbTrks.size()) CheckEfficiency();
419
420 fGlbTrks.clear();
421 fStsHits.clear();
422}
423
425{
426 auto sts_trk_idx = trk->GetStsTrackIndex();
427 auto rich_trk_idx = trk->GetRichRingIndex();
428 auto much_trk_idx = trk->GetMuchTrackIndex();
429 auto trd_trk_idx = trk->GetTrdTrackIndex();
430 auto tof_trk_idx = trk->GetTofTrackIndex();
431 double trk_p_val = TMath::Prob(trk->GetChi2(), trk->GetNDF());
432 fH1D["ca_track_chi2:all"]->Fill(trk->GetChi2());
433
434 // Apply GlobalTracks cuts
435 int32_t mvd_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
436 ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofMvdHits()
437 : 0;
438
439 int32_t sts_trk_size = sts_trk_idx != -1 && fStsTrkArray != nullptr
440 ? ((CbmStsTrack*) fStsTrkArray->UncheckedAt(sts_trk_idx))->GetNofStsHits()
441 : 0;
442
443 int32_t rich_trk_size = rich_trk_idx != -1 && fRchTrkArray != nullptr
444 ? ((CbmTrack*) fRchTrkArray->UncheckedAt(rich_trk_idx))->GetNofHits()
445 : 0;
446
447 int32_t much_trk_size = much_trk_idx != -1 && fMchTrkArray != nullptr
448 ? ((CbmTrack*) fMchTrkArray->UncheckedAt(much_trk_idx))->GetNofHits()
449 : 0;
450
451 int32_t trd_trk_size = trd_trk_idx != -1 && fTrdTrkArray != nullptr
452 ? ((CbmTrack*) fTrdTrkArray->UncheckedAt(trd_trk_idx))->GetNofHits()
453 : 0;
454
455 int32_t tof_trk_size = tof_trk_idx != -1 && fTofTrkArray != nullptr
456 ? ((CbmTrack*) fTofTrkArray->UncheckedAt(tof_trk_idx))->GetNofHits()
457 : 0;
458
459 if (fAnalysisCuts != nullptr
460 && (!fAnalysisCuts->Check(CbmCutId::kGlobalTrackMvdSize, mvd_trk_size)
461 || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackStsSize, sts_trk_size)
462 || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackRichSize, rich_trk_size)
463 || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackMuchSize, much_trk_size)
464 || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTrdSize, trd_trk_size)
465 || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackTofSize, tof_trk_size)
467 || !fAnalysisCuts->Check(CbmCutId::kGlobalTrackPval, trk_p_val))) {
468 return;
469 }
470
471 fH1D["ca_track_chi2:sel"]->Fill(trk->GetChi2());
472 fGlbTrks.push_back(trk);
473}
474
476{
477 if (hit == nullptr) return;
478 uint32_t address = hit->GetAddress();
479 uint32_t unit = CbmStsAddress::GetElementId(address, kStsUnit);
480
481 if (unit != fTestLayer) return;
482
483 if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckStsHit(hit, fStsCluArray)) return;
484
485 fStsHits[address].push_back(hit);
486 fH2D[Form("Sts%u_hit_map", unit)]->Fill(hit->GetX(), hit->GetY());
487 fH2D[Form("Sts0x%x_hit_map", address)]->Fill(hit->GetX(), hit->GetY());
488}
489
491{
492 // Check if CbmEvent
493 if (fCbmEvtArray != nullptr) {
494 LOG(info) << "Running CbmStsEfficiency - Event-like - " << entry_;
495
496 uint32_t nb_events = fCbmEvtArray->GetEntriesFast();
497 for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
498 CbmEvent* event = (CbmEvent*) fCbmEvtArray->UncheckedAt(evt_idx);
499 if (fAnalysisCuts != nullptr && !fAnalysisCuts->CheckEvent(event)) continue;
500 LOG(debug) << Form("Process CbmEvent %d / %d", evt_idx, nb_events);
501 ProcessEvent(event);
502 }
503 }
504 else {
505
506 LOG(info) << "Running CbmStsEfficiency - TS-like - ";
507 uint32_t n_of_hits = fStsHitArray->GetEntriesFast();
508 for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
509 CbmStsHit* sts_hit = (CbmStsHit*) fStsHitArray->UncheckedAt(hit_idx);
510 ProcessHit(sts_hit);
511 }
512 uint32_t nb_of_glob_trk = fGlbTrkArray->GetEntriesFast();
513 LOG(debug) << Form("Number of GlobalTracks: %u", nb_of_glob_trk);
514 for (uint32_t glob_trk_idx = 0; glob_trk_idx < nb_of_glob_trk; glob_trk_idx++) {
515 CbmGlobalTrack* glob_trk = (CbmGlobalTrack*) fGlbTrkArray->UncheckedAt(glob_trk_idx);
516 ProcessGlobalTrack(glob_trk);
517 }
518
519 if (fGlbTrks.size()) CheckEfficiency();
520
521 fGlbTrks.clear();
522 fStsHits.clear();
523 }
524 entry_++;
525}
526
528{
529 LOG(debug) << "Init CbmStsEfficiency ...";
530
531 FairRootManager* ioman = FairRootManager::Instance();
532 if (ioman != nullptr) {
533 fCbmEvtArray = (TClonesArray*) ioman->GetObject("CbmEvent");
534
535 fGlbTrkArray = (TClonesArray*) ioman->GetObject("GlobalTrack");
536
537 fStsTrkArray = (TClonesArray*) ioman->GetObject("StsTrack");
538 fRchTrkArray = (TClonesArray*) ioman->GetObject("RichTrack");
539 fMchTrkArray = (TClonesArray*) ioman->GetObject("MuchTrack");
540 fTrdTrkArray = (TClonesArray*) ioman->GetObject("TrdTrack");
541 fTofTrkArray = (TClonesArray*) ioman->GetObject("TofTrack");
542
543 fStsHitArray = (TClonesArray*) ioman->GetObject("StsHit");
544
545 fStsCluArray = (TClonesArray*) ioman->GetObject("StsCluster");
546 }
547
548 LoadSetup();
549
551
552 std::stringstream ss;
553 for (auto s : fDUTList) {
554 ss << Form("\t\t0x%x - U%d L%d M%d\n", s, CbmStsAddress::GetElementId(s, kStsUnit),
556 }
557
558 LOG(info) << "Max vtx target dz: " << fMaxDisTrgVtx;
559 LOG(info) << "Max trk vtx DCA: " << fMaxDCATrkVtx;
560 LOG(info) << "Default residual: " << fDefaultResidual;
561 LOG(info) << "Test layer: " << fTestLayer;
562 LOG(info) << "Layer modules:\n" << ss.str();
563
564 return kSUCCESS;
565}
566
567void CbmStsEfficiency::SetSensorResidual(int32_t address, TVector3 m, TVector3 s)
568{
569 fResiduals[address] = Residual(m, s);
570}
571
572void CbmStsEfficiency::SetResidual(std::string file_name)
573{
574 std::ifstream in(file_name);
575 int32_t sensor;
576 double mean_x, mean_y, sigma_x, sigma_y;
577 while (in >> std::hex >> sensor >> std::dec >> mean_x >> mean_y >> sigma_x >> sigma_y) {
578 SetSensorResidual(sensor, TVector3(mean_x, mean_y, 0), TVector3(sigma_x, sigma_y, 0));
579 }
580}
581
582
@ kGlobalTrackMvdSize
Definition CbmCutId.h:132
@ kGlobalTrackChi2
Definition CbmCutId.h:126
@ kGlobalTrackMuchSize
Definition CbmCutId.h:141
@ kGlobalTrackTrdSize
Definition CbmCutId.h:144
@ kGlobalTrackStsSize
Definition CbmCutId.h:135
@ kGlobalTrackPval
Definition CbmCutId.h:127
@ kGlobalTrackTofSize
Definition CbmCutId.h:147
@ kGlobalTrackRichSize
Definition CbmCutId.h:138
@ kStsModule
@ kStsLadder
@ kStsUnit
TH2D * FindInactiveArea(TH2D *h, int dead_size_x=10, int dead_size_y=10)
static vector< vector< QAHit > > hits
friend fvec sqrt(const fvec &a)
Estimates a common vertex from multiple straight GlobalTracks.
Class characterising one event by a collection of links (indices) to data objects,...
Definition CbmEvent.h:34
size_t GetNofData() const
Definition CbmEvent.cxx:58
uint32_t GetIndex(ECbmDataType type, uint32_t iData) const
Definition CbmEvent.cxx:42
int32_t GetStsTrackIndex() const
double GetChi2() const
int32_t GetRichRingIndex() const
int32_t GetTofTrackIndex() const
int32_t GetMuchTrackIndex() const
int32_t GetNDF() const
int32_t GetTrdTrackIndex() const
int32_t GetAddress() const
Definition CbmHit.h:77
double GetY() const
Definition CbmPixelHit.h:74
double GetX() const
Definition CbmPixelHit.h:73
CbmCutMap * fAnalysisCuts
std::map< std::string, std::unique_ptr< TH2D > > fH2D
void SaveToFile()
It write all mapped objects to the FairRunAna sink file.
void LoadSetup()
Load the STS setup and fill the map with XYZ boundaries for each STS setup element....
std::unordered_map< int32_t, std::vector< double > > fStsGeoInfo
std::map< std::string, std::unique_ptr< TH1D > > fH1D
void ProcessGlobalTrack(CbmGlobalTrack *)
Process an Global tracks It filters the tracks based on the provided CbmCutMap.
void Exec(Option_t *)
TClonesArray * fRchTrkArray
void SetResidual(std::string)
void SetVertexFinder(CbmDcaVertexFinder *)
TClonesArray * fCbmEvtArray
void ProcessEvent(CbmEvent *)
Process an Cbm events It filters event based on the provided CbmCutMap.
CbmDcaVertexFinder * fVertexFinder
std::vector< int32_t > fDUTList
void Efficiency(uint32_t)
TClonesArray * fStsCluArray
std::vector< CbmGlobalTrack * > fGlbTrks
CbmStsEfficiency()=default
TClonesArray * fStsTrkArray
TClonesArray * fGlbTrkArray
TClonesArray * fStsHitArray
std::map< int32_t, Residual > fResiduals
std::map< int32_t, std::vector< CbmStsHit * > > fStsHits
TClonesArray * fTrdTrkArray
void SetSensorResidual(int32_t, TVector3, TVector3)
void ProcessHit(CbmStsHit *)
Process an STS hit It filters hits based on the provided CbmCutMap.
TClonesArray * fMchTrkArray
TClonesArray * fTofTrkArray
data class for a reconstructed 3-d hit in the STS
Definition CbmStsHit.h:35
Data class with information on a STS local track.
uint32_t GetElementId(int32_t address, int32_t level)
Get the index of an element.
static const double kStsDy
Definition CbmStsUtils.h:22
static const double kStsDx
Definition CbmStsUtils.h:21
Structure to hold the binning for 1D histogram.
Definition CbmStsUtils.h:92