CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
TrackMergeremb< T1 > Class Template Reference

#include <TrackMergeremb.h>

Inheritance diagram for TrackMergeremb< T1 >:
edm::stream::EDProducer<>

Public Member Functions

 TrackMergeremb (const edm::ParameterSet &)
 
 ~TrackMergeremb () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Types

typedef edm::ValueMap< reco::GsfTrackRefVectorGsfTrackToTrackMapnew
 
typedef T1 TrackCollectionemb
 
typedef edm::ValueMap< reco::TrackRefVectorTrackToTrackMapnew
 

Private Member Functions

void merg_and_put (edm::Event &, std::string, std::vector< edm::EDGetTokenT< TrackCollectionemb >> &)
 
template<>
void merg_and_put (edm::Event &iEvent, std::string instance, std::vector< edm::EDGetTokenT< reco::TrackCollection >> &to_merge)
 
template<>
void merg_and_put (edm::Event &iEvent, std::string instance, std::vector< edm::EDGetTokenT< reco::GsfTrackCollection >> &to_merge)
 
template<>
void merg_and_put (edm::Event &iEvent, std::string instance, std::vector< edm::EDGetTokenT< reco::MuonCollection >> &to_merge)
 
template<>
void merg_and_put (edm::Event &iEvent, std::string instance, std::vector< edm::EDGetTokenT< reco::PFCandidateCollection >> &to_merge)
 
void produce (edm::Event &, const edm::EventSetup &) override
 
void willconsume (const edm::ParameterSet &iConfig)
 
template<>
void willconsume (const edm::ParameterSet &iConfig)
 
template<>
void willconsume (const edm::ParameterSet &iConfig)
 
template<>
void willconsume (const edm::ParameterSet &iConfig)
 
void willproduce (std::string instance, std::string alias)
 
template<>
void willproduce (std::string instance, std::string alias)
 
template<>
void willproduce (std::string instance, std::string alias)
 
template<>
void willproduce (std::string instance, std::string alias)
 
template<>
void willproduce (std::string instance, std::string alias)
 

Private Attributes

std::string alias
 
const GlobalTrackingGeometrygeometry_ = nullptr
 
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecordglobalGeomToken_
 
std::map< std::string, std::vector< edm::EDGetTokenT< TrackCollectionemb > > > inputs_
 
edm::EDGetTokenT< reco::GsfTrackCollectioninputs_fixgsftrackcol_
 
edm::EDGetTokenT< GsfTrackToTrackMapnewinputs_fixgsftrackrefs_
 
edm::EDGetTokenT< reco::MuonCollectioninputs_fixmucol_
 
edm::EDGetTokenT< reco::MuonToMuonMapinputs_fixmurefs_
 
edm::EDGetTokenT< reco::TrackCollectioninputs_fixtrackcol_
 
edm::EDGetTokenT< TrackToTrackMapnewinputs_fixtrackrefs_
 
std::map< std::string, std::vector< edm::EDGetTokenT< edm::ValueMap< reco::MuonQuality > > > > inputs_qual_
 
edm::EDGetTokenT< reco::ElectronSeedCollectioninputs_rElectronMergedSeeds_
 
edm::EDGetTokenT< edm::View< TrajectorySeed > > inputs_rElectronMergedSeedViews_
 
edm::EDGetTokenT< reco::SuperClusterCollectioninputs_SC_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

template<typename T1>
class TrackMergeremb< T1 >

Author
Stefan Wayand; Christian Veelken, LLR Clean Up from Christian Winter & Sebastian Brommer, KIT

Definition at line 47 of file TrackMergeremb.h.

Member Typedef Documentation

◆ GsfTrackToTrackMapnew

template<typename T1 >
typedef edm::ValueMap<reco::GsfTrackRefVector> TrackMergeremb< T1 >::GsfTrackToTrackMapnew
private

Definition at line 65 of file TrackMergeremb.h.

◆ TrackCollectionemb

template<typename T1 >
typedef T1 TrackMergeremb< T1 >::TrackCollectionemb
private

Definition at line 55 of file TrackMergeremb.h.

◆ TrackToTrackMapnew

