File indexing completed on 2024-04-06 12:28:53
0001 #include "SeedCombiner.h"
0002
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/EventSetup.h"
0005 #include "DataFormats/Common/interface/Handle.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007
0008 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0009
0010 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducerFactory.h"
0011 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
0012 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
0013
0014 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGeneratorFactory.h"
0015 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGenerator.h"
0016
0017 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitorFactory.h"
0018 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitor.h"
0019 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
0020
0021 #include "RecoTracker/TkSeedGenerator/interface/SeedGeneratorFromRegionHits.h"
0022
0023 #include "TrackingTools/PatternTools/interface/ClusterRemovalRefSetter.h"
0024 #include "FWCore/Utilities/interface/transform.h"
0025
0026 using namespace edm;
0027
0028
0029 SeedCombiner::SeedCombiner(const edm::ParameterSet& cfg) {
0030 inputCollections_ =
0031 edm::vector_transform(cfg.getParameter<std::vector<edm::InputTag> >("seedCollections"),
0032 [this](edm::InputTag const& tag) { return consumes<TrajectorySeedCollection>(tag); });
0033 produces<TrajectorySeedCollection>();
0034 reKeing_ = false;
0035 if (cfg.exists("clusterRemovalInfos")) {
0036 clusterRemovalInfos_ = cfg.getParameter<std::vector<edm::InputTag> >("clusterRemovalInfos");
0037 clusterRemovalTokens_.resize(clusterRemovalInfos_.size());
0038 for (unsigned int i = 0; i < clusterRemovalInfos_.size(); ++i)
0039 if (!(clusterRemovalInfos_[i] == edm::InputTag("")))
0040 clusterRemovalTokens_[i] = consumes<reco::ClusterRemovalInfo>(clusterRemovalInfos_[i]);
0041 if (!clusterRemovalInfos_.empty() && clusterRemovalInfos_.size() == inputCollections_.size())
0042 reKeing_ = true;
0043 }
0044 }
0045
0046 SeedCombiner::~SeedCombiner() {}
0047
0048 void SeedCombiner::produce(edm::Event& ev, const edm::EventSetup& es) {
0049
0050 size_t ninputs = inputCollections_.size();
0051 size_t nseeds = 0;
0052 std::vector<Handle<TrajectorySeedCollection> > seedCollections(ninputs);
0053 for (size_t i = 0; i < ninputs; ++i) {
0054 ev.getByToken(inputCollections_[i], seedCollections[i]);
0055 nseeds += seedCollections[i]->size();
0056 }
0057
0058
0059 auto result = std::make_unique<TrajectorySeedCollection>();
0060 result->reserve(nseeds);
0061
0062
0063 unsigned int iSC = 0, iSC_max = seedCollections.size();
0064 for (; iSC != iSC_max; ++iSC) {
0065 Handle<TrajectorySeedCollection>& collection = seedCollections[iSC];
0066 if (reKeing_ && !(clusterRemovalInfos_[iSC] == edm::InputTag(""))) {
0067 ClusterRemovalRefSetter refSetter(ev, clusterRemovalTokens_[iSC]);
0068
0069 for (TrajectorySeedCollection::const_iterator iS = collection->begin(); iS != collection->end(); ++iS) {
0070 TrajectorySeed::RecHitContainer newRecHitContainer;
0071 newRecHitContainer.reserve(iS->nHits());
0072
0073 for (auto const& recHit : iS->recHits()) {
0074 newRecHitContainer.push_back(recHit);
0075 refSetter.reKey(&newRecHitContainer.back());
0076 }
0077 result->push_back(TrajectorySeed(iS->startingState(), std::move(newRecHitContainer), iS->direction()));
0078 }
0079 } else {
0080
0081 result->insert(result->end(), collection->begin(), collection->end());
0082 }
0083 }
0084
0085
0086 ev.put(std::move(result));
0087 }