import ROOT def setMarker(vec,style,color,size): marker=ROOT.TPolyMarker() marker.SetPoint(0,vec.X(),vec.Y()) marker.SetMarkerStyle(style) marker.SetMarkerColor(color) marker.SetMarkerSize(size) return marker def setLine(start,stop,color=1,size=1): line=ROOT.TLine(start.X(), start.Y(), stop.X(), stop.Y()) line.SetLineColor(color) line.SetLineWidth(size) return line ROOT.gROOT.ProcessLine(".x rootlogon.C") ROOT.gROOT.ProcessLine("gStyle->SetPalette(1)") ROOT.gROOT.LoadMacro("stlPYROOT.h+") padShapePool=ROOT.TpcPadShapePool('tpc/parfiles/PadShapePrototype.dat','tpc/FOPI/par/padresponse.txt') padplane=ROOT.TpcPadPlane('tpc/parfiles/padPlane_FOPI.dat',padShapePool) pad=padplane.GetPad(0) print pad.GetArea() normal=ROOT.TVector3(0,1,0) origin=ROOT.TVector3(2.46817-0.1,-14.625,20) direction=ROOT.TVector3(0,0,0) offset=ROOT.TVector3(0,0,0) pad.FindIntersectionLine(origin,normal,offset,direction) print 'offset' offset.Print() print 'direction' direction.Print() int1=ROOT.TVector3(0,0,0) int2=ROOT.TVector3(0,0,0) print 'intersection:',pad.IntersectWithPlane(origin,normal,int1,int2) int1.Print() int2.Print() canvas=ROOT.TCanvas('c','c',700,700) hist=ROOT.TH2D("h","pad",100,pad.x()-0.2,pad.x()+0.2,100,pad.y()-0.2,pad.y()+0.2) hist.Draw() pad.Draw(1) draw_origin=setMarker(origin,20,2,1) draw_origin.Draw() draw_normal=setLine(origin,origin+normal,2,1) draw_normal.Draw() p1=ROOT.TVector3(direction) p1*=30 p1+=offset p2=ROOT.TVector3(direction) p2*=-30 p2+=offset p1.Print() p2.Print() draw_projection=setLine(p1,p2,3,1) draw_projection.Draw() draw_intersect1=setMarker(int1,20,6,1) draw_intersect2=setMarker(int2,20,6,1) draw_intersect1.Draw() draw_intersect2.Draw() print 'postion of intersection0: ({0},{1})'.format(int1.X(),int1.Y()) print 'postion of intersection1: ({0},{1})'.format(int2.X(),int2.Y()) for i in range(pad.GetNBoundaryPoints()): print 'position of vertex {0}: ({1},{2})'.format(i,pad.GetBoundaryPoint(i)[0],pad.GetBoundaryPoint(i)[1]) print 'position of the pad: ({0},{1})'.format(pad.x(),pad.y()) print 'and the area fraction above plane is:{0}'.format(pad.GetAreaFractionBelowPlane(origin,normal)) u=raw_input()