ATLAS Offline Software
Classes | Functions | Variables
fitman Namespace Reference

Classes

class  Plots
 

Functions

def logresult (cmd='', fitresult=None)
 
def tmpHist (what, wmin=-1e10, wmax=+1e10)
 

Variables

string __author__ = 'Juerg Beringer'
 
string __version__ = '$Id: fitman.py 721742 2016-02-03 23:34:44Z beringer $'
 
string __usage__
 
list qargv = [ ]
 
string qcmd = ' '.join(qargv)
 
 parser = OptionParser(usage=__usage__, version=__version__)
 
 dest
 
 default
 
 None
 
 help
 
 type
 
 action
 
 False
 
 options
 
 args
 
 cmdList = args
 
 srcFile = ROOT.TFile(options.srcNtName)
 
 srcNt = srcFile.Get(options.srcTreeName)
 
 nEntries = srcNt.GetEntries()
 
 dstFile = ROOT.TFile(options.ntName,'recreate')
 
 dstNt = ROOT.TTree(options.ntTree,'Vertices')
 
 bx = array('d',[0]); dstNt.Branch('x',bx,'x/D')
 
 by = array('d',[0]); dstNt.Branch('y',by,'y/D')
 
 bz = array('d',[0]); dstNt.Branch('z',bz,'z/D')
 
 bvxx = array('d',[0]); dstNt.Branch('vxx',bvxx,'vxx/D')
 
 bvyy = array('d',[0]); dstNt.Branch('vyy',bvyy,'vyy/D')
 
 bvxy = array('d',[0]); dstNt.Branch('vxy',bvxy,'vxy/D')
 
 bvxz = array('d',[0]); dstNt.Branch('vxz',bvxz,'vxz/D')
 
 bvyz = array('d',[0]); dstNt.Branch('vyz',bvyz,'vyz/D')
 
 bvzz = array('d',[0]); dstNt.Branch('vzz',bvzz,'vzz/D')
 
int nSelected = 0
 
int nWritten = 0
 
 maxVtxErr2 = options.maxvtxerr*options.maxvtxerr
 
 minVtxErr2 = options.minvtxerr*options.minvtxerr
 
 x = RooRealVar("x","x [mm]",-3,3)
 
 y = RooRealVar("y","y [mm]",-3,3)
 
 z = RooRealVar("z","z [mm]",-300,300)
 
 vxx = RooRealVar("vxx","vxx",-3,3)
 
 vyy = RooRealVar("vyy","vyy",-3,3)
 
 vxy = RooRealVar("vxy","vxy",-3,3)
 
 vxz = RooRealVar("vxz","vxz",-3,3)
 
 vyz = RooRealVar("vyz","vyz",-3,3)
 
 vzz = RooRealVar("vzz","vzz",-3,3)
 
 vtxDataFile = ROOT.TFile(options.ntName)
 
 vtxData = vtxDataFile.Get(options.ntTree)
 
def hx = tmpHist('x',-3.,3.)
 
def hy = tmpHist('y',-3.,3.)
 
