CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
EcalCondTools Namespace Reference

Functions

def compare
 
def compareBarrel
 
def compareBarrelBorder
 
def compareEndcap
 
def compareEndcapBorder
 
def dumpXML
 
def getObject
 
def getToken
 
def histo
 
def listIovs
 
def listTags
 
def makedist
 
def plot
 

Function Documentation

def EcalCondTools.compare (   tag1,
  db1,
  since1,
  tag2,
  db2,
  since2,
  filename = 'compare.root' 
)
Produce comparison plots for two records. Save plots to file \
   according to format. tag can be an xml file

Definition at line 65 of file EcalCondTools.py.

References compareBarrel(), compareBarrelBorder(), compareEndcap(), compareEndcapBorder(), EcalPyUtils.fromXML(), and getObject().

Referenced by TTUTrackingAlg.alignTracks(), muonisolation::CaloExtractorByAssociator.deposits(), and plot().

65 
66  tag2,db2,since2,filename='compare.root'):
67  '''Produce comparison plots for two records. Save plots to file \
68  according to format. tag can be an xml file'''
69 
70  coeff_1_b=[]
71  coeff_2_b=[]
72 
73  coeff_1_e=[]
74  coeff_2_e=[]
75 
76  if tag1.find(".xml") < 0:
77  try:
78  exec('import '+db1.moduleName(tag1)+' as Plug')
79  what = {'how':'barrel'}
80  w = inspect.setWhat(Plug.What(),what)
81  ex = Plug.Extractor(w)
82  p = getObject(db1,tag1,since1)
83  p.extract(ex)
84  coeff_1_b = [i for i in ex.values()]# first set of coefficients
85  what = {'how':'endcap'}
86  w = inspect.setWhat(Plug.What(),what)
87  ex = Plug.Extractor(w)
88  p.extract(ex)
89  coeff_1_e = [i for i in ex.values()]# first set of coefficients
90 
91 
92  except Exception,er :
93  print er
94  else:
95  coeff_1_b,coeff_1_e = EcalPyUtils.fromXML(tag1)
96 
97  if tag2.find(".xml")<0:
98  try:
99  exec('import '+db2.moduleName(tag2)+' as Plug')
100  what = {'how':'barrel'}
101  w = inspect.setWhat(Plug.What(),what)
102  ex = Plug.Extractor(w)
103  p = getObject(db2,tag2,since2)
104  p.extract(ex)
105  coeff_2_b = [i for i in ex.values()]# 2nd set of coefficients
106  what = {'how':'endcap'}
107  w = inspect.setWhat(Plug.What(),what)
108  ex = Plug.Extractor(w)
109  p.extract(ex)
110  coeff_2_e = [i for i in ex.values()]# first set of coefficients
111 
112 
113  except Exception, er :
114  print er
115  else:
116  coeff_2_b,coeff_2_e = EcalPyUtils.fromXML(tag2)
117 
118  gStyle.SetPalette(1)
119 
120  savefile = TFile(filename,"RECREATE")
121 
122  ebhisto,ebmap, profx, profy= compareBarrel(coeff_1_b,coeff_2_b)
123  eephisto,eepmap,eemhisto,eemmap=compareEndcap(coeff_1_e,coeff_2_e)
124 
125 #make more canvas
126 
127 
128 
129  diff_distro_can = TCanvas("EBdiff","EBdiff")
130  diff_distro_can.Divide(2,2)
131 
132  diff_distro_can.cd(1)
133  ebhisto.Draw()
134  diff_distro_can.cd(2)
135  ebmap.Draw("colz")
136  diff_distro_can.cd(3)
137  profx.Draw()
138  diff_distro_can.cd(4)
139  profy.Draw()
140 
141 # diff_distro_can.SaveAs(filename)
142 
143  c2 = TCanvas("EEdiff","EEdiff")
144  c2.Divide(2,2)
145 
146  c2.cd(1)
147  eephisto.Draw()
148  c2.cd(2)
149  eepmap.Draw("colz")
150  c2.cd(3)
151  eemhisto.Draw()
152  c2.cd(4)
153  eemmap.Draw("colz")
154 
155  EEfilename = "EE_"+filename
156 
157 # c2.SaveAs(EEfilename)
158 
159 
160 
161  eeborderphisto,eeborderpmap,eebordermhisto,eebordermmap=compareEndcapBorder(coeff_1_e,coeff_2_e)
162  ebborderhisto,ebbordermap = compareBarrelBorder(coeff_1_b,coeff_2_b)
163 
164  border_diff_distro_can = TCanvas("border_difference","borders difference")
165  border_diff_distro_can.Divide(2,3)
166 
167  border_diff_distro_can.cd(1)
168  ebborderhisto.Draw()
169  border_diff_distro_can.cd(2)
170  ebbordermap.Draw("colz")
171  border_diff_distro_can.cd(3)
172  eeborderphisto.Draw()
173  border_diff_distro_can.cd(4)
174  eeborderpmap.Draw("colz")
175  border_diff_distro_can.cd(5)
176  eebordermhisto.Draw()
177  border_diff_distro_can.cd(6)
178  eebordermmap.Draw("colz")
179 
180  bordersfilename = "borders_"+filename
181  prof_filename = "profiles_"+filename
182 
183 # border_diff_distro_can.SaveAs(bordersfilename)
184 
185  savefile.Write()
186 
187 
def EcalCondTools.compareBarrel (   coeff_barl_1,
  coeff_barl_2 
)
Return an histogram and a map of the differences 