template<typename T1 >
typedef edm::ValueMap<reco::TrackRefVector> TrackMergeremb< T1 >::TrackToTrackMapnew
private

Definition at line 64 of file TrackMergeremb.h.

Constructor & Destructor Documentation

◆ TrackMergeremb()

template<typename T1 >
TrackMergeremb< T1 >::TrackMergeremb ( const edm::ParameterSet iConfig)
explicit

Definition at line 54 of file TrackMergeremb.cc.

References isoTrack_cff::alias, deDxTools::esConsumes(), edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

54  {
55  alias = iConfig.getParameter<std::string>("@module_label");
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));
60  }
61  willconsume(iConfig);
62  for (const auto &toproduce : inputs_) {
63  willproduce(toproduce.first, alias);
64  }
65 }
void willconsume(const edm::ParameterSet &iConfig)
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::string alias
std::map< std::string, std::vector< edm::EDGetTokenT< TrackCollectionemb > > > inputs_
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > globalGeomToken_
void willproduce(std::string instance, std::string alias)

◆ ~TrackMergeremb()

template<typename T1 >
TrackMergeremb< T1 >::~TrackMergeremb ( )
override

Definition at line 68 of file TrackMergeremb.cc.

68  {
69  // nothing to be done yet...
70 }

Member Function Documentation

◆ merg_and_put() [1/5]

template<typename T1 >
void TrackMergeremb< T1 >::merg_and_put ( edm::Event iEvent,
std::string  instance,
std::vector< edm::EDGetTokenT< TrackCollectionemb >> &  to_merge 
)
private

Definition at line 90 of file TrackMergeremb.cc.

References iEvent, instance, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, and eostools::move().

92  {
93  std::unique_ptr<TrackCollectionemb> outTracks = std::unique_ptr<TrackCollectionemb>(new TrackCollectionemb);
94 
95  for (auto akt_collection : to_merge) {
97  iEvent.getByToken(akt_collection, track_col_in);
98 
99  size_t sedref_it = 0;
100  for (typename TrackCollectionemb::const_iterator it = track_col_in->begin(); it != track_col_in->end();
101  ++it, ++sedref_it) {
102  outTracks->push_back(typename T1::value_type(*it));
103  }
104 
105  } // end merge
106 
107  iEvent.put(std::move(outTracks), instance);
108 }
static PFTauRenderPlugin instance
int iEvent
Definition: GenABIO.cc:224
def move(src, dest)
Definition: eostools.py:511

◆ merg_and_put() [2/5]

template<>
void TrackMergeremb< reco::TrackCollection >::merg_and_put ( edm::Event iEvent,
std::string  instance,
std::vector< edm::EDGetTokenT< reco::TrackCollection >> &  to_merge 
)
private

Definition at line 119 of file TrackMergeremb.cc.

References trigObjTnPSource_cfi::filler, iEvent, instance, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, eostools::move(), and edm::RefVector< C, T, F >::push_back().

120  {
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>();
125 
126  auto rTrackExtras = iEvent.getRefBeforePut<reco::TrackExtraCollection>();
127 
128  std::vector<reco::TrackRefVector> trackRefColl;
129 
130  for (auto akt_collection : to_merge) {
132  iEvent.getByToken(akt_collection, track_col_in);
133 
134  unsigned sedref_it = 0;
135  for (reco::TrackCollection::const_iterator it = track_col_in->begin(); it != track_col_in->end();
136  ++it, ++sedref_it) {
137  outTracks->push_back(reco::Track(*it));
138  auto rechits = it->recHits();
139  // Fixing geometry records of detector components for tracking rec. hits
140  for (auto ith = rechits.begin(); ith != rechits.end(); ith++) {
141  auto hit = *(&(*ith));
142  hit->setDet(*geometry_->idToDet(hit->rawId()));
143  }
144  outTracks_ex->push_back(reco::TrackExtra(*it->extra()));
145  outTracks->back().setExtra(reco::TrackExtraRef(rTrackExtras, outTracks_ex->size() - 1));
146  reco::TrackRef trackRefold(track_col_in, sedref_it);
147 
148  reco::TrackRefVector trackRefColl_helpvec;
149  trackRefColl_helpvec.push_back(trackRefold);
150  trackRefColl.push_back(trackRefColl_helpvec);
151  }
152 
153  } // end merge
154 
155  edm::OrphanHandle<reco::TrackCollection> trackHandle = iEvent.put(std::move(outTracks), instance);
156  iEvent.put(std::move(outTracks_ex), instance);
157 
158  TrackToTrackMapnew::Filler filler(*outTracks_refs);
159  filler.insert(trackHandle, trackRefColl.begin(), trackRefColl.end());
160  filler.fill();
161 
162  iEvent.put(std::move(outTracks_refs));
163  iEvent.put(std::move(outTracks_rh), instance); // not implemented so far
164 }
static PFTauRenderPlugin instance
const GeomDet * idToDet(DetId) const override
int iEvent
Definition: GenABIO.cc:224
helper::Filler< ValueMap< T > > Filler
Definition: ValueMap.h:162
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
const GlobalTrackingGeometry * geometry_
def move(src, dest)
Definition: eostools.py:511