def hz = tmpHist('z',-300.,300.)
 
 data = RooDataSet("data","data", vtxData, RooArgSet(x,y,z,vxx,vyy,vxy,vzz))
 
 mx = RooRealVar("mx","Mean x", hx.GetMean(), -2, 2)
 
 sx = RooRealVar("sx","Sigma x", hx.GetRMS(), 0, 1)
 
 ax = RooRealVar("ax","Tilt x", 0, -1e-3, 1e-3)
 
 my = RooRealVar("my","Mean y", hy.GetMean(), -2, 2)
 
 sy = RooRealVar("sy","Sigma y", hy.GetRMS(), 0, 1)
 
 ay = RooRealVar("ay","Tilt y", 0, -1e-3, 1e-3)
 
 mz = RooRealVar("mz","Mean z", hz.GetMean(), -300, 300)
 
 sz = RooRealVar("sz","Sigma z", hz.GetRMS(), 0, 100)
 
 k = RooRealVar("k","Error scale factor", 1, 0.0, 3)
 
 rho = RooRealVar("rho","Correlation coefficient", 0, -1, 1)
 
 f = RooRealVar("f", "Fraction of 1st Gauss", 0.9, 0., 1)
 
 mx2 = RooRealVar("mx2","Mean x", -0.05, -2, 2)
 
 sx2 = RooRealVar("sx2","Sigma x", 0.10, 0, 1)
 
 ax2 = RooRealVar("ax2","Tilt x", 0, -1e-3, 1e-3)
 
 my2 = RooRealVar("my2","Mean y", 1, -2, 2)
 
 sy2 = RooRealVar("sy2","Sigma y", 0.10, 0, 1)
 
 ay2 = RooRealVar("ay2","Tilt y", 0, -1e-3, 1e-3)
 
 mz2 = RooRealVar("mz2","Mean z", -3, -300, 300)
 
 sz2 = RooRealVar("sz2","Sigma z", 60, 0, 100)
 
 rho2 = RooRealVar("rho2","Correlation coefficient", 0, -1, 1)
 
 mux = RooFormulaVar("mux","@0+@1*(@2-@3)",RooArgList(mx,ax,z,mz))
 
 muy = RooFormulaVar("muy","@0+@1*(@2-@3)",RooArgList(my,ay,z,mz))
 
 cxx = RooFormulaVar("cxx","@0*@0+@1*@1*@2",RooArgList(sx,k,vxx))
 
 cxy = RooFormulaVar("cxy","@0*@1*@2+@3*@3*@4",RooArgList(rho,sx,sy,k,vxy))
 
 cyy = RooFormulaVar("cyy","@0*@0+@1*@1*@2",RooArgList(sy,k,vyy))
 
 czz = RooFormulaVar("czz","@0*@0",RooArgList(sz))
 
 czzv = RooFormulaVar("czz","@0*@0+@1",RooArgList(sz,vzz))
 
 mux2 = RooFormulaVar("mux2","@0+@1*(@2-@3)",RooArgList(mx2,ax,z,mz))
 
 muy2 = RooFormulaVar("muy2","@0+@1*(@2-@3)",RooArgList(my2,ay,z,mz))
 
 cxx2 = RooFormulaVar("cxx2","@0*@0+@1*@1*@2",RooArgList(sx2,k,vxx))
 
 cxy2 = RooFormulaVar("cxy2","@0*@1*@2+@3*@3*@4",RooArgList(rho,sx2,sy2,k,vxy))
 
 cyy2 = RooFormulaVar("cyy2","@0*@0+@1*@1*@2",RooArgList(sy2,k,vyy))
 
 czz2 = RooFormulaVar("czz","@0*@0",RooArgList(sz))
 
 dummyMatrix = ROOT.TMatrixDSym(3)
 
bool cmdOk = False
 
 fitmodel
 
 fitresult
 
 g1
 
 g2
 
 plots = Plots(whatList = ['x','y','z'])
 
 saveAsList
 
 gPadSaveAsList
 
 allCanvasDivs
 
 allCanvasSize
 

Function Documentation

◆ logresult()

def fitman.logresult (   cmd = '',
  fitresult = None 
)

Definition at line 133 of file fitman.py.

133 def logresult(cmd='',fitresult=None):
134  log = open('%s.txt' % options.name,'w')
135  if cmd:
136  log.write(cmd)
137  log.write('\n')
138  if fitresult:
139  out = ROOT.std.stringstream()
140  fitresult.printStream(out,fitresult.defaultPrintContents(''),fitresult.defaultPrintStyle(''))
141  log.write(out.str())
142  del out
143  log.close()
144 
145 

◆ tmpHist()

def fitman.tmpHist (   what,
  wmin = -1e10,
  wmax = +1e10 
)

