11 #include <boost/bind.hpp> 38 template<
class JetType,
class CandType>
70 template<
class JetType,
class CandType>
89 produces<std::vector<JetType> >(
"jets");
90 produces<JetMatchMap>();
93 template<
class JetType,
class CandType>
97 std::cout <<
"<RecoTauJetRegionProducer::produce (moduleLabel = " <<
moduleLabel_ <<
")>:" << std::endl;
108 std::vector<CandPtr> pfCands;
109 pfCands.reserve(pfCandsHandle->size());
110 for (
size_t icand = 0; icand < pfCandsHandle->size(); ++icand ) {
111 pfCands.push_back(CandPtr(pfCandsHandle, icand));
119 size_t nJets = jets.
size();
124 std::vector<std::unordered_set<unsigned> > fastJetToPFCandMap;
127 fastJetToPFCandMap.resize(nJets);
128 for (
size_t ijet = 0; ijet < nJets; ++ijet ) {
131 const auto& pfCandsMappedToJet = (*jetToPFCandMap)[jetRef];
132 for (
const auto& pfCandMappedToJet : pfCandsMappedToJet ) {
133 fastJetToPFCandMap[ijet].emplace(pfCandMappedToJet.key());
142 size_t nOriginalJets = 0;
147 evt.
get(originalId, originalJets);
150 <<
"Can't get the original jets that made: " <<
inputJets_ 151 <<
" that have product ID: " << originalId
152 <<
" from the event!!";
155 nOriginalJets = originalJets->size();
158 auto newJets = std::make_unique<std::vector<JetType> >();
162 std::vector<int> matchInfo(nOriginalJets, -1);
163 newJets->reserve(nJets);
165 for (
size_t ijet = 0; ijet < nJets; ++ijet ) {
171 newJets->emplace_back(*jetRef);
172 JetType& newJet = newJets->back();
174 newJet.clearDaughters();
176 for (
const auto& pfCand : pfCands ) {
177 bool isMappedToJet =
false;
178 if ( jetToPFCandMap.
isValid() ) {
179 auto temp = jetToPFCandMap->
find(jetRef);
180 if(
temp == jetToPFCandMap->
end() ) {
181 edm::LogWarning(
"WeirdCandidateMap") <<
"Candidate map for jet " << jetRef.
key() <<
" is empty!";
184 isMappedToJet = fastJetToPFCandMap[ijet].count(pfCand.key());
186 isMappedToJet =
true;
191 std::cout <<
"jet #" << ijet <<
": Pt = " << jetRef->pt() <<
", eta = " << jetRef->eta() <<
", 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() <<
", phi = " << jetConstituent->phi() << std::endl;
203 matchInfo[jetRef.
key()] = nNewJets;
212 for (
size_t ijet = 0; ijet < nJets; ++ijet) {
218 template<
class JetType,
class CandType>
224 desc.
add<
double>(
"deltaR", 0.8);
226 desc.
add<
int>(
"verbosity", 0);
227 desc.
add<
double>(
"maxJetAbsEta", 2.5);
228 desc.
add<
double>(
"minJetPt", 14.0);
230 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.