8 |
|
from DBSAPI.dbsApiException import * |
9 |
|
import common |
10 |
|
from crab_util import * |
11 |
+ |
from LumiList import LumiList |
12 |
|
import os |
13 |
|
|
14 |
|
|
89 |
|
# Attributes |
90 |
|
self.datasetPath = datasetPath |
91 |
|
# Analysis dataset is primary/processed/tier/definition |
92 |
< |
self.ads = len(self.datasetPath.split("/")) > 3 |
92 |
> |
self.ads = len(self.datasetPath.split("/")) > 4 |
93 |
|
self.cfg_params = cfg_params |
94 |
|
self.skipBlocks = skipAnBlocks |
95 |
|
|
102 |
|
self.maxLumis = 0 # DBS output: total number of lumis |
103 |
|
self.parent = {} # DBS output: parents of each file |
104 |
|
self.lumis = {} # DBS output: lumis in each file |
105 |
< |
|
105 |
> |
self.lumiMask = None |
106 |
|
|
107 |
|
def fetchDBSInfo(self): |
108 |
|
""" |
112 |
|
global_url="http://cmsdbsprod.cern.ch/cms_dbs_prod_global/servlet/DBSServlet" |
113 |
|
caf_url = "http://cmsdbsprod.cern.ch/cms_dbs_caf_analysis_01/servlet/DBSServlet" |
114 |
|
dbs_url_map = {'glite': global_url, |
115 |
+ |
'glite_slc5':global_url,\ |
116 |
|
'glitecoll':global_url,\ |
117 |
|
'condor': global_url,\ |
118 |
|
'condor_g': global_url,\ |
119 |
|
'glidein': global_url,\ |
120 |
|
'lsf': global_url,\ |
121 |
|
'caf': caf_url,\ |
122 |
< |
'sge': global_url, |
123 |
< |
'arc': global_url |
122 |
> |
'sge': global_url,\ |
123 |
> |
'arc': global_url,\ |
124 |
> |
'pbs': global_url |
125 |
|
} |
126 |
|
|
127 |
|
dbs_url_default = dbs_url_map[(common.scheduler.name()).lower()] |
128 |
|
dbs_url= self.cfg_params.get('CMSSW.dbs_url', dbs_url_default) |
129 |
< |
common.logger.debug("Accessing DBS at: "+dbs_url) |
129 |
> |
common.logger.info("Accessing DBS at: "+dbs_url) |
130 |
|
|
131 |
|
## check if runs are selected |
132 |
|
runselection = [] |
133 |
|
if (self.cfg_params.has_key('CMSSW.runselection')): |
134 |
|
runselection = parseRange2(self.cfg_params['CMSSW.runselection']) |
135 |
|
|
136 |
+ |
## check if lumiMask is set |
137 |
+ |
self.lumiMask = self.cfg_params.get('CMSSW.lumi_mask',None) |
138 |
+ |
lumiList = None |
139 |
+ |
if self.lumiMask: |
140 |
+ |
lumiList = LumiList(filename=self.lumiMask) |
141 |
|
|
142 |
|
self.splitByRun = int(self.cfg_params.get('CMSSW.split_by_run', 0)) |
143 |
|
|
163 |
|
# parse files and fill arrays |
164 |
|
for file in self.files : |
165 |
|
parList = [] |
166 |
< |
lumiList = [] # List of tuples |
166 |
> |
fileLumis = [] # List of tuples |
167 |
|
# skip already analyzed blocks |
168 |
|
fileblock = file['Block']['Name'] |
169 |
|
if fileblock not in anFileBlocks : |
171 |
|
# asked retry the list of parent for the given child |
172 |
|
if useparent==1: |
173 |
|
parList = [x['LogicalFileName'] for x in file['ParentList']] |
174 |
< |
if self.ads: |
175 |
< |
lumiList = [ (x['RunNumber'], x['LumiSectionNumber']) |
174 |
> |
if self.ads or self.lumiMask: |
175 |
> |
fileLumis = [ (x['RunNumber'], x['LumiSectionNumber']) |
176 |
|
for x in file['LumiList'] ] |
177 |
|
self.parent[filename] = parList |
178 |
< |
self.lumis[filename] = lumiList |
178 |
> |
# For LumiMask, intersection of two lists. |
179 |
> |
if self.lumiMask: |
180 |
> |
self.lumis[filename] = lumiList.filterLumis(fileLumis) |
181 |
> |
else: |
182 |
> |
self.lumis[filename] = fileLumis |
183 |
|
if filename.find('.dat') < 0 : |
184 |
|
events = file['NumberOfEvents'] |
185 |
|
# Count number of events and lumis per block |
198 |
|
|
199 |
|
# total number of events |
200 |
|
self.maxEvents += events |
201 |
< |
self.maxLumis += len(lumiList) |
201 |
> |
self.maxLumis += len(self.lumis[filename]) |
202 |
|
|
203 |
|
if self.skipBlocks and len(self.eventsPerBlock.keys()) == 0: |
204 |
|
msg = "No new fileblocks available for dataset: "+str(self.datasetPath) |
219 |
|
def queryDbs(self,api,path=None,runselection=None,useParent=None): |
220 |
|
|
221 |
|
allowedRetriveValue = ['retrive_block', 'retrive_run'] |
222 |
< |
if self.ads: allowedRetriveValue.append('retrive_lumi') |
222 |
> |
if self.ads or self.lumiMask: |
223 |
> |
allowedRetriveValue.append('retrive_lumi') |
224 |
|
if useParent == 1: allowedRetriveValue.append('retrive_parent') |
225 |
|
common.logger.debug("Set of input parameters used for DBS query: %s" % allowedRetriveValue) |
226 |
|
try: |
227 |
|
if len(runselection) <=0 : |
228 |
< |
if useParent==1 or self.splitByRun==1 : |
228 |
> |
if useParent==1 or self.splitByRun==1 or self.ads or self.lumiMask: |
229 |
|
if self.ads: |
230 |
|
files = api.listFiles(analysisDataset=path, retriveList=allowedRetriveValue) |
231 |
|
else : |