ATLAS Offline Software
Functions
python.h6prod_getxy Namespace Reference

Functions

def getXYInPolygon (s, nev0=1500)
 
def drawXYInPolygon (nev0=1500)
 
def getXYSetInPolygon (nev0=1500)
 Function returns two arrays with xCryo, yTable positions inside user defined shape (polygon) Points are placed in a rectangular grid with center in x0,y0 and grid step dx,dy. More...
 

Function Documentation

◆ drawXYInPolygon()

def python.h6prod_getxy.drawXYInPolygon (   nev0 = 1500)

Definition at line 17 of file h6prod_getxy.py.

17 def drawXYInPolygon(nev0=1500):
18  nevtot = 0
19  nevinwin = 0
20  xset,yset,nset = getXYSetInPolygon(nev0)
21  print ("Number of points ", len(xset), len(yset))
22  #histXY = ROOT.TH2F( 'clusE', 'clusE', 500, -500.0, 500.0, 500, -500., 500. )
23  histXY = ROOT.TH2F( 'clusE', 'clusE', 2000, -800.0, 800.0, 2000, -800., 800. )
24  histXY.SetStats(0)
25  histXY.SetTitle("")
26  for i in range(0,len(xset)):
27  #print ("nrun:",i+1," xCryo:",xset[i], "yTable:",yset[i])
28  print ('nrun %3d xCryo %5d yTable %5d nev %5d' % (i+1,xset[i], yset[i], nset[i]))
29  nevtot = nevtot + nset[i]
30  dist = sqrt(xset[i]*xset[i] + (70-yset[i])*(70-yset[i]))
31  if dist < 300:
32  nevinwin = nevinwin + nset[i]
33 
34  histXY.Fill(xset[i], yset[i])
35  c0 = ROOT.TCanvas( 'c0', 'c0', 800, 800 )
36  c0.SetFillColor(10)
37  c0.SetFillStyle(0)
38  c0.cd()
39  ROOT.gPad.SetGrid()
40  ROOT.gPad.SetLeftMargin(0.12)
41  ROOT.gPad.SetRightMargin(0.12)
42  ROOT.gPad.SetTopMargin(0.12)
43  ROOT.gPad.SetBottomMargin(0.12)
44  tc = ROOT.TEllipse(0,70,300)
45  tc.SetFillStyle(0)
46  tc.SetLineWidth(2)
47  histXY.SetMarkerStyle(20)
48  histXY.SetLineColor(2)
49  histXY.SetMarkerColor(2)
50  histXY.Draw()
51  tc.Draw()
52  #poly_np = 9
53  #poly_x = array('d',[0, 300, 150, 250, 0, -250, -150, -300, 0])
54  #poly_y = array('d',[320, 220, -80, -130, -280, -130, -80, 220, 320])
55  poly_np = 8
56  poly_x = array('d',[0, 500, 700, 60, -60, -700, -500, 0])
57  poly_y = array('d',[700, 600, 400, -400, -400, 400, 600, 700])
58  myPoly = ROOT.TPolyLine(poly_np, poly_x, poly_y)
59  myPoly.SetLineColor(4)
60  myPoly.SetLineWidth(2)
61  myPoly.Draw()
62 
63  #for i in range(0,500):
64  #x,y = getXYInPolygon(i)
65  #print ("nrun:",i+1," xCryo:",x, "yTable:",y)
66 
67  print ("nevtot:",nevtot, "in win:",nevinwin)
68  return c0, histXY, tc, myPoly
69 
70 
71 #def getXYInPolygon(s):
72 
73 

◆ getXYInPolygon()

def python.h6prod_getxy.getXYInPolygon (   s,
  nev0 = 1500 
)

Definition at line 10 of file h6prod_getxy.py.

10 def getXYInPolygon(s,nev0=1500):
11  xset,yset,nset = getXYSetInPolygon(nev0)
12  ss = s%(len(xset))
13  return xset[ss], yset[ss], nset[ss]
14 
15 
16 

◆ getXYSetInPolygon()

def python.h6prod_getxy.getXYSetInPolygon (   nev0 = 1500)

Function returns two arrays with xCryo, yTable positions inside user defined shape (polygon) Points are placed in a rectangular grid with center in x0,y0 and grid step dx,dy.

Definition at line 78 of file h6prod_getxy.py.

