24 |
|
common.work_space.resDir()) + '/' |
25 |
|
return |
26 |
|
|
27 |
+ |
def getInputRunLumi(self, file): |
28 |
+ |
import xml.dom.minidom |
29 |
+ |
|
30 |
+ |
dom = xml.dom.minidom.parse(file) |
31 |
+ |
ll=[] |
32 |
+ |
|
33 |
+ |
for elem in dom.getElementsByTagName("Job"): |
34 |
+ |
nJob = int(elem.getAttribute("JobID")) |
35 |
+ |
#print "---> nJob = ", nJob |
36 |
+ |
lumis = elem.getAttribute('Lumis') |
37 |
+ |
#print "--->>> lumis = ", str(lumis) |
38 |
+ |
#lumis = '193752:1' |
39 |
+ |
#lumis = '193752:1-193752:5,193774:1-193774:5,193775:1' |
40 |
+ |
if lumis: |
41 |
+ |
tmp=str.split(str(lumis), ",") |
42 |
+ |
#print "tmp = ", tmp |
43 |
+ |
else: |
44 |
+ |
return |
45 |
+ |
|
46 |
+ |
|
47 |
+ |
#tmp = [193752:1-193752:5] [193774:1-193774:5] |
48 |
+ |
for entry in tmp: |
49 |
+ |
run_lumi=str.split(entry, "-") |
50 |
+ |
# run_lumi = [193752:1] [193752:5] |
51 |
+ |
#print"run_lumi = ", run_lumi |
52 |
+ |
if len(run_lumi) == 0: pass |
53 |
+ |
if len(run_lumi) == 1: |
54 |
+ |
lumi = str.split(run_lumi[0],":")[1] |
55 |
+ |
run = str.split(run_lumi[0],":")[0] |
56 |
+ |
ll.append((run,int(lumi))) |
57 |
+ |
|
58 |
+ |
if len(run_lumi) == 2: |
59 |
+ |
lumi_max = str.split(run_lumi[1],":")[1] |
60 |
+ |
lumi_min = str.split(run_lumi[0],":")[1] |
61 |
+ |
#print "lumi_min = ", lumi_min |
62 |
+ |
#print "lumi_max = ", lumi_max |
63 |
+ |
run = str.split(run_lumi[1],":")[0] |
64 |
+ |
#print "run = ", run |
65 |
+ |
for count in range(int(lumi_min),int(lumi_max) + 1): |
66 |
+ |
ll.append((run,count)) |
67 |
+ |
|
68 |
+ |
#print "alla fine ll = ", ll |
69 |
+ |
|
70 |
+ |
if len(ll): |
71 |
+ |
lumiList = LumiList(lumis = ll) |
72 |
+ |
#print "lumiList = ", lumiList |
73 |
+ |
compactList = lumiList.getCompactList() |
74 |
+ |
#print "compactList = ", compactList |
75 |
+ |
|
76 |
+ |
totalLumiFilename = self.fjrDirectory + 'InputLumiSummaryOfTask.json' |
77 |
+ |
totalLumiSummary = open(totalLumiFilename, 'w') |
78 |
+ |
json.dump(compactList, totalLumiSummary) |
79 |
+ |
totalLumiSummary.write('\n') |
80 |
+ |
totalLumiSummary.close() |
81 |
+ |
return totalLumiFilename |
82 |
+ |
|
83 |
+ |
def compareJsonFile(self,inputJsonFile): |
84 |
+ |
|
85 |
+ |
#if (self.fjrDirectory + 'lumiSummary.json'): |
86 |
+ |
reportFileName = self.fjrDirectory + 'lumiSummary.json' |
87 |
+ |
command = 'compareJSON.py --sub ' + inputJsonFile + ' ' + reportFileName + ' ' + self.fjrDirectory + 'missingLumiSummary.json' |
88 |
+ |
#common.logger.info(command) |
89 |
+ |
os.system(command) |
90 |
+ |
return |
91 |
+ |
|
92 |
|
def run(self): |
93 |
|
""" |
94 |
|
The main method of the class: report status of a task |
187 |
|
pass |
188 |
|
msg+= "\n----------------------------\n" |
189 |
|
common.logger.info(msg) |
125 |
– |
return |
190 |
|
|
191 |
|
|
192 |
+ |
file = common.work_space.shareDir() + 'arguments.xml' |
193 |
+ |
#print "file = ", file |
194 |
+ |
|
195 |
+ |
### starting from the arguments.xml file, a json file containing the run:lumi |
196 |
+ |
### that should be analyzed with the task |
197 |
+ |
inputRunLumiFileName = self.getInputRunLumi(file) |
198 |
+ |
|
199 |
+ |
|
200 |
+ |
### missing lumi to analyze: starting from lumimask or from argument file |
201 |
+ |
### calculate the difference with report.json |
202 |
+ |
### if a lumimask is used in the crab.cfg |
203 |
+ |
if (self.cfg_params.get('CMSSW.lumi_mask')): |
204 |
+ |
lumimask=self.cfg_params.get('CMSSW.lumi_mask') |
205 |
+ |
#print "lumimask = ", lumimask |
206 |
+ |
self.compareJsonFile(lumimask) |
207 |
+ |
### without lumimask |
208 |
+ |
elif (inputRunLumiFileName): |
209 |
+ |
self.compareJsonFile(inputRunLumiFileName) |
210 |
+ |
else: |
211 |
+ |
common.logger.info("no json file to compare") |
212 |
+ |
return |
213 |
+ |
|