14 #include "TProfile2D.h"
26 const char* shortname,
27 const char* outtrunk) {
29 sprintf(modfull,
"%s%s",
module, postfix);
31 sprintf(labfull,
"%s%s",
label, postfix);
34 sprintf(
dirname,
"%s", shortname);
42 gSystem->cd(workdir.c_str());
43 gSystem->MakeDirectory(labfull);
48 gStyle->SetOptStat(111111);
53 TH1F* deltax = (TH1F*)castat.
getObject(
"deltax");
54 if (deltax && deltax->GetEntries() > 0) {
58 plotfilename += outtrunk;
61 plotfilename += labfull;
62 plotfilename +=
"/deltax_";
63 plotfilename += labfull;
66 plotfilename +=
".gif";
67 gPad->Print(plotfilename.c_str());
71 TH1F* deltay = (TH1F*)castat.
getObject(
"deltay");
72 if (deltay && deltay->GetEntries() > 0) {
76 plotfilename += outtrunk;
79 plotfilename += labfull;
80 plotfilename +=
"/deltay_";
81 plotfilename += labfull;
84 plotfilename +=
".gif";
85 gPad->Print(plotfilename.c_str());
89 TH1F* deltaz = (TH1F*)castat.
getObject(
"deltaz");
90 if (deltaz && deltaz->GetEntries() > 0) {
94 plotfilename += outtrunk;
97 plotfilename += labfull;
98 plotfilename +=
"/deltaz_";
99 plotfilename += labfull;
102 plotfilename +=
".gif";
103 gPad->Print(plotfilename.c_str());
107 gStyle->SetOptStat(111);
108 gStyle->SetOptFit(111);
109 TProfile* deltaxvsz = (TProfile*)castat.
getObject(
"deltaxvsz");
110 if (deltaxvsz && deltaxvsz->GetEntries() > 0) {
112 deltaxvsz->Fit(
"pol1",
"",
"", -10., 10.);
113 if (deltaxvsz->GetFunction(
"pol1")) {
114 deltaxvsz->GetFunction(
"pol1")->SetLineColor(kRed);
115 deltaxvsz->GetFunction(
"pol1")->SetLineWidth(1);
117 deltaxvsz->GetYaxis()->SetRangeUser(-0.001, 0.001);
119 plotfilename += outtrunk;
122 plotfilename += labfull;
123 plotfilename +=
"/deltaxvsz_";
124 plotfilename += labfull;
127 plotfilename +=
".gif";
128 gPad->Print(plotfilename.c_str());
131 TProfile* deltayvsz = (TProfile*)castat.
getObject(
"deltayvsz");
132 if (deltayvsz && deltayvsz->GetEntries() > 0) {
134 deltayvsz->Fit(
"pol1",
"",
"", -10., 10.);
135 if (deltayvsz->GetFunction(
"pol1")) {
136 deltayvsz->GetFunction(
"pol1")->SetLineColor(kRed);
137 deltayvsz->GetFunction(
"pol1")->SetLineWidth(1);
139 deltayvsz->GetYaxis()->SetRangeUser(-0.001, 0.001);
141 plotfilename += outtrunk;
144 plotfilename += labfull;
145 plotfilename +=
"/deltayvsz_";
146 plotfilename += labfull;
149 plotfilename +=
".gif";
150 gPad->Print(plotfilename.c_str());
154 gStyle->SetOptStat(111111);
155 gStyle->SetOptFit(1111);
158 TF1* fdoubleg =
new TF1(
"doubleg",
159 "[1]*exp(-0.5*((x-[0])/[2])**2)+[3]*exp(-0.5*((x-[0])/[4])**2)+[5]*exp(sqrt((x-[0])**2)*[6])",
162 fdoubleg->SetLineColor(kRed);
163 fdoubleg->SetLineWidth(1);
170 gStyle->SetOptFit(1111);
173 TH1D* deltaxsum =
new TH1D(
"deltaxsum",
"(PV-BS) Fitted X position vs run", 10, 0., 10.);
174 deltaxsum->SetCanExtend(TH1::kAllAxes);
175 TH1D* deltaysum =
new TH1D(
"deltaysum",
"(PV-BS) Fitted Y position vs run", 10, 0., 10.);
176 deltaysum->SetCanExtend(TH1::kAllAxes);
178 TH1D* deltaxmeansum =
new TH1D(
"deltaxmeansum",
"(PV-BS) Mean X position vs run", 10, 0., 10.);
179 deltaxmeansum->SetCanExtend(TH1::kAllAxes);
180 TH1D* deltaymeansum =
new TH1D(
"deltaymeansum",
"(PV-BS) Mean Y position vs run", 10, 0., 10.);
181 deltaymeansum->SetCanExtend(TH1::kAllAxes);
183 TH1D* deltazmeansum =
new TH1D(
"deltazmeansum",
"(PV-BS) Mean Z position vs run", 10, 0., 10.);
184 deltazmeansum->SetCanExtend(TH1::kAllAxes);
190 std::cout <<
"Found " <<
runs.size() <<
" runs" << std::endl;
192 for (
unsigned int i = 0;
i <
runs.size(); ++
i) {
194 sprintf(runlabel,
"%d",
runs[
i]);
196 sprintf(runpath,
"run_%d",
runs[
i]);
200 TH1F* deltax = (TH1F*)castat.
getObject(
"deltaxrun");
201 if (deltax && deltax->GetEntries() > 0) {
203 fdoubleg->SetParameter(0, deltax->GetMean());
204 fdoubleg->SetParameter(2, deltax->GetRMS());
205 fdoubleg->SetParameter(4, deltax->GetRMS());
206 fdoubleg->SetParameter(1, deltax->GetMaximum());
207 fdoubleg->SetParameter(3, 0.1 * deltax->GetMaximum());
208 fdoubleg->SetParameter(5, 0.1 * deltax->GetMaximum());
209 const int result = deltax->Fit(fdoubleg,
"b",
"", -.05, .05);
212 sprintf(tresult,
"%d",
result);
214 res.SetTextColor(kRed);
216 res.DrawTextNDC(.2, .8, tresult);
218 int bin = deltaxsum->Fill(runlabel, fdoubleg->GetParameter(0));
219 deltaxsum->SetBinError(
bin, fdoubleg->GetParError(0));
221 bin = deltaxmeansum->Fill(runlabel, deltax->GetMean());
222 deltaxmeansum->SetBinError(
bin, deltax->GetMeanError());
225 plotfilename += outtrunk;
228 plotfilename += labfull;
229 plotfilename +=
"/deltaxrun_";
230 plotfilename += labfull;
234 plotfilename += runpath;
235 plotfilename +=
".gif";
236 gPad->Print(plotfilename.c_str());
240 TH1F* deltay = (TH1F*)castat.
getObject(
"deltayrun");
241 if (deltay && deltay->GetEntries() > 0) {
243 fdoubleg->SetParameter(0, deltay->GetMean());
244 fdoubleg->SetParameter(2, deltay->GetRMS());
245 fdoubleg->SetParameter(4, deltay->GetRMS());
246 fdoubleg->SetParameter(1, deltay->GetMaximum());
247 fdoubleg->SetParameter(3, 0.1 * deltay->GetMaximum());
248 fdoubleg->SetParameter(5, 0.1 * deltay->GetMaximum());
249 const int result = deltay->Fit(fdoubleg,
"b",
"", -.05, .05);
252 sprintf(tresult,
"%d",
result);
254 res.SetTextColor(kRed);
256 res.DrawTextNDC(.2, .8, tresult);
258 int bin = deltaysum->Fill(runlabel, fdoubleg->GetParameter(0));
259 deltaysum->SetBinError(
bin, fdoubleg->GetParError(0));
261 bin = deltaymeansum->Fill(runlabel, deltay->GetMean());
262 deltaymeansum->SetBinError(
bin, deltay->GetMeanError());
265 plotfilename += outtrunk;
268 plotfilename += labfull;
269 plotfilename +=
"/deltayrun_";
270 plotfilename += labfull;
274 plotfilename += runpath;
275 plotfilename +=
".gif";
276 gPad->Print(plotfilename.c_str());
280 TH1F* deltaz = (TH1F*)castat.
getObject(
"deltazrun");
281 if (deltaz && deltaz->GetEntries() > 0) {
285 int bin = deltazmeansum->Fill(runlabel, deltaz->GetMean());
286 deltazmeansum->SetBinError(
bin, deltaz->GetMeanError());
289 plotfilename += outtrunk;
292 plotfilename += labfull;
293 plotfilename +=
"/deltazrun_";
294 plotfilename += labfull;
298 plotfilename += runpath;
299 plotfilename +=
".gif";
300 gPad->Print(plotfilename.c_str());
305 TProfile* deltaxvsz = (TProfile*)castat.
getObject(
"deltaxvszrun");
306 if (deltaxvsz && deltaxvsz->GetEntries() > 0) {
309 plotfilename += outtrunk;
312 plotfilename += labfull;
313 plotfilename +=
"/deltaxvszrun_";
314 plotfilename += labfull;
318 plotfilename += runpath;
319 plotfilename +=
".gif";
320 gPad->Print(plotfilename.c_str());
324 TProfile* deltayvsz = (TProfile*)castat.
getObject(
"deltayvszrun");
325 if (deltayvsz && deltayvsz->GetEntries() > 0) {
328 plotfilename += outtrunk;
331 plotfilename += labfull;
332 plotfilename +=
"/deltayvszrun_";
333 plotfilename += labfull;
337 plotfilename += runpath;
338 plotfilename +=
".gif";
339 gPad->Print(plotfilename.c_str());
343 TH1F* deltaxvsorb = (TH1F*)castat.
getObject(
"deltaxvsorbrun");
344 if (deltaxvsorb && deltaxvsorb->GetEntries() > 0) {
347 plotfilename += outtrunk;
350 plotfilename += labfull;
351 plotfilename +=
"/deltaxvsorb_";
352 plotfilename += labfull;
356 plotfilename += runpath;
357 plotfilename +=
".gif";
358 gPad->Print(plotfilename.c_str());
361 TH1F* deltayvsorb = (TH1F*)castat.
getObject(
"deltayvsorbrun");
362 if (deltayvsorb && deltayvsorb->GetEntries() > 0) {
365 plotfilename += outtrunk;
368 plotfilename += labfull;
369 plotfilename +=
"/deltayvsorb_";
370 plotfilename += labfull;
374 plotfilename += runpath;
375 plotfilename +=
".gif";
376 gPad->Print(plotfilename.c_str());
379 TH1F* deltazvsorb = (TH1F*)castat.
getObject(
"deltazvsorbrun");
380 if (deltazvsorb && deltazvsorb->GetEntries() > 0) {
383 plotfilename += outtrunk;
386 plotfilename += labfull;
387 plotfilename +=
"/deltazvsorb_";
388 plotfilename += labfull;
392 plotfilename += runpath;
393 plotfilename +=
".gif";
394 gPad->Print(plotfilename.c_str());
400 gStyle->SetOptStat(1111);
401 gStyle->SetOptFit(0);
406 plotfilename = outtrunk;
409 plotfilename += labfull;
410 plotfilename +=
"/deltaxsum_";
411 plotfilename += labfull;
414 plotfilename +=
".gif";
416 TCanvas* cwidedeltax =
new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
418 deltaxsum->SetLineColor(kRed);
419 deltaxsum->SetMarkerColor(kRed);
420 deltaxsum->GetYaxis()->SetRangeUser(-.002, .002);
421 deltaxsum->GetYaxis()->SetTitle(
"#Delta x (cm)");
423 deltaxmeansum->Draw(
"esame");
424 TLegend deltaxleg(.7, .8, .85, .9,
"#Delta(x)");
425 deltaxleg.AddEntry(deltaxsum,
"fitted mean",
"l");
426 deltaxleg.AddEntry(deltaxmeansum,
"aritm. mean",
"l");
428 gPad->Print(plotfilename.c_str());
431 plotfilename = outtrunk;
434 plotfilename += labfull;
435 plotfilename +=
"/deltaysum_";
436 plotfilename += labfull;
439 plotfilename +=
".gif";
441 TCanvas* cwidedeltay =
new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
443 deltaysum->SetLineColor(kRed);
444 deltaysum->SetMarkerColor(kRed);
445 deltaysum->GetYaxis()->SetRangeUser(-.002, .002);
446 deltaysum->GetYaxis()->SetTitle(
"#Delta y (cm)");
448 deltaymeansum->Draw(
"esame");
449 TLegend deltayleg(.7, .8, .85, .9,
"#Delta(y)");
450 deltayleg.AddEntry(deltaysum,
"fitted mean",
"l");
451 deltayleg.AddEntry(deltaymeansum,
"aritm. mean",
"l");
453 gPad->Print(plotfilename.c_str());
456 plotfilename = outtrunk;
459 plotfilename += labfull;
460 plotfilename +=
"/deltazsum_";
461 plotfilename += labfull;
464 plotfilename +=
".gif";
466 TCanvas* cwidedeltaz =
new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
468 deltazmeansum->GetYaxis()->SetRangeUser(-2., 2.);
469 deltazmeansum->GetYaxis()->SetTitle(
"#Delta z (cm)");
470 deltazmeansum->Draw();
471 gPad->Print(plotfilename.c_str());
476 delete deltaxmeansum;
477 delete deltaymeansum;
478 delete deltazmeansum;