CbmRoot
CbmLitFieldQaReport.cxx
Go to the documentation of this file.
1 
6 #include "CbmLitFieldQaReport.h"
7 #include "CbmDrawHist.h"
8 #include "CbmHistManager.h"
9 #include "CbmReportElement.h"
10 #include "CbmRichDraw.h"
11 #include "CbmUtils.h"
12 #include "TCanvas.h"
13 #include "TGraph.h"
14 #include "TGraph2D.h"
15 #include "TH2D.h"
16 #include <boost/assign/list_of.hpp>
17 
18 using boost::assign::list_of;
20 using Cbm::Split;
21 using Cbm::ToString;
22 using namespace std;
23 
24 CbmLitFieldQaReport::CbmLitFieldQaReport() { SetReportName("field_qa"); }
25 
27 
29  Out() << R()->DocumentBegin() << std::endl;
30  Out() << R()->Title(0, "Magnetic field QA") << std::endl;
31  PrintCanvases();
32  Out() << R()->DocumentEnd();
33 }
34 
36  //gStyle->SetPalette(55, 0);
38  DrawFieldSlices();
39  DrawFieldAlongZ();
40  DrawFieldRichPmtPlane();
41 }
42 
44  vector<TGraph2D*> graphsBx = HM()->G2Vector("hmf_Bx_Graph2D_.*");
45  for (Int_t i = 0; i < graphsBx.size(); i++) {
46  string name = graphsBx[i]->GetName();
47  string canvasName = GetReportName() + "_map_at_z_" + Split(name, '_')[3];
48  TCanvas* canvas =
49  CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
50  canvas->Divide(2, 2);
51  TGraph2D* graphBy = HM()->G2(FindAndReplace(name, "_Bx_", "_By_"));
52  TGraph2D* graphBz = HM()->G2(FindAndReplace(name, "_Bx_", "_Bz_"));
53  TGraph2D* graphMod = HM()->G2(FindAndReplace(name, "_Bx_", "_Mod_"));
54  canvas->cd(1);
55  DrawGraph2D(graphsBx[i]);
56  canvas->cd(2);
57  DrawGraph2D(graphBy);
58  canvas->cd(3);
59  DrawGraph2D(graphBz);
60  canvas->cd(4);
61  DrawGraph2D(graphMod);
62  }
63 }
64 
66  // Draw for different angles
67  vector<TGraph*> graphsBx = HM()->G1Vector("hmf_BxAlongZAngle_Graph_.*");
68  for (Int_t i = 0; i < graphsBx.size(); i++) {
69  string name = graphsBx[i]->GetName();
70  string canvasName =
71  GetReportName() + "_map_along_z_angle_" + Split(name, '_')[3];
72  TCanvas* canvas =
73  CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
74  TGraph* graphBy = HM()->G1(FindAndReplace(name, "_Bx", "_By"));
75  TGraph* graphBz = HM()->G1(FindAndReplace(name, "_Bx", "_Bz"));
76  TGraph* graphMod = HM()->G1(FindAndReplace(name, "_Bx", "_Mod"));
77  DrawGraph({graphsBx[i], graphBy, graphBz, graphMod},
78  {"B_{x}", "B_{y}", "B_{z}", "|B|"},
79  kLinear,
80  kLinear,
81  true,
82  0.7,
83  0.5,
84  0.9,
85  0.3);
86  gPad->SetGrid(true, true);
87  }
88 
89  // Draw for different XY positions
90  graphsBx = HM()->G1Vector("hmf_BxAlongZXY_Graph_.*");
91  for (Int_t i = 0; i < graphsBx.size(); i++) {
92  string name = graphsBx[i]->GetName();
93  vector<string> splits = Split(name, '_');
94  string canvasName =
95  GetReportName() + "_map_along_z_xy_" + splits[3] + "_" + splits[4];
96  TCanvas* canvas =
97  CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
98  TGraph* graphBy = HM()->G1(FindAndReplace(name, "_Bx", "_By"));
99  TGraph* graphBz = HM()->G1(FindAndReplace(name, "_Bx", "_Bz"));
100  TGraph* graphMod = HM()->G1(FindAndReplace(name, "_Bx", "_Mod"));
101  DrawGraph({graphsBx[i], graphBy, graphBz, graphMod},
102  {"B_{x}", "B_{y}", "B_{z}", "|B|"},
103  kLinear,
104  kLinear,
105  true,
106  0.7,
107  0.5,
108  0.9,
109  0.3);
110  gPad->SetGrid(true, true);
111  }
112 
113  // Draw integral for different XY positions
114  graphsBx = HM()->G1Vector("hmf_BxAlongZXYIntegral_Graph_.*");
115  for (Int_t i = 0; i < graphsBx.size(); i++) {
116  string name = graphsBx[i]->GetName();
117  vector<string> splits = Split(name, '_');
118  string canvasName = GetReportName() + "_map_along_z_integral_xy_"
119  + splits[3] + "_" + splits[4];
120  TCanvas* canvas =
121  CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
122  TGraph* graphBy = HM()->G1(FindAndReplace(name, "_Bx", "_By"));
123  TGraph* graphBz = HM()->G1(FindAndReplace(name, "_Bx", "_Bz"));
124  TGraph* graphMod = HM()->G1(FindAndReplace(name, "_Bx", "_Mod"));
125  DrawGraph({graphsBx[i], graphBy, graphBz, graphMod},
126  {"B_{x}", "B_{y}", "B_{z}", "|B|"},
127  kLinear,
128  kLinear,
129  true,
130  0.7,
131  0.5,
132  0.9,
133  0.3);
134  gPad->SetGrid(true, true);
135  }
136 }
137 
139  string names[] = {"Bx", "By", "Bz", "Mod"};
140 
141  for (Int_t iName = 0; iName < 4; iName++) {
142  TGraph2D* grU = HM()->G2("hmf_" + names[iName] + "_Rich_Pmt_up");
143  TGraph2D* grD = HM()->G2("hmf_" + names[iName] + "_Rich_Pmt_down");
144  if (grU->GetN() == 0 || grD->GetN() == 0) continue;
145  string canvasName = GetReportName() + "_rich_pmt_" + names[iName];
146  TCanvas* canvas =
147  CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
148  CbmRichDraw::DrawPmtGraph2D(grU, grD, canvas);
149  }
150 
151  string canvasName = GetReportName() + "_rich_pmt_projection_edge";
152  TCanvas* canvas =
153  CreateCanvas(canvasName.c_str(), canvasName.c_str(), 1000, 1000);
154  TH2D* h2U = HM()->G2("hmf_Mod_Rich_Pmt_up")->GetHistogram();
155  TH2D* h2D = HM()->G2("hmf_Mod_Rich_Pmt_down")->GetHistogram();
156  Int_t nBins = h2D->GetNbinsY();
157  TH1D* hPrU = h2U->ProjectionX("_px", 1, 1);
158  TH1D* hPrD = h2D->ProjectionX("_px", nBins, nBins);
159  hPrU->GetYaxis()->SetTitle(h2U->GetZaxis()->GetTitle());
160  hPrD->GetYaxis()->SetTitle(h2D->GetZaxis()->GetTitle());
161 
162  DrawH1({hPrU, hPrD},
163  {"Top plane", "Bottom plane"},
164  kLinear,
165  kLinear,
166  true,
167  0.7,
168  0.8,
169  0.99,
170  0.99,
171  "hist");
172 }
173 
CbmLitFieldQaReport::DrawFieldRichPmtPlane
void DrawFieldRichPmtPlane()
Draw field map components for RICH PMT plane.
Definition: CbmLitFieldQaReport.cxx:138
CbmLitFieldQaReport::Create
virtual void Create()
Inherited from CbmSimulationReport.
Definition: CbmLitFieldQaReport.cxx:28
CbmRichDraw::DrawPmtGraph2D
static void DrawPmtGraph2D(TGraph2D *gUp, TGraph2D *gDown, TCanvas *c)
Definition: CbmRichDraw.h:52
Cbm::FindAndReplace
string FindAndReplace(const string &name, const string &oldSubstr, const string &newSubstr)
Definition: CbmUtils.cxx:45
CbmLitFieldQaReport::CbmLitFieldQaReport
CbmLitFieldQaReport()
Constructor.
Definition: CbmLitFieldQaReport.cxx:24
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
DrawGraph2D
void DrawGraph2D(TGraph2D *graph, HistScale logx, HistScale logy, HistScale logz, const string &drawOpt)
Definition: CbmDrawHist.cxx:224
CbmDrawHist.h
Helper functions for drawing 1D and 2D histograms and graphs.
CbmRichDraw.h
CbmReportElement.h
Abstract class for basic report elements (headers, tables, images etc.).
CbmHistManager.h
Histogram manager.
DrawGraph
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)
Definition: CbmDrawHist.cxx:151
DrawH1
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)
Definition: CbmDrawHist.cxx:49
CbmLitFieldQaReport::Draw
virtual void Draw()
Inherited from CbmSimulationReport.
Definition: CbmLitFieldQaReport.cxx:35
kLinear
@ kLinear
Definition: CbmDrawHist.h:79
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmUtils.h
CbmLitFieldQaReport.h
Creates field QA report.
CbmLitFieldQaReport::~CbmLitFieldQaReport
virtual ~CbmLitFieldQaReport()
Destructor.
Definition: CbmLitFieldQaReport.cxx:26
SetDefaultDrawStyle
void SetDefaultDrawStyle()
Definition: CbmDrawHist.cxx:33
CbmLitFieldQaReport::DrawFieldAlongZ
void DrawFieldAlongZ()
Draw field map components along Z coordinate.
Definition: CbmLitFieldQaReport.cxx:65
CbmLitFieldQaReport
Creates field QA report.
Definition: CbmLitFieldQaReport.h:20
Cbm::ToString
std::string ToString(const T &value)
Definition: CbmUtils.h:16
Cbm::Split
vector< string > Split(const string &name, char delimiter)
Definition: CbmUtils.cxx:54
CbmLitFieldQaReport::DrawFieldSlices
void DrawFieldSlices()
Draw field map components for each slice.
Definition: CbmLitFieldQaReport.cxx:43