ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan Class Reference
Collaboration diagram for python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan:

Public Member Functions

def __init__ (self, nspace_LArBadChannelDBTools, class_LArBadChanBitPacking, class_LArBadChannel, class_HWIdentifier, onLineID, larCablingSvc, msg)
 
def BadChan_SetChannelNameDict (self, channelNameDict)
 
def BadChan_SetBadChannelDataFromPayload (self, coolChan, payload)
 
def BadChan_DisplayBadChanEntry (self, coolChan)
 
def BadChan_DisplayBadChanEntryLine (self, sMessage, iChanCmpt, sHWid, sChanName, badChan_word, sValueInit)
 
def BadChan_DisplayBadChanEntryVector_FromAttrList (self, attrList)
 
def BadChan_DisplayBadChanEntryVector (self, vBadChanEntry)
 
def BadChan_TransformEntryIntoDictionnary (self, vBadChanEntry)
 
def BadChan_GetChannelHWIdentifierAndStatus (self, barrel_ec, pos_neg, feedthrough, slot, channel)
 
def BadChan_GetBadChannelPb_String (self, larBadChannel)
 
def BadChan_GetBadChannelPb_Int (self, larBadChannel)
 
def BadChan_GetCoolChannelNameFromHWIdentifier (self, sHWid)
 
def BadChan_GetBadChannelProblemType (self)
 
def BadChan_ModifyLarBadChannel (self, coolChan)
 
def BadChan_GetCablingServiceNameFromHWIdentifier (self, sHWid)
 
def BadChan_ShowBadChannelCorrectionsSummary (self, coolChan)
 
def BadChan_GetNewChannelStatus (self, badChan_wordInit)
 
def BadChan_SaveBadChannelCorrectionsToDatabase (self, dbstring, dbSvc, dbFolderName, selectedTag)
 
def BadChan_CheckSavedDatabaseContent (self, dbName, dbSvc, dbFolderName, selectedTag)
 

Public Attributes

 nspace_LArBadChannelDBTools
 
 class_LArBadChanBitPacking
 
 class_LArBadChannel
 
 class_HWIdentifier
 
 onlineID
 
 larCablingSvc
 
 msg
 
 dict_vectBadChanEntry
 
 dict_vectBadChanEntry_Status
 
 dict_vectBadChanEntry_Init
 
 channelNameDict
 
 class_LArBadChannelState
 
 nbProblemType
 
 channelProblemTypeList
 

Detailed Description

My first python algorithm ( and most probably not my last... ;-)) )

Definition at line 24 of file LArDBFolderBrowser_BadChan.py.

Constructor & Destructor Documentation

◆ __init__()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.__init__ (   self,
  nspace_LArBadChannelDBTools,
  class_LArBadChanBitPacking,
  class_LArBadChannel,
  class_HWIdentifier,
  onLineID,
  larCablingSvc,
  msg 
)

Definition at line 28 of file LArDBFolderBrowser_BadChan.py.

28  def __init__(self,nspace_LArBadChannelDBTools,class_LArBadChanBitPacking,class_LArBadChannel,class_HWIdentifier,
29  onLineID,larCablingSvc,msg):
30 
31  self.nspace_LArBadChannelDBTools=nspace_LArBadChannelDBTools
32  self.class_LArBadChanBitPacking=class_LArBadChanBitPacking
33  self.class_LArBadChannel=class_LArBadChannel
34  self.class_HWIdentifier=class_HWIdentifier
35  self.onlineID = onLineID
36  self.larCablingSvc = larCablingSvc
37  self.msg=msg
38 
39  self.dict_vectBadChanEntry={}
40  self.dict_vectBadChanEntry_Status={}
41  self.dict_vectBadChanEntry_Init={}
42  self.channelNameDict={}
43  self.BadChan_GetBadChannelProblemType()
44 
45  return
46 

Member Function Documentation

◆ BadChan_CheckSavedDatabaseContent()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_CheckSavedDatabaseContent (   self,
  dbName,
  dbSvc,
  dbFolderName,
  selectedTag 
)

Definition at line 649 of file LArDBFolderBrowser_BadChan.py.

