3 from __future__
import print_function
7 from subprocess
import call
14 from getGTfromDQMFile_V2
import getGTfromDQMFile
18 dirDict = { 315252:[
'Data2018',
'Run2018'],\
19 308336:[
'Data2018',
'Commissioning2018'],\
20 294644:[
'Data2017',
'Run2017'],\
21 290123:[
'Data2017',
'Commissioning2017'],\
22 284500:[
'Data2016',
'PARun2016'],\
23 271024:[
'Data2016',
'Run2016'],\
24 264200:[
'Data2016',
'Commissioning2016'],\
25 246907:[
'Data2015',
'Run2015'],\
26 232881:[
'Data2015',
'Commissioning2015'],\
27 211658:[
'Data2013',
'Run2013'],\
28 209634:[
'Data2013',
'HIRun2013'],\
29 190450:[
'Data2012',
'Run2012']}
31 for key
in sorted(dirDict):
34 return dirDict[runKey]
38 DataLocalDir=runDirval[0]
39 DataOfflineDir=runDirval[1]
41 print(
'Processing '+ Run_type +
' in '+DataOfflineDir+
"...")
43 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/')
44 url =
'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+
'/'+Run_type+
'/000'+
str(nnn)+
'xx/' 45 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")
46 f=codecs.open(
"index.html",
'r') 48 if any(
str(Run_Number[i])
in s
for s
in index):
50 if (
str(Run_Number[i])
in s)
and (
"__DQMIO.root" in s):
53 print(
'No DQM file available. Please check the Offline server')
56 print(
'Downloading DQM file:'+File_Name)
57 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)
63 DataLocalDir=runDirval[0]
64 DataOfflineDir=runDirval[1]
70 url1 =
'https://cmsweb.cern.ch/dqm/online/data/browse/Original/000'+
str(nnnOnline)+
'xxxx/000'+
str(nnn)+
'xx/' 71 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")
73 url2 =
'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OnlineData/original/000'+
str(nnnOnline)+
'xxxx/000'+
str(nnn)+
'xx/' 74 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")
75 f_online_backup=codecs.open(
"index_online_backup.html",
'r') 76 index_online_backup = f_online_backup.readlines() 78 f_online=codecs.open("index_online.html",
'r') 79 index_online = f_online.readlines() 80 if any(
str(run)
in x
for x
in index_online):
81 for x
in index_online:
82 if (
str(run)
in x)
and (
"_PixelPhase1_" in x):
86 print(
"Can't find any file in offline server, trying the online server")
87 if any(
str(run)
in y
for y
in index_online_backup):
88 for y
in index_online:
89 if (
str(run)
in y)
and (
"_PixelPhase1_" in y):
93 print(
'No Online DQM file available. Skip dead roc map')
96 print(
'Downloading DQM file:'+File_Name_online)
99 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)
101 os.remove(
'index_online.html')
102 os.remove(
'index_online_backup.html')
103 return deadRocMap, File_Name_online;
106 def getGT(DQMfile, RunNumber, globalTagVar):
108 print(
"Global Tag: " + globalTag_v0)
109 globalTag = globalTag_v0
111 for z
in range(len(globalTag_v0)-2):
112 if (globalTag_v0[z].isdigit())
and (globalTag_v0[z+1].isdigit())
and (globalTag_v0[z+2].isdigit()) and(globalTag_v0[z+3].isupper()):
113 globalTag = globalTag_v0[z:]
115 print(
" No GlobalTag found: trying from DAS.... ");
116 globalTag =
str(os.popen(
'getGTscript.sh '+filepath+ File_Name+
' ' +
str(Run_Number[i])));
118 print(
" No GlobalTag found for run: "+
str(Run_Number[i]));
122 Run_type = sys.argv[1]
123 Run_Number = [
int(x)
for x
in sys.argv[2:]]
124 CMSSW_BASE =
str(os.popen(
'echo ${CMSSW_BASE}').read().
strip())
127 if Run_type ==
'Cosmics' or Run_type ==
'StreamExpress' or Run_type ==
'StreamExpressCosmics' or 'ZeroBias' or re.match(
'ZeroBias([0-9]+?)',Run_type):
130 print(
"please enter a valid run type: Cosmics | ZeroBias | StreamExpress | StreamExpressCosmics ");
133 for i
in range(len(Run_Number)):
135 print(
"Downloading File!!")
136 nnnOut = Run_Number[i]/1000
143 DataLocalDir=runDirval[0]
148 print(
"get the run status from DQMFile")
151 check_command =
'check_runcomplete '+filepath+File_Name
152 Check_output = subprocess.call(check_command, shell=
True)
155 if Check_output == 0:
156 print(
'Using DQM file: '+File_Name)
158 print(
'*****************Warning: DQM file is not ready************************');
159 input_var = raw_input(
"DQM file is incompleted, do you want to continue? (y/n): ")
160 if (input_var ==
'y')
or (input_var ==
'Y'):
161 print(
'Using DQM file: '+File_Name)
168 checkfolder = os.path.exists(
str(Run_Number[i]))
169 if checkfolder ==
True:
170 shutil.rmtree(
str(Run_Number[i]))
171 os.makedirs(
str(Run_Number[i])+
'/'+Run_type)
173 os.makedirs(
str(Run_Number[i])+
'/'+Run_type)
177 globalTag =
getGT(filepath+File_Name,
str(Run_Number[i]),
'globalTag_Step1')
182 print(
" Creating the TrackerMap.... ")
184 detIdInfoFileName =
'TkDetIdInfo_Run'+
str(Run_Number[i])+
'_'+Run_type+
'.root' 185 workPath = os.popen(
'pwd').readline().
strip()
187 os.chdir(
str(Run_Number[i])+
'/'+Run_type)
190 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)
191 os.system(
'rm -f *svg')
193 sefile =
'QualityTest_run'+
str(Run_Number[i])+
'.txt' 194 shutil.move(
'QTBadModules.log',sefile)
204 if Run_type ==
"Cosmics" or Run_type ==
"StreamExpressCosmics":
205 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')
207 os.system(
'cat ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/data/index_template_TKMap.html | sed -e "s@RunNumber@'+
str(Run_Number[i])+
'@g" > index.html')
209 shutil.copyfile(CMSSW_BASE+
'/src/DQM/SiStripMonitorClient/data/fedmap.html',
'fedmap.html')
210 shutil.copyfile(CMSSW_BASE+
'/src/DQM/SiStripMonitorClient/data/psumap.html',
'psumap.html')
212 print(
" Check TrackerMap on "+
str(Run_Number[i])+
'/'+Run_type+
" folder")
215 output.append(os.popen(
"/bin/ls ").readline().
strip())
219 print(
" Creating the list of bad modules ")
221 os.system(
'listbadmodule '+filepath+
'/'+File_Name+
' PCLBadComponents.log')
241 os.system(
'bs_bad_ls_harvester . '+
str(Run_Number[i]))
248 if (Run_type ==
"Cosmics")
or (Run_type ==
"StreamExpressCosmics"):
253 os.system(
'cmsRun ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/test/mergeBadChannel_Template_cfg.py globalTag='+globalTag+
' runNumber='+
str(Run_Number[i])+
' dqmFile='+filepath+
'/'+File_Name)
254 shutil.move(
'MergedBadComponents.log',
'MergedBadComponents_run'+
str(Run_Number[i])+
'.txt')
256 os.system(
"mkdir -p /data/users/event_display/TkCommissioner_runs/"+DataLocalDir+
"/"+dest+
" 2> /dev/null")
259 shutil.copyfile(detIdInfoFileName,
'/data/users/event_display/TkCommissioner_runs/'+DataLocalDir+
'/'+dest+
'/'+detIdInfoFileName)
261 os.remove(detIdInfoFileName)
262 os.remove(
'MergedBadComponentsTkMap_Canvas.root')
263 os.remove(
'MergedBadComponentsTkMap.root')
265 print(
"countig dead pixel ROCs")
266 if (Run_Number[i] < 290124) :
268 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROCCounter.py '+filepath+
'/'+File_Name)
270 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROCCounter_Phase1.py '+filepath+
'/'+File_Name)
272 os.system(
'mkdir -p /data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type+
' 2> /dev/null')
274 shutil.move(
'PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt',workPath+
'/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt')
281 if deadRocMap ==
True:
283 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROC_duringRun.py '+filepath+File_Name_online+
' '+filepath+File_Name)
284 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/change_name.py')
285 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/PixelMapPlotter.py MaskedROC_sum.txt -c')
286 os.remove(
'MaskedROC_sum.txt')
287 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/InefficientDoubleROC.py '+filepath+File_Name_online)
289 print(
'No Online DQM file available, Dead ROC maps will not be produced')
290 print(
'No Online DQM file available, inefficient DC list will also not be produced')
294 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/MergeOccDeadROC.py '+filepath+File_Name)
297 strip_files = os.listdir(
'.')
298 for file_name
in strip_files:
299 full_stripfile_name = os.path.join(
'.', file_name)
300 if (os.path.isfile(full_stripfile_name)):
301 shutil.copy(full_stripfile_name,
'/data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type)
308 shutil.rmtree(
str(Run_Number[i]))
309 os.remove(
'index.html')
313 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/TH2PolyOfflineMaps.py ' + filepath+
'/'+File_Name+
' 3000 2000')
314 shutil.move(workPath+
'/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt',
'OUT/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt')
318 pixel_files = os.listdir(
'./OUT')
319 for file_name
in pixel_files:
320 full_pixelfile_name = os.path.join(
'./OUT/', file_name)
321 if (os.path.isfile(full_pixelfile_name)):
322 shutil.copy(full_pixelfile_name,
'/data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type)
329 pixelTreeFileName =
'PixelPhase1Tree_Run'+
str(Run_Number[i])+
'_'+Run_type+
'.root' 330 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/PhaseITreeProducer.py ' + filepath+
'/'+File_Name +
' ' + pixelTreeFileName)
332 shutil.copyfile(pixelTreeFileName,
'/data/users/event_display/TkCommissioner_runs/'+DataLocalDir+
'/'+dest+
'/'+pixelTreeFileName)
333 os.remove(pixelTreeFileName)
335 os.remove(filepath+File_Name)
337 os.remove(filepath+File_Name_online)
bool any(const std::vector< T > &v, const T &what)
S & print(S &os, JobReport::InputFile const &f)
def downloadnlineDQMhisto(run, Run_type)
def setRunDirectory(runNumber)
def getGT(DQMfile, RunNumber, globalTagVar)
def downloadOfflineDQMhisto(run, Run_type)