Definition at line 365 of file EcalCondTools.py.

References EcalPyUtils.unhashEBIndex().

Referenced by compare().

366 def compareBarrel(coeff_barl_1,coeff_barl_2) :
367  '''Return an histogram and a map of the differences '''
368 
369  diff_distro_h = TH1F("diffh","diffh",100,-2,2)
370  diff_distro_m = TH2F("diffm","diffm",360,1,361,171,-85,86)
371  diff_distro_m.SetStats(0)
372  ebeta = TH2F("ebeta","ebeta",171,-85,86,100,-2,2)
373  ebphi = TH2F("ebphi","ebphi",360,1,361,100,-2,2)
374 
375 
376  for i,c in enumerate(coeff_barl_1):
377  diff = c - coeff_barl_2[i]
378  ieta,iphi= EcalPyUtils.unhashEBIndex(i)
379  diff_distro_h.Fill(diff)
380  diff_distro_m.Fill(iphi,ieta,diff)
381  ebeta.Fill(ieta,diff)
382  ebphi.Fill(iphi,diff)
383 
384  prof_x_h = ebeta.ProfileX()
385  prof_y_h = ebphi.ProfileX()
386 
387  return diff_distro_h, diff_distro_m, prof_x_h, prof_y_h
388 
389 
def unhashEBIndex
Definition: EcalPyUtils.py:9
def EcalCondTools.compareBarrelBorder (   coeff_barl_1,
  coeff_barl_2 
)
Return an histogram and a map of the differences 

Definition at line 390 of file EcalCondTools.py.

References abs, and EcalPyUtils.unhashEBIndex().

Referenced by compare().

391 def compareBarrelBorder(coeff_barl_1,coeff_barl_2) :
392  '''Return an histogram and a map of the differences '''
393 
394  diff_distro_border_h = TH1F("diffborderh","diffh",100,-2,2)
395  diff_distro_border_m = TH2F("diffborderm","diffm",360,1,361,171,-85,86)
396  diff_distro_border_m.SetStats(0)
397 
398  for i,c in enumerate(coeff_barl_1):
399  diff = c - coeff_barl_2[i]
400  ieta,iphi= EcalPyUtils.unhashEBIndex(i)
401  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):
402  diff_distro_border_h.Fill(diff)
403  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):
404  diff_distro_border_m.Fill(iphi,ieta,diff)
405 
406  return diff_distro_border_h, diff_distro_border_m
407 
408 
409 
410 
#define abs(x)
Definition: mlp_lapack.h:159
def unhashEBIndex
Definition: EcalPyUtils.py:9
def EcalCondTools.compareEndcap (   coeff_endc_1,
  coeff_endc_2 
)
Return an histogram and a map of the differences for each endcap

