36 template <
class JetType,
class CandType>
68 template <
class JetType,
class CandType>
70 : moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")) {
79 double deltaR =
cfg.getParameter<
double>(
"deltaR");
86 produces<std::vector<JetType> >(
"jets");
87 produces<JetMatchMap>();
90 template <
class JetType,
class CandType>
93 std::cout <<
"<RecoTauJetRegionProducer::produce (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
94 std::cout <<
" inputJets = " << inputJets_ << std::endl;
95 std::cout <<
" pfCandSrc = " << pfCandSrc_ << std::endl;
96 std::cout <<
" pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl;
104 std::vector<CandPtr> pfCands;
105 pfCands.reserve(pfCandsHandle->size());
106 for (
size_t icand = 0; icand < pfCandsHandle->size(); ++icand) {
107 pfCands.push_back(CandPtr(pfCandsHandle, icand));
115 size_t nJets =
jets.size();
120 std::vector<std::unordered_set<unsigned> > fastJetToPFCandMap;
121 if (!pfCandAssocMapSrc_.label().empty()) {
122 evt.
getByToken(pfCandAssocMap_token, jetToPFCandMap);
123 fastJetToPFCandMap.resize(nJets);
124 for (
size_t ijet = 0; ijet < nJets; ++ijet) {
127 const auto& pfCandsMappedToJet = (*jetToPFCandMap)[jetRef];
128 for (
const auto& pfCandMappedToJet : pfCandsMappedToJet) {
129 fastJetToPFCandMap[ijet].emplace(pfCandMappedToJet.key());
138 size_t nOriginalJets = 0;
143 evt.
get(originalId, originalJets);
145 edm::LogError(
"MissingOriginalCollection") <<
"Can't get the original jets that made: " << inputJets_
146 <<
" that have product ID: " << originalId <<
" from the event!!";
149 nOriginalJets = originalJets->size();
152 auto newJets = std::make_unique<std::vector<JetType> >();
156 std::vector<int> matchInfo(nOriginalJets, -1);
157 newJets->reserve(nJets);
159 for (
size_t ijet = 0; ijet < nJets; ++ijet) {
162 if (jetRef->pt() - minJetPt_ < 1
e-5)
164 if (
std::abs(jetRef->eta()) - maxJetAbsEta_ > -1
e-5)
167 newJets->emplace_back(*jetRef);
168 JetType& newJet = newJets->back();
170 newJet.clearDaughters();
172 for (
const auto& pfCand : pfCands) {
173 bool isMappedToJet =
false;
174 if (jetToPFCandMap.
isValid()) {
175 auto temp = jetToPFCandMap->find(jetRef);
176 if (
temp == jetToPFCandMap->end()) {
177 edm::LogWarning(
"WeirdCandidateMap") <<
"Candidate map for jet " << jetRef.
key() <<
" is empty!";
180 isMappedToJet = fastJetToPFCandMap[ijet].count(pfCand.key());
182 isMappedToJet =
true;
184 if (
reco::deltaR2(*jetRef, *pfCand) < deltaR2_ && isMappedToJet)
185 newJet.addDaughter(pfCand);
188 std::cout <<
"jet #" << ijet <<
": Pt = " << jetRef->pt() <<
", eta = " << jetRef->eta()
189 <<
", phi = " << jetRef->eta() <<
","
190 <<
" mass = " << jetRef->mass() <<
", area = " << jetRef->jetArea() << std::endl;
191 auto jetConstituents = newJet.daughterPtrVector();
193 for (
const auto& jetConstituent : jetConstituents) {
194 std::cout <<
" constituent #" <<
idx <<
": Pt = " << jetConstituent->pt() <<
", eta = " << jetConstituent->eta()
195 <<
", phi = " << jetConstituent->phi() << std::endl;
202 matchInfo[jetRef.
key()] = nNewJets;
211 ? std::make_unique<JetMatchMap>(
213 : std::make_unique<JetMatchMap>();
214 for (
size_t ijet = 0; ijet < nJets; ++ijet) {
221 template <
class JetType,
class CandType>
227 desc.add<
double>(
"deltaR", 0.8);
229 desc.add<
int>(
"verbosity", 0);
230 desc.add<
double>(
"maxJetAbsEta", 2.5);
231 desc.add<
double>(
"minJetPt", 14.0);