示例#1
0
	def set_n_events_files(self, new_entry):
		new_entry["n_events_generated"]    = "-1"
		new_entry["n_files"] = "-1"
		inputDBS = new_entry.get("inputDBS", "global")
		if inputDBS in ["global","phys03","phys02","phys01"]:
			url = 'https://cmsweb.cern.ch/dbs/prod/'+inputDBS+'/DBSReader'
			from Kappa.Skimming.getNumberGeneratedEventsFromDB import RestClient
			cert = os.environ['X509_USER_PROXY']
			if not cert.strip():
				print "X509_USER_PROXY not properly set. Get a voms proxy and set this environment variable to get N events/files from siteDB"
				return 
			rest_client = RestClient(cert=cert)
			import ast
			dataset = new_entry["dbs"]
			answer=ast.literal_eval(rest_client.get(url, api='blocksummaries', params={'dataset': dataset}))
			new_entry["n_events_generated"] = str(answer[0]["num_event"])
			new_entry["n_files"] = str(answer[0]["num_file"])
		elif inputDBS in ["list"]:
			file_in = open(new_entry["dbs"] , 'r')
			n_files = 0
			n_events = 0
			for akt_line in file_in.readlines():
				if "root =" in akt_line:
					n_files +=1
					n_events += int(akt_line.split('=')[1])
					new_entry["n_events_generated"]    = str(n_events)
					new_entry["n_files"] = str(n_files)
				else:
					print "This inputDBS(",inputDBS,") can not provide event and file numbers"
示例#2
0
 def query_datasets(self,
                    pattern,
                    inputDBS=None,
                    xsec=None,
                    nick_name=None,
                    globaltag=None):
     from Kappa.Skimming.getNumberGeneratedEventsFromDB import RestClient
     cert = os.environ['X509_USER_PROXY']
     if not cert.strip():
         print "X509_USER_PROXY not properly set. Get a voms proxy and set this environment variable to get N events/files from siteDB"
         return
     rest_client = RestClient(cert=cert)
     url = 'https://cmsweb.cern.ch/dbs/prod/' + inputDBS + '/DBSReader'
     import ast
     print pattern
     dataset_list = [
         d["dataset"] for d in ast.literal_eval(
             rest_client.get(
                 url, api='datasets', params={'dataset': pattern}))
     ]
     print "Adding missing datasets queried from the pattern: "
     print pattern
     print "---------------------------------------------"
     for dataset in dataset_list:
         self.add_dataset(dataset,
                          inputDBS=inputDBS,
                          xsec=xsec,
                          nick_name=nick_name,
                          globaltag=globaltag)
     return
示例#3
0
 def set_n_events_files(self, new_entry):
     new_entry["n_events_generated"] = "-1"
     new_entry["n_files"] = "-1"
     inputDBS = new_entry.get("inputDBS", "global")
     if inputDBS in ["global", "phys03", "phys02", "phys01"]:
         url = 'https://cmsweb.cern.ch/dbs/prod/' + inputDBS + '/DBSReader'
         from Kappa.Skimming.getNumberGeneratedEventsFromDB import RestClient
         cert = os.environ['X509_USER_PROXY']
         if not cert.strip():
             print "X509_USER_PROXY not properly set. Get a voms proxy and set this environment variable to get N events/files from siteDB"
             return
         rest_client = RestClient(cert=cert)
         import ast
         dataset = new_entry["dbs"]
         answer = ast.literal_eval(
             rest_client.get(url,
                             api='blocksummaries',
                             params={'dataset': dataset}))
         new_entry["n_events_generated"] = str(answer[0]["num_event"])
         new_entry["n_files"] = str(answer[0]["num_file"])
     elif inputDBS in ["list"]:
         file_in = open(new_entry["dbs"], 'r')
         n_files = 0
         n_events = 0
         for akt_line in file_in.readlines():
             if "root =" in akt_line:
                 n_files += 1
                 n_events += int(akt_line.split('=')[1])
                 new_entry["n_events_generated"] = str(n_events)
                 new_entry["n_files"] = str(n_files)
             else:
                 print "This inputDBS(", inputDBS, ") can not provide event and file numbers"
示例#4
0
 def get_testfile_for_nick(self, nick, inputDBS='global'):
     dbsname = self.base_dict[nick]["dbs"]
     url = 'https://cmsweb.cern.ch/dbs/prod/' + inputDBS + '/DBSReader'
     from Kappa.Skimming.getNumberGeneratedEventsFromDB import RestClient
     cert = os.environ['X509_USER_PROXY']
     if not cert.strip():
         print "X509_USER_PROXY not properly set. Get a voms proxy and set this environment variable to get N events/files from siteDB"
         return
     rest_client = RestClient(cert=cert)
     import ast
     answer = ast.literal_eval(
         rest_client.get(url, api='files', params={'dataset': dbsname}))
     return 'root://cms-xrd-global.cern.ch/' + answer[0]["logical_file_name"]
示例#5
0
	def query_datasets(self,pattern,inputDBS=None, xsec=None, nick_name=None, globaltag=None):
		from Kappa.Skimming.getNumberGeneratedEventsFromDB import RestClient
		cert = os.environ['X509_USER_PROXY']
		if not cert.strip():
			print "X509_USER_PROXY not properly set. Get a voms proxy and set this environment variable to get N events/files from siteDB"
			return
		rest_client = RestClient(cert=cert)
		url = 'https://cmsweb.cern.ch/dbs/prod/'+inputDBS+'/DBSReader'
		import ast
		print pattern
		dataset_list = [d["dataset"]  for d in ast.literal_eval(rest_client.get(url, api='datasets', params={'dataset': pattern}))]
		print "Adding missing datasets queried from the pattern: "
		print pattern
		print "---------------------------------------------"
		for dataset in dataset_list:
			self.add_dataset(dataset, inputDBS=inputDBS, xsec=xsec, nick_name=nick_name, globaltag=globaltag)
		return
示例#6
0
 def is_compatible_release(self, nick, inputDBS='global'):
     dbsname = self.base_dict[nick]["dbs"]
     url = 'https://cmsweb.cern.ch/dbs/prod/' + inputDBS + '/DBSReader'
     from Kappa.Skimming.getNumberGeneratedEventsFromDB import RestClient
     cert = os.environ['X509_USER_PROXY']
     if not cert.strip():
         print "X509_USER_PROXY not properly set. Get a voms proxy and set this environment variable to get N events/files from siteDB"
         return
     rest_client = RestClient(cert=cert)
     import ast
     answer = ast.literal_eval(
         rest_client.get(url,
                         api='releaseversions',
                         params={'dataset': dbsname}))
     version = [
         int(a) for a in answer[0]["release_version"][0].split("_")[1:4]
     ]
     return tools.is_compatible_cmssw_version(version)