1 from __future__
import print_function
2 from ROOT
import TStyle, kWhite, kTRUE
3 from ROOT
import gROOT, gStyle
4 from ROOT
import kGray, kAzure, kMagenta, kOrange, kWhite
5 from ROOT
import kRed, kBlue, kGreen, kPink, kYellow
6 from ROOT
import TLine, TLatex, TColor
8 from collections
import namedtuple, OrderedDict
9 from math
import sin, cos, tan, atan, exp, pi
10 from array
import array
12 from Validation.Geometry.plot_utils
import Plot_params
15 plots.setdefault(
'x_vs_eta',
Plot_params(10,
'#eta',
'x/X_{0}', 0.0, 145., -4.0, 4.0,
'', 0, 0., 0., 0, 1))
16 plots.setdefault(
'x_vs_phi',
Plot_params(20,
'#varphi [rad]',
'x/X_{0}', 0.0, 6.2, -4.0, 4.0,
'', 0, 0., 0., 0, 1))
17 plots.setdefault(
'x_vs_R',
Plot_params(40,
'R [cm]',
'x/X_{0}', 0.0, 70.0, 0.0, 1200.0,
'', 0, 0., 0., 0, 1))
18 plots.setdefault(
'l_vs_eta',
Plot_params(10010,
'#eta',
'x/#lambda_{I}', 0.0, 22.8, -4.0, 4.0,
'', 0, 0., 0., 0, 1))
19 plots.setdefault(
'l_vs_phi',
Plot_params(10020,
'#varphi [rad]',
'x/#lambda_{I}', 0.0, 1.2, -4.0, 4.0,
'', 0, 0., 0., 0, 1))
20 plots.setdefault(
'l_vs_R',
Plot_params(10040,
'R [cm]',
'x/#lambda_{I}', 0.0, 7.5, 0.0, 1200.0,
'', 0, 0., 0., 0, 1))
21 plots.setdefault(
'x_vs_eta_vs_phi',
Plot_params(30,
'#eta',
'#varphi', 0., 0., 0., 0.,
'x/X_{0}', 0, -1., -1., 0, 1))
22 plots.setdefault(
'l_vs_eta_vs_phi',
Plot_params(10030,
'#eta',
'#varphi', 0., 0., 0., 0.,
'x/#lambda_{I}', 0, -1, -1, 0, 1))
23 plots.setdefault(
'x_vs_z_vs_Rsum',
Plot_params(50,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'#Sigmax/X_{0}', 1, -1., -1., 0, 0))
24 plots.setdefault(
'x_vs_z_vs_Rsumcos',
Plot_params(52,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'#Sigmax/X_{0}', 1, -1., -1., 0, 0))
26 plots.setdefault(
'x_vs_z_vs_Rloc',
Plot_params(70,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'x/X_{0}', 1, -1., -1., 0, 0))
27 plots.setdefault(
'x_vs_z_vs_Rloccos',
Plot_params(72,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'x/X_{0}', 1, -1., -1., 0, 0))
28 plots.setdefault(
'l_vs_z_vs_Rsum',
Plot_params(10050,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'#Sigmax/#lambda_{I}', 1, -1., -1., 0, 0))
29 plots.setdefault(
'l_vs_z_vs_Rsumcos',
Plot_params(10052,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'#Sigmax/#lambda_{I}', 1, -1., -1., 0, 0))
30 plots.setdefault(
'l_vs_z_vs_R',
Plot_params(10060,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'1/#lambda_{I}', 1, -1., -1., 0, 0))
31 plots.setdefault(
'l_vs_z_vs_Rloc',
Plot_params(10070,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'x/#lambda_{I}', 1, -1., -1., 0, 0))
32 plots.setdefault(
'l_vs_z_vs_Rloccos',
Plot_params(10072,
'z [mm]',
'R [mm]', 0., 0., 0., 0.,
'x/#lambda_{I}', 1, -1., -1., 0, 0))
33 plots.setdefault(
'x_over_l_vs_eta',
Plot_params(10,
'#eta',
'(x/X_{0})/(x/#lambda_{I})', 0., 0., 0., 0.,
'', 0, -1, -1, 0, 0))
34 plots.setdefault(
'x_over_l_vs_phi',
Plot_params(20,
'#varphi [rad]',
'(x/X_{0})/(x/#lambda_{I})', 0., 0., 0., 0.,
'', 0, -1, -1, 0, 0))
37 _LABELS2COMPS = {
'BeamPipe':
'BEAM',
42 'EndcapTimingLayer':
'EndcapTimingLayer',
43 'Neutron Moderator + Thermal Screen' :
'CALOECTSModerator',
44 'HGCal + HGCal Service + Thermal Screen' :
'CALOECTSRear',
45 'Solenoid Magnet' :
'MGNT',
46 'Muon Wheels and Cables' :
'MB',
49 'FromVertexToBackOfHGCal' : [
'BEAM',
'Tracker',
'ECAL',
'HCal',
'EndcapTimingLayer',
'CALOECTSModerator',
'CALOECTSRear',
'MGNT',
'MB'],
52 'HGCalHE': [
'HGCalHEsil',
'HGCalHEmix']
62 COMPOUNDS = OrderedDict()
63 COMPOUNDS[
"HGCal"] = [
"HGCal"]
64 COMPOUNDS[
"HGCalEE"] = [
"HGCalEE"]
65 COMPOUNDS[
"HGCalHE"] = [
"HGCalHEsil",
"HGCalHEmix"]
66 COMPOUNDS[
"FromVertexToBackOfHGCal"] = [
"BeamPipe",
"Tracker",
"ECAL",
"HCal",
"EndcapTimingLayer",
"Neutron Moderator + Thermal Screen",
"HGCal + HGCal Service + Thermal Screen",
"Solenoid Magnet",
"Muon Wheels and Cables"]
75 DETECTORS = OrderedDict()
76 DETECTORS[
"BeamPipe"] = kGray+2
77 DETECTORS[
"Tracker"] = 9
80 DETECTORS[
"EndcapTimingLayer"] = 7
81 DETECTORS[
"Neutron Moderator + Thermal Screen"] = 46
82 DETECTORS[
"HGCal + HGCal Service + Thermal Screen"] = 5
83 DETECTORS[
"Solenoid Magnet"] = 4
84 DETECTORS[
"Muon Wheels and Cables"] = 28
102 sDETS[
"ECAL"] = kBlue
103 sDETS[
"HCal"] = kOrange
113 hist_label_to_num = OrderedDict()
114 hist_label_to_num[
'COP'] = [100, 2,
'Copper']
115 hist_label_to_num[
'SCI'] = [200, 3,
'Scintillator']
116 hist_label_to_num[
'CAB'] = [300, 4,
'Cables']
117 hist_label_to_num[
'MNE'] = [400, 5,
'HGC_G10-FR4']
118 hist_label_to_num[
'SIL'] = [500, 6,
'Silicon']
119 hist_label_to_num[
'OTH'] = [600, 7,
'Other']
120 hist_label_to_num[
'AIR'] = [700, 8,
'Air']
121 hist_label_to_num[
'SST'] = [800, 9,
'Stainless Steel']
122 hist_label_to_num[
'WCU'] = [900, 28,
'WCu']
123 hist_label_to_num[
'LEA'] = [1000, 12,
'Lead']
124 hist_label_to_num[
'EPX'] = [1100, 46,
'Epoxy']
125 hist_label_to_num[
'KAP'] = [1200, 49,
'Kapton']
126 hist_label_to_num[
'ALU'] = [1300, 33,
'Aluminium']
129 """The plots in the twiki are already too much and to avoid mistakes
130 we will try to automatize the procedure
134 label = label.replace(
" ",
"_")
140 zoomtitle =
"in all HGCal"
141 zoomdir =
"%s/" % label
142 elif zoom ==
"zplus":
143 zoomstring =
"_ZplusZoom"
144 zoomtitle =
"in Z+ endcap of HGCal"
145 zoomdir =
"%s/ZPlusZoom/" % label
146 elif zoom ==
"zminus":
147 zoomstring =
"_ZminusZoom"
148 zoomtitle =
"in Z- endcap of HGCal"
149 zoomdir =
"%s/ZMinusZoom/" % label
151 print(
"WRONG OPTION")
155 if plotname ==
"x_vs_z_vs_Rsum":
156 print(
"%%TWISTY{ mode=\"div\" showlink=\"Click to see the %s plots %s \" hidelink=\"Hide %s %s\" showimgright=\"%%ICONURLPATH{toggleopen-small}%%\" hideimgright=\"%%ICONURLPATH{toggleclose-small}%%\"}%%" % (label,zoomtitle, label, zoomtitle))
158 if "Rsum" in plotname
and "x_vs" in plotname
and not "cos" in plotname:
159 print(
"| <img alt=\"HGCal_%s%s%s.png\" height=\"300\" width=\"550\" src=\"http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.png\" /> | The plot on the left shows the 2D profile histogram for *%s* %s that displays the mean value of the material budget in units of radiation length in each R-z cell. R-z cell is 1 cm x 1 mm. The plot depicts the accumulated material budget as seen by the track, as the track travels throughout the detector.[[http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.pdf][Click to enlarge plot]] |" % (plotname,label,zoomstring,zoomdir,plotname,label,zoomstring, label, zoomtitle,zoomdir,plotname,label,zoomstring))
161 if "Rsum" in plotname
and "l_vs" in plotname
and not "cos" in plotname:
162 print(
"| <img alt=\"HGCal_%s%s%s.png\" height=\"300\" width=\"550\" src=\"http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.png\" /> | The plot on the left shows the 2D profile histogram for *%s* %s that displays the mean value of the material budget in units of interaction length in each R-z cell. R-z cell is 1 cm x 1 mm. The plot depicts the accumulated material budget as seen by the track, as the track travels throughout the detector.[[http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.pdf][Click to enlarge plot]] |" % (plotname,label,zoomstring,zoomdir,plotname,label,zoomstring, label, zoomtitle,zoomdir,plotname,label,zoomstring))
164 if "Rsumcos" in plotname
and "x_vs" in plotname:
165 print(
"| <img alt=\"HGCal_%s%s%s.png\" height=\"300\" width=\"550\" src=\"http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.png\" /> | The plot on the left shows the 2D profile histogram for *%s* %s that displays the mean value of the material budget in units of radiation length in each R-z cell. R-z cell is 1 cm x 1 mm. The plot depicts the orthogonal accumulated material budget, that is cos(theta) what the track sees.[[http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.pdf][Click to enlarge plot]] |" % (plotname,label,zoomstring,zoomdir,plotname,label,zoomstring, label, zoomtitle,zoomdir,plotname,label,zoomstring))
167 if "Rsumcos" in plotname
and "l_vs" in plotname:
168 print(
"| <img alt=\"HGCal_%s%s%s.png\" height=\"300\" width=\"550\" src=\"http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.png\" /> | The plot on the left shows the 2D profile histogram for *%s* %s that displays the mean value of the material budget in units of interaction length in each R-z cell. R-z cell is 1 cm x 1 mm. The plot depicts the orthogonal accumulated material budget, that is cos(theta) what the track sees.[[http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.pdf][Click to enlarge plot]] |" % (plotname,label,zoomstring,zoomdir,plotname,label,zoomstring, label, zoomtitle,zoomdir,plotname,label,zoomstring))
170 if "Rloc" in plotname
and "x_vs" in plotname
and not "cos" in plotname:
171 print(
"| <img alt=\"HGCal_%s%s%s.png\" height=\"300\" width=\"550\" src=\"http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.png\" /> | The plot on the left shows the 2D profile histogram for *%s* %s that displays the local mean value of the material budget in units of radiation length in each R-z cell. R-z cell is 1 cm x 1 mm. The plot depicts the local material budget as seen by the track, as the track travels throughout the detector.[[http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.pdf][Click to enlarge plot]] |" % (plotname,label,zoomstring,zoomdir,plotname,label,zoomstring, label, zoomtitle,zoomdir,plotname,label,zoomstring))
173 if "Rloc" in plotname
and "l_vs" in plotname
and not "cos" in plotname:
174 print(
"| <img alt=\"HGCal_%s%s%s.png\" height=\"300\" width=\"550\" src=\"http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.png\" /> | The plot on the left shows the 2D profile histogram for *%s* %s that displays the local mean value of the material budget in units of interaction length in each R-z cell. R-z cell is 1 cm x 1 mm. The plot depicts the local material budget as seen by the track, as the track travels throughout the detector.[[http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.pdf][Click to enlarge plot]] |" % (plotname,label,zoomstring,zoomdir,plotname,label,zoomstring, label, zoomtitle,zoomdir,plotname,label,zoomstring))
177 if plotname ==
"l_vs_z_vs_Rloc":
181 I won't put the local cos plots for now, only the sum cos above
182 if "Rloccos" in plotname and "x_vs" in plotname:
183 print "| <img alt=\"HGCal_%s%s%s.png\" height=\"300\" width=\"550\" src=\"http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.png\" /> | The plot on the left shows the 2D profile histogram for *%s* %s that displays the local mean value of the material budget in units of radiation length in each R-z cell. R-z cell is 1 cm x 1 mm. The plot depicts the orthogonal accumulated material budget, that is cos(theta) what the track sees.[[http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.pdf][Click to enlarge plot]] |" % (plotname,label,zoomstring,zoomdir,plotname,label,zoomstring, label, zoomtitle,zoomdir,plotname,label,zoomstring)
185 if "Rloccos" in plotname and "l_vs" in plotname:
186 print "| <img alt=\"HGCal_%s%s%s.png\" height=\"300\" width=\"550\" src=\"http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.png\" /> | The plot on the left shows the 2D profile histogram for *%s* %s that displays the local mean value of the material budget in units of interaction length in each R-z cell. R-z cell is 1 cm x 1 mm. The plot depicts the orthogonal accumulated material budget, that is cos(theta) what the track sees.[[http://apsallid.web.cern.ch/apsallid/HGCalMaterial/%sHGCal_%s%s%s.pdf][Click to enlarge plot]] |" % (plotname,label,zoomstring,zoomdir,plotname,label,zoomstring, label, zoomtitle,zoomdir,plotname,label,zoomstring)
192 ncolors =
array(
'i', [])
193 gStyle.SetNumberContours(NCont);
194 stops = [ 0.00, 0.10, 0.25, 0.45, 0.60, 0.75, 1.00 ]
195 red = [ 1.00, 0.00, 0.00, 0.00, 0.97, 0.97, 0.10 ]
196 green = [ 1.00, 0.97, 0.30, 0.40, 0.97, 0.00, 0.00 ]
197 blue = [ 1.00, 0.97, 0.97, 0.00, 0.00, 0.00, 0.00 ]
198 stopsArray =
array(
'd', stops)
199 redArray =
array(
'd', red)
200 greenArray =
array(
'd', green)
201 blueArray =
array(
'd', blue)
202 first_color_number = TColor.CreateGradientColorTable(NRGBs, stopsArray, redArray, greenArray, blueArray, NCont);
203 gStyle.SetNumberContours(NCont)
208 for i
in range(palsize):
209 palette.append(first_color_number+i)
210 palarray =
array(
'i',palette)
212 gStyle.SetPalette(palsize,palarray)
231 dEdx[
'Copper'] = 1.257
233 dEdx[
'H_Scintillator'] = 0.91512109*dEdx[
'C'] + 0.084878906*dEdx[
'H']
234 dEdx[
'Silicon'] = 0.3876
236 dEdx[
'HGC_G10-FR4'] = 0.18077359*dEdx[
'Silicon'] + 0.4056325*dEdx[
'0'] + 0.27804208*dEdx[
'C'] + 0.068442752*dEdx[
'H'] + 0.067109079*dEdx[
'Br']
241 dEdx[
'StainlessSteel'] = 0.6996*dEdx[
'Fe']+0.01*dEdx[
'Mn']+0.19*dEdx[
'Cr']+0.1*dEdx[
'Ni']+0.0004*dEdx[
'C'];
243 dEdx[
'WCu'] = 0.75*dEdx[
'W']+0.25*dEdx[
'Copper']
246 dEdx[
'Epoxy'] = 0.53539691*dEdx[
'C'] + 0.13179314*dEdx[
'H'] + 0.33280996*dEdx[
'0']
247 dEdx[
'Kapton'] = 0.59985105*dEdx[
'C'] + 0.080541353*dEdx[
'H'] + 0.31960759*dEdx[
'0']
250 dEdx[
'Cables'] = 0.586*dEdx[
'Copper'] + 0.259*dEdx[
'C'] + 0.138*dEdx[
'0'] + 0.017*dEdx[
'H']
253 MatXo = OrderedDict()
254 MatXo[
'Copper'] = 14.3559
255 MatXo[
'H_Scintillator'] = 425.393
256 MatXo[
'Cables'] = 66.722
257 MatXo[
'HGC_G10-FR4'] = 175.056
258 MatXo[
'Silicon'] = 93.6762
260 MatXo[
'Air'] = 301522.
261 MatXo[
'StainlessSteel'] = 17.3555
262 MatXo[
'WCu'] = 5.1225
263 MatXo[
'Lead'] = 5.6118
264 MatXo[
'Epoxy'] = 315.901
265 MatXo[
'Kapton'] = 365.309
268 """Function to draw the eta.
269 Function to draw the eta references on top of an already existing
270 TCanvas. The lines and labels drawn are collected inside a list and
271 the list is returned to the user to extend the live of the objects
272 contained, otherwise no lines and labels will be drawn, since they
273 will be garbage-collected as soon as this function returns.
278 etas = [ 0.2*i
for i
in range(0,18) ]
286 th = 2*atan(
exp(-ieta))
290 lineh = TLine(-20.,0.,20.,0.)
292 linev = TLine(0.,-10.,0.,10.)
294 keep_alive.append(lineh)
295 keep_alive.append(linev)
299 if ieta>-1.6
and ieta<1.6:
310 x2 = x1+lineL*
cos(th)
311 y2 = y1+lineL*
sin(th)
315 line1 = TLine(x1,y1,x2,y2)
317 keep_alive.append(line1)
319 text =
"%3.1f" % ieta
320 t1 = TLatex(xt, yt,
'%s' % (
'#eta = 0' if ieta == 0
else text))
322 t1.SetTextAlign(talign)
324 keep_alive.append(t1)
Sin< T >::type sin(const T &t)
Exp< T >::type exp(const T &t)
const uint16_t range(const Frame &aFrame)
Cos< T >::type cos(const T &t)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Tan< T >::type tan(const T &t)