6 from subprocess
import call
13 from getGTfromDQMFile_V2
import getGTfromDQMFile
17 dirDict = { 315252:[
'Data2018',
'Run2018'],\
18 308336:[
'Data2018',
'Commissioning2018'],\
19 294644:[
'Data2017',
'Run2017'],\
20 290123:[
'Data2017',
'Commissioning2017'],\
21 284500:[
'Data2016',
'PARun2016'],\
22 271024:[
'Data2016',
'Run2016'],\
23 264200:[
'Data2016',
'Commissioning2016'],\
24 246907:[
'Data2015',
'Run2015'],\
25 232881:[
'Data2015',
'Commissioning2015'],\
26 211658:[
'Data2013',
'Run2013'],\
27 209634:[
'Data2013',
'HIRun2013'],\
28 190450:[
'Data2012',
'Run2012']}
30 for key
in sorted(dirDict):
33 return dirDict[runKey]
37 DataLocalDir=runDirval[0]
38 DataOfflineDir=runDirval[1]
40 print 'Processing '+ Run_type +
' in '+DataOfflineDir+
"..." 42 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/' 43 url =
'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OfflineData/'+DataOfflineDir+
'/'+Run_type+
'/000'+
str(nnn)+
'xx/' 44 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")
45 f=codecs.open(
"index.html",
'r') 47 if any(
str(Run_Number[i])
in s
for s
in index):
49 if (
str(Run_Number[i])
in s)
and (
"__DQMIO.root" in s):
52 print 'No DQM file available. Please check the Offline server' 55 print 'Downloading DQM file:'+File_Name
56 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)
62 DataLocalDir=runDirval[0]
63 DataOfflineDir=runDirval[1]
69 url1 =
'https://cmsweb.cern.ch/dqm/online/data/browse/Original/000'+
str(nnnOnline)+
'xxxx/000'+
str(nnn)+
'xx/' 70 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")
72 url2 =
'https://cmsweb.cern.ch/dqm/offline/data/browse/ROOT/OnlineData/original/000'+
str(nnnOnline)+
'xxxx/000'+
str(nnn)+
'xx/' 73 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")
74 f_online_backup=codecs.open(
"index_online_backup.html",
'r') 75 index_online_backup = f_online_backup.readlines() 77 f_online=codecs.open("index_online.html",
'r') 78 index_online = f_online.readlines() 79 if any(
str(run)
in x
for x
in index_online):
80 for x
in index_online:
81 if (
str(run)
in x)
and (
"_PixelPhase1_" in x):
85 print "Can't find any file in offline server, trying the online server" 86 if any(
str(run)
in y
for y
in index_online_backup):
87 for y
in index_online:
88 if (
str(run)
in y)
and (
"_PixelPhase1_" in y):
92 print 'No Online DQM file available. Skip dead roc map' 95 print 'Downloading DQM file:'+File_Name_online
98 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)
100 os.remove(
'index_online.html')
101 os.remove(
'index_online_backup.html')
102 return deadRocMap, File_Name_online;
105 def getGT(DQMfile, RunNumber, globalTagVar):
107 print "Global Tag: " + globalTag_v0
108 globalTag = globalTag_v0
110 for z
in range(len(globalTag_v0)-2):
111 if (globalTag_v0[z].isdigit())
and (globalTag_v0[z+1].isdigit())
and (globalTag_v0[z+2].isdigit()) and(globalTag_v0[z+3].isupper()):
112 globalTag = globalTag_v0[z:]
114 print " No GlobalTag found: trying from DAS.... ";
115 globalTag =
str(os.popen(
'getGTscript.sh '+filepath+ File_Name+
' ' +
str(Run_Number[i])));
117 print " No GlobalTag found for run: "+
str(Run_Number[i]);
121 Run_type = sys.argv[1]
122 Run_Number = [
int(x)
for x
in sys.argv[2:]]
123 CMSSW_BASE =
str(os.popen(
'echo ${CMSSW_BASE}').read().
strip())
126 if Run_type ==
'Cosmics' or Run_type ==
'StreamExpress' or Run_type ==
'StreamExpressCosmics' or 'ZeroBias' or re.match(
'ZeroBias([0-9]+?)',Run_type):
129 print "please enter a valid run type: Cosmics | ZeroBias | StreamExpress | StreamExpressCosmics ";
132 for i
in range(len(Run_Number)):
134 print "Downloading File!!" 135 nnnOut = Run_Number[i]/1000
142 DataLocalDir=runDirval[0]
147 print "get the run status from DQMFile" 150 check_command =
'check_runcomplete '+filepath+File_Name
151 Check_output = subprocess.call(check_command, shell=
True)
154 if Check_output == 0:
155 print 'Using DQM file: '+File_Name
157 print '*****************Warning: DQM file is not ready************************';
158 input_var = raw_input(
"DQM file is incompleted, do you want to continue? (y/n): ")
159 if (input_var ==
'y')
or (input_var ==
'Y'):
160 print 'Using DQM file: '+File_Name
167 checkfolder = os.path.exists(
str(Run_Number[i]))
168 if checkfolder ==
True:
169 shutil.rmtree(
str(Run_Number[i]))
170 os.makedirs(
str(Run_Number[i])+
'/'+Run_type)
172 os.makedirs(
str(Run_Number[i])+
'/'+Run_type)
176 globalTag =
getGT(filepath+File_Name,
str(Run_Number[i]),
'globalTag_Step1')
181 print " Creating the TrackerMap.... " 183 detIdInfoFileName =
'TkDetIdInfo_Run'+
str(Run_Number[i])+
'_'+Run_type+
'.root' 184 workPath = os.popen(
'pwd').readline().
strip()
186 os.chdir(
str(Run_Number[i])+
'/'+Run_type)
189 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)
190 os.system(
'rm -f *svg')
192 sefile =
'QualityTest_run'+
str(Run_Number[i])+
'.txt' 193 shutil.move(
'QTBadModules.log',sefile)
203 if Run_type ==
"Cosmics" or Run_type ==
"StreamExpressCosmics":
204 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')
206 os.system(
'cat ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/data/index_template_TKMap.html | sed -e "s@RunNumber@'+
str(Run_Number[i])+
'@g" > index.html')
208 shutil.copyfile(CMSSW_BASE+
'/src/DQM/SiStripMonitorClient/data/fedmap.html',
'fedmap.html')
209 shutil.copyfile(CMSSW_BASE+
'/src/DQM/SiStripMonitorClient/data/psumap.html',
'psumap.html')
211 print " Check TrackerMap on "+
str(Run_Number[i])+
'/'+Run_type+
" folder" 214 output.append(os.popen(
"/bin/ls ").readline().
strip())
218 print " Creating the list of bad modules " 220 os.system(
'listbadmodule '+filepath+
'/'+File_Name+
' PCLBadComponents.log')
240 os.system(
'bs_bad_ls_harvester . '+
str(Run_Number[i]))
247 if (Run_type ==
"Cosmics")
or (Run_type ==
"StreamExpressCosmics"):
252 os.system(
'cmsRun ${CMSSW_BASE}/src/DQM/SiStripMonitorClient/test/mergeBadChannel_Template_cfg.py globalTag='+globalTag+
' runNumber='+
str(Run_Number[i])+
' dqmFile='+filepath+
'/'+File_Name)
253 shutil.move(
'MergedBadComponents.log',
'MergedBadComponents_run'+
str(Run_Number[i])+
'.txt')
255 os.system(
"mkdir -p /data/users/event_display/TkCommissioner_runs/"+DataLocalDir+
"/"+dest+
" 2> /dev/null")
258 shutil.copyfile(detIdInfoFileName,
'/data/users/event_display/TkCommissioner_runs/'+DataLocalDir+
'/'+dest+
'/'+detIdInfoFileName)
260 os.remove(detIdInfoFileName)
261 os.remove(
'MergedBadComponentsTkMap_Canvas.root')
262 os.remove(
'MergedBadComponentsTkMap.root')
264 print "countig dead pixel ROCs" 265 if (Run_Number[i] < 290124) :
267 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROCCounter.py '+filepath+
'/'+File_Name)
269 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROCCounter_Phase1.py '+filepath+
'/'+File_Name)
271 os.system(
'mkdir -p /data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type+
' 2> /dev/null')
273 shutil.move(
'PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt',workPath+
'/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt')
280 if deadRocMap ==
True:
282 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/DeadROC_duringRun.py '+filepath+File_Name_online+
' '+filepath+File_Name)
283 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/change_name.py')
284 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/PixelMapPlotter.py MaskedROC_sum.txt -c')
285 os.remove(
'MaskedROC_sum.txt')
286 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/InefficientDoubleROC.py '+filepath+File_Name_online)
288 print 'No Online DQM file available, Dead ROC maps will not be produced' 289 print 'No Online DQM file available, inefficient DC list will also not be produced' 293 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/MergeOccDeadROC.py '+filepath+File_Name)
296 strip_files = os.listdir(
'.')
297 for file_name
in strip_files:
298 full_stripfile_name = os.path.join(
'.', file_name)
299 if (os.path.isfile(full_stripfile_name)):
300 shutil.copy(full_stripfile_name,
'/data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type)
307 shutil.rmtree(
str(Run_Number[i]))
308 os.remove(
'index.html')
312 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/TH2PolyOfflineMaps.py ' + filepath+
'/'+File_Name+
' 3000 2000')
313 shutil.move(workPath+
'/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt',
'OUT/PixZeroOccROCs_run'+
str(Run_Number[i])+
'.txt')
317 pixel_files = os.listdir(
'./OUT')
318 for file_name
in pixel_files:
319 full_pixelfile_name = os.path.join(
'./OUT/', file_name)
320 if (os.path.isfile(full_pixelfile_name)):
321 shutil.copy(full_pixelfile_name,
'/data/users/event_display/'+DataLocalDir+
'/'+dest+
'/'+
str(nnnOut)+
'/'+
str(Run_Number[i])+
'/'+Run_type)
328 pixelTreeFileName =
'PixelPhase1Tree_Run'+
str(Run_Number[i])+
'_'+Run_type+
'.root' 329 os.system(
'${CMSSW_BASE}/src/DQM/SiStripMonitorClient/scripts/PhaseITreeProducer.py ' + filepath+
'/'+File_Name +
' ' + pixelTreeFileName)
331 shutil.copyfile(pixelTreeFileName,
'/data/users/event_display/TkCommissioner_runs/'+DataLocalDir+
'/'+dest+
'/'+pixelTreeFileName)
332 os.remove(pixelTreeFileName)
334 os.remove(filepath+File_Name)
336 os.remove(filepath+File_Name_online)
bool any(const std::vector< T > &v, const T &what)
def downloadnlineDQMhisto(run, Run_type)
def setRunDirectory(runNumber)
def getGT(DQMfile, RunNumber, globalTagVar)
def downloadOfflineDQMhisto(run, Run_type)