Skip to content

Commit

Permalink
Merge pull request cms-sw#56 from gpetruc/fixes_for_80X_tests
Browse files Browse the repository at this point in the history
Fixes for 80X tests
  • Loading branch information
gpetruc authored Oct 30, 2017
2 parents 7cc7fcf + d77816f commit ec7093c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
26 changes: 23 additions & 3 deletions PhysicsTools/NanoAOD/plugins/GenWeightsTableProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,11 @@ class GenWeightsTableProducer : public edm::global::EDProducer<edm::StreamCache<
std::vector<ScaleVarWeight> scaleVariationIDs;
std::vector<PDFSetWeights> pdfSetWeightIDs;

std::regex weightgroup("<weightgroup\\s+combine=\"(.*)\"\\s+name=\"(.*)\"\\s*>");
std::regex weightgroup("<weightgroup\\s+combine=\"(.*)\"\\s+(?:name|type)=\"(.*)\"\\s*>");
std::regex endweightgroup("</weightgroup>");
std::regex scalew("<weight\\s+id=\"(\\d+)\">\\s*(muR=(\\S+)\\s+muF=(\\S+)(\\s+.*)?)</weight>");
std::regex scalew("<weight\\s+id=\"(\\d+)\">\\s*(mu[rR]=(\\S+)\\s+mu[Ff]=(\\S+)(\\s+.*)?)</weight>");
std::regex pdfw("<weight\\s+id=\"(\\d+)\">\\s*PDF set\\s*=\\s*(\\d+)\\s*</weight>");
std::regex pdfwOld("<weight\\s+id=\"(\\d+)\">\\s*Member \\s*(\\d+)\\s*</weight>");
std::smatch groups;
for (auto iter=lheInfo->headers_begin(), end = lheInfo->headers_end(); iter != end; ++iter) {
if (iter->tag() != "initrwgt") {
Expand All @@ -243,7 +244,7 @@ class GenWeightsTableProducer : public edm::global::EDProducer<edm::StreamCache<
if (lheDebug) std::cout << lines[iLine];
if (std::regex_search(lines[iLine], groups, weightgroup)) {
if (lheDebug) std::cout << ">>> Looks like the beginning of a weight group for " << groups.str(2) << std::endl;
if (groups.str(2) == "scale_variation") {
if (groups.str(2) == "scale_variation" || groups.str(2) == "Central scale variation") {
for ( ++iLine; iLine < nLines; ++iLine) {
if (lheDebug) std::cout << " " << lines[iLine];
if (std::regex_search(lines[iLine], groups, scalew)) {
Expand Down Expand Up @@ -276,6 +277,25 @@ class GenWeightsTableProducer : public edm::global::EDProducer<edm::StreamCache<
break;
}
}
} else if (groups.str(2) == "NNPDF30_lo_as_0130.LHgrid") {
for ( ++iLine; iLine < nLines; ++iLine) {
if (lheDebug) std::cout << " " << lines[iLine];
if (std::regex_search(lines[iLine], groups, pdfwOld)) {
unsigned int lhaID = std::stoi(groups.str(2))+262000;
if (lheDebug) std::cout << " >>> PDF weight " << groups.str(1) << " for " << groups.str(2) << " = " << lhaID << std::endl;
if (lhaID == 262000) continue;
if (pdfSetWeightIDs.empty() || ! pdfSetWeightIDs.back().maybe_add(groups.str(1),lhaID)) {
pdfSetWeightIDs.emplace_back(groups.str(1),lhaID);
}
} else if (std::regex_search(lines[iLine], endweightgroup)) {
if (lheDebug) std::cout << ">>> Looks like the end of a weight group" << std::endl;
break;
} else if (std::regex_search(lines[iLine], weightgroup)) {
if (lheDebug) std::cout << ">>> Looks like the beginning of a new weight group, I will assume I missed the end of the group." << std::endl;
--iLine; // rewind by one, and go back to the outer loop
break;
}
}
} else {
for ( ++iLine; iLine < nLines; ++iLine) {
if (lheDebug) std::cout << " " << lines[iLine];
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/NanoAOD/python/nano_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
genWeightsTable = cms.EDProducer("GenWeightsTableProducer",
genEvent = cms.InputTag("generator"),
lheInfo = cms.InputTag("externalLHEProducer"),
preferredPDFs = cms.vuint32(91400,260001),
preferredPDFs = cms.vuint32(91400,260001,262001),
namedWeightIDs = cms.vstring(),
namedWeightLabels = cms.vstring(),
lheWeightPrecision = cms.int32(14),
Expand Down
6 changes: 3 additions & 3 deletions PhysicsTools/NanoAOD/test/inspectNanoFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def inspectRootFile(infile):
htemp = ROOT.gROOT.FindObject("htemp")
n = htemp.GetEntries() * htemp.GetMean()
htemp.Delete()
branchmap[counter]._entries = entries
branchmap[counter].entries = entries
for c in countees:
br = branchmap[c]
br.entries = n
Expand Down Expand Up @@ -168,7 +168,7 @@ def makeSurvey(treeName, treeData):
else:
tag = "<b><a href=\"#%s\">%s</a></b><br/>" % (s['name'],s['name']);
tag += "Size: %.0f b/%s (%.1f%%)" % (s['tot']/entries*1024, unit, s['tot']/allsize*100);
if (s['kind'] in ("Vector","Collection")):
if (s['kind'] in ("Vector","Collection")) and s['entries'] > 0:
tag += "<br/>Items/%s: %.1f, %.0f b/item" %(unit, float(s['entries'])/entries, s['tot']/s['entries']*1024);
scriptdata.append( "{ 'label':'%s', 'tag':'%s', 'size':%s, 'tip':'%s' }" % ( s['name'], s['name'], s['tot']/entries, tag) )
runningtotal += s['tot']
Expand Down Expand Up @@ -264,7 +264,7 @@ def writeSizeReport(fileData, stream):
stream.write("<tr class='header'><th>" + "</th><th>".join( [ "branch", "kind", "b/event", "b/item", "plot", "%" ]) + "</th></tr>\n")
subs = [ fileData.Events['branches'][b] for b in s['subs'] ]
for b in sorted(subs, key = lambda s : - s['tot']):
stream.write("<th title=\"%s\">%s</th><td style='text-align : left;'>%s</td><td>%.1f</td><td>%.1f</td>" % (b['doc'],b['name'], b['kind'], b['tot']/events*1024, b['tot']/s['entries']*1024))
stream.write("<th title=\"%s\">%s</th><td style='text-align : left;'>%s</td><td>%.1f</td><td>%.1f</td>" % (b['doc'],b['name'], b['kind'], b['tot']/events*1024, b['tot']/s['entries']*1024 if s['entries'] else 0))
stream.write("<td class=\"img\"><img src='http://gpetrucc.web.cern.ch/gpetrucc/micro/blue-dot.gif' width='%d' height='%d' /></td>" % ( b['tot']/s['tot']*200, 10 ))
stream.write("<td>%.1f%%</td>" % (b['tot']/s['tot'] * 100.0))
stream.write("</tr>\n")
Expand Down

0 comments on commit ec7093c

Please sign in to comment.