Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:08:42

0001 #!/usr/bin/env python3
0002 
0003 from __future__ import print_function
0004 import sys
0005 import string
0006 from ROOT import TFile
0007 from array import array
0008 
0009 def getFileInPath(rfile):
0010    import os
0011    for dir in os.environ['CMSSW_SEARCH_PATH'].split(":"):
0012      if os.path.exists(os.path.join(dir,rfile)): return os.path.join(dir,rfile)
0013    return None
0014 
0015 
0016 detIDsFileName = getFileInPath('DQM/SiStripMonitorClient/data/detids.dat')
0017 
0018 filename_online=sys.argv[1]
0019 filename_offline=sys.argv[2]
0020 
0021 runNum=filename_offline[19:25]
0022 
0023 dir="DQMData/Run " + runNum + "/PixelPhase1/Run summary/Pahse1_MechanicalView/"
0024 
0025 
0026 dirBPix=dir + "PXBarrel/"
0027 dirFPix=dir + "PXForward/"
0028 
0029 hnameB="digi_occupancy_per_SignedModuleCoord_per_SignedLadderCoord_PXLayer_"
0030 
0031 minlad=[-6,-14,-22,-32]
0032 
0033 shell=""
0034 
0035 #Barrel
0036 def BPIX_list(inputFile):
0037     DQMfile=TFile(inputFile)
0038     BPIXCounter = []
0039     BPIXCounter_v0 = []
0040     for l in range(1,5):
0041         hname=hnameB + str(l)
0042     
0043         RocMap=DQMfile.FindObjectAny(hname)
0044     
0045         for j in range(1,RocMap.GetNbinsY()+1):
0046         
0047             lad=minlad[l-1] + int(j-1)/2
0048             alad=abs(lad)
0049         
0050             for i in range(1,RocMap.GetNbinsX()+1):
0051             
0052                 roc=0
0053             
0054                 bin=RocMap.GetBin(i,j)
0055                 digi=RocMap.GetBinContent(bin)
0056 
0057                 if (digi!=0): continue
0058             
0059                 mod=-4 + int((i-1)/8)
0060 
0061                 if (lad==0 or mod==0): continue
0062 
0063                 if (lad < 0 and mod < 0) :
0064 
0065                     shell="BmO"
0066 
0067                     if (alad%2==1):
0068                         if (j%2==1): roc=(i-1)%8
0069                         if (j%2==0): roc= 15-(i-1)%8
0070                     
0071                     elif (alad%2==0):
0072                         if (j%2 ==0): roc=(i-1)%8
0073                         if (j%2 ==1): roc= 15-(i-1)%8
0074 
0075                 if (lad > 0 and mod < 0):
0076 
0077                     shell= "BmI";
0078                 
0079                     if (lad%2==1):
0080                         if (j%2 ==0): roc=(i-1)%8
0081                         if (j%2 ==1): roc= 15-(i-1)%8
0082                     
0083                     if (lad%2==0):
0084                         if (j%2 ==1): roc=(i-1)%8
0085                         if (j%2 ==0): roc= 15-(i-1)%8
0086 
0087                 if (lad > 0 and mod > 0):                                                                  
0088                 
0089                     shell= "BpI"
0090                 
0091                     if (lad%2==1):
0092                         if (j%2 ==1): roc=7-(i-1)%8
0093                         if (j%2 ==0): roc=8+(i-1)%8
0094                     
0095                     if (lad%2==0):
0096                         if (j%2 ==0): roc=7-(i-1)%8
0097                         if (j%2 ==1): roc=8+(i-1)%8
0098 
0099                 if (lad < 0 and mod > 0):     
0100                     shell= "BpO"
0101                 
0102                     if (alad%2==1):
0103                         if (j%2 ==0): roc=7-(i-1)%8
0104                         if (j%2 ==1): roc=8+(i-1)%8
0105                     
0106                     if (alad%2==0):
0107                         if (j%2 ==1): roc=7-(i-1)%8
0108                         if (j%2 ==0): roc=8+(i-1)%8
0109 
0110                 f1=open(getFileInPath('DQM/SiStripMonitorClient/data/detids.dat'))
0111                 modwritten=False
0112                 Mod_check = "LYR"+str(l) + "_LDR" + str(abs(lad)) + "F_MOD" +str(abs(mod))
0113                 shell_check = "BPix_" + str(shell)
0114 
0115                 for line in f1:
0116                     refName=line.split(" ")[1]
0117                     if modwritten: break
0118                     shell_ref = str(refName[:8]).strip()
0119                     module_ref = str(refName[14:]).strip()
0120 
0121                     if (Mod_check == module_ref) and (shell_check == shell_ref):
0122 
0123                         ModuleName_BPIX = refName.strip()+"_ROC "
0124                         BmLYR1_check = ModuleName_BPIX.split('_')                        
0125                         if ((BmLYR1_check[1] == "BmI" or BmLYR1_check[1] == "BmO") and (BmLYR1_check[3] == "LYR1")):
0126                            if int(roc) <= 7:
0127                               roc = str(int(roc)+8)
0128                            elif int(roc) >= 8:
0129                               roc =str(int(roc)-8)
0130 
0131                         BPix_Name = ModuleName_BPIX + str(roc)
0132                         BPIXCounter_v0.append(BPix_Name)
0133                         BPIXCounter = list(set(BPIXCounter_v0))
0134                         modwritten=True
0135     return BPIXCounter
0136 
0137 #End of Barrel
0138 
0139 #Doing FPix
0140 
0141 hnameF="digi_occupancy_per_SignedDiskCoord_per_SignedBladePanelCoord_PXRing_"
0142 minbld=[-11,-17]
0143 
0144 def FPIX_list(inputFile):
0145     FPIXCounter = []
0146     DQMfile=TFile(inputFile)
0147     for r in range (1,3):
0148 
0149         hname=hnameF + str(r)
0150         RocMap=DQMfile.FindObjectAny(hname)
0151 
0152         for j in range(1,RocMap.GetNbinsY()+1):        
0153 
0154             bld=minbld[r-1] + int(j-1)/4
0155             abld=abs(bld)
0156         
0157             for i in range(1,RocMap.GetNbinsX()+1):
0158             
0159                 roc=0
0160 
0161                 bin=RocMap.GetBin(i,j)
0162                 digi=RocMap.GetBinContent(bin)
0163 
0164                 if (digi!=0): continue
0165 
0166                 disk=-3 + int(i-1)/8
0167 
0168                 if (bld==0 or disk==0): continue
0169 
0170                 pnl=0
0171 
0172                 if ((j-1)%4==0 or (j-1)%4==1): pnl=2
0173                 if ((j-1)%4==2 or (j-1)%4==3): pnl=1
0174 
0175                 if (disk < 0 and bld <0):
0176 
0177                     shell= "BmO"
0178 
0179                     if ((j-1)%4==0 or (j-1)%4==3): roc= 15-(i-1)%8 
0180                     if ((j-1)%4==1 or (j-1)%4==2): roc= (i-1)%8
0181 
0182                 if (disk < 0 and bld >0):
0183                     
0184                     shell= "BmI";
0185                 
0186                     if ((j-1)%4==0 or (j-1)%4==3): roc= 15-(i-1)%8 
0187                     if ((j-1)%4==1 or (j-1)%4==2): roc= (i-1)%8
0188 
0189                 if (disk > 0 and bld >0):
0190                     
0191                     shell= "BpI"
0192                 
0193                     if ((j-1)%4==0 or (j-1)%4==3): roc=7-(i-1)%8 
0194                     if ((j-1)%4==1 or (j-1)%4==2): roc=8+(i-1)%8
0195                 
0196                 if (disk > 0 and bld <0):
0197 
0198                     shell= "BpO"
0199                 
0200                     if ((j-1)%4==0 or (j-1)%4==3): roc=7-(i-1)%8; 
0201                     if ((j-1)%4==1 or (j-1)%4==2): roc=8+(i-1)%8;
0202 
0203 
0204                 FPix_Name = "FPix_" + str(shell) + "_D" + str(abs(disk)) + '_BLD'+ str(abs(bld)) + '_PNL' + str(abs(pnl)) + '_RNG'+ str(abs(r)) + "_ROC " + str(roc) +""
0205                 FPIXCounter.append(FPix_Name)
0206     return FPIXCounter
0207 
0208 
0209 deadROCList_online = list(set(BPIX_list(filename_online))) + list(set(FPIX_list(filename_online)))
0210 deadROCList_offline = list(set(BPIX_list(filename_offline))) + list(set(FPIX_list(filename_offline)))
0211 
0212 MaskedROC_DuringRun = list(set(deadROCList_online) - set(deadROCList_offline))
0213 print('Number of New Dead ROC: '+ str(len(MaskedROC_DuringRun)))
0214 
0215 outFileName = 'DeadROC_Diff.txt'
0216 outFileName_online = 'DeadROC_online.txt'
0217 outFileName_offline = 'DeadROC_offline.txt'
0218 f = open(outFileName,"w")
0219 f1 = open(outFileName_online,"w")
0220 f2 = open(outFileName_offline,"w")
0221 
0222 for i in range(len(MaskedROC_DuringRun)):
0223 
0224     f.write(MaskedROC_DuringRun[i]+"\n")
0225 f.close()
0226 
0227 for i in range(len(deadROCList_online)):
0228 
0229     f1.write(deadROCList_online[i]+"\n")
0230 f1.close()
0231 
0232 for i in range(len(deadROCList_offline)):
0233 
0234     f2.write(deadROCList_offline[i]+"\n")
0235 f2.close()
0236 
0237