◆ merg_and_put() [3/5]

template<>
void TrackMergeremb< reco::GsfTrackCollection >::merg_and_put ( edm::Event iEvent,
std::string  instance,
std::vector< edm::EDGetTokenT< reco::GsfTrackCollection >> &  to_merge 
)
private

Definition at line 185 of file TrackMergeremb.cc.

References trigObjTnPSource_cfi::filler, iEvent, instance, edm::Ref< C, T, F >::isAvailable(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, eostools::move(), edm::RefVector< C, T, F >::push_back(), fileCollector::seed, reco::TrackExtra::setSeedRef(), and cuy::tex.

186  {
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>();
192 
193  auto rTrackExtras = iEvent.getRefBeforePut<reco::TrackExtraCollection>();
194  auto rTrackExtras_gsf = iEvent.getRefBeforePut<reco::GsfTrackExtraCollection>();
195 
196  auto rHits = iEvent.getRefBeforePut<TrackingRecHitCollection>();
197  std::vector<reco::GsfTrackRefVector> trackRefColl;
198 
199  // track to track map for trackerdriven seed fix
200  edm::Handle<TrackToTrackMapnew> track_ref_map;
201  iEvent.getByToken(inputs_fixtrackrefs_, track_ref_map);
202 
204  iEvent.getByToken(inputs_fixtrackcol_, track_new_col);
205 
206  std::map<reco::TrackRef, reco::TrackRef> simple_track_to_track_map;
207  for (unsigned abc = 0; abc < track_new_col->size(); ++abc) {
208  reco::TrackRef trackRef(track_new_col, abc);
209  simple_track_to_track_map[trackRef] = trackRef;
210  simple_track_to_track_map[((*track_ref_map)[trackRef])[0]] = trackRef;
211  }
212 
213  // merge begin
214  for (auto akt_collection : to_merge) {
216  iEvent.getByToken(akt_collection, track_col_in);
217 
218  size_t sedref_it = 0;
219  for (reco::GsfTrackCollection::const_iterator it = track_col_in->begin(); it != track_col_in->end();
220  ++it, ++sedref_it) {
221  reco::ElectronSeedRef seed = it->seedRef().castTo<reco::ElectronSeedRef>();
222  (const_cast<reco::ElectronSeed *>(seed.get()))->setCtfTrack(simple_track_to_track_map[seed->ctfTrack()]);
223  outTracks->push_back(reco::GsfTrack(*it));
224  auto rechits = it->recHits();
225  // Fixing geometry records of detector components for tracking rec. hits
226  for (auto ith = rechits.begin(); ith != rechits.end(); ith++) {
227  auto hit = *(&(*ith));
228  hit->setDet(*geometry_->idToDet(hit->rawId()));
229  }
230  outTracks_ex->push_back(reco::TrackExtra(*it->extra()));
231  outTracks_exgsf->push_back(reco::GsfTrackExtra(*it->gsfExtra()));
232 
233  outTracks->back().setExtra(reco::TrackExtraRef(rTrackExtras, outTracks_ex->size() - 1));
234  outTracks->back().setGsfExtra(reco::GsfTrackExtraRef(rTrackExtras_gsf, outTracks_exgsf->size() - 1));
235 
236  reco::GsfTrackRef trackRefold(track_col_in, sedref_it);
237  reco::GsfTrackRefVector trackRefColl_helpvec;
238  trackRefColl_helpvec.push_back(trackRefold);
239  trackRefColl.push_back(trackRefColl_helpvec);
240  }
241 
242  } // end merge
243 
245  GsfTrackToTrackMapnew::Filler filler(*outTracks_refs);
246  filler.insert(trackHandle, trackRefColl.begin(), trackRefColl.end());
247  filler.fill();
248 
250  iEvent.getByToken(inputs_rElectronMergedSeeds_, elSeeds);
251  auto bElSeeds = elSeeds->cbegin();
252  auto eElSeeds = elSeeds->cend();
253 
254  edm::Handle<edm::View<TrajectorySeed>> seedViewsHandle;
255  iEvent.getByToken(inputs_rElectronMergedSeedViews_, seedViewsHandle);
256 
257  std::unique_ptr<reco::TrackExtraCollection> outTracks_ex_new = std::make_unique<reco::TrackExtraCollection>();
258 
259  // fix track extras to new merged seeds
260  for (typename reco::TrackExtraCollection::const_iterator tex = outTracks_ex->begin(); tex != outTracks_ex->end();
261  ++tex) {
262  reco::TrackExtra newTrackExtra(*tex);
263 
264  if (tex->seedRef().isAvailable()) {
265  const reco::ElectronSeedRef &trSeedRef(tex->seedRef().castTo<reco::ElectronSeedRef>());
266  if (trSeedRef.isAvailable()) {
267  // find new seed with corresponding supercluster or ctfTrack
268  // note that seed can be both Ecal- and Tracker-driven
269  size_t sedref_it = 0;
270  for (auto tseed = bElSeeds; tseed != eElSeeds; ++tseed, ++sedref_it) {
271  const reco::ElectronSeedRef elSeedRef(elSeeds, sedref_it);
272 
273  if (trSeedRef->isEcalDriven() && elSeedRef->isEcalDriven()) {
274  // match seeds by pair of detIds
275  if (trSeedRef->detId(0) == elSeedRef->detId(0) && trSeedRef->detId(1) == elSeedRef->detId(1)) {
276  edm::RefToBase<TrajectorySeed> traSeedRef(seedViewsHandle, sedref_it);
277  newTrackExtra.setSeedRef(traSeedRef);
278  }
279  }
280  if (trSeedRef->isTrackerDriven() && elSeedRef->isTrackerDriven()) {
281  // if tracker driven, check for same ctf track
282  if (simple_track_to_track_map[trSeedRef->ctfTrack()] == elSeedRef->ctfTrack()) {
283  edm::RefToBase<TrajectorySeed> traSeedRef(seedViewsHandle, sedref_it);
284  newTrackExtra.setSeedRef(traSeedRef);
285  }
286  }
287  }
288  }
289  }
290 
291  outTracks_ex_new->push_back(newTrackExtra);
292  }
293 
294  iEvent.put(std::move(outTracks_refs));
295  iEvent.put(std::move(outTracks_ex_new), instance);
296  iEvent.put(std::move(outTracks_exgsf), instance);
297  iEvent.put(std::move(outTracks_rh), instance);
298 }
edm::EDGetTokenT< edm::View< TrajectorySeed > > inputs_rElectronMergedSeedViews_
edm::EDGetTokenT< reco::ElectronSeedCollection > inputs_rElectronMergedSeeds_
static PFTauRenderPlugin instance
std::vector< GsfTrackExtra > GsfTrackExtraCollection
collection of GsfTrackExtra objects
edm::EDGetTokenT< reco::TrackCollection > inputs_fixtrackcol_
const GeomDet * idToDet(DetId) const override
int iEvent
Definition: GenABIO.cc:224
tex
Definition: cuy.py:773
helper::Filler< ValueMap< T > > Filler
Definition: ValueMap.h:162
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
edm::EDGetTokenT< TrackToTrackMapnew > inputs_fixtrackrefs_
const GlobalTrackingGeometry * geometry_
def move(src, dest)
Definition: eostools.py:511

◆ merg_and_put() [4/5]

template<>
void TrackMergeremb< reco::MuonCollection >::merg_and_put ( edm::Event iEvent,
std::string  instance,
std::vector< edm::EDGetTokenT< reco::MuonCollection >> &  to_merge 
)
private

Definition at line 330 of file TrackMergeremb.cc.

References makeMEIFBenchmarkPlots::ev, trigObjTnPSource_cfi::filler, iEvent, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, eostools::move(), custom_jme_cff::nMuons, and AlCaHLTBitMon_QueryRunRegistry::string.

332  {
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>(); // not implemented so far
336 
337  edm::Handle<TrackToTrackMapnew> track_ref_map;
338  iEvent.getByToken(inputs_fixtrackrefs_, track_ref_map);
339 
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) {
344  reco::TrackRef trackRef(track_new_col, abc);
345  simple_track_to_track_map[trackRef] =
346  trackRef; // catch the case, where a seed ctf track could already be updated, such that the update doesn't happen again
347  simple_track_to_track_map[((*track_ref_map)[trackRef])[0]] = trackRef;
348  }
349 
350  std::vector<reco::MuonRef> muonRefColl;
351  reco::MuonRefProd outputMuonsRefProd = iEvent.getRefBeforePut<reco::MuonCollection>();
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) {
359  outTracks->push_back(reco::Muon(*it));
360  reco::MuonRef muRefold(track_col_in, old_idx);
361  muonRefColl.push_back(muRefold);
362  reco::MuonRef muRefnew(outputMuonsRefProd, new_idx);
363 
364  if (it->track().isNonnull()) {
365  outTracks->back().setTrack(simple_track_to_track_map[it->track()]);
366  }
367  }
368 
369  } // end merge
370 
371  const int nMuons = outTracks->size();
372 
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);
381 
382  edm::OrphanHandle<reco::MuonCollection> muonHandle = iEvent.put(std::move(outTracks));
383 
384  auto fillMap = [](auto refH, auto &vec, edm::Event &ev, const std::string &cAl = "") {
386  std::unique_ptr<MapType> oMap(new MapType());
387  {
388  typename MapType::Filler filler(*oMap);
389  filler.insert(refH, vec.begin(), vec.end());
390  vec.clear();
391  filler.fill();
392  }
393  ev.put(std::move(oMap), cAl);
394  };
395 
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);
405  iEvent.put(std::move(calomu));
406 }
edm::EDGetTokenT< reco::TrackCollection > inputs_fixtrackcol_
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< TrackToTrackMapnew > inputs_fixtrackrefs_
def move(src, dest)
Definition: eostools.py:511

