11 #include <boost/bind.hpp> 38 template <
class JetType,
class CandType>
70 template <
class JetType,
class CandType>
88 produces<std::vector<JetType> >(
"jets");
89 produces<JetMatchMap>();
92 template <
class JetType,
class CandType>
95 std::cout <<
"<RecoTauJetRegionProducer::produce (moduleLabel = " <<
moduleLabel_ <<
")>:" << 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;
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);
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) {
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;
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);
235 descriptions.
add(name, desc);
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::InputTag pfCandAssocMapSrc_
static void fillDescriptionsBase(edm::ConfigurationDescriptions &descriptions, const std::string &name)
edm::EDGetTokenT< JetToCandidateAssociation > pfCandAssocMap_token
const_iterator end() const
last iterator over the map (read only)
RecoTauGenericJetRegionProducer< reco::PFJet, reco::PFCandidate > RecoTauJetRegionProducer
bool getByToken(EDGetToken token, Handle< PROD > &result) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
RecoTauGenericJetRegionProducer< pat::Jet, pat::PackedCandidate > RecoTauPatJetRegionProducer
const_iterator find(const key_type &k) const
find element with specified reference key
void produce(edm::Event &evt, const edm::EventSetup &es) override
key_type key() const
Accessor for product key.
#define DEFINE_FWK_MODULE(type)
ProductID id() const
Accessor for product ID.
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< reco::CandidateView > Jets_token
bool get(ProductID const &oid, Handle< PROD > &result) const
ParameterDescriptionBase * add(U const &iLabel, T const &value)
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)
size_type size() const
Size of the RefVector.