Definition at line 411 of file EcalCondTools.py.

References mathSSE.sqrt(), and EcalPyUtils.unhashEEIndex().

Referenced by compare().

412 def compareEndcap(coeff_endc_1, coeff_endc_2) :
413  ''' Return an histogram and a map of the differences for each endcap'''
414 
415  diff_distro_h_eep = TH1F("diff EE+","diff EE+",100,-2,2)
416  diff_distro_h_eem = TH1F("diff EE-","diff EE-",100,-2,2)
417 
418 
419  diff_distro_m_eep = TH2F("map EE+","map EE+",100,1,101,100,1,101)
420  diff_distro_m_eem = TH2F("map EE-","map EE-",100,1,101,100,1,101)
421 
422  temp_h = TH1F("tempR","tempR",50,0,50)
423 
424  diff_distro_m_eep.SetStats(0)
425  diff_distro_m_eem.SetStats(0)
426 
427 
428  for i,c in enumerate(coeff_endc_1):
429  diff = c - coeff_endc_2[i]
430  ix,iy,iz = EcalPyUtils.unhashEEIndex(i)
431  R = sqrt((ix-50)*(ix-50)+(iy-50)*(iy-50))
432 
433  if iz >0:
434  diff_distro_h_eep.Fill(diff)
435  diff_distro_m_eep.Fill(ix,iy,diff)
436 
437  else:
438  diff_distro_h_eem.Fill(diff)
439  diff_distro_m_eem.Fill(ix,iy,diff)
440 
441  return diff_distro_h_eep, \
442  diff_distro_m_eep, \
443  diff_distro_h_eem, \
444  diff_distro_m_eem
445 
446 
T sqrt(T t)
Definition: SSEVec.h:28
def unhashEEIndex
Definition: EcalPyUtils.py:14
def EcalCondTools.compareEndcapBorder (   coeff_endc_1,
  coeff_endc_2 
)
Return an histogram and a map of the differences for each endcap

Definition at line 447 of file EcalCondTools.py.

References EcalPyUtils.unhashEEIndex().

Referenced by compare().

448 def compareEndcapBorder(coeff_endc_1, coeff_endc_2) :
449  ''' Return an histogram and a map of the differences for each endcap'''
450 
451  border_diff_distro_h_eep = TH1F("borderdiff EE+","diff EE+",100,-2,2)
452  border_diff_distro_h_eem = TH1F("borderdiff EE-","diff EE-",100,-2,2)
453 
454 
455  border_diff_distro_m_eep = TH2F("bordermap EE+","map EE+",100,1,101,100,1,101)
456  border_diff_distro_m_eem = TH2F("bordermap EE-","map EE-",100,1,101,100,1,101)
457 
458  border_diff_distro_m_eep.SetStats(0)
459  border_diff_distro_m_eem.SetStats(0)
460 
461 
462  for i,c in enumerate(coeff_endc_1):
463  diff = c - coeff_endc_2[i]
464  ix,iy,iz = EcalPyUtils.unhashEEIndex(i)
465  Rsq = ((ix-50.0)**2+(iy-50.0)**2)
466 
467  if (iz >0 and (Rsq<144.0 or Rsq>2500.0)):
468  border_diff_distro_h_eep.Fill(diff)
469  border_diff_distro_m_eep.Fill(ix,iy,diff)
470  elif (iz<0 and (Rsq<144.0 or Rsq>2500.0)):
471  border_diff_distro_h_eem.Fill(diff)
472  border_diff_distro_m_eem.Fill(ix,iy,diff)
473 
474 
475  return border_diff_distro_h_eep, \
476  border_diff_distro_m_eep, \
477  border_diff_distro_h_eem, \
478  border_diff_distro_m_eem
def unhashEEIndex
Definition: EcalPyUtils.py:14
def EcalCondTools.dumpXML (   db,
  tag,
  since,
  filename = 'dump.xml' 
)
Dump record in XML format for a given tag 