649  def BadChan_CheckSavedDatabaseContent(self,dbName,dbSvc,dbFolderName,selectedTag):
650 
651  # Dump new database content to screen
652  try:
653  dbase = dbSvc.openDatabase(dbName,False)
654  except Exception as e:
655  print ('Problem opening database',e)
656  sys.exit(-1)
657  print ("Opened database",dbName)
658 
659  # Get Folder
660  try:
661  f = dbase.getFolder(dbFolderName)
662  print ("Analysing Folder " + str(dbFolderName))
663  except Exception:
664  print ("Skipping " + str(dbFolderName))
665  return
666 
667  # get tags
668  tags = f.listTags()
669 
670  # SES
671  if tags.size()==0:
672  tags.push_back("notag")
673 
674  print ("for tags ",)
675  for tag in tags:
676  print (tag)
677 
678  bTagFound=False
679  bSavingProcessError=False
680 
681  for tag in tags:
682 
683  if tag!=selectedTag:
684  continue
685 
686  bTagFound=True
687 
688  f.countObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all())
689  objs = f.browseObjects( cool.ValidityKeyMin,cool.ValidityKeyMax,cool.ChannelSelection.all())
690  i = 0
691  while objs.hasNext():
692  obj = objs.next()
693  print ("Found object", i, end='')
694  print ("since [r,l]: [", obj.since() >> 32,',',obj.since()%0x100000000,']', end='')
695  print ("until [r,l]: [", obj.until() >> 32,',',obj.until()%0x100000000,']', end='')
696  print ("payload", obj.payload(), end='')
697  print ("chan",obj.channelId() )
698 
699  # Get components of payload object
700  payload=obj.payload()
701  channelSize=payload['ChannelSize']
702  statusWordSize=payload['StatusWordSize']
703  endianness=payload['Endianness']
704  version=payload['Version']
705  blob=payload['Blob']
706 
707  # Decode blob content
708  vect_BadChanEntry=self.nspace_LArBadChannelDBTools.decodeBlob(blob,channelSize,statusWordSize,endianness,version,
709  self.nspace_LArBadChannelDBTools.getDefaultMsgStream())
710 
711  # Transform vect_BadChanNetry into python dictionnary
712  sChannelDict,sChannelDict_Status=self.BadChan_TransformEntryIntoDictionnary(vect_BadChanEntry)
713 
714  sChannelKey=obj.channelId()
715  HWidChecked={}
716  for key in sChannelDict.keys():
717  HWidChecked[key]=0
718 
719  print (" -> SQlite database content vs initial data : channel ", sChannelKey)
720 
721  # Check all the saved data vs initial data
722  listHWidKeys=[x for x in sChannelDict.keys()]
723  for x in self.dict_vectBadChanEntry_Status[sChannelKey].keys():
724  if x not in listHWidKeys:
725  listHWidKeys.append(x)
726  listHWidKeys.sort()
727  iChanCmpt=0
728  for keyHWid in listHWidKeys:
729 
730  try:
731  sChanName,badChan_word,sValueInit=sChannelDict[keyHWid]
732  except Exception:
733  sChanName="UNDEFINED"
734  badChan_word=0
735 
736  sSuffix="OK"
737  if self.dict_vectBadChanEntry_Status[sChannelKey][keyHWid]==STATUS_INIT:
738  if sChannelDict[keyHWid][1]!=self.dict_vectBadChanEntry_Init[sChannelKey][keyHWid][1]:
739  sPrefix="ERR"
740  sSuffix=" no modification was done"+keyHWid
741  bSavingProcessError=True
742  else:
743  sPrefix=" "
744  self.BadChan_DisplayBadChanEntryLine(sPrefix,iChanCmpt,keyHWid,sChanName,badChan_word,sSuffix)
745 
746  if self.dict_vectBadChanEntry_Status[sChannelKey][keyHWid]==STATUS_REMOVED:
747  if keyHWid in sChannelDict:
748  sPrefix="ERR"
749  sSuffix=" deletion not taken into accout"+keyHWid
750  bSavingProcessError=True
751  else:
752  sPrefix=STATUS_REMOVED
753  sChanName,badChan_word,sValue_Init=self.dict_vectBadChanEntry[sChannelKey][keyHWid]
754  self.BadChan_DisplayBadChanEntryLine(sPrefix,iChanCmpt,keyHWid,sChanName,badChan_word,sSuffix)
755 
756  if self.dict_vectBadChanEntry_Status[sChannelKey][keyHWid]==STATUS_NEW:
757  if sChannelDict[keyHWid][1]!=self.dict_vectBadChanEntry[sChannelKey][keyHWid][1]:
758  sPrefix="ERR"
759  sSuffix=" error while saving new status "+keyHWid
760  bSavingProcessError=True
761  else:
762  sPrefix=STATUS_NEW
763  self.BadChan_DisplayBadChanEntryLine(sPrefix,iChanCmpt,keyHWid,sChanName,badChan_word,sSuffix)
764 
765  if self.dict_vectBadChanEntry_Status[sChannelKey][keyHWid]==STATUS_MODIFIED:
766  if sChannelDict[keyHWid][1]!=self.dict_vectBadChanEntry[sChannelKey][keyHWid][1]:
767  sPrefix="ERR"
768  sSuffix=" error while saving modified status "+keyHWid
769  bSavingProcessError=True
770  else:
771  sPrefix=STATUS_MODIFIED
772  self.BadChan_DisplayBadChanEntryLine(sPrefix,iChanCmpt,keyHWid,sChanName,badChan_word,sSuffix)
773 
774  HWidChecked[keyHWid]=1
775  iChanCmpt += 1
776 
777  for key in self.dict_vectBadChanEntry_Status[sChannelKey].keys():
778  if key not in HWidChecked and self.dict_vectBadChanEntry_Status[sChannelKey][key]!=STATUS_REMOVED:
779  print ("ERROR : initial ",key," has not been saved")
780  elif key in HWidChecked and HWidChecked[key]==0:
781  print ("ERROR : ",key," has not been checked")
782 
783  i += 1
784 
785 
786  objs.close()
787 
788  if bTagFound is False:
789  print ("ERROR : tag "+selectedTag+" not found in saved SQlite file")
790 
791  if bSavingProcessError is True:
792  print ("ERROR : found while making comparison between corrected and saved datas" )
793 
794 
795  dbase.closeDatabase()
796 
797 
798 
799 

◆ BadChan_DisplayBadChanEntry()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_DisplayBadChanEntry (   self,
  coolChan 
)
 

Definition at line 90 of file LArDBFolderBrowser_BadChan.py.

