forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'cmg-central/CMG_MiniAOD_Lite_V6_0_from-…
…CMSSW_7_0_6' into CMG_MiniAOD_Lite_V6_0_from-CMSSW_7_0_6
- Loading branch information
Showing
33 changed files
with
734 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" ]]; then | ||
echo "Usage: $0 [ -q <queue> ] [ directory ] " | ||
echo "Will look in the specified directory (or in the current one if none is specified), " | ||
echo "list failed jobs and print the cmgResubChunk commands to resubmit them." | ||
echo "The default queue is 8nh" | ||
exit 1; | ||
fi | ||
|
||
Q=8nh | ||
if [[ "$1" == "-q" ]]; then | ||
Q=$2; shift; shift; | ||
fi; | ||
|
||
BASE=""; | ||
if [[ "$1" != "" && "$1" != "." ]]; then | ||
test -d $1 && cd $1 && BASE="$PWD/"; | ||
fi | ||
|
||
echo "Will print out the commands to resubmit the chunks that failed " | ||
for D in *_Chunk[0-9]*; do | ||
test -f $D/JSONAnalyzer/JSON.pck || echo cmgResubChunk -q 8nh ${BASE}${D}; | ||
done; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" ]]; then | ||
echo "Usage: $0 [ -q <queue> ] <Component_ChunkXYZ> [ <JobName> ] " | ||
echo " will resubmit the chunk <Component_ChunkXYZ> to the queue <queue> (default: 2nd) " | ||
echo " if no jobname is specified, the job name in LSF will be the chunk name." | ||
echo " you can also run this command from within the Component_ChunkXYZ directory, in that case you can omit the chunk name" | ||
exit 1; | ||
fi | ||
|
||
Q=2nd | ||
if [[ "$1" == "-q" ]]; then | ||
Q=$2; shift; shift; | ||
fi; | ||
if [[ "$1" != "" ]] && test -d $1 && test -f $1/batchScript.sh; then | ||
cd $1; shift; | ||
elif test \! -f batchScript.sh; then | ||
echo "You did not specify a valid chunk to resubmit and you're not in a chunk directory."; | ||
exit 1; | ||
fi | ||
LAB="$(basename $PWD)"; if [[ "$1" != "" ]]; then LAB=$1; fi; | ||
rename LSFJ OLD_LSFJ *; | ||
bsub -q $Q -J $LAB < batchScript.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,65 @@ | ||
#!/usr/bin/env python | ||
from CMGTools.TTHAnalysis.treeReAnalyzer import * | ||
|
||
import os, ROOT | ||
import os,itertools, ROOT | ||
if "/smearer_cc.so" not in ROOT.gSystem.GetLibraries(): | ||
ROOT.gROOT.ProcessLine(".L %s/src/CMGTools/TTHAnalysis/python/plotter/smearer.cc+" % os.environ['CMSSW_BASE']); | ||
if "/mcCorrections_cc.so" not in ROOT.gSystem.GetLibraries(): | ||
ROOT.gROOT.ProcessLine(".L %s/src/CMGTools/TTHAnalysis/python/plotter/mcCorrections.cc+" % os.environ['CMSSW_BASE']); | ||
|
||
def plausible(rec,gen): | ||
dr = deltaR(rec,gen) | ||
if abs(rec.pdgId) == 11 and abs(gen.pdgId) != 11: return False | ||
if abs(rec.pdgId) == 13 and abs(gen.pdgId) != 13: return False | ||
if dr < 0.3: return True | ||
if gen.pt < abs(rec.pdgId) == 13 and gen.pdgId != rec.pdgId: return False | ||
if dr < 0.7: return True | ||
if min(rec.pt,gen.pt)/max(rec.pt,gen.pt) < 0.3: return False | ||
return True | ||
|
||
from optparse import OptionParser | ||
parser = OptionParser(usage="%prog [options] <PROCESS> <FILEOUT>") | ||
parser.add_option("-t", "--tree", dest="tree", default='ttHLepTreeProducerTTH', help="Pattern for tree name"); | ||
parser.add_option("-V", "--vector", dest="vectorTree", action="store_true", default=True, help="Input tree is a vector") | ||
(options, args) = parser.parse_args() | ||
|
||
class LepTreeProducer(Module): | ||
def beginJob(self): | ||
self.t = PyTree(self.book("TTree","t","t")) | ||
self.t.branch("dr_in","F") | ||
self.t.branch("ptf_in","F") | ||
self.t.branch("CSV_in","F") | ||
#self.t.branch("dr_out","F") | ||
#self.t.branch("ptf_out","F") | ||
#self.t.branch("CSV_out","F") | ||
self.t.branch("good","I") | ||
self.t.branch("nJet25","I") | ||
self.t.branch("nBJetLoose25","I") | ||
self.t.branch("nBJetMedium25","I") | ||
self.t.branch("puWeight","F") | ||
#self.t.branch("nVert","F") | ||
self.copyvars = [ 'relIso','chargedIso','mvaId','pt','eta','pdgId','innerHits','tightId',"mva"] | ||
self.copyvars = ['relIso03','chargedHadRelIso03','relIso04','chargedHadRelIso04','mvaId','pt','eta','pdgId','lostHits','tightId','nStations','trkKink','caloCompatibility','globalTrackChi2','trackerLayers','pixelLayers','mcMatchId','mcMatchAny', 'mcMatchTau'] | ||
for C in self.copyvars: self.t.branch(C,"F") | ||
# these I can't copy since I need | ||
for C in [ 'sip3d','dxy','dz' ]: self.t.branch(C,"F") | ||
# these I can't copy since I need to apply corrections | ||
for C in [ 'sip3d','dxy','dz','jetPtRatio','jetBTagCSV','jetDR']: self.t.branch(C,"F") | ||
self.first = True | ||
def analyze(self,event): | ||
#if event.nLepGood < 3: return False | ||
#jet = Collection(event,"Jet") | ||
lep = Collection(event,"LepGood","nLepGood",8) | ||
glep = Collection(event,"GenLep") | ||
gtau = Collection(event,"GenLepFromTau") | ||
for l in lep: | ||
self.t.sip3d = ROOT.scaleSip3dMC(l.sip3d, l.pdgId,l.pt,l.eta,l.mcMatchId,l.mcMatchAny) if self.corr else l.sip3d | ||
self.t.dz = ROOT.scaleDzMC( l.dz, l.pdgId,l.pt,l.eta,l.mcMatchId,l.mcMatchAny) if self.corr else l.dz | ||
self.t.dxy = ROOT.scaleDxyMC( l.dxy, l.pdgId,l.pt,l.eta,l.mcMatchId,l.mcMatchAny) if self.corr else l.dxy | ||
(dr,ptf) = (l.jetDR,l.jetPtRatio) | ||
self.t.dr_in = ROOT.correctJetDRMC(dr,l.pdgId,l.pt,l.eta,l.mcMatchId,l.mcMatchAny) if self.corr else dr | ||
self.t.ptf_in = ROOT.correctJetPtRatioMC(ptf,l.pdgId,l.pt,l.eta,l.mcMatchId,l.mcMatchAny) if self.corr else ptf | ||
self.t.CSV_in = l.jetBTagCSV | ||
#(j,dr) = closest(l, jet) | ||
#ptot = j.p4() + l.p4() | ||
#self.t.dr_out = dr | ||
#self.t.ptf_out = l.pt/ptot.Pt() | ||
#self.t.CSV_out = j.btagCSV | ||
(gmatch,dr) = closest(l,glep,presel=plausible) | ||
if dr < 1.5 and abs(gmatch.pdgId) == abs(l.pdgId): | ||
self.t.good = 20 if dr < 0.5 else 2 | ||
else: | ||
(gmatch,dr) = closest(l,gtau,presel=plausible) | ||
if dr < 1.5 and abs(gmatch.pdgId) == abs(l.pdgId): | ||
self.t.good = 10 if dr < 0.5 else 1 | ||
else: | ||
self.t.good = -l.mcMatchAny | ||
self.t.fill() | ||
self.t.jetDR = ROOT.correctJetDRMC(dr,l.pdgId,l.pt,l.eta,l.mcMatchId,l.mcMatchAny) if self.corr else dr | ||
self.t.jetPtRatio = ROOT.correctJetPtRatioMC(ptf,l.pdgId,l.pt,l.eta,l.mcMatchId,l.mcMatchAny) if self.corr else ptf | ||
self.t.jetBTagCSV = l.jetBTagCSV | ||
for C in self.copyvars: setattr(self.t, C, getattr(l,C)) | ||
self.t.nJet25 = event.nJet25 | ||
self.t.nBJetLoose25 = event.nBJetLoose25 | ||
self.t.nBJetMedium25 = event.nBJetMedium25 | ||
self.t.puWeight = event.puWeight | ||
#self.t.nVert = event.nVert | ||
self.t.fill() | ||
|
||
from sys import argv | ||
f = ROOT.TFile.Open(argv[1]) | ||
t = f.Get("ttHLepTreeProducerBase") | ||
print "Reading %s (%d entries)" % (argv[1], t.GetEntries()) | ||
f = ROOT.TFile.Open(args[0]+"/"+options.tree+"/"+options.tree+"_tree.root") | ||
t = f.Get(options.tree) | ||
t.vectorTree = options.vectorTree | ||
print "Reading %s (%d entries)" % (args[0], t.GetEntries()) | ||
|
||
booker = Booker(argv[2] if len(argv) >= 3 else "lepTree.root") | ||
booker = Booker(args[1] if len(argv) >= 3 else "lepTree.root") | ||
prod = LepTreeProducer("rec",booker) | ||
if len(argv) >= 4 and argv[3] == "NoCorr": | ||
if len(args) >= 3 and args[2] == "NoCorr": | ||
print "Will not apply corrections" | ||
prod.corr = False | ||
else: | ||
print "Will apply corrections" | ||
prod.corr = True | ||
el = EventLoop([ prod, ]) | ||
maxEv = (int(argv[4]) if len(argv) >= 5 else -1) | ||
maxEv = (int(args[3]) if len(args) >= 4 else -1) | ||
print "max entries: ",maxEv | ||
el.loop([t], maxEvents=maxEv) | ||
booker.done() |
Oops, something went wrong.