Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New version of heppy #8536

Merged
merged 80 commits into from
Mar 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
9dd4189
Adding jet pT sorting
safarzad Jan 23, 2015
389d905
Heppy - Fixed metNoMu to still subtract the muons even when not recal…
Jan 28, 2015
6ef7f08
back to using full5x5 clustershapes
pandolf Feb 3, 2015
8ff64a2
full5x5 methods now have full5x5 in the name
pandolf Feb 3, 2015
b18db62
updated to new particle selection (see https://github.com/UAEDF-tomc/…
pandolf Feb 3, 2015
d3a994d
Heppy METAnalyzer: add rawmet
mariadalfonso Feb 4, 2015
4d320a3
compatible with new version of rootfile
pandolf Feb 4, 2015
67d0a78
Replaced PAT photon isolation with RECO isolation
mmasciov Feb 5, 2015
7b18f2b
quiet printout and removed obsolete files
cbernet Feb 6, 2015
a9d8479
finalized quiet printout in CMSSW scripts
cbernet Feb 6, 2015
9a6bdd0
logging level driven by cfg file
cbernet Feb 6, 2015
6f76184
Added import ROOT
mmasciov Feb 6, 2015
b6a14ca
timereport logged as warning
cbernet Feb 7, 2015
71cebc8
Update tau object/analyzer/filler to latest POG recommendations
steggema Feb 9, 2015
5a15794
HeppyCore heppy: add verbose switch to bring logging to INFO info lev…
gpetruc Feb 10, 2015
afb0ad2
Use correct name + check for presence of decay mode finding ID in config
steggema Feb 11, 2015
7436808
Update to latest tau POG recommendation
steggema Feb 11, 2015
5750578
Heppy - Fixed bug with batch submission at Imperial College
Feb 10, 2015
79e5af6
Heppy - added metNoPhoton to the met analyzer
Feb 10, 2015
fb4cb5e
Heppy - updated the METAnalyzer and added options for batch submissio…
Jan 27, 2015
36e1e1c
Update impact parameter handling to POG recommendations
steggema Feb 11, 2015
78cb849
add cmsRun preprocessor
arizzi Feb 12, 2015
2aa9040
clean up and fix file hierarchy
arizzi Feb 12, 2015
7eb4976
remove kwargs
arizzi Feb 12, 2015
a31cf9f
Heppy Jet: cleaning jet-photon only on with the laeading photon
mariadalfonso Feb 12, 2015
54eb93b
Heppy Jet: cleaning jet-photon only on with the laeading photon
mariadalfonso Feb 12, 2015
9286dfa
Heppy: fixes in PileUpAnalyzer, adding default config
arizzi Jan 27, 2015
e90a9b6
Heppy : fix LHE analyzer pedning a better fix in FWLite
arizzi Feb 13, 2015
30e48ba
bug fix for running without preprocessor
arizzi Feb 13, 2015
eaad6c6
more complete and commented examples
arizzi Feb 13, 2015
264d7ca
Heppy: tool to recompute lepton isolation in C++; weights for neutral…
gpetruc Feb 2, 2015
32b84ab
Heppy Lepton analyzer: miniIsolation and improvements:
gpetruc Feb 2, 2015
b60aa07
Heppy JetAnalyzer: improvements in cleaning\nallow choosing whether t…
gpetruc Feb 3, 2015
fb85ceb
now using compiled IsolationComputer
pandolf Feb 6, 2015
b4e011d
added configurable fromPV() threshold and dz threshold and option to …
pandolf Feb 6, 2015
bb0b74d
removed useless cmgCand handle
pandolf Feb 6, 2015
079677c
fixed parentheses
pandolf Feb 6, 2015
b464a0c
add configurable first photon jet cleaning
mariadalfonso Feb 13, 2015
503d487
HeppyCore: add a line with the total in the time report
gpetruc Feb 4, 2015
11243bf
Heppy: more decent printout of NTupleVariable and such
gpetruc Feb 4, 2015
5102ec2
Heppy: speed up a bit the GeneratorAnalyer (~10%)
gpetruc Feb 5, 2015
bf72b0b
HeppyCore: Small speedup of combinatorics in MC matching
gpetruc Feb 13, 2015
48cd51e
add missing file.cd() to write the tree in the output service file
arizzi Feb 16, 2015
9c2989d
example configuration for running on crab
arizzi Feb 16, 2015
ed52265
Add support for multiple trees in same file and an example to play wi…
arizzi Feb 16, 2015
9e265f6
add an optional filter function in tree producer to select events to …
arizzi Feb 17, 2015
2625759
add protection for multiple trees with same name
arizzi Feb 17, 2015
b760850
recover original MT2 precision
Feb 18, 2015
ab306c0
recover original MT2 precision. Also in mt2w_bisect.cc
Feb 18, 2015
780d308
revert wrong merge on looper.py, add type to nevents so that is prope…
arizzi Feb 18, 2015
14c1163
generalize associated vertices for cases where there are no good vert…
Feb 18, 2015
b6e57fe
Remove duplicate function definition; remove tau-tau specific relativ…
steggema Feb 19, 2015
30d2c1c
Fix name of R-dependent all charged iso; redefine default all charged…
steggema Feb 19, 2015
9cdf0a7
Add default all charged isolation for muon (which will be used in abs…
steggema Feb 19, 2015
00bb8f8
Fix for generator feature in Phys 14 ggH samples and fix method call
steggema Feb 19, 2015
fa79dc3
Go back to import like in heppy branch
steggema Feb 19, 2015
23ee900
Remove unneeded specific H->tau tau electron
steggema Feb 19, 2015
c5c0f6f
Make the tau relIso dummy method really behave like the lepton one
steggema Feb 19, 2015
d0c8d6b
add the calculation of monojet specific event variables
emanueledimarco Feb 18, 2015
313811a
add the calculation of monojet specific event variables
emanueledimarco Feb 18, 2015
8c7ffc6
normalize Adish's variable with HT
emanueledimarco Feb 19, 2015
acf5239
adding back electron eta SC variable in Heppy
Feb 25, 2015
6ec8455
added PDF variables to PDF analyzer, leptonic tops to generator, LHE …
jpata Feb 27, 2015
0a61a9c
Heppy: Add tau matching
arizzi Mar 1, 2015
316d044
save top quark neutrinos
jpata Mar 2, 2015
762d3c9
now matching photons also to protons
pandolf Mar 4, 2015
35e84d7
Heppy METAnalyzer: fix tkMET
mariadalfonso Mar 8, 2015
f9a0039
removed unded handles
mariadalfonso Mar 8, 2015
98e8ebc
add methods to ReclusterJets
cbotta Mar 11, 2015
2787516
HeppyCore looper: fix sub-file splitting boundaries
gpetruc Mar 16, 2015
f11d445
Merge branch 'tmp_merge_attempt_giovanni' of https://github.com/cbern…
gpetruc Mar 18, 2015
411ffe1
fix compilation of IsolationComputer
gpetruc Mar 18, 2015
467dccb
reverted to official test files
cbernet Mar 19, 2015
89f5f03
bug fix: setup object passed to analyzer beginLoop
cbernet Mar 19, 2015
75dff72
Merge branch 'cbernet/heppy_7_4_0_pre6' into merge-attempt
cbernet Mar 19, 2015
fecf363
Merge branch 'heppy_7_4_X' of https://github.com/cbernet/cmssw into h…
gpetruc Mar 25, 2015
e5fdbef
Don't use deepcopy, just call pat::MET constructor. And, use enum ins…
gpetruc Mar 25, 2015
4064364
Merge branch 'patMET_ctor_fix-740p9' into heppy_740p9
gpetruc Mar 25, 2015
1985cb1
Merged heppy_7_4_X from repository cbernet
cbernet Mar 26, 2015
ef0e756
Merged heppy_740p9 from repository gpetruc
cbernet Mar 26, 2015
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
28 changes: 28 additions & 0 deletions PhysicsTools/Heppy/interface/Apc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef PhysicsTools_Heppy_Apc_h
#define PhysicsTools_Heppy_Apc_h

#include <cmath>
#include <numeric>
#include <vector>


/* Apc
*
* Calculates the Apc event variable for a given input jet collection
*
*/

namespace heppy {

struct Apc {

static double getApcJetMetMin( const std::vector<double>& et,
const std::vector<double>& px,
const std::vector<double>& py,
const double metx, const double mety);

};

};

#endif // Apc_h
64 changes: 64 additions & 0 deletions PhysicsTools/Heppy/interface/IsolationComputer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#ifndef PhysicsTools_Heppy_IsolationComputer_h
#define PhysicsTools_Heppy_IsolationComputer_h

#include <vector>
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"

namespace heppy {
class IsolationComputer {
public:
/// Create the calculator; optionally specify a cone for computing deltaBeta weights
IsolationComputer(float weightCone=-1) : weightCone_(weightCone) {}

/// Self-veto policy
enum SelfVetoPolicy {
selfVetoNone=0, selfVetoAll=1, selfVetoFirst=2
};
/// Initialize with the list of packed candidates (note: clears also all vetos)
void setPackedCandidates(const std::vector<pat::PackedCandidate> & all, int fromPV_thresh=1, float dz_thresh=9999., bool also_leptons=false) ;


/// veto footprint from this candidate, for the isolation of all candidates and also for calculation of neutral weights (if used)
void addVetos(const reco::Candidate &cand) ;

/// clear all vetos
void clearVetos() ;

/// Isolation from charged from the PV
float chargedAbsIso(const reco::Candidate &cand, float dR, float innerR=0, float threshold=0, SelfVetoPolicy selfVeto=selfVetoAll) const ;

/// Isolation from charged from PU
float puAbsIso(const reco::Candidate &cand, float dR, float innerR=0, float threshold=0, SelfVetoPolicy selfVeto=selfVetoAll) const ;

/// Isolation from all neutrals (uncorrected)
float neutralAbsIsoRaw(const reco::Candidate &cand, float dR, float innerR=0, float threshold=0, SelfVetoPolicy selfVeto=selfVetoAll) const ;

/// Isolation from neutral hadrons (uncorrected)
float neutralHadAbsIsoRaw(const reco::Candidate &cand, float dR, float innerR=0, float threshold=0, SelfVetoPolicy selfVeto=selfVetoAll) const ;

/// Isolation from photons (uncorrected)
float photonAbsIsoRaw(const reco::Candidate &cand, float dR, float innerR=0, float threshold=0, SelfVetoPolicy selfVeto=selfVetoAll) const ;

/// Isolation from all neutrals (with weights)
float neutralAbsIsoWeighted(const reco::Candidate &cand, float dR, float innerR=0, float threshold=0, SelfVetoPolicy selfVeto=selfVetoAll) const ;

/// Isolation from neutral hadrons (with weights)
float neutralHadAbsIsoWeighted(const reco::Candidate &cand, float dR, float innerR=0, float threshold=0, SelfVetoPolicy selfVeto=selfVetoAll) const ;

/// Isolation from photons (with weights)
float photonAbsIsoWeighted(const reco::Candidate &cand, float dR, float innerR=0, float threshold=0, SelfVetoPolicy selfVeto=selfVetoAll) const ;
protected:
const std::vector<pat::PackedCandidate> * allcands_;
float weightCone_;
// collections of objects, sorted in eta
std::vector<const pat::PackedCandidate *> charged_, neutral_, pileup_;
mutable std::vector<float> weights_;
std::vector<const reco::Candidate *> vetos_;

float isoSumRaw(const std::vector<const pat::PackedCandidate *> & cands, const reco::Candidate &cand, float dR, float innerR, float threshold, SelfVetoPolicy selfVeto, int pdgId=-1) const ;
float isoSumNeutralsWeighted(const reco::Candidate &cand, float dR, float innerR, float threshold, SelfVetoPolicy selfVeto, int pdgId=-1) const ;
};

}

#endif
14 changes: 14 additions & 0 deletions PhysicsTools/Heppy/interface/ReclusterJets.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,27 @@ class ReclusterJets {

/// get grouping (exclusive jets, until n are left)
std::vector<LorentzVector> getGroupingExclusive(int njets);

/// get grouping (exclusive jets, up to cut dcut)
std::vector<LorentzVector> getGroupingExclusive(double dcut);

/// get pruned 4-vector
LorentzVector getPruned(double zcut, double rcutFactor) ;

/// get pruned 4-vector for a given subject (must be called after getGroupingExclusive)
LorentzVector getPrunedSubjetExclusive(unsigned int isubjet, double zcut, double rcutFactor) ;

/// get pruned 4-vector for a given subject (must be called after getGroupingInclusive)
LorentzVector getPrunedSubjetInclusive(unsigned int isubjet, double zcut, double rcutFactor) ;


private:
// pack the returns in a fwlite-friendly way
std::vector<LorentzVector> makeP4s(const std::vector<fastjet::PseudoJet> &jets) ;

// prune and return in fa fwlite-friendly way
LorentzVector getPruned(const fastjet::PseudoJet & jet, double zcut, double rcutFactor) ;

// used to handle the inputs
std::vector<fastjet::PseudoJet> fjInputs_; // fastjet inputs

Expand Down
34 changes: 33 additions & 1 deletion PhysicsTools/Heppy/python/analyzers/core/AutoFillTreeProducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def declareVariables(self,setup):
tree = self.tree
self.declareCoreVariables(tree, isMC)

if not hasattr(self.cfg_ana,"ignoreAnalyzerBookings") or not self.cfg_ana.ignoreAnalyzerBooking :
if not hasattr(self.cfg_ana,"ignoreAnalyzerBookings") or not self.cfg_ana.ignoreAnalyzerBookings :
#import variables declared by the analyzers
if hasattr(setup,"globalVariables"):
self.globalVariables+=setup.globalVariables
Expand Down Expand Up @@ -137,6 +137,9 @@ def fillCoreVariables(self, tr, event, isMC):
tr.vfill('pdfWeight_%s' % pdf, event.pdfWeights[pdf])

def process(self, event):
if hasattr(self.cfg_ana,"filter") :
if not self.cfg_ana.filter(event) :
return True #do not stop processing, just filter myself
self.readCollections( event.input)
self.fillTree(event)

Expand Down Expand Up @@ -167,4 +170,33 @@ def fillTree(self, event, resetFirst=True):
c.fillBranchesVector(self.tree, getattr(event, cn), isMC)

self.tree.tree.Fill()

def getPythonWrapper(self):
"""
This function produces a string that contains a Python wrapper for the event.
The wrapper is automatically generated based on the collections and allows the full
event contents to be accessed from subsequent Analyzers using e.g.

leps = event.selLeptons #is of type selLeptons
pt0 = leps[0].pt

One just needs to add the EventAnalyzer to the sequence.
"""

isMC = self.cfg_comp.isMC

classes = ""
anclass = ""
anclass += "from PhysicsTools.HeppyCore.framework.analyzer import Analyzer\n"
anclass += "class EventAnalyzer(Analyzer):\n"
anclass += " def __init__(self, cfg_ana, cfg_comp, looperName):\n"
anclass += " super(EventAnalyzer, self).__init__(cfg_ana, cfg_comp, looperName)\n"

anclass += " def process(self, event):\n"

for cname, coll in self.collections.items():
classes += coll.get_py_wrapper_class(isMC)
anclass += " event.{0} = {0}.make_array(event)\n".format(coll.name)

return classes + "\n" + anclass

13 changes: 12 additions & 1 deletion PhysicsTools/Heppy/python/analyzers/core/PileUpAnalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from PhysicsTools.Heppy.analyzers.core.AutoHandle import AutoHandle
from PhysicsTools.HeppyCore.statistics.average import Average
from PhysicsTools.Heppy.physicsutils.PileUpSummaryInfo import PileUpSummaryInfo
import PhysicsTools.HeppyCore.framework.config as cfg

from ROOT import TFile, TH1F

class PileUpAnalyzer( Analyzer ):
Expand Down Expand Up @@ -57,7 +59,7 @@ def __init__(self, cfg_ana, cfg_comp, looperName):
self.cfg_comp.puFileData = None

if self.cfg_comp.isMC or self.cfg_comp.isEmbed:
if self.cfg_comp.puFileMC is None and self.cfg_comp.puFileData is None:
if not hasattr(self.cfg_comp,"puFileMC") or (self.cfg_comp.puFileMC is None and self.cfg_comp.puFileData is None):
self.enable = False
else:
assert( os.path.isfile(self.cfg_comp.puFileMC) )
Expand Down Expand Up @@ -145,3 +147,12 @@ def write(self, setup):
super(PileUpAnalyzer, self).write(setup)
if self.cfg_comp.isMC and self.doHists:
self.rawmcpileup.write()


setattr(PileUpAnalyzer,"defaultConfig", cfg.Analyzer(
class_object = PileUpAnalyzer,
true = True, # use number of true interactions for reweighting
makeHists=False
)
)

11 changes: 6 additions & 5 deletions PhysicsTools/Heppy/python/analyzers/core/TreeAnalyzerNumpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ class TreeAnalyzerNumpy( Analyzer ):

def __init__(self, cfg_ana, cfg_comp, looperName):
super(TreeAnalyzerNumpy,self).__init__(cfg_ana, cfg_comp, looperName)
self.outservicename = "outputfile"
if hasattr(cfg_ana,"outservicename") :
self.outservicename = cfg_ana.outservicename
self.outservicename = getattr(cfg_ana,"outservicename","outputfile")
self.treename = getattr(cfg_ana,"treename","tree")


def beginLoop(self, setup) :
super(TreeAnalyzerNumpy, self).beginLoop(setup)
print setup.services
if self.outservicename in setup.services:
print "Using outputfile given in", self.outservicename
self.file = setup.services[self.outservicename].file
Expand All @@ -28,7 +26,10 @@ def beginLoop(self, setup) :
isCompressed = self.cfg_ana.isCompressed if hasattr(self.cfg_ana,'isCompressed') else 1
print 'Compression', isCompressed
self.file = TFile( fileName, 'recreate', '', isCompressed )
self.tree = Tree('tree', self.name)
self.file.cd()
if self.file.Get(self.treename) :
raise RuntimeError, "You are booking two Trees with the same name in the same file"
self.tree = Tree(self.treename, self.name)
self.tree.setDefaultFloatType(getattr(self.cfg_ana, 'defaultFloatType','D')); # or 'F'
self.declareVariables(setup)

Expand Down
36 changes: 36 additions & 0 deletions PhysicsTools/Heppy/python/analyzers/core/autovars.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def makeBranch(self,treeNumpy,isMC):
def fillBranch(self,treeNumpy,object,isMC):
if self.mcOnly and not isMC: return
treeNumpy.fill(self.name, self(object))
def __repr__(self):
return "<NTupleVariable[%s]>" % self.name

class NTupleObjectType:
def __init__(self,name,baseObjectTypes=[],mcOnly=[],variables=[]):
Expand Down Expand Up @@ -60,6 +62,8 @@ def allBases(self):
return ret
def removeVariable(self,name):
self.variables = [ v for v in self.variables if v.name != name]
def __repr__(self):
return "<NTupleObjectType[%s]>" % self.name

class NTupleObject:
def __init__(self, name, objectType, help="", mcOnly=False):
Expand All @@ -79,6 +83,8 @@ def fillBranches(self,treeNumpy,object,isMC):
allvars = self.objectType.allVars(isMC)
for v in allvars:
treeNumpy.fill("%s_%s" % (self.name, v.name), v(object))
def __repr__(self):
return "<NTupleObject[%s]>" % self.name


class NTupleCollection:
Expand Down Expand Up @@ -137,5 +143,35 @@ def fillBranchesVector(self,treeNumpy,collection,isMC):
for v in allvars:
name="%s_%s" % (self.name, v.name) if v.name != "" else self.name
treeNumpy.vfill(name, [ v(collection[i]) for i in xrange(num) ])
def __repr__(self):
return "<NTupleCollection[%s]>" % self.name

def get_cpp_declaration(self, isMC):
s = []
for v in self.objectType.allVars(isMC):
s += ["{0} {1}__{2}[{3}];".format(v.type.__name__, self.name, v.name, self.maxlen)]
return "\n".join(s)

def get_cpp_wrapper_class(self, isMC):
s = "class %s {\n" % self.name
s += "public:\n"
for v in self.objectType.allVars(isMC):
s += " {0} {1};\n".format(v.type.__name__, v.name)
s += "};\n"
return s

def get_py_wrapper_class(self, isMC):
s = "class %s:\n" % self.name
s += " def __init__(self, tree, n):\n"
for v in self.objectType.allVars(isMC):
if len(v.name)>0:
s += " self.{0} = tree.{1}_{2}[n];\n".format(v.name, self.name, v.name)
else:
s += " self.{0} = tree.{0}[n];\n".format(self.name)

s += " @staticmethod\n"
s += " def make_array(event):\n"
s += " return [{0}(event.input, i) for i in range(event.input.n{0})]\n".format(self.name)
return s


Loading