90  def BadChan_DisplayBadChanEntry(self,coolChan):
91  """ """
92 
93  iChanCmpt=0
94  listHWidKeys=[x for x in self.dict_vectBadChanEntry[coolChan].keys()]
95  listHWidKeys.sort()
96 
97  print ("")
98  for sHWid in listHWidKeys:
99 
100  if sHWid in self.dict_vectBadChanEntry_Init[coolChan]:
101  sChanName,badChan_word,sValueInit=self.dict_vectBadChanEntry_Init[coolChan][sHWid]
102  sPrefix=""
103  if self.dict_vectBadChanEntry_Status[coolChan][sHWid]!=STATUS_INIT:
104  sPrefix="->"
105  self.BadChan_DisplayBadChanEntryLine(sPrefix,iChanCmpt,sHWid,sChanName,badChan_word,sValueInit)
106 
107  if self.dict_vectBadChanEntry_Status[coolChan][sHWid]!=STATUS_INIT:
108  sChanName,badChan_word,sValueInit=self.dict_vectBadChanEntry[coolChan][sHWid]
109  channelStatus=self.dict_vectBadChanEntry_Status[coolChan][sHWid]
110  self.BadChan_DisplayBadChanEntryLine(channelStatus,iChanCmpt,sHWid,sChanName,badChan_word,sValueInit)
111 
112  iChanCmpt += 1
113 
114 

◆ BadChan_DisplayBadChanEntryLine()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_DisplayBadChanEntryLine (   self,
  sMessage,
  iChanCmpt,
  sHWid,
  sChanName,
  badChan_word,
  sValueInit 
)

Definition at line 115 of file LArDBFolderBrowser_BadChan.py.

115  def BadChan_DisplayBadChanEntryLine(self,sMessage,iChanCmpt,sHWid,sChanName,badChan_word,sValueInit):
116 
117  obj_HWid=self.class_HWIdentifier()
118  obj_HWid.set(sHWid)
119 
120  barrel_ec=self.onlineID.barrel_ec(obj_HWid)
121  pos_neg=self.onlineID.pos_neg(obj_HWid)
122  feedthrough=self.onlineID.feedthrough(obj_HWid)
123  slot=self.onlineID.slot(obj_HWid)
124  channel=self.onlineID.channel(obj_HWid)
125 
126  larBadChannel=self.class_LArBadChannel(badChan_word)
127  sStatusString=self.BadChan_GetBadChannelPb_String(larBadChannel)
128 
129  if sMessage=="":
130  print (" %5d : %-10s %1d %1d %2d %2d %3d %40s %s " % (iChanCmpt+1,obj_HWid.getString(),
131  barrel_ec,pos_neg,feedthrough,slot,channel,
132  sChanName,sStatusString))
133  else:
134  print ("%3s %5d : %-10s %1d %1d %2d %2d %3d %40s %s %s" % (sMessage,iChanCmpt+1,obj_HWid.getString(),
135  barrel_ec,pos_neg,feedthrough,slot,channel,
136  sChanName,sStatusString,sValueInit))
137 
138 
139  # print ("%5d : %-10s %1d %1d %2d %2d %3d %40s %s // %s" % (iChanCmpt,obj_HWid.getString(),
140  # barrel_ec,pos_neg,feedthrough,slot,channel,
141  # sChanName,sStatusString,sValueInit))
142 
143 
144 

◆ BadChan_DisplayBadChanEntryVector()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_DisplayBadChanEntryVector (   self,
  vBadChanEntry 
)
 

Definition at line 158 of file LArDBFolderBrowser_BadChan.py.

158  def BadChan_DisplayBadChanEntryVector(self,vBadChanEntry):
159  """ """
160 
161  sChannelDict,sChannelDict_Status=self.BadChan_TransformEntryIntoDictionnary(vBadChanEntry)
162  listHWidKeys=[x for x in sChannelDict.keys()]
163  listHWidKeys.sort()
164 
165  iCmpt=0
166  for sHWid in listHWidKeys:
167 
168  (sChannelName,larBadChannelStatus,sStatusValue)=sChannelDict[sHWid]
169  self.BadChan_DisplayBadChanEntryLine("",iCmpt,sHWid,sChannelName,larBadChannelStatus,sStatusValue)
170  iCmpt +=1
171 
172 

◆ BadChan_DisplayBadChanEntryVector_FromAttrList()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_DisplayBadChanEntryVector_FromAttrList (   self,
  attrList 
)

Definition at line 145 of file LArDBFolderBrowser_BadChan.py.

145  def BadChan_DisplayBadChanEntryVector_FromAttrList(self,attrList):
146 
147  blob = attrList['Blob']
148  channelSize = attrList['ChannelSize']
149  statusWordSize = attrList['StatusWordSize']
150  endianness = attrList['Endianness']
151  version = attrList['Version']
152  vect_BadChanEntry=self.nspace_LArBadChannelDBTools.decodeBlob(blob,channelSize,statusWordSize,endianness,version,
153  self.nspace_LArBadChannelDBTools.getDefaultMsgStream())
154  print ("BadChanEntry vector size : ",vect_BadChanEntry.size())
155  self.BadChan_DisplayBadChanEntryVector(vect_BadChanEntry)
156 
157 

◆ BadChan_GetBadChannelPb_Int()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_GetBadChannelPb_Int (   self,
  larBadChannel 
)
Get bad channel ProblemType indexes 

Definition at line 243 of file LArDBFolderBrowser_BadChan.py.

243  def BadChan_GetBadChannelPb_Int(self,larBadChannel):
244  """ Get bad channel ProblemType indexes """
245 
246  iBadChannelPb=[]
247  for i in range(0,self.nbProblemType):
248  if larBadChannel.statusBad(i):
249  iBadChannelPb.append(i)
250 
251  return iBadChannelPb
252 
253 

◆ BadChan_GetBadChannelPb_String()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_GetBadChannelPb_String (   self,
  larBadChannel 
)
Get bad channel ProblemType names 

Definition at line 232 of file LArDBFolderBrowser_BadChan.py.

