diff --git a/LArCalorimeter/LArBadChannelTool/CMakeLists.txt b/LArCalorimeter/LArBadChannelTool/CMakeLists.txt index d1ca42efc5b33790d80eb83ec8682575faa8becb..f1e6ffa1287319f1224c154bc014e568a7eae369 100644 --- a/LArCalorimeter/LArBadChannelTool/CMakeLists.txt +++ b/LArCalorimeter/LArBadChannelTool/CMakeLists.txt @@ -55,3 +55,10 @@ atlas_install_python_modules( python/*.py ) atlas_install_joboptions( share/*.py ) atlas_install_scripts( share/LArBuildBadChannelDB.sh share/LArBuildMissingFebDB.sh ) +atlas_add_test( flake8 + SCRIPT flake8 --select=ATL,F,E7,E9,W6 ${CMAKE_CURRENT_SOURCE_DIR}/python + POST_EXEC_SCRIPT nopost.sh ) + +atlas_add_test( flake8_share + SCRIPT flake8 --select=ATL,F,E7,E9,W6 --ignore=F401,F821,ATL900 ${CMAKE_CURRENT_SOURCE_DIR}/share + POST_EXEC_SCRIPT nopost.sh ) diff --git a/LArCalorimeter/LArBadChannelTool/python/LArBadChannelAccess.py b/LArCalorimeter/LArBadChannelTool/python/LArBadChannelAccess.py index 1246895938bd2e6fe7f5dc74bc8cced53c6b7275..2b4a864c109d9cc6dc5ef59dc1639d8efd0eff1f 100644 --- a/LArCalorimeter/LArBadChannelTool/python/LArBadChannelAccess.py +++ b/LArCalorimeter/LArBadChannelTool/python/LArBadChannelAccess.py @@ -1,11 +1,13 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +from __future__ import print_function def LArBadChannelAccess(algname="LArBadChannelCondAlg",dbString=None): from AthenaCommon.AlgSequence import AthSequencer condSeq = AthSequencer("AthCondSeq") if hasattr(condSeq,algname): - print "Access to bad Feb info already set up" + print ("Access to bad Feb info already set up") return diff --git a/LArCalorimeter/LArBadChannelTool/python/LArBadChannelBrowserLib.py b/LArCalorimeter/LArBadChannelTool/python/LArBadChannelBrowserLib.py index 709ad6756b748d5fea7e099a963573fc0ac1e524..845a91984e0ba5339adc836c770df71dca8fcf1e 100644 --- a/LArCalorimeter/LArBadChannelTool/python/LArBadChannelBrowserLib.py +++ b/LArCalorimeter/LArBadChannelTool/python/LArBadChannelBrowserLib.py @@ -1,10 +1,11 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from __future__ import print_function -import AthenaCommon.SystemOfUnits as Units from AthenaPython.PyAthena import StatusCode import AthenaPython.PyAthena as PyAthena import sys,os -from PyCool import cool,coral +from PyCool import cool import cppyy import LArBadChannelBrowserTools @@ -82,10 +83,10 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): dbstring="COOLONL_LAR/CONDBR2" try: self.db = self.dbSvc.openDatabase(dbstring,True) - except Exception,e: - print 'Problem opening database',e + except Exception as e: + print ('Problem opening database',e) sys.exit(-1) - print "Opened database",dbstring + print ("Opened database",dbstring) # ----------------------------------------------------------- # Initialize onlineID from detector store @@ -158,7 +159,8 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): # ----------------------------------------------------------- # Select the tag iSelectedTag=LArBadChannelBrowserTools.ChooseOptionFromList("Tag list : ","","",listOfTags,+1,False,{}) - if iSelectedTag<1: return + if iSelectedTag<1: + return self.selectedTag=listOfTags[iSelectedTag-1] # ----------------------------------------------------------- @@ -196,7 +198,8 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): if endOfModif=='q': sDBName=os.environ["PWD"]+"/MissingFebUpdate.db" - if os.path.isfile(sDBName): os.remove(sDBName) + if os.path.isfile(sDBName): + os.remove(sDBName) dbstring="sqlite://;schema="+sDBName+";dbname=BADCHAN" self.dbBrowserMissingFeb.MissingFeb_SaveMissingFebCorrectionsToDatabase(dbstring,self.dbSvc,self.dbFolderName,self.selectedTag) self.dbBrowserMissingFeb.MissingFeb_CheckSavedDatabaseContent(dbstring,self.dbSvc,self.dbFolderName,self.selectedTag) @@ -215,12 +218,14 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): if repCoolChan=="a": iAbortConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to quit ? ") - if iAbortConfirmation==1: return + if iAbortConfirmation==1: + return elif repCoolChan=="q": - print " SAUVEGARDE FINALE" + print (" SAUVEGARDE FINALE") if self.folderId==BAD_CHANNEL: sDBName=os.environ["PWD"]+"/BadChannelUpdate.db" - if os.path.isfile(sDBName): os.remove(sDBName) + if os.path.isfile(sDBName): + os.remove(sDBName) dbstring="sqlite://;schema="+sDBName+";dbname=BADCHAN" self.dbBrowserBadChan.BadChan_SaveBadChannelCorrectionsToDatabase(dbstring,self.dbSvc,self.dbFolderName,self.selectedTag) self.dbBrowserBadChan.BadChan_CheckSavedDatabaseContent(dbstring,self.dbSvc,self.dbFolderName,self.selectedTag) @@ -249,9 +254,9 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): # Get Folder try: f = self.db.getFolder(folderName) - print "Analysing Folder " + str(folderName) - except: - print "Skipping " + str(folderName) + print ("Analysing Folder " + str(folderName)) + except Exception: + print ("Skipping " + str(folderName)) return # get tags @@ -261,29 +266,31 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): sIOVBeginEnd={} for tag in tags: - nobjs = f.countObjects( cool.ValidityKeyMin, - cool.ValidityKeyMax, - cool.ChannelSelection.all(), - tag) + f.countObjects( cool.ValidityKeyMin, + cool.ValidityKeyMax, + cool.ChannelSelection.all(), + tag) objs = f.browseObjects( cool.ValidityKeyMin, cool.ValidityKeyMax, cool.ChannelSelection.all(), tag) - iObjet = 0 while objs.hasNext(): obj = objs.next() - if obj.channelId()>iMaxChannelNumber: iMaxChannelNumber=obj.channelId() + if obj.channelId()>iMaxChannelNumber: + iMaxChannelNumber=obj.channelId() keyTag=tag - if not sIOVBeginEnd.has_key(keyTag): sIOVBeginEnd[keyTag]={} + if keyTag not in sIOVBeginEnd: + sIOVBeginEnd[keyTag]={} keyChan=obj.channelId() - if not sIOVBeginEnd[keyTag].has_key(keyChan): sIOVBeginEnd[keyTag][keyChan]=[] + if keyChan not in sIOVBeginEnd[keyTag]: + sIOVBeginEnd[keyTag][keyChan]=[] sIOVBeginEnd[keyTag][keyChan].append((obj.since()>>32%0x100000000,obj.until()>>32%0x100000000)) -# print "IOV : ",obj.channelId()," : ",obj.since()>>32," ",obj.until()>>32 +# print ("IOV : ",obj.channelId()," : ",obj.since()>>32," ",obj.until()>>32) objs.close() @@ -299,9 +306,9 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): # Get Folder try: f = self.db.getFolder(folderName) - print "Analysing Folder " + str(folderName) - except: - print "Skipping " + str(folderName) + print ("Analysing Folder " + str(folderName)) + except Exception: + print ("Skipping " + str(folderName)) return # get tags @@ -309,14 +316,15 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): for tag in tags: - if tag!=tagName: continue + if tag!=tagName: + continue - print "-> tag : ",tag + print ("-> tag : ",tag) - nobjs = f.countObjects( cool.ValidityKeyMin, - cool.ValidityKeyMax, - cool.ChannelSelection.all(), - tag) + f.countObjects( cool.ValidityKeyMin, + cool.ValidityKeyMax, + cool.ChannelSelection.all(), + tag) objs = f.browseObjects( cool.ValidityKeyMin, cool.ValidityKeyMax, @@ -329,11 +337,11 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): # Select cool channel vs IOV if (obj.since()>>32%0x100000000)==tagIOVNumber[obj.channelId()]: - print "Found object", iObjet, - print "since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', - print "until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', - print "payload", obj.payload(), - print "chan",obj.channelId() + print ("Found object", iObjet, end='') + print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', end='') + print ("until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', end='') + print ("payload", obj.payload(), end='') + print ("chan",obj.channelId()) payload=obj.payload() @@ -344,9 +352,9 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): sChannelKey=obj.channelId() sChannelName=self.dbBrowserMissingFeb.MissingFeb_SetBadChannelDataFromPayload(sChannelKey,payload) - print sChannelKey," ",sChannelName + print (sChannelKey," ",sChannelName) channelNameDict[sChannelKey]=sChannelName - print str(channelNameDict) + print (str(channelNameDict)) iObjet=iObjet+1 @@ -363,10 +371,10 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): try: dbase = dbSvc.openDatabase(dbName,False) - except Exception,e: - print 'Problem opening database',e + except Exception as e: + print ('Problem opening database',e) sys.exit(-1) - print "Opened database",dbName + print ("Opened database",dbName) # Loop over folders folders = dbase.listAllNodes() @@ -374,20 +382,22 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): # Get Folder try: f = dbase.getFolder(ff) - print "Analysing Folder " + str(ff) - except: - print "Skipping " + str(ff) + print ("Analysing Folder " + str(ff)) + except Exception: + print ("Skipping " + str(ff)) continue # get tags tags = f.listTags() # SES - if tags.size()==0: tags.push_back("notag") + if tags.size()==0: + tags.push_back("notag") - print "for tags ", - for tag in tags: print tag + print ("for tags ",) + for tag in tags: + print (tag) for tag in tags: @@ -396,7 +406,7 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): cool.ValidityKeyMax, cool.ChannelSelection.all()) - print "number of objects", nobjs + print ("number of objects", nobjs) objs = f.browseObjects( cool.ValidityKeyMin, cool.ValidityKeyMax, @@ -404,11 +414,11 @@ class LArBadChannelBrowserAlg(PyAthena.Alg): i = 0 while objs.hasNext(): obj = objs.next() - print "Found object", i, - print "since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', - print "until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', - print "payload", obj.payload(), - print "chan",obj.channelId() + print ("Found object", i, end='') + print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', end='') + print ("until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', end='') + print ("payload", obj.payload(), end='') + print ("chan",obj.channelId() ) i += 1 # payloadDict[obj.channelId()]=obj.payload() diff --git a/LArCalorimeter/LArBadChannelTool/python/LArBadChannelBrowserTools.py b/LArCalorimeter/LArBadChannelTool/python/LArBadChannelBrowserTools.py index 591e1b457b38ea7e84d0bc665f820b55475dd315..06163f8ce80d49f15e5348d33cbb84b7e485ed56 100644 --- a/LArCalorimeter/LArBadChannelTool/python/LArBadChannelBrowserTools.py +++ b/LArCalorimeter/LArBadChannelTool/python/LArBadChannelBrowserTools.py @@ -1,80 +1,80 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -import sys -import os -import types - -import AthenaCommon.SystemOfUnits as Units -from AthenaPython.PyAthena import StatusCode -import AthenaPython.PyAthena as PyAthena -from PyCool import cool,coral +from __future__ import print_function def ChooseOptionFromList(sTitle,sMessage,sPrompt,sChoiceList,iPlusMinus,bPlusMinus,optionDict): - print "" - print sTitle + print ("") + print (sTitle) - if bPlusMinus==False: + if bPlusMinus is False: for index,s in enumerate(sChoiceList): - print "%3d : %-20s" % (index+iPlusMinus,s) + print ("%3d : %-20s" % (index+iPlusMinus,s)) else: for index,s in enumerate(sChoiceList): - print "%3d/%3d : %-20s" % (index+iPlusMinus,-index,s) + print ("%3d/%3d : %-20s" % (index+iPlusMinus,-index,s)) # option menu sMenu="" for s,v in optionDict: sMenu=sMenu+s+" "+v+" " - if sMenu!="": print "\n"+sMenu + if sMenu!="": + print ("\n"+sMenu) bValidResponse=False - while bValidResponse==False: + while bValidResponse is False: - print " .. "+sPrompt+" > ", + print (" .. "+sPrompt+" > ", end='') tty = open("/dev/tty", "r+") rep=tty.readline() rep=rep.strip() # response is in option list for s,v in optionDict: - if rep==s: return rep + if rep==s: + return rep # convert response to integer try: iResponse=int(rep) # reponse in indexes - if bPlusMinus==False: - if iResponse in range(iPlusMinus, len(sChoiceList)+iPlusMinus): return iResponse + if bPlusMinus is False: + if iResponse in range(iPlusMinus, len(sChoiceList)+iPlusMinus): + return iResponse # reponse in indexes - if bPlusMinus==True: - if iResponse in range(iPlusMinus, len(sChoiceList)+iPlusMinus+1): return iResponse - if iResponse in range(-len(sChoiceList)+iPlusMinus,iPlusMinus-1): return iResponse + if bPlusMinus is True: + if iResponse in range(iPlusMinus, len(sChoiceList)+iPlusMinus+1): + return iResponse + if iResponse in range(-len(sChoiceList)+iPlusMinus,iPlusMinus-1): + return iResponse - print "WARNING : response out of range" + print ("WARNING : response out of range") - except: - print "???" + except Exception: + print ("???") def TypeEnterToContinue(sMessage): - if sMessage!="": print sMessage - print " .. Type ENTER to continue > ", + if sMessage!="": + print (sMessage) + print (" .. Type ENTER to continue > ", end='') tty = open("/dev/tty", "r+") - rep=tty.readline() + tty.readline() def YesNoQuestion(sMessage): - print "" - print sMessage+" [y/n] :", + print ("") + print (sMessage+" [y/n] :", end='') tty = open("/dev/tty", "r+") rep=tty.readline() rep=rep.strip() - if rep=="y" or rep=="Y": return 1 + if rep=="y" or rep=="Y": + return 1 return 0 diff --git a/LArCalorimeter/LArBadChannelTool/python/LArBadFebAccess.py b/LArCalorimeter/LArBadChannelTool/python/LArBadFebAccess.py index 3060132a969e6567ad7f23f5b6712f093ba8a535..116560844870f9e538bac043af9f940c72098821 100644 --- a/LArCalorimeter/LArBadChannelTool/python/LArBadFebAccess.py +++ b/LArCalorimeter/LArBadChannelTool/python/LArBadFebAccess.py @@ -1,17 +1,19 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration +from __future__ import print_function def LArBadFebAccess(algname="LArBadFebCondAlg", dbString=None): from AthenaCommon.AlgSequence import AthSequencer condSeq = AthSequencer("AthCondSeq") if hasattr(condSeq,algname): - print "Access to bad Feb info already set up" + print ("Access to bad Feb info already set up") return from IOVDbSvc.CondDB import conddb if dbString is not None: - foldername=conddb.extractFolder(dbString) + #foldername=conddb.extractFolder(dbString) conddb.addFolder("",dbString,className='AthenaAttributeList') #else: # if conddb.isOnline or conddb.isMC: diff --git a/LArCalorimeter/LArBadChannelTool/python/LArDBFolderBrowser_BadChan.py b/LArCalorimeter/LArBadChannelTool/python/LArDBFolderBrowser_BadChan.py index 05e9cd2c6f3d1e3ba0fe2cbaea092ad0952b725b..431720d00675ca2a6b7395dd62a644f41afecc2d 100644 --- a/LArCalorimeter/LArBadChannelTool/python/LArDBFolderBrowser_BadChan.py +++ b/LArCalorimeter/LArBadChannelTool/python/LArDBFolderBrowser_BadChan.py @@ -1,13 +1,10 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from __future__ import print_function -import AthenaCommon.SystemOfUnits as Units from AthenaPython.PyAthena import StatusCode -import AthenaPython.PyAthena as PyAthena import sys -from PyCool import cool,coral - -from GaudiKernel.Constants import * -import logging +from PyCool import cool import LArBadChannelBrowserTools @@ -72,7 +69,7 @@ class LArDBFolderBrowser_BadChan(): # Add entry in dictionnary sChannelKey=coolChan - if not self.dict_vectBadChanEntry.has_key(sChannelKey): + if sChannelKey not in self.dict_vectBadChanEntry: self.dict_vectBadChanEntry[sChannelKey]={} # Get channel name from first vect_BadChanEntry element @@ -97,13 +94,14 @@ class LArDBFolderBrowser_BadChan(): listHWidKeys=[x for x in self.dict_vectBadChanEntry[coolChan].keys()] listHWidKeys.sort() - print "" + print ("") for sHWid in listHWidKeys: - if self.dict_vectBadChanEntry_Init[coolChan].has_key(sHWid): + if sHWid in self.dict_vectBadChanEntry_Init[coolChan]: sChanName,badChan_word,sValueInit=self.dict_vectBadChanEntry_Init[coolChan][sHWid] sPrefix="" - if self.dict_vectBadChanEntry_Status[coolChan][sHWid]!=STATUS_INIT:sPrefix="->" + if self.dict_vectBadChanEntry_Status[coolChan][sHWid]!=STATUS_INIT: + sPrefix="->" self.BadChan_DisplayBadChanEntryLine(sPrefix,iChanCmpt,sHWid,sChanName,badChan_word,sValueInit) if self.dict_vectBadChanEntry_Status[coolChan][sHWid]!=STATUS_INIT: @@ -119,9 +117,6 @@ class LArDBFolderBrowser_BadChan(): obj_HWid=self.class_HWIdentifier() obj_HWid.set(sHWid) - cblSvc_id = self.larCablingSvc.cnvToIdentifier(obj_HWid) - cblSvc_string = self.onlineID.print_to_string(cblSvc_id) - barrel_ec=self.onlineID.barrel_ec(obj_HWid) pos_neg=self.onlineID.pos_neg(obj_HWid) feedthrough=self.onlineID.feedthrough(obj_HWid) @@ -132,18 +127,18 @@ class LArDBFolderBrowser_BadChan(): sStatusString=self.BadChan_GetBadChannelPb_String(larBadChannel) if sMessage=="": - print " %5d : %-10s %1d %1d %2d %2d %3d %40s %s " % (iChanCmpt+1,obj_HWid.getString(), + print (" %5d : %-10s %1d %1d %2d %2d %3d %40s %s " % (iChanCmpt+1,obj_HWid.getString(), barrel_ec,pos_neg,feedthrough,slot,channel, - sChanName,sStatusString) + sChanName,sStatusString)) else: - print "%3s %5d : %-10s %1d %1d %2d %2d %3d %40s %s %s" % (sMessage,iChanCmpt+1,obj_HWid.getString(), + print ("%3s %5d : %-10s %1d %1d %2d %2d %3d %40s %s %s" % (sMessage,iChanCmpt+1,obj_HWid.getString(), barrel_ec,pos_neg,feedthrough,slot,channel, - sChanName,sStatusString,sValueInit) + sChanName,sStatusString,sValueInit)) - # print "%5d : %-10s %1d %1d %2d %2d %3d %40s %s // %s" % (iChanCmpt,obj_HWid.getString(), + # print ("%5d : %-10s %1d %1d %2d %2d %3d %40s %s // %s" % (iChanCmpt,obj_HWid.getString(), # barrel_ec,pos_neg,feedthrough,slot,channel, - # sChanName,sStatusString,sValueInit) + # sChanName,sStatusString,sValueInit)) @@ -156,7 +151,7 @@ class LArDBFolderBrowser_BadChan(): version = attrList['Version'] vect_BadChanEntry=self.nspace_LArBadChannelDBTools.decodeBlob(blob,channelSize,statusWordSize,endianness,version, self.nspace_LArBadChannelDBTools.getDefaultMsgStream()) - print "BadChanEntry vector size : ",vect_BadChanEntry.size() + print ("BadChanEntry vector size : ",vect_BadChanEntry.size()) self.BadChan_DisplayBadChanEntryVector(vect_BadChanEntry) @@ -178,7 +173,7 @@ class LArDBFolderBrowser_BadChan(): def BadChan_TransformEntryIntoDictionnary(self,vBadChanEntry): """ Transform the BadChanEntry decoded from blob object into a python dictionnary """ - print "--------------------------- Blob SIZE : ",vBadChanEntry.size() + print ("--------------------------- Blob SIZE : ",vBadChanEntry.size()) iNbBadChannel=vBadChanEntry.size() sChannelDict={} @@ -202,15 +197,20 @@ class LArDBFolderBrowser_BadChan(): """ Get channel HW identifier and its status """ sid = self.onlineID.channel_Id(int(barrel_ec),int(pos_neg),int(feedthrough),int(slot),int(channel)) - print str(barrel_ec)+" "+str(pos_neg)+" "+str(feedthrough)+" "+str(slot)+" "+str(channel)+" => ",sid.getString() + print (str(barrel_ec)+" "+str(pos_neg)+" "+str(feedthrough)+" "+str(slot)+" "+str(channel)+" => ",sid.getString()) # Check if HW identifier is valid bValidWHidentifier=False - if self.onlineID.isEMBchannel(sid): bValidWHidentifier=True - if self.onlineID.isEMECchannel(sid): bValidWHidentifier=True - if self.onlineID.isHECchannel(sid): bValidWHidentifier=True - if self.onlineID.isFCALchannel(sid): bValidWHidentifier=True - if bValidWHidentifier==False: return (-1,sid.getString(),"",0) + if self.onlineID.isEMBchannel(sid): + bValidWHidentifier=True + if self.onlineID.isEMECchannel(sid): + bValidWHidentifier=True + if self.onlineID.isHECchannel(sid): + bValidWHidentifier=True + if self.onlineID.isFCALchannel(sid): + bValidWHidentifier=True + if bValidWHidentifier is False: + return (-1,sid.getString(),"",0) # Check if HW identifier already corresponds to a bad channel for key in self.dict_vectBadChanEntry.keys(): @@ -218,8 +218,8 @@ class LArDBFolderBrowser_BadChan(): sChannelName,badChan_word,x=self.dict_vectBadChanEntry[key][sHWid] if sid.getString()==sHWid: - larBadChannel=self.class_LArBadChannel(badChan_word) - larBadChannelStatus=self.BadChan_GetBadChannelPb_String(larBadChannel) + #larBadChannel=self.class_LArBadChannel(badChan_word) + #larBadChannelStatus=self.BadChan_GetBadChannelPb_String(larBadChannel) return (0,sid.getString(),sChannelName,badChan_word) @@ -294,8 +294,8 @@ class LArDBFolderBrowser_BadChan(): for i in range(0,self.nbProblemType): self.channelProblemTypeList.append(obj_larBadChanBitPacking.stringName(i)) - print "ENUM ProblemType : " - print self.channelProblemTypeList + print ("ENUM ProblemType : ") + print (self.channelProblemTypeList) @@ -310,11 +310,11 @@ class LArDBFolderBrowser_BadChan(): bEndOfCorrection=False while not bEndOfCorrection: - print "" - print ".. To select a channel : enter channel index or barrel_ec pos_neg feedthrough slot channel " - print ".. To add a channel : enter barrel_ec pos_neg feedthrough slot channel " - print ".. To remove a channel : enter -(channel index) " - print ".. Other : s (summary) / r (refresh list) / a (abort) / q (save and quit) .. > ", + print ("") + print (".. To select a channel : enter channel index or barrel_ec pos_neg feedthrough slot channel ") + print (".. To add a channel : enter barrel_ec pos_neg feedthrough slot channel ") + print (".. To remove a channel : enter -(channel index) ") + print (".. Other : s (summary) / r (refresh list) / a (abort) / q (save and quit) .. > ", end='') tty = open("/dev/tty", "r+") rep=tty.readline() rep=rep.strip() @@ -332,31 +332,39 @@ class LArDBFolderBrowser_BadChan(): barrel_ec,pos_neg,feedthrough,slot,channel=rep.split(' ') bReadableAnswer=True iCombinationAnswer=1 - except: - if rep=="a": sTxtAnswer="abort" - elif rep=="r": sTxtAnswer="refresh" - elif rep=="s": sTxtAnswer="summary" - elif rep=="q": sTxtAnswer="save-quit" + except Exception: + if rep=="a": + sTxtAnswer="abort" + elif rep=="r": + sTxtAnswer="refresh" + elif rep=="s": + sTxtAnswer="summary" + elif rep=="q": + sTxtAnswer="save-quit" else: try: iSelection=int(rep) - if iSelection in range(1,iNbBadChannel+1): iSelectedIndex=iSelection - if iSelection in range(-iNbBadChannel-1,0): iSelectedIndex=iSelection - if iSelectedIndex==-99999: bReadableAnswer=False - except: + if iSelection in range(1,iNbBadChannel+1): + iSelectedIndex=iSelection + if iSelection in range(-iNbBadChannel-1,0): + iSelectedIndex=iSelection + if iSelectedIndex==-99999: + bReadableAnswer=False + except Exception: iSelectedIndex=0 bReadableAnswer=False continue - if bReadableAnswer==False: - print "could not decode answer... " + if bReadableAnswer is False: + print ("could not decode answer... ") bEndOfCorrection=False continue # Abort answer if sTxtAnswer=="abort": iAbortConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to quit ? ") - if iAbortConfirmation==1: return + if iAbortConfirmation==1: + return bEndOfCorrection=False # Refresh answer @@ -394,26 +402,28 @@ class LArDBFolderBrowser_BadChan(): else: iRes,sHWid,sChanName,badChan_word=self.BadChan_GetChannelHWIdentifierAndStatus(barrel_ec,pos_neg,feedthrough,slot,channel) if iRes==-1: - print "An error occured while computing HW identifier -> computed HW identifier does not exist" + print ("An error occured while computing HW identifier -> computed HW identifier does not exist") bChangeHWstatus=False if iRes==1: bNewHWidentifier=True if bChangeHWstatus: - print"" - for i in range(0,50): print "-", - print"" - for i in range(0,50): print "-", - print"" + print ("") + for i in range(0,50): + print ("-",) + print ("") + for i in range(0,50): + print ("-",) + print ("") self.BadChan_DisplayBadChanEntryLine("",0,sHWid,sChanName,badChan_word,"") - print " ",self.BadChan_GetCablingServiceNameFromHWIdentifier(sHWid) + print (" ",self.BadChan_GetCablingServiceNameFromHWIdentifier(sHWid)) iRes,sNewStatus=self.BadChan_GetNewChannelStatus(badChan_word) - print "MODIFICATION STATUS : ",badChan_word," ",sNewStatus + print ("MODIFICATION STATUS : ",badChan_word," ",sNewStatus) if iRes==0 and sNewStatus!=badChan_word: - if bNewHWidentifier==False: + if bNewHWidentifier is False: self.dict_vectBadChanEntry_Status[coolChan][sHWid]=STATUS_MODIFIED self.dict_vectBadChanEntry[coolChan][sHWid]=(sChanName,sNewStatus,sValueInit) else: @@ -431,75 +441,6 @@ class LArDBFolderBrowser_BadChan(): return StatusCode.Success - def BadChan_GetChannelHWIdentifierAndStatus(self,barrel_ec,pos_neg,feedthrough,slot,channel): - """ Get channel HW identifier and its status """ - - sid = self.onlineID.channel_Id(int(barrel_ec),int(pos_neg),int(feedthrough),int(slot),int(channel)) - print str(barrel_ec)+" "+str(pos_neg)+" "+str(feedthrough)+" "+str(slot)+" "+str(channel)+" => ",sid.getString() - - # Check if HW identifier is valid - bValidWHidentifier=False - if self.onlineID.isEMBchannel(sid): bValidWHidentifier=True - if self.onlineID.isEMECchannel(sid): bValidWHidentifier=True - if self.onlineID.isHECchannel(sid): bValidWHidentifier=True - if self.onlineID.isFCALchannel(sid): bValidWHidentifier=True - if bValidWHidentifier==False: return (-1,sid.getString(),"",0) - - - # Check if HW identifier already corresponds to a bad channel - for key in self.dict_vectBadChanEntry.keys(): - for sHWid in self.dict_vectBadChanEntry[key].keys(): - - sChannelName,badChan_word,x=self.dict_vectBadChanEntry[key][sHWid] - if sid.getString()==sHWid: - larBadChannel=self.class_LArBadChannel(badChan_word) - larBadChannelStatus=self.BadChan_GetBadChannelPb_String(larBadChannel) - - return (0,sid.getString(),sChannelName,badChan_word) - - # default : new lar bad channel status - sChannelName=self.onlineID.channel_name(sid) - badChan_word=0 - return (1,sid.getString(),sChannelName,badChan_word) - - - def BadChan_GetBadChannelPb_String(self,larBadChannel): - """ Get bad channel ProblemType names """ - - sBadChannelPb="" - for i in range(0,self.nbProblemType): - if larBadChannel.statusBad(i): - sBadChannelPb=sBadChannelPb+self.channelProblemTypeList[i]+"," - - return sBadChannelPb - - - def BadChan_GetBadChannelPb_Int(self,larBadChannel): - """ Get bad channel ProblemType indexes """ - - iBadChannelPb=[] - for i in range(0,self.nbProblemType): - if larBadChannel.statusBad(i): - iBadChannelPb.append(i) - - return iBadChannelPb - - - - def BadChan_GetBadChannelProblemType(self): - """ Get list of problem type defines in LArBadChanBitPacking file """ - - obj_larBadChanBitPacking=self.class_LArBadChanBitPacking() - - self.nbProblemType=int(obj_larBadChanBitPacking.numberOfProblemTypes()) - - self.channelProblemTypeList=[] - for i in range(0,self.nbProblemType): - self.channelProblemTypeList.append(obj_larBadChanBitPacking.stringName(i)) - - print "ENUM ProblemType : " - print self.channelProblemTypeList - def BadChan_GetCablingServiceNameFromHWIdentifier(self, sHWid): """ Get Cabling Service param from HW identifier """ @@ -517,10 +458,10 @@ class LArDBFolderBrowser_BadChan(): listHWidKeys=[x for x in self.dict_vectBadChanEntry[coolChan].keys()] listHWidKeys.sort() -# print listHWidKeys - print "" +# print (listHWidKeys) + print ("") - print "Correction summary : "+self.channelNameDict[coolChan] + print ("Correction summary : "+self.channelNameDict[coolChan]) iNbCorrection=0 for index,sHWid in enumerate(listHWidKeys): if self.dict_vectBadChanEntry_Status[coolChan][sHWid]!=STATUS_INIT: @@ -529,7 +470,8 @@ class LArDBFolderBrowser_BadChan(): self.BadChan_DisplayBadChanEntryLine(channelStatus,index,sHWid,sChanName,badChan_word,"") iNbCorrection += 1 - if iNbCorrection==0: print"-" + if iNbCorrection==0: + print ("-") def BadChan_GetNewChannelStatus(self,badChan_wordInit): @@ -541,27 +483,29 @@ class LArDBFolderBrowser_BadChan(): sTmp="\n" for index,s in enumerate(self.channelProblemTypeList): sTmp=sTmp+"%2d %-20s" % (index,s) - if (index+1)%5==0: sTmp=sTmp+"\n" - print sTmp - print ".. to add/remove a pb : enter index/-index or sequence of indexes" - print ".. other : a : abort / c : cancel correction / r : reset to valid / n : next channel" - print "" + if (index+1)%5==0: + sTmp=sTmp+"\n" + print (sTmp) + print (".. to add/remove a pb : enter index/-index or sequence of indexes") + print (".. other : a : abort / c : cancel correction / r : reset to valid / n : next channel") + print ("") bEndOfStatusCorrection=False larBadChannel=self.class_LArBadChannel(badChan_word) while not bEndOfStatusCorrection: iProblemList=self.BadChan_GetBadChannelPb_Int(larBadChannel) - print "Status ",self.BadChan_GetBadChannelPb_String(larBadChannel)," ",iProblemList - print "" - print ".. > ", + print ("Status ",self.BadChan_GetBadChannelPb_String(larBadChannel)," ",iProblemList) + print ("") + print (".. > ", end='') tty = open("/dev/tty", "r+") rep=tty.readline() rep=rep.strip() if rep=="a": iAbortConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to quit ? ") - if iAbortConfirmation==1: return (-1,badChan_wordInit) + if iAbortConfirmation==1: + return (-1,badChan_wordInit) bEndOfStatusCorrection=False elif rep=="n": badChan_word=larBadChannel.packedData() @@ -569,7 +513,8 @@ class LArDBFolderBrowser_BadChan(): bEndOfStatusCorrection=True elif rep=="c": iCancelConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to cancel correction ? ") - if iCancelConfirmation==1: return (1,STATUS_INIT) + if iCancelConfirmation==1: + return (1,STATUS_INIT) bEndOfStatusCorrection=True else: import re @@ -578,15 +523,18 @@ class LArDBFolderBrowser_BadChan(): sRepSeq=[x for x in sTmp if x !=''] # reset - if "r" in sRepSeq: iProblemList=[] + if "r" in sRepSeq: + iProblemList=[] # Indexes for index in sRepSeq: try: iNewPb=int(index) - if iNewPb in range(1,self.nbProblemType) and iNewPb not in iProblemList: iProblemList.append(iNewPb) - if iNewPb in range(-self.nbProblemType+1,0) and -iNewPb in iProblemList: iProblemList.remove(-iNewPb) - except: + if iNewPb in range(1,self.nbProblemType) and iNewPb not in iProblemList: + iProblemList.append(iNewPb) + if iNewPb in range(-self.nbProblemType+1,0) and -iNewPb in iProblemList: + iProblemList.remove(-iNewPb) + except Exception: continue larBadChannel=self.class_LArBadChannel() @@ -609,7 +557,6 @@ class LArDBFolderBrowser_BadChan(): inst_larBadChannelState=self.class_LArBadChannelState() # Loop over cool channels - bStoreNewCoolChannels=False bNewDBCreated=False for coolChan in listKeys: @@ -641,7 +588,6 @@ class LArDBFolderBrowser_BadChan(): if iNbCorrection>0: for sEntry in vect_BadChanEntry: inst_larBadChannelState.add(sEntry,coolChan) - bStoreNewCoolChannels=True else: continue @@ -653,14 +599,13 @@ class LArDBFolderBrowser_BadChan(): athenaAttrList=self.nspace_LArBadChannelDBTools.createPayload(inst_larBadChannelState.coolChannel(coolChan), attrListSpec) # if save DB has not been created => do it - if bNewDBCreated==False: - import os + if bNewDBCreated is False: try: dbSave = dbSvc.createDatabase(dbstring) - except Exception,e: - print 'Problem opening database',e + except Exception as e: + print ('Problem opening database',e) sys.exit(-1) - print "Opened database",dbstring + print ("Opened database",dbstring) desc='<timeStamp>run-event</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>' @@ -674,7 +619,7 @@ class LArDBFolderBrowser_BadChan(): elif typeName=="blob": coolSpec.extend(attrSpec.name(),cool.StorageType.Blob64k) else: - print "Undefined cool.StorageType "+typeName + print ("Undefined cool.StorageType "+typeName) # myfolder=dbSave.createFolder(dbFolderName, coolSpec, desc, cool.FolderVersioning.SINGLE_VERSION,True) myfolder=dbSave.createFolder(dbFolderName, coolSpec, desc, cool.FolderVersioning.MULTI_VERSION,True) @@ -696,7 +641,7 @@ class LArDBFolderBrowser_BadChan(): myfolder.storeObject(beginRun,endRun,coolPayload,coolChan,selectedTag) # Close new databse - if bNewDBCreated==True: + if bNewDBCreated is True: dbSave.closeDatabase() @@ -706,47 +651,50 @@ class LArDBFolderBrowser_BadChan(): # Dump new database content to screen try: dbase = dbSvc.openDatabase(dbName,False) - except Exception,e: - print 'Problem opening database',e + except Exception as e: + print ('Problem opening database',e) sys.exit(-1) - print "Opened database",dbName + print ("Opened database",dbName) # Get Folder try: f = dbase.getFolder(dbFolderName) - print "Analysing Folder " + str(dbFolderName) - except: - print "Skipping " + str(dbFolderName) + print ("Analysing Folder " + str(dbFolderName)) + except Exception: + print ("Skipping " + str(dbFolderName)) return # get tags tags = f.listTags() # SES - if tags.size()==0: tags.push_back("notag") + if tags.size()==0: + tags.push_back("notag") - print "for tags ", - for tag in tags: print tag + print ("for tags ",) + for tag in tags: + print (tag) bTagFound=False bSavingProcessError=False for tag in tags: - if tag!=selectedTag: continue + if tag!=selectedTag: + continue bTagFound=True - nobjs = f.countObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all()) + f.countObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all()) objs = f.browseObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all()) i = 0 while objs.hasNext(): obj = objs.next() - print "Found object", i, - print "since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', - print "until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', - print "payload", obj.payload(), - print "chan",obj.channelId() + print ("Found object", i, end='') + print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', end='') + print ("until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', end='') + print ("payload", obj.payload(), end='') + print ("chan",obj.channelId() ) # Get components of payload object payload=obj.payload() @@ -765,21 +713,23 @@ class LArDBFolderBrowser_BadChan(): sChannelKey=obj.channelId() HWidChecked={} - for key in sChannelDict.keys(): HWidChecked[key]=0 + for key in sChannelDict.keys(): + HWidChecked[key]=0 - print " -> SQlite database content vs initial data : channel ", sChannelKey + print (" -> SQlite database content vs initial data : channel ", sChannelKey) # Check all the saved data vs initial data listHWidKeys=[x for x in sChannelDict.keys()] for x in self.dict_vectBadChanEntry_Status[sChannelKey].keys(): - if x not in listHWidKeys: listHWidKeys.append(x) + if x not in listHWidKeys: + listHWidKeys.append(x) listHWidKeys.sort() iChanCmpt=0 for keyHWid in listHWidKeys: try: sChanName,badChan_word,sValueInit=sChannelDict[keyHWid] - except: + except Exception: sChanName="UNDEFINED" badChan_word=0 @@ -794,7 +744,7 @@ class LArDBFolderBrowser_BadChan(): self.BadChan_DisplayBadChanEntryLine(sPrefix,iChanCmpt,keyHWid,sChanName,badChan_word,sSuffix) if self.dict_vectBadChanEntry_Status[sChannelKey][keyHWid]==STATUS_REMOVED: - if sChannelDict.has_key(keyHWid): + if keyHWid in sChannelDict: sPrefix="ERR" sSuffix=" deletion not taken into accout"+keyHWid bSavingProcessError=True @@ -825,21 +775,21 @@ class LArDBFolderBrowser_BadChan(): iChanCmpt += 1 for key in self.dict_vectBadChanEntry_Status[sChannelKey].keys(): - if not HWidChecked.has_key(key) and self.dict_vectBadChanEntry_Status[sChannelKey][key]!=STATUS_REMOVED: - print "ERROR : initial ",key," has not been saved" - elif HWidChecked.has_key(key) and HWidChecked[key]==0: - print "ERROR : ",key," has not been checked" + if key not in HWidChecked and self.dict_vectBadChanEntry_Status[sChannelKey][key]!=STATUS_REMOVED: + print ("ERROR : initial ",key," has not been saved") + elif key in HWidChecked and HWidChecked[key]==0: + print ("ERROR : ",key," has not been checked") i += 1 objs.close() - if bTagFound==False: - print "ERROR : tag "+selectedTag+" not found in saved SQlite file" + if bTagFound is False: + print ("ERROR : tag "+selectedTag+" not found in saved SQlite file") - if bSavingProcessError==True: - print "ERROR : found while making comparison between corrected and saved datas" + if bSavingProcessError is True: + print ("ERROR : found while making comparison between corrected and saved datas" ) dbase.closeDatabase() diff --git a/LArCalorimeter/LArBadChannelTool/python/LArDBFolderBrowser_MissingFEBs.py b/LArCalorimeter/LArBadChannelTool/python/LArDBFolderBrowser_MissingFEBs.py index b74e267399efdbce80a2b111d94d17ec63c667dd..180ef70341de0d7fad93d82a88079632645d98e0 100644 --- a/LArCalorimeter/LArBadChannelTool/python/LArDBFolderBrowser_MissingFEBs.py +++ b/LArCalorimeter/LArBadChannelTool/python/LArDBFolderBrowser_MissingFEBs.py @@ -1,11 +1,10 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from __future__ import print_function -import AthenaCommon.SystemOfUnits as Units from AthenaPython.PyAthena import StatusCode -import AthenaPython.PyAthena as PyAthena import sys -import os -from PyCool import cool,coral +from PyCool import cool import LArBadChannelBrowserTools @@ -53,13 +52,14 @@ class LArDBFolderBrowser_MissingFEBs(): self.nspace_LArBadChannelDBTools.getDefaultMsgStream()) - print vect_MissingFebHWid.size() - for s in vect_MissingFebHWid: print s, - print "" + print (vect_MissingFebHWid.size()) + for s in vect_MissingFebHWid: + print (s, end='') + print ("") # Add entry in dictionnary sChannelKey=coolChan - if not self.dict_vectMissingFebHWid.has_key(sChannelKey): + if sChannelKey not in self.dict_vectMissingFebHWid: self.dict_vectMissingFebHWid[sChannelKey]={} # Transform vect_BadChanNetry into python dictionnary @@ -83,13 +83,14 @@ class LArDBFolderBrowser_MissingFEBs(): listHWidKeys=[x for x in self.dict_vectMissingFebHWid[coolChan].keys()] listHWidKeys.sort() - print "" + print ("") for sHWid in listHWidKeys: - if self.dict_vectMissingFebHWid_Init[coolChan].has_key(sHWid): + if sHWid in self.dict_vectMissingFebHWid_Init[coolChan]: sChanName,sStatus,sValueInit=self.dict_vectMissingFebHWid_Init[coolChan][sHWid] sPrefix="" - if self.dict_vectMissingFebHWid_Status[coolChan][sHWid]!=STATUS_INIT:sPrefix="->" + if self.dict_vectMissingFebHWid_Status[coolChan][sHWid]!=STATUS_INIT: + sPrefix="->" self.MissingFeb_DisplayMissingFebLine(sPrefix,iChanCmpt,sHWid,sChanName,sStatus,"") if self.dict_vectMissingFebHWid_Status[coolChan][sHWid]!=STATUS_INIT: @@ -103,9 +104,6 @@ class LArDBFolderBrowser_MissingFEBs(): obj_HWid=self.class_HWIdentifier() obj_HWid.set(sHWid) - - cblSvc_id = self.larCablingSvc.cnvToIdentifier(obj_HWid) - cblSvc_string = self.onlineID.print_to_string(cblSvc_id) barrel_ec=self.onlineID.barrel_ec(obj_HWid) pos_neg=self.onlineID.pos_neg(obj_HWid) @@ -114,21 +112,21 @@ class LArDBFolderBrowser_MissingFEBs(): channel=self.onlineID.channel(obj_HWid) if sMessage=="": - print " %5d : %-10s %1d %1d %2d %2d %3d %40s %s " % (iChanCmpt+1,obj_HWid.getString(), + print (" %5d : %-10s %1d %1d %2d %2d %3d %40s %s " % (iChanCmpt+1,obj_HWid.getString(), barrel_ec,pos_neg,feedthrough,slot,channel, - sChanName,sStatusValue) + sChanName,sStatusValue)) else: - print "%3s %5d : %-10s %1d %1d %2d %2d %3d %40s %s %s" % (sMessage,iChanCmpt+1,obj_HWid.getString(), + print ("%3s %5d : %-10s %1d %1d %2d %2d %3d %40s %s %s" % (sMessage,iChanCmpt+1,obj_HWid.getString(), barrel_ec,pos_neg,feedthrough,slot,channel, - sChanName,sStatusValue,sValueInit) + sChanName,sStatusValue,sValueInit)) def MissingFeb_ShowMissingFebCorrectionsSummary(self,coolChan): listHWidKeys=[x for x in self.dict_vectMissingFebHWid[coolChan].keys()] listHWidKeys.sort() - print "" - print "Correction summary : " + print ("") + print ("Correction summary : ") iNbCorrection=0 for index,sHWid in enumerate(listHWidKeys): if self.dict_vectMissingFebHWid_Status[coolChan][sHWid]!=STATUS_INIT: @@ -137,13 +135,14 @@ class LArDBFolderBrowser_MissingFEBs(): self.MissingFeb_DisplayMissingFebLine(channelStatus,index,sHWid,sChanName,badChan_word,"") iNbCorrection += 1 - if iNbCorrection==0: print"-" + if iNbCorrection==0: + print ("-") def MissingFeb_TransformEntryIntoDictionnary(self,vMissingFEBHWid): """ Transform the missing FEB decoded from blob object into a python dictionnary """ - print "--------------------------- Blob SIZE : ",vMissingFEBHWid.size() + print ("--------------------------- Blob SIZE : ",vMissingFEBHWid.size()) iNbMissingFEB=vMissingFEBHWid.size() sChannelDict={} @@ -171,10 +170,10 @@ class LArDBFolderBrowser_MissingFEBs(): bEndOfCorrection=False while not bEndOfCorrection: - print "" - print ".. To add a missing feb : enter barrel_ec pos_neg feedthrough slot " - print ".. To remove a missing feb : enter -(channel index) " - print ".. Other : s (summary) / r (refresh list) / a (abort) / q (save and quit) .. > ", + print ("") + print (".. To add a missing feb : enter barrel_ec pos_neg feedthrough slot ") + print (".. To remove a missing feb : enter -(channel index) ") + print (".. Other : s (summary) / r (refresh list) / a (abort) / q (save and quit) .. > ",) tty = open("/dev/tty", "r+") rep=tty.readline() rep=rep.strip() @@ -193,31 +192,39 @@ class LArDBFolderBrowser_MissingFEBs(): channel=0 bReadableAnswer=True iCombinationAnswer=1 - except: - if rep=="a": sTxtAnswer="abort" - elif rep=="r": sTxtAnswer="refresh" - elif rep=="s": sTxtAnswer="summary" - elif rep=="q": sTxtAnswer="save-quit" + except Exception: + if rep=="a": + sTxtAnswer="abort" + elif rep=="r": + sTxtAnswer="refresh" + elif rep=="s": + sTxtAnswer="summary" + elif rep=="q": + sTxtAnswer="save-quit" else: try: iSelection=int(rep) - if iSelection in range(1,iNbBadChannel+1): iSelectedIndex=iSelection - if iSelection in range(-iNbBadChannel-1,0): iSelectedIndex=iSelection - if iSelectedIndex==-99999: bReadableAnswer=False - except: + if iSelection in range(1,iNbBadChannel+1): + iSelectedIndex=iSelection + if iSelection in range(-iNbBadChannel-1,0): + iSelectedIndex=iSelection + if iSelectedIndex==-99999: + bReadableAnswer=False + except Exception: iSelectedIndex=0 bReadableAnswer=False continue - if bReadableAnswer==False: - print "could not decode answer... " + if bReadableAnswer is False: + print ("could not decode answer... ") bEndOfCorrection=False continue # Abort answer if sTxtAnswer=="abort": iAbortConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to quit ? ") - if iAbortConfirmation==1: return 'a' + if iAbortConfirmation==1: + return 'a' bEndOfCorrection=False # Refresh answer @@ -254,7 +261,7 @@ class LArDBFolderBrowser_MissingFEBs(): else: iRes,sHWid,sChanName,sFebStatus=self.MissingFeb_GetChannelHWIdentifierAndStatus(barrel_ec,pos_neg,feedthrough,slot,channel) if iRes==0 : - print "FEB already defined as missing" + print ("FEB already defined as missing") sValueInit=self.dict_vectMissingFebHWid[coolChan][sHWid][2] else: sValueInit="None" @@ -273,15 +280,20 @@ class LArDBFolderBrowser_MissingFEBs(): """ Get channel HW identifier and its status """ sid = self.onlineID.channel_Id(int(barrel_ec),int(pos_neg),int(feedthrough),int(slot),int(channel)) - print str(barrel_ec)+" "+str(pos_neg)+" "+str(feedthrough)+" "+str(slot)+" "+str(channel)+" => ",sid.getString() + print (str(barrel_ec)+" "+str(pos_neg)+" "+str(feedthrough)+" "+str(slot)+" "+str(channel)+" => ",sid.getString()) # Check if HW identifier is valid bValidWHidentifier=False - if self.onlineID.isEMBchannel(sid): bValidWHidentifier=True - if self.onlineID.isEMECchannel(sid): bValidWHidentifier=True - if self.onlineID.isHECchannel(sid): bValidWHidentifier=True - if self.onlineID.isFCALchannel(sid): bValidWHidentifier=True - if bValidWHidentifier==False: return (-1,sid.getString(),"",0) + if self.onlineID.isEMBchannel(sid): + bValidWHidentifier=True + if self.onlineID.isEMECchannel(sid): + bValidWHidentifier=True + if self.onlineID.isHECchannel(sid): + bValidWHidentifier=True + if self.onlineID.isFCALchannel(sid): + bValidWHidentifier=True + if bValidWHidentifier is False: + return (-1,sid.getString(),"",0) for key in self.dict_vectMissingFebHWid.keys(): for sHWid in self.dict_vectMissingFebHWid[key].keys(): @@ -299,8 +311,6 @@ class LArDBFolderBrowser_MissingFEBs(): listKeys.sort() # Loop over cool channels - bStoreNewCoolChannels=False - bNewDBCreated=False vect_MissingFebHWid=cppyy.gbl.std.vector('HWIdentifier')() @@ -312,10 +322,12 @@ class LArDBFolderBrowser_MissingFEBs(): sHWid=key if self.dict_vectMissingFebHWid_Status[coolChan][sHWid]==STATUS_INIT: - sStatusFeb=self.dict_vectMissingFebHWid_Init[coolChan][sHWid][1] + #StatusFeb=self.dict_vectMissingFebHWid_Init[coolChan][sHWid][1] + pass elif self.dict_vectMissingFebHWid_Status[coolChan][sHWid]==STATUS_MODIFIED or self.dict_vectMissingFebHWid_Status[coolChan][sHWid]==STATUS_NEW: iNbCorrection += 1 - sStatusFeb=self.dict_vectMissingFebHWid[coolChan][sHWid][1] + #sStatusFeb=self.dict_vectMissingFebHWid[coolChan][sHWid][1] + pass elif self.dict_vectMissingFebHWid_Status[coolChan][sHWid]==STATUS_REMOVED: iNbCorrection += 1 continue @@ -327,9 +339,9 @@ class LArDBFolderBrowser_MissingFEBs(): # if correction were made => store MissingFebHWid vector if iNbCorrection>0: - bStoreNewCoolChannels=True + pass else: - print "No correcton to save" + print ("No correcton to save") return # Create object based on new LArBadChannelState (via LArBadChannelDBTools python interface) @@ -340,13 +352,12 @@ class LArDBFolderBrowser_MissingFEBs(): athenaAttrList=self.nspace_LArBadChannelDBTools.createFebPayload(vect_MissingFebHWid) # new DB creation - import os try: dbSave = dbSvc.createDatabase(dbstring) - except Exception,e: - print 'Problem opening database',e + except Exception as e: + print ('Problem opening database',e) sys.exit(-1) - print "Opened database",dbstring + print ("Opened database",dbstring) desc='<timeStamp>run-event</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>' @@ -360,7 +371,7 @@ class LArDBFolderBrowser_MissingFEBs(): elif typeName=="blob": coolSpec.extend(attrSpec.name(),cool.StorageType.Blob64k) else: - print "Undefined cool.StorageType "+typeName + print ("Undefined cool.StorageType "+typeName) myfolder=dbSave.createFolder(dbFolderName, coolSpec, desc, cool.FolderVersioning.MULTI_VERSION,True) @@ -388,47 +399,50 @@ class LArDBFolderBrowser_MissingFEBs(): # Dump new database content to screen try: dbase = dbSvc.openDatabase(dbName,False) - except Exception,e: - print 'Problem opening database',e + except Exception as e: + print ('Problem opening database',e) sys.exit(-1) - print "Opened database",dbName + print ("Opened database",dbName) # Get Folder try: f = dbase.getFolder(dbFolderName) - print "Analysing Folder " + str(dbFolderName) - except: - print "Skipping " + str(dbFolderName) + print ("Analysing Folder " + str(dbFolderName)) + except Exception: + print ("Skipping " + str(dbFolderName)) return # get tags tags = f.listTags() # SES - if tags.size()==0: tags.push_back("notag") + if tags.size()==0: + tags.push_back("notag") - print "for tags ", - for tag in tags: print tag + print ("for tags ", end='') + for tag in tags: + print (tag) bTagFound=False bSavingProcessError=False for tag in tags: - if tag!=selectedTag: continue + if tag!=selectedTag: + continue bTagFound=True - nobjs = f.countObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all()) + f.countObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all()) objs = f.browseObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all()) i = 0 while objs.hasNext(): obj = objs.next() - print "Found object", i, - print "since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', - print "until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', - print "payload", obj.payload(), - print "chan",obj.channelId() + print ("Found object", i, end='') + print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', end='') + print ("until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', end='') + print ("payload", obj.payload(), end='') + print ("chan",obj.channelId() ) # Get components of payload object payload=obj.payload() @@ -447,21 +461,23 @@ class LArDBFolderBrowser_MissingFEBs(): sChannelKey=obj.channelId() HWidChecked={} - for key in sChannelDict.keys(): HWidChecked[key]=0 + for key in sChannelDict.keys(): + HWidChecked[key]=0 - print " -> SQlite database content vs initial data : channel ", sChannelKey + print (" -> SQlite database content vs initial data : channel ", sChannelKey) # Check all the saved data vs initial data listHWidKeys=[x for x in sChannelDict.keys()] for x in self.dict_vectMissingFebHWid_Status[sChannelKey].keys(): - if x not in listHWidKeys: listHWidKeys.append(x) + if x not in listHWidKeys: + listHWidKeys.append(x) listHWidKeys.sort() iChanCmpt=0 for keyHWid in listHWidKeys: try: sChanName,sFebStatus,sValueInit=sChannelDict[keyHWid] - except: + except Exception: sChanName="UNDEFINED" sFebStatus=0 @@ -476,7 +492,7 @@ class LArDBFolderBrowser_MissingFEBs(): self.MissingFeb_DisplayMissingFebLine(sPrefix,iChanCmpt,keyHWid,sChanName,sFebStatus,sSuffix) if self.dict_vectMissingFebHWid_Status[sChannelKey][keyHWid]==STATUS_REMOVED: - if sChannelDict.has_key(keyHWid): + if keyHWid in sChannelDict: sPrefix="ERR" sSuffix=" deletion not taken into accout"+keyHWid bSavingProcessError=True @@ -507,21 +523,21 @@ class LArDBFolderBrowser_MissingFEBs(): iChanCmpt += 1 for key in self.dict_vectMissingFebHWid_Status[sChannelKey].keys(): - if not HWidChecked.has_key(key) and self.dict_vectMissingFebHWid_Status[sChannelKey][key]!=STATUS_REMOVED: - print "ERROR : initial ",key," has not been saved" - elif HWidChecked.has_key(key) and HWidChecked[key]==0: - print "ERROR : ",key," has not been checked" + if key not in HWidChecked and self.dict_vectMissingFebHWid_Status[sChannelKey][key]!=STATUS_REMOVED: + print ("ERROR : initial ",key," has not been saved") + elif key in HWidChecked and HWidChecked[key]==0: + print ("ERROR : ",key," has not been checked") i += 1 objs.close() - if bTagFound==False: - print "ERROR : tag "+selectedTag+" not found in saved SQlite file" + if bTagFound is False: + print ("ERROR : tag "+selectedTag+" not found in saved SQlite file") - if bSavingProcessError==True: - print "ERROR : found while making comparison between corrected and saved datas" + if bSavingProcessError is True: + print ("ERROR : found while making comparison between corrected and saved datas" ) dbase.closeDatabase() diff --git a/LArCalorimeter/LArBadChannelTool/python/UpdateManyBadChannelIOVs.py b/LArCalorimeter/LArBadChannelTool/python/UpdateManyBadChannelIOVs.py index 2717cabba6c4d0127242d10cbee2e8f94e0ac7be..454cd71ce945b71fe302ff1dd6da87da1d842a4c 100644 --- a/LArCalorimeter/LArBadChannelTool/python/UpdateManyBadChannelIOVs.py +++ b/LArCalorimeter/LArBadChannelTool/python/UpdateManyBadChannelIOVs.py @@ -1,25 +1,27 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration -from PyCool import cool,coral +from __future__ import print_function + +from PyCool import cool from struct import pack,unpack from copy import deepcopy def addAndRemove(dbname,folder,tag,ts1,ts2,chansToAdd=dict(),chansToRemove=()): - print "Add:",chansToAdd - print "Rem:",chansToRemove + print ("Add:",chansToAdd) + print ("Rem:",chansToRemove) dbSvc = cool.DatabaseSvcFactory.databaseService() try: db1= dbSvc.openDatabase(dbname,False) - except Exception,e: - print "Problems connecting to database:",e + except Exception as e: + print ("Problems connecting to database:",e) return 1 if not db1.existsFolder(folder): - print "ERROR folder",folder,"does not exist in",inputdb + print ("ERROR folder",folder,"does not exist in",dbname) return fd1=db1.getFolder(folder) @@ -30,7 +32,7 @@ def addAndRemove(dbname,folder,tag,ts1,ts2,chansToAdd=dict(),chansToRemove=()): payload=obj.payload() since=obj.since() cc=obj.channelId() - #print "Working on channel %i valid since run %i" % (cc,since>>32) + #print ("Working on channel %i valid since run %i" % (cc,since>>32)) if since<ts1: since=ts1 @@ -38,7 +40,7 @@ def addAndRemove(dbname,folder,tag,ts1,ts2,chansToAdd=dict(),chansToRemove=()): touched=False - if chansToAdd.has_key(cc): + if cc in chansToAdd: toAdd=deepcopy(chansToAdd[cc]) touched=True else: @@ -48,19 +50,19 @@ def addAndRemove(dbname,folder,tag,ts1,ts2,chansToAdd=dict(),chansToRemove=()): for i in range(bcBlob.size()/8): (ch,bc)=unpack('II',bcBlob.read(8)) if ch in chansToRemove: - print "Removing entry [0x%x 0x%x] from COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32) + print ("Removing entry [0x%x 0x%x] from COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32)) touched=True continue - if toAdd.has_key(ch): + if ch in toAdd: bc|=toAdd.pop(ch) - print "Augmenting existing channel 0x%x to 0x%x in COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32) + print ("Augmenting existing channel 0x%x to 0x%x in COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32)) newData+=((ch,bc),) #Adding channels: - for (ch,bc) in toAdd.iteritems(): - print "Adding entry [0x%x 0x%x] to COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32) + for (ch,bc) in toAdd.items(): + print ("Adding entry [0x%x 0x%x] to COOL channel %i, IOV start run %i" % (ch,bc,cc, since>>32)) newData+=((ch,bc),) @@ -70,7 +72,7 @@ def addAndRemove(dbname,folder,tag,ts1,ts2,chansToAdd=dict(),chansToRemove=()): for i in range(len(newData)): bcBlob.write(pack("II",newData[i][0],newData[i][1])) - print "Storing changed object channel %i, valid from run %i to %i" % (cc,since>>32,obj.until()>>32) + print ("Storing changed object channel %i, valid from run %i to %i" % (cc,since>>32,obj.until()>>32)) fd1.storeObject(since,obj.until(),payload,cc,tag,True) itr.close() diff --git a/LArCalorimeter/LArBadChannelTool/python/getMissingFebs.py b/LArCalorimeter/LArBadChannelTool/python/getMissingFebs.py index 7c35875536a8a939d77c3b7070b862e95f0d5128..b72592543bacc6a5a3057ab704e6ea5bc4c97199 100644 --- a/LArCalorimeter/LArBadChannelTool/python/getMissingFebs.py +++ b/LArCalorimeter/LArBadChannelTool/python/getMissingFebs.py @@ -1,8 +1,9 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from __future__ import print_function from PyCool import cool import ROOT -import cppyy import sys # Make sure the dictionary is loaded. @@ -25,24 +26,24 @@ def getMissingFebs(run, tag=None): dbSvc = cool.DatabaseSvcFactory.databaseService() try: db= dbSvc.openDatabase(dbName) - except Exception,e: - print "Problems connecting to database:",e + except Exception as e: + print ("Problems connecting to database:",e) return None - print "getMissingFEBs: Checking tag",tag,"for run",run + print ("getMissingFEBs: Checking tag",tag,"for run",run) if not db.existsFolder(fName): - print "ERROR: Folder",fName,"not found in ",dbName + print ("ERROR: Folder",fName,"not found in ",dbName) return None f=db.getFolder(fName) if not f.existsUserTag(tag): try: t=f.resolveTag(tag) - except Exception,e: - print "ERROR: Tag",tag,"not defined in folder",fName - print e + except Exception as e: + print ("ERROR: Tag",tag,"not defined in folder",fName) + print (e) return None else: t=tag @@ -54,13 +55,13 @@ def getMissingFebs(run, tag=None): - ts1=cool.ValidityKey(1L+(run<<32)) - ts2=cool.ValidityKey(((run+1L)<<32)-1) + ts1=cool.ValidityKey(1+(run<<32)) + ts2=cool.ValidityKey(((run+1)<<32)-1) itr=f.browseObjects(ts1,ts2,cool.ChannelSelection(0),t) while itr.goToNext(): obj=itr.currentRef() pl=obj.payload() - #print obj.since(), obj.until(), pl + #print (obj.since(), obj.until(), pl) al=cl_AthenaAttributeList(pl.attributeList()) vect_BadFebEntry=cl_LArBadChannelDBTools.readBadFeb(al,ms) @@ -76,4 +77,4 @@ def getMissingFebs(run, tag=None): return retval -#print getMissingFebs(201489,"COMCOND-BLKPA-006-03") +#print (getMissingFebs(201489,"COMCOND-BLKPA-006-03")) diff --git a/LArCalorimeter/LArBadChannelTool/share/LArBadChannel2Ascii.py b/LArCalorimeter/LArBadChannelTool/share/LArBadChannel2Ascii.py index 259c3cbd4748d4133aa5021e2ef2367b621dc5a3..6c83c1d7b41e206bc52b8439fda38294cc9ccbb2 100644 --- a/LArCalorimeter/LArBadChannelTool/share/LArBadChannel2Ascii.py +++ b/LArCalorimeter/LArBadChannelTool/share/LArBadChannel2Ascii.py @@ -1,3 +1,5 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + if 'OutputFile' not in dir(): OutputFile="bc_output.txt" @@ -9,7 +11,7 @@ if 'DBString' not in dir(): if 'sqlite' in dir(): dbStr="<db>sqlite://;schema="+sqlite+";dbname="+DBInstance+"</db>" - if not 'tag' in dir(): + if 'tag' not in dir(): tag="LARBadChannelsOflBadChannels-UPD4-00" else: dbStr=DBString+DBInstance+"</db>" @@ -19,16 +21,16 @@ if 'tag' in dir(): else: tagStr="" -if not 'IOVEndRun' in dir(): +if 'IOVEndRun' not in dir(): IOVEndRun = -1 -if not 'IOVEndLB' in dir(): +if 'IOVEndLB' not in dir(): IOVEndLB = -1 -if not 'folderStr' in dir(): +if 'folderStr' not in dir(): folderStr="/LAR/BadChannelsOfl/BadChannels" -if not 'ExecutiveSummaryFile' in dir(): +if 'ExecutiveSummaryFile' not in dir(): ExecutiveSummaryFile="" @@ -76,7 +78,7 @@ from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() ## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc -from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr) from AthenaCommon.AlgSequence import AthSequencer diff --git a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelBrowser.py b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelBrowser.py index 656f919c4695059f15c73ad7afa0684150b5ad84..3decb8b159eff17faf6e644e9ae0d437c033d9e4 100644 --- a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelBrowser.py +++ b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelBrowser.py @@ -1,13 +1,8 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + ## @file MyPyAna/share/myjob.py ## @purpose steering job option file for MyAlg -import sys -import AthenaPython.PyAthena as PyAthena - -## get a handle on the sequence of algorithms to be run -import AthenaCommon.SystemOfUnits as Units - - from AthenaCommon.GlobalFlags import GlobalFlags GlobalFlags.DetGeo.set_commis() GlobalFlags.Luminosity.set_zero() diff --git a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelDBAlg.py b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelDBAlg.py index 85a9ee08d1baf162c7b819299c6be0eb1bd47d84..f05d83a5f750291a306aedd28011d2ee9faffc2e 100644 --- a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelDBAlg.py +++ b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelDBAlg.py @@ -1,3 +1,5 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + #No input file -> use MC event selector if 'DBInstance' not in dir(): @@ -27,7 +29,6 @@ if "IOVEndLB" not in dir(): if "sqlite" not in dir(): sqlite="BadChannels.db" -from string import * import AthenaCommon.AtlasUnixGeneratorJob from AthenaCommon.GlobalFlags import globalflags @@ -75,8 +76,7 @@ svcMgr.IOVDbSvc.GlobalTag="CONDBR2-ES1PA-2014-01" from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() -## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc -from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr) theApp.EvtMax=1 @@ -95,7 +95,7 @@ condSeq = AthSequencer("AthCondSeq") condSeq+=theLArBadChannelCondAlg OutputList=[ "CondAttrListCollection#"+Folder ] -Tag=join(split(Folder, '/'),'') + TagPostfix +Tag=''.join(Folder.split ('/')) + TagPostfix OutputTagList=[Tag] from RegistrationServices.OutputConditionsAlg import OutputConditionsAlg @@ -117,6 +117,7 @@ svcMgr.IOVRegistrationSvc.RecreateFolders = False #Allow add in a second tag svcMgr.DetectorStore.Dump=True +from AthenaCommon import CfgMgr svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = WARNING) diff --git a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelReadTest.py b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelReadTest.py index 3b1488ed405ec59f49d6caecab3c98780c4622d0..23c47a9fe93b3bd0813cb0717ce73ed6c5e46a2c 100644 --- a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelReadTest.py +++ b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelReadTest.py @@ -1,9 +1,13 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + FEBFolder = "/LAR/BadChannels/MissingFEBs" FEBFile = "../share/badfebs.txt" #No input file -> use MC event selector import AthenaCommon.AtlasUnixGeneratorJob +from AthenaCommon import CfgMgr + from AthenaCommon.GlobalFlags import GlobalFlags GlobalFlags.DetGeo.set_commis() GlobalFlags.Luminosity.set_zero() @@ -50,8 +54,7 @@ svcMgr.EventSelector.FirstEvent = 1 from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() -## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc -from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr) theApp.EvtMax=1 @@ -65,7 +68,7 @@ theApp.EvtMax=1 from LArCalibTest.LArCalibTestConf import DumpCaloBadChannels theDumper=DumpCaloBadChannels() theDumper.FileName="list.txt" -topSequence+=theDumper; +topSequence+=theDumper #Thats the registration algo #from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelDBAlg diff --git a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelSummary.py b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelSummary.py index 1aabc8bbac7a9e9265683a84b622b847f27c461d..2f219032f77634958d8bc27c38b62a8e26bf494d 100644 --- a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelSummary.py +++ b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelSummary.py @@ -1,8 +1,10 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration include("LArBadChannelTool/LArBadChannel2Ascii.py") #Some overwrites to generate Executive Summary file with missing FEB information: +from IOVDbSvc.CondDB import conddb conddb.addFolder("LAR_OFL","/LAR/BadChannelsOfl/MissingFEBs") theLArBadChannelTool.CoolMissingFEBsFolder="/LAR/BadChannelsOfl/MissingFEBs" diff --git a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelTiming.py b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelTiming.py index 536c65a8fc75b9279d1ca27f9e368b3a33a245e1..f0bbd71a4defd22653447ca604f6843f4fd21545 100644 --- a/LArCalorimeter/LArBadChannelTool/share/LArBadChannelTiming.py +++ b/LArCalorimeter/LArBadChannelTool/share/LArBadChannelTiming.py @@ -1,6 +1,10 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + #No input file -> use MC event selector import AthenaCommon.AtlasUnixGeneratorJob +from AthenaCommon import CfgMgr + from AthenaCommon.GlobalFlags import GlobalFlags GlobalFlags.DetGeo.set_commis() GlobalFlags.Luminosity.set_zero() @@ -33,8 +37,7 @@ include( "CaloDetMgrDetDescrCnv/CaloDetMgrDetDescrCnv_joboptions.py" ) from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() -## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc -from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr) theApp.EvtMax=10 diff --git a/LArCalorimeter/LArBadChannelTool/share/LArMissingFebDbAlg.py b/LArCalorimeter/LArBadChannelTool/share/LArMissingFebDbAlg.py index 04abf99da7972c9eb85ffbcf3fbfed52d771951c..985416680830466c8895bf81f3c04fcd2e3a6411 100644 --- a/LArCalorimeter/LArBadChannelTool/share/LArMissingFebDbAlg.py +++ b/LArCalorimeter/LArBadChannelTool/share/LArMissingFebDbAlg.py @@ -1,3 +1,5 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + #No input file -> use MC event selector if 'DBInstance' not in dir(): DBInstance="CONDBR2" @@ -27,7 +29,6 @@ if "IOVEndLB" not in dir(): if "sqlite" not in dir(): sqlite="MissingFEBs.db" -from string import * import AthenaCommon.AtlasUnixGeneratorJob from AthenaCommon.GlobalFlags import globalflags @@ -72,8 +73,7 @@ svcMgr.IOVDbSvc.GlobalTag="CONDBR2-ES1PA-2017-04" from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() -## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc -from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr) theApp.EvtMax=1 @@ -81,7 +81,7 @@ from LArBadChannelTool.LArBadChannelToolConf import LArBadFebCondAlg theLArBadChannelCondAlg=LArBadFebCondAlg(ReadKey="", InputFileName=InputFile, OutputLevel=DEBUG) from AthenaCommon.AlgSequence import AthSequencer condSeq = AthSequencer("AthCondSeq") -condSeq+=theLArBadFebCondAlg +condSeq+=theLArBadChannelCondAlg #Thats the registration algo from LArBadChannelTool.LArBadChannelToolConf import LArBadChannelDBAlg @@ -91,7 +91,7 @@ theLArDBAlg.FEBFolder=Folder topSequence += theLArDBAlg OutputList=[ "AthenaAttributeList#"+Folder ] -FEBTag=join(split(Folder, '/'),'') + TagPostfix +FEBTag = ''.join(Folder.split ('/')) + TagPostfix OutputTagList=[FEBTag] WriteIOV=True @@ -115,6 +115,7 @@ svcMgr.IOVRegistrationSvc.RecreateFolders = False svcMgr.DetectorStore.Dump=True +from AthenaCommon import CfgMgr svcMgr+=CfgMgr.AthenaEventLoopMgr(OutputLevel = WARNING) diff --git a/LArCalorimeter/LArBadChannelTool/share/LArMissingFebs2Ascii.py b/LArCalorimeter/LArBadChannelTool/share/LArMissingFebs2Ascii.py index 99754e768f01e82bbb9f4d2a2e3f1e0cb70c9f32..e6d2b3e335e98d345f4b756aefd8494cd37e563b 100644 --- a/LArCalorimeter/LArBadChannelTool/share/LArMissingFebs2Ascii.py +++ b/LArCalorimeter/LArBadChannelTool/share/LArMissingFebs2Ascii.py @@ -1,9 +1,11 @@ +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + if 'DBInstance' not in dir(): DBInstance="CONDBR2" if 'sqlite' in dir(): dbStr="<db>sqlite://;schema="+sqlite+";dbname="+DBInstance+"</db>" - if not 'tag' in dir(): + if 'tag' not in dir(): tag="LARBadChannelsOflMissingFEBs-UPD4-00" else: dbStr="<db>COOLOFL_LAR/"+DBInstance+"</db>" @@ -60,8 +62,7 @@ svcMgr.EventSelector.FirstLB = LBNumber from AthenaCommon.AlgSequence import AlgSequence topSequence = AlgSequence() -## get a handle to the ApplicationManager, to the ServiceManager and to the ToolSvc -from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr,ToolSvc) +from AthenaCommon.AppMgr import (theApp, ServiceMgr as svcMgr) from AthenaCommon.AlgSequence import AthSequencer condSeq = AthSequencer("AthCondSeq")