35 template <
class JetType,
class CandType>
67 template <
class JetType,
class CandType>
69 : moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")) {
78 double deltaR =
cfg.getParameter<
double>(
"deltaR");
85 produces<std::vector<JetType> >(
"jets");
86 produces<JetMatchMap>();
89 template <
class JetType,
class CandType>
92 std::cout <<
"<RecoTauJetRegionProducer::produce (moduleLabel = " << moduleLabel_ <<
")>:" << std::endl;
93 std::cout <<
" inputJets = " << inputJets_ << std::endl;
94 std::cout <<
" pfCandSrc = " << pfCandSrc_ << std::endl;
95 std::cout <<
" pfCandAssocMapSrc_ = " << pfCandAssocMapSrc_ << std::endl;
103 std::vector<CandPtr> pfCands;
104 pfCands.reserve(pfCandsHandle->size());
105 for (
size_t icand = 0; icand < pfCandsHandle->size(); ++icand) {
106 pfCands.push_back(CandPtr(pfCandsHandle, icand));
119 std::vector<std::unordered_set<unsigned> > fastJetToPFCandMap;
120 if (!pfCandAssocMapSrc_.label().empty()) {
121 evt.
getByToken(pfCandAssocMap_token, jetToPFCandMap);
122 fastJetToPFCandMap.resize(
nJets);
123 for (
size_t ijet = 0; ijet <
nJets; ++ijet) {
126 const auto& pfCandsMappedToJet = (*jetToPFCandMap)[jetRef];
127 for (
const auto& pfCandMappedToJet : pfCandsMappedToJet) {
128 fastJetToPFCandMap[ijet].emplace(pfCandMappedToJet.key());
137 size_t nOriginalJets = 0;
142 evt.
get(originalId, originalJets);
144 edm::LogError(
"MissingOriginalCollection") <<
"Can't get the original jets that made: " << inputJets_
145 <<
" that have product ID: " << originalId <<
" from the event!!";
148 nOriginalJets = originalJets->size();
151 auto newJets = std::make_unique<std::vector<JetType> >();
155 std::vector<int> matchInfo(nOriginalJets, -1);
156 newJets->reserve(
nJets);
158 for (
size_t ijet = 0; ijet <
nJets; ++ijet) {
161 if (jetRef->pt() - minJetPt_ < 1
e-5)
163 if (
std::abs(jetRef->eta()) - maxJetAbsEta_ > -1
e-5)
166 newJets->emplace_back(*jetRef);
167 JetType& newJet = newJets->back();
169 newJet.clearDaughters();
171 for (
const auto& pfCand : pfCands) {
172 bool isMappedToJet =
false;
173 if (jetToPFCandMap.
isValid()) {
174 auto temp = jetToPFCandMap->find(jetRef);
175 if (
temp == jetToPFCandMap->end()) {
176 edm::LogWarning(
"WeirdCandidateMap") <<
"Candidate map for jet " << jetRef.
key() <<
" is empty!";
179 isMappedToJet = fastJetToPFCandMap[ijet].count(pfCand.key());
181 isMappedToJet =
true;
183 if (
reco::deltaR2(*jetRef, *pfCand) < deltaR2_ && isMappedToJet)
184 newJet.addDaughter(pfCand);
187 std::cout <<
"jet #" << ijet <<
": Pt = " << jetRef->pt() <<
", eta = " << jetRef->eta()
188 <<
", phi = " << jetRef->eta() <<
"," 189 <<
" mass = " << jetRef->mass() <<
", area = " << jetRef->jetArea() << std::endl;
190 auto jetConstituents = newJet.daughterPtrVector();
192 for (
const auto& jetConstituent : jetConstituents) {
193 std::cout <<
" constituent #" <<
idx <<
": Pt = " << jetConstituent->pt() <<
", eta = " << jetConstituent->eta()
194 <<
", phi = " << jetConstituent->phi() << std::endl;
201 matchInfo[jetRef.
key()] = nNewJets;
209 auto matching = (
nJets != 0)
210 ? std::make_unique<JetMatchMap>(
212 : std::make_unique<JetMatchMap>();
213 for (
size_t ijet = 0; ijet <
nJets; ++ijet) {
220 template <
class JetType,
class CandType>
226 desc.add<
double>(
"deltaR", 0.8);
228 desc.add<
int>(
"verbosity", 0);
229 desc.add<
double>(
"maxJetAbsEta", 2.5);
230 desc.add<
double>(
"minJetPt", 14.0);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::InputTag pfCandAssocMapSrc_
bool get(ProductID const &oid, Handle< PROD > &result) const
static void fillDescriptionsBase(edm::ConfigurationDescriptions &descriptions, const std::string &name)
edm::EDGetTokenT< JetToCandidateAssociation > pfCandAssocMap_token
RecoTauGenericJetRegionProducer< reco::PFJet, reco::PFCandidate > RecoTauJetRegionProducer
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
RecoTauGenericJetRegionProducer< pat::Jet, pat::PackedCandidate > RecoTauPatJetRegionProducer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void produce(edm::Event &evt, const edm::EventSetup &es) override
Log< level::Error, false > LogError
static constexpr int nJets
key_type key() const
Accessor for product key.
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< reco::CandidateView > Jets_token
#define DEFINE_FWK_MODULE(type)
edm::AssociationMap< edm::OneToMany< std::vector< JetType >, std::vector< CandType >, unsigned int > > JetToCandidateAssociation
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
~RecoTauGenericJetRegionProducer() override
edm::AssociationMap< edm::OneToOne< reco::JetView, reco::JetView > > JetMatchMap
void add(std::string const &label, ParameterSetDescription const &psetDescription)
RecoTauGenericJetRegionProducer(const edm::ParameterSet &pset)
edm::EDGetTokenT< std::vector< CandType > > pf_token
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
Log< level::Warning, false > LogWarning