Go to the documentation of this file.00001 #include "HLTrigger/JetMET/interface/HLTJetCollectionsForElePlusJets.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/JetReco/interface/CaloJetCollection.h"
00008 #include "DataFormats/JetReco/interface/PFJetCollection.h"
00009
00010 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00011
00012 #include "DataFormats/Common/interface/Handle.h"
00013
00014 #include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
00015
00016 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00017 #include "TVector3.h"
00018
00019 #include <string>
00020 #include <vector>
00021 #include <typeinfo>
00022
00023 template<typename T>
00024 HLTJetCollectionsForElePlusJets<T>::HLTJetCollectionsForElePlusJets(const edm::ParameterSet& iConfig):
00025 hltElectronTag(iConfig.getParameter< edm::InputTag > ("HltElectronTag")),
00026 sourceJetTag(iConfig.getParameter< edm::InputTag > ("SourceJetTag")),
00027
00028
00029
00030 minDeltaR_(iConfig.getParameter< double > ("minDeltaR"))
00031
00032
00033
00034 {
00035 typedef std::vector<edm::RefVector<std::vector<T>,T,edm::refhelper::FindUsingAdvance<std::vector<T>,T> > > TCollectionVector;
00036 produces<TCollectionVector> ();
00037 }
00038
00039
00040 template<typename T>
00041 HLTJetCollectionsForElePlusJets<T>::~HLTJetCollectionsForElePlusJets()
00042 {
00043
00044
00045
00046 }
00047
00048 template<typename T>
00049 void HLTJetCollectionsForElePlusJets<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
00050 edm::ParameterSetDescription desc;
00051 desc.add<edm::InputTag> ("HltElectronTag", edm::InputTag("triggerFilterObjectWithRefs"));
00052 desc.add<edm::InputTag> ("SourceJetTag", edm::InputTag("jetCollection"));
00053
00054
00055
00056 desc.add<double> ("minDeltaR", 0.5);
00057
00058
00059
00060 descriptions.add(std::string("hlt")+std::string(typeid(HLTJetCollectionsForElePlusJets<T>).name()),desc);
00061 }
00062
00063
00064
00065
00066
00067
00068
00069 template <typename T>
00070 void
00071 HLTJetCollectionsForElePlusJets<T>::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00072 {
00073 using namespace edm;
00074 using namespace std;
00075
00076 typedef vector<T> TCollection;
00077 typedef Ref<TCollection> TRef;
00078
00079 typedef edm::RefVector<TCollection> TRefVector;
00080
00081 typedef std::vector<edm::RefVector<std::vector<T>,T,edm::refhelper::FindUsingAdvance<std::vector<T>,T> > > TCollectionVector;
00082
00083 edm::Handle<trigger::TriggerFilterObjectWithRefs> PrevFilterOutput;
00084 iEvent.getByLabel(hltElectronTag,PrevFilterOutput);
00085
00086
00087 std::vector<edm::Ref<reco::RecoEcalCandidateCollection> > clusCands;
00088 PrevFilterOutput->getObjects(trigger::TriggerCluster,clusCands);
00089
00090 std::vector<edm::Ref<reco::ElectronCollection> > eleCands;
00091 PrevFilterOutput->getObjects(trigger::TriggerElectron,eleCands);
00092
00093
00094 std::vector<TVector3> ElePs;
00095
00096 if(!clusCands.empty()){
00097 for(size_t candNr=0;candNr<clusCands.size();candNr++){
00098 TVector3 positionVector(
00099 clusCands[candNr]->superCluster()->position().x(),
00100 clusCands[candNr]->superCluster()->position().y(),
00101 clusCands[candNr]->superCluster()->position().z());
00102 ElePs.push_back(positionVector);
00103 }
00104 }else if(!eleCands.empty()){
00105 for(size_t candNr=0;candNr<eleCands.size();candNr++){
00106 TVector3 positionVector(
00107 eleCands[candNr]->superCluster()->position().x(),
00108 eleCands[candNr]->superCluster()->position().y(),
00109 eleCands[candNr]->superCluster()->position().z());
00110 ElePs.push_back(positionVector);
00111 }
00112 }
00113
00114 edm::Handle<TCollection> theJetCollectionHandle;
00115 iEvent.getByLabel(sourceJetTag, theJetCollectionHandle);
00116
00117
00118 const TCollection & theJetCollection = *theJetCollectionHandle;
00119
00120
00121
00122 std::auto_ptr < TCollectionVector > allSelections(new TCollectionVector());
00123
00124
00125
00126 for (unsigned int i = 0; i < ElePs.size(); i++) {
00127
00128
00129
00130 TRefVector refVector;
00131
00132 for (unsigned int j = 0; j < theJetCollection.size(); j++) {
00133 TVector3 JetP(theJetCollection[j].px(), theJetCollection[j].py(), theJetCollection[j].pz());
00134 double DR = ElePs[i].DeltaR(JetP);
00135
00136 if (DR > minDeltaR_)
00137 refVector.push_back(TRef(theJetCollectionHandle, j));
00138 }
00139 allSelections->push_back(refVector);
00140 }
00141
00142
00143 iEvent.put(allSelections);
00144
00145 return;
00146
00147 }