Definition at line 37 of file EcalCondTools.py.

References getToken().

Referenced by EcalAlignmentXMLTranslator.writeXML(), EcalTBWeightsXMLTranslator.writeXML(), EcalPedestalsXMLTranslator.writeXML(), EcalDAQTowerStatusXMLTranslator.writeXML(), EcalDCSTowerStatusXMLTranslator.writeXML(), EcalADCToGeVXMLTranslator.writeXML(), EcalLaserAPDPNRatiosXMLTranslator.writeXML(), EcalChannelStatusXMLTranslator.writeXML(), EcalGainRatiosXMLTranslator.writeXML(), EcalFloatCondObjectContainerXMLTranslator.writeXML(), EcalWeightGroupXMLTranslator.writeXML(), and EcalWeightSetXMLTranslator.writeXML().

37 
38 def dumpXML(db,tag,since,filename='dump.xml'):
39  '''Dump record in XML format for a given tag '''
40  try :
41  iov = inspect.Iov(db,tag)
42  token = getToken(db,tag,since)
43  payload=inspect.PayLoad(db,token)
44  out = open(filename,'w')
45  print >> out, payload
46 
47  except Exception,er :
48  print er
def EcalCondTools.getObject (   db,
  tag,
  since 
)
Return payload object for a given iov, tag, db

Definition at line 295 of file EcalCondTools.py.

Referenced by compare(), and histo().

296 def getObject(db,tag,since):
297  ''' Return payload object for a given iov, tag, db'''
298  found=0
299  try:
300  exec('import '+db.moduleName(tag)+' as Plug')
301  for elem in db.iov(tag).elements :
302  if str(elem.since())==str(since):
303  found=1
304  return Plug.Object(elem)
305 
306  except Exception, er :
307  print er
308 
309  if not found :
310  print "Could not retrieve payload for tag: " , tag, " since: ", since
311  sys.exit(0)
312 
def EcalCondTools.getToken (   db,
  tag,
  since 
)
Return payload token for a given iov, tag, db

Definition at line 279 of file EcalCondTools.py.

Referenced by dumpXML(), and plot().

280 def getToken(db,tag,since):
281  ''' Return payload token for a given iov, tag, db'''
282  try :
283  iov = inspect.Iov(db,tag)
284  iovlist = iov.list()
285  for p in iovlist:
286  tmpsince=p[1]
287  if str(tmpsince)==str(since) :
288  return p[0]
289  print "Could not retrieve token for tag: " , tag, " since: ", since
290  sys.exit(0)
291 
292  except Exception, er :
293  print er
294 
def EcalCondTools.histo (   db,
  tag,
  since,
  filename = 'histo.root' 
)
Make histograms and save to file. tag can be an xml file

Definition at line 188 of file EcalCondTools.py.

References EcalPyUtils.fromXML(), getObject(), and makedist().

