Skip to content

Commit

Permalink
IVF and btag fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
arizzi committed Apr 14, 2014
1 parent 0cd76a1 commit 5ea3775
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
8 changes: 7 additions & 1 deletion PhysicsTools/PatAlgos/plugins/PATLostTracks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace pat {

private:
edm::EDGetTokenT<reco::PFCandidateCollection> Cands_;
edm::EDGetTokenT<edm::Association<pat::PackedCandidateCollection> > map_;
edm::EDGetTokenT<reco::TrackCollection> Tracks_;
edm::EDGetTokenT<reco::VertexCollection> Vertices_;
edm::EDGetTokenT<reco::VertexCollection> PV_;
Expand All @@ -46,6 +47,7 @@ namespace pat {

pat::PATLostTracks::PATLostTracks(const edm::ParameterSet& iConfig) :
Cands_(consumes<reco::PFCandidateCollection>(iConfig.getParameter<edm::InputTag>("inputCandidates"))),
map_(consumes<edm::Association<pat::PackedCandidateCollection> >(iConfig.getParameter<edm::InputTag>("packedPFCandidates"))),
Tracks_(consumes<reco::TrackCollection>(iConfig.getParameter<edm::InputTag>("inputTracks"))),
Vertices_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("secondaryVertices"))),
PV_(consumes<reco::VertexCollection>(iConfig.getParameter<edm::InputTag>("primaryVertices"))),
Expand All @@ -67,6 +69,9 @@ void pat::PATLostTracks::produce(edm::Event& iEvent, const edm::EventSetup& iSet
iEvent.getByToken( Cands_, cands );
std::vector<reco::Candidate>::const_iterator cand;

edm::Handle<edm::Association<pat::PackedCandidateCollection> > pf2pc;
iEvent.getByToken(map_,pf2pc);

edm::Handle<reco::TrackCollection> tracks;
iEvent.getByToken( Tracks_, tracks );

Expand All @@ -87,9 +92,10 @@ void pat::PATLostTracks::produce(edm::Event& iEvent, const edm::EventSetup& iSet

//Mark all tracks used in candidates
for(unsigned int ic=0, nc = cands->size(); ic < nc; ++ic) {
edm::Ref<reco::PFCandidateCollection> r(cands,ic);
const reco::PFCandidate &cand=(*cands)[ic];
if (cand.charge()) {
if(cand.trackRef().isNonnull() && cand.trackRef().id() ==tracks.id())
if(cand.trackRef().isNonnull() && cand.trackRef().id() ==tracks.id() && (*pf2pc)[r]->numberOfHits() > 0) // also check if packed candidates are storing the tracks for this one
{
used[cand.trackRef().key()]=1;
}
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/PatAlgos/plugins/PATSecondaryVertexSlimmer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void pat::PATSecondaryVertexSlimmer::produce(edm::Event& iEvent, const edm::Even

for(reco::Vertex::trackRef_iterator it=v.tracks_begin(); it != v.tracks_end(); it++) {
if(v.trackWeight(*it)>0.5) {
if((*pf2pc)[*it].isNonnull()) {
if((*pf2pc)[*it].isNonnull() && (*pf2pc)[*it]->numberOfHits() > 0) {
outPtr->back().addDaughter(reco::CandidatePtr(edm::refToPtr((*pf2pc)[*it]) ));
}
else {
Expand Down
2 changes: 1 addition & 1 deletion PhysicsTools/PatAlgos/plugins/TrackAndVertexUnpacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ void PATTrackAndVertexUnpacker::produce(edm::Event & iEvent, const edm::EventSet
unsigned int j=0;
for(unsigned int i=0;i<cands->size();i++) {
const pat::PackedCandidate & c = (*cands)[i];
if(c.charge() != 0 && c.pt() > 0.95){
if(c.charge() != 0 && c.numberOfHits()> 0){
outTks->push_back(c.pseudoTrack());
if(c.fromPV()==pat::PackedCandidate::PVUsedInFit)
{
Expand Down
1 change: 1 addition & 0 deletions PhysicsTools/PatAlgos/python/slimming/lostTracks_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

lostTracks = cms.EDProducer("PATLostTracks",
inputCandidates = cms.InputTag("particleFlow"),
packedPFCandidates = cms.InputTag("packedPFCandidates"),
inputTracks = cms.InputTag("generalTracks"),
secondaryVertices = cms.InputTag("inclusiveMergedVertices"),
primaryVertices = cms.InputTag("offlineSlimmedPrimaryVertices"),
Expand Down
14 changes: 11 additions & 3 deletions PhysicsTools/PatAlgos/python/tools/jetTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __init__(self):
self.addParameter(self._defaultParameters,'jetSource','', "Label of the input collection from which the new patJet collection should be created", cms.InputTag)
self.addParameter(self._defaultParameters,'trackSource',cms.InputTag('generalTracks'), "Label of the input collection for tracks to be used in b-tagging", cms.InputTag)
self.addParameter(self._defaultParameters,'pvSource',cms.InputTag('offlinePrimaryVertices'), "Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
self.addParameter(self._defaultParameters,'svSource',cms.InputTag('inclusiveMergedVertices'), "Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
self.addParameter(self._defaultParameters,'algo','', "Jet algorithm of the input collection from which the new patJet collection should be created")
self.addParameter(self._defaultParameters,'jetCorrections',None, "Add all relevant information about jet energy corrections that you want to be added to your new patJet \
collection. The format has to be given in a python tuple of type: (\'AK5Calo\',[\'L2Relative\', \'L3Absolute\'], patMet). Here the first argument corresponds to the payload \
Expand Down Expand Up @@ -62,7 +63,7 @@ def getDefaultParameters(self):
"""
return self._defaultParameters

def __call__(self,process,labelName=None,postfix=None,jetSource=None,trackSource=None,pvSource=None,algo=None,jetCorrections=None,btagDiscriminators=None,btagInfos=None,jetTrackAssociation=None,outputModules=None):
def __call__(self,process,labelName=None,postfix=None,jetSource=None,trackSource=None,svSource=None,pvSource=None,algo=None,jetCorrections=None,btagDiscriminators=None,btagInfos=None,jetTrackAssociation=None,outputModules=None):
"""
Function call wrapper. This will check the parameters and call the actual implementation that
can be found in toolCode via the base class function apply.
Expand All @@ -79,6 +80,9 @@ def __call__(self,process,labelName=None,postfix=None,jetSource=None,trackSource
if pvSource is None:
pvSource=self._defaultParameters['pvSource'].value
self.setParameter('pvSource', pvSource)
if svSource is None:
svSource=self._defaultParameters['svSource'].value
self.setParameter('svSource', svSource)
if trackSource is None:
trackSource=self._defaultParameters['trackSource'].value
self.setParameter('trackSource', trackSource)
Expand Down Expand Up @@ -113,6 +117,7 @@ def toolCode(self, process):
jetSource=self._parameters['jetSource'].value
trackSource=self._parameters['trackSource'].value
pvSource=self._parameters['pvSource'].value
svSource=self._parameters['svSource'].value
algo=self._parameters['algo'].value
jetCorrections=self._parameters['jetCorrections'].value
btagDiscriminators=list(self._parameters['btagDiscriminators'].value)
Expand Down Expand Up @@ -274,7 +279,7 @@ def toolCode(self, process):
if btagInfo == 'secondaryVertexTagInfos':
setattr(process, btagInfo+_labelName+postfix, btag.secondaryVertexTagInfos.clone(trackIPTagInfos = cms.InputTag('impactParameterTagInfos'+_labelName+postfix)))
if btagInfo == 'inclusiveSecondaryVertexFinderTagInfos':
setattr(process, btagInfo+_labelName+postfix, btag.inclusiveSecondaryVertexFinderTagInfos.clone(trackIPTagInfos = cms.InputTag('impactParameterTagInfos'+_labelName+postfix)))
setattr(process, btagInfo+_labelName+postfix, btag.inclusiveSecondaryVertexFinderTagInfos.clone(trackIPTagInfos = cms.InputTag('impactParameterTagInfos'+_labelName+postfix), extSVCollection=svSource))
if btagInfo == 'inclusiveSecondaryVertexFinderFilteredTagInfos':
setattr(process, btagInfo+_labelName+postfix, btag.inclusiveSecondaryVertexFinderFilteredTagInfos.clone(trackIPTagInfos = cms.InputTag('impactParameterTagInfos'+_labelName+postfix)))
if btagInfo == 'secondaryVertexNegativeTagInfos':
Expand Down Expand Up @@ -465,6 +470,7 @@ def __init__(self):
self.addParameter(self._defaultParameters,'jetSource','', "Label of the input collection from which the new patJet collection should be created", cms.InputTag)
self.addParameter(self._defaultParameters,'trackSource',cms.InputTag('generalTracks'), "Label of the input collection for tracks to be used in b-tagging", cms.InputTag)
self.addParameter(self._defaultParameters,'pvSource',cms.InputTag('offlinePrimaryVertices'), "Label of the input collection for primary vertices used in b-tagging", cms.InputTag)
self.addParameter(self._defaultParameters,'svSource',cms.InputTag('inclusiveMergedVertices'), "Label of the input collection for IVF vertices used in b-tagging", cms.InputTag)
self.addParameter(self._defaultParameters,'algo','', "Jet algorithm of the input collection from which the new patJet collection should be created")
self.addParameter(self._defaultParameters,'postfix','', "postfix from usePF2PAT")
self.addParameter(self._defaultParameters,'jetCorrections',None, "Add all relevant information about jet energy corrections that you want to be added to your new patJet \
Expand Down Expand Up @@ -536,8 +542,9 @@ def toolCode(self, process):
"""
## initialize parameters
jetSource=self._parameters['jetSource'].value
pvSource=self._parameters['pvSource'].value
trackSource=self._parameters['trackSource'].value
pvSource=self._parameters['pvSource'].value
svSource=self._parameters['svSource'].value
postfix=self._parameters['postfix'].value
algo=self._parameters['algo'].value
jetCorrections=self._parameters['jetCorrections'].value
Expand All @@ -554,6 +561,7 @@ def toolCode(self, process):
jetSource=jetSource,
trackSource=trackSource,
pvSource=pvSource,
svSource=svSource,
algo=algo,
jetCorrections=jetCorrections,
btagDiscriminators=btagDiscriminators,
Expand Down

0 comments on commit 5ea3775

Please sign in to comment.