232  def BadChan_GetBadChannelPb_String(self,larBadChannel):
233  """ Get bad channel ProblemType names """
234 
235  sBadChannelPb=""
236  for i in range(0,self.nbProblemType):
237  if larBadChannel.statusBad(i):
238  sBadChannelPb=sBadChannelPb+self.channelProblemTypeList[i]+","
239 
240  return sBadChannelPb
241 
242 

◆ BadChan_GetBadChannelProblemType()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_GetBadChannelProblemType (   self)
Get list of problem type defines in LArBadChanBitPacking file 

Definition at line 286 of file LArDBFolderBrowser_BadChan.py.

286  def BadChan_GetBadChannelProblemType(self):
287  """ Get list of problem type defines in LArBadChanBitPacking file """
288 
289  obj_larBadChanBitPacking=self.class_LArBadChanBitPacking()
290 
291  self.nbProblemType=int(obj_larBadChanBitPacking.numberOfProblemTypes())
292 
293  self.channelProblemTypeList=[]
294  for i in range(0,self.nbProblemType):
295  self.channelProblemTypeList.append(obj_larBadChanBitPacking.stringName(i))
296 
297  print ("ENUM ProblemType : ")
298  print (self.channelProblemTypeList)
299 
300 
301 
302 

◆ BadChan_GetCablingServiceNameFromHWIdentifier()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_GetCablingServiceNameFromHWIdentifier (   self,
  sHWid 
)
Get Cabling Service param from HW identifier 

Definition at line 445 of file LArDBFolderBrowser_BadChan.py.

445  def BadChan_GetCablingServiceNameFromHWIdentifier(self, sHWid):
446  """ Get Cabling Service param from HW identifier """
447 
448  obj_HWid=self.class_HWIdentifier()
449  obj_HWid.set(sHWid)
450 
451  cblSvc_id = self.larCablingSvc.cnvToIdentifier(obj_HWid)
452  cblSvc_string = self.onlineID.print_to_string(cblSvc_id)
453 
454  return cblSvc_string
455 
456 

◆ BadChan_GetChannelHWIdentifierAndStatus()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_GetChannelHWIdentifierAndStatus (   self,
  barrel_ec,
  pos_neg,
  feedthrough,
  slot,
  channel 
)
Get channel HW identifier and its status 

Definition at line 196 of file LArDBFolderBrowser_BadChan.py.

196  def BadChan_GetChannelHWIdentifierAndStatus(self,barrel_ec,pos_neg,feedthrough,slot,channel):
197  """ Get channel HW identifier and its status """
198 
199  sid = self.onlineID.channel_Id(int(barrel_ec),int(pos_neg),int(feedthrough),int(slot),int(channel))
200  print (str(barrel_ec)+" "+str(pos_neg)+" "+str(feedthrough)+" "+str(slot)+" "+str(channel)+" => ",sid.getString())
201 
202  # Check if HW identifier is valid
203  bValidWHidentifier=False
204  if self.onlineID.isEMBchannel(sid):
205  bValidWHidentifier=True
206  if self.onlineID.isEMECchannel(sid):
207  bValidWHidentifier=True
208  if self.onlineID.isHECchannel(sid):
209  bValidWHidentifier=True
210  if self.onlineID.isFCALchannel(sid):
211  bValidWHidentifier=True
212  if bValidWHidentifier is False:
213  return (-1,sid.getString(),"",0)
214 
215  # Check if HW identifier already corresponds to a bad channel
216  for key in self.dict_vectBadChanEntry.keys():
217  for sHWid in self.dict_vectBadChanEntry[key].keys():
218 
219  sChannelName,badChan_word,x=self.dict_vectBadChanEntry[key][sHWid]
220  if sid.getString()==sHWid:
221  #larBadChannel=self.class_LArBadChannel(badChan_word)
222  #larBadChannelStatus=self.BadChan_GetBadChannelPb_String(larBadChannel)
223 
224  return (0,sid.getString(),sChannelName,badChan_word)
225 
226  # default : new lar bad channel status
227  sChannelName=self.onlineID.channel_name(sid)
228  badChan_word=0
229  return (1,sid.getString(),sChannelName,badChan_word)
230 
231 

◆ BadChan_GetCoolChannelNameFromHWIdentifier()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_GetCoolChannelNameFromHWIdentifier (   self,
  sHWid 
)
Get channel name from HW identifier (only for text menu purpose)

Definition at line 254 of file LArDBFolderBrowser_BadChan.py.

254  def BadChan_GetCoolChannelNameFromHWIdentifier(self,sHWid):
255  """ Get channel name from HW identifier (only for text menu purpose)"""
256 
257  self.class_LArBadChannelState=cppyy.makeClass('LArBadChannelState')
258  inst_larBadChannelState=self.class_LArBadChannelState()
259 
260  sChannelName=""
261  if self.onlineID.isEMBchannel(sHWid):
262  if self.onlineID.pos_neg(sHWid)==1:
263  iEnumChannel=inst_larBadChannelState.EMBA
264  else:
265  iEnumChannel=inst_larBadChannelState.EMBC
266  if self.onlineID.isEMECchannel(sHWid):
267  if self.onlineID.pos_neg(sHWid)==1:
268  iEnumChannel=inst_larBadChannelState.EMECA
269  else:
270  iEnumChannel=inst_larBadChannelState.EMECC
271  if self.onlineID.isHECchannel(sHWid):
272  if self.onlineID.pos_neg(sHWid)==1:
273  iEnumChannel=inst_larBadChannelState.HECA
274  else:
275  iEnumChannel=inst_larBadChannelState.HECC
276  if self.onlineID.isFCALchannel(sHWid):
277  if self.onlineID.pos_neg(sHWid)==1:
278  iEnumChannel=inst_larBadChannelState.FCALA
279  else:
280  iEnumChannel=inst_larBadChannelState.FCALC
281 
282  sChannelName=inst_larBadChannelState.coolChannelName(iEnumChannel)+" ("+str(iEnumChannel)+")"
283  return sChannelName
284 
285 

