ATLAS Offline Software
fillTRTHists.py
Go to the documentation of this file.
1 # ================================
2 # Fills the TRT Histograms
3 # Author John Alison <johnda@hep.upenn.edu>
4 
5 # In the text file, the following is the order of the information
6 # m_trt_barrel_ec, m_trt_layer_or_wheel, m_trt_phi_module, m_trt_straw_layer, (m_trt_straw), m_trt_x, m_trt_y, m_trt_z);
7 # The m_trt_straw is only filled if the detailed TRT txt file was created
8 for i in range(len(trtElements1)):
9 
10  # the index allows us to readin files produced with and without the detailed TRT setting with the same code
11 
12  # Get the position of the first geometry
13  xIndex = 4
14  yIndex = 5
15  zIndex = 6
16  if len(trtElements1[i]) == 8:
17  xIndex = 5
18  yIndex = 6
19  zIndex = 7
20 
21  trt_wheel = trtElements1[i][1]
22  trt_strawlayer = trtElements1[i][3]
23 
24  trt_x1 = trtElements1[i][xIndex]
25  trt_y1 = trtElements1[i][yIndex]
26  trt_z1 = trtElements1[i][zIndex]
27 
28  trt_x2 = trtElements2[i][xIndex]
29  trt_y2 = trtElements2[i][yIndex]
30  trt_z2 = trtElements2[i][zIndex]
31 
32  if abs(trtElements1[i][0]) == 1:
33  fillBarrelHists(trt_x1,trt_y1,trt_z1
34  ,trt_x2,trt_y2,trt_z2
35  ,trtHists
36  )
37 
38  # Fill TRT Trans can
39  if trtElements1[i][3] == 15:
40  if trtElements1[i][0] == -1:
41  trtTransCan[0].cd()
42  else:
43  trtTransCan[1].cd()
44  line.SetLineColor(kGreen+1)
45  line.DrawArrow(trt_x1,trt_y1,trt_x1+TRASL_FACTOR*(trt_x2-trt_x1),trt_y1+TRASL_FACTOR*(trt_y2-trt_y1),0.01,"")
46 
47  IDTransCan.cd()
48  if trt_z1 < 0:
49  line.SetLineColor(kGreen-2)
50  else:
51  line.SetLineColor(kGreen+2)
52  line.DrawArrow(trt_x1,trt_y1,trt_x1+TRASL_FACTOR*(trt_x2-trt_x1),trt_y1+TRASL_FACTOR*(trt_y2-trt_y1),0.01,"")
53 
54  # Save values for later drawing
55  trt_lay = trtElements1[i][1]
56  trt_phi = trtElements1[i][2]
57 
58  # C-Side
59  if trtElements1[i][0] == -1:
60 
61  x1_Cside[(trt_lay,trt_phi)] = trt_x1
62  y1_Cside[(trt_lay,trt_phi)] = trt_y1
63 
64  x2_Cside[(trt_lay,trt_phi)] = trt_x2
65  y2_Cside[(trt_lay,trt_phi)] = trt_y2
66 
67  # A-Side
68  else:
69 
70  x1_Aside[(trt_lay,trt_phi)] = trt_x1
71  y1_Aside[(trt_lay,trt_phi)] = trt_y1
72  z1_Aside[(trt_lay,trt_phi)] = trt_z1
73 
74  x2_Aside[(trt_lay,trt_phi)] = trt_x2
75  y2_Aside[(trt_lay,trt_phi)] = trt_y2
76 
77 
78  if len(drawTRTModules) > 0:
79  trt_bec = trtElements1[i][0]
80 
81  # Only Barrel for the moment
82  if abs(trt_bec) == 1:
83  trt_lay = trtElements1[i][1]
84  trt_phi = trtElements1[i][2]
85 
86  # Only draw the modules we care about
87  if (trt_lay, trt_phi) in drawTRTModules:
88 
89  #fill the hists
90  thisTRTHist = trtModuleHists[(trt_lay),(trt_phi)]
91  fillBarrelHists(trt_x1,trt_y1,trt_z1
92  ,trt_x2,trt_y2,trt_z2
93  ,thisTRTHist)
94 
95 
96  # Draw the Trans can
97  theseCans = trtModTransCan[(trt_lay),(trt_phi)]
98 
99  if trt_bec == -1:
100  theseCans[0].cd()
101  else:
102  theseCans[1].cd()
103 
104  line.SetLineColor(kGreen+1)
105  line.DrawArrow(trt_x1,trt_y1,trt_x1+TRASL_FACTOR*(trt_x2-trt_x1),trt_y1+TRASL_FACTOR*(trt_y2-trt_y1),0.01,"")
106 
107 
108  # Endcap A
109  if trtElements1[i][0] == 2:
110  fillEndcapHists(trt_x1,trt_y1,trt_z1
111  ,trt_x2,trt_y2,trt_z2
112  ,trtHists
113  ,2
114  )
115 
116 
117  drawStrawPlaneTransCan(2,trt_wheel,trt_strawlayer,trt_x1,trt_y1,trt_x2,trt_y2)
118 
119 
120  # Endcap C
121  if trtElements1[i][0] == -2:
122  fillEndcapHists(trt_x1,trt_y1,trt_z1
123  ,trt_x2,trt_y2,trt_z2
124  ,trtHists
125  ,0
126  )
127 
128  drawStrawPlaneTransCan(-2,trt_wheel,trt_strawlayer,trt_x1,trt_y1,trt_x2,trt_y2)
129 
comparisonUtils.fillBarrelHists
def fillBarrelHists(x1, y1, z1, x2, y2, z2, theHists)
Definition: comparisonUtils.py:5
comparisonUtils.fillEndcapHists
def fillEndcapHists(x1, y1, z1, x2, y2, z2, theHists, side)
Definition: comparisonUtils.py:65
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
calibdata.cd
cd
Definition: calibdata.py:51
comparisonUtils.drawStrawPlaneTransCan
def drawStrawPlaneTransCan(bec, wheel, strawlayer, x1, y1, x2, y2)
Definition: comparisonUtils.py:342