CbmRoot
Loading...
Searching...
No Matches
CbmStsDigitizeQaReport.cxx
Go to the documentation of this file.
1/* Copyright (C) 2016-2020 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Hanna Malygina [committer], Volker Friese */
4
6
7#include "CbmDrawHist.h"
8#include "CbmHistManager.h"
9#include "CbmReportElement.h"
10#include "CbmStsModule.h"
11#include "CbmStsParAsic.h"
12#include "CbmStsParSim.h"
13#include "CbmStsSetup.h"
14#include "CbmUtils.h"
15
16#include "TCanvas.h"
17#include "TF1.h"
18#include "TH1.h"
19#include "TProfile.h"
20#include "TStyle.h"
21
22#include <boost/assign/list_of.hpp>
23
24using boost::assign::list_of;
27using Cbm::Split;
28using std::endl;
29using std::string;
30using std::stringstream;
31using std::vector;
32
34 const CbmStsParAsic* asicPar)
36 , fSetup(setup)
37 , fSettings(settings)
38 , fAsicPar(asicPar)
39{
40 SetReportName("STSdigitize_qa");
41}
42
44
46{
47 CbmStsELoss eLossModel = fSettings->ELossModel();
48 Bool_t lorentz = fSettings->LorentzShift();
49 Bool_t diffusion = fSettings->Diffusion();
50 Bool_t crossTalk = fSettings->CrossTalk();
51 Double_t dynRange = fAsicPar->GetDynRange();
52 Double_t threshold = fAsicPar->GetThreshold();
53 Int_t nAdc = fAsicPar->GetNofAdc();
54 Double_t timeResolution = fAsicPar->GetTimeResol();
55 Double_t deadTime = fAsicPar->GetDeadTime();
56 Double_t noise = fAsicPar->GetNoise();
57 size_t buf_size = 15;
58 char eLossModelChar[buf_size];
59 if (eLossModel == CbmStsELoss::kIdeal) snprintf(eLossModelChar, buf_size - 1, "ideal");
60 if (eLossModel == CbmStsELoss::kUniform) snprintf(eLossModelChar, buf_size - 1, "uniform");
61 if (eLossModel == CbmStsELoss::kUrban) snprintf(eLossModelChar, buf_size - 1, "non-uniform");
62 Out().precision(1);
63 Out() << R()->DocumentBegin();
64 Out() << R()->Title(0, GetTitle());
65 Out() << "Number of events: " << HM()->H1("h_EventNo_DigitizeQa")->GetEntries() << endl;
66 Out() << endl;
67 Out() << "Digitizer parameters: " << endl;
68 Out() << "\t noise \t\t\t" << noise << " e" << endl;
69 Out() << "\t threshold \t\t" << threshold << " e" << endl;
70 Out() << "\t dynamic range \t\t" << dynRange << " e" << endl;
71 Out() << "\t number of ADC \t\t" << nAdc << endl;
72 Out() << "\t time resolution \t" << timeResolution << " ns" << endl;
73 Out() << "\t dead time \t\t" << deadTime << " ns" << endl;
74 Out() << endl;
75 Out() << "Detector response model takes into account: " << endl;
76 Out() << "\t energy loss model: \t" << eLossModelChar << endl;
77 Out() << "\t diffusion: \t\t" << (diffusion ? "On" : "Off") << endl;
78 Out() << "\t Lorentz shift: \t" << (lorentz ? "On" : "Off") << endl;
79 Out() << "\t cross talk: \t\t" << (crossTalk ? "On" : "Off") << endl;
80
82
83 Out() << R()->DocumentEnd();
84}
85
87{
92 DrawH1ByPattern("h_DigiCharge");
93 /*DrawH1ByPattern("h_DigisByPoint");
94 DrawH1ByPattern("h_PointsInDigi");*/
96}
97
99{
100 string name = "h_NofObjects_";
101 if (!HM()->Exists(name + "Points") && !HM()->Exists(name + "Digis") && !HM()->Exists(name + "Digis_Station")
102 && !HM()->Exists(name + "Points_Station"))
103 return;
104 string canvasName = GetReportName() + name;
105 TCanvas* canvas = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 500);
106 canvas->SetGrid();
107 canvas->SetLogy();
108 canvas->cd();
109 vector<string> labels = list_of("Points")("Digis");
110 vector<TH1*> histos = list_of(HM()->H1(name + "Points"))(HM()->H1(name + "Digis"));
111 DrawH1(histos, labels, kLinear, kLinear, true, 0.5, 0.55, 0.9, 0.75);
112
113 vector<TH1*> histos1 = list_of(HM()->H1(name + "Points_Station"))(HM()->H1(name + "Digis_Station"));
114 canvasName = GetReportName() + "h_NofObjects_Station";
115 TCanvas* canvas1 = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 500);
116 canvas1->SetGrid();
117 canvas1->cd();
118 DrawH1(histos1, labels, kLinear, kLinear, true, 0.5, 0.55, 0.9, 0.75);
119}
120
122{
123 string name = "h_DigisPerChip_Station";
124 for (Int_t stationId = 0; stationId < fSetup->GetNofStations(); stationId++) {
125 if (!HM()->Exists(Form("h_DigisPerChip_Station%i", stationId))
126 && !HM()->Exists(Form("h_PointsMap_Station%i", stationId))
127 && !HM()->Exists(Form("h_MeanAngleMap_Station%i", stationId))
128 && !HM()->Exists(Form("h_RMSAngleMap_Station%i", stationId)))
129 return;
130 }
131 string canvasName = GetReportName() + name;
132 TCanvas* canvas = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 2400, 600);
133 canvas->Divide(4, 2);
134 canvas->SetGrid();
135
136 string name1 = "h_PointsMap_Station";
137 string canvasName1 = GetReportName() + name1;
138 TCanvas* canvas1 = CreateCanvas(canvasName1.c_str(), canvasName1.c_str(), 2400, 600);
139 canvas1->Divide(4, 2);
140 canvas1->SetGrid();
141
142 string name2 = "h_MeanAngleMap_Station";
143 string canvasName2 = GetReportName() + name2;
144 TCanvas* canvas2 = CreateCanvas(canvasName2.c_str(), canvasName2.c_str(), 2400, 600);
145 canvas2->Divide(4, 2);
146 canvas2->SetGrid();
147
148 string name3 = "h_RMSAngleMap_Station";
149 string canvasName3 = GetReportName() + name3;
150 TCanvas* canvas3 = CreateCanvas(canvasName3.c_str(), canvasName3.c_str(), 2400, 600);
151 canvas3->Divide(4, 2);
152 canvas3->SetGrid();
153
154 for (Int_t stationId = 0; stationId < fSetup->GetNofStations(); stationId++) {
155 canvas->cd(stationId + 1);
156 DrawH2(HM()->H2(Form("%s%i", name.c_str(), stationId)), kLinear, kLinear, kLinear);
157
158 canvas1->cd(stationId + 1);
159 DrawH2(HM()->H2(Form("%s%i", name1.c_str(), stationId)), kLinear, kLinear, kLinear);
160
161 canvas2->cd(stationId + 1);
162 DrawH2(HM()->H2(Form("%s%i", name2.c_str(), stationId)), kLinear, kLinear, kLinear);
163
164 canvas3->cd(stationId + 1);
165 DrawH2(HM()->H2(Form("%s%i", name3.c_str(), stationId)), kLinear, kLinear, kLinear);
166 }
167}
168
169
171{
172 string name = "h_";
173 if (!HM()->Exists(name + "PointsInDigiLog") && !HM()->Exists(name + "DigisByPointLog")) return;
174 string canvasName = GetReportName() + name + "PointsInDigiLog";
175 TCanvas* canvas = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 500);
176 canvas->SetGrid();
177 canvas->SetLogy();
178 canvas->cd();
179 vector<TH1*> histos = list_of(HM()->H1(name + "PointsInDigiLog"));
180 vector<string> labels =
181 list_of(Form("Points in digi, \n mean = %.2f", HM()->H1(name + "PointsInDigiLog")->GetMean()));
182 DrawH1(histos, labels, kLinear, kLinear, true, 0.5, 0.55, 0.9, 0.65);
183
184 canvasName = GetReportName() + name + "DigisByPointLog";
185 vector<TH1*> histos1 = list_of(HM()->H1(name + "DigisByPointLog"));
186 vector<string> labels1 =
187 list_of(Form("Digis by point, \n mean = %.2f", HM()->H1(name + "DigisByPointLog")->GetMean()));
188 TCanvas* canvas1 = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 500);
189 canvas1->SetGrid();
190 canvas1->SetLogy();
191 canvas1->cd();
192 DrawH1(histos1, labels1, kLinear, kLinear, true, 0.5, 0.55, 0.9, 0.65);
193}
194
196{
197 string name = "h_";
198 if (!HM()->Exists(name + "PointsInDigi") && !HM()->Exists(name + "DigisByPoint")) return;
199 string canvasName = GetReportName() + name + "PointsInDigi";
200 TCanvas* canvas = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 500);
201 canvas->SetGrid();
202 canvas->cd();
203 vector<TH1*> histos = list_of(HM()->H1(name + "PointsInDigi"));
204 vector<string> labels = list_of(Form("Points in digi, \n mean = %.2f", HM()->H1(name + "PointsInDigi")->GetMean()));
205 DrawH1(histos, labels, kLinear, kLinear, true, 0.5, 0.55, 0.9, 0.65);
206
207 canvasName = GetReportName() + name + "DigisByPoint";
208 vector<TH1*> histos1 = list_of(HM()->H1(name + "DigisByPoint"));
209 vector<string> labels1 = list_of(Form("Digis by point, \n mean = %.2f", HM()->H1(name + "DigisByPoint")->GetMean()));
210 TCanvas* canvas1 = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 800, 500);
211 canvas1->SetGrid();
212 canvas1->cd();
213 DrawH1(histos1, labels1, kLinear, kLinear, true, 0.5, 0.55, 0.9, 0.65);
214}
215
216
218{
219 Int_t nofEvents = HM()->H1("h_EventNo_DigitizeQa")->GetEntries();
220 if (nofEvents == 0) nofEvents = 1;
221
222 HM()->ScaleByPattern("h_NofObjects_.*_Station_.*", 1. / nofEvents);
223 HM()->ShrinkEmptyBinsH1ByPattern("h_NofObjects_.*_Station_.*");
224}
225
ClassImp(CbmConverterManager)
void DrawH1(TH1 *hist, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
void DrawH2(TH2 *hist, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Helper functions for drawing 1D and 2D histograms and graphs.
@ kLinear
Definition CbmDrawHist.h:69
Histogram manager.
Abstract class for basic report elements (headers, tables, images etc.).
CbmStsELoss
Energy loss model used in simulation.
Definition CbmStsDefs.h:49
void ShrinkEmptyBinsH1ByPattern(const std::string &pattern)
Shrink empty bins in H1.
void ScaleByPattern(const std::string &pattern, Double_t scale)
Scale histograms which name matches specified pattern.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
virtual std::string Title(int size, const std::string &title) const =0
Return string with title.
virtual std::string DocumentBegin() const =0
Return string with open tags for document.
virtual std::string DocumentEnd() const =0
Return string with close tags of the document.
std::ostream & Out() const
All text output goes to this stream.
Definition CbmReport.h:66
void SetReportName(const std::string &name)
Definition CbmReport.h:69
void PrintCanvases() const
Print images created from canvases in the report.
const std::string & GetReportName() const
Definition CbmReport.h:74
const CbmReportElement * R() const
Accessor to CbmReportElement object. User has to write the report using available tags from CbmReport...
Definition CbmReport.h:61
TCanvas * CreateCanvas(const char *name, const char *title, Int_t ww, Int_t wh)
Create canvas and put it to vector of TCanvases. Canvases created with this function will be automati...
Definition CbmReport.cxx:94
Base class for simulation reports.
TH2 * H2(const std::string &name) const
Return pointer to TH2 histogram.
void DrawH1ByPattern(const std::string &histNamePattern)
Select by pattern TH1 histograms and draw each histogram on separate canvas.
TH1 * H1(const std::string &name) const
Return pointer to TH1 histogram.
CbmHistManager * HM() const
Return pointer to Histogram manager.
virtual void Draw()
Pure abstract function which is called from public Create() function. This function has to draw all n...
const CbmStsParSim * fSettings
const CbmStsParAsic * fAsicPar
CbmStsDigitizeQaReport(CbmStsSetup *setup, const CbmStsParSim *settings, const CbmStsParAsic *asicPar)
virtual void Create()
Inherited from CbmReport. Pure abstract function which is called from public Create() function.
Parameters of the STS readout ASIC.
double GetDynRange() const
Dynamic range of ADC.
uint16_t GetNofAdc() const
Number of ADC channels.
double GetNoise() const
Electronic noise RMS.
double GetThreshold() const
ADC Threshold.
double GetTimeResol() const
Time resolution.
double GetDeadTime() const
Single-channel dead time.
Settings for STS simulation (digitizer)
Bool_t LorentzShift() const
Check whether Lorentz shift is applied.
CbmStsELoss ELossModel() const
Energy loss model.
Bool_t CrossTalk() const
Check whether cross-talk is applied.
Bool_t Diffusion() const
Check whether diffusion is applied.
Class representing the top level of the STS setup.
Definition CbmStsSetup.h:43
Int_t GetNofStations() const
Definition CbmStsSetup.h:94
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
Definition CbmUtils.cxx:59
vector< string > Split(const string &name, char delimiter)
Definition CbmUtils.cxx:67
std::string NumberToString(const T &value, int precision=1)
Definition CbmUtils.h:34