Go to the documentation of this file.00001 #include "HLTrigger/JetMET/interface/HLTJetCollectionsForLeptonPlusJets.h"
00002
00003 #include "FWCore/Framework/interface/MakerMacros.h"
00004
00005 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00006 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00007 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
00008 #include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
00009 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00010 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00011
00012 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00013
00014 #include "DataFormats/Common/interface/Handle.h"
00015
00016 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00017
00018 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00019 #include "DataFormats/Math/interface/deltaR.h"
00020
00021
00022
00023
00024 template <typename jetType>
00025 HLTJetCollectionsForLeptonPlusJets<jetType>::HLTJetCollectionsForLeptonPlusJets(const edm::ParameterSet& iConfig):
00026 hltLeptonTag(iConfig.getParameter< edm::InputTag > ("HltLeptonTag")),
00027 sourceJetTag(iConfig.getParameter< edm::InputTag > ("SourceJetTag")),
00028 minDeltaR_(iConfig.getParameter< double > ("minDeltaR"))
00029 {
00030 using namespace edm;
00031 using namespace std;
00032 typedef vector<RefVector<vector<jetType>,jetType,refhelper::FindUsingAdvance<vector<jetType>,jetType> > > JetCollectionVector;
00033 produces<JetCollectionVector> ();
00034 }
00035
00036 template <typename jetType>
00037 HLTJetCollectionsForLeptonPlusJets<jetType>::~HLTJetCollectionsForLeptonPlusJets()
00038 {
00039
00040
00041
00042 }
00043
00044 template <typename jetType>
00045 void
00046 HLTJetCollectionsForLeptonPlusJets<jetType>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00047 edm::ParameterSetDescription desc;
00048 desc.add<edm::InputTag> ("HltLeptonTag", edm::InputTag("triggerFilterObjectWithRefs"));
00049 desc.add<edm::InputTag> ("SourceJetTag", edm::InputTag("caloJetCollection"));
00050 desc.add<double> ("minDeltaR", 0.5);
00051 descriptions.add(std::string("hlt")+std::string(typeid(HLTJetCollectionsForLeptonPlusJets<jetType>).name()),desc);
00052 }
00053
00054
00055
00056
00057
00058
00059
00060
00061 template <typename jetType>
00062 void
00063 HLTJetCollectionsForLeptonPlusJets<jetType>::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00064 {
00065 using namespace edm;
00066 using namespace std;
00067
00068 typedef vector<RefVector<vector<jetType>,jetType,refhelper::FindUsingAdvance<vector<jetType>,jetType> > > JetCollectionVector;
00069 typedef vector<jetType> JetCollection;
00070 typedef edm::RefVector<JetCollection> JetRefVector;
00071 typedef edm::Ref<JetCollection> JetRef;
00072
00073 Handle<trigger::TriggerFilterObjectWithRefs> PrevFilterOutput;
00074 iEvent.getByLabel(hltLeptonTag,PrevFilterOutput);
00075
00076
00077 vector<Ref<reco::RecoEcalCandidateCollection> > clusCands;
00078 PrevFilterOutput->getObjects(trigger::TriggerCluster,clusCands);
00079
00080 vector<Ref<reco::ElectronCollection> > eleCands;
00081 PrevFilterOutput->getObjects(trigger::TriggerElectron,eleCands);
00082
00083 vector<reco::RecoChargedCandidateRef> muonCands;
00084 PrevFilterOutput->getObjects(trigger::TriggerMuon,muonCands);
00085
00086 Handle<JetCollection> theJetCollectionHandle;
00087 iEvent.getByLabel(sourceJetTag, theJetCollectionHandle);
00088
00089 const JetCollection & theJetCollection = *theJetCollectionHandle;
00090
00091 auto_ptr < JetCollectionVector > allSelections(new JetCollectionVector());
00092
00093 if(!clusCands.empty()){
00094 for(size_t candNr=0;candNr<clusCands.size();candNr++){
00095 JetRefVector refVector;
00096 for (unsigned int j = 0; j < theJetCollection.size(); j++) {
00097 if (deltaR(clusCands[candNr]->superCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
00098 }
00099 allSelections->push_back(refVector);
00100 }
00101 }
00102
00103 if(!eleCands.empty()){
00104 for(size_t candNr=0;candNr<eleCands.size();candNr++){
00105 JetRefVector refVector;
00106 for (unsigned int j = 0; j < theJetCollection.size(); j++) {
00107 if (deltaR(eleCands[candNr]->superCluster()->position(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
00108 }
00109 allSelections->push_back(refVector);
00110 }
00111 }
00112
00113 if(!muonCands.empty()){
00114 for(size_t candNr=0;candNr<muonCands.size();candNr++){
00115 JetRefVector refVector;
00116 for (unsigned int j = 0; j < theJetCollection.size(); j++) {
00117 if (deltaR(muonCands[candNr]->p4(),theJetCollection[j]) > minDeltaR_) refVector.push_back(JetRef(theJetCollectionHandle, j));
00118 }
00119 allSelections->push_back(refVector);
00120 }
00121 }
00122
00123
00124
00125
00126 iEvent.put(allSelections);
00127
00128 return;
00129
00130 }
00131