◆ BadChan_GetNewChannelStatus()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_GetNewChannelStatus (   self,
  badChan_wordInit 
)

Definition at line 477 of file LArDBFolderBrowser_BadChan.py.

477  def BadChan_GetNewChannelStatus(self,badChan_wordInit):
478 
479  badChan_word=badChan_wordInit
480 
481  inst_larBadChanBitPacking=self.class_LArBadChanBitPacking()
482 
483  sTmp="\n"
484  for index,s in enumerate(self.channelProblemTypeList):
485  sTmp=sTmp+"%2d %-20s" % (index,s)
486  if (index+1)%5==0:
487  sTmp=sTmp+"\n"
488  print (sTmp)
489  print (".. to add/remove a pb : enter index/-index or sequence of indexes")
490  print (".. other : a : abort / c : cancel correction / r : reset to valid / n : next channel")
491  print ("")
492 
493  bEndOfStatusCorrection=False
494  larBadChannel=self.class_LArBadChannel(badChan_word)
495  while not bEndOfStatusCorrection:
496 
497  iProblemList=self.BadChan_GetBadChannelPb_Int(larBadChannel)
498  print ("Status ",self.BadChan_GetBadChannelPb_String(larBadChannel)," ",iProblemList)
499  print ("")
500  print (".. > ", end='')
501  tty = open("/dev/tty", "r+")
502  rep=tty.readline()
503  rep=rep.strip()
504 
505  if rep=="a":
506  iAbortConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to quit ? ")
507  if iAbortConfirmation==1:
508  return (-1,badChan_wordInit)
509  bEndOfStatusCorrection=False
510  elif rep=="n":
511  badChan_word=larBadChannel.packedData()
512  return (0,badChan_word)
513  bEndOfStatusCorrection=True
514  elif rep=="c":
515  iCancelConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to cancel correction ? ")
516  if iCancelConfirmation==1:
517  return (1,STATUS_INIT)
518  bEndOfStatusCorrection=True
519  else:
520  import re
521  reSplitScheme=re.compile('[ ,;]+')
522  sTmp=reSplitScheme.split(rep)
523  sRepSeq=[x for x in sTmp if x !='']
524 
525  # reset
526  if "r" in sRepSeq:
527  iProblemList=[]
528 
529  # Indexes
530  for index in sRepSeq:
531  try:
532  iNewPb=int(index)
533  if iNewPb in range(1,self.nbProblemType) and iNewPb not in iProblemList:
534  iProblemList.append(iNewPb)
535  if iNewPb in range(-self.nbProblemType+1,0) and -iNewPb in iProblemList:
536  iProblemList.remove(-iNewPb)
537  except Exception:
538  continue
539 
540  larBadChannel=self.class_LArBadChannel()
541  for iPb in iProblemList:
542  inst_larBadChanBitPacking.setBit(iPb,larBadChannel)
543  badChan_word=larBadChannel.packedData()
544 
545 
546  return (-1,badChan_word)
547 
548 
549 

◆ BadChan_ModifyLarBadChannel()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_ModifyLarBadChannel (   self,
  coolChan 
)

Definition at line 303 of file LArDBFolderBrowser_BadChan.py.