189 def histo (db, tag,since,filename='histo.root'):
190  '''Make histograms and save to file. tag can be an xml file'''
191 
192  coeff_barl=[]
193  coeff_endc=[]
194 
195  if tag.find(".xml")< 0:
196  try:
197  exec('import '+db.moduleName(tag)+' as Plug')
198 
199  what = {'how':'barrel'}
200  w = inspect.setWhat(Plug.What(),what)
201  ex = Plug.Extractor(w)
202  p=getObject(db,tag,since)
203  p.extract(ex)
204  coeff_barl = [i for i in ex.values()]
205 
206 
207  what = {'how':'endcap'}
208  w = inspect.setWhat(Plug.What(),what)
209  ex = Plug.Extractor(w)
210  p.extract(ex)
211  coeff_endc = [i for i in ex.values()]
212 
213  except Exception, er :
214  print er
215 
216  else :
217  coeff_barl,coeff_endc=EcalPyUtils.fromXML(tag)
218 
219 
220  savefile = TFile(filename,"RECREATE")
221 
222  ebmap, ebeta, ebphi, eePmap, ebdist, eeMmap, prof_eePL, prof_eePR, prof_eeML, prof_eeMR, ebBorderdist = makedist(coeff_barl, coeff_endc)
223 
224 
225 
226  gStyle.SetPalette(1)
227 
228  c = TCanvas("CCdist")
229  c.Divide(2,2)
230 
231  c.cd(1)
232  ebmap.Draw("colz")
233  c.cd(2)
234  eePmap.Draw("colz")
235  c.cd(3)
236  ebdist.Draw()
237  c.cd(4)
238  eeMmap.Draw("colz")
239 
240 # c.SaveAs(filename)
241 
242  prof_eb_eta = ebeta.ProfileX()
243  prof_eb_phi = ebphi.ProfileX()
244 
245  c2 = TCanvas("CCprofiles")
246  c2.Divide(2,2)
247 
248  leg = TLegend(0.1,0.7,0.48,0.9)
249 
250  c2.cd(1)
251  prof_eb_eta.Draw()
252  c2.cd(2)
253  prof_eb_phi.Draw()
254  c2.cd(3)
255  prof_eePL.SetMarkerStyle(8)
256  prof_eePL.Draw()
257  prof_eePR.SetMarkerStyle(8)
258  prof_eePR.SetMarkerColor(2)
259  prof_eePR.Draw("same")
260  prof_eeML.SetMarkerStyle(8)
261  prof_eeML.SetMarkerColor(3)
262  prof_eeML.Draw("same")
263  prof_eeMR.SetMarkerStyle(8)
264  prof_eeMR.SetMarkerColor(5)
265  prof_eeMR.Draw("same")
266  leg.AddEntry(prof_eePL,"Dee1","lp")
267  leg.AddEntry(prof_eePR,"Dee2","lp")
268  leg.AddEntry(prof_eeMR,"Dee3","lp")
269  leg.AddEntry(prof_eeML,"Dee4","lp")
270  leg.Draw()
271  c2.cd(4)
272  ebBorderdist.Draw()
273 
274  extrafilename = "profiles_"+filename
275  # c2.SaveAs(extrafilename)
276 
277  savefile.Write()
278 
def EcalCondTools.listIovs (   db,
  tag 
)
List all available iovs for a given tag

Definition at line 24 of file EcalCondTools.py.

24 
25 def listIovs(db,tag):
26  '''List all available iovs for a given tag'''
27 
28  try :
29  iov = inspect.Iov(db,tag)
30  iovlist = iov.list()
31  print "Available iovs for tag: ",tag
32  for p in iovlist:
33  print " Since " , p[1], " Till " , p[2]
34 
35  except Exception,er :
36  print er
def EcalCondTools.listTags (   db)
List all available tags for a given db 

Definition at line 18 of file EcalCondTools.py.

18 
19 def listTags(db):
20  '''List all available tags for a given db '''
21  tags=db.allTags()
22  for tag in tags.split():
23  print tag
def EcalCondTools.makedist (   coeff_barl,
  coeff_endc 
)

Definition at line 313 of file EcalCondTools.py.

References abs, mathSSE.sqrt(), EcalPyUtils.unhashEBIndex(), and EcalPyUtils.unhashEEIndex().

Referenced by histo().

