3 from __future__
import print_function
7 from subprocess
import call
14 from getGTfromDQMFile_V2
import getGTfromDQMFile
18 dirDict = { 325799:[
'Data2018',
'HIRun2018'],\
19 315252:[
'Data2018',
'Run2018'],\
20 308336:[
'Data2018',
'Commissioning2018'],\
21 294644:[
'Data2017',
'Run2017'],\
22 290123:[
'Data2017',
'Commissioning2017'],\
23 284500:[
'Data2016',
'PARun2016'],\
24 271024:[
'Data2016',
'Run2016'],\
25 264200:[
'Data2016',
'Commissioning2016'],\
26 246907:[
'Data2015',
'Run2015'],\
27 232881:[
'Data2015',
'Commissioning2015'],\
28 211658:[
'Data2013',
'Run2013'],\
29 209634:[
'Data2013',
'HIRun2013'],\
30 190450:[
'Data2012',
'Run2012']}
32 for key
in sorted(dirDict):
35 return dirDict[runKey]
39 DataLocalDir=runDirval[0]
40 DataOfflineDir=runDirval[1]
42 print(
'Processing '+ Run_type +
' in '+DataOfflineDir+
"...")
44 print(
'Directory to fetch the DQM file from: https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+
'/'+Run_type+
'/000'+
str(nnn)+
'xx/')
45 url =
'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+
'/'+Run_type+
'/000'+
str(nnn)+
'xx/' 46 os.popen(
"curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET "+url+
" > index.html")
47 f=codecs.open(
"index.html",
'r') 49 if any(
str(Run_Number[i])
in s
for s
in index):
52 if (
str(Run_Number[i])
in s)
and (
"__DQMIO.root" in s)
and (
"17Sep2018" in s):
55 if (
str(Run_Number[i])
in s)
and (
"__DQMIO.root" in s):
59 print(
'No DQM file available. Please check the Offline server')
62 print(
'Downloading DQM file:'+File_Name)
63 os.system(
'curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+
'/'+Run_type+
'/000'+
str(nnn)+
'xx/'+File_Name+
' > /tmp/'+File_Name)
69 DataLocalDir=runDirval[0]
70 DataOfflineDir=runDirval[1]
72 print(
'Processing '+ Run_type +
' in '+DataOfflineDir+
"...")
74 print(
'Directory to fetch the DQM file from: https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+
'/'+Run_type+
'/000'+
str(nnn)+
'xx/')
75 url =
'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+
'/'+Run_type+
'/000'+
str(nnn)+
'xx/' 76 os.popen(
"curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET "+url+
" > index.html")
77 f=codecs.open(
"index.html",
'r') 79 if any(
str(Run_Number[i])
in s
for s
in index):
81 if (
str(Run_Number[i])
in s)
and (
"PromptCalibProdSiPixel-Express" in s)
and (
"__ALCAPROMPT.root" in s):
84 print(
'No DQM file available. Please check the Offline server')
87 print(
'Downloading DQM file:'+File_Name)
88 os.system(
'curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+
'/'+Run_type+
'/000'+
str(nnn)+
'xx/'+File_Name+
' > /tmp/'+File_Name)
95 DataLocalDir=runDirval[0]
96 DataOfflineDir=runDirval[1]
102 url1 =
'https://cmsweb.cern.ch/dqm/online/data/browse/Original/000'+
str(nnnOnline)+
'xxxx/000'+
str(nnn)+
'xx/' 103 os.popen(
"curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET "+url1+
" > index_online.html")
105 url2 =
'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OnlineData/original/000'+
str(nnnOnline)+
'xxxx/000'+
str(nnn)+
'xx/' 106 os.popen(
"curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET "+url2+
" > index_online_backup.html")
107 f_online_backup=codecs.open(
"index_online_backup.html",
'r') index_online_backup = f_online_backup.readlines() 109 f_online=codecs.open("index_online.html",
'r') 110 index_online = f_online.readlines() 111 if any(
str(run)
in x
for x
in index_online):
112 for x
in index_online:
113 if (
str(run)
in x)
and (
"_PixelPhase1_" in x):
117 print(
"Can't find any file in offline server, trying the online server")
118 if any(
str(run)
in y
for y
in index_online_backup):
119 for y
in index_online:
120 if (
str(run)
in y)
and (
"_PixelPhase1_" in y):
124 print(
'No Online DQM file available. Skip dead roc map')
127 print(
'Downloading DQM file:'+File_Name_online)
130 os.system(
'curl -k --cert /data/users/cctrkdata/current/auth/proxy/proxy.cert --key /data/users/cctrkdata/current/auth/proxy/proxy.cert -X GET https://cmsweb.cern.ch/dqm/online/data/browse/Original/000'+
str(nnnOnline)+
'xxxx/000'+
str(nnn)+
'xx/'+File_Name_online+
' > /tmp/'+File_Name_online)
132 os.remove(
'index_online.html')
133 os.remove(
'index_online_backup.html')
134 return deadRocMap, File_Name_online;
137 def getGT(DQMfile, RunNumber, globalTagVar):
139 print(
"Global Tag: " + globalTag_v0)
140 globalTag = globalTag_v0
142 for z
in range(len(globalTag_v0)-2):
143 if (globalTag_v0[z].isdigit())
and (globalTag_v0[z+1].isdigit())
and (globalTag_v0[z+2].isdigit()) and(globalTag_v0[z+3].isupper()):
144 globalTag = globalTag_v0[z:]
147 print(
" No GlobalTag found: trying from DAS.... ")
148 globalTag =
str(os.popen(
'getGTscript.sh '+filepath+ File_Name+
' ' +
str(Run_Number[i])));
150 print(
" No GlobalTag found for run: "+
str(Run_Number[i]))
155 Run_type = sys.argv[1]
156 Run_Number = [
int(x)
for x
in sys.argv[2:]]
161 if Run_type ==
'Cosmics' or Run_type ==
'StreamExpress' or Run_type ==
'StreamExpressCosmics' or Run_type ==
'ZeroBias' or Run_type ==
'StreamHIExpress' or Run_type ==
'HIMinimumBias1' or re.match(
'ZeroBias([0-9]+?)',Run_type)
or re.match(
'HIMinimumBias([0-9]+?)',Run_type):
163 elif Run_type ==
'ReReco':
167 print(
"please enter a valid run type: Cosmics | ZeroBias | StreamExpress | StreamExpressCosmics ")
170 for i
in range(len(Run_Number)):
172 print(
"Downloading File!!")
173 nnnOut = Run_Number[i]/1000
177 if Run_type==
"StreamExpress" or Run_type==
"StreamHIExpress":
182 DataLocalDir=runDirval[0]
187 print(
"get the run status from DQMFile")
190 check_command =
'check_runcomplete '+filepath+File_Name
191 Check_output = subprocess.call(check_command, shell=
True)
194 if Check_output == 0:
195 print(
'Using DQM file: '+File_Name)
197 print(
'*****************Warning: DQM file is not ready************************')
198 input_var =
input(
"DQM file is incompleted, do you want to continue? (y/n): ")
199 if (input_var ==
'y')
or (input_var ==
'Y'):
200 print(
'Using DQM file: '+File_Name)
203 if Run_type==
"StreamExpress" or Run_type==
"StreamHIExpress":
204 if File_Name_PCL==
'Temp':
207 print(
'*****************Warning: PCL file is not ready************************')
208 input_var =
input(
"PCL file is not ready, you will need to re-run the script later for PCL plots, do you want to continue? (y/n): ")
209 if (input_var ==
'y')
or (input_var ==
'Y'):
210 print(
'--------> Remember to re-run the script later!!!!!')
216 checkfolder = os.path.exists(
str(Run_Number[i]))
217 if checkfolder ==
True:
218 shutil.rmtree(
str(Run_Number[i]))
219 os.makedirs(
str(Run_Number[i])+
'/'+Run_type)
221 os.makedirs(
str(Run_Number[i])+
'/'+Run_type)
225 globalTag =
getGT(filepath+File_Name,
str(Run_Number[i]),
'globalTag_Step1')
230 print(
" Creating the TrackerMap.... ")
232 detIdInfoFileName =
'TkDetIdInfo_Run'+
str(Run_Number[i])+
'_'+Run_type+
'.root' 233 workPath = os.popen(
'pwd').readline().
strip()
235 os.chdir(
str(Run_Number[i])+
'/'+Run_type)
238 os.system(
'cmsRun ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/test/SiStripDQM_OfflineTkMap_Template_cfg_DB.py globalTag='+globalTag+
' runNumber='+
str(Run_Number[i])+
' dqmFile='+filepath+
'/'+File_Name+
' detIdInfoFile='+detIdInfoFileName)
239 os.system(
'rm -f *svg')
241 sefile =
'QualityTest_run'+
str(Run_Number[i])+
'.txt' 242 shutil.move(
'QTBadModules.log',sefile)
252 if Run_type ==
"Cosmics" or Run_type ==
"StreamExpressCosmics":
253 os.system(
'cat ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/data/index_template_TKMap_cosmics.html | sed -e "s@RunNumber@'+
str(Run_Number[i])+
'@g" > index.html')
254 elif Run_type ==
"StreamExpress":
255 os.system(
'cat ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/data/index_template_Express_TKMap.html | sed -e "s@RunNumber@'+
str(Run_Number[i])+
'@g" > index.html')
257 os.system(
'cat ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/data/index_template_TKMap.html | sed -e "s@RunNumber@'+
str(Run_Number[i])+
'@g" > index.html')
259 shutil.copyfile(CMSSW_BASE+
'/src/DQM/SiStripMonitorClient/data/fedmap.html',
'fedmap.html')
260 shutil.copyfile(CMSSW_BASE+
'/src/DQM/SiStripMonitorClient/data/psumap.html',
'psumap.html')
262 print(
" Check TrackerMap on "+
str(Run_Number[i])+
'/'+Run_type+
" folder")
265 output.append(os.popen(
"/bin/ls ").readline().
strip())
269 print(
" Creating the list of bad modules ")
271 os.system(
'listbadmodule '+filepath+
'/'+File_Name+
' PCLBadComponents.log')
291 os.system(
'bs_bad_ls_harvester . '+
str(Run_Number[i]))
298 if (Run_type ==
"Cosmics")
or (Run_type ==
"StreamExpressCosmics"):
303 os.system(
'cmsRun ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/test/mergeBadChannel_Template_cfg.py globalTag='+globalTag+
' runNumber='+
str(Run_Number[i])+
' dqmFile='+filepath+
'/'+File_Name)
304 shutil.move(
'MergedBadComponents.log',
'MergedBadComponents_run'+
str(Run_Number[i])+
'.txt')
306 os.system(
"mkdir -p /data/users/event_display/TkCommissioner_runs/"+DataLocalDir+
"/"+dest+
" 2> /dev/null")
309 shutil.copyfile(detIdInfoFileName,
'/data/users/event_display/TkCommissioner_runs/'+DataLocalDir+
'/'+dest+
'/'+detIdInfoFileName)
311 os.remove(detIdInfoFileName)
312 os.remove(
'MergedBadComponentsTkMap_Canvas.root')
313 os.remove(
'MergedBadComponentsTkMap.root')
315 print(
"countig dead pixel ROCs" )
316 if (Run_Number[i] < 290124) :
318 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROCCounter.py '+filepath+
'/'+File_Name)
320 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROCCounter_Phase1.py '+filepath+
'/'+File_Name)
323 os.system(
'mkdir -p /data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/ReReco 2> /dev/null')
325 os.system(
'mkdir -p /data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type+
' 2> /dev/null')
327 shutil.move(
'PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt',workPath+
'/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt')
334 if deadRocMap ==
True:
336 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROC_duringRun.py '+filepath+File_Name_online+
' '+filepath+File_Name)
337 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/change_name.py')
338 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/PixelMapPlotter.py MaskedROC_sum.txt -c')
339 os.remove(
'MaskedROC_sum.txt')
340 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/InefficientDoubleROC.py '+filepath+File_Name_online)
342 print(
'No Online DQM file available, Dead ROC maps will not be produced')
343 print(
'No Online DQM file available, inefficient DC list will also not be produced')
347 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/MergeOccDeadROC.py '+filepath+File_Name)
350 if Run_type==
"StreamExpress" or Run_type==
"StreamHIExpress":
351 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/MergePCLDeadROC.py '+filepath+File_Name+
' '+filepath+File_Name_PCL)
352 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/MergePCLFedErr.py '+filepath+File_Name+
' '+filepath+File_Name_PCL)
353 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/PCLOthers.py '+filepath+File_Name+
' '+filepath+File_Name_PCL)
356 strip_files = os.listdir(
'.')
357 for file_name
in strip_files:
358 full_stripfile_name = os.path.join(
'.', file_name)
359 if (os.path.isfile(full_stripfile_name)):
361 shutil.copy(full_stripfile_name,
'/data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/ReReco')
363 shutil.copy(full_stripfile_name,
'/data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type)
370 shutil.rmtree(
str(Run_Number[i]))
371 os.remove(
'index.html')
375 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/TH2PolyOfflineMaps.py ' + filepath+
'/'+File_Name+
' 3000 2000')
376 shutil.move(workPath+
'/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt',
'OUT/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt')
380 pixel_files = os.listdir(
'./OUT')
381 for file_name
in pixel_files:
382 full_pixelfile_name = os.path.join(
'./OUT/', file_name)
383 if (os.path.isfile(full_pixelfile_name)):
385 shutil.copy(full_pixelfile_name,
'/data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/ReReco')
387 shutil.copy(full_pixelfile_name,
'/data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type)
394 pixelTreeFileName =
'PixelPhase1Tree_Run'+
str(Run_Number[i])+
'_'+Run_type+
'.root' 395 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/PhaseITreeProducer.py ' + filepath+
'/'+File_Name +
' ' + pixelTreeFileName)
397 shutil.copyfile(pixelTreeFileName,
'/data/users/event_display/TkCommissioner_runs/'+DataLocalDir+
'/'+dest+
'/'+pixelTreeFileName)
398 os.remove(pixelTreeFileName)
400 os.remove(filepath+File_Name)
402 os.remove(filepath+File_Name_online)
404
bool any(const std::vector< T > &v, const T &what)
static std::string const input
def downloadnlineDQMhisto(run, Run_type)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def downloadOfflinePCLhisto(run, Run_type)
def split(sequence, size)
def setRunDirectory(runNumber)
def getGT(DQMfile, RunNumber, globalTagVar)
def downloadOfflineDQMhisto(run, Run_type, rereco)