-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Define RefProdVector for HGCRecHitCollection and PFRecHitCollection #49190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
ac427f6
e52d9b6
3b7f5fe
dbe55da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #ifndef DataFormats_Common_interface_MultiCollection_h | ||
| #define DataFormats_Common_interface_MultiCollection_h | ||
|
|
||
| #include <vector> | ||
|
|
||
| #include "DataFormats/Common/interface/RefProd.h" | ||
|
|
||
| namespace edm { | ||
| template <typename T> | ||
| using MultiCollection = std::vector<edm::RefProd<T>>; | ||
| } // namespace edm | ||
|
|
||
| #endif // DataFormats_Common_interface_MultiCollection_h | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| #include "DataFormats/CaloRecHit/interface/CaloCluster.h" | ||
| #include "SimDataFormats/Associations/interface/TICLAssociationMap.h" | ||
| #include "DataFormats/HGCRecHit/interface/HGCRecHitCollections.h" | ||
| #include "DataFormats/Common/interface/MultiCollection.h" | ||
| #include "DataFormats/Common/interface/MultiSpan.h" | ||
|
|
||
| class AllHitToTracksterAssociatorsProducer : public edm::global::EDProducer<> { | ||
|
|
@@ -25,22 +26,19 @@ class AllHitToTracksterAssociatorsProducer : public edm::global::EDProducer<> { | |
| std::vector<std::pair<std::string, edm::EDGetTokenT<std::vector<ticl::Trackster>>>> tracksterCollectionTokens_; | ||
| edm::EDGetTokenT<std::vector<reco::CaloCluster>> layerClustersToken_; | ||
| edm::EDGetTokenT<std::unordered_map<DetId, const unsigned int>> hitMapToken_; | ||
| std::vector<edm::EDGetTokenT<HGCRecHitCollection>> hitsTokens_; | ||
| edm::EDGetTokenT<edm::MultiCollection<HGCRecHitCollection>> hitsToken_; | ||
| }; | ||
|
|
||
| AllHitToTracksterAssociatorsProducer::AllHitToTracksterAssociatorsProducer(const edm::ParameterSet& pset) | ||
| : layerClustersToken_(consumes<std::vector<reco::CaloCluster>>(pset.getParameter<edm::InputTag>("layerClusters"))), | ||
| hitMapToken_( | ||
| consumes<std::unordered_map<DetId, const unsigned int>>(pset.getParameter<edm::InputTag>("hitMapTag"))) { | ||
| consumes<std::unordered_map<DetId, const unsigned int>>(pset.getParameter<edm::InputTag>("hitMapTag"))), | ||
| hitsToken_(consumes<edm::MultiCollection<HGCRecHitCollection>>(pset.getParameter<edm::InputTag>("hits"))) { | ||
| const auto& tracksterCollections = pset.getParameter<std::vector<edm::InputTag>>("tracksterCollections"); | ||
| for (const auto& tag : tracksterCollections) { | ||
| tracksterCollectionTokens_.emplace_back(tag.label() + tag.instance(), consumes<std::vector<ticl::Trackster>>(tag)); | ||
| } | ||
|
|
||
| for (const auto& tag : pset.getParameter<std::vector<edm::InputTag>>("hits")) { | ||
| hitsTokens_.emplace_back(consumes<HGCRecHitCollection>(tag)); | ||
| } | ||
|
|
||
| for (const auto& tracksterToken : tracksterCollectionTokens_) { | ||
| produces<ticl::AssociationMap<ticl::mapWithFraction>>("hitTo" + tracksterToken.first); | ||
| produces<ticl::AssociationMap<ticl::mapWithFraction>>(tracksterToken.first + "ToHit"); | ||
|
|
@@ -65,20 +63,25 @@ void AllHitToTracksterAssociatorsProducer::produce(edm::StreamID, edm::Event& iE | |
| Handle<std::unordered_map<DetId, const unsigned int>> hitMap; | ||
| iEvent.getByToken(hitMapToken_, hitMap); | ||
|
|
||
| edm::MultiSpan<HGCRecHit> rechitSpan; | ||
| for (const auto& token : hitsTokens_) { | ||
| Handle<HGCRecHitCollection> hitsHandle; | ||
| iEvent.getByToken(token, hitsHandle); | ||
| if (!iEvent.getHandle(hitsToken_)) { | ||
| edm::LogWarning("AllHitToTracksterAssociatorsProducer") << "Missing edm::MultiCollection<HGCRecHitCollection>."; | ||
| for (const auto& tracksterToken : tracksterCollectionTokens_) { | ||
| iEvent.put(std::make_unique<ticl::AssociationMap<ticl::mapWithFraction>>(), "hitTo" + tracksterToken.first); | ||
| iEvent.put(std::make_unique<ticl::AssociationMap<ticl::mapWithFraction>>(), tracksterToken.first + "ToHit"); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| // Protection against missing HGCRecHitCollection | ||
| if (!hitsHandle.isValid()) { | ||
| edm::LogWarning("AllHitToTracksterAssociatorsProducer") | ||
| << "Missing HGCRecHitCollection for one of the hitsTokens."; | ||
| continue; | ||
| // Protection against missing HGCRecHitCollection | ||
| const auto hits = iEvent.get(hitsToken_); | ||
| for (std::size_t index = 0; const auto& hgcRecHitCollection : hits) { | ||
| if (hgcRecHitCollection->empty()) { | ||
| edm::LogWarning("AllHitToTracksterAssociatorsProducer") << "HGCRecHitCollections #" << index << " is not valid."; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The producers, that have been adapted in the PR contain a few debug evaluations. They have not beed guarded by NDEBUG so far, should this be done?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guarding with |
||
| } | ||
| rechitSpan.add(*hitsHandle); | ||
| index++; | ||
| } | ||
|
|
||
| edm::MultiSpan<HGCRecHit> rechitSpan(hits); | ||
| // Check if rechitSpan is empty | ||
| if (rechitSpan.size() == 0) { | ||
| edm::LogWarning("HitToSimClusterCaloParticleAssociatorProducer") | ||
|
|
@@ -135,10 +138,7 @@ void AllHitToTracksterAssociatorsProducer::fillDescriptions(edm::ConfigurationDe | |
| edm::InputTag("ticlCandidate")}); | ||
| desc.add<edm::InputTag>("layerClusters", edm::InputTag("hgcalMergeLayerClusters")); | ||
| desc.add<edm::InputTag>("hitMapTag", edm::InputTag("recHitMapProducer", "hgcalRecHitMap")); | ||
| desc.add<std::vector<edm::InputTag>>("hits", | ||
| {edm::InputTag("HGCalRecHit", "HGCEERecHits"), | ||
| edm::InputTag("HGCalRecHit", "HGCHEFRecHits"), | ||
| edm::InputTag("HGCalRecHit", "HGCHEBRecHits")}); | ||
| desc.add<edm::InputTag>("hits", edm::InputTag("recHitMapProducer", "MultiHGCRecHitCollectionProduct")); | ||
| descriptions.add("AllHitToTracksterAssociatorsProducer", desc); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Repeating #49190 (comment) I still find the
MultiCollectionnot to be a very descriptive name. How about e.g.RefProdVector?