CbmRoot
Loading...
Searching...
No Matches
CbmLitFieldQaReport.cxx
Go to the documentation of this file.
1/* Copyright (C) 2011-2020 GSI/JINR-LIT, Darmstadt/Dubna
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Andrey Lebedev [committer] */
4
10#include "CbmLitFieldQaReport.h"
11
12#include "CbmDrawHist.h"
13#include "CbmHistManager.h"
14#include "CbmReportElement.h"
15#include "CbmRichDraw.h"
16#include "CbmUtils.h"
17#include "TCanvas.h"
18#include "TGraph.h"
19#include "TGraph2D.h"
20#include "TH2D.h"
21
22#include <boost/assign/list_of.hpp>
23
24using boost::assign::list_of;
26using Cbm::Split;
27using Cbm::ToString;
28using namespace std;
29
31
33
35{
36 Out() << R()->DocumentBegin() << std::endl;
37 Out() << R()->Title(0, "Magnetic field QA") << std::endl;
39 Out() << R()->DocumentEnd();
40}
41
43{
44 //gStyle->SetPalette(55, 0);
49}
50
52{
53 vector<TGraph2D*> graphsBx = HM()->G2Vector("hmf_Bx_Graph2D_.*");
54 for (UInt_t i = 0; i < graphsBx.size(); i++) {
55 string name = graphsBx[i]->GetName();
56 string canvasName = GetReportName() + "_map_at_z_" + Split(name, '_')[3];
57 TCanvas* canvas = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
58 canvas->Divide(2, 2);
59 TGraph2D* graphBy = HM()->G2(FindAndReplace(name, "_Bx_", "_By_"));
60 TGraph2D* graphBz = HM()->G2(FindAndReplace(name, "_Bx_", "_Bz_"));
61 TGraph2D* graphMod = HM()->G2(FindAndReplace(name, "_Bx_", "_Mod_"));
62 canvas->cd(1);
63 DrawGraph2D(graphsBx[i]);
64 canvas->cd(2);
65 DrawGraph2D(graphBy);
66 canvas->cd(3);
67 DrawGraph2D(graphBz);
68 canvas->cd(4);
69 DrawGraph2D(graphMod);
70 }
71}
72
74{
75 // Draw for different angles
76 vector<TGraph*> graphsBx = HM()->G1Vector("hmf_BxAlongZAngle_Graph_.*");
77 for (UInt_t i = 0; i < graphsBx.size(); i++) {
78 string name = graphsBx[i]->GetName();
79 string canvasName = GetReportName() + "_map_along_z_angle_" + Split(name, '_')[3];
80 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
81 TGraph* graphBy = HM()->G1(FindAndReplace(name, "_Bx", "_By"));
82 TGraph* graphBz = HM()->G1(FindAndReplace(name, "_Bx", "_Bz"));
83 TGraph* graphMod = HM()->G1(FindAndReplace(name, "_Bx", "_Mod"));
84 DrawGraph({graphsBx[i], graphBy, graphBz, graphMod}, {"B_{x}", "B_{y}", "B_{z}", "|B|"}, kLinear, kLinear, true,
85 0.7, 0.5, 0.9, 0.3);
86 gPad->SetGrid(true, true);
87 }
88
89 // Draw for different XY positions
90 graphsBx = HM()->G1Vector("hmf_BxAlongZXY_Graph_.*");
91 for (UInt_t i = 0; i < graphsBx.size(); i++) {
92 string name = graphsBx[i]->GetName();
93 vector<string> splits = Split(name, '_');
94 string canvasName = GetReportName() + "_map_along_z_xy_" + splits[3] + "_" + splits[4];
95 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
96 TGraph* graphBy = HM()->G1(FindAndReplace(name, "_Bx", "_By"));
97 TGraph* graphBz = HM()->G1(FindAndReplace(name, "_Bx", "_Bz"));
98 TGraph* graphMod = HM()->G1(FindAndReplace(name, "_Bx", "_Mod"));
99 DrawGraph({graphsBx[i], graphBy, graphBz, graphMod}, {"B_{x}", "B_{y}", "B_{z}", "|B|"}, kLinear, kLinear, true,
100 0.7, 0.5, 0.9, 0.3);
101 gPad->SetGrid(true, true);
102 }
103
104 // Draw integral for different XY positions
105 graphsBx = HM()->G1Vector("hmf_BxAlongZXYIntegral_Graph_.*");
106 for (UInt_t i = 0; i < graphsBx.size(); i++) {
107 string name = graphsBx[i]->GetName();
108 vector<string> splits = Split(name, '_');
109 string canvasName = GetReportName() + "_map_along_z_integral_xy_" + splits[3] + "_" + splits[4];
110 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
111 TGraph* graphBy = HM()->G1(FindAndReplace(name, "_Bx", "_By"));
112 TGraph* graphBz = HM()->G1(FindAndReplace(name, "_Bx", "_Bz"));
113 TGraph* graphMod = HM()->G1(FindAndReplace(name, "_Bx", "_Mod"));
114 DrawGraph({graphsBx[i], graphBy, graphBz, graphMod}, {"B_{x}", "B_{y}", "B_{z}", "|B|"}, kLinear, kLinear, true,
115 0.7, 0.5, 0.9, 0.3);
116 gPad->SetGrid(true, true);
117 }
118}
119
121{
122 string names[] = {"Bx", "By", "Bz", "Mod"};
123
124 for (Int_t iName = 0; iName < 4; iName++) {
125 TGraph2D* grU = HM()->G2("hmf_" + names[iName] + "_Rich_Pmt_up");
126 TGraph2D* grD = HM()->G2("hmf_" + names[iName] + "_Rich_Pmt_down");
127 if (grU->GetN() == 0 || grD->GetN() == 0) continue;
128 string canvasName = GetReportName() + "_rich_pmt_" + names[iName];
129 TCanvas* canvas = CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
130 CbmRichDraw::DrawPmtGraph2D(grU, grD, canvas);
131 }
132
133 string canvasName = GetReportName() + "_rich_pmt_projection_edge";
134 CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
135 TH2D* h2U = HM()->G2("hmf_Mod_Rich_Pmt_up")->GetHistogram();
136 TH2D* h2D = HM()->G2("hmf_Mod_Rich_Pmt_down")->GetHistogram();
137 Int_t nBins = h2D->GetNbinsY();
138 TH1D* hPrU = h2U->ProjectionX("_px", 1, 1);
139 TH1D* hPrD = h2D->ProjectionX("_px", nBins, nBins);
140 hPrU->GetYaxis()->SetTitle(h2U->GetZaxis()->GetTitle());
141 hPrD->GetYaxis()->SetTitle(h2D->GetZaxis()->GetTitle());
142
143 DrawH1({hPrU, hPrD}, {"Top plane", "Bottom plane"}, kLinear, kLinear, true, 0.7, 0.8, 0.99, 0.99, "hist");
144}
145
ClassImp(CbmConverterManager)
void SetDefaultDrawStyle()
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 DrawGraph2D(TGraph2D *graph, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
void DrawGraph(TGraph *graph, HistScale logx, HistScale logy, const string &drawOpt, Int_t color, Int_t lineWidth, Int_t lineStyle, Int_t markerSize, Int_t markerStyle)
Helper functions for drawing 1D and 2D histograms and graphs.
@ kLinear
Definition CbmDrawHist.h:69
Histogram manager.
Creates field QA report.
Abstract class for basic report elements (headers, tables, images etc.).
TGraph2D * G2(const std::string &name) const
Return pointer to TGraph2D.
std::vector< TGraph2D * > G2Vector(const std::vector< std::string > &names) const
Return vector of pointers to TGraph2D.
TGraph * G1(const std::string &name) const
Return pointer to TGraph.
std::vector< TGraph * > G1Vector(const std::vector< std::string > &names) const
Return vector of pointers to TGraph.
Creates field QA report.
CbmLitFieldQaReport()
Constructor.
virtual void Create()
Inherited from CbmSimulationReport.
void DrawFieldRichPmtPlane()
Draw field map components for RICH PMT plane.
void DrawFieldSlices()
Draw field map components for each slice.
virtual void Draw()
Inherited from CbmSimulationReport.
void DrawFieldAlongZ()
Draw field map components along Z coordinate.
virtual ~CbmLitFieldQaReport()
Destructor.
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
static void DrawPmtGraph2D(TGraph2D *gUp, TGraph2D *gDown, TCanvas *c)
Definition CbmRichDraw.h:57
CbmHistManager * HM() const
Return pointer to Histogram manager.
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 ToString(const T &value)
Definition CbmUtils.h:26
Hash for CbmL1LinkKey.