diff --git a/HLTrigger/JetMET/interface/HLTJetCollectionsForBoostedLeptonPlusJets.h b/HLTrigger/JetMET/interface/HLTJetCollectionsForBoostedLeptonPlusJets.h index d48b866e5b7b5..7af67a3179a81 100644 --- a/HLTrigger/JetMET/interface/HLTJetCollectionsForBoostedLeptonPlusJets.h +++ b/HLTrigger/JetMET/interface/HLTJetCollectionsForBoostedLeptonPlusJets.h @@ -51,7 +51,7 @@ template class HLTJetCollectionsForBoostedLeptonPlusJets: pub edm::InputTag hltLeptonTag; edm::InputTag sourceJetTag; - double minDeltaR_; //min dR for jets and leptons not to match + double minDeltaR_; //min dR to consider cleaning // ----------member data --------------------------- }; diff --git a/HLTrigger/JetMET/src/HLTJetCollectionsForBoostedLeptonPlusJets.cc b/HLTrigger/JetMET/src/HLTJetCollectionsForBoostedLeptonPlusJets.cc index e795e18006fb3..a4878156bd2a3 100644 --- a/HLTrigger/JetMET/src/HLTJetCollectionsForBoostedLeptonPlusJets.cc +++ b/HLTrigger/JetMET/src/HLTJetCollectionsForBoostedLeptonPlusJets.cc @@ -12,11 +12,11 @@ #include "DataFormats/Common/interface/Handle.h" #include "DataFormats/EgammaReco/interface/SuperCluster.h" #include "DataFormats/Math/interface/deltaR.h" -#include "DataFormats/Math/interface/LorentzVector.h" #include "DataFormats/JetReco/interface/PFJet.h" #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h" #include "HLTrigger/JetMET/interface/HLTJetCollectionsForBoostedLeptonPlusJets.h" #include "HLTrigger/HLTcore/interface/defaultModuleLabel.h" +#include "CommonTools/Utils/interface/PtComparator.h" @@ -29,10 +29,12 @@ HLTJetCollectionsForBoostedLeptonPlusJets::HLTJetCollectionsForBoostedL { using namespace edm; using namespace std; - typedef vector,jetType,refhelper::FindUsingAdvance,jetType> > > JetCollectionVector; + + typedef vector JetCollection; + m_theLeptonToken = consumes(hltLeptonTag); m_theJetToken = consumes>(sourceJetTag); - produces (); + produces(); } template @@ -46,13 +48,13 @@ HLTJetCollectionsForBoostedLeptonPlusJets::~HLTJetCollectionsForBoosted template void HLTJetCollectionsForBoostedLeptonPlusJets::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { - edm::ParameterSetDescription desc; - desc.add ("HltLeptonTag", edm::InputTag("triggerFilterObjectWithRefs")); - //(2) - desc.add ("SourceJetTag", edm::InputTag("jetCollection")); - //(2) - desc.add ("minDeltaR", 0.5); - descriptions.add(defaultModuleLabel>(), desc); + edm::ParameterSetDescription desc; + desc.add ("HltLeptonTag", edm::InputTag("triggerFilterObjectWithRefs")); + //(2) + desc.add ("SourceJetTag", edm::InputTag("jetCollection")); + //(2) + desc.add ("minDeltaR", 0.5); + descriptions.add(defaultModuleLabel>(), desc); } // @@ -71,22 +73,15 @@ HLTJetCollectionsForBoostedLeptonPlusJets::produce(edm::Event& iEvent, //(3) using namespace reco; //(3) - - typedef vector,jetType,refhelper::FindUsingAdvance,jetType> > > JetCollectionVector; typedef vector JetCollection; - typedef edm::RefVector JetRefVector; - typedef edm::Ref JetRef; - //(4) - typedef math::XYZTLorentzVector LorentzVector; - //(4) Handle PrevFilterOutput; iEvent.getByToken(m_theLeptonToken,PrevFilterOutput); //its easier on the if statement flow if I try everything at once, shouldnt add to timing // Electrons can be stored as objects of types TriggerCluster, TriggerElectron, or TriggerPhoton - vector > clusCands; - PrevFilterOutput->getObjects(trigger::TriggerCluster,clusCands); + vector muonCands; + PrevFilterOutput->getObjects(trigger::TriggerMuon,muonCands); vector > eleCands; PrevFilterOutput->getObjects(trigger::TriggerElectron,eleCands); @@ -94,119 +89,121 @@ HLTJetCollectionsForBoostedLeptonPlusJets::produce(edm::Event& iEvent, trigger::VRphoton photonCands; PrevFilterOutput->getObjects(trigger::TriggerPhoton, photonCands); - vector muonCands; - PrevFilterOutput->getObjects(trigger::TriggerMuon,muonCands); + vector > clusCands; + PrevFilterOutput->getObjects(trigger::TriggerCluster,clusCands); Handle theJetCollectionHandle; iEvent.getByToken(m_theJetToken, theJetCollectionHandle); const JetCollection & theJetCollection = *theJetCollectionHandle; + typename JetCollection::const_iterator jet; - auto_ptr < JetCollectionVector > allSelections(new JetCollectionVector()); - - if(!clusCands.empty()){ // try trigger clusters - for(size_t candNr=0;candNrsuperCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j)); - else{ - unsigned int w =0 ; - std::vector pfConstituents = theJetCollection[j].getPFConstituents(); - for(std::vector::const_iterator i_candidate = pfConstituents.begin(); i_candidate != pfConstituents.end(); ++i_candidate){ - TVector3 ClusP(clusCands[candNr]->p4().Px(),clusCands[candNr]->p4().Py(), clusCands[candNr]->p4().Pz()); - TVector3 PFJetConstP((*i_candidate)->px(),(*i_candidate)->py(),(*i_candidate)->pz()); - double deltaRPFConste = ClusP.DeltaR(PFJetConstP); - if(deltaRPFConste < 0.001 && w==0){ - const_cast(theJetCollection[j].p4()) = theJetCollection[j].p4() - clusCands[candNr]->p4(); - w ++; - } //if + auto_ptr < JetCollection > allSelections(new JetCollection); + + std::vector usedCands; + + std::cout<<"----------------NEW EVENT----------------\n"; + if(!muonCands.empty()){ // muons + for (jet = theJetCollectionHandle->begin(); jet != theJetCollectionHandle->end(); jet++) { + //const jetType* referenceJet = &*jet; + jetType cleanedJet = *jet; //copy original jet + if (cleanedJet.pt()>30) std::cout<<"Jet: pt = "<p4()); + usedCands.push_back(candNr); + break; + }//if constituent matched }//for constituents - refVector.push_back(JetRef(theJetCollectionHandle, j)); - }//else - } - allSelections->push_back(refVector); - } - } - - if(!eleCands.empty()){ // try electrons - for(size_t candNr=0;candNrsuperCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j)); - else{ - unsigned int w =0 ; - std::vector pfConstituents = theJetCollection[j].getPFConstituents(); - for(std::vector::const_iterator i_candidate = pfConstituents.begin(); i_candidate != pfConstituents.end(); ++i_candidate){ - TVector3 ElectronP(eleCands[candNr]->p4().Px(),eleCands[candNr]->p4().Py(), eleCands[candNr]->p4().Pz()); - TVector3 PFJetConstP((*i_candidate)->px(),(*i_candidate)->py(),(*i_candidate)->pz()); - double deltaRPFConste = ElectronP.DeltaR(PFJetConstP); - if(deltaRPFConste < 0.001 && w==0){ - const_cast(theJetCollection[j].p4()) = theJetCollection[j].p4() - eleCands[candNr]->p4(); - w ++; - } //if + }//if dRpush_back(cleanedJet); + }//for jets + }//if cands + + if(!eleCands.empty()){ // electrons + for (jet = theJetCollectionHandle->begin(); jet != theJetCollectionHandle->end(); jet++) { + //const jetType* referenceJet = &*jet; + jetType cleanedJet = *jet; //copy original jet + if (cleanedJet.pt()>30) std::cout<<"Jet: pt = "<p4()); + usedCands.push_back(candNr); + break; + }//if constituent matched }//for constituents - refVector.push_back(JetRef(theJetCollectionHandle, j)); - }//else - }//for jet collection - - allSelections->push_back(refVector); - } - } - - if(!photonCands.empty()){ // try photons - for(size_t candNr=0;candNrsuperCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j)); - else{ - unsigned int w =0 ; - std::vector pfConstituents = theJetCollection[j].getPFConstituents(); - for(std::vector::const_iterator i_candidate = pfConstituents.begin(); i_candidate != pfConstituents.end(); ++i_candidate){ - TVector3 PhotonP(photonCands[candNr]->p4().Px(),photonCands[candNr]->p4().Py(), photonCands[candNr]->p4().Pz()); - TVector3 PFJetConstP((*i_candidate)->px(),(*i_candidate)->py(),(*i_candidate)->pz()); - double deltaRPFConste = PhotonP.DeltaR(PFJetConstP); - if(deltaRPFConste < 0.001 && w==0){ - const_cast(theJetCollection[j].p4()) = theJetCollection[j].p4() - photonCands[candNr]->p4(); - w ++; - } //if + }//if dRpush_back(cleanedJet); + }//for jets + }//if cands + + if(!photonCands.empty()){ // photons + for (jet = theJetCollectionHandle->begin(); jet != theJetCollectionHandle->end(); jet++) { + //const jetType* referenceJet = &*jet; + jetType cleanedJet = *jet; //copy original jet + if (cleanedJet.pt()>30) std::cout<<"Jet: pt = "<p4()); + usedCands.push_back(candNr); + break; + }//if constituent matched }//for constituents - refVector.push_back(JetRef(theJetCollectionHandle, j)); - }//else - }//for jet collection - allSelections->push_back(refVector); - } - } - - if(!muonCands.empty()){ // muons - for(size_t candNr=0;candNrp4(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j)); - else{ - unsigned int w =0 ; - std::vector pfConstituents = theJetCollection[j].getPFConstituents(); - for(std::vector::const_iterator i_candidate = pfConstituents.begin(); i_candidate != pfConstituents.end(); ++i_candidate){ - TVector3 MuP(muonCands[candNr]->p4().Px(),muonCands[candNr]->p4().Py(), muonCands[candNr]->p4().Pz()); - TVector3 PFJetConstP((*i_candidate)->px(),(*i_candidate)->py(),(*i_candidate)->pz()); - double deltaRPFConste = MuP.DeltaR(PFJetConstP); - if(deltaRPFConste < 0.001 && w==0){ - const_cast(theJetCollection[j].p4()) = theJetCollection[j].p4() - muonCands[candNr]->p4(); - w ++; - } //if + }//if dRpush_back(cleanedJet); + }//for jets + }//if cands + + if(!clusCands.empty()){ // trigger clusters + for (jet = theJetCollectionHandle->begin(); jet != theJetCollectionHandle->end(); jet++) { + //const jetType* referenceJet = &*jet; + jetType cleanedJet = *jet; //copy original jet + if (cleanedJet.pt()>30) std::cout<<"Jet: pt = "<p4()); + usedCands.push_back(candNr); + break; + }//if constituent matched }//for constituents - refVector.push_back(JetRef(theJetCollectionHandle, j)); - }//else - } - allSelections->push_back(refVector); - } - } - - - - - iEvent.put(allSelections); + }//if dRpush_back(cleanedJet); + }//for jets + }//if cands + + NumericSafeGreaterByPt compJets; + // reorder cleaned jets + std::sort (allSelections->begin(), allSelections->end(), compJets); + iEvent.put(allSelections); return; } -