◆ merg_and_put() [5/5]

template<>
void TrackMergeremb< reco::PFCandidateCollection >::merg_and_put ( edm::Event iEvent,
std::string  instance,
std::vector< edm::EDGetTokenT< reco::PFCandidateCollection >> &  to_merge 
)
private

Definition at line 425 of file TrackMergeremb.cc.

References HLT_2024v14_cff::distance, l1ctLayer1_cff::dr, generator_cfi::drMin, PVValHelper::dx, PVValHelper::dy, PVValHelper::dz, iEvent, instance, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, eostools::move(), and mathSSE::sqrt().

426  {
427  std::unique_ptr<reco::PFCandidateCollection> outTracks = std::make_unique<reco::PFCandidateCollection>();
428 
429  edm::Handle<TrackToTrackMapnew> track_ref_map;
430  iEvent.getByToken(inputs_fixtrackrefs_, track_ref_map);
431 
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) {
436  reco::TrackRef trackRef(track_new_col, abc);
437  simple_track_to_track_map[trackRef] =
438  trackRef; // catch the case, where a seed ctf track could already be updated, such that the update doesn't happen again
439  simple_track_to_track_map[((*track_ref_map)[trackRef])[0]] = trackRef;
440  }
441 
442  edm::Handle<GsfTrackToTrackMapnew> gsftrack_ref_map;
443  iEvent.getByToken(inputs_fixgsftrackrefs_, gsftrack_ref_map);
444 
445  edm::Handle<reco::GsfTrackCollection> gsftrack_new_col;
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) {
449  reco::GsfTrackRef gsfTrackRef(gsftrack_new_col, abc);
450  simple_gsftrack_to_gsftrack_map[((*gsftrack_ref_map)[gsfTrackRef])[0]] = gsfTrackRef;
451  }
452 
454  iEvent.getByToken(inputs_fixmurefs_, muon_ref_map);
455 
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) {
460  reco::MuonRef muRef(muon_new_col, abc);
461  simple_mu_to_mu_map[(*muon_ref_map)[muRef]] = muRef;
462  }
463 
464  // used for photon matching
466  iEvent.getByToken(inputs_SC_, sCs);
467  auto bSc = sCs->cbegin();
468  auto eSc = sCs->cend();
469 
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) {
474  outTracks->push_back(reco::PFCandidate(*it));
475  if (it->trackRef().isNonnull() && outTracks->back().charge()) {
476  outTracks->back().setTrackRef(simple_track_to_track_map[it->trackRef()]);
477  }
478  if (it->gsfTrackRef().isNonnull()) {
479  outTracks->back().setGsfTrackRef(simple_gsftrack_to_gsftrack_map[it->gsfTrackRef()]);
480  }
481  if (it->superClusterRef().isNonnull()) {
482  const reco::SuperClusterRef &pfScRef(it->superClusterRef());
483 
484  float dx, dy, dz, dr;
485  float drMin = 10.0; // also used as treshold for matching
486  reco::SuperClusterRef ccrefMin;
487  for (auto sc = bSc; sc != eSc; ++sc) {
488  const reco::SuperClusterRef &scRef(reco::SuperClusterRef(sCs, std::distance(bSc, sc)));
489  dx = fabs(scRef->x() - pfScRef->x());
490  dy = fabs(scRef->y() - pfScRef->y());
491  dz = fabs(scRef->z() - pfScRef->z());
492  dr = sqrt(dx * dx + dy * dy + dz * dz);
493  if (dr < drMin) {
494  drMin = dr;
495  outTracks->back().setSuperClusterRef(scRef);
496  }
497  }
498  }
499  if (it->muonRef().isNonnull()) {
500  outTracks->back().setMuonRef(simple_mu_to_mu_map[it->muonRef()]);
501  }
502  }
503  } // end merge
504 
505  iEvent.put(std::move(outTracks), instance);
506 }
static PFTauRenderPlugin instance
edm::EDGetTokenT< reco::MuonToMuonMap > inputs_fixmurefs_
edm::EDGetTokenT< reco::TrackCollection > inputs_fixtrackcol_
edm::EDGetTokenT< reco::SuperClusterCollection > inputs_SC_
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:23
edm::EDGetTokenT< GsfTrackToTrackMapnew > inputs_fixgsftrackrefs_
edm::EDGetTokenT< reco::GsfTrackCollection > inputs_fixgsftrackcol_
edm::EDGetTokenT< reco::MuonCollection > inputs_fixmucol_
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:41
edm::EDGetTokenT< TrackToTrackMapnew > inputs_fixtrackrefs_
def move(src, dest)
Definition: eostools.py:511

