Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GenReader/plugins/EFTGenHistsWithCuts.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -74,7 +74,7 @@ struct HistInfo {
int h_no;
};

class EFTGenHistsWithCuts: public edm::EDAnalyzer
class EFTGenHistsWithCuts: public edm::one::EDAnalyzer<>
{
private:
// EDAnalyzer-specific:
Expand Down
4 changes: 2 additions & 2 deletions GenReader/plugins/EFTGenReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -72,7 +72,7 @@
// end includes
// -----------------------------------------------

class EFTGenReader: public edm::EDAnalyzer
class EFTGenReader: public edm::one::EDAnalyzer<>
{
private:
// EDAnalyzer-specific:
Expand Down
4 changes: 2 additions & 2 deletions GenReader/plugins/EFTMaodHists.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -64,7 +64,7 @@
// end includes
// -----------------------------------------------

class EFTMaodHists: public edm::EDAnalyzer
class EFTMaodHists: public edm::one::EDAnalyzer<>
{
private:
// EDAnalyzer-specific:
Expand Down
4 changes: 2 additions & 2 deletions GenReader/plugins/EFTSelectionAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -65,7 +65,7 @@
// end includes
// -----------------------------------------------

class EFTSelectionAnalyzer: public edm::EDAnalyzer
class EFTSelectionAnalyzer: public edm::one::EDAnalyzer<>
{
private:
// EDAnalyzer-specific:
Expand Down
28 changes: 14 additions & 14 deletions GenReader/python/DatasetHelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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)

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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]

Expand Down
36 changes: 18 additions & 18 deletions GenReader/python/HTMLGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ 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
self.tag_attributes[k] = v

# 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

Expand Down Expand Up @@ -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 += ">"
Expand All @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -289,7 +289,7 @@ def getTableBody(self):
# Returns the n-th <th> tag for this <table> 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
Expand Down Expand Up @@ -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)
Expand All @@ -355,7 +355,7 @@ def appendTableRow(self,row_attributes={},cell_list=[]):
# Adds a <tr> tag to the <tbody> (if present) for this <table> 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()
Expand All @@ -370,7 +370,7 @@ def addTableRow(self,table_row):
# Adds a <tr> tag to the <tbody> for this <table> 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()
Expand Down Expand Up @@ -424,7 +424,7 @@ def getHeaderRow(self):
# Returns the n-th <th> tag for this <thead> 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]
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions GenReader/python/make_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 3 additions & 3 deletions GenReader/python/update_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions GenReader/python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
4 changes: 2 additions & 2 deletions LHEReader/plugins/EFTLHEReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -63,7 +63,7 @@
// end includes
// -----------------------------------------------

class EFTLHEReader: public edm::EDAnalyzer
class EFTLHEReader: public edm::one::EDAnalyzer<>
{
private:
// EDAnalyzer-specific:
Expand Down