589 """History of variable what vs LB or time."""
590 ROOT.gStyle.SetOptStat(0)
592 calc = BeamSpotAverage([what],weightedAverage=
not options.simpleaverage)
595 arescale =
varDef(what,
'arescale',1.0)
597 if b.sigmaX < 0.01
or b.sigmaY < 0.01:
598 print (
"OUTLIER ", b.run, b.lbStart, b.lbEnd, b.sigmaX, b.sigmaY)
599 if not b.bcid
in grDict:
600 grDict[b.bcid] = BeamSpotGraph(timeAxis=options.timeaxis, separationAxis=options.separation)
603 grDict[b.bcid].
add(b,what,arescale)
607 print (
'Plotting data from %i BCID ...\n' % len(grDict))
614 for gr
in [grDict.get(bcid)
for bcid
in grDict]:
615 xmin =
min(xmin,gr.xmin)
616 xmax =
max(xmax,gr.xmax)
617 ymin =
min(ymin,gr.ymin)
618 ymax =
max(ymax,gr.ymax)
627 xmax += .05*h
if len(grDict)==1
else 0.3*h
629 h = (ymax-ymin)/2*options.yscale
632 if options.xmin!=
None:
633 xmin = time.mktime(time.strptime(options.xmin,
'%b %d %H:%M:%S %Y'))
if options.timeaxis
else float(options.xmin)
634 if options.xmax!=
None:
635 xmax = time.mktime(time.strptime(options.xmax,
'%b %d %H:%M:%S %Y'))
if options.timeaxis
else float(options.xmax)
637 ymin =
varDef(what,
'min',-100)
638 ymax =
varDef(what,
'max',+100)
639 if options.ymin!=
None:
641 if options.ymax!=
None:
646 atit =
';%s;%s' % (timeLabel,
varDef(what,
'atit',what))
647 elif options.separation:
648 atit =
';%s;%s' % (
'Nominal Separation [mm]',
varDef(what,
'atit',what))
650 atit =
';%s;%s' % (
'Luminosity block number',
varDef(what,
'atit',what))
653 ROOT.gPad.SetLogy(options.logy)
655 xAxis = frame.GetXaxis()
656 yAxis = frame.GetYaxis()
657 xAxis.SetTimeDisplay(1)
662 xAxis.SetTimeOffset(0)
664 if (xmax-xmin)/86400 < 1:
665 xAxis.SetTimeFormat(
'%H:%M')
672 xAxis.SetTimeFormat(
'%b %d')
674 xAxis.SetTimeFormat(
'#splitline{%b %d}{%H:%M}')
675 xAxis.SetLabelOffset(0.02)
676 xAxis.SetTitleOffset(1.6)
678 xAxis.SetLabelSize(options.lsize)
679 xAxis.SetTitleSize(options.lsize)
680 yAxis.SetLabelSize(options.lsize)
681 yAxis.SetTitleSize(options.lsize)
683 xAxis.SetLabelSize(0.044)
685 xAxis.SetTimeFormat(options.adatefmt)
687 xAxis.SetNdivisions(options.ndivs,0)
688 frame.LabelsOption(
'd',
'X')
690 if options.xtitoffset:
691 xAxis.SetTitleOffset(options.xtitoffset)
692 if options.ytitoffset:
693 yAxis.SetTitleOffset(options.ytitoffset)
707 legendList.append([b,options.alegend,
'FL'])
708 legendList.append([
None,
'%s %s #pm %s %s' % (
fmtVal(what,mean,
True),
varDef(what,
'units'),
713 for bcid
in sorted(grDict.keys()):
717 name = what
if bcid==0
else '%s-bcid%04i' % (what,bcid)
718 tgraph = self.protect( gr.getTGraph(name) )
721 if options.tgraphfile:
722 print (
'Saving TGraphErrors',tgraph.GetName(),
'to file',options.tgraphfile)
723 tgraphfile = ROOT.TFile(options.tgraphfile,
'UPDATE')
729 tgraph.SetMarkerSize(options.msize
if options.msize
else 0.8)
731 legendList.append([tgraph,options.plegend,
'PLE'])
733 tgraph.SetMarkerColor(styleFactory.nextColorStyle())
734 tgraph.SetMarkerStyle(styleFactory.nextMarkerStyle())
735 tgraph.SetMarkerSize(options.msize
if options.msize
else 1.2)
736 if len(legendList)<options.maxlegends:
737 text =
'All' if bcid==0
else 'BCID %i' % bcid
738 legendList.append([tgraph,text,
'PLE'])
742 if len(grDict)>options.maxlegends:
743 legendList.append([
None,
'...',
''])
746 if options.fit
and len(grDict)==1:
747 ROOT.gStyle.SetOptFit(1111)
749 tgraph.Fit(options.fit,
'',
'SAME', gr.xmin,gr.xmax)
752 legendX = 0.6
if len(grDict)==1
else 0.8
753 self.writeText(what,legendList
if not options.public
else [],
not options.public,legendX=legendX)