303  def BadChan_ModifyLarBadChannel(self,coolChan):
304 
305 
306  listHWidKeys=[x for x in self.dict_vectBadChanEntry[coolChan].keys()]
307  listHWidKeys.sort()
308  iNbBadChannel=len(self.dict_vectBadChanEntry[coolChan].keys())
309 
310  bEndOfCorrection=False
311  while not bEndOfCorrection:
312 
313  print ("")
314  print (".. To select a channel : enter channel index or barrel_ec pos_neg feedthrough slot channel ")
315  print (".. To add a channel : enter barrel_ec pos_neg feedthrough slot channel ")
316  print (".. To remove a channel : enter -(channel index) ")
317  print (".. Other : s (summary) / r (refresh list) / a (abort) / q (save and quit) .. > ", end='')
318  tty = open("/dev/tty", "r+")
319  rep=tty.readline()
320  rep=rep.strip()
321 
322  bReadableAnswer=True
323  barrel_ec=-1
324  pos_neg=-1
325  feedthrough=-1
326  slot=-1
327  channel=-1
328  iSelectedIndex=0
329  sTxtAnswer=""
330  iCombinationAnswer=0
331  try:
332  barrel_ec,pos_neg,feedthrough,slot,channel=rep.split(' ')
333  bReadableAnswer=True
334  iCombinationAnswer=1
335  except Exception:
336  if rep=="a":
337  sTxtAnswer="abort"
338  elif rep=="r":
339  sTxtAnswer="refresh"
340  elif rep=="s":
341  sTxtAnswer="summary"
342  elif rep=="q":
343  sTxtAnswer="save-quit"
344  else:
345  try:
346  iSelection=int(rep)
347  if iSelection in range(1,iNbBadChannel+1):
348  iSelectedIndex=iSelection
349  if iSelection in range(-iNbBadChannel-1,0):
350  iSelectedIndex=iSelection
351  if iSelectedIndex==-99999:
352  bReadableAnswer=False
353  except Exception:
354  iSelectedIndex=0
355  bReadableAnswer=False
356  continue
357 
358  if bReadableAnswer is False:
359  print ("could not decode answer... ")
360  bEndOfCorrection=False
361  continue
362 
363  # Abort answer
364  if sTxtAnswer=="abort":
365  iAbortConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to quit ? ")
366  if iAbortConfirmation==1:
367  return
368  bEndOfCorrection=False
369 
370  # Refresh answer
371  if sTxtAnswer=="refresh":
372  self.BadChan_DisplayBadChanEntry(coolChan)
373  bEndOfCorrection=False
374 
375  # Summary answer
376  if sTxtAnswer=="summary":
377  self.BadChan_ShowBadChannelCorrectionsSummary(coolChan)
378  bEndOfCorrection=False
379 
380  # Refresh answer
381  if sTxtAnswer=="save-quit":
382  bEndOfCorrection=True
383 
384  # Channel selected by negative index => to remove
385  if iSelectedIndex<0:
386  sHWid=listHWidKeys[-iSelectedIndex-1]
387  sChanName,badChan_word,sValueInit=self.dict_vectBadChanEntry[coolChan][sHWid]
388  iDeleteConfirmation=LArBadChannelBrowserTools.YesNoQuestion("Are you sure you want to delete "+sChanName+" ? ")
389  if iDeleteConfirmation==1:
390  self.dict_vectBadChanEntry_Status[coolChan][sHWid]=STATUS_REMOVED
391  self.BadChan_ShowBadChannelCorrectionsSummary(coolChan)
392  bEndOfCorrection=False
393 
394  # Channel selected by index or parameters
395  if iSelectedIndex>0 or iCombinationAnswer==1:
396 
397  bChangeHWstatus=True
398  bNewHWidentifier=False
399  if iSelectedIndex>0:
400  sHWid=listHWidKeys[iSelectedIndex-1]
401  sChanName,badChan_word,sValueInit=self.dict_vectBadChanEntry[coolChan][sHWid]
402  else:
403  iRes,sHWid,sChanName,badChan_word=self.BadChan_GetChannelHWIdentifierAndStatus(barrel_ec,pos_neg,feedthrough,slot,channel)
404  if iRes==-1:
405  print ("An error occured while computing HW identifier -> computed HW identifier does not exist")
406  bChangeHWstatus=False
407  if iRes==1:
408  bNewHWidentifier=True
409 
410  if bChangeHWstatus:
411  print ("")
412  for i in range(0,50):
413  print ("-",)
414  print ("")
415  for i in range(0,50):
416  print ("-",)
417  print ("")
418  self.BadChan_DisplayBadChanEntryLine("",0,sHWid,sChanName,badChan_word,"")
419  print (" ",self.BadChan_GetCablingServiceNameFromHWIdentifier(sHWid))
420 
421  iRes,sNewStatus=self.BadChan_GetNewChannelStatus(badChan_word)
422 
423  print ("MODIFICATION STATUS : ",badChan_word," ",sNewStatus)
424 
425  if iRes==0 and sNewStatus!=badChan_word:
426  if bNewHWidentifier is False:
427  self.dict_vectBadChanEntry_Status[coolChan][sHWid]=STATUS_MODIFIED
428  self.dict_vectBadChanEntry[coolChan][sHWid]=(sChanName,sNewStatus,sValueInit)
429  else:
430  self.dict_vectBadChanEntry_Status[coolChan][sHWid]=STATUS_NEW
431  sValueInit="None"
432  self.dict_vectBadChanEntry[coolChan][sHWid]=(sChanName,sNewStatus,sValueInit)
433  self.BadChan_DisplayBadChanEntry(coolChan)
434  elif iRes==1:
435  self.dict_vectBadChanEntry_Status[coolChan][sHWid]=STATUS_INIT
436 
437 
438  self.BadChan_ShowBadChannelCorrectionsSummary(coolChan)
439  bEndOfCorrection=False
440 
441 
442  return StatusCode.Success
443 
444 

◆ BadChan_SaveBadChannelCorrectionsToDatabase()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_SaveBadChannelCorrectionsToDatabase (   self,
  dbstring,
  dbSvc,
  dbFolderName,
  selectedTag 
)

Definition at line 550 of file LArDBFolderBrowser_BadChan.py.