Definition at line 146 of file fitman.py.

146 def tmpHist(what,wmin=-1e10,wmax=+1e10):
147  vtxData.Draw(what,'%s > %s && %s < %s' % (what,wmin,what,wmax),'goff')
148  h = ROOT.gROOT.FindObject('htemp')
149  print 'Histogram for %s: mean = %7.4f rms = %1.4f' % (what,h.GetMean(),h.GetRMS())
150  return h.Clone('tmp-'+what)
151 
152 
153 #
154 # Definition of plots
155 #

Variable Documentation

◆ __author__

string fitman.__author__ = 'Juerg Beringer'
private

Definition at line 9 of file fitman.py.

◆ __usage__

string fitman.__usage__
private
Initial value:
1 = """%prog [options] [cmd ...]
2 
3 Commands are:
4 
5  extract Extract selected vertices into vertex ntuple
6  (if given, must be first command)
7  stdfit Standard beam spot fit (except for outlier removal)
8  stdfitvzz Dito, but includes z resolution
9  mypdf Similar to stdfit, but uses dedicated BeamSpotPdf class
10  (fast, but doesn't implement all integrals for plotting yet)
11  2gauss Double Gaussian fit - NOT YET WORKING
12  plot[xyz] Plot data and fit of x, y, and z, or single plot
13  data Histograms of x, y, z
14  cov Histograms of vertex error covariance
15  vtxerr Histograms of vertex errors in x, y, z
16  vtxerrxy Histograms of vertex errors in x, y
17 """

Definition at line 11 of file fitman.py.

◆ __version__

string fitman.__version__ = '$Id: fitman.py 721742 2016-02-03 23:34:44Z beringer $'
private

Definition at line 10 of file fitman.py.

◆ action

fitman.action

Definition at line 87 of file fitman.py.

◆ allCanvasDivs

fitman.allCanvasDivs

Definition at line 659 of file fitman.py.

◆ allCanvasSize

fitman.allCanvasSize

Definition at line 667 of file fitman.py.

◆ args

fitman.args

Definition at line 110 of file fitman.py.

◆ ax

fitman.ax = RooRealVar("ax","Tilt x", 0, -1e-3, 1e-3)

Definition at line 522 of file fitman.py.

◆ ax2

fitman.ax2 = RooRealVar("ax2","Tilt x", 0, -1e-3, 1e-3)

Definition at line 538 of file fitman.py.

◆ ay

fitman.ay = RooRealVar("ay","Tilt y", 0, -1e-3, 1e-3)

Definition at line 525 of file fitman.py.

◆ ay2

fitman.ay2 = RooRealVar("ay2","Tilt y", 0, -1e-3, 1e-3)

Definition at line 541 of file fitman.py.

◆ bvxx

fitman.bvxx = array('d',[0]); dstNt.Branch('vxx',bvxx,'vxx/D')

Definition at line 413 of file fitman.py.

◆ bvxy

fitman.bvxy = array('d',[0]); dstNt.Branch('vxy',bvxy,'vxy/D')

Definition at line 415 of file fitman.py.

◆ bvxz

fitman.bvxz = array('d',[0]); dstNt.Branch('vxz',bvxz,'vxz/D')

Definition at line 416 of file fitman.py.

◆ bvyy

fitman.bvyy = array('d',[0]); dstNt.Branch('vyy',bvyy,'vyy/D')

Definition at line 414 of file fitman.py.

◆ bvyz

fitman.bvyz = array('d',[0]); dstNt.Branch('vyz',bvyz,'vyz/D')

Definition at line 417 of file fitman.py.

◆ bvzz

fitman.bvzz = array('d',[0]); dstNt.Branch('vzz',bvzz,'vzz/D')

Definition at line 418 of file fitman.py.

◆ bx

fitman.bx = array('d',[0]); dstNt.Branch('x',bx,'x/D')

Definition at line 410 of file fitman.py.

