11 #include <boost/bind.hpp>
38 template <
class JetType,
class CandType>
70 template <
class JetType,
class CandType>
72 : moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")) {
81 double deltaR =
cfg.getParameter<
double>(
"deltaR");
88 produces<std::vector<JetType> >(
"jets");
89 produces<JetMatchMap>();
92 template <
class JetType,
class CandType>
95 std::cout <<
"<RecoTauJetRegionProducer::produce (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
96 std::cout <<
" inputJets = " << inputJets_ << std::endl;
97 std::cout <<
" pfCandSrc = " << pfCandSrc_ << std::endl;
98 std::cout <<
" pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl;
106 std::vector<CandPtr> pfCands;
107 pfCands.reserve(pfCandsHandle->size());
108 for (
size_t icand = 0; icand < pfCandsHandle->size(); ++icand) {
109 pfCands.push_back(CandPtr(pfCandsHandle, icand));
117 size_t nJets =
jets.size();
122 std::vector<std::unordered_set<unsigned> > fastJetToPFCandMap;
123 if (!pfCandAssocMapSrc_.label().empty()) {
124 evt.
getByToken(pfCandAssocMap_token, jetToPFCandMap);
125 fastJetToPFCandMap.resize(nJets);
126 for (
size_t ijet = 0; ijet < nJets; ++ijet) {
129 const auto& pfCandsMappedToJet = (*jetToPFCandMap)[jetRef];
130 for (
const auto& pfCandMappedToJet : pfCandsMappedToJet) {
131 fastJetToPFCandMap[ijet].emplace(pfCandMappedToJet.key());
140 size_t nOriginalJets = 0;
145 evt.
get(originalId, originalJets);
147 edm::LogError(
"MissingOriginalCollection") <<
"Can't get the original jets that made: " << inputJets_
148 <<
" that have product ID: " << originalId <<
" from the event!!";
151 nOriginalJets = originalJets->size();
154 auto newJets = std::make_unique<std::vector<JetType> >();
158 std::vector<int> matchInfo(nOriginalJets, -1);
159 newJets->reserve(nJets);
161 for (
size_t ijet = 0; ijet < nJets; ++ijet) {
164 if (jetRef->pt() - minJetPt_ < 1
e-5)
166 if (
std::abs(jetRef->eta()) - maxJetAbsEta_ > -1
e-5)
169 newJets->emplace_back(*jetRef);
170 JetType& newJet = newJets->back();
172 newJet.clearDaughters();
174 for (
const auto& pfCand : pfCands) {
175 bool isMappedToJet =
false;
176 if (jetToPFCandMap.
isValid()) {
177 auto temp = jetToPFCandMap->find(jetRef);
178 if (
temp == jetToPFCandMap->end()) {
179 edm::LogWarning(
"WeirdCandidateMap") <<
"Candidate map for jet " << jetRef.
key() <<
" is empty!";
182 isMappedToJet = fastJetToPFCandMap[ijet].count(pfCand.key());
184 isMappedToJet =
true;
186 if (
reco::deltaR2(*jetRef, *pfCand) < deltaR2_ && isMappedToJet)
187 newJet.addDaughter(pfCand);
190 std::cout <<
"jet #" << ijet <<
": Pt = " << jetRef->pt() <<
", eta = " << jetRef->eta()
191 <<
", phi = " << jetRef->eta() <<
","
192 <<
" mass = " << jetRef->mass() <<
", area = " << jetRef->jetArea() << std::endl;
193 auto jetConstituents = newJet.daughterPtrVector();
195 for (
const auto& jetConstituent : jetConstituents) {
196 std::cout <<
" constituent #" <<
idx <<
": Pt = " << jetConstituent->pt() <<
", eta = " << jetConstituent->eta()
197 <<
", phi = " << jetConstituent->phi() << std::endl;
204 matchInfo[jetRef.
key()] = nNewJets;
213 ? std::make_unique<JetMatchMap>(
215 : std::make_unique<JetMatchMap>();
216 for (
size_t ijet = 0; ijet < nJets; ++ijet) {
223 template <
class JetType,
class CandType>
229 desc.
add<
double>(
"deltaR", 0.8);
231 desc.
add<
int>(
"verbosity", 0);
232 desc.
add<
double>(
"maxJetAbsEta", 2.5);
233 desc.
add<
double>(
"minJetPt", 14.0);