21 template <
typename jetType>
24 : hltLeptonTag(iConfig.getParameter<
edm::
InputTag>(
"HltLeptonTag")),
25 sourceJetTag(iConfig.getParameter<
edm::
InputTag>(
"SourceJetTag")),
26 minDeltaR_(iConfig.getParameter<double>(
"minDeltaR")) {
36 produces<JetCollectionVector>();
37 produces<JetCollection>();
40 template <
typename jetType>
46 template <
typename jetType>
53 desc.add<
double>(
"minDeltaR", 0.5);
63 template <
typename jetType>
81 vector<reco::RecoChargedCandidateRef> muonCands;
84 vector<Ref<reco::ElectronCollection>> eleCands;
90 vector<Ref<reco::RecoEcalCandidateCollection>> clusCands;
96 typename JetCollection::const_iterator
jet;
99 unique_ptr<JetCollectionVector> product(
new JetCollectionVector);
101 std::vector<size_t> usedCands;
103 if (!muonCands.empty()) {
104 for (
jet = theJetCollectionHandle->begin();
jet != theJetCollectionHandle->end();
jet++) {
107 for (
size_t candNr = 0; candNr < muonCands.size(); candNr++) {
108 if (
std::find(usedCands.begin(), usedCands.end(), candNr) != usedCands.end())
111 std::vector<edm::Ptr<reco::PFCandidate>> pfConstituents = cleanedJet.getPFConstituents();
113 i_candidate != pfConstituents.end();
115 if (
deltaR((*muonCands[candNr]), (**i_candidate)) < 0.001) {
116 cleanedJet.setP4(cleanedJet.p4() - muonCands[candNr]->p4());
117 usedCands.push_back(candNr);
123 allSelections->push_back(cleanedJet);
127 if (!eleCands.empty()) {
128 for (
jet = theJetCollectionHandle->begin();
jet != theJetCollectionHandle->end();
jet++) {
131 for (
size_t candNr = 0; candNr < eleCands.size(); candNr++) {
132 if (
std::find(usedCands.begin(), usedCands.end(), candNr) != usedCands.end())
135 std::vector<edm::Ptr<reco::PFCandidate>> pfConstituents = cleanedJet.getPFConstituents();
137 i_candidate != pfConstituents.end();
139 if (
deltaR((*eleCands[candNr]), (**i_candidate)) < 0.001) {
140 cleanedJet.setP4(cleanedJet.p4() - eleCands[candNr]->p4());
141 usedCands.push_back(candNr);
147 allSelections->push_back(cleanedJet);
151 if (!photonCands.empty()) {
152 for (
jet = theJetCollectionHandle->begin();
jet != theJetCollectionHandle->end();
jet++) {
155 for (
size_t candNr = 0; candNr < photonCands.size(); candNr++) {
156 if (
std::find(usedCands.begin(), usedCands.end(), candNr) != usedCands.end())
159 std::vector<edm::Ptr<reco::PFCandidate>> pfConstituents = cleanedJet.getPFConstituents();
161 i_candidate != pfConstituents.end();
163 if (
deltaR((*photonCands[candNr]), (**i_candidate)) < 0.001) {
164 cleanedJet.setP4(cleanedJet.p4() - photonCands[candNr]->p4());
165 usedCands.push_back(candNr);
171 allSelections->push_back(cleanedJet);
175 if (!clusCands.empty()) {
176 for (
jet = theJetCollectionHandle->begin();
jet != theJetCollectionHandle->end();
jet++) {
179 for (
size_t candNr = 0; candNr < clusCands.size(); candNr++) {
180 if (
std::find(usedCands.begin(), usedCands.end(), candNr) != usedCands.end())
183 std::vector<edm::Ptr<reco::PFCandidate>> pfConstituents = cleanedJet.getPFConstituents();
185 i_candidate != pfConstituents.end();
187 if (
deltaR((*clusCands[candNr]), (**i_candidate)) < 0.001) {
188 cleanedJet.setP4(cleanedJet.p4() - clusCands[candNr]->p4());
189 usedCands.push_back(candNr);
195 allSelections->push_back(cleanedJet);
201 std::sort(allSelections->begin(), allSelections->end(), compJets);
208 for (
unsigned iJet = 0; iJet <
jets.size(); ++iJet) {
209 cleanedJetRefs.push_back(
JetRef(cleanedJetHandle, iJet));
212 product->emplace_back(cleanedJetRefs);