◆ by

fitman.by = array('d',[0]); dstNt.Branch('y',by,'y/D')

Definition at line 411 of file fitman.py.

◆ bz

fitman.bz = array('d',[0]); dstNt.Branch('z',bz,'z/D')

Definition at line 412 of file fitman.py.

◆ cmdList

fitman.cmdList = args

Definition at line 117 of file fitman.py.

◆ cmdOk

bool fitman.cmdOk = False

Definition at line 575 of file fitman.py.

◆ cxx

fitman.cxx = RooFormulaVar("cxx","@0*@0+@1*@1*@2",RooArgList(sx,k,vxx))

Definition at line 549 of file fitman.py.

◆ cxx2

fitman.cxx2 = RooFormulaVar("cxx2","@0*@0+@1*@1*@2",RooArgList(sx2,k,vxx))

Definition at line 558 of file fitman.py.

◆ cxy

fitman.cxy = RooFormulaVar("cxy","@0*@1*@2+@3*@3*@4",RooArgList(rho,sx,sy,k,vxy))

Definition at line 550 of file fitman.py.

◆ cxy2

fitman.cxy2 = RooFormulaVar("cxy2","@0*@1*@2+@3*@3*@4",RooArgList(rho,sx2,sy2,k,vxy))

Definition at line 559 of file fitman.py.

◆ cyy

fitman.cyy = RooFormulaVar("cyy","@0*@0+@1*@1*@2",RooArgList(sy,k,vyy))

Definition at line 551 of file fitman.py.

◆ cyy2

fitman.cyy2 = RooFormulaVar("cyy2","@0*@0+@1*@1*@2",RooArgList(sy2,k,vyy))

Definition at line 560 of file fitman.py.

◆ czz

fitman.czz = RooFormulaVar("czz","@0*@0",RooArgList(sz))

Definition at line 552 of file fitman.py.

◆ czz2

fitman.czz2 = RooFormulaVar("czz","@0*@0",RooArgList(sz))

Definition at line 561 of file fitman.py.

◆ czzv

fitman.czzv = RooFormulaVar("czz","@0*@0+@1",RooArgList(sz,vzz))

Definition at line 553 of file fitman.py.

◆ data

fitman.data = RooDataSet("data","data", vtxData, RooArgSet(x,y,z,vxx,vyy,vxy,vzz))

Definition at line 517 of file fitman.py.

◆ default

fitman.default

Definition at line 55 of file fitman.py.

◆ dest

fitman.dest

Definition at line 55 of file fitman.py.

◆ dstFile

fitman.dstFile = ROOT.TFile(options.ntName,'recreate')

Definition at line 408 of file fitman.py.

◆ dstNt

fitman.dstNt = ROOT.TTree(options.ntTree,'Vertices')

Definition at line 409 of file fitman.py.

◆ dummyMatrix

fitman.dummyMatrix = ROOT.TMatrixDSym(3)

Definition at line 565 of file fitman.py.

◆ f

fitman.f = RooRealVar("f", "Fraction of 1st Gauss", 0.9, 0., 1)

Definition at line 535 of file fitman.py.

◆ False

fitman.False

Definition at line 87 of file fitman.py.

◆ fitmodel

fitman.fitmodel
Initial value:
1 = ROOT.GenGauss3D("fitmodel","Full beam spot PDF",
2  RooArgList(x,y,z),
3  RooArgList(mux,muy,mz),
4  cxx,cxy,RooFit.RooConst(0),cyy,RooFit.RooConst(0),czz,
5  dummyMatrix)

Definition at line 584 of file fitman.py.

◆ fitresult

fitman.fitresult
Initial value:
1 = fitmodel.fitTo(data,RooFit.ConditionalObservables(RooArgSet(vxx,vyy,vxy)),
2  RooFit.NumCPU(options.nCpu), RooFit.Timer(kTRUE), RooFit.Save())

