18 |
|
#include <vector> |
19 |
|
#include <map> |
20 |
|
#include <string> |
21 |
+ |
#include "TStyle.h" |
22 |
+ |
#include "TPaveText.h" |
23 |
+ |
#include "TLegend.h" |
24 |
|
|
25 |
|
using namespace std; |
26 |
|
typedef map<unsigned int, unsigned int> RunNumberMap; |
46 |
|
if ( it>0 ) { |
47 |
|
fg.SetRange(pars[1]-nSigRange*pars[2], |
48 |
|
pars[1]+nSigRange*pars[2]); |
49 |
< |
// if ( dbg ) { |
50 |
< |
// cout << "Setting range to " << pars[1]-nSigRange*pars[2] |
51 |
< |
// << " " << pars[1]+nSigRange*pars[2] << endl; |
52 |
< |
// } |
49 |
> |
// if ( dbg ) { |
50 |
> |
// cout << "Setting range to " << pars[1]-nSigRange*pars[2] |
51 |
> |
// << " " << pars[1]+nSigRange*pars[2] << endl; |
52 |
> |
// } |
53 |
|
} |
54 |
|
else { |
55 |
|
fg.SetRange(slice->GetXaxis()->GetXmin(), |
56 |
|
slice->GetXaxis()->GetXmax()); |
57 |
< |
// if ( dbg ) { |
58 |
< |
// cout << "Setting range to " << slice->GetXaxis()->GetXmin() |
59 |
< |
// << " " << slice->GetXaxis()->GetXmax() << endl; |
60 |
< |
// } |
57 |
> |
// if ( dbg ) { |
58 |
> |
// cout << "Setting range to " << slice->GetXaxis()->GetXmin() |
59 |
> |
// << " " << slice->GetXaxis()->GetXmax() << endl; |
60 |
> |
// } |
61 |
|
} |
62 |
|
if ( dbg ) |
63 |
|
slice->Fit(&fg,"QLR+"); |
153 |
|
hwidth->SetBinError(ib,epars[2]); |
154 |
|
} |
155 |
|
// keep failing fits for debugging |
156 |
< |
// if ( converged ) delete slice; |
156 |
> |
// if ( converged ) delete slice; |
157 |
|
xhmean->SetBinLabel(ib,xhisto->GetBinLabel(ib)); |
158 |
|
xhwidth->SetBinLabel(ib,xhisto->GetBinLabel(ib)); |
159 |
|
} |
169 |
|
TAxis* axis = histo->GetXaxis(); |
170 |
|
for ( RunNumberMap::const_iterator i=runNumbers.begin(); |
171 |
|
i!=runNumbers.end(); ++i ) { |
172 |
< |
sprintf(label,"%d",(*i).first); |
172 |
> |
if ((*i).first == 124120 || (*i).first == 124275) |
173 |
> |
sprintf(label,"%d %s",(*i).first," (2.36 TeV)"); |
174 |
> |
else |
175 |
> |
sprintf(label,"%d",(*i).first); |
176 |
|
axis->SetBinLabel((*i).second+1,label); |
177 |
|
} |
178 |
|
} |
234 |
|
string pvTitle("pv.VsRunMean"); |
235 |
|
pvTitle.replace(2,1,1,coord[ic]); |
236 |
|
TH1* pvVsRun = (TH1*)gROOT->FindObject(pvTitle.c_str()); |
237 |
< |
pvVsRun->SetMarkerStyle(20); |
237 |
> |
|
238 |
> |
Double_t yMin,yMax; |
239 |
> |
if (ic == 2){ |
240 |
> |
yMax=pvVsRun->GetMaximum()+0.4; |
241 |
> |
yMin=pvVsRun->GetMinimum()-0.4; |
242 |
> |
} |
243 |
> |
else { |
244 |
> |
yMax=pvVsRun->GetMaximum()+0.01; |
245 |
> |
yMin=pvVsRun->GetMinimum()-0.005; |
246 |
> |
} |
247 |
> |
|
248 |
> |
pvVsRun->GetYaxis()->SetRangeUser(yMin,yMax); |
249 |
> |
pvVsRun->GetXaxis()->LabelsOption("u"); |
250 |
> |
pvVsRun->GetXaxis()->SetTitle("Run"); |
251 |
> |
pvVsRun->GetYaxis()->SetTitle(TString(coord[ic])+" (cm)"); |
252 |
|
pvVsRun->Draw(); |
253 |
|
bsVsRun->SetFillStyle(1001); |
254 |
|
bsVsRun->SetFillColor(7); |
255 |
+ |
// bsVsRun->SetMarkerStyle(21); |
256 |
+ |
bsVsRun->SetMarkerColor(7); |
257 |
+ |
bsVsRun->SetLineColor(7); |
258 |
|
bsVsRun->Draw("E2 same"); |
259 |
|
pvVsRun->Draw("same"); |
260 |
+ |
|
261 |
+ |
TPaveText *ppt= new TPaveText(.42,.7,.82,.86,"NDC"); |
262 |
+ |
ppt->AddText("CMS Preliminary 2009"); |
263 |
+ |
ppt->SetTextAlign(12); |
264 |
+ |
ppt->SetTextFont(62); |
265 |
+ |
ppt->SetTextSize(0.045); |
266 |
+ |
ppt->SetBorderSize(0); |
267 |
+ |
ppt->SetFillStyle(0); |
268 |
+ |
ppt->Draw(); |
269 |
+ |
|
270 |
+ |
TLegend*l0=new TLegend(0.45,0.6,0.65,0.7); |
271 |
+ |
l0->SetFillColor(0); |
272 |
+ |
l0->SetBorderSize(0); |
273 |
+ |
l0->AddEntry(pvVsRun," PrimaryVertex","p"); |
274 |
+ |
l0->AddEntry(bsVsRun," Beam Spot","f"); |
275 |
+ |
l0->Draw(); |
276 |
+ |
|
277 |
+ |
c->Print(TString(canvasTitle)+".png"); |
278 |
+ |
|
279 |
|
} |
280 |
|
} |
281 |
|
|
284 |
|
// |
285 |
|
void pvHistory (const vector<string>& fileNames) { |
286 |
|
|
287 |
+ |
gROOT->SetStyle("CMS"); |
288 |
|
fwlite::ChainEvent ev(fileNames); |
289 |
|
|
290 |
|
fwlite::Handle< reco::BeamSpot > bsHandle; |
336 |
|
int nev(0); |
337 |
|
for( ev.toBegin(); !ev.atEnd(); ++ev) { |
338 |
|
int run = ev.id().run(); |
339 |
< |
// if ( (++nev)%1000 == 0 ) cout << "processing record " << nev << " ( run " |
340 |
< |
// << ev.id().run() << " " << " evt " |
341 |
< |
// << ev.id().event() << " )" << endl; |
339 |
> |
// if ( (++nev)%1000 == 0 ) cout << "processing record " << nev << " ( run " |
340 |
> |
// << ev.id().run() << " " << " evt " |
341 |
> |
// << ev.id().event() << " )" << endl; |
342 |
|
// |
343 |
|
// update bin index if run changed |
344 |
|
// |
351 |
|
idx = (*irun).second; |
352 |
|
} |
353 |
|
lastRun = run; |
354 |
< |
// cout << "Run " << run << " idx " << idx << endl; |
354 |
> |
// cout << "Run " << run << " idx " << idx << endl; |
355 |
|
} |
356 |
|
if ( idx<0 ) continue; |
357 |
|
|
421 |
|
TH1* pvzMean; TH1* pvzWidth; |
422 |
|
fitRunHistogram(pvzVsRun,pvzMean,pvzWidth); |
423 |
|
|
424 |
< |
// cout << pvxMean << endl; |
425 |
< |
// cout << pvxMean->GetNbinsX() << " " << pvxMean->GetXaxis() << endl; |
424 |
> |
// cout << pvxMean << endl; |
425 |
> |
// cout << pvxMean->GetNbinsX() << " " << pvxMean->GetXaxis() << endl; |
426 |
|
// |
427 |
|
// summary table |
428 |
|
// |
461 |
|
// |
462 |
|
// plot inidividual histograms / run |
463 |
|
// |
464 |
< |
// for ( RunNumberMap::iterator i=runNumberIndices.begin(); |
465 |
< |
// i!=runNumberIndices.end(); ++i ) { |
466 |
< |
// plotRun('x',(*i).first); |
467 |
< |
// plotRun('y',(*i).first); |
468 |
< |
// plotRun('z',(*i).first); |
469 |
< |
// } |
464 |
> |
// for ( RunNumberMap::iterator i=runNumberIndices.begin(); |
465 |
> |
// i!=runNumberIndices.end(); ++i ) { |
466 |
> |
// plotRun('x',(*i).first); |
467 |
> |
// plotRun('y',(*i).first); |
468 |
> |
// plotRun('z',(*i).first); |
469 |
> |
// } |
470 |
|
|
471 |
|
} |
472 |
|
// |
476 |
|
vector<string> fileNames(1,fileName); |
477 |
|
pvHistory(fileNames); |
478 |
|
} |
479 |
+ |
|