78 def getXYSetInPolygon(nev0=1500):
79  # this is our polygon drawn on xCryo, yTable plane in which we are going to place our cryostat and table
80  #poly_np = 9
81  #poly_x = array('i',[0, 300, 150, 250, 0, -250, -150, -300, 0])
82  #poly_y = array('i',[320, 220, -80, -130, -280, -130, -80, 220, 320])
83 
84  poly_np = 8
85  poly_x = array('i',[0, 500, 700, 60, -60, -700, -500, 0])
86  poly_y = array('i',[700, 600, 400, -400, -400, 400, 600, 700])
87 
88  # this is starting point of grid
89  x0 = 0
90  y0 = 0
91  # this is grid step
92  dx = 25
93  dy = 25
94  # this is number of events to simulate in points Y=-400 and Y=+400
95  #n_Ytop = 2000
96  #n_Ybot = 4000
97  n_Ytop = nev0
98  y_Ytop = 700
99  n_Ybot = nev0*2
100  y_Ybot = -400
101  print ("Initial number of events:", nev0, "y_Ytop:",y_Ytop, "n_Ytop:",n_Ytop, "y_Ybot:",y_Ybot, "n_Ybot:",n_Ybot)
102  # - - - - - -
103  # - 2 3 4 - -
104  # - 1 + 5 - -
105  # - 0 7 6 - -
106  # - - - - - -
107  #
108  xset = []
109  yset = []
110  nset = []
111  xset.append(x0)
112  yset.append(y0)
113  #nset.append((n_Ytop+(y0-400)*(n_Ytop-n_Ybot)/800)/100*100)
114  nset.append( (n_Ybot+(y0-y_Ybot)*(n_Ytop-n_Ybot)/(y_Ytop-y_Ybot))/10*10 )
115  for iRound in range(1,1000):
116  boxSide = 1+iRound*2
117  nPoints = (boxSide-1)*4
118  #print ("----------------------------------------")
119  #print ("iRound:", iRound, " boxSide ", boxSide, "nPoints ", nPoints)
120  nGoodPoints = 0
121  for iPoint in range(0, nPoints):
122  boxSideNum = iPoint/(boxSide-1)
123  boxSideStep = iPoint%(boxSide-1)
124  if boxSideNum == 0:
125  iX = x0 - iRound*dx
126  iY = y0 - iRound*dy + dy*boxSideStep
127  if boxSideNum == 1:
128  iX = x0 - iRound*dx + dx*boxSideStep
129  iY = y0 + iRound*dy
130  if boxSideNum == 2:
131  iX = x0 + iRound*dx
132  iY = y0 + iRound*dy - dy*boxSideStep
133  if boxSideNum == 3:
134  iX = x0 + iRound*dx - dx*boxSideStep
135  iY = y0 - iRound*dy
136  mt = ROOT.TMath
137  result = mt.IsInside(iX, iY, poly_np, poly_x, poly_y)
138  #print ("iPoint ", iPoint," from nPoints ",nPoints, " boxSideNum:",boxSideNum, " mod:", boxSideStep, " iX:", iX, " iY:", iY, result)
139  if result == 1:
140  nGoodPoints += 1
141  xset.append(iX)
142  yset.append(iY)
143  nset.append( (n_Ybot+(iY-y_Ybot)*(n_Ytop-n_Ybot)/(y_Ytop-y_Ybot))/10*10 )
144  #print ("nGoodPoints:", nGoodPoints, " nPoints:", nPoints)
145  if nGoodPoints == 0:
146  break
147 
148  return xset, yset, nset
149 
150 
151 #def getXYInRectangle(s):
152  #xmin=-240
153  #xmax=240
154  #ymin=-170
155  #ymax=181
156  #dx=100
157  #dy=100
158  #nx=(xmax-xmin)/dx + 1
159  #ny=(ymax-ymin)/dy + 1
160  #ss = s%(nx*ny)
161  #iy=ss/nx
162  #ix=ss%nx
163 
168 
169 
170 #def getXYInCircle(s):
171 
183 
184  #nx=(xmax-xmin)/dx + 1
185  #ny=(ymax-ymin)/dy + 1
186  #ntot = nx*ny
187  #xset = []
188  #yset = []
189  #for ix in range(0, int(nx)):
190  #for iy in range(0,int(ny)):
191  #x=xmin+ix*dx
192  #y=ymin+iy*dy
193  #dist = sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0))
194 
202 
python.h6prod_getxy.getXYInPolygon
def getXYInPolygon(s, nev0=1500)
Definition: h6prod_getxy.py:10
python.h6prod_getxy.drawXYInPolygon
def drawXYInPolygon(nev0=1500)
Definition: h6prod_getxy.py:17
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.h6prod_getxy.getXYSetInPolygon
def getXYSetInPolygon(nev0=1500)
Function returns two arrays with xCryo, yTable positions inside user defined shape (polygon) Points a...
Definition: h6prod_getxy.py:78
array