Definition at line 590 of file fitman.py.

◆ g1

fitman.g1
Initial value:
1 = ROOT.GenGauss3D("g1","Full beam spot PDF",
2  RooArgList(x,y,z),
3  RooArgList(mux,muy,mz),
4  cxx,cxy,RooFit.RooConst(0),cyy,RooFit.RooConst(0),czz,
5  dummyMatrix)

Definition at line 619 of file fitman.py.

◆ g2

fitman.g2
Initial value:
1 = ROOT.GenGauss3Dclone("g2","Full beam spot PDF",
2  RooArgList(x,y,z),
3  RooArgList(mux,muy,mz),
4  cxx2,cxy2,RooFit.RooConst(0),cyy2,RooFit.RooConst(0),czz2,
5  dummyMatrix)

Definition at line 624 of file fitman.py.

◆ gPadSaveAsList

fitman.gPadSaveAsList

Definition at line 640 of file fitman.py.

◆ help

fitman.help

Definition at line 55 of file fitman.py.

◆ hx

def fitman.hx = tmpHist('x',-3.,3.)

Definition at line 514 of file fitman.py.

◆ hy

def fitman.hy = tmpHist('y',-3.,3.)

Definition at line 515 of file fitman.py.

◆ hz

def fitman.hz = tmpHist('z',-300.,300.)

Definition at line 516 of file fitman.py.

◆ k

fitman.k = RooRealVar("k","Error scale factor", 1, 0.0, 3)

Definition at line 528 of file fitman.py.

◆ maxVtxErr2

fitman.maxVtxErr2 = options.maxvtxerr*options.maxvtxerr

Definition at line 422 of file fitman.py.

◆ minVtxErr2

fitman.minVtxErr2 = options.minvtxerr*options.minvtxerr

Definition at line 424 of file fitman.py.

◆ mux

fitman.mux = RooFormulaVar("mux","@0+@1*(@2-@3)",RooArgList(mx,ax,z,mz))

Definition at line 547 of file fitman.py.

◆ mux2

fitman.mux2 = RooFormulaVar("mux2","@0+@1*(@2-@3)",RooArgList(mx2,ax,z,mz))

Definition at line 556 of file fitman.py.

◆ muy

fitman.muy = RooFormulaVar("muy","@0+@1*(@2-@3)",RooArgList(my,ay,z,mz))

Definition at line 548 of file fitman.py.

◆ muy2

fitman.muy2 = RooFormulaVar("muy2","@0+@1*(@2-@3)",RooArgList(my2,ay,z,mz))

Definition at line 557 of file fitman.py.

◆ mx

fitman.mx = RooRealVar("mx","Mean x", hx.GetMean(), -2, 2)

Definition at line 520 of file fitman.py.

◆ mx2

fitman.mx2 = RooRealVar("mx2","Mean x", -0.05, -2, 2)

Definition at line 536 of file fitman.py.

◆ my

fitman.my = RooRealVar("my","Mean y", hy.GetMean(), -2, 2)

Definition at line 523 of file fitman.py.

◆ my2

fitman.my2 = RooRealVar("my2","Mean y", 1, -2, 2)

Definition at line 539 of file fitman.py.

◆ mz

fitman.mz = RooRealVar("mz","Mean z", hz.GetMean(), -300, 300)

Definition at line 526 of file fitman.py.

◆ mz2

fitman.mz2 = RooRealVar("mz2","Mean z", -3, -300, 300)

Definition at line 542 of file fitman.py.

◆ nEntries

fitman.nEntries = srcNt.GetEntries()

Definition at line 375 of file fitman.py.

◆ None

fitman.None

Definition at line 55 of file fitman.py.

◆ nSelected

int fitman.nSelected = 0

Definition at line 419 of file fitman.py.

◆ nWritten

int fitman.nWritten = 0

Definition at line 420 of file fitman.py.

◆ options

fitman.options

