12 from CondCore.Utilities
import iovInspector
as inspect
13 from ROOT
import TCanvas,TH1F, TH2F, gStyle, TChain, TTree, TLegend, TFile
19 '''List all available tags for a given db '''
21 for tag
in tags.split():
25 '''List all available iovs for a given tag'''
28 iov = inspect.Iov(db,tag)
30 print "Available iovs for tag: ",tag
32 print " Since " , p[1],
" Till " , p[2]
37 def dumpXML(db,tag,since,filename='dump.xml'):
38 '''Dump record in XML format for a given tag '''
40 iov = inspect.Iov(db,tag)
42 payload=inspect.PayLoad(db,token)
43 out = open(filename,
'w')
49 def plot (db, tag,since,filename='plot.root'):
50 '''Invoke the plot function from the wrapper and save to the specified \
51 file. The file format will reflect the extension given.'''
54 iov = inspect.Iov(db,tag)
57 payload=inspect.PayLoad(db,token)
58 payload.plot(filename,
"",[],[])
65 tag2,db2,since2,filename=
'compare.root'):
66 '''Produce comparison plots for two records. Save plots to file \
67 according to format. tag can be an xml file'''
75 if tag1.find(
".xml") < 0:
77 exec(
'import '+db1.moduleName(tag1)+
' as Plug')
78 what = {
'how':
'barrel'}
79 w = inspect.setWhat(Plug.What(),what)
80 ex = Plug.Extractor(w)
83 coeff_1_b = [i
for i
in ex.values()]
84 what = {
'how':
'endcap'}
85 w = inspect.setWhat(Plug.What(),what)
86 ex = Plug.Extractor(w)
88 coeff_1_e = [i
for i
in ex.values()]
96 if tag2.find(
".xml")<0:
98 exec(
'import '+db2.moduleName(tag2)+
' as Plug')
99 what = {
'how':
'barrel'}
100 w = inspect.setWhat(Plug.What(),what)
101 ex = Plug.Extractor(w)
104 coeff_2_b = [i
for i
in ex.values()]
105 what = {
'how':
'endcap'}
106 w = inspect.setWhat(Plug.What(),what)
107 ex = Plug.Extractor(w)
109 coeff_2_e = [i
for i
in ex.values()]
112 except Exception, er :
119 savefile = TFile(filename,
"RECREATE")
121 ebhisto,ebmap, profx, profy=
compareBarrel(coeff_1_b,coeff_2_b)
122 eephisto,eepmap,eemhisto,eemmap=
compareEndcap(coeff_1_e,coeff_2_e)
128 diff_distro_can = TCanvas(
"EBdiff",
"EBdiff")
129 diff_distro_can.Divide(2,2)
131 diff_distro_can.cd(1)
133 diff_distro_can.cd(2)
135 diff_distro_can.cd(3)
137 diff_distro_can.cd(4)
142 c2 = TCanvas(
"EEdiff",
"EEdiff")
154 EEfilename =
"EE_"+filename
160 eeborderphisto,eeborderpmap,eebordermhisto,eebordermmap=
compareEndcapBorder(coeff_1_e,coeff_2_e)
163 border_diff_distro_can = TCanvas(
"border_difference",
"borders difference")
164 border_diff_distro_can.Divide(2,3)
166 border_diff_distro_can.cd(1)
168 border_diff_distro_can.cd(2)
169 ebbordermap.Draw(
"colz")
170 border_diff_distro_can.cd(3)
171 eeborderphisto.Draw()
172 border_diff_distro_can.cd(4)
173 eeborderpmap.Draw(
"colz")
174 border_diff_distro_can.cd(5)
175 eebordermhisto.Draw()
176 border_diff_distro_can.cd(6)
177 eebordermmap.Draw(
"colz")
179 bordersfilename =
"borders_"+filename
180 prof_filename =
"profiles_"+filename
188 def histo (db, tag,since,filename='histo.root'):
189 '''Make histograms and save to file. tag can be an xml file'''
194 if tag.find(
".xml")< 0:
196 exec(
'import '+db.moduleName(tag)+
' as Plug')
198 what = {
'how':
'barrel'}
199 w = inspect.setWhat(Plug.What(),what)
200 ex = Plug.Extractor(w)
203 coeff_barl = [i
for i
in ex.values()]
206 what = {
'how':
'endcap'}
207 w = inspect.setWhat(Plug.What(),what)
208 ex = Plug.Extractor(w)
210 coeff_endc = [i
for i
in ex.values()]
212 except Exception, er :
219 savefile = TFile(filename,
"RECREATE")
221 ebmap, ebeta, ebphi, eePmap, ebdist, eeMmap, prof_eePL, prof_eePR, prof_eeML, prof_eeMR, ebBorderdist =
makedist(coeff_barl, coeff_endc)
227 c = TCanvas(
"CCdist")
241 prof_eb_eta = ebeta.ProfileX()
242 prof_eb_phi = ebphi.ProfileX()
244 c2 = TCanvas(
"CCprofiles")
247 leg = TLegend(0.1,0.7,0.48,0.9)
254 prof_eePL.SetMarkerStyle(8)
256 prof_eePR.SetMarkerStyle(8)
257 prof_eePR.SetMarkerColor(2)
258 prof_eePR.Draw(
"same")
259 prof_eeML.SetMarkerStyle(8)
260 prof_eeML.SetMarkerColor(3)
261 prof_eeML.Draw(
"same")
262 prof_eeMR.SetMarkerStyle(8)
263 prof_eeMR.SetMarkerColor(5)
264 prof_eeMR.Draw(
"same")
265 leg.AddEntry(prof_eePL,
"Dee1",
"lp")
266 leg.AddEntry(prof_eePR,
"Dee2",
"lp")
267 leg.AddEntry(prof_eeMR,
"Dee3",
"lp")
268 leg.AddEntry(prof_eeML,
"Dee4",
"lp")
273 extrafilename =
"profiles_"+filename
280 ''' Return payload token for a given iov, tag, db'''
282 iov = inspect.Iov(db,tag)
286 if str(tmpsince)==str(since) :
288 print "Could not retrieve token for tag: " , tag,
" since: ", since
291 except Exception, er :
296 ''' Return payload object for a given iov, tag, db'''
299 exec(
'import '+db.moduleName(tag)+
' as Plug')
300 for elem
in db.iov(tag).elements :
301 if str(elem.since())==str(since):
303 return Plug.Object(elem)
305 except Exception, er :
309 print "Could not retrieve payload for tag: " , tag,
" since: ", since
315 ebmap = TH2F(
"EB",
"EB",360,1,261,171, -85,86)
316 eePmap = TH2F(
"EE",
"EE",100, 1,101,100,1,101)
317 eeMmap = TH2F(
"EEminus",
"EEminus",100,1,101,100,1,101)
318 ebdist = TH1F(
"EBdist",
"EBdist",100,-2,2)
319 ebBorderdist = TH1F(
"EBBorderdist",
"EBBorderdist",100,-2,2)
321 ebeta = TH2F(
"ebeta",
"ebeta",171,-85,86,100,-2,2)
322 ebphi = TH2F(
"ebphi",
"ebphi",360,1,361,100,-2,2)
324 eePL = TH2F(
"EEPL",
"EEPlus Left",50,10,55,100,-2,2)
325 eePR = TH2F(
"EEPR",
"EEPlus Right",50,10,55,100,-2,2)
326 eeML = TH2F(
"EEML",
"EEMinus Left",50,10,55,100,-2,2)
327 eeMR = TH2F(
"EEMR",
"EEMinus Right",50,10,55,100,-2,2)
329 for i,c
in enumerate(coeff_barl):
331 ebmap.Fill(iphi,ieta,c)
336 if (
abs(ieta)==85
or abs(ieta)==65
or abs(ieta)==64
or abs(ieta)==45
or abs(ieta)==44
or abs(ieta)==25
or abs(ieta)==24
or abs(ieta)==1
or iphi%20==1
or iphi%20==0):
340 for i,c
in enumerate(coeff_endc):
342 R =
sqrt((ix-50)*(ix-50)+(iy-50)*(iy-50))
358 prof_eePL = eePL.ProfileX()
359 prof_eePR = eePR.ProfileX()
360 prof_eeML = eeML.ProfileX()
361 prof_eeMR = eeMR.ProfileX()
363 return ebmap, ebeta, ebphi, eePmap, ebdist, eeMmap, prof_eePL, prof_eePR, prof_eeML, prof_eeMR, ebBorderdist
366 '''Return an histogram and a map of the differences '''
368 diff_distro_h = TH1F(
"diffh",
"diffh",100,-2,2)
369 diff_distro_m = TH2F(
"diffm",
"diffm",360,1,361,171,-85,86)
370 diff_distro_m.SetStats(0)
371 ebeta = TH2F(
"ebeta",
"ebeta",171,-85,86,100,-2,2)
372 ebphi = TH2F(
"ebphi",
"ebphi",360,1,361,100,-2,2)
375 for i,c
in enumerate(coeff_barl_1):
376 diff = c - coeff_barl_2[i]
378 diff_distro_h.Fill(diff)
379 diff_distro_m.Fill(iphi,ieta,diff)
380 ebeta.Fill(ieta,diff)
381 ebphi.Fill(iphi,diff)
383 prof_x_h = ebeta.ProfileX()
384 prof_y_h = ebphi.ProfileX()
386 return diff_distro_h, diff_distro_m, prof_x_h, prof_y_h
391 '''Return an histogram and a map of the differences '''
393 diff_distro_border_h = TH1F(
"diffborderh",
"diffh",100,-2,2)
394 diff_distro_border_m = TH2F(
"diffborderm",
"diffm",360,1,361,171,-85,86)
395 diff_distro_border_m.SetStats(0)
397 for i,c
in enumerate(coeff_barl_1):
398 diff = c - coeff_barl_2[i]
400 if (
abs(ieta)==85
or abs(ieta)==65
or abs(ieta)==64
or abs(ieta)==45
or abs(ieta)==44
or abs(ieta)==25
or abs(ieta)==24
or abs(ieta)==1
or iphi%20==1
or iphi%20==0):
401 diff_distro_border_h.Fill(diff)
402 if (
abs(ieta)==85
or abs(ieta)==65
or abs(ieta)==64
or abs(ieta)==45
or abs(ieta)==44
or abs(ieta)==25
or abs(ieta)==24
or abs(ieta)==1
or iphi%20==0
or iphi%20==1):
403 diff_distro_border_m.Fill(iphi,ieta,diff)
405 return diff_distro_border_h, diff_distro_border_m
412 ''' Return an histogram and a map of the differences for each endcap'''
414 diff_distro_h_eep = TH1F(
"diff EE+",
"diff EE+",100,-2,2)
415 diff_distro_h_eem = TH1F(
"diff EE-",
"diff EE-",100,-2,2)
418 diff_distro_m_eep = TH2F(
"map EE+",
"map EE+",100,1,101,100,1,101)
419 diff_distro_m_eem = TH2F(
"map EE-",
"map EE-",100,1,101,100,1,101)
421 temp_h = TH1F(
"tempR",
"tempR",50,0,50)
423 diff_distro_m_eep.SetStats(0)
424 diff_distro_m_eem.SetStats(0)
427 for i,c
in enumerate(coeff_endc_1):
428 diff = c - coeff_endc_2[i]
430 R =
sqrt((ix-50)*(ix-50)+(iy-50)*(iy-50))
433 diff_distro_h_eep.Fill(diff)
434 diff_distro_m_eep.Fill(ix,iy,diff)
437 diff_distro_h_eem.Fill(diff)
438 diff_distro_m_eem.Fill(ix,iy,diff)
440 return diff_distro_h_eep, \
448 ''' Return an histogram and a map of the differences for each endcap'''
450 border_diff_distro_h_eep = TH1F(
"borderdiff EE+",
"diff EE+",100,-2,2)
451 border_diff_distro_h_eem = TH1F(
"borderdiff EE-",
"diff EE-",100,-2,2)
454 border_diff_distro_m_eep = TH2F(
"bordermap EE+",
"map EE+",100,1,101,100,1,101)
455 border_diff_distro_m_eem = TH2F(
"bordermap EE-",
"map EE-",100,1,101,100,1,101)
457 border_diff_distro_m_eep.SetStats(0)
458 border_diff_distro_m_eem.SetStats(0)
461 for i,c
in enumerate(coeff_endc_1):
462 diff = c - coeff_endc_2[i]
464 Rsq = ((ix-50.0)**2+(iy-50.0)**2)
466 if (iz >0
and (Rsq<144.0
or Rsq>2500.0)):
467 border_diff_distro_h_eep.Fill(diff)
468 border_diff_distro_m_eep.Fill(ix,iy,diff)
469 elif (iz<0
and (Rsq<144.0
or Rsq>2500.0)):
470 border_diff_distro_h_eem.Fill(diff)
471 border_diff_distro_m_eem.Fill(ix,iy,diff)
474 return border_diff_distro_h_eep, \
475 border_diff_distro_m_eep, \
476 border_diff_distro_h_eem, \
477 border_diff_distro_m_eem