import sys, os, copy,math from math import sqrt pandapath = os.environ.get('PANDAPATH') sys.path.append(pandapath + '/macro/tpc/FOPI/python/argparse-1.2.1') sys.path.append(pandapath + '/macro/tpc/FOPI/mberger') import argparse, ROOT from functions import set_palette, openTree, thisIsTheEnd, getSlices import random ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine('gROOT->SetStyle("Plain")') ROOT.gROOT.LoadMacro("stlPYROOT.h+") set_palette() def draw_cov2D(cov,cog,col): tcov=ROOT.TMatrixDSym(2,cov.GetMatrixArray()) eigenproblem=ROOT.TMatrixDEigen(ROOT.TMatrixD(tcov)) eigenwert=eigenproblem.GetEigenValues() eigenvector=eigenproblem.GetEigenVectors() teigenvector=ROOT.TVector2(eigenvector[0][0],eigenvector[1][0]) teigenvector2=ROOT.TVector2(eigenvector[0][1],eigenvector[1][1]) eigenvector_i=ROOT.TMatrixD(ROOT.TMatrixD.kInverted,eigenvector) if eigenwert[0][0]!=0 and eigenwert[1][1]!=0: pcov=ROOT.TEllipse(cog.X(),cog.Y(),math.sqrt(eigenwert[0][0]),math.sqrt(eigenwert[1][1]),0,360,ROOT.TMath.RadToDeg()*teigenvector.Phi()) else: return False pcov.SetFillStyle(4000) pcov.SetLineColor(col) return pcov padShapePool=ROOT.TpcPadShapePool('tpc/parfiles/PadShapePrototype.dat','tpc/FOPI/par/padresponse.txt') padplane=ROOT.TpcPadPlane('tpc/parfiles/padPlane_FOPI.dat',padShapePool) padshapeCov=ROOT.TMatrixDSym(2) padshapeCov[0][0]=0.15**2 padshapeCov[1][1]=0.15**2 padx=ROOT.Double(0) pady=ROOT.Double(0) padplane.GetPadXY(0,padx,pady) print padx,pady dirvect=ROOT.TVectorD() dirvect.ResizeTo(2) dirvect[0]=0 dirvect[1]=1 projlength=padshapeCov.Similarity(dirvect) print projlength, sqrt(projlength) plane=ROOT.TH2D("padplane","padplane",300,padx-.2,padx+.2,300,pady-.2,pady+.2) plane.Draw() padplane.GetPad(0).Draw(2) Draw_padshapeCov=draw_cov2D(padshapeCov,ROOT.TVector3(padx,pady,0),3) Draw_padshapeCov.Draw() padshapeCov.Print() padshapeCov.Invert() padshapeCov.Print() thisIsTheEnd()