550  def BadChan_SaveBadChannelCorrectionsToDatabase(self,dbstring,dbSvc,dbFolderName,selectedTag):
551 
552  listKeys=self.dict_vectBadChanEntry.keys()
553  listKeys.sort()
554 
555  # Create LArBadChannel object for defined BadChanEntry vector and coolChan
556  self.class_LArBadChannelState=cppyy.makeClass('LArBadChannelState')
557  inst_larBadChannelState=self.class_LArBadChannelState()
558 
559  # Loop over cool channels
560  bNewDBCreated=False
561  for coolChan in listKeys:
562 
563  vect_BadChanEntry=cppyy.gbl.std.vector('std::pair<HWIdentifier,LArBadChannel>')()
564 
565  listHWidKeys=[x for x in self.dict_vectBadChanEntry[coolChan].keys()]
566  listHWidKeys.sort()
567  iNbCorrection=0
568  for key in listHWidKeys:
569 
570  sHWid=key
571  if self.dict_vectBadChanEntry_Status[coolChan][sHWid]==STATUS_INIT:
572  badChan_word=self.dict_vectBadChanEntry_Init[coolChan][sHWid][1]
573  elif self.dict_vectBadChanEntry_Status[coolChan][sHWid]==STATUS_MODIFIED or self.dict_vectBadChanEntry_Status[coolChan][sHWid]==STATUS_NEW:
574  iNbCorrection += 1
575  badChan_word=self.dict_vectBadChanEntry[coolChan][sHWid][1]
576  elif self.dict_vectBadChanEntry_Status[coolChan][sHWid]==STATUS_REMOVED:
577  iNbCorrection += 1
578  continue
579 
580  obj_HWid=self.class_HWIdentifier()
581  obj_HWid.set(sHWid)
582  larBadChannel=self.class_LArBadChannel(badChan_word)
583 
584  pair_BadChanEntry=cppyy.gbl.pair('HWIdentifier,LArBadChannel')(obj_HWid, larBadChannel)
585  vect_BadChanEntry.push_back(pair_BadChanEntry)
586 
587  # if correction were made => store BadChanEntry vector
588  if iNbCorrection>0:
589  for sEntry in vect_BadChanEntry:
590  inst_larBadChannelState.add(sEntry,coolChan)
591  else:
592  continue
593 
594  # Create object based on new LArBadChannelState (via LArBadChannelDBTools python interface)
595  attrListSpec=cppyy.gbl.coral.AttributeListSpecification()
596  athenaAttrList=cppyy.gbl.AthenaAttributeList()
597 
598  attrListSpec=self.nspace_LArBadChannelDBTools.createCoolSpec()
599  athenaAttrList=self.nspace_LArBadChannelDBTools.createPayload(inst_larBadChannelState.coolChannel(coolChan), attrListSpec)
600 
601  # if save DB has not been created => do it
602  if bNewDBCreated is False:
603  try:
604  dbSave = dbSvc.createDatabase(dbstring)
605  except Exception as e:
606  print ('Problem opening database',e)
607  sys.exit(-1)
608  print ("Opened database",dbstring)
609 
610  desc='<timeStamp>run-event</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
611 
612  # Create cool spec from AttributeListSpec
613  coolSpec=cool.RecordSpecification()
614  for iElemt in range(0,attrListSpec.size()):
615  attrSpec=attrListSpec[iElemt]
616  typeName=attrSpec.typeName()
617  if typeName=="unsigned int":
618  coolSpec.extend(attrSpec.name(),cool.StorageType.UInt32)
619  elif typeName=="blob":
620  coolSpec.extend(attrSpec.name(),cool.StorageType.Blob64k)
621  else:
622  print ("Undefined cool.StorageType "+typeName)
623 
624 # myfolder=dbSave.createFolder(dbFolderName, coolSpec, desc, cool.FolderVersioning.SINGLE_VERSION,True)
625  myfolder=dbSave.createFolder(dbFolderName, coolSpec, desc, cool.FolderVersioning.MULTI_VERSION,True)
626 
627  import string
628  IOVBeginEnd=["90","9999999"]
629  beginRun = string.atoi(IOVBeginEnd[0]) << 32
630  endRun = string.atoi(IOVBeginEnd[1]) << 32
631 
632  bNewDBCreated=True
633 
634  # Create cool payload from AthenaAttributeList payload
635  coolPayload=cool.Record(coolSpec)
636  for iElemt in range(0,attrListSpec.size()):
637  attrSpec=attrListSpec[iElemt]
638  coolPayload[attrSpec.name()]=athenaAttrList[attrSpec.name()]
639 
640  # Store cool object to folder
641  myfolder.storeObject(beginRun,endRun,coolPayload,coolChan,selectedTag)
642 
643  # Close new databse
644  if bNewDBCreated is True:
645  dbSave.closeDatabase()
646 
647 
648 

◆ BadChan_SetBadChannelDataFromPayload()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_SetBadChannelDataFromPayload (   self,
  coolChan,
  payload 
)

Definition at line 55 of file LArDBFolderBrowser_BadChan.py.

55  def BadChan_SetBadChannelDataFromPayload(self,coolChan,payload):
56 
57 
58  # Get components of payload object
59  channelSize=payload['ChannelSize']
60  statusWordSize=payload['StatusWordSize']
61  endianness=payload['Endianness']
62  version=payload['Version']
63  blob=payload['Blob']
64 
65 
66  # Decode blob content
67  vect_BadChanEntry=self.nspace_LArBadChannelDBTools.decodeBlob(blob,channelSize,statusWordSize,endianness,version,
68  self.nspace_LArBadChannelDBTools.getDefaultMsgStream())
69 
70  # Add entry in dictionnary
71  sChannelKey=coolChan
72  if sChannelKey not in self.dict_vectBadChanEntry:
73  self.dict_vectBadChanEntry[sChannelKey]={}
74 
75  # Get channel name from first vect_BadChanEntry element
76  obj_HWid=vect_BadChanEntry.at(0).first
77 
78  # Transform vect_BadChanNetry into python dictionnary
79  sChannelDict,sChannelDict_Status=self.BadChan_TransformEntryIntoDictionnary(vect_BadChanEntry)
80  self.dict_vectBadChanEntry[sChannelKey]={}
81  self.dict_vectBadChanEntry_Init[sChannelKey]={}
82  for key in sChannelDict.keys():
83  self.dict_vectBadChanEntry[sChannelKey][key]=sChannelDict[key]
84  self.dict_vectBadChanEntry_Init[sChannelKey][key]=sChannelDict[key]
85  self.dict_vectBadChanEntry_Status[sChannelKey]=sChannelDict_Status
86 
87  return (self.BadChan_GetCoolChannelNameFromHWIdentifier(obj_HWid))
88 
89 

◆ BadChan_SetChannelNameDict()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_SetChannelNameDict (   self,
  channelNameDict 
)

Definition at line 47 of file LArDBFolderBrowser_BadChan.py.

47  def BadChan_SetChannelNameDict(self,channelNameDict):
48 
49  for key in channelNameDict.keys():
50  self.channelNameDict[key]=channelNameDict[key]
51 
52  return
53 
54 