◆ produce()

template<typename T1 >
void TrackMergeremb< T1 >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 73 of file TrackMergeremb.cc.

References edm::EventSetup::getData(), and iEvent.

73  {
75  for (auto input_ : inputs_) {
76  merg_and_put(iEvent, input_.first, input_.second);
77 
78  } // end instance
79 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
std::map< std::string, std::vector< edm::EDGetTokenT< TrackCollectionemb > > > inputs_
void merg_and_put(edm::Event &, std::string, std::vector< edm::EDGetTokenT< TrackCollectionemb >> &)
edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > globalGeomToken_
int iEvent
Definition: GenABIO.cc:224
const GlobalTrackingGeometry * geometry_

◆ willconsume() [1/4]

template<typename T1 >
void TrackMergeremb< T1 >::willconsume ( const edm::ParameterSet iConfig)
private

Definition at line 87 of file TrackMergeremb.cc.

87 {}

◆ willconsume() [2/4]

template<>
void TrackMergeremb< reco::GsfTrackCollection >::willconsume ( const edm::ParameterSet iConfig)
private

Definition at line 167 of file TrackMergeremb.cc.

References ProducerED_cfi::InputTag.

167  {
168  // track refs for trackerdriven seeds
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"));
173 }
edm::EDGetTokenT< edm::View< TrajectorySeed > > inputs_rElectronMergedSeedViews_
edm::EDGetTokenT< reco::ElectronSeedCollection > inputs_rElectronMergedSeeds_
edm::EDGetTokenT< reco::TrackCollection > inputs_fixtrackcol_
edm::EDGetTokenT< TrackToTrackMapnew > inputs_fixtrackrefs_

◆ willconsume() [3/4]

template<>
void TrackMergeremb< reco::MuonCollection >::willconsume ( const edm::ParameterSet iConfig)
private

Definition at line 319 of file TrackMergeremb.cc.

References isoTrack_cff::alias, and ProducerED_cfi::InputTag.

319  {
320  if (alias == "displacedMuons1stStep") {
321  inputs_fixtrackrefs_ = consumes<TrackToTrackMapnew>(edm::InputTag("displacedTracks"));
322  inputs_fixtrackcol_ = consumes<reco::TrackCollection>(edm::InputTag("displacedTracks"));
323  } else {
324  inputs_fixtrackrefs_ = consumes<TrackToTrackMapnew>(edm::InputTag("generalTracks"));
325  inputs_fixtrackcol_ = consumes<reco::TrackCollection>(edm::InputTag("generalTracks"));
326  }
327 }
std::string alias
edm::EDGetTokenT< reco::TrackCollection > inputs_fixtrackcol_
edm::EDGetTokenT< TrackToTrackMapnew > inputs_fixtrackrefs_

◆ willconsume() [4/4]

template<>
void TrackMergeremb< reco::PFCandidateCollection >::willconsume ( const edm::ParameterSet iConfig)
private

Definition at line 414 of file TrackMergeremb.cc.

References ProducerED_cfi::InputTag.

414  {
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"));
422 }
edm::EDGetTokenT< reco::MuonToMuonMap > inputs_fixmurefs_
edm::EDGetTokenT< reco::TrackCollection > inputs_fixtrackcol_
edm::EDGetTokenT< reco::SuperClusterCollection > inputs_SC_
edm::EDGetTokenT< GsfTrackToTrackMapnew > inputs_fixgsftrackrefs_
edm::EDGetTokenT< reco::GsfTrackCollection > inputs_fixgsftrackcol_
edm::EDGetTokenT< reco::MuonCollection > inputs_fixmucol_
edm::EDGetTokenT< TrackToTrackMapnew > inputs_fixtrackrefs_

◆ willproduce() [1/5]

template<typename T1 >
void TrackMergeremb< T1 >::willproduce ( std::string  instance,
std::string  alias 
)
private

Definition at line 82 of file TrackMergeremb.cc.

References instance.

82  {
83  produces<TrackCollectionemb>(instance);
84 }
static PFTauRenderPlugin instance

◆ willproduce() [2/5]

template<>
void TrackMergeremb< reco::TrackCollection >::willproduce ( std::string  instance,
std::string  alias 
)
private

Definition at line 111 of file TrackMergeremb.cc.

References isoTrack_cff::alias, and instance.

111  {
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>();
116 }
std::string alias
static PFTauRenderPlugin instance

◆ willproduce() [3/5]

template<>
void TrackMergeremb< reco::GsfTrackCollection >::willproduce ( std::string  instance,
std::string  alias 
)
private

Definition at line 176 of file TrackMergeremb.cc.

References isoTrack_cff::alias, and instance.

176  {
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>();
182 }
std::string alias
static PFTauRenderPlugin instance

◆ willproduce() [4/5]

template<>
void TrackMergeremb< reco::MuonCollection >::willproduce ( std::string  instance,
std::string  alias 
)
private

Definition at line 301 of file TrackMergeremb.cc.

301  {
302  produces<reco::MuonCollection>();
303  produces<reco::CaloMuonCollection>();
304  produces<reco::MuonTimeExtraMap>("combined");
305  produces<reco::MuonTimeExtraMap>("dt");
306  produces<reco::MuonTimeExtraMap>("csc");
307 
308  // todo make this configurable (or not )
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");
314 
315  produces<reco::MuonToMuonMap>();
316 }

◆ willproduce() [5/5]

template<>
void TrackMergeremb< reco::PFCandidateCollection >::willproduce ( std::string  instance,
std::string  alias 
)
private

Definition at line 409 of file TrackMergeremb.cc.

References instance.

409  {
410  produces<reco::PFCandidateCollection>(instance);
411 }
static PFTauRenderPlugin instance

Member Data Documentation

◆ alias

template<typename T1 >
std::string TrackMergeremb< T1 >::alias
private

Definition at line 83 of file TrackMergeremb.h.

◆ geometry_

template<typename T1 >
const GlobalTrackingGeometry* TrackMergeremb< T1 >::geometry_ = nullptr
private

Definition at line 68 of file TrackMergeremb.h.

◆ globalGeomToken_

template<typename T1 >
edm::ESGetToken<GlobalTrackingGeometry, GlobalTrackingGeometryRecord> TrackMergeremb< T1 >::globalGeomToken_
private

Definition at line 67 of file TrackMergeremb.h.

◆ inputs_

template<typename T1 >
std::map<std::string, std::vector<edm::EDGetTokenT<TrackCollectionemb> > > TrackMergeremb< T1 >::inputs_
private

Definition at line 61 of file TrackMergeremb.h.

◆ inputs_fixgsftrackcol_

template<typename T1 >
edm::EDGetTokenT<reco::GsfTrackCollection> TrackMergeremb< T1 >::inputs_fixgsftrackcol_
private

Definition at line 74 of file TrackMergeremb.h.

◆ inputs_fixgsftrackrefs_

template<typename T1 >
edm::EDGetTokenT<GsfTrackToTrackMapnew> TrackMergeremb< T1 >::inputs_fixgsftrackrefs_
private

Definition at line 73 of file TrackMergeremb.h.

◆ inputs_fixmucol_

template<typename T1 >
edm::EDGetTokenT<reco::MuonCollection> TrackMergeremb< T1 >::inputs_fixmucol_
private

Definition at line 77 of file TrackMergeremb.h.

◆ inputs_fixmurefs_

template<typename T1 >
edm::EDGetTokenT<reco::MuonToMuonMap> TrackMergeremb< T1 >::inputs_fixmurefs_
private

Definition at line 76 of file TrackMergeremb.h.

◆ inputs_fixtrackcol_

template<typename T1 >
edm::EDGetTokenT<reco::TrackCollection> TrackMergeremb< T1 >::inputs_fixtrackcol_
private

Definition at line 71 of file TrackMergeremb.h.

◆ inputs_fixtrackrefs_

template<typename T1 >
edm::EDGetTokenT<TrackToTrackMapnew> TrackMergeremb< T1 >::inputs_fixtrackrefs_
private

Definition at line 70 of file TrackMergeremb.h.

◆ inputs_qual_

template<typename T1 >
std::map<std::string, std::vector<edm::EDGetTokenT<edm::ValueMap<reco::MuonQuality> > > > TrackMergeremb< T1 >::inputs_qual_
private

Definition at line 62 of file TrackMergeremb.h.

◆ inputs_rElectronMergedSeeds_

template<typename T1 >
edm::EDGetTokenT<reco::ElectronSeedCollection> TrackMergeremb< T1 >::inputs_rElectronMergedSeeds_
private

Definition at line 80 of file TrackMergeremb.h.

◆ inputs_rElectronMergedSeedViews_

template<typename T1 >
edm::EDGetTokenT<edm::View<TrajectorySeed> > TrackMergeremb< T1 >::inputs_rElectronMergedSeedViews_
private

Definition at line 81 of file TrackMergeremb.h.

◆ inputs_SC_

template<typename T1 >
edm::EDGetTokenT<reco::SuperClusterCollection> TrackMergeremb< T1 >::inputs_SC_
private

Definition at line 79 of file TrackMergeremb.h.