314 def makedist(coeff_barl, coeff_endc) :
315 
316  ebmap = TH2F("EB","EB",360,1,261,171, -85,86)
317  eePmap = TH2F("EE","EE",100, 1,101,100,1,101)
318  eeMmap = TH2F("EEminus","EEminus",100,1,101,100,1,101)
319  ebdist = TH1F("EBdist","EBdist",100,-2,2)
320  ebBorderdist = TH1F("EBBorderdist","EBBorderdist",100,-2,2)
321 
322  ebeta = TH2F("ebeta","ebeta",171,-85,86,100,-2,2)
323  ebphi = TH2F("ebphi","ebphi",360,1,361,100,-2,2)
324 
325  eePL = TH2F("EEPL","EEPlus Left",50,10,55,100,-2,2)
326  eePR = TH2F("EEPR","EEPlus Right",50,10,55,100,-2,2)
327  eeML = TH2F("EEML","EEMinus Left",50,10,55,100,-2,2)
328  eeMR = TH2F("EEMR","EEMinus Right",50,10,55,100,-2,2)
329 
330  for i,c in enumerate(coeff_barl):
331  ieta,iphi = EcalPyUtils.unhashEBIndex(i)
332  ebmap.Fill(iphi,ieta,c)
333  ebdist.Fill(c)
334  ebeta.Fill(ieta,c)
335  ebphi.Fill(iphi,c)
336 
337  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):
338  ebBorderdist.Fill(c)
339 
340 
341  for i,c in enumerate(coeff_endc):
342  ix,iy,iz = EcalPyUtils.unhashEEIndex(i)
343  R = sqrt((ix-50)*(ix-50)+(iy-50)*(iy-50))
344 
345  if iz>0:
346  eePmap.Fill(ix,iy,c)
347  if ix<50:
348  eePL.Fill(R,c,1)
349  if ix>50:
350  eePR.Fill(R,c,1)
351 
352  if iz<0:
353  eeMmap.Fill(ix,iy,c)
354  if ix<50:
355  eeML.Fill(R,c,1)
356  if ix>50:
357  eeMR.Fill(R,c,1)
358 
359  prof_eePL = eePL.ProfileX()
360  prof_eePR = eePR.ProfileX()
361  prof_eeML = eeML.ProfileX()
362  prof_eeMR = eeMR.ProfileX()
363 
364  return ebmap, ebeta, ebphi, eePmap, ebdist, eeMmap, prof_eePL, prof_eePR, prof_eeML, prof_eeMR, ebBorderdist
#define abs(x)
Definition: mlp_lapack.h:159
T sqrt(T t)
Definition: SSEVec.h:28
def unhashEBIndex
Definition: EcalPyUtils.py:9
def unhashEEIndex
Definition: EcalPyUtils.py:14
def EcalCondTools.plot (   db,
  tag,
  since,
  filename = 'plot.root' 
)
Invoke the plot function from the wrapper and save to the specified \
   file. The file format will reflect the extension given.

Definition at line 49 of file EcalCondTools.py.

References compare(), and getToken().

Referenced by TaggingVariablePlotter.analyzeTag(), DQMHistPlotter.DQMHistPlotter(), SiPixelHistoricInfoReader.endJob(), DQMHistEffProducer.endJob(), DQMHistPlotter.endJob(), DTNoiseAnalysisTest.endLuminosityBlock(), HLTTauDQMSource.endLuminosityBlock(), FlavourHistograms< T >.epsPlot(), SummaryPlotXmlParser.parseXML(), DQMHistPlotter::cfgEntryDrawJob.print(), runInspector(), and TaggingVariablePlotter::VariableConfig.VariableConfig().

49 
50 def plot (db, tag,since,filename='plot.root'):
51  '''Invoke the plot function from the wrapper and save to the specified \
52  file. The file format will reflect the extension given.'''
53 
54  try :
55  iov = inspect.Iov(db,tag)
56  iovlist = iov.list()
57  token = getToken(db,tag,since)
58  payload=inspect.PayLoad(db,token)
59  payload.plot(filename,"",[],[])
60 
61  except Exception,er :
62  print er
63