◆ BadChan_ShowBadChannelCorrectionsSummary()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_ShowBadChannelCorrectionsSummary (   self,
  coolChan 
)

Definition at line 457 of file LArDBFolderBrowser_BadChan.py.

457  def BadChan_ShowBadChannelCorrectionsSummary(self,coolChan):
458 
459  listHWidKeys=[x for x in self.dict_vectBadChanEntry[coolChan].keys()]
460  listHWidKeys.sort()
461 # print (listHWidKeys)
462  print ("")
463 
464  print ("Correction summary : "+self.channelNameDict[coolChan])
465  iNbCorrection=0
466  for index,sHWid in enumerate(listHWidKeys):
467  if self.dict_vectBadChanEntry_Status[coolChan][sHWid]!=STATUS_INIT:
468  sChanName,badChan_word,sValueInit=self.dict_vectBadChanEntry[coolChan][sHWid]
469  channelStatus=self.dict_vectBadChanEntry_Status[coolChan][sHWid]
470  self.BadChan_DisplayBadChanEntryLine(channelStatus,index,sHWid,sChanName,badChan_word,"")
471  iNbCorrection += 1
472 
473  if iNbCorrection==0:
474  print ("-")
475 
476 

◆ BadChan_TransformEntryIntoDictionnary()

def python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.BadChan_TransformEntryIntoDictionnary (   self,
  vBadChanEntry 
)
Transform the BadChanEntry decoded from blob object into a python dictionnary 

Definition at line 173 of file LArDBFolderBrowser_BadChan.py.

173  def BadChan_TransformEntryIntoDictionnary(self,vBadChanEntry):
174  """ Transform the BadChanEntry decoded from blob object into a python dictionnary """
175 
176  print ("--------------------------- Blob SIZE : ",vBadChanEntry.size())
177  iNbBadChannel=vBadChanEntry.size()
178 
179  sChannelDict={}
180  sChannelDict_Status={}
181  for i in range(0,iNbBadChannel):
182  larBadChannel=vBadChanEntry.at(i).second
183  obj_HWid=vBadChanEntry.at(i).first
184  sHexaString=obj_HWid.getString()
185 
186  sChannelName=self.onlineID.channel_name(vBadChanEntry.at(i).first)
187  sInitialValues=sHexaString+" "+self.BadChan_GetBadChannelPb_String(larBadChannel)
188  sChannelDict[sHexaString]=(sChannelName,larBadChannel.packedData(),sInitialValues)
189  sChannelDict_Status[sHexaString]=STATUS_INIT
190 
191  return (sChannelDict,sChannelDict_Status)
192 
193 
194 
195 

Member Data Documentation

◆ channelNameDict

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.channelNameDict

Definition at line 41 of file LArDBFolderBrowser_BadChan.py.

◆ channelProblemTypeList

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.channelProblemTypeList

Definition at line 293 of file LArDBFolderBrowser_BadChan.py.

◆ class_HWIdentifier

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.class_HWIdentifier

Definition at line 33 of file LArDBFolderBrowser_BadChan.py.

◆ class_LArBadChanBitPacking

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.class_LArBadChanBitPacking

Definition at line 31 of file LArDBFolderBrowser_BadChan.py.

◆ class_LArBadChannel

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.class_LArBadChannel

Definition at line 32 of file LArDBFolderBrowser_BadChan.py.

◆ class_LArBadChannelState

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.class_LArBadChannelState

Definition at line 257 of file LArDBFolderBrowser_BadChan.py.

◆ dict_vectBadChanEntry

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.dict_vectBadChanEntry

Definition at line 38 of file LArDBFolderBrowser_BadChan.py.

◆ dict_vectBadChanEntry_Init

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.dict_vectBadChanEntry_Init

Definition at line 40 of file LArDBFolderBrowser_BadChan.py.

◆ dict_vectBadChanEntry_Status

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.dict_vectBadChanEntry_Status

Definition at line 39 of file LArDBFolderBrowser_BadChan.py.

◆ larCablingSvc

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.larCablingSvc

Definition at line 35 of file LArDBFolderBrowser_BadChan.py.

◆ msg

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.msg

Definition at line 36 of file LArDBFolderBrowser_BadChan.py.

◆ nbProblemType

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.nbProblemType

Definition at line 291 of file LArDBFolderBrowser_BadChan.py.

◆ nspace_LArBadChannelDBTools

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.nspace_LArBadChannelDBTools

Definition at line 30 of file LArDBFolderBrowser_BadChan.py.

◆ onlineID

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.onlineID

Definition at line 34 of file LArDBFolderBrowser_BadChan.py.


The documentation for this class was generated from the following file:
LArBadChannelDBTools::createCoolSpec
coral::AttributeListSpecification * createCoolSpec()
creates the AttributeListSpecification for the LArBadChannel DB
Definition: LArBadChannelDBTools.cxx:35
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
LArBadChannelDBTools::createPayload
AthenaAttributeList * createPayload(const std::vector< Entry > &data, const coral::AttributeListSpecification &spec)
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
LArBadChanBlobUtils::decodeBlob
std::vector< std::pair< HWIdentifier, T > > decodeBlob(const coral::Blob *blobp, std::size_t chanSize, std::size_t stateSize, int endian, int version, MsgStream &log)
Checks BLOB for differences in endian-ness and size of data types with respect to the architecture on...
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
LArBadChannelDBTools::getDefaultMsgStream
MsgStream getDefaultMsgStream()
used to get default msg stream
Definition: LArBadChannelDBTools.cxx:28