File indexing completed on 2024-04-06 12:32:15
0001 from __future__ import print_function
0002 from ROOT import TStyle, kWhite, kTRUE
0003 from ROOT import gROOT, gStyle
0004 from ROOT import kGray, kAzure, kMagenta, kOrange, kWhite
0005 from ROOT import kRed, kBlue, kGreen, kPink, kYellow
0006 from ROOT import TLine, TLatex, TColor
0007
0008 from collections import namedtuple, OrderedDict
0009 from math import sin, cos, tan, atan, exp, pi
0010 from array import array
0011
0012 from Validation.Geometry.plot_utils import Plot_params
0013
0014 plots = {}
0015 plots.setdefault('x_vs_eta', Plot_params(10, '#eta', 'x/X_{0}', 0.0, 145., -4.0, 4.0, '', 0, 0., 0., 0, 1))
0016 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))
0017 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))
0018 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))
0019 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))
0020 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))
0021 plots.setdefault('x_vs_eta_vs_phi', Plot_params(30, '#eta', '#varphi', 0., 0., 0., 0., 'x/X_{0}', 0, -1., -1., 0, 1))
0022 plots.setdefault('l_vs_eta_vs_phi', Plot_params(10030, '#eta', '#varphi', 0., 0., 0., 0., 'x/#lambda_{I}', 0, -1, -1, 0, 1))
0023 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))
0024 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))
0025
0026 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))
0027 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))
0028 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))
0029 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))
0030 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))
0031 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))
0032 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))
0033 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))
0034 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))
0035
0036
0037 _LABELS2COMPS = {'BeamPipe': 'BEAM',
0038 'Tracker': 'Tracker',
0039
0040
0041
0042 'EndcapTimingLayer': 'EndcapTimingLayer',
0043 'Neutron Moderator + Thermal Screen' : 'CALOECTSModerator',
0044 'HGCal + HGCal Service + Thermal Screen' : 'CALOECTSRear',
0045 'Solenoid Magnet' : 'MGNT',
0046 'Muon Wheels and Cables' : 'MB',
0047 'ECAL': 'ECAL',
0048 'HCal': 'HCal',
0049 'FromVertexToBackOfHGCal' : ['BEAM','Tracker','ECAL','HCal','EndcapTimingLayer','CALOECTSModerator','CALOECTSRear','MGNT','MB'],
0050 'HGCal': 'HGCal',
0051 'HGCalEE': 'HGCalEE',
0052 'HGCalHE': ['HGCalHEsil', 'HGCalHEmix']
0053 }
0054
0055
0056
0057
0058
0059
0060
0061
0062 COMPOUNDS = OrderedDict()
0063 COMPOUNDS["HGCal"] = ["HGCal"]
0064 COMPOUNDS["HGCalEE"] = ["HGCalEE"]
0065 COMPOUNDS["HGCalHE"] = ["HGCalHEsil", "HGCalHEmix"]
0066 COMPOUNDS["FromVertexToBackOfHGCal"] = ["BeamPipe","Tracker","ECAL","HCal","EndcapTimingLayer","Neutron Moderator + Thermal Screen","HGCal + HGCal Service + Thermal Screen","Solenoid Magnet","Muon Wheels and Cables"]
0067
0068
0069
0070
0071
0072
0073
0074
0075 DETECTORS = OrderedDict()
0076 DETECTORS["BeamPipe"] = kGray+2
0077 DETECTORS["Tracker"] = 9
0078 DETECTORS["ECAL"] = 2
0079 DETECTORS["HCal"] = 6
0080 DETECTORS["EndcapTimingLayer"] = 7
0081 DETECTORS["Neutron Moderator + Thermal Screen"] = 46
0082 DETECTORS["HGCal + HGCal Service + Thermal Screen"] = 5
0083 DETECTORS["Solenoid Magnet"] = 4
0084 DETECTORS["Muon Wheels and Cables"] = 28
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098 sDETS = OrderedDict()
0099
0100
0101
0102 sDETS["ECAL"] = kBlue
0103 sDETS["HCal"] = kOrange
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113 hist_label_to_num = OrderedDict()
0114 hist_label_to_num['COP'] = [100, 2, 'Copper']
0115 hist_label_to_num['SCI'] = [200, 3, 'Scintillator']
0116 hist_label_to_num['CAB'] = [300, 4, 'Cables']
0117 hist_label_to_num['MNE'] = [400, 5, 'HGC_G10-FR4']
0118 hist_label_to_num['SIL'] = [500, 6, 'Silicon']
0119 hist_label_to_num['OTH'] = [600, 7, 'Other']
0120 hist_label_to_num['AIR'] = [700, 8, 'Air']
0121 hist_label_to_num['SST'] = [800, 9, 'Stainless Steel']
0122 hist_label_to_num['WCU'] = [900, 28, 'WCu']
0123 hist_label_to_num['LEA'] = [1000, 12, 'Lead']
0124 hist_label_to_num['EPX'] = [1100, 46, 'Epoxy']
0125 hist_label_to_num['KAP'] = [1200, 49, 'Kapton']
0126 hist_label_to_num['ALU'] = [1300, 33, 'Aluminium']
0127 hist_label_to_num['POL'] = [1400, 800, 'Polystyrene']
0128 hist_label_to_num['EEC'] = [1500, 900, 'HGC_EEConnector']
0129 hist_label_to_num['HEC'] = [1600, 40, 'HGC_HEConnector']
0130
0131 def TwikiPrintout(plotname, label, zoom):
0132 """The plots in the twiki are already too much and to avoid mistakes
0133 we will try to automatize the procedure
0134 """
0135
0136
0137 label = label.replace(" ", "_")
0138
0139 zoomstring = ""
0140
0141 if zoom == "all":
0142 zoomstring = ""
0143 zoomtitle = "in all HGCal"
0144 zoomdir = "%s/" % label
0145 elif zoom == "zplus":
0146 zoomstring = "_ZplusZoom"
0147 zoomtitle = "in Z+ endcap of HGCal"
0148 zoomdir = "%s/ZPlusZoom/" % label
0149 elif zoom == "zminus":
0150 zoomstring = "_ZminusZoom"
0151 zoomtitle = "in Z- endcap of HGCal"
0152 zoomdir = "%s/ZMinusZoom/" % label
0153 else :
0154 print("WRONG OPTION")
0155
0156
0157
0158 if plotname == "x_vs_z_vs_Rsum":
0159 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))
0160
0161 if "Rsum" in plotname and "x_vs" in plotname and not "cos" in plotname:
0162 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))
0163
0164 if "Rsum" in plotname and "l_vs" in plotname and not "cos" in plotname:
0165 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))
0166
0167 if "Rsumcos" in plotname and "x_vs" in plotname:
0168 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))
0169
0170 if "Rsumcos" in plotname and "l_vs" in plotname:
0171 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))
0172
0173 if "Rloc" in plotname and "x_vs" in plotname and not "cos" in plotname:
0174 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))
0175
0176 if "Rloc" in plotname and "l_vs" in plotname and not "cos" in plotname:
0177 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))
0178
0179
0180 if plotname == "l_vs_z_vs_Rloc":
0181 print("%ENDTWISTY%")
0182
0183 """
0184 I won't put the local cos plots for now, only the sum cos above
0185 if "Rloccos" in plotname and "x_vs" in plotname:
0186 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)
0187
0188 if "Rloccos" in plotname and "l_vs" in plotname:
0189 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)
0190 """
0191
0192 def acustompalette():
0193 NRGBs = 7
0194 NCont = 100
0195 ncolors = array('i', [])
0196 gStyle.SetNumberContours(NCont);
0197 stops = [ 0.00, 0.10, 0.25, 0.45, 0.60, 0.75, 1.00 ]
0198 red = [ 1.00, 0.00, 0.00, 0.00, 0.97, 0.97, 0.10 ]
0199 green = [ 1.00, 0.97, 0.30, 0.40, 0.97, 0.00, 0.00 ]
0200 blue = [ 1.00, 0.97, 0.97, 0.00, 0.00, 0.00, 0.00 ]
0201 stopsArray = array('d', stops)
0202 redArray = array('d', red)
0203 greenArray = array('d', green)
0204 blueArray = array('d', blue)
0205 first_color_number = TColor.CreateGradientColorTable(NRGBs, stopsArray, redArray, greenArray, blueArray, NCont);
0206 gStyle.SetNumberContours(NCont)
0207
0208
0209 palsize = NCont
0210 palette = []
0211 for i in range(palsize):
0212 palette.append(first_color_number+i)
0213 palarray = array('i',palette)
0214
0215 gStyle.SetPalette(palsize,palarray)
0216
0217
0218
0219 dEdx = OrderedDict()
0220
0221
0222 dEdx['Fe'] = 1.143
0223 dEdx['Mn'] = 1.062
0224 dEdx['Cr'] = 1.046
0225 dEdx['Ni'] = 1.307
0226 dEdx['C'] = 0.3952
0227 dEdx['0'] = 0.
0228 dEdx['H'] = 0.
0229 dEdx['Br'] = 0.
0230 dEdx['W'] = 2.210
0231 dEdx['Al'] = 0.4358
0232
0233
0234 dEdx['Copper'] = 1.257
0235
0236 dEdx['H_Scintillator'] = 0.91512109*dEdx['C'] + 0.084878906*dEdx['H']
0237 dEdx['Silicon'] = 0.3876
0238
0239 dEdx['HGC_G10-FR4'] = 0.18077359*dEdx['Silicon'] + 0.4056325*dEdx['0'] + 0.27804208*dEdx['C'] + 0.068442752*dEdx['H'] + 0.067109079*dEdx['Br']
0240 dEdx['Other'] = 0.
0241
0242 dEdx['Air'] = 0.
0243
0244 dEdx['StainlessSteel'] = 0.6996*dEdx['Fe']+0.01*dEdx['Mn']+0.19*dEdx['Cr']+0.1*dEdx['Ni']+0.0004*dEdx['C'];
0245
0246 dEdx['WCu'] = 0.75*dEdx['W']+0.25*dEdx['Copper']
0247
0248 dEdx['Lead'] = 1.274
0249 dEdx['Epoxy'] = 0.53539691*dEdx['C'] + 0.13179314*dEdx['H'] + 0.33280996*dEdx['0']
0250 dEdx['Kapton'] = 0.59985105*dEdx['C'] + 0.080541353*dEdx['H'] + 0.31960759*dEdx['0']
0251
0252
0253 dEdx['Cables'] = 0.586*dEdx['Copper'] + 0.259*dEdx['C'] + 0.138*dEdx['0'] + 0.017*dEdx['H']
0254
0255
0256 MatXo = OrderedDict()
0257 MatXo['Copper'] = 14.3559
0258 MatXo['H_Scintillator'] = 425.393
0259 MatXo['Cables'] = 66.722
0260 MatXo['HGC_G10-FR4'] = 175.056
0261 MatXo['Silicon'] = 93.6762
0262 MatXo['Other'] = 0.
0263 MatXo['Air'] = 301522.
0264 MatXo['StainlessSteel'] = 17.3555
0265 MatXo['WCu'] = 5.1225
0266 MatXo['Lead'] = 5.6118
0267 MatXo['Epoxy'] = 315.901
0268 MatXo['Kapton'] = 365.309
0269
0270 def drawHalfEtaValues():
0271 """Function to draw the eta.
0272 Function to draw the eta references on top of an already existing
0273 TCanvas. The lines and labels drawn are collected inside a list and
0274 the list is returned to the user to extend the live of the objects
0275 contained, otherwise no lines and labels will be drawn, since they
0276 will be garbage-collected as soon as this function returns.
0277 """
0278
0279
0280 keep_alive = []
0281 etas = [ 0.2*i for i in range(0,18) ]
0282
0283 etax = 2850.
0284 etay = 1240.
0285 lineL = 110
0286 offT = 10.
0287
0288 for ieta in etas:
0289 th = 2*atan(exp(-ieta))
0290 talign = 21
0291
0292
0293 lineh = TLine(-20.,0.,20.,0.)
0294 lineh.Draw()
0295 linev = TLine(0.,-10.,0.,10.)
0296 linev.Draw()
0297 keep_alive.append(lineh)
0298 keep_alive.append(linev)
0299
0300 x1 = 0
0301 y1 = 0
0302 if ieta>-1.6 and ieta<1.6:
0303 x1 = etay/tan(th)
0304 y1 = etay
0305 elif ieta <=-1.6:
0306 x1 = -etax
0307 y1 = -etax*tan(th)
0308 talign = 11
0309 elif ieta>=1.6:
0310 x1 = etax
0311 y1 = etax*tan(th)
0312 talign = 31
0313 x2 = x1+lineL*cos(th)
0314 y2 = y1+lineL*sin(th)
0315 xt = x2
0316 yt = y2+offT
0317
0318 line1 = TLine(x1,y1,x2,y2)
0319 line1.Draw()
0320 keep_alive.append(line1)
0321
0322 text = "%3.1f" % ieta
0323 t1 = TLatex(xt, yt, '%s' % ('#eta = 0' if ieta == 0 else text))
0324 t1.SetTextSize(0.03)
0325 t1.SetTextAlign(talign)
0326 t1.Draw()
0327 keep_alive.append(t1)
0328 return keep_alive