Definition at line 110 of file fitman.py.

◆ parser

fitman.parser = OptionParser(usage=__usage__, version=__version__)

Definition at line 54 of file fitman.py.

◆ plots

fitman.plots = Plots(whatList = ['x','y','z'])

Definition at line 638 of file fitman.py.

◆ qargv

list fitman.qargv = [ ]

Definition at line 38 of file fitman.py.

◆ qcmd

string fitman.qcmd = ' '.join(qargv)

Definition at line 47 of file fitman.py.

◆ rho

fitman.rho = RooRealVar("rho","Correlation coefficient", 0, -1, 1)

Definition at line 532 of file fitman.py.

◆ rho2

fitman.rho2 = RooRealVar("rho2","Correlation coefficient", 0, -1, 1)

Definition at line 544 of file fitman.py.

◆ saveAsList

fitman.saveAsList

Definition at line 639 of file fitman.py.

◆ srcFile

fitman.srcFile = ROOT.TFile(options.srcNtName)

Definition at line 373 of file fitman.py.

◆ srcNt

fitman.srcNt = srcFile.Get(options.srcTreeName)

Definition at line 374 of file fitman.py.

◆ sx

fitman.sx = RooRealVar("sx","Sigma x", hx.GetRMS(), 0, 1)

Definition at line 521 of file fitman.py.

◆ sx2

fitman.sx2 = RooRealVar("sx2","Sigma x", 0.10, 0, 1)

Definition at line 537 of file fitman.py.

◆ sy

fitman.sy = RooRealVar("sy","Sigma y", hy.GetRMS(), 0, 1)

Definition at line 524 of file fitman.py.

◆ sy2

fitman.sy2 = RooRealVar("sy2","Sigma y", 0.10, 0, 1)

Definition at line 540 of file fitman.py.

◆ sz

fitman.sz = RooRealVar("sz","Sigma z", hz.GetRMS(), 0, 100)

Definition at line 527 of file fitman.py.

◆ sz2

fitman.sz2 = RooRealVar("sz2","Sigma z", 60, 0, 100)

Definition at line 543 of file fitman.py.

◆ type

fitman.type

Definition at line 57 of file fitman.py.

◆ vtxData

fitman.vtxData = vtxDataFile.Get(options.ntTree)

Definition at line 512 of file fitman.py.

◆ vtxDataFile

fitman.vtxDataFile = ROOT.TFile(options.ntName)

Definition at line 511 of file fitman.py.

◆ vxx

fitman.vxx = RooRealVar("vxx","vxx",-3,3)

Definition at line 504 of file fitman.py.

◆ vxy

fitman.vxy = RooRealVar("vxy","vxy",-3,3)

Definition at line 506 of file fitman.py.

◆ vxz

fitman.vxz = RooRealVar("vxz","vxz",-3,3)

Definition at line 507 of file fitman.py.

◆ vyy

fitman.vyy = RooRealVar("vyy","vyy",-3,3)

Definition at line 505 of file fitman.py.

◆ vyz

fitman.vyz = RooRealVar("vyz","vyz",-3,3)

Definition at line 508 of file fitman.py.

◆ vzz

fitman.vzz = RooRealVar("vzz","vzz",-3,3)

Definition at line 509 of file fitman.py.

◆ x

fitman.x = RooRealVar("x","x [mm]",-3,3)

Definition at line 501 of file fitman.py.

◆ y

fitman.y = RooRealVar("y","y [mm]",-3,3)

Definition at line 502 of file fitman.py.

◆ z

fitman.z = RooRealVar("z","z [mm]",-300,300)

Definition at line 503 of file fitman.py.

fitman.logresult
def logresult(cmd='', fitresult=None)
Definition: fitman.py:133
fitman.tmpHist
def tmpHist(what, wmin=-1e10, wmax=+1e10)
Definition: fitman.py:146
Trk::open
@ open
Definition: BinningType.h:40