Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-26 02:34:10

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