ATLAS Offline Software
Loading...
Searching...
No Matches
python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan Class Reference
Collaboration diagram for python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan:

Public Member Functions

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

Public Attributes

 nspace_LArBadChannelDBTools = nspace_LArBadChannelDBTools
 class_LArBadChanBitPacking = class_LArBadChanBitPacking
 class_LArBadChannel = class_LArBadChannel
 class_HWIdentifier = class_HWIdentifier
 onlineID = onLineID
 larCablingSvc = larCablingSvc
 msg = msg
dict dict_vectBadChanEntry = {}
dict dict_vectBadChanEntry_Status = {}
dict dict_vectBadChanEntry_Init = {}
dict channelNameDict = {}
 nbProblemType
 class_LArBadChannelState = cppyy.makeClass('LArBadChannelState')
list channelProblemTypeList = []

Detailed Description

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

Definition at line 23 of file LArDBFolderBrowser_BadChan.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 27 of file LArDBFolderBrowser_BadChan.py.

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

Member Function Documentation

◆ BadChan_CheckSavedDatabaseContent()

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

Definition at line 648 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_DisplayBadChanEntry()

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

Definition at line 89 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_DisplayBadChanEntryLine()

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

Definition at line 114 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_DisplayBadChanEntryVector()

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

Definition at line 157 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_DisplayBadChanEntryVector_FromAttrList()

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

Definition at line 144 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_GetBadChannelPb_Int()

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

Definition at line 242 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_GetBadChannelPb_String()

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

Definition at line 231 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_GetBadChannelProblemType()

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

Definition at line 285 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_GetCablingServiceNameFromHWIdentifier()

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

Definition at line 444 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_GetChannelHWIdentifierAndStatus()

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 195 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_GetCoolChannelNameFromHWIdentifier()

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

Definition at line 253 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_GetNewChannelStatus()

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

Definition at line 476 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_ModifyLarBadChannel()

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

Definition at line 302 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_SaveBadChannelCorrectionsToDatabase()

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

Definition at line 549 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_SetBadChannelDataFromPayload()

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

Definition at line 54 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_SetChannelNameDict()

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

Definition at line 46 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_ShowBadChannelCorrectionsSummary()

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

Definition at line 456 of file LArDBFolderBrowser_BadChan.py.

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

◆ BadChan_TransformEntryIntoDictionnary()

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

Definition at line 172 of file LArDBFolderBrowser_BadChan.py.

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

Member Data Documentation

◆ channelNameDict

dict 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 292 of file LArDBFolderBrowser_BadChan.py.

◆ class_HWIdentifier

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.class_HWIdentifier = class_HWIdentifier

Definition at line 33 of file LArDBFolderBrowser_BadChan.py.

◆ class_LArBadChanBitPacking

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.class_LArBadChanBitPacking = class_LArBadChanBitPacking

Definition at line 31 of file LArDBFolderBrowser_BadChan.py.

◆ class_LArBadChannel

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.class_LArBadChannel = class_LArBadChannel

Definition at line 32 of file LArDBFolderBrowser_BadChan.py.

◆ class_LArBadChannelState

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.class_LArBadChannelState = cppyy.makeClass('LArBadChannelState')

Definition at line 256 of file LArDBFolderBrowser_BadChan.py.

◆ dict_vectBadChanEntry

dict python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.dict_vectBadChanEntry = {}

Definition at line 38 of file LArDBFolderBrowser_BadChan.py.

◆ dict_vectBadChanEntry_Init

dict python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.dict_vectBadChanEntry_Init = {}

Definition at line 40 of file LArDBFolderBrowser_BadChan.py.

◆ dict_vectBadChanEntry_Status

dict python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.dict_vectBadChanEntry_Status = {}

Definition at line 39 of file LArDBFolderBrowser_BadChan.py.

◆ larCablingSvc

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.larCablingSvc = larCablingSvc

Definition at line 35 of file LArDBFolderBrowser_BadChan.py.

◆ msg

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.msg = msg

Definition at line 36 of file LArDBFolderBrowser_BadChan.py.

◆ nbProblemType

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.nbProblemType

Definition at line 235 of file LArDBFolderBrowser_BadChan.py.

◆ nspace_LArBadChannelDBTools

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.nspace_LArBadChannelDBTools = nspace_LArBadChannelDBTools

Definition at line 30 of file LArDBFolderBrowser_BadChan.py.

◆ onlineID

python.LArDBFolderBrowser_BadChan.LArDBFolderBrowser_BadChan.onlineID = onLineID

Definition at line 34 of file LArDBFolderBrowser_BadChan.py.


The documentation for this class was generated from the following file: