14 #include "TProfile2D.h"
22 void BSvsPVPlots(
const char* fullname,
const char*
module,
const char*
label,
const char* postfix,
const char* shortname,
const char* outtrunk) {
25 sprintf(modfull,
"%s%s",module,postfix);
27 sprintf(labfull,
"%s%s",label,postfix);
30 sprintf(dirname,
"%s",shortname);
40 gSystem->cd(workdir.c_str());
41 gSystem->MakeDirectory(labfull);
47 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",
"[1]*exp(-0.5*((x-[0])/[2])**2)+[3]*exp(-0.5*((x-[0])/[4])**2)+[5]*exp(sqrt((x-[0])**2)*[6])",-.2,.2);
159 fdoubleg->SetLineColor(kRed);
160 fdoubleg->SetLineWidth(1);
167 gStyle->SetOptFit(1111);
170 TH1D* deltaxsum =
new TH1D(
"deltaxsum",
"(PV-BS) Fitted X position vs run",10,0.,10.);
171 deltaxsum->SetCanExtend(TH1::kAllAxes);
172 TH1D* deltaysum =
new TH1D(
"deltaysum",
"(PV-BS) Fitted Y position vs run",10,0.,10.);
173 deltaysum->SetCanExtend(TH1::kAllAxes);
175 TH1D* deltaxmeansum =
new TH1D(
"deltaxmeansum",
"(PV-BS) Mean X position vs run",10,0.,10.);
176 deltaxmeansum->SetCanExtend(TH1::kAllAxes);
177 TH1D* deltaymeansum =
new TH1D(
"deltaymeansum",
"(PV-BS) Mean Y position vs run",10,0.,10.);
178 deltaymeansum->SetCanExtend(TH1::kAllAxes);
180 TH1D* deltazmeansum =
new TH1D(
"deltazmeansum",
"(PV-BS) Mean Z position vs run",10,0.,10.);
181 deltazmeansum->SetCanExtend(TH1::kAllAxes);
184 std::sort(runs.begin(),runs.end());
188 std::cout <<
"Found " << runs.size() <<
" runs" << std::endl;
190 for(
unsigned int i=0;
i<runs.size();++
i) {
193 sprintf(runlabel,
"%d",runs[
i]);
195 sprintf(runpath,
"run_%d",runs[i]);
199 TH1F* deltax = (TH1F*)castat.
getObject(
"deltaxrun");
200 if (deltax && deltax->GetEntries()>0) {
202 fdoubleg->SetParameter(0,deltax->GetMean());
203 fdoubleg->SetParameter(2,deltax->GetRMS());
204 fdoubleg->SetParameter(4,deltax->GetRMS());
205 fdoubleg->SetParameter(1,deltax->GetMaximum());
206 fdoubleg->SetParameter(3,0.1*deltax->GetMaximum());
207 fdoubleg->SetParameter(5,0.1*deltax->GetMaximum());
208 const int result = deltax->Fit(fdoubleg,
"b",
"",-.05,.05);
211 sprintf(tresult,
"%d",result);
212 TText res; res.SetTextColor(kRed);
213 if(result!=0) res.DrawTextNDC(.2,.8,tresult);
215 int bin = deltaxsum->Fill(runlabel,fdoubleg->GetParameter(0));
216 deltaxsum->SetBinError(bin,fdoubleg->GetParError(0));
218 bin = deltaxmeansum->Fill(runlabel,deltax->GetMean());
219 deltaxmeansum->SetBinError(bin,deltax->GetMeanError());
222 plotfilename += outtrunk;
225 plotfilename += labfull;
226 plotfilename +=
"/deltaxrun_";
227 plotfilename += labfull;
231 plotfilename += runpath;
232 plotfilename +=
".gif";
233 gPad->Print(plotfilename.c_str());
237 TH1F* deltay = (TH1F*)castat.
getObject(
"deltayrun");
238 if (deltay && deltay->GetEntries()>0) {
240 fdoubleg->SetParameter(0,deltay->GetMean());
241 fdoubleg->SetParameter(2,deltay->GetRMS());
242 fdoubleg->SetParameter(4,deltay->GetRMS());
243 fdoubleg->SetParameter(1,deltay->GetMaximum());
244 fdoubleg->SetParameter(3,0.1*deltay->GetMaximum());
245 fdoubleg->SetParameter(5,0.1*deltay->GetMaximum());
246 const int result = deltay->Fit(fdoubleg,
"b",
"",-.05,.05);
249 sprintf(tresult,
"%d",result);
250 TText res; res.SetTextColor(kRed);
251 if(result!=0) res.DrawTextNDC(.2,.8,tresult);
253 int bin = deltaysum->Fill(runlabel,fdoubleg->GetParameter(0));
254 deltaysum->SetBinError(bin,fdoubleg->GetParError(0));
256 bin = deltaymeansum->Fill(runlabel,deltay->GetMean());
257 deltaymeansum->SetBinError(bin,deltay->GetMeanError());
260 plotfilename += outtrunk;
263 plotfilename += labfull;
264 plotfilename +=
"/deltayrun_";
265 plotfilename += labfull;
269 plotfilename += runpath;
270 plotfilename +=
".gif";
271 gPad->Print(plotfilename.c_str());
275 TH1F* deltaz = (TH1F*)castat.
getObject(
"deltazrun");
276 if (deltaz && deltaz->GetEntries()>0) {
280 int bin = deltazmeansum->Fill(runlabel,deltaz->GetMean());
281 deltazmeansum->SetBinError(bin,deltaz->GetMeanError());
284 plotfilename += outtrunk;
287 plotfilename += labfull;
288 plotfilename +=
"/deltazrun_";
289 plotfilename += labfull;
293 plotfilename += runpath;
294 plotfilename +=
".gif";
295 gPad->Print(plotfilename.c_str());
300 TProfile* deltaxvsz = (TProfile*)castat.
getObject(
"deltaxvszrun");
301 if (deltaxvsz && deltaxvsz->GetEntries()>0) {
304 plotfilename += outtrunk;
307 plotfilename += labfull;
308 plotfilename +=
"/deltaxvszrun_";
309 plotfilename += labfull;
313 plotfilename += runpath;
314 plotfilename +=
".gif";
315 gPad->Print(plotfilename.c_str());
319 TProfile* deltayvsz = (TProfile*)castat.
getObject(
"deltayvszrun");
320 if (deltayvsz && deltayvsz->GetEntries()>0) {
323 plotfilename += outtrunk;
326 plotfilename += labfull;
327 plotfilename +=
"/deltayvszrun_";
328 plotfilename += labfull;
332 plotfilename += runpath;
333 plotfilename +=
".gif";
334 gPad->Print(plotfilename.c_str());
339 TH1F* deltaxvsorb = (TH1F*)castat.
getObject(
"deltaxvsorbrun");
340 if (deltaxvsorb && deltaxvsorb->GetEntries()>0) {
343 plotfilename += outtrunk;
346 plotfilename += labfull;
347 plotfilename +=
"/deltaxvsorb_";
348 plotfilename += labfull;
352 plotfilename += runpath;
353 plotfilename +=
".gif";
354 gPad->Print(plotfilename.c_str());
357 TH1F* deltayvsorb = (TH1F*)castat.
getObject(
"deltayvsorbrun");
358 if (deltayvsorb && deltayvsorb->GetEntries()>0) {
361 plotfilename += outtrunk;
364 plotfilename += labfull;
365 plotfilename +=
"/deltayvsorb_";
366 plotfilename += labfull;
370 plotfilename += runpath;
371 plotfilename +=
".gif";
372 gPad->Print(plotfilename.c_str());
375 TH1F* deltazvsorb = (TH1F*)castat.
getObject(
"deltazvsorbrun");
376 if (deltazvsorb && deltazvsorb->GetEntries()>0) {
379 plotfilename += outtrunk;
382 plotfilename += labfull;
383 plotfilename +=
"/deltazvsorb_";
384 plotfilename += labfull;
388 plotfilename += runpath;
389 plotfilename +=
".gif";
390 gPad->Print(plotfilename.c_str());
396 gStyle->SetOptStat(1111);
397 gStyle->SetOptFit(0);
402 plotfilename = outtrunk;
405 plotfilename += labfull;
406 plotfilename +=
"/deltaxsum_";
407 plotfilename += labfull;
410 plotfilename +=
".gif";
412 TCanvas * cwidedeltax =
new TCanvas(plotfilename.c_str(),plotfilename.c_str(),1500,500);
414 deltaxsum->SetLineColor(kRed); deltaxsum->SetMarkerColor(kRed);
415 deltaxsum->GetYaxis()->SetRangeUser(-.002,.002);
416 deltaxsum->GetYaxis()->SetTitle(
"#Delta x (cm)");
418 deltaxmeansum->Draw(
"esame");
419 TLegend deltaxleg(.7,.8,.85,.9,
"#Delta(x)");
420 deltaxleg.AddEntry(deltaxsum,
"fitted mean",
"l");
421 deltaxleg.AddEntry(deltaxmeansum,
"aritm. mean",
"l");
423 gPad->Print(plotfilename.c_str());
426 plotfilename = outtrunk;
429 plotfilename += labfull;
430 plotfilename +=
"/deltaysum_";
431 plotfilename += labfull;
434 plotfilename +=
".gif";
436 TCanvas * cwidedeltay =
new TCanvas(plotfilename.c_str(),plotfilename.c_str(),1500,500);
438 deltaysum->SetLineColor(kRed); deltaysum->SetMarkerColor(kRed);
439 deltaysum->GetYaxis()->SetRangeUser(-.002,.002);
440 deltaysum->GetYaxis()->SetTitle(
"#Delta y (cm)");
442 deltaymeansum->Draw(
"esame");
443 TLegend deltayleg(.7,.8,.85,.9,
"#Delta(y)");
444 deltayleg.AddEntry(deltaysum,
"fitted mean",
"l");
445 deltayleg.AddEntry(deltaymeansum,
"aritm. mean",
"l");
447 gPad->Print(plotfilename.c_str());
451 plotfilename = outtrunk;
454 plotfilename += labfull;
455 plotfilename +=
"/deltazsum_";
456 plotfilename += labfull;
459 plotfilename +=
".gif";
461 TCanvas * cwidedeltaz =
new TCanvas(plotfilename.c_str(),plotfilename.c_str(),1500,500);
463 deltazmeansum->GetYaxis()->SetRangeUser(-2.,2.);
464 deltazmeansum->GetYaxis()->SetTitle(
"#Delta z (cm)");
465 deltazmeansum->Draw();
466 gPad->Print(plotfilename.c_str());
471 delete deltaxmeansum;
472 delete deltaymeansum;
473 delete deltazmeansum;
TObject * getObject(const char *name) const
void setPath(const char *path)
const std::vector< unsigned int > getRunList() const
void BSvsPVPlots(const char *fullname, const char *module, const char *label, const char *postfix, const char *shortname, const char *outtrunk)