diff --git a/GenReader/plugins/EFTGenHistsWithCuts.h b/GenReader/plugins/EFTGenHistsWithCuts.h index 1444909..0252d52 100644 --- a/GenReader/plugins/EFTGenHistsWithCuts.h +++ b/GenReader/plugins/EFTGenHistsWithCuts.h @@ -34,7 +34,7 @@ #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -74,7 +74,7 @@ struct HistInfo { int h_no; }; -class EFTGenHistsWithCuts: public edm::EDAnalyzer +class EFTGenHistsWithCuts: public edm::one::EDAnalyzer<> { private: // EDAnalyzer-specific: diff --git a/GenReader/plugins/EFTGenReader.h b/GenReader/plugins/EFTGenReader.h index 9da8c9e..0ef9f27 100644 --- a/GenReader/plugins/EFTGenReader.h +++ b/GenReader/plugins/EFTGenReader.h @@ -35,7 +35,7 @@ #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -72,7 +72,7 @@ // end includes // ----------------------------------------------- -class EFTGenReader: public edm::EDAnalyzer +class EFTGenReader: public edm::one::EDAnalyzer<> { private: // EDAnalyzer-specific: diff --git a/GenReader/plugins/EFTMaodHists.h b/GenReader/plugins/EFTMaodHists.h index 01dd5c8..8bd8e6e 100644 --- a/GenReader/plugins/EFTMaodHists.h +++ b/GenReader/plugins/EFTMaodHists.h @@ -34,7 +34,7 @@ #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -64,7 +64,7 @@ // end includes // ----------------------------------------------- -class EFTMaodHists: public edm::EDAnalyzer +class EFTMaodHists: public edm::one::EDAnalyzer<> { private: // EDAnalyzer-specific: diff --git a/GenReader/plugins/EFTSelectionAnalyzer.h b/GenReader/plugins/EFTSelectionAnalyzer.h index 752492d..bf3f9de 100644 --- a/GenReader/plugins/EFTSelectionAnalyzer.h +++ b/GenReader/plugins/EFTSelectionAnalyzer.h @@ -35,7 +35,7 @@ #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" #include "FWCore/Framework/interface/MakerMacros.h" @@ -65,7 +65,7 @@ // end includes // ----------------------------------------------- -class EFTSelectionAnalyzer: public edm::EDAnalyzer +class EFTSelectionAnalyzer: public edm::one::EDAnalyzer<> { private: // EDAnalyzer-specific: diff --git a/GenReader/python/DatasetHelper.py b/GenReader/python/DatasetHelper.py index b5e0fb3..e0da125 100644 --- a/GenReader/python/DatasetHelper.py +++ b/GenReader/python/DatasetHelper.py @@ -16,39 +16,39 @@ def load(self,fn,update=False): # update: If set to false, will remove any pre-existing datasets and only include ones # found in the specified file if not os.path.exists(fn): - print "ERROR: Unknown file/directory: {fn}".format(fn=fn) + print("ERROR: Unknown file/directory: {fn}".format(fn=fn)) return if not update: self.__datasets = {} self.__json_files = [] - print "Loading JSON: {fn}".format(fn=fn) + print("Loading JSON: {fn}".format(fn=fn)) self.__json_files.append(fn) with open(fn) as f: d = json.load(f) - for k,ds in d.iteritems(): + for k,ds in d.items(): self.updateDataset(k,**ds) # Save the dataset info to a json file def save(self,fn): - print "Saving JSON: {fn}".format(fn=fn) + print("Saving JSON: {fn}".format(fn=fn)) with open(fn,'w') as f: d = self.toDict() json.dump(d,f,indent=2,sort_keys=True) # Return a list of all dataset names currently loaded def list(self): - return self.__datasets.keys() + return list(self.__datasets.keys()) # Return if the dataset name is known def exists(self,name): - return self.__datasets.has_key(name) + return name in self.__datasets # Print a dataset as formatted json def dump(self,name): if not self.exists(name): return ds = self.__datasets[name] - print json.dumps(ds.toDict(),indent=2,sort_keys=True) + print(json.dumps(ds.toDict(),indent=2,sort_keys=True)) # Remove all datasets def clear(self): @@ -60,7 +60,7 @@ def newDataset(self,name,force=False,**kwargs): self.updateDataset(name,**kwargs) else: if self.exists(name): - print "ERROR: Skipping {name} since it already exists!".format(name=name) + print("ERROR: Skipping {name} since it already exists!".format(name=name)) return self.__datasets[name] = DSContainer(name,**kwargs) @@ -118,7 +118,7 @@ def findOnHadoop(self,ds): lst = [] loc = str(ds.getData('loc')) # converts from a unicode string object to a normal str if not os.path.exists(loc): - print "Unknown fpath: {loc}".format(loc=loc) + print("Unknown fpath: {loc}".format(loc=loc)) return [] idx = 0 max_files = 100 # currently arbitrary @@ -135,7 +135,7 @@ def findOnHadoop(self,ds): # DSContainer() objects def toDict(self): d = {} - for k,ds in self.__datasets.iteritems(): + for k,ds in self.__datasets.items(): d[k] = ds.toDict() return d @@ -156,15 +156,15 @@ def __init__(self,name,**kwargs): # Generic setter def setData(self,**kwargs): - for k,v in kwargs.iteritems(): - if not self.__data.has_key(k): - print "Unknown key in {name}: '{key}'".format(name=self.__name,key=k) + for k,v in kwargs.items(): + if k not in self.__data: + print("Unknown key in {name}: '{key}'".format(name=self.__name,key=k)) continue self.__data[k] = v # Generic getter def getData(self,data_field): - if not self.__data.has_key(data_field): + if data_field not in self.__data: return None return self.__data[data_field] diff --git a/GenReader/python/HTMLGenerator.py b/GenReader/python/HTMLGenerator.py index fbe9462..2a71faa 100644 --- a/GenReader/python/HTMLGenerator.py +++ b/GenReader/python/HTMLGenerator.py @@ -29,11 +29,11 @@ def getContent(self): # Check if the tag has the corresponding attribute def hasAttribute(self,k): - return self.tag_attributes.has_key(k) + return k in self.tag_attributes # Adds new attribute:value pairs to this tag def addAttributes(self,**kwargs): - for k,v in kwargs.iteritems(): + for k,v in kwargs.items(): # Skip already defined attributes if k in self.CLASS_TRANSLATION: k = 'class' if self.hasAttribute(k): continue @@ -41,7 +41,7 @@ def addAttributes(self,**kwargs): # Modify existing attributes (if found) def setAttributes(self,**kwargs): - for k,v in kwargs.iteritems(): + for k,v in kwargs.items(): if not self.hasAttribute(k): continue self.tag_attributes[k] = v @@ -123,7 +123,7 @@ def dumpTag(self,depth=0): indent = INDENT_SIZE*depth*int(self.pretty_print) # Empty tags don't get indented, might want to change this at some point string = "<%s" % (self.tag_name) if self.isEmptyTag() else "%s<%s" % (indent,self.tag_name) - for k,v in self.getAttributes().iteritems(): + for k,v in self.getAttributes().items(): string += " %s=%s" % (k,self.attr2Str(k,v)) if self.isEmptyTag(): return string+"/>" string += ">" @@ -149,7 +149,7 @@ def dumpTagOLD(self): string = "<" + self.tag_name if self.use_dict: ### Alternate attribute reading - for tag_opt in self.tag_attributes.keys(): + for tag_opt in list(self.tag_attributes.keys()): string += " " if type(self.tag_attributes[tag_opt]) is int: string += tag_opt + "=%d" % self.tag_attributes[tag_opt] @@ -249,13 +249,13 @@ def __init__(self,attributes={},header_cols=[]): # children won't inherit the proper pretty_print setting when they are added to # the parent tag new_col.setPrettyPrint(self.pretty_print) - if tag_info.has_key('content'): + if 'content' in tag_info: new_col.setContent(tag_info['content']) - if tag_info.has_key('attributes'): + if 'attributes' in tag_info: new_col.addAttributes(**tag_info['attributes']) #for k,v, in tag_info['attributes'].iteritems(): # new_col.addAttribute(k,v) - if tag_info.has_key('tags'): + if 'tags' in tag_info: for tag in tag_info['tags']: new_col.addTag(tag) header_row.append(new_col) @@ -289,7 +289,7 @@ def getTableBody(self): # Returns the n-th tag for this tag def getHeaderColumn(self,n): if n >= self.nCols or n < 0: - print "ERROR: Requested column out of range!" + print("ERROR: Requested column out of range!") return elif self.table_head_index < 0: return @@ -340,13 +340,13 @@ def appendTableRow(self,row_attributes={},cell_list=[]): new_cell = DataCellTag() row.addTag(new_cell) #new_cell.setPrettyPrint(self.pretty_print) # See comment in init() - if tag_info.has_key('content'): + if 'content' in tag_info: new_cell.setContent(tag_info['content']) - if tag_info.has_key('attributes'): + if 'attributes' in tag_info: new_cell.addAttributes(**tag_info['attributes']) #for k,v in tag_info['attributes'].iteritems(): # new_cell.addAttribute(k,v) - if tag_info.has_key('tags'): + if 'tags' in tag_info: for tag in tag_info['tags']: new_cell.addTag(tag) #row.addTag(new_cell) @@ -355,7 +355,7 @@ def appendTableRow(self,row_attributes={},cell_list=[]): # Adds a tag to the (if present) for this
tag, otherwise add the row directly to the table def addTableRow(self,table_row): if not self.nCols() is None and self.nCols() != table_row.nCols(): - print "ERROR: Column Mismatch!" + print("ERROR: Column Mismatch!") return table_body = self.getTableBody() @@ -370,7 +370,7 @@ def addTableRow(self,table_row): # Adds a tag to the for this
tag def addRow(self,td_list): if self.nCols() != len(td_list): - print "ERROR: Column Mismatch!" + print("ERROR: Column Mismatch!") return new_row = TableRowTag() new_row.setPrettyPrint(self.pretty_print) # See comment in init() @@ -424,7 +424,7 @@ def getHeaderRow(self): # Returns the n-th tag def getColumn(self,n): if n >= self.nCols or n < 0: - print "ERROR: Requested column out of range!" + print("ERROR: Requested column out of range!") return head_row = self.getHeaderRow() return head_row.nested_tags[n] @@ -497,7 +497,7 @@ def __init__(self): def dumpTag(self,depth=0): indent = INDENT_SIZE*depth*int(self.pretty_print) string = "%s<%s" % (indent,self.tag_name) - for k,v in self.getAttributes().iteritems(): + for k,v in self.getAttributes().items(): string += " %s=%s" % (k,self.attr2Str(k,v)) string += ">\n" return string @@ -507,7 +507,7 @@ def dumpTagOLD(self): if self.use_dict: ### Alternate attribute reading - for tag_opt in self.tag_attributes.keys(): + for tag_opt in list(self.tag_attributes.keys()): string += " " if type(self.tag_attributes[tag_opt]) is int: string += tag_opt + "=%d" % self.tag_attributes[tag_opt] @@ -602,7 +602,7 @@ def saveHTML(self,f_name='index.html',f_dir='.'): output = self.dumpHTML() f_path = os.path.join(f_dir,f_name); - print "Saving HTML output to: %s" % f_path + print("Saving HTML output to: %s" % f_path) #html_file = open(f_path,'wb') html_file = open(f_path,'w') diff --git a/GenReader/python/make_html.py b/GenReader/python/make_html.py index 52fc4e7..9fb1b87 100644 --- a/GenReader/python/make_html.py +++ b/GenReader/python/make_html.py @@ -64,7 +64,7 @@ def getImages(tar_dir,file_type='png'): def make_html(tar_dir): home_dir = os.getcwd() if not os.path.exists(tar_dir): - print "Target directory does not exists: %s" % (tar_dir) + print("Target directory does not exists: %s" % (tar_dir)) return os.chdir(tar_dir) @@ -123,7 +123,7 @@ def main(): else: fpath = os.path.join(web_area,'eft_stuff/tmp') if not os.path.exists(fpath): - print "ERROR: Unknown path {}".format(fpath) + print("ERROR: Unknown path {}".format(fpath)) return make_html(fpath) diff --git a/GenReader/python/update_datasets.py b/GenReader/python/update_datasets.py index d3e529b..7ecf1c6 100644 --- a/GenReader/python/update_datasets.py +++ b/GenReader/python/update_datasets.py @@ -87,7 +87,7 @@ def example2(ds_helper): on_das=False, central_xsec=central_xsec ) - print new_name + print(new_name) ds_helper.dump(new_name) # Example of modifying content of existing datasets @@ -115,9 +115,9 @@ def main(): ds_helper.load(DATASET_FILE) if args.list: - print "---Available Samples---" + print("---Available Samples---") for sample_name in sorted(ds_helper.list()): - print "{name}".format(name=sample_name) + print("{name}".format(name=sample_name)) return #example1(ds_helper) diff --git a/GenReader/python/utils.py b/GenReader/python/utils.py index ace645e..a05f943 100644 --- a/GenReader/python/utils.py +++ b/GenReader/python/utils.py @@ -14,7 +14,7 @@ def run_process(inputs,verbose=True,indent=0): break if l: stdout.append(l.strip()) - if verbose: print indent_str+l.strip() + if verbose: print(indent_str+l.strip()) return stdout # Match strings using one or more regular expressions @@ -24,7 +24,7 @@ def regex_match(lst,regex_lst,verbose=0): if len(regex_lst) == 0: return lst[:] if verbose: - for p in regex_lst: print "rgx:",r"%s" % (p) + for p in regex_lst: print("rgx:",r"%s" % (p)) for s in lst: for pat in regex_lst: m = re.search(r"%s" % (pat),s) @@ -51,10 +51,10 @@ def move_files(files,target): def clean_dir(tdir,targets,dry_run=False): fnames = regex_match(get_files(tdir),targets) if len(fnames) == 0: return - print "Removing files from: {}".format(tdir) - print "\tTargets: {}".format(targets) + print("Removing files from: {}".format(tdir)) + print("\tTargets: {}".format(targets)) for fn in fnames: fpath = os.path.join(tdir,fn) - print "\tRemoving {}".format(fn) + print("\tRemoving {}".format(fn)) if not dry_run: os.remove(fpath) \ No newline at end of file diff --git a/LHEReader/plugins/EFTLHEReader.h b/LHEReader/plugins/EFTLHEReader.h index 7c97534..2eb8f00 100644 --- a/LHEReader/plugins/EFTLHEReader.h +++ b/LHEReader/plugins/EFTLHEReader.h @@ -32,7 +32,7 @@ #include "FWCore/ParameterSet/interface/ProcessDesc.h" #include "FWCore/ParameterSet/interface/FileInPath.h" #include "FWCore/Framework/interface/Frameworkfwd.h" -#include "FWCore/Framework/interface/EDAnalyzer.h" +#include "FWCore/Framework/interface/one/EDAnalyzer.h" #include "DataFormats/Common/interface/Handle.h" #include "FWCore/Framework/interface/ESHandle.h" #include "FWCore/Framework/interface/Event.h" @@ -63,7 +63,7 @@ // end includes // ----------------------------------------------- -class EFTLHEReader: public edm::EDAnalyzer +class EFTLHEReader: public edm::one::EDAnalyzer<> { private: // EDAnalyzer-specific:
tag for this