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 88 of file EcalCondTools.py.
00090 : 00091 '''Produce comparison plots for two records. Save plots to file \ 00092 according to format. tag can be an xml file''' 00093 print "EcalCondTools.py compare tag1 ", tag1, "since1 : ", since1, " tag2 ", tag2," s2 ", since2 00094 00095 coeff_1_b=[] 00096 coeff_2_b=[] 00097 00098 coeff_1_e=[] 00099 coeff_2_e=[] 00100 00101 if tag1.find(".xml") < 0: 00102 found=0 00103 try: 00104 db1.startTransaction() 00105 Plug = __import__(str(db1.payloadModules(tag1)[0])) 00106 payload = Plug.Object(db1) 00107 listOfIovElem= [iovElem for iovElem in db1.iov(tag1).elements] 00108 what = {'how':'barrel'} 00109 w = inspect.setWhat(Plug.What(),what) 00110 exb = Plug.Extractor(w) 00111 what = {'how':'endcap'} 00112 w = inspect.setWhat(Plug.What(),what) 00113 exe = Plug.Extractor(w) 00114 # p = getObject(db1,tag1,since1,ex) 00115 # p.extract(ex) 00116 print " before loop" 00117 for elem in db1.iov(tag1).elements : 00118 if str(elem.since())==str(since1): 00119 found=1 00120 payload.load(elem) 00121 payload.extract(exb) 00122 coeff_1_b = [i for i in exb.values()]# first set of coefficients 00123 payload.extract(exe) 00124 coeff_1_e = [i for i in exe.values()] 00125 db1.commitTransaction() 00126 00127 except Exception,er : 00128 print " compare first set exception ",er 00129 if not found : 00130 print "Could not retrieve payload for tag: " , tag1, " since: ", since1 00131 sys.exit(0) 00132 00133 else: 00134 coeff_1_b,coeff_1_e = EcalPyUtils.fromXML(tag1) 00135 00136 if tag2.find(".xml")<0: 00137 found=0 00138 try: 00139 db2.startTransaction() 00140 Plug = __import__(str(db2.payloadModules(tag2)[0])) 00141 what = {'how':'barrel'} 00142 w = inspect.setWhat(Plug.What(),what) 00143 exb = Plug.Extractor(w) 00144 what = {'how':'endcap'} 00145 w = inspect.setWhat(Plug.What(),what) 00146 exe = Plug.Extractor(w) 00147 # p = getObject(db2,tag2,since2) 00148 # p.extract(ex) 00149 for elem in db2.iov(tag2).elements : 00150 if str(elem.since())==str(since2): 00151 found=1 00152 payload.load(elem) 00153 payload.extract(exb) 00154 coeff_2_b = [i for i in exb.values()]# second set of coefficients 00155 payload.extract(exe) 00156 coeff_2_e = [i for i in exe.values()] 00157 db2.commitTransaction() 00158 00159 except Exception, er : 00160 print " compare second set exception ",er 00161 if not found : 00162 print "Could not retrieve payload for tag: " , tag2, " since: ", since2 00163 sys.exit(0) 00164 00165 else: 00166 coeff_2_b,coeff_2_e = EcalPyUtils.fromXML(tag2) 00167 00168 gStyle.SetPalette(1) 00169 00170 savefile = TFile(filename,"RECREATE") 00171 00172 ebhisto,ebmap, profx, profy= compareBarrel(coeff_1_b,coeff_2_b) 00173 eephisto,eepmap,eemhisto,eemmap=compareEndcap(coeff_1_e,coeff_2_e) 00174 00175 #make more canvas (suppressed : use a root file) 00176 00177 # cEBdiff = TCanvas("EBdiff","EBdiff") 00178 # cEBdiff.Divide(2,2) 00179 00180 # cEBdiff.cd(1) 00181 # ebhisto.Draw() 00182 # cEBdiff.cd(2) 00183 # ebmap.Draw("colz") 00184 # cEBdiff.cd(3) 00185 # profx.Draw() 00186 # cEBdiff.cd(4) 00187 # profy.Draw() 00188 00189 # EBfilename = "EB_"+filename 00190 # cEBdiff.SaveAs(EBfilename) 00191 00192 # cEEdiff = TCanvas("EEdiff","EEdiff") 00193 # cEEdiff.Divide(2,2) 00194 00195 # cEEdiff.cd(1) 00196 # eephisto.Draw() 00197 # cEEdiff.cd(2) 00198 # eepmap.Draw("colz") 00199 # cEEdiff.cd(3) 00200 # eemhisto.Draw() 00201 # cEEdiff.cd(4) 00202 # eemmap.Draw("colz") 00203 00204 # EEfilename = "EE_"+filename 00205 # cEEdiff.SaveAs(EEfilename) 00206 00207 00208 eeborderphisto,eeborderpmap,eebordermhisto,eebordermmap=compareEndcapBorder(coeff_1_e,coeff_2_e) 00209 ebborderhisto,ebbordermap = compareBarrelBorder(coeff_1_b,coeff_2_b) 00210 00211 border_diff_distro_can = TCanvas("border_difference","borders difference") 00212 border_diff_distro_can.Divide(2,3) 00213 00214 border_diff_distro_can.cd(1) 00215 ebborderhisto.Draw() 00216 border_diff_distro_can.cd(2) 00217 ebbordermap.Draw("colz") 00218 border_diff_distro_can.cd(3) 00219 eeborderphisto.Draw() 00220 border_diff_distro_can.cd(4) 00221 eeborderpmap.Draw("colz") 00222 border_diff_distro_can.cd(5) 00223 eebordermhisto.Draw() 00224 border_diff_distro_can.cd(6) 00225 eebordermmap.Draw("colz") 00226 00227 bordersfilename = "borders_"+filename 00228 prof_filename = "profiles_"+filename 00229 00230 # border_diff_distro_can.SaveAs(bordersfilename) 00231 00232 savefile.Write() 00233 00234
def EcalCondTools::compareBarrel | ( | coeff_barl_1, | |
coeff_barl_2 | |||
) |
Return an histogram and a map of the differences
Definition at line 427 of file EcalCondTools.py.
00428 : 00429 '''Return an histogram and a map of the differences ''' 00430 00431 diff_distro_h = TH1F("diffh","diffh",100,-2,2) 00432 diff_distro_m = TH2F("diffm","diffm",360,1,361,171,-85,86) 00433 diff_distro_m.SetStats(0) 00434 ebeta = TH2F("ebeta","ebeta",171,-85,86,100,-2,2) 00435 ebphi = TH2F("ebphi","ebphi",360,1,361,100,-2,2) 00436 00437 00438 for i,c in enumerate(coeff_barl_1): 00439 diff = c - coeff_barl_2[i] 00440 ieta,iphi= EcalPyUtils.unhashEBIndex(i) 00441 diff_distro_h.Fill(diff) 00442 diff_distro_m.Fill(iphi,ieta,diff) 00443 ebeta.Fill(ieta,diff) 00444 ebphi.Fill(iphi,diff) 00445 00446 prof_x_h = ebeta.ProfileX() 00447 prof_y_h = ebphi.ProfileX() 00448 00449 return diff_distro_h, diff_distro_m, prof_x_h, prof_y_h 00450 00451
def EcalCondTools::compareBarrelBorder | ( | coeff_barl_1, | |
coeff_barl_2 | |||
) |
Return an histogram and a map of the differences
Definition at line 452 of file EcalCondTools.py.
00453 : 00454 '''Return an histogram and a map of the differences ''' 00455 00456 diff_distro_border_h = TH1F("diffborderh","diffh",100,-2,2) 00457 diff_distro_border_m = TH2F("diffborderm","diffm",360,1,361,171,-85,86) 00458 diff_distro_border_m.SetStats(0) 00459 00460 for i,c in enumerate(coeff_barl_1): 00461 diff = c - coeff_barl_2[i] 00462 ieta,iphi= EcalPyUtils.unhashEBIndex(i) 00463 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): 00464 diff_distro_border_h.Fill(diff) 00465 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): 00466 diff_distro_border_m.Fill(iphi,ieta,diff) 00467 00468 return diff_distro_border_h, diff_distro_border_m 00469 00470 00471 00472
def EcalCondTools::compareEndcap | ( | coeff_endc_1, | |
coeff_endc_2 | |||
) |
Return an histogram and a map of the differences for each endcap
Definition at line 473 of file EcalCondTools.py.
00474 : 00475 ''' Return an histogram and a map of the differences for each endcap''' 00476 00477 diff_distro_h_eep = TH1F("diff EE+","diff EE+",100,-2,2) 00478 diff_distro_h_eem = TH1F("diff EE-","diff EE-",100,-2,2) 00479 00480 00481 diff_distro_m_eep = TH2F("map EE+","map EE+",100,1,101,100,1,101) 00482 diff_distro_m_eem = TH2F("map EE-","map EE-",100,1,101,100,1,101) 00483 00484 temp_h = TH1F("tempR","tempR",50,0,50) 00485 00486 diff_distro_m_eep.SetStats(0) 00487 diff_distro_m_eem.SetStats(0) 00488 00489 00490 for i,c in enumerate(coeff_endc_1): 00491 diff = c - coeff_endc_2[i] 00492 ix,iy,iz = EcalPyUtils.unhashEEIndex(i) 00493 R = sqrt((ix-50)*(ix-50)+(iy-50)*(iy-50)) 00494 00495 if iz >0: 00496 diff_distro_h_eep.Fill(diff) 00497 diff_distro_m_eep.Fill(ix,iy,diff) 00498 00499 else: 00500 diff_distro_h_eem.Fill(diff) 00501 diff_distro_m_eem.Fill(ix,iy,diff) 00502 00503 return diff_distro_h_eep, \ 00504 diff_distro_m_eep, \ 00505 diff_distro_h_eem, \ 00506 diff_distro_m_eem 00507 00508
def EcalCondTools::compareEndcapBorder | ( | coeff_endc_1, | |
coeff_endc_2 | |||
) |
Return an histogram and a map of the differences for each endcap
Definition at line 509 of file EcalCondTools.py.
00510 : 00511 ''' Return an histogram and a map of the differences for each endcap''' 00512 00513 border_diff_distro_h_eep = TH1F("borderdiff EE+","diff EE+",100,-2,2) 00514 border_diff_distro_h_eem = TH1F("borderdiff EE-","diff EE-",100,-2,2) 00515 00516 00517 border_diff_distro_m_eep = TH2F("bordermap EE+","map EE+",100,1,101,100,1,101) 00518 border_diff_distro_m_eem = TH2F("bordermap EE-","map EE-",100,1,101,100,1,101) 00519 00520 border_diff_distro_m_eep.SetStats(0) 00521 border_diff_distro_m_eem.SetStats(0) 00522 00523 00524 for i,c in enumerate(coeff_endc_1): 00525 diff = c - coeff_endc_2[i] 00526 ix,iy,iz = EcalPyUtils.unhashEEIndex(i) 00527 Rsq = ((ix-50.0)**2+(iy-50.0)**2) 00528 00529 if (iz >0 and (Rsq<144.0 or Rsq>2500.0)): 00530 border_diff_distro_h_eep.Fill(diff) 00531 border_diff_distro_m_eep.Fill(ix,iy,diff) 00532 elif (iz<0 and (Rsq<144.0 or Rsq>2500.0)): 00533 border_diff_distro_h_eem.Fill(diff) 00534 border_diff_distro_m_eem.Fill(ix,iy,diff) 00535 00536 00537 return border_diff_distro_h_eep, \ 00538 border_diff_distro_m_eep, \ 00539 border_diff_distro_h_eem, \ 00540 border_diff_distro_m_eem
def EcalCondTools::dumpXML | ( | db, | |
tag, | |||
since, | |||
filename = 'dump.xml' |
|||
) |
Dump record in XML format for a given tag
Definition at line 42 of file EcalCondTools.py.
Referenced by ecalpyutils::arraystoXML(), cond::PayLoadInspector< DataT >::dump(), EcalFloatCondObjectContainerXMLTranslator::dumpXML(), cond::PayLoadInspector< DataT >::summary(), EcalClusterEnergyCorrectionXMLTranslator::writeXML(), EcalClusterCrackCorrXMLTranslator::writeXML(), EcalTimeOffsetXMLTranslator::writeXML(), EcalClusterEnergyCorrectionObjectSpecificXMLTranslator::writeXML(), EcalTPGStripStatusXMLTranslator::writeXML(), EcalADCToGeVXMLTranslator::writeXML(), EcalTBWeightsXMLTranslator::writeXML(), EcalLaserAPDPNRatiosXMLTranslator::writeXML(), EcalWeightGroupXMLTranslator::writeXML(), EcalTPGCrystalStatusXMLTranslator::writeXML(), EcalTPGTowerStatusXMLTranslator::writeXML(), EcalDAQTowerStatusXMLTranslator::writeXML(), EcalPedestalsXMLTranslator::writeXML(), EcalDCSTowerStatusXMLTranslator::writeXML(), EcalChannelStatusXMLTranslator::writeXML(), EcalGainRatiosXMLTranslator::writeXML(), EcalWeightSetXMLTranslator::writeXML(), EcalFloatCondObjectContainerXMLTranslator::writeXML(), and EcalClusterLocalContCorrXMLTranslator::writeXML().
00043 : 00044 '''Dump record in XML format for a given tag ''' 00045 try : 00046 iov = inspect.Iov(db,tag) 00047 db.startTransaction() 00048 Plug = __import__(str(db.payloadModules(tag)[0])) 00049 payload = Plug.Object(db) 00050 listOfIovElem= [iovElem for iovElem in db.iov(tag).elements] 00051 inst = 0 00052 for elem in db.iov(tag).elements : 00053 inst = inst + 1 00054 if str(elem.since())==str(since): 00055 found = inst 00056 break 00057 db.commitTransaction() 00058 payload = inspect.PayLoad(db, tag, elem) 00059 out = open(filename,'w') 00060 print >> out, payload 00061 00062 except Exception,er : 00063 print " dumpXML exception ",er
def EcalCondTools::getObject | ( | db, | |
tag, | |||
since | |||
) |
Return payload object for a given iov, tag, db
Definition at line 348 of file EcalCondTools.py.
00349 : 00350 ''' Return payload object for a given iov, tag, db''' 00351 found=0 00352 try: 00353 # exec('import '+db.moduleName(tag)+' as Plug') 00354 db.startReadOnlyTransaction() 00355 Plug = __import__(str(db.payloadModules(tag)[0])) 00356 print " getObject Plug" 00357 payload = Plug.Object(db) 00358 db.commitTransaction() 00359 listOfIovElem= [iovElem for iovElem in db.iov(tag).elements] 00360 print " getObject before loop" 00361 for elem in db.iov(tag).elements : 00362 if str(elem.since())==str(since): 00363 found=1 00364 print " getObject found ", elem.since() 00365 # return Plug.Object(elem) 00366 return elem 00367 00368 except Exception, er : 00369 print " getObject exception ",er 00370 00371 if not found : 00372 print "Could not retrieve payload for tag: " , tag, " since: ", since 00373 sys.exit(0) 00374
def EcalCondTools::getToken | ( | db, | |
tag, | |||
since | |||
) |
Return payload token for a given iov, tag, db
Definition at line 332 of file EcalCondTools.py.
00333 : 00334 ''' Return payload token for a given iov, tag, db''' 00335 try : 00336 iov = inspect.Iov(db,tag) 00337 iovlist = iov.list() 00338 for p in iovlist: 00339 tmpsince=p[1] 00340 if str(tmpsince)==str(since) : 00341 return p[0] 00342 print "Could not retrieve token for tag: " , tag, " since: ", since 00343 sys.exit(0) 00344 00345 except Exception, er : 00346 print er 00347
def EcalCondTools::histo | ( | db, | |
tag, | |||
since, | |||
filename = 'histo.root' |
|||
) |
Make histograms and save to file. tag can be an xml file
Definition at line 235 of file EcalCondTools.py.
00236 : 00237 '''Make histograms and save to file. tag can be an xml file''' 00238 00239 coeff_barl=[] 00240 coeff_endc=[] 00241 00242 if tag.find(".xml")< 0: 00243 found=0 00244 try: 00245 # exec('import '+db.moduleName(tag)+' as Plug') 00246 db.startTransaction() 00247 Plug = __import__(str(db.payloadModules(tag)[0])) 00248 payload = Plug.Object(db) 00249 listOfIovElem= [iovElem for iovElem in db.iov(tag).elements] 00250 what = {'how':'barrel'} 00251 w = inspect.setWhat(Plug.What(),what) 00252 exb = Plug.Extractor(w) 00253 what = {'how':'endcap'} 00254 w = inspect.setWhat(Plug.What(),what) 00255 exe = Plug.Extractor(w) 00256 for elem in db.iov(tag).elements : 00257 if str(elem.since())==str(since): 00258 found=1 00259 payload.load(elem) 00260 payload.extract(exb) 00261 coeff_barl = [i for i in exb.values()] 00262 payload.extract(exe) 00263 coeff_endc = [i for i in exe.values()] 00264 db.commitTransaction() 00265 00266 except Exception, er : 00267 print " histo exception ",er 00268 if not found : 00269 print "Could not retrieve payload for tag: " , tag, " since: ", since 00270 sys.exit(0) 00271 00272 else : 00273 coeff_barl,coeff_endc=EcalPyUtils.fromXML(tag) 00274 00275 savefile = TFile(filename,"RECREATE") 00276 00277 ebmap, ebeta, ebphi, eePmap, ebdist, eeMmap, prof_eePL, prof_eePR, prof_eeML, prof_eeMR, ebBorderdist = makedist(coeff_barl, coeff_endc) 00278 00279 gStyle.SetPalette(1) 00280 00281 c = TCanvas("CCdist") 00282 c.Divide(2,2) 00283 00284 c.cd(1) 00285 ebmap.Draw("colz") 00286 c.cd(2) 00287 eePmap.Draw("colz") 00288 c.cd(3) 00289 ebdist.Draw() 00290 c.cd(4) 00291 eeMmap.Draw("colz") 00292 00293 # c.SaveAs(filename) 00294 00295 prof_eb_eta = ebeta.ProfileX() 00296 prof_eb_phi = ebphi.ProfileX() 00297 00298 c2 = TCanvas("CCprofiles") 00299 c2.Divide(2,2) 00300 00301 leg = TLegend(0.1,0.7,0.48,0.9) 00302 00303 c2.cd(1) 00304 prof_eb_eta.Draw() 00305 c2.cd(2) 00306 prof_eb_phi.Draw() 00307 c2.cd(3) 00308 prof_eePL.SetMarkerStyle(8) 00309 prof_eePL.Draw() 00310 prof_eePR.SetMarkerStyle(8) 00311 prof_eePR.SetMarkerColor(2) 00312 prof_eePR.Draw("same") 00313 prof_eeML.SetMarkerStyle(8) 00314 prof_eeML.SetMarkerColor(3) 00315 prof_eeML.Draw("same") 00316 prof_eeMR.SetMarkerStyle(8) 00317 prof_eeMR.SetMarkerColor(5) 00318 prof_eeMR.Draw("same") 00319 leg.AddEntry(prof_eePL,"Dee1","lp") 00320 leg.AddEntry(prof_eePR,"Dee2","lp") 00321 leg.AddEntry(prof_eeMR,"Dee3","lp") 00322 leg.AddEntry(prof_eeML,"Dee4","lp") 00323 leg.Draw() 00324 c2.cd(4) 00325 ebBorderdist.Draw() 00326 00327 extrafilename = "profiles_"+filename 00328 # c2.SaveAs(extrafilename) 00329 00330 savefile.Write() 00331
def EcalCondTools::listIovs | ( | db, | |
tag | |||
) |
List all available iovs for a given tag
Definition at line 29 of file EcalCondTools.py.
00030 : 00031 '''List all available iovs for a given tag''' 00032 00033 try : 00034 iov = inspect.Iov(db,tag) 00035 iovlist = iov.list() 00036 print "Available iovs for tag: ",tag 00037 for p in iovlist: 00038 print " Since " , p[1], " Till " , p[2] 00039 00040 except Exception,er : 00041 print " listIovs exception ",er
def EcalCondTools::listTags | ( | db | ) |
List all available tags for a given db
Definition at line 18 of file EcalCondTools.py.
def EcalCondTools::makedist | ( | coeff_barl, | |
coeff_endc | |||
) |
Definition at line 375 of file EcalCondTools.py.
00376 : 00377 00378 ebmap = TH2F("EB","EB",360,1,261,171, -85,86) 00379 eePmap = TH2F("EE","EE",100, 1,101,100,1,101) 00380 eeMmap = TH2F("EEminus","EEminus",100,1,101,100,1,101) 00381 ebdist = TH1F("EBdist","EBdist",100,-2,2) 00382 ebBorderdist = TH1F("EBBorderdist","EBBorderdist",100,-2,2) 00383 00384 ebeta = TH2F("ebeta","ebeta",171,-85,86,100,-2,2) 00385 ebphi = TH2F("ebphi","ebphi",360,1,361,100,-2,2) 00386 00387 eePL = TH2F("EEPL","EEPlus Left",50,10,55,100,-2,2) 00388 eePR = TH2F("EEPR","EEPlus Right",50,10,55,100,-2,2) 00389 eeML = TH2F("EEML","EEMinus Left",50,10,55,100,-2,2) 00390 eeMR = TH2F("EEMR","EEMinus Right",50,10,55,100,-2,2) 00391 00392 for i,c in enumerate(coeff_barl): 00393 ieta,iphi = EcalPyUtils.unhashEBIndex(i) 00394 ebmap.Fill(iphi,ieta,c) 00395 ebdist.Fill(c) 00396 ebeta.Fill(ieta,c) 00397 ebphi.Fill(iphi,c) 00398 00399 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): 00400 ebBorderdist.Fill(c) 00401 00402 00403 for i,c in enumerate(coeff_endc): 00404 ix,iy,iz = EcalPyUtils.unhashEEIndex(i) 00405 R = sqrt((ix-50)*(ix-50)+(iy-50)*(iy-50)) 00406 00407 if iz>0: 00408 eePmap.Fill(ix,iy,c) 00409 if ix<50: 00410 eePL.Fill(R,c,1) 00411 if ix>50: 00412 eePR.Fill(R,c,1) 00413 00414 if iz<0: 00415 eeMmap.Fill(ix,iy,c) 00416 if ix<50: 00417 eeML.Fill(R,c,1) 00418 if ix>50: 00419 eeMR.Fill(R,c,1) 00420 00421 prof_eePL = eePL.ProfileX() 00422 prof_eePR = eePR.ProfileX() 00423 prof_eeML = eeML.ProfileX() 00424 prof_eeMR = eeMR.ProfileX() 00425 00426 return ebmap, ebeta, ebphi, eePmap, ebdist, eeMmap, prof_eePL, prof_eePR, prof_eeML, prof_eeMR, ebBorderdist
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 64 of file EcalCondTools.py.
00065 : 00066 '''Invoke the plot function from the wrapper and save to the specified \ 00067 file. The file format will reflect the extension given.''' 00068 00069 try : 00070 iov = inspect.Iov(db,tag) 00071 db.startTransaction() 00072 Plug = __import__(str(db.payloadModules(tag)[0])) 00073 payload = Plug.Object(db) 00074 listOfIovElem= [iovElem for iovElem in db.iov(tag).elements] 00075 inst = 0 00076 for elem in db.iov(tag).elements : 00077 inst = inst + 1 00078 if str(elem.since())==str(since): 00079 found = inst 00080 break 00081 db.commitTransaction() 00082 payload = inspect.PayLoad(db, tag, elem) 00083 payload.plot(filename,"",[],[]) 00084 00085 except Exception,er : 00086 print " plot exception ",er 00087