53 template <
typename T1>
56 std::vector<edm::InputTag> inCollections = iConfig.
getParameter<std::vector<edm::InputTag>>(
"mergCollections");
58 for (
const auto &inCollection : inCollections) {
59 inputs_[inCollection.instance()].push_back(consumes<TrackCollectionemb>(inCollection));
62 for (
const auto &toproduce : inputs_) {
63 willproduce(toproduce.first,
alias);
67 template <
typename T1>
72 template <
typename T1>
74 geometry_ = &iSetup.
getData(globalGeomToken_);
75 for (
auto input_ : inputs_) {
76 merg_and_put(
iEvent, input_.first, input_.second);
81 template <
typename T1>
83 produces<TrackCollectionemb>(
instance);
86 template <
typename T1>
89 template <
typename T1>
93 std::unique_ptr<TrackCollectionemb> outTracks = std::unique_ptr<TrackCollectionemb>(
new TrackCollectionemb);
95 for (
auto akt_collection : to_merge) {
97 iEvent.getByToken(akt_collection, track_col_in);
100 for (
typename TrackCollectionemb::const_iterator
it = track_col_in->begin();
it != track_col_in->end();
112 produces<reco::TrackCollection>(
instance).setBranchAlias(
alias +
"Tracks");
113 produces<reco::TrackExtraCollection>(
instance).setBranchAlias(
alias +
"TrackExtras");
114 produces<TrackingRecHitCollection>(
instance).setBranchAlias(
alias +
"RecHits");
115 produces<TrackToTrackMapnew>();
121 std::unique_ptr<reco::TrackCollection> outTracks = std::make_unique<reco::TrackCollection>();
122 std::unique_ptr<reco::TrackExtraCollection> outTracks_ex = std::make_unique<reco::TrackExtraCollection>();
123 std::unique_ptr<TrackingRecHitCollection> outTracks_rh = std::make_unique<TrackingRecHitCollection>();
124 std::unique_ptr<TrackToTrackMapnew> outTracks_refs = std::make_unique<TrackToTrackMapnew>();
128 std::vector<reco::TrackRefVector> trackRefColl;
130 for (
auto akt_collection : to_merge) {
132 iEvent.getByToken(akt_collection, track_col_in);
134 unsigned sedref_it = 0;
135 for (reco::TrackCollection::const_iterator
it = track_col_in->begin();
it != track_col_in->end();
138 auto rechits =
it->recHits();
140 for (
auto ith = rechits.begin(); ith != rechits.end(); ith++) {
141 auto hit = *(&(*ith));
142 hit->setDet(*geometry_->idToDet(
hit->rawId()));
149 trackRefColl_helpvec.
push_back(trackRefold);
150 trackRefColl.push_back(trackRefColl_helpvec);
159 filler.insert(trackHandle, trackRefColl.begin(), trackRefColl.end());
169 inputs_fixtrackrefs_ = consumes<TrackToTrackMapnew>(
edm::InputTag(
"generalTracks"));
170 inputs_fixtrackcol_ = consumes<reco::TrackCollection>(
edm::InputTag(
"generalTracks"));
171 inputs_rElectronMergedSeeds_ = consumes<reco::ElectronSeedCollection>(
edm::InputTag(
"electronMergedSeeds"));
172 inputs_rElectronMergedSeedViews_ = consumes<edm::View<TrajectorySeed>>(
edm::InputTag(
"electronMergedSeeds"));
177 produces<reco::GsfTrackCollection>(
instance).setBranchAlias(
alias +
"GsfTracks");
178 produces<reco::TrackExtraCollection>(
instance).setBranchAlias(
alias +
"TrackExtras");
179 produces<reco::GsfTrackExtraCollection>(
instance).setBranchAlias(
alias +
"GsfTrackExtras");
180 produces<TrackingRecHitCollection>(
instance).setBranchAlias(
alias +
"RecHits");
181 produces<GsfTrackToTrackMapnew>();
187 std::unique_ptr<reco::GsfTrackCollection> outTracks = std::make_unique<reco::GsfTrackCollection>();
188 std::unique_ptr<reco::TrackExtraCollection> outTracks_ex = std::make_unique<reco::TrackExtraCollection>();
189 std::unique_ptr<reco::GsfTrackExtraCollection> outTracks_exgsf = std::make_unique<reco::GsfTrackExtraCollection>();
190 std::unique_ptr<TrackingRecHitCollection> outTracks_rh = std::make_unique<TrackingRecHitCollection>();
191 std::unique_ptr<GsfTrackToTrackMapnew> outTracks_refs = std::make_unique<GsfTrackToTrackMapnew>();
197 std::vector<reco::GsfTrackRefVector> trackRefColl;
201 iEvent.getByToken(inputs_fixtrackrefs_, track_ref_map);
204 iEvent.getByToken(inputs_fixtrackcol_, track_new_col);
206 std::map<reco::TrackRef, reco::TrackRef> simple_track_to_track_map;
207 for (
unsigned abc = 0; abc < track_new_col->size(); ++abc) {
209 simple_track_to_track_map[trackRef] = trackRef;
210 simple_track_to_track_map[((*track_ref_map)[trackRef])[0]] = trackRef;
214 for (
auto akt_collection : to_merge) {
216 iEvent.getByToken(akt_collection, track_col_in);
218 size_t sedref_it = 0;
219 for (reco::GsfTrackCollection::const_iterator
it = track_col_in->begin();
it != track_col_in->end();
224 auto rechits =
it->recHits();
226 for (
auto ith = rechits.begin(); ith != rechits.end(); ith++) {
227 auto hit = *(&(*ith));
228 hit->setDet(*geometry_->idToDet(
hit->rawId()));
238 trackRefColl_helpvec.
push_back(trackRefold);
239 trackRefColl.push_back(trackRefColl_helpvec);
246 filler.insert(trackHandle, trackRefColl.begin(), trackRefColl.end());
250 iEvent.getByToken(inputs_rElectronMergedSeeds_, elSeeds);
251 auto bElSeeds = elSeeds->cbegin();
252 auto eElSeeds = elSeeds->cend();
255 iEvent.getByToken(inputs_rElectronMergedSeedViews_, seedViewsHandle);
257 std::unique_ptr<reco::TrackExtraCollection> outTracks_ex_new = std::make_unique<reco::TrackExtraCollection>();
260 for (
typename reco::TrackExtraCollection::const_iterator
tex = outTracks_ex->begin();
tex != outTracks_ex->end();
264 if (
tex->seedRef().isAvailable()) {
269 size_t sedref_it = 0;
270 for (
auto tseed = bElSeeds; tseed != eElSeeds; ++tseed, ++sedref_it) {
273 if (trSeedRef->isEcalDriven() && elSeedRef->isEcalDriven()) {
275 if (trSeedRef->detId(0) == elSeedRef->detId(0) && trSeedRef->detId(1) == elSeedRef->detId(1)) {
280 if (trSeedRef->isTrackerDriven() && elSeedRef->isTrackerDriven()) {
282 if (simple_track_to_track_map[trSeedRef->ctfTrack()] == elSeedRef->ctfTrack()) {
291 outTracks_ex_new->push_back(newTrackExtra);
302 produces<reco::MuonCollection>();
303 produces<reco::CaloMuonCollection>();
304 produces<reco::MuonTimeExtraMap>(
"combined");
305 produces<reco::MuonTimeExtraMap>(
"dt");
306 produces<reco::MuonTimeExtraMap>(
"csc");
309 produces<reco::IsoDepositMap>(
"tracker");
310 produces<reco::IsoDepositMap>(
"ecal");
311 produces<reco::IsoDepositMap>(
"hcal");
312 produces<reco::IsoDepositMap>(
"ho");
313 produces<reco::IsoDepositMap>(
"jets");
315 produces<reco::MuonToMuonMap>();
320 if (
alias ==
"displacedMuons1stStep") {
321 inputs_fixtrackrefs_ = consumes<TrackToTrackMapnew>(
edm::InputTag(
"displacedTracks"));
322 inputs_fixtrackcol_ = consumes<reco::TrackCollection>(
edm::InputTag(
"displacedTracks"));
324 inputs_fixtrackrefs_ = consumes<TrackToTrackMapnew>(
edm::InputTag(
"generalTracks"));
325 inputs_fixtrackcol_ = consumes<reco::TrackCollection>(
edm::InputTag(
"generalTracks"));
333 std::unique_ptr<reco::MuonCollection> outTracks = std::make_unique<reco::MuonCollection>();
334 std::unique_ptr<reco::CaloMuonCollection> calomu =
335 std::make_unique<reco::CaloMuonCollection>();
338 iEvent.getByToken(inputs_fixtrackrefs_, track_ref_map);
341 iEvent.getByToken(inputs_fixtrackcol_, track_new_col);
342 std::map<reco::TrackRef, reco::TrackRef> simple_track_to_track_map;
343 for (
unsigned abc = 0; abc < track_new_col->size(); ++abc) {
345 simple_track_to_track_map[trackRef] =
347 simple_track_to_track_map[((*track_ref_map)[trackRef])[0]] = trackRef;
350 std::vector<reco::MuonRef> muonRefColl;
352 unsigned new_idx = 0;
353 for (
auto akt_collection : to_merge) {
355 iEvent.getByToken(akt_collection, track_col_in);
356 unsigned old_idx = 0;
357 for (reco::MuonCollection::const_iterator
it = track_col_in->begin();
it != track_col_in->end();
358 ++
it, ++old_idx, ++new_idx) {
361 muonRefColl.push_back(muRefold);
364 if (
it->track().isNonnull()) {
365 outTracks->back().setTrack(simple_track_to_track_map[
it->track()]);
371 const int nMuons = outTracks->size();
373 std::vector<reco::MuonTimeExtra> dtTimeColl(
nMuons);
374 std::vector<reco::MuonTimeExtra> cscTimeColl(
nMuons);
375 std::vector<reco::MuonTimeExtra> combinedTimeColl(
nMuons);
376 std::vector<reco::IsoDeposit> trackDepColl(
nMuons);
377 std::vector<reco::IsoDeposit> ecalDepColl(
nMuons);
378 std::vector<reco::IsoDeposit> hcalDepColl(
nMuons);
379 std::vector<reco::IsoDeposit> hoDepColl(
nMuons);
380 std::vector<reco::IsoDeposit> jetDepColl(
nMuons);
386 std::unique_ptr<MapType> oMap(
new MapType());
388 typename MapType::Filler
filler(*oMap);
389 filler.insert(refH, vec.begin(), vec.end());
396 fillMap(muonHandle, combinedTimeColl,
iEvent,
"combined");
397 fillMap(muonHandle, dtTimeColl,
iEvent,
"dt");
398 fillMap(muonHandle, cscTimeColl,
iEvent,
"csc");
399 fillMap(muonHandle, trackDepColl,
iEvent,
"tracker");
400 fillMap(muonHandle, ecalDepColl,
iEvent,
"ecal");
401 fillMap(muonHandle, hcalDepColl,
iEvent,
"hcal");
402 fillMap(muonHandle, hoDepColl,
iEvent,
"ho");
403 fillMap(muonHandle, jetDepColl,
iEvent,
"jets");
404 fillMap(muonHandle, muonRefColl,
iEvent);
410 produces<reco::PFCandidateCollection>(
instance);
415 inputs_fixtrackrefs_ = consumes<TrackToTrackMapnew>(
edm::InputTag(
"generalTracks"));
416 inputs_fixtrackcol_ = consumes<reco::TrackCollection>(
edm::InputTag(
"generalTracks"));
417 inputs_fixgsftrackrefs_ = consumes<GsfTrackToTrackMapnew>(
edm::InputTag(
"electronGsfTracks"));
418 inputs_fixgsftrackcol_ = consumes<reco::GsfTrackCollection>(
edm::InputTag(
"electronGsfTracks"));
419 inputs_fixmurefs_ = consumes<reco::MuonToMuonMap>(
edm::InputTag(
"muons1stStep"));
420 inputs_fixmucol_ = consumes<reco::MuonCollection>(
edm::InputTag(
"muons1stStep"));
421 inputs_SC_ = consumes<reco::SuperClusterCollection>(
edm::InputTag(
"particleFlowEGamma"));
427 std::unique_ptr<reco::PFCandidateCollection> outTracks = std::make_unique<reco::PFCandidateCollection>();
430 iEvent.getByToken(inputs_fixtrackrefs_, track_ref_map);
433 iEvent.getByToken(inputs_fixtrackcol_, track_new_col);
434 std::map<reco::TrackRef, reco::TrackRef> simple_track_to_track_map;
435 for (
unsigned abc = 0; abc < track_new_col->size(); ++abc) {
437 simple_track_to_track_map[trackRef] =
439 simple_track_to_track_map[((*track_ref_map)[trackRef])[0]] = trackRef;
443 iEvent.getByToken(inputs_fixgsftrackrefs_, gsftrack_ref_map);
446 iEvent.getByToken(inputs_fixgsftrackcol_, gsftrack_new_col);
447 std::map<reco::GsfTrackRef, reco::GsfTrackRef> simple_gsftrack_to_gsftrack_map;
448 for (
unsigned abc = 0; abc < gsftrack_new_col->size(); ++abc) {
450 simple_gsftrack_to_gsftrack_map[((*gsftrack_ref_map)[gsfTrackRef])[0]] = gsfTrackRef;
454 iEvent.getByToken(inputs_fixmurefs_, muon_ref_map);
457 iEvent.getByToken(inputs_fixmucol_, muon_new_col);
458 std::map<reco::MuonRef, reco::MuonRef> simple_mu_to_mu_map;
459 for (
unsigned abc = 0; abc < muon_new_col->size(); ++abc) {
461 simple_mu_to_mu_map[(*muon_ref_map)[muRef]] = muRef;
466 iEvent.getByToken(inputs_SC_, sCs);
467 auto bSc = sCs->cbegin();
468 auto eSc = sCs->cend();
470 for (
auto akt_collection : to_merge) {
472 iEvent.getByToken(akt_collection, track_col_in);
473 for (reco::PFCandidateCollection::const_iterator
it = track_col_in->begin();
it != track_col_in->end(); ++
it) {
475 if (
it->trackRef().isNonnull() && outTracks->back().charge()) {
476 outTracks->back().setTrackRef(simple_track_to_track_map[
it->trackRef()]);
478 if (
it->gsfTrackRef().isNonnull()) {
479 outTracks->back().setGsfTrackRef(simple_gsftrack_to_gsftrack_map[
it->gsfTrackRef()]);
481 if (
it->superClusterRef().isNonnull()) {
487 for (
auto sc = bSc; sc != eSc; ++sc) {
489 dx = fabs(scRef->x() - pfScRef->x());
490 dy = fabs(scRef->y() - pfScRef->y());
491 dz = fabs(scRef->z() - pfScRef->z());
495 outTracks->back().setSuperClusterRef(scRef);
499 if (
it->muonRef().isNonnull()) {
500 outTracks->back().setMuonRef(simple_mu_to_mu_map[
it->muonRef()]);
TrackMergeremb< reco::PFCandidateCollection > PFColMerger
void willconsume(const edm::ParameterSet &iConfig)
T getParameter(std::string const &) const
TrackMergeremb< reco::ConversionCollection > ConversionColMerger
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
TrackMergeremb< reco::MuonCollection > MuonColMerger
static PFTauRenderPlugin instance
void merg_and_put(edm::Event &, std::string, std::vector< edm::EDGetTokenT< TrackCollectionemb >> &)
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
~TrackMergeremb() override
void willproduce(std::string instance, std::string alias)
std::vector< Muon > MuonCollection
collection of Muon objects
Container::value_type value_type
TrackMergeremb< reco::GsfElectronCollection > GsfElectronColMerger
TrackMergeremb< reco::GsfTrackCollection > GsfTrackColMerger
#define DEFINE_FWK_MODULE(type)
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Particle reconstructed by the particle flow algorithm.
TrackMergeremb< reco::PhotonCollection > PhotonColMerger
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
TrackMergeremb(const edm::ParameterSet &)
TrackMergeremb< reco::TrackCollection > TrackColMerger
void produce(edm::Event &, const edm::EventSetup &) override