CbmRoot
Loading...
Searching...
No Matches
CbmCaInputQaSts.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: Sergei Zharko [committer] */
4
9
10#include "CbmCaInputQaSts.h"
11
12#include "CbmAddress.h"
13#include "CbmMCDataArray.h"
14#include "CbmMCEventList.h"
15#include "CbmMCTrack.h"
16#include "CbmMatch.h"
17#include "CbmQaCanvas.h"
18#include "CbmQaTable.h"
19#include "CbmQaUtil.h"
20#include "CbmStsCluster.h"
21#include "CbmStsHit.h"
22#include "CbmStsPoint.h"
23#include "CbmTimeSlice.h"
24#include "FairRootManager.h"
25#include "Logger.h"
26#include "TBox.h"
27#include "TClonesArray.h"
28#include "TEllipse.h"
29#include "TF1.h"
30#include "TFormula.h"
31#include "TGraphAsymmErrors.h"
32#include "TH1F.h"
33#include "TH2F.h"
34#include "TMath.h"
35#include "TProfile.h"
36#include "TProfile2D.h"
37#include "TStyle.h"
38
39#include <algorithm>
40#include <fstream>
41#include <iomanip>
42#include <numeric>
43#include <tuple>
44
46
47// ---------------------------------------------------------------------------------------------------------------------
48//
49CbmCaInputQaSts::CbmCaInputQaSts(int verbose, bool isMCUsed) : CbmCaInputQaBase("CbmCaInputQaSts", verbose, isMCUsed)
50{
51 // Default parameters of task
53}
54
55// ---------------------------------------------------------------------------------------------------------------------
56//
58{
60 if (IsMCUsed()) {
61 for (int idig = 0; idig <= fkMaxDigisInClusterForPulls; idig++) {
63 auto [msgU, resU] = CheckRangePull(fvph_pull_u_Ndig[idig]);
64 StoreCheckResult(Form("pull_u_%d_digis", idig), resU, msgU);
65
67 auto [msgV, resV] = CheckRangePull(fvph_pull_v_Ndig[idig]);
68 StoreCheckResult(Form("pull_v_%d_digis", idig), resV, msgV);
69 }
70 } // McUsed
71}
72
73
74// ---------------------------------------------------------------------------------------------------------------------
75//
77{
78 gStyle->SetOptFit(1);
79
80 if (IsMCUsed()) {
81 { // u-coordinate vs N digis
82 auto* canv = MakeQaObject<CbmQaCanvas>("vs N digi/pull_u", "Pulls for u coordinate vs N digis", 1600, 800);
83 canv->Divide2D(fkMaxDigisInClusterForPulls + 1);
84 for (int i = 0; i <= fkMaxDigisInClusterForPulls; ++i) {
85 canv->cd((i > 0) ? i : fkMaxDigisInClusterForPulls + 1);
86 fvph_pull_u_Ndig[i]->DrawCopy("", "");
87 }
88 }
89
90 { // v-coordinate vs N digis
91 auto* canv = MakeQaObject<CbmQaCanvas>("vs N digi/pull_v", "Pulls for v coordinate vs N digis", 1600, 800);
92 canv->Divide2D(fkMaxDigisInClusterForPulls + 1);
93 for (int i = 0; i <= fkMaxDigisInClusterForPulls; ++i) {
94 canv->cd((i > 0) ? i : fkMaxDigisInClusterForPulls + 1);
95 fvph_pull_v_Ndig[i]->DrawCopy("", "");
96 }
97 }
98 }
99
101}
102
103// ---------------------------------------------------------------------------------------------------------------------
104//
106{
108
109 // Vectors with pointers to histograms
110 fvph_pull_u_Ndig.clear();
111 fvph_pull_v_Ndig.clear();
112}
113
114// ---------------------------------------------------------------------------------------------------------------------
115//
117{
118 auto SetRange = [](std::array<double, 2>& range, double min, double max) {
119 range[0] = min;
120 range[1] = max;
121 };
122 // Hit errors
123 SetRange(fRHitDx, 0.0000, 0.0050); // [cm]
124 SetRange(fRHitDy, 0.0000, 0.0200); // [cm]
125 SetRange(fRHitDu, 0.0000, 0.0050); // [cm]
126 SetRange(fRHitDv, 0.0000, 0.0050); // [cm]
127 SetRange(fRHitDt, 0.0000, 10.000); // [ns]
128 // Residuals
129 SetRange(fRResX, -0.02, 0.02);
130 SetRange(fRResY, -0.10, 0.10);
131 SetRange(fRResU, -0.02, 0.02);
132 SetRange(fRResV, -0.02, 0.02);
133 SetRange(fRResT, -25.0, 25.0);
134}
135
136// ---------------------------------------------------------------------------------------------------------------------
137//
139{
140 const auto* pHit = dynamic_cast<const CbmStsHit*>(fpHits->At(fHitQaData.GetHitIndex()));
141
142 if (IsMCUsed()) { // u-coordinate residual per number of digis
143 const auto* pCluster = dynamic_cast<const CbmStsCluster*>(fpClusters->At(pHit->GetFrontClusterId()));
144 assert(pCluster);
145 int nDigis = pCluster->GetNofDigis();
146 if (nDigis > fkMaxDigisInClusterForPulls) {
147 nDigis = 0;
148 }
149 fvph_pull_u_Ndig[nDigis]->Fill(fHitQaData.GetPullU());
150 }
151
152 if (IsMCUsed()) { // v-coordinate residual per number of digis
153 const auto* pCluster = dynamic_cast<const CbmStsCluster*>(fpClusters->At(pHit->GetBackClusterId()));
154 assert(pCluster);
155 int nDigis = pCluster->GetNofDigis();
156 if (nDigis > fkMaxDigisInClusterForPulls) {
157 nDigis = 0;
158 }
159 fvph_pull_v_Ndig[nDigis]->Fill(fHitQaData.GetPullV());
160 }
161}
162
163// ---------------------------------------------------------------------------------------------------------------------
164//
166
167// ---------------------------------------------------------------------------------------------------------------------
168//
170{
171 // ----- Detector intereface
172 //
173 auto initStatus = CbmCaInputQaBase::InitQa();
174 if (initStatus != kSUCCESS) {
175 return initStatus;
176 }
177
178 // ----- Input data initialization
179 //
180 fpClusters = dynamic_cast<TClonesArray*>(FairRootManager::Instance()->GetObject("StsCluster"));
181 LOG_IF(fatal, !fpClusters) << "\033[1;31m" << fName << ": container of hit clusters in STS is not found\033[0m";
182
183 // ----- Histogram initialization
184 //
185 int nSt = fpDetInterface->GetNofTrackingStations();
186
187 // rename some histogramms with respect to STS specifics
188 for (int iSt = 0; iSt <= nSt; ++iSt) {
189 TString tsuff = (iSt == nSt) ? "" : Form(" in STS station %d", iSt); // Histogram title suffix
190 fvph_hit_du[iSt]->SetTitle((TString) "Hit position error across front strips" + tsuff);
191 fvph_hit_dv[iSt]->SetTitle((TString) "Hit position error across back strips" + tsuff);
192 fvph_hit_kuv[iSt]->SetTitle((TString) "Hit error correlation between front and back strips" + tsuff);
193 if (IsMCUsed()) {
194 fvph_res_u[iSt]->SetTitle((TString) "Residuals for Front strip coordinate" + tsuff);
195 fvph_res_v[iSt]->SetTitle((TString) "Residuals for Back strip coordinate" + tsuff);
196 fvph_pull_u[iSt]->SetTitle((TString) "Pulls for Front strip coordinate" + tsuff);
197 fvph_pull_v[iSt]->SetTitle((TString) "Pulls for Back strip coordinate" + tsuff);
198 fvph_res_u_vs_u[iSt]->SetTitle((TString) "Residuals for Front strip coordinate" + tsuff);
199 fvph_res_v_vs_v[iSt]->SetTitle((TString) "Residuals for Back strip coordinate" + tsuff);
200 fvph_pull_u_vs_u[iSt]->SetTitle((TString) "Pulls for Front strip coordinate" + tsuff);
201 fvph_pull_v_vs_v[iSt]->SetTitle((TString) "Pulls for Back strip coordinate" + tsuff);
202 }
203 }
204
205 if (IsMCUsed()) {
208
209 for (int idig = 0; idig <= fkMaxDigisInClusterForPulls; idig++) {
210 TString sN = "All stations/pull/Ndigi/pull_u_";
211 TString sT = "Pulls for Front strip coordinate, hits with ";
212 if (idig == 0) {
213 sN += Form("%d+_digi", fkMaxDigisInClusterForPulls + 1);
214 sT += Form(">=%d digi", fkMaxDigisInClusterForPulls + 1);
215 }
216 else {
217 sN += Form("%d_digi", idig);
218 sT += Form("%d digi", idig);
219 }
220 sT += "; (u_{reco} - u_{MC}) / #sigma_{u}^{reco}";
222 }
223
224 for (int idig = 0; idig <= fkMaxDigisInClusterForPulls; idig++) {
225 TString sN = "All stations/pull/Ndigi/pull_v_";
226 TString sT = "Pulls for Back strip coordinate, hits with ";
227 if (idig == 0) {
228 sN += Form("%d+_digi", fkMaxDigisInClusterForPulls + 1);
229 sT += Form(">=%d digi", fkMaxDigisInClusterForPulls + 1);
230 }
231 else {
232 sN += Form("%d_digi", idig);
233 sT += Form("%d digi", idig);
234 }
235 sT += "; (v_{reco} - v_{MC}) / #sigma_{v}^{reco}";
237 }
238 }
239
240 return kSUCCESS;
241}
ClassImp(CbmCaInputQaSts)
QA-task for CA tracking input from MuCh detector (header)
Definition of the CbmQaCanvas class.
Definition of CbmQaTable class.
Useful utilities for CBM QA tasks.
Data class for STS clusters.
Data class for a reconstructed hit in the STS.
friend fscal max(fscal x, fscal y)
friend fscal min(fscal x, fscal y)
void CreateSummary() override
Creates summary cavases, tables etc.
std::pair< std::string, bool > CheckRangePull(TH1 *h) const
void Check() override
Method to check, if the QA results are acceptable.
CbmCaInputQaBase(const char *name, int verbose, bool isMCUsed)
InitStatus InitQa() override
Initializes QA task.
const cbm::algo::RecoSetupUnit_t< ToCbmModuleId(DetID)> * fpDetInterface
void DeInit() override
De-initializes histograms.
A QA-task class, which provides assurance of MuCh hits and geometry.
void FillHistogramsPerHit() override
Fills histograms per hit.
CbmCaInputQaSts(int verbose, bool isMCUsed)
void FillHistogramsPerPoint() override
Fills histograms per MC point.
std::vector< TH1F * > fvph_pull_u_Ndig
pull for u coordinate, depending on N digis in the cluster
InitStatus InitQa() override
Initializes QA.
void DefineParameters() override
Defines parameters of the task.
const int fkMaxDigisInClusterForPulls
max digis in cluster for separate histogramming of puls
void CreateSummary() override
Creates summary cavases, tables etc.
std::vector< TH1F * > fvph_pull_v_Ndig
pull for v coordinate, depending on N digis in the cluster
void DeInit() override
De-initializes histograms.
void Check() override
Method to check, if the QA results are acceptable.
TClonesArray * fpClusters
Array of hit clusters.
T * MakeQaObject(TString sName, TString sTitle, Args... args)
Definition CbmQaIO.h:260
void StoreCheckResult(const std::string &tag, bool result, const std::string &msg="")
Data class for STS clusters.
data class for a reconstructed 3-d hit in the STS
Definition CbmStsHit.h:35
void SetLargeStats(TH1 *pHist)
Set large stat. window.