BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
plot_align_corrections_bmn.C
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// This macro plots evolution of the new and cumulative alignment corrections
3// vs. iteration number.
4//
5//
6// Anatoly.Solomin@jinr.ru 2017-02-16
7
8#include <map>
9
10void CreateItCorrs(Double_t***** itCorrs, Int_t nKinds, Int_t nParams, Int_t nIts, BmnGemStripStationSet* stationSet);
11void CreateItCorrErrs(Double_t**** itNewCorrErrs, Int_t nParams, Int_t nIts, BmnGemStripStationSet* stationSet);
12void FillItCorrsItErrs(TString newAlignCorrFileListFileName,
13 Double_t***** itCorrs,
14 Double_t**** itNewCorrErrs,
15 Int_t iKind,
16 int const mlpdParNr_What[][3]);
17
18void plot_align_corrections_bmn(TString new1AlignCorrFileListFileName, TString new2AlignCorrFileListFileName = "")
19{
20 TString sum1AlignCorrFileListFileName = new1AlignCorrFileListFileName;
21 sum1AlignCorrFileListFileName = sum1AlignCorrFileListFileName.ReplaceAll("new", "sum");
22 TString sum2AlignCorrFileListFileName;
23 if (new2AlignCorrFileListFileName != "") {
24 sum2AlignCorrFileListFileName = new2AlignCorrFileListFileName;
25 sum2AlignCorrFileListFileName = sum2AlignCorrFileListFileName.ReplaceAll("new", "sum");
26 }
27 TString alignCorrPlotsFileName = new1AlignCorrFileListFileName;
28 alignCorrPlotsFileName = alignCorrPlotsFileName.ReplaceAll("filelist_", "");
29 alignCorrPlotsFileName = alignCorrPlotsFileName.ReplaceAll("new_align", "corr_plots");
30 alignCorrPlotsFileName = alignCorrPlotsFileName.ReplaceAll("txt", "root");
31 if (new2AlignCorrFileListFileName != "") {
32 alignCorrPlotsFileName = alignCorrPlotsFileName.ReplaceAll("fromdefault", "fromscratch_vs_fromdefault");
33 }
34
35 // get run period
36 TString substr = new1AlignCorrFileListFileName("bmn_run[0-9]+");
37 substr = substr("[0-9]+");
38 int runPeriod = substr.Atoi();
39
40 TString new1StartAlignFrom = new1AlignCorrFileListFileName("from[a-z]+");
41 new1StartAlignFrom = "from " + new1StartAlignFrom.ReplaceAll("from", "");
42 TString new2StartAlignFrom;
43 if (new2AlignCorrFileListFileName != "") {
44 new2StartAlignFrom = new2AlignCorrFileListFileName("from[a-z]+");
45 new2StartAlignFrom = "from " + new2StartAlignFrom.ReplaceAll("from", "");
46 }
47
48 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
49 bmnloadlibs(); // load BmnRoot libraries
50
51 map<const pair<int, int>, int> mStatMod_Pad;
52
53 int mlpdParNr_What5[30][3] = {
54 {0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {0, 1, 0}, {1, 1, 0}, {2, 1, 0}, {0, 2, 0}, {1, 2, 0}, {2, 2, 0}, {0, 3, 0},
55 {1, 3, 0}, {2, 3, 0}, {0, 4, 0}, {1, 4, 0}, {2, 4, 0}, {0, 4, 1}, {1, 4, 1}, {2, 4, 1}, {0, 5, 0}, {1, 5, 0},
56 {2, 5, 0}, {0, 5, 1}, {1, 5, 1}, {2, 5, 1}, {0, 6, 0}, {1, 6, 0}, {2, 6, 0}, {0, 6, 1}, {1, 6, 1}, {2, 6, 1}};
57 int mlpdParNr_What6[27][3] = {{0, 0, 0}, {1, 0, 0}, {2, 0, 0}, {0, 1, 0}, {1, 1, 0}, {2, 1, 0}, {0, 2, 0},
58 {1, 2, 0}, {2, 2, 0}, {0, 3, 0}, {1, 3, 0}, {2, 3, 0}, {0, 3, 1}, {1, 3, 1},
59 {2, 3, 1}, {0, 4, 0}, {1, 4, 0}, {2, 4, 0}, {0, 4, 1}, {1, 4, 1}, {2, 4, 1},
60 {0, 5, 0}, {1, 5, 0}, {2, 5, 0}, {0, 5, 1}, {1, 5, 1}, {2, 5, 1}};
61 BmnGemStripStationSet* stationSet;
62 Int_t iStatFirst; // first GEM station to start with
63 Int_t nStations; // number of GEM stations
64 if (runPeriod == 5) {
66 iStatFirst = 1;
67 nStations = 7;
68 mStatMod_Pad[make_pair(1, 0)] = 1;
69 mStatMod_Pad[make_pair(2, 0)] = 2;
70 mStatMod_Pad[make_pair(3, 0)] = 3;
71 mStatMod_Pad[make_pair(4, 0)] = 4;
72 mStatMod_Pad[make_pair(4, 1)] = 10;
73 mStatMod_Pad[make_pair(5, 0)] = 5;
74 mStatMod_Pad[make_pair(5, 1)] = 11;
75 mStatMod_Pad[make_pair(6, 0)] = 6;
76 mStatMod_Pad[make_pair(6, 1)] = 12;
77 } else if (runPeriod == 6) {
79 iStatFirst = 0;
80 nStations = 6;
81 mStatMod_Pad[make_pair(0, 0)] = 1;
82 mStatMod_Pad[make_pair(1, 0)] = 2;
83 mStatMod_Pad[make_pair(2, 0)] = 3;
84 mStatMod_Pad[make_pair(3, 0)] = 4;
85 mStatMod_Pad[make_pair(3, 1)] = 10;
86 mStatMod_Pad[make_pair(4, 0)] = 5;
87 mStatMod_Pad[make_pair(4, 1)] = 11;
88 mStatMod_Pad[make_pair(5, 0)] = 6;
89 mStatMod_Pad[make_pair(5, 1)] = 12;
90 }
91 ifstream ifstrm(new1AlignCorrFileListFileName);
92 string line;
93 int n = 0; // number of iterations counter
94 while (getline(ifstrm, line)) { // this is in fact a loop over the iterations
95 n++;
96 // cout <<line<< endl;
97 }
98 ifstrm.close();
99 const Int_t nIts = n;
100 Double_t its[nIts]; // array with the iteration numbers
101 for (int i = 0; i < nIts; i++)
102 its[i] = (Double_t)i + 1.; // fill array of the iteration numbers (stating with 1)
103 // cout <<"nIts = "<<nIts<< endl; // number of iterations
104
105 const Int_t nKinds = 2;
106 const Int_t nParams = 3;
107 // Double_t***** itCorrs1 = new Double_t****[nKinds];
108 // Double_t**** itNewCorrErrs1 = new Double_t***[nParams];
109 // Double_t***** itCorrs2 = new Double_t****[nKinds];
110 // Double_t**** itNewCorrErrs2 = new Double_t***[nParams];
111 Double_t***** itCorrs1;
112 Double_t**** itNewCorrErrs1;
113 Double_t***** itCorrs2;
114 Double_t**** itNewCorrErrs2;
115 // CreateItCorrs( itCorrs1, nKinds, nParams, nIts, stationSet);
116 itCorrs1 = new Double_t****[nKinds];
117 for (Int_t iKind = 0; iKind < nKinds; iKind++) {
118 itCorrs1[iKind] = new Double_t***[nParams];
119 for (Int_t iPar = 0; iPar < nParams; iPar++) {
120 Int_t nStats = stationSet->GetNStations();
121 itCorrs1[iKind][iPar] = new Double_t**[nStats];
122 for (Int_t iStat = 0; iStat < nStats; iStat++) {
123 Int_t nModuls = stationSet->GetGemStation(iStat)->GetNModules();
124 itCorrs1[iKind][iPar][iStat] = new Double_t*[nModuls];
125 for (Int_t iMod = 0; iMod < nModuls; iMod++) {
126 itCorrs1[iKind][iPar][iStat][iMod] = new Double_t[nIts];
127 for (Int_t iIt = 0; iIt < nIts; iIt++) {
128 itCorrs1[iKind][iPar][iStat][iMod][iIt] = 0.;
129 }
130 }
131 }
132 }
133 }
134 // CreateItCorrErrs( itNewCorrErrs1, nParams, nIts, stationSet);
135 itNewCorrErrs1 = new Double_t***[nParams];
136 for (Int_t iPar = 0; iPar < nParams; iPar++) {
137 Int_t nStats = stationSet->GetNStations();
138 itNewCorrErrs1[iPar] = new Double_t**[nStats];
139 for (Int_t iStat = 0; iStat < nStats; iStat++) {
140 Int_t nModuls = stationSet->GetGemStation(iStat)->GetNModules();
141 itNewCorrErrs1[iPar][iStat] = new Double_t*[nModuls];
142 for (Int_t iMod = 0; iMod < nModuls; iMod++) {
143 itNewCorrErrs1[iPar][iStat][iMod] = new Double_t[nIts];
144 for (Int_t iIt = 0; iIt < nIts; iIt++) {
145 itNewCorrErrs1[iPar][iStat][iMod][iIt] = 0.;
146 }
147 }
148 }
149 }
150 if (new2AlignCorrFileListFileName != "") {
151 // CreateItCorrs( itCorrs2, nKinds, nParams, nIts, stationSet);
152 itCorrs2 = new Double_t****[nKinds];
153 for (Int_t iKind = 0; iKind < nKinds; iKind++) {
154 itCorrs2[iKind] = new Double_t***[nParams];
155 for (Int_t iPar = 0; iPar < nParams; iPar++) {
156 Int_t nStats = stationSet->GetNStations();
157 itCorrs2[iKind][iPar] = new Double_t**[nStats];
158 for (Int_t iStat = 0; iStat < nStats; iStat++) {
159 Int_t nModuls = stationSet->GetGemStation(iStat)->GetNModules();
160 itCorrs2[iKind][iPar][iStat] = new Double_t*[nModuls];
161 for (Int_t iMod = 0; iMod < nModuls; iMod++) {
162 itCorrs2[iKind][iPar][iStat][iMod] = new Double_t[nIts];
163 for (Int_t iIt = 0; iIt < nIts; iIt++) {
164 itCorrs2[iKind][iPar][iStat][iMod][iIt] = 0.;
165 }
166 }
167 }
168 }
169 }
170 // CreateItCorrErrs(itNewCorrErrs2, nParams, nIts, stationSet);
171 itNewCorrErrs2 = new Double_t***[nParams];
172 for (Int_t iPar = 0; iPar < nParams; iPar++) {
173 Int_t nStats = stationSet->GetNStations();
174 itNewCorrErrs2[iPar] = new Double_t**[nStats];
175 for (Int_t iStat = 0; iStat < nStats; iStat++) {
176 Int_t nModuls = stationSet->GetGemStation(iStat)->GetNModules();
177 itNewCorrErrs2[iPar][iStat] = new Double_t*[nModuls];
178 for (Int_t iMod = 0; iMod < nModuls; iMod++) {
179 itNewCorrErrs2[iPar][iStat][iMod] = new Double_t[nIts];
180 for (Int_t iIt = 0; iIt < nIts; iIt++) {
181 itNewCorrErrs2[iPar][iStat][iMod][iIt] = 0.;
182 }
183 }
184 }
185 }
186 }
187
188 TString kinds[2] = {"new", "sum"};
189 if (runPeriod == 5) {
190 for (Int_t iKind = 0; iKind < nKinds; iKind++) {
191 FillItCorrsItErrs(new1AlignCorrFileListFileName, itCorrs1, itNewCorrErrs1, iKind, mlpdParNr_What5);
192 if (new2AlignCorrFileListFileName != "") {
193 FillItCorrsItErrs(new2AlignCorrFileListFileName, itCorrs2, itNewCorrErrs2, iKind, mlpdParNr_What5);
194 }
195 }
196 } else if (runPeriod == 6) {
197 for (Int_t iKind = 0; iKind < nKinds; iKind++) {
198 FillItCorrsItErrs(new1AlignCorrFileListFileName, itCorrs1, itNewCorrErrs1, iKind, mlpdParNr_What6);
199 if (new2AlignCorrFileListFileName != "") {
200 FillItCorrsItErrs(new2AlignCorrFileListFileName, itCorrs2, itNewCorrErrs2, iKind, mlpdParNr_What6);
201 }
202 }
203 }
204
205 TCanvas* canvas = new TCanvas("canvas", "Convergency of alignment", nStations * 200, 1200);
206 canvas->Divide(nStations, 12, 0., 0.);
207 TPad* pad;
208 Int_t padNr(0);
209 gROOT->ForceStyle(kTRUE);
210 /*
211 gStyle->SetPadTopMargin(0.);
212 gStyle->SetPadLeftMargin(0.);
213 gStyle->SetPadRightMargin(0.);
214 gStyle->SetPadBottomMargin(0.);
215 gStyle->SetPadBottomMargin(0.03);
216 */
217 gStyle->SetLineWidth(1);
218 gStyle->SetTitleY(0.980);
219 gStyle->SetLineScalePS(0.5);
220
221 canvas->cd(0);
222 gPad->SetTopMargin(0.);
223 gPad->SetLeftMargin(0.);
224 gPad->SetRightMargin(0.);
225 gPad->SetBottomMargin(0.);
226 cout << endl;
227 TString xyz[] = {"X", "Y", "Z"};
228 Double_t alCorrs1[nIts];
229 Double_t alCorrErrs1[nIts];
230 Double_t alCorrs2[nIts];
231 Double_t alCorrErrs2[nIts];
232 for (Int_t iKind = 0; iKind < nKinds; iKind++) {
233 for (Int_t iPar = 0; iPar < nParams; iPar++) {
234 Int_t nStats = stationSet->GetNStations();
235 for (Int_t iStat = iStatFirst; iStat < nStats; iStat++) {
236 Int_t nModuls = stationSet->GetGemStation(iStat)->GetNModules();
237 for (Int_t iMod = 0; iMod < nModuls; iMod++) {
238 // Double_t alCorrs = new Double_t[nIts];
239 for (Int_t iIt = 0; iIt < nIts; iIt++) {
240 // cout <<"itCorrs1[ "<<iKind<<"]["<<iPar<<"]["<<iStat<<"]["<<iMod<<"]["<<iIt<<"] =
241 // "<<TString::Format("% 14.11f", itCorrs1[iKind][iPar][iStat][iMod][iIt])<< endl;
242 alCorrs1[iIt] = itCorrs1[iKind][iPar][iStat][iMod][iIt];
243 // cout <<TString::Format("alCorrs1[ %2i] = % 14.11f", iIt, alCorrs1[iIt])<<
244 // endl;
245 if (kinds[iKind] == "new") {
246 // cout <<"itNewCorrErrs1[ "<<iPar<<"]["<<iStat<<"]["<<iMod<<"]["<<iIt<<"] =
247 // "<<TString::Format("% 14.11f", itNewCorrErrs1[iPar][iStat][iMod][iIt])<< endl;
248 if (itNewCorrErrs1[iPar][iStat][iMod][iIt] > 0.)
249 alCorrErrs1[iIt] = itNewCorrErrs1[iPar][iStat][iMod][iIt];
250 else
251 alCorrErrs1[iIt] = 0.;
252 } else {
253 alCorrErrs1[iIt] = 0.;
254 }
255 // cout <<TString::Format("alCorrErrs1[ %2i] = % 14.11f", iIt, alCorrErrs1[iIt])<<
256 // endl;
257 if (new2AlignCorrFileListFileName != "") {
258 // cout <<"itCorrs2[ "<<iKind<<"]["<<iPar<<"]["<<iStat<<"]["<<iMod<<"]["<<iIt<<"] =
259 // "<<TString::Format("% 14.11f", itCorrs2[iKind][iPar][iStat][iMod][iIt])<< endl;
260 alCorrs2[iIt] = itCorrs2[iKind][iPar][iStat][iMod][iIt];
261 // cout <<TString::Format("alCorrs2[ %2i] = % 14.11f", iIt, alCorrs2[iIt])<<
262 // endl;
263 if (kinds[iKind] == "new") {
264 // cout <<"itNewCorrErrs2[ "<<iPar<<"]["<<iStat<<"]["<<iMod<<"]["<<iIt<<"] =
265 // "<<TString::Format("% 14.11f", itNewCorrErrs2[iPar][iStat][iMod][iIt])<< endl;
266 if (itNewCorrErrs2[iPar][iStat][iMod][iIt] > 0.)
267 alCorrErrs2[iIt] = itNewCorrErrs2[iPar][iStat][iMod][iIt];
268 else
269 alCorrErrs2[iIt] = 0.;
270 } else {
271 alCorrErrs2[iIt] = 0.;
272 }
273 // cout <<TString::Format("alCorrErrs2[ %2i] = % 14.11f", iIt,
274 // alCorrErrs2[iIt])<< endl;
275 }
276 }
277 // cout <<"nIts = "<<nIts<< endl;
278 // res = mStatMod_Pad.find(make_pair(iStat, iMod));
279 // padNr = res + iPar*12 + iKind*36;
280 // cout <<"mStatMod_Pad[make_pair("<<iStat<<", "<<iMod<<")] = "<<mStatMod_Pad[make_pair(iStat,
281 // iMod)]<< endl;
282 padNr = mStatMod_Pad[make_pair(iStat, iMod)] + iPar * 12 + iKind * 36;
283 // cout <<"padNr = "<<padNr<< endl;
284 canvas->cd(padNr);
285 // pad = (TPad*)canvas->cd(padNr);
286 // gPad->SetFrameBorderMode(0);
287 // gPad->SetBorderMode(0);
288 // gPad->SetBorderSize(0);
289 // gPad->SetTopMargin( 0.01 );
290 // gPad->SetLeftMargin( 0.08 );
291 // gPad->SetRightMargin( 0.005);
292 // gPad->SetBottomMargin(0.05 );
293
294 TGraphErrors* grer1 = new TGraphErrors(nIts, its, alCorrs1, 0, alCorrErrs1);
295 if (kinds[iKind] == "new") {
296 grer1->SetMaximum(0.5);
297 grer1->SetMinimum(-0.5);
298 } else {
299 grer1->SetMaximum(0.5);
300 grer1->SetMinimum(-0.5);
301 }
302 grer1->SetTitle(kinds[iKind] + " " + xyz[iPar] + " corrections starting " + new1StartAlignFrom
303 + " stat " + TString::Itoa(iStat, 10) + " mod " + TString::Itoa(iMod, 10));
304
305 grer1->GetXaxis()->SetLimits(-0., (Double_t)nIts);
306 grer1->GetXaxis()->SetNdivisions(nIts);
307 // grer1->GetXaxis()->SetTitle("iteration number");
308 // grer1->GetXaxis()->SetTitleOffset(0.6);
309 // grer1->GetXaxis()->SetTitleSize(0.03);
310 // grer1->GetXaxis()->SetLabelSize(0.03);
311 // grer1->GetYaxis()->SetLabelSize(0.03);
312 grer1->SetFillStyle(1001);
313 grer1->SetFillColor(kCyan - 10);
314 // grer1->Draw("3AL");
315 // canvas->cd(padNr);
316
317 TGraph* gr1 = new TGraph(nIts, its, alCorrs1);
318 if (kinds[iKind] == "new") {
319 gr1->SetMaximum(0.5);
320 gr1->SetMinimum(-0.5);
321 } else {
322 gr1->SetMaximum(0.5);
323 gr1->SetMinimum(-0.5);
324 }
325 gr1->SetTitle(kinds[iKind] + " " + xyz[iPar] + " corrections starting " + new1StartAlignFrom
326 + " stat " + TString::Itoa(iStat, 10) + " mod " + TString::Itoa(iMod, 10));
327
328 gr1->GetXaxis()->SetLimits(-0., (Double_t)nIts);
329 gr1->GetXaxis()->SetNdivisions(nIts);
330 // gr1->GetXaxis()->SetTitle("iteration number");
331 // gr1->GetXaxis()->SetTitleOffset(0.6);
332 // gr1->GetXaxis()->SetTitleSize(0.03);
333 // gr1->GetXaxis()->SetLabelSize(0.03);
334 // gr1->GetYaxis()->SetLabelSize(0.03);
335 gr1->SetFillStyle(4000);
336 gr1->SetFillColor(0);
337 // gr1->Draw("AL");
338 // canvas->cd(padNr);
339 if (new2AlignCorrFileListFileName != "") {
340 TGraphErrors* grer2 = new TGraphErrors(nIts, its, alCorrs2, 0, alCorrErrs2);
341 if (kinds[iKind] == "new") {
342 grer2->SetMaximum(0.5);
343 grer2->SetMinimum(-0.5);
344 } else {
345 grer2->SetMaximum(0.5);
346 grer2->SetMinimum(-0.5);
347 }
348 grer2->SetTitle(kinds[iKind] + " " + xyz[iPar] + " corrections starting " + new1StartAlignFrom
349 + " stat " + TString::Itoa(iStat, 10) + " mod " + TString::Itoa(iMod, 10));
350
351 grer2->GetXaxis()->SetLimits(-0., (Double_t)nIts);
352 grer2->GetXaxis()->SetNdivisions(nIts);
353 // grer2->GetXaxis()->SetTitle("iteration number");
354 // grer2->GetXaxis()->SetTitleOffset(0.6);
355 // grer2->GetXaxis()->SetTitleSize(0.03);
356 // grer2->GetXaxis()->SetLabelSize(0.03);
357 // grer2->GetYaxis()->SetLabelSize(0.03);
358 grer2->SetFillStyle(1001);
359 grer2->SetFillColor(kMagenta - 10);
360 // grer2->Draw("3AL");
361 // canvas->cd(padNr);
362
363 TGraph* gr2 = new TGraph(nIts, its, alCorrs2);
364 if (kinds[iKind] == "new") {
365 gr2->SetMaximum(0.5);
366 gr2->SetMinimum(-0.5);
367 } else {
368 gr2->SetMaximum(0.5);
369 gr2->SetMinimum(-0.5);
370 }
371 gr2->SetTitle(kinds[iKind] + " " + xyz[iPar] + " corrections starting " + new1StartAlignFrom
372 + " stat " + TString::Itoa(iStat, 10) + " mod " + TString::Itoa(iMod, 10));
373
374 gr2->GetXaxis()->SetLimits(-0., (Double_t)nIts);
375 gr2->GetXaxis()->SetNdivisions(nIts);
376 // gr2->GetXaxis()->SetTitle("iteration number");
377 // gr2->GetXaxis()->SetTitleOffset(0.6);
378 // gr2->GetXaxis()->SetTitleSize(0.03);
379 // gr2->GetXaxis()->SetLabelSize(0.03);
380 // gr2->GetYaxis()->SetLabelSize(0.03);
381 gr2->SetFillStyle(4000);
382 gr2->SetFillColor(0);
383 gr2->SetLineColor(kRed + 1);
384 // gr2->Draw("AL");
385 // canvas->cd(padNr);
386 }
387 TMultiGraph* mg = new TMultiGraph();
388 mg->Add(grer1, "A3");
389 mg->Add(gr1, "AL");
390 mg->SetTitle(kinds[iKind] + " " + xyz[iPar] + " corrections starting " + new1StartAlignFrom
391 + " stat " + TString::Itoa(iStat, 10) + " mod " + TString::Itoa(iMod, 10));
392
393 if (new2AlignCorrFileListFileName != "") {
394 mg->Add(grer2, "A3");
395 mg->Add(gr2, "AL");
396 mg->SetTitle(kinds[iKind] + " " + xyz[iPar] + " corrections starting " + new1StartAlignFrom
397 + " and " + new2StartAlignFrom + " stat " + TString::Itoa(iStat, 10) + " mod "
398 + TString::Itoa(iMod, 10));
399 }
400 if (kinds[iKind] == "new") {
401 mg->SetMaximum(0.5);
402 mg->SetMinimum(-0.5);
403 } else {
404 mg->SetMaximum(0.5);
405 mg->SetMinimum(-0.5);
406 }
407
408 mg->Draw("A");
409 // canvas->cd(padNr);
410 gPad->Modified();
411
412 gPad->SetFrameBorderMode(0);
413 gPad->SetBorderMode(0);
414 gPad->SetBorderSize(0);
415 gPad->SetTopMargin(0.01);
416 gPad->SetLeftMargin(0.08);
417 gPad->SetRightMargin(0.005);
418 // gPad->SetBottomMargin(0.05 );
419 gPad->SetBottomMargin(0.1);
420
421 mg->GetXaxis()->SetLimits(-0., (Double_t)nIts);
422 mg->GetXaxis()->SetNdivisions(nIts);
423 mg->GetXaxis()->SetTitle("iteration number");
424 mg->GetXaxis()->SetTitleOffset(0.6);
425 // mg->GetXaxis()->SetTitleSize(0.03);
426 // mg->GetXaxis()->SetLabelSize(0.03);
427 // mg->GetYaxis()->SetLabelSize(0.03);
428 mg->Draw("A");
429 // canvas->cd(padNr);
430 gPad->Modified();
431
432 TLine* zerolevel = new TLine(0., 0., (Double_t)nIts, 0.);
433 zerolevel->SetLineColor(kBlue);
434 zerolevel->SetLineStyle(3);
435 zerolevel->Draw();
436 gPad->Modified();
437 // canvas->cd(padNr);
438 // gPad->Modified();
439 // gPad->Update();
440 // delete grer;
441 // delete gr;
442 // delete mg;
443 }
444 }
445 }
446 }
447 canvas->Update();
448 canvas->SaveAs(alignCorrPlotsFileName.ReplaceAll("root", "pdf"));
449 canvas->SaveAs(alignCorrPlotsFileName.ReplaceAll("pdf", "root"));
450 canvas->SaveAs(alignCorrPlotsFileName.ReplaceAll("root", "eps"));
451}
452
453void CreateItCorrs(Double_t***** itCorrs, Int_t nKinds, Int_t nParams, Int_t nIts, BmnGemStripStationSet* stationSet)
454{
455 Double_t***** itCorrs = new Double_t****[nKinds];
456 for (Int_t iKind = 0; iKind < nKinds; iKind++) {
457 itCorrs[iKind] = new Double_t***[nParams];
458 for (Int_t iPar = 0; iPar < nParams; iPar++) {
459 Int_t nStats = stationSet->GetNStations();
460 itCorrs[iKind][iPar] = new Double_t**[nStats];
461 for (Int_t iStat = 0; iStat < nStats; iStat++) {
462 Int_t nModuls = stationSet->GetGemStation(iStat)->GetNModules();
463 itCorrs[iKind][iPar][iStat] = new Double_t*[nModuls];
464 for (Int_t iMod = 0; iMod < nModuls; iMod++) {
465 itCorrs[iKind][iPar][iStat][iMod] = new Double_t[nIts];
466 for (Int_t iIt = 0; iIt < nIts; iIt++) {
467 itCorrs[iKind][iPar][iStat][iMod][iIt] = 0.;
468 // cout <<"itCorrs["<<iKind<<"]["<<iPar<<"]["<<iStat<<"]["<<iMod<<"]["<<iIt<<"] =
469 // "<<TString::Format("% 14.11f", itCorrs[iKind][iPar][iStat][iMod][iIt])<< endl;
470 }
471 }
472 }
473 }
474 }
475}
476
477void CreateItCorrErrs(Double_t**** itNewCorrErrs, Int_t nParams, Int_t nIts, BmnGemStripStationSet* stationSet)
478{
479 Double_t**** itNewCorrErrs = new Double_t***[nParams];
480 for (Int_t iPar = 0; iPar < nParams; iPar++) {
481 Int_t nStats = stationSet->GetNStations();
482 itNewCorrErrs[iPar] = new Double_t**[nStats];
483 for (Int_t iStat = 0; iStat < nStats; iStat++) {
484 Int_t nModuls = stationSet->GetGemStation(iStat)->GetNModules();
485 itNewCorrErrs[iPar][iStat] = new Double_t*[nModuls];
486 for (Int_t iMod = 0; iMod < nModuls; iMod++) {
487 itNewCorrErrs[iPar][iStat][iMod] = new Double_t[nIts];
488 for (Int_t iIt = 0; iIt < nIts; iIt++) {
489 itNewCorrErrs[iPar][iStat][iMod][iIt] = 0.;
490 }
491 }
492 }
493 }
494}
495
496void FillItCorrsItErrs(TString newAlignCorrFileListFileName,
497 Double_t***** itCorrs,
498 Double_t**** itNewCorrErrs,
499 Int_t iKind,
500 int mlpdParNr_What[][3])
501{
502 cout << "newAlignCorrFileListFileName = " << newAlignCorrFileListFileName << endl;
503 // cout <<TString::Format("iKind = %i", iKind)<< endl;
504 TString fnameTStrg = newAlignCorrFileListFileName;
505 if (iKind == 1)
506 fnameTStrg = fnameTStrg.ReplaceAll("new", "sum");
507 string fnamestrg = fnameTStrg;
508 cout << "fnamestrg = " + fnamestrg << endl;
509 ifstream corrFileListFstr(fnamestrg.c_str());
510 fnamestrg = "";
511 TString fname;
512 Int_t iIt(-1); // iteration counter: starts with 0
513 while (corrFileListFstr >> fnamestrg) { // this is in fact the main loop over the iterations
514 fname = fnamestrg;
515 cout << "fname = " + fname << endl;
516 TFile* corrFile = new TFile(fname.Data());
517 TTree* corrTree = (TTree*)corrFile->Get("cbmsim");
518 // cout <<"corrTree->Print()"<< endl;
519 // corrTree->Print();
520 // TClonesArray* corrs = new TClonesArray("BmnGemAlignCorrections");
521 TClonesArray* corrs = NULL;
522 corrTree->SetBranchAddress("BmnGemAlignCorrections", &corrs);
523
524 for (Int_t iEntry = 0; iEntry < (Int_t)corrTree->GetEntries(); iEntry++) {
525 // cout <<TString::Format("iEntry = % 5i", iEntry)<< endl;
526 corrTree->GetEntry(iEntry);
527 if ((Int_t)corrs->GetEntriesFast() > 0) {
528 // cout <<TString::Format("iEntry = % 5i", iEntry)<< endl;
529 // cout <<"(Int_t)corrs->GetEntriesFast() = "<<(Int_t)corrs->GetEntriesFast()<< endl;
530 break;
531 }
532 }
533 iIt++;
534 // cout <<TString::Format( "iIt = % 2i", iIt )<< endl;
535 for (Int_t iCorr = 0; iCorr < (Int_t)corrs->GetEntriesFast(); iCorr++) {
536 // cout <<TString::Format("iCorr = % 2i", iCorr)<< endl;
538 Int_t iStat = tmp->GetStation();
539 // cout <<TString::Format("iStat = % 2i", iStat)<< endl;
540 Int_t iMod = tmp->GetModule();
541 // cout <<TString::Format("iMod = % 2i", iMod )<< endl;
542 itCorrs[iKind][0][iStat][iMod][iIt] = tmp->GetCorrections().X(),
543 //cout <<"itCorrs["<<iKind<<"]["<<0<<"]["<<iStat<<"]["<<iMod<<"]["<<iIt<<"] = "<<TString::Format("% 14.11f", itCorrs[iKind][0][iStat][iMod][iIt])<< endl;
544 itCorrs[iKind][1][iStat][iMod][iIt] = tmp->GetCorrections().Y(),
545 //cout <<"itCorrs["<<iKind<<"]["<<1<<"]["<<iStat<<"]["<<iMod<<"]["<<iIt<<"] = "<<TString::Format("% 14.11f", itCorrs[iKind][1][iStat][iMod][iIt])<< endl;
546 itCorrs[iKind][2][iStat][iMod][iIt] = tmp->GetCorrections().Z());
547 // cout <<"itCorrs["<<iKind<<"]["<<2<<"]["<<iStat<<"]["<<iMod<<"]["<<iIt<<"] =
548 // "<<TString::Format("% 14.11f", itCorrs[iKind][2][iStat][iMod][iIt])<< endl;
549 }
550 delete corrFile;
551 // delete corrs;
552
553 if (iKind == 0) {
554 // extract millepede's parameter errors:
555 TString mlpdResFname = fname;
556 mlpdResFname = mlpdResFname.ReplaceAll("_it", "_millepede_it");
557 mlpdResFname = mlpdResFname.ReplaceAll(".root", ".res");
558 cout << "mlpdResFname = " << mlpdResFname << endl;
559 ifstream ifstrmMlpdRes(mlpdResFname.Data());
560 string line;
561
562 // while (ifstrmMlpdRes >> line) {
563 getline(ifstrmMlpdRes, line); // skip the title line
564 cout << line << endl;
565 while (getline(ifstrmMlpdRes, line)) { // loop over lines in the Millepede<...>.res file
566 cout << line << endl;
567 stringstream stgstm(line);
568 int parNr;
569 double parVal, presigma, differ, parErr;
570 stgstm >> parNr >> parVal >> presigma;
571 if (presigma > 0.) { // presima == -1. means not usable line
572 if (abs(parVal) > 1.E-9) {
573 stgstm >> differ >> parErr;
574 } else {
575 parErr = 0.;
576 }
577 cout << TString::Format("parNr = %2i parVal = % 14.11f parErr = % 14.11f", parNr, parVal, parErr)
578 << endl;
579 Int_t jPar = mlpdParNr_What[parNr - 1][0];
580 Int_t jStat = mlpdParNr_What[parNr - 1][1];
581 Int_t jMod = mlpdParNr_What[parNr - 1][2];
582 cout << "jPar = " << jPar << " jStat = " << jStat << " jMod = " << jMod << endl;
583 itNewCorrErrs[jPar][jStat][jMod][iIt] = parErr;
584 cout << "itNewCorrErrs[ " << jPar << "][" << jStat << "][" << jMod << "][" << iIt
585 << "] = " << TString::Format("% 14.11f", itNewCorrErrs[jPar][jStat][jMod][iIt])
586 << endl;
587 }
588 }
589 }
590 }
591}
int i
Definition P4_F32vec4.h:22
int Int_t
double Double_t
constexpr Bool_t kTRUE
kRed
kMagenta
kCyan
kBlue
#define gROOT
R__EXTERN TStyle * gStyle
#define gPad
BmnGemStripStation * GetGemStation(Int_t station_num)
virtual void SetTitleOffset(Float_t offset=1)
virtual void SetNdivisions(Int_t n1, Int_t n2, Int_t n3, Bool_t optim=kTRUE)
virtual void SetFillColor(Color_t fcolor)
virtual void SetFillStyle(Style_t fstyle)
virtual void SetLineStyle(Style_t lstyle)
virtual void SetLineColor(Color_t lcolor)
virtual void SetLimits(Double_t xmin, Double_t xmax)
TVirtualPad * cd(Int_t subpadnumber=0) override
void Update() override
T * Get(const char *namecycle)
virtual void SetMaximum(Double_t maximum=-1111)
TAxis * GetXaxis() const
void SetTitle(const char *title="") override
virtual void SetMinimum(Double_t minimum=-1111)
virtual void Add(TGraph *graph, Option_t *chopt="")
virtual void SetMinimum(Double_t minimum=-1111)
void Draw(Option_t *chopt="") override
virtual void SetMaximum(Double_t maximum=-1111)
TAxis * GetXaxis()
virtual void SetTitle(const char *title="")
Int_t GetEntriesFast() const
TObject * UncheckedAt(Int_t i) const
virtual void Draw(Option_t *option="")
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
void SaveAs(const char *filename="", Option_t *option="") const override
Int_t Atoi() const
const char * Data() const
static TString Format(const char *fmt,...)
static TString Itoa(Int_t value, Int_t base)
TString & ReplaceAll(const char *s1, const char *s2)
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
virtual Long64_t GetEntries() const
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
Double_t Z() const
Double_t Y() const
Double_t X() const
RVec< PromoteType< T > > abs(const RVec< T > &v)
*brief user defined string literal for JSON values *sa std::size_t n
Definition json.hpp:20362
void plot_align_corrections_bmn(TString new1AlignCorrFileListFileName, TString new2AlignCorrFileListFileName="")
void FillItCorrsItErrs(TString newAlignCorrFileListFileName, Double_t *****itCorrs, Double_t ****itNewCorrErrs, Int_t iKind, int const mlpdParNr_What[][3])
void CreateItCorrErrs(Double_t ****itNewCorrErrs, Int_t nParams, Int_t nIts, BmnGemStripStationSet *stationSet)
void CreateItCorrs(Double_t *****itCorrs, Int_t nKinds, Int_t nParams, Int_t nIts, BmnGemStripStationSet *stationSet)