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("/")) > 4 or len(self.datasetPath.split("/")) == 1 |
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 |
|
""" |
110 |
|
""" |
111 |
|
## get DBS URL |
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" |
113 |
< |
dbs_url_map = {'glite': global_url, |
114 |
< |
'glite_slc5':global_url,\ |
115 |
< |
'glitecoll':global_url,\ |
116 |
< |
'condor': global_url,\ |
117 |
< |
'condor_g': global_url,\ |
118 |
< |
'glidein': global_url,\ |
119 |
< |
'lsf': global_url,\ |
120 |
< |
'caf': caf_url,\ |
121 |
< |
'sge': global_url,\ |
122 |
< |
'arc': global_url,\ |
123 |
< |
'pbs': global_url |
124 |
< |
} |
125 |
< |
|
126 |
< |
dbs_url_default = dbs_url_map[(common.scheduler.name()).lower()] |
127 |
< |
dbs_url= self.cfg_params.get('CMSSW.dbs_url', dbs_url_default) |
113 |
> |
dbs_url= self.cfg_params.get('CMSSW.dbs_url', global_url) |
114 |
|
common.logger.info("Accessing DBS at: "+dbs_url) |
115 |
|
|
116 |
|
## check if runs are selected |
118 |
|
if (self.cfg_params.has_key('CMSSW.runselection')): |
119 |
|
runselection = parseRange2(self.cfg_params['CMSSW.runselection']) |
120 |
|
|
121 |
+ |
## check if various lumi parameters are set |
122 |
+ |
self.lumiMask = self.cfg_params.get('CMSSW.lumi_mask',None) |
123 |
+ |
self.lumiParams = self.cfg_params.get('CMSSW.total_number_of_lumis',None) or \ |
124 |
+ |
self.cfg_params.get('CMSSW.lumis_per_job',None) |
125 |
+ |
|
126 |
+ |
lumiList = None |
127 |
+ |
if self.lumiMask: |
128 |
+ |
lumiList = LumiList(filename=self.lumiMask) |
129 |
|
|
130 |
|
self.splitByRun = int(self.cfg_params.get('CMSSW.split_by_run', 0)) |
131 |
|
|
134 |
|
args = {} |
135 |
|
args['url'] = dbs_url |
136 |
|
args['level'] = 'CRITICAL' |
143 |
– |
args['adshome'] = '$HOME/DBSADS' |
137 |
|
|
138 |
|
## check if has been requested to use the parent info |
139 |
|
useparent = int(self.cfg_params.get('CMSSW.use_parent',0)) |
151 |
|
# parse files and fill arrays |
152 |
|
for file in self.files : |
153 |
|
parList = [] |
154 |
< |
lumiList = [] # List of tuples |
154 |
> |
fileLumis = [] # List of tuples |
155 |
|
# skip already analyzed blocks |
156 |
|
fileblock = file['Block']['Name'] |
157 |
|
if fileblock not in anFileBlocks : |
159 |
|
# asked retry the list of parent for the given child |
160 |
|
if useparent==1: |
161 |
|
parList = [x['LogicalFileName'] for x in file['ParentList']] |
162 |
< |
if self.ads: |
163 |
< |
lumiList = [ (x['RunNumber'], x['LumiSectionNumber']) |
162 |
> |
if self.ads or self.lumiMask or self.lumiParams: |
163 |
> |
fileLumis = [ (x['RunNumber'], x['LumiSectionNumber']) |
164 |
|
for x in file['LumiList'] ] |
165 |
|
self.parent[filename] = parList |
166 |
< |
self.lumis[filename] = lumiList |
166 |
> |
# For LumiMask, intersection of two lists. |
167 |
> |
if self.lumiMask: |
168 |
> |
self.lumis[filename] = lumiList.filterLumis(fileLumis) |
169 |
> |
else: |
170 |
> |
self.lumis[filename] = fileLumis |
171 |
|
if filename.find('.dat') < 0 : |
172 |
|
events = file['NumberOfEvents'] |
173 |
|
# Count number of events and lumis per block |
186 |
|
|
187 |
|
# total number of events |
188 |
|
self.maxEvents += events |
189 |
< |
self.maxLumis += len(lumiList) |
189 |
> |
self.maxLumis += len(self.lumis[filename]) |
190 |
|
|
191 |
|
if self.skipBlocks and len(self.eventsPerBlock.keys()) == 0: |
192 |
|
msg = "No new fileblocks available for dataset: "+str(self.datasetPath) |
207 |
|
def queryDbs(self,api,path=None,runselection=None,useParent=None): |
208 |
|
|
209 |
|
allowedRetriveValue = ['retrive_block', 'retrive_run'] |
210 |
< |
if self.ads: allowedRetriveValue.append('retrive_lumi') |
210 |
> |
if self.ads or self.lumiMask or self.lumiParams: |
211 |
> |
allowedRetriveValue.append('retrive_lumi') |
212 |
|
if useParent == 1: allowedRetriveValue.append('retrive_parent') |
213 |
|
common.logger.debug("Set of input parameters used for DBS query: %s" % allowedRetriveValue) |
214 |
|
try: |
215 |
|
if len(runselection) <=0 : |
216 |
< |
if useParent==1 or self.splitByRun==1 or self.ads: |
216 |
> |
if useParent==1 or self.splitByRun==1 or self.ads or self.lumiMask or self.lumiParams: |
217 |
|
if self.ads: |
218 |
|
files = api.listFiles(analysisDataset=path, retriveList=allowedRetriveValue) |
219 |
|
else : |