CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
L3TkMuonProducer Class Reference

#include <L3TkMuonProducer.h>

Inheritance diagram for L3TkMuonProducer:
edm::stream::EDProducer<>

Public Types

typedef edm::Ref< L3MuonTrajectorySeedCollectionSeedRef
 
- 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
 

Public Member Functions

 L3TkMuonProducer (const edm::ParameterSet &)
 constructor with config More...
 
void produce (edm::Event &, const edm::EventSetup &) override
 produce candidates More...
 
 ~L3TkMuonProducer () override
 destructor More...
 
- 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 std::map< pseudoRef, std::pair< reco::TrackRef, SeedRef > > LXtoL3sMap
 
typedef std::pair< unsigned int, unsigned int > pseudoRef
 

Private Member Functions

pseudoRef makePseudoRef (const L3MuonTrajectorySeed &s)
 
bool sharedSeed (const L3MuonTrajectorySeed &s1, const L3MuonTrajectorySeed &s2)
 

Static Private Member Functions

static bool seedRefBypT (const SeedRef &s1, const SeedRef &s2)
 
static bool trackRefBypT (const reco::TrackRef &t1, const reco::TrackRef &t2)
 

Private Attributes

edm::InputTag theL3CollectionLabel
 
edm::EDGetTokenT< reco::TrackCollectiontrackToken_
 

Detailed Description

This module creates a skimed list of reco::Track (pointing to the original TrackExtra and TrackingRecHitOwnedVector One highest pT track per L1/L2 is selected, requiring some quality.

Author
J-R Vlimant.

Definition at line 27 of file L3TkMuonProducer.h.

Member Typedef Documentation

◆ LXtoL3sMap

typedef std::map<pseudoRef, std::pair<reco::TrackRef, SeedRef> > L3TkMuonProducer::LXtoL3sMap
private

Definition at line 47 of file L3TkMuonProducer.h.

◆ pseudoRef

typedef std::pair<unsigned int, unsigned int> L3TkMuonProducer::pseudoRef
private

Definition at line 46 of file L3TkMuonProducer.h.

◆ SeedRef

Definition at line 38 of file L3TkMuonProducer.h.

Constructor & Destructor Documentation

◆ L3TkMuonProducer()

L3TkMuonProducer::L3TkMuonProducer ( const edm::ParameterSet parameterSet)

constructor with config

Definition at line 26 of file L3TkMuonProducer.cc.

References edm::ParameterSet::getParameter(), l1ctLayer2EG_cff::id, LogTrace, edm::BranchDescription::moduleLabel(), edm::parameterSet(), edm::BranchDescription::processName(), edm::BranchDescription::productInstanceName(), and edm::BranchDescription::unwrappedTypeID().

26  {
27  LogTrace("Muon|RecoMuon|L3TkMuonProducer") << " constructor called";
28 
29  // StandAlone Collection Label
31  trackToken_ = consumes<reco::TrackCollection>(theL3CollectionLabel);
32  produces<TrackCollection>();
33  produces<TrackExtraCollection>();
34  produces<TrackingRecHitCollection>();
35 
36  callWhenNewProductsRegistered([this](const edm::BranchDescription& iBD) {
38  if (iBD.unwrappedTypeID() == id) {
39  this->mayConsume<L3MuonTrajectorySeedCollection>(
41  }
42  });
43 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TypeID unwrappedTypeID() const
std::string const & processName() const
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
#define LogTrace(id)
std::string const & productInstanceName() const
edm::EDGetTokenT< reco::TrackCollection > trackToken_
edm::InputTag theL3CollectionLabel
std::string const & moduleLabel() const

◆ ~L3TkMuonProducer()

L3TkMuonProducer::~L3TkMuonProducer ( )
override

destructor

Definition at line 46 of file L3TkMuonProducer.cc.

References LogTrace.

46  {
47  LogTrace("Muon|RecoMuon|L3TkMuonProducer") << " L3TkMuonProducer destructor called";
48 }
#define LogTrace(id)

Member Function Documentation

◆ makePseudoRef()

pseudoRef L3TkMuonProducer::makePseudoRef ( const L3MuonTrajectorySeed s)
inlineprivate

Definition at line 49 of file L3TkMuonProducer.h.

References edm::ProductID::id(), edm::Ref< C, T, F >::id(), edm::Ref< C, T, F >::isNull(), edm::Ref< C, T, F >::key(), and alignCSCRings::s.

49  {
50  reco::TrackRef l2ref = s.l2Track();
51  if (l2ref.isNull()) {
52  l1extra::L1MuonParticleRef l1ref = s.l1Particle();
53  return std::make_pair(l1ref.id().id(), l1ref.key());
54  } else
55  return std::make_pair(l2ref.id().id(), l2ref.key());
56  }
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
key_type key() const
Accessor for product key.
Definition: Ref.h:250
bool isNull() const
Checks for null.
Definition: Ref.h:235
ProductIndex id() const
Definition: ProductID.h:35

◆ produce()

void L3TkMuonProducer::produce ( edm::Event event,
const edm::EventSetup eventSetup 
)
override

produce candidates

reconstruct muons

Definition at line 108 of file L3TkMuonProducer.cc.

References TrajectorySeed::direction(), f, mps_fire::i, edm::ProductID::id(), edm::Ref< C, T, F >::id(), reco::Track::innerDetId(), reco::Track::innerMomentum(), reco::Track::innerOk(), reco::Track::innerPosition(), reco::Track::innerStateCovariance(), edm::Ref< C, T, F >::key(), LogDebug, findQualityFiles::maxI, metname, edm::StableProvenance::moduleLabel(), eostools::move(), reco::Track::outerDetId(), reco::Track::outerMomentum(), reco::Track::outerOk(), reco::Track::outerPosition(), reco::Track::outerStateCovariance(), printseed(), printvector(), edm::StableProvenance::processName(), edm::StableProvenance::productInstanceName(), reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), fileCollector::seed, jetUpdater_cfi::sort, and pwdgSkimBPark_cfi::tracks.

108  {
109  const string metname = "Muon|RecoMuon|L3TkMuonProducer";
110 
111  // Take the L3 container
112  LogDebug(metname) << " Taking the L3/GLB muons: " << theL3CollectionLabel.label();
114  event.getByToken(trackToken_, tracks);
115 
116  //make the LX->L3s pools
117  LXtoL3sMap LXtoL3s;
118 
119  unsigned int maxI = tracks->size();
120  bool gotL3seeds = false;
122 
123  //make a list of reference to tracker tracks
124  vector<TrackRef> orderedTrackTracks(maxI);
125  for (unsigned int i = 0; i != maxI; i++)
126  orderedTrackTracks[i] = TrackRef(tracks, i);
127  LogDebug(metname) << "vector of L3 tracks before ordering:\n" << printvector(orderedTrackTracks);
128  //order them in pT
129  sort(orderedTrackTracks.begin(), orderedTrackTracks.end(), trackRefBypT);
130  LogDebug(metname) << "vector of L3 tracks after ordering:\n" << printvector(orderedTrackTracks);
131  //loop over then
132  for (unsigned int i = 0; i != maxI; i++) {
133  TrackRef& tk = orderedTrackTracks[i];
134  SeedRef l3seedRef = tk->seedRef().castTo<SeedRef>();
135 
136  vector<SeedRef> allPossibleOrderedLx; // with identical hit-set
137  //add the direct relation
138  allPossibleOrderedLx.push_back(l3seedRef);
139  LogDebug(metname) << "adding the seed ref: " << l3seedRef.id().id() << ":" << l3seedRef.key()
140  << " for this tracker track: " << tk.id().id() << ":" << tk.key();
141 
142  //add the relations due to shared seeds
143  //check whether there is a "shared" seed in addition
144  if (!gotL3seeds) {
145  //need to fetch the handle from the ref
146  const edm::StableProvenance& seedsProv = event.getStableProvenance(l3seedRef.id());
147  edm::InputTag l3seedsTag(seedsProv.moduleLabel(), seedsProv.productInstanceName(), seedsProv.processName());
148  event.getByLabel(l3seedsTag, l3seeds);
149  gotL3seeds = true;
150  LogDebug(metname) << "got seeds handle from: " << l3seedsTag;
151  }
152  //loop the other seeds in the collection
153  for (unsigned int iS = 0; iS != l3seeds->size(); ++iS) {
154  const L3MuonTrajectorySeed& seed = (*l3seeds)[iS];
155  const L3MuonTrajectorySeed& thisSeed = *l3seedRef;
156  if (l3seedRef.key() == iS)
157  continue; //not care about this one
158  //compare this seed with the seed in the collection
159  if (sharedSeed(seed, thisSeed)) {
160  SeedRef thisSharedSeedRef(l3seeds, iS);
161  LogDebug(metname) << "shared seeds: \n"
162  << printseed(l3seedRef) << " and: \n"
163  << printseed(thisSharedSeedRef)
164  << "\nadding ANOTHER seed ref: " << thisSharedSeedRef.id().id() << ":"
165  << thisSharedSeedRef.key() << " for this tracker track: " << tk.id().id() << ":" << tk.key();
166  // edm::LogError(metname)<<" we have a shared seed right there.";
167  allPossibleOrderedLx.push_back(thisSharedSeedRef);
168  } //seed is shared
169  } //loop all other existing seed for overlaps
170 
171  //now you have the full list of Lx objects that have seed this tracker track.
172  // order the list in pT of Lx objects
173  LogDebug(metname) << "list of possible Lx objects for tracker track: " << tk.id().id() << ":" << tk.key()
174  << " before ordering\n"
175  << printvector(allPossibleOrderedLx);
176  sort(allPossibleOrderedLx.begin(), allPossibleOrderedLx.end(), seedRefBypT);
177  LogDebug(metname) << "list of possible Lx objects for tracker track: " << tk.id().id() << ":" << tk.key()
178  << " after ordering\n"
179  << printvector(allPossibleOrderedLx);
180  // assign this tracker track to the highest pT Lx.
181  for (unsigned int iL = 0; iL != allPossibleOrderedLx.size(); ++iL) {
182  SeedRef thisRef = allPossibleOrderedLx[iL];
183  pseudoRef ref = makePseudoRef(*thisRef);
184  LogDebug(metname) << "seed ref: " << thisRef.id().id() << ":" << thisRef.key()
185  << " transcribe to pseudoref: " << ref.first << ":" << ref.second;
186  LXtoL3sMap::iterator f = LXtoL3s.find(ref);
187  if (f != LXtoL3s.end()) {
188  //there's already an entry. because of the prior ordering in pT of the tracker track refs
189  // the track ref already there *has* a higher pT: this one cannot compete and should be assigned to the next Lx;
190  LogDebug(metname) << "this tracker track: " << tk.id().id() << ":" << tk.key() << " (" << tk->pt() << ")"
191  << "\n cannot compete in pT with track: " << f->second.first.id().id() << ":"
192  << f->second.first.key() << " (" << f->second.first->pt() << ")"
193  << "\n already assigned to pseudo ref: " << ref.first << ":" << ref.second
194  << " which corresponds to seedRef: " << f->second.second.id().id() << ":"
195  << f->second.second.key();
196  continue;
197  } else {
198  //there was no entry yet. make the assignement
199  LogDebug(metname) << "this tracker track: " << tk.id().id() << ":" << tk.key()
200  << " is assigned to pseudo ref: " << ref.first << ":" << ref.second
201  << " which corresponds to seedRef: " << thisRef.id().id() << ":" << thisRef.key();
202  LXtoL3s[ref] = std::make_pair(tk, thisRef);
203  //once assigned. break
204  break;
205  }
206  } //loop possible Lx for possible assignement
207  } //loop over ordered list of tracker track refs
208 
209  //prepare the output
210  auto outTracks = std::make_unique<TrackCollection>(LXtoL3s.size());
211  auto outTrackExtras = std::make_unique<TrackExtraCollection>(LXtoL3s.size());
212  reco::TrackExtraRefProd rTrackExtras = event.getRefBeforePut<TrackExtraCollection>();
213  auto outRecHits = std::make_unique<TrackingRecHitCollection>();
214  TrackingRecHitRefProd rHits = event.getRefBeforePut<TrackingRecHitCollection>();
215 
216  LogDebug(metname) << "reading the map to make " << LXtoL3s.size() << "products.";
217  //fill the collection from the map
218  LXtoL3sMap::iterator f = LXtoL3s.begin();
219  unsigned int i = 0;
220  for (; f != LXtoL3s.end(); ++f, ++i) {
221  LogDebug(metname) << "copy the track over, and make ref to extra";
222  const Track& trk = *(f->second.first);
223  (*outTracks)[i] = Track(trk);
224  (*outTracks)[i].setExtra(TrackExtraRef(rTrackExtras, i));
225 
226  LogDebug(metname) << "copy the trackExtra too, and change the seedref";
227  edm::RefToBase<TrajectorySeed> seedRef(f->second.second);
228  //do not use the copy constructor, otherwise the hit Ref are still the same
229  (*outTrackExtras)[i] = TrackExtra(trk.outerPosition(),
230  trk.outerMomentum(),
231  trk.outerOk(),
232  trk.innerPosition(),
233  trk.innerMomentum(),
234  trk.innerOk(),
235  trk.outerStateCovariance(),
236  trk.outerDetId(),
237  trk.innerStateCovariance(),
238  trk.innerDetId(),
239  seedRef->direction(),
240  seedRef);
241 
242  LogDebug(metname) << "copy the hits too";
243  unsigned int iRH = 0;
244  for (trackingRecHit_iterator hit = trk.recHitsBegin(); hit != trk.recHitsEnd(); ++hit, ++iRH) {
245  outRecHits->push_back((*hit)->clone());
246  }
247  (*outTrackExtras)[i].setHits(rHits, 0, iRH);
248  }
249 
250  LogDebug(metname) << "made: " << outTracks->size() << " tracks, " << outTrackExtras->size() << " extras and "
251  << outRecHits->size() << " rechits.";
252 
253  //put the collection in the event
254  LogDebug(metname) << "loading...";
255  event.put(std::move(outTracks));
256  event.put(std::move(outTrackExtras));
257  event.put(std::move(outRecHits));
258  LogDebug(metname) << " Event loaded"
259  << "================================";
260 }
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
Definition: Track.h:68
const math::XYZPoint & outerPosition() const
position of the outermost hit
Definition: Track.h:62
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
Definition: Track.h:65
string printseed(const L3TkMuonProducer::SeedRef &s)
const std::string metname
std::string const & productInstanceName() const
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
Definition: TrackExtraFwd.h:16
std::string const & label() const
Definition: InputTag.h:36
key_type key() const
Accessor for product key.
Definition: Ref.h:250
bool sharedSeed(const L3MuonTrajectorySeed &s1, const L3MuonTrajectorySeed &s2)
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
Definition: Track.h:71
std::map< pseudoRef, std::pair< reco::TrackRef, SeedRef > > LXtoL3sMap
static bool trackRefBypT(const reco::TrackRef &t1, const reco::TrackRef &t2)
static bool seedRefBypT(const SeedRef &s1, const SeedRef &s2)
std::string const & moduleLabel() const
std::string const & processName() const
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
double f[11][100]
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
Definition: Track.h:82
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
edm::Ref< L3MuonTrajectorySeedCollection > SeedRef
ProductIndex id() const
Definition: ProductID.h:35
bool innerOk() const
return true if the innermost hit is valid
Definition: Track.h:53
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
Definition: TrackExtraFwd.h:10
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:20
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Definition: Track.h:79
std::pair< unsigned int, unsigned int > pseudoRef
edm::EDGetTokenT< reco::TrackCollection > trackToken_
pseudoRef makePseudoRef(const L3MuonTrajectorySeed &s)
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
Definition: Track.h:59
edm::InputTag theL3CollectionLabel
const math::XYZPoint & innerPosition() const
position of the innermost hit
Definition: Track.h:56
string printvector(const vector< TrackRef > &v)
def move(src, dest)
Definition: eostools.py:511
bool outerOk() const
return true if the outermost hit is valid
Definition: Track.h:50
#define LogDebug(id)

◆ seedRefBypT()

static bool L3TkMuonProducer::seedRefBypT ( const SeedRef s1,
const SeedRef s2 
)
inlinestaticprivate

Definition at line 61 of file L3TkMuonProducer.h.

References edm::Ref< C, T, F >::isNull(), HLT_2022v15_cff::pt1, and HLT_2022v15_cff::pt2.

61  {
62  double pt1, pt2;
63  reco::TrackRef l2ref1 = s1->l2Track();
64  if (l2ref1.isNull())
65  pt1 = s1->l1Particle()->pt();
66  else
67  pt1 = l2ref1->pt();
68  reco::TrackRef l2ref2 = s2->l2Track();
69  if (l2ref2.isNull())
70  pt2 = s2->l1Particle()->pt();
71  else
72  pt2 = l2ref2->pt();
73  return (pt1 > pt2);
74  }
bool isNull() const
Checks for null.
Definition: Ref.h:235

◆ sharedSeed()

bool L3TkMuonProducer::sharedSeed ( const L3MuonTrajectorySeed s1,
const L3MuonTrajectorySeed s2 
)
private

Definition at line 50 of file L3TkMuonProducer.cc.

References TrackingRecHit::all, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, TrajectorySeed::nHits(), diffTwoXMLs::r2, and TrajectorySeed::recHits().

50  {
51  //quit right away on nH=0
52  if (s1.nHits() == 0 || s2.nHits() == 0)
53  return false;
54  //quit right away if not the same number of hits
55  if (s1.nHits() != s2.nHits())
56  return false;
57  auto const& r1 = s1.recHits();
58  auto const& r2 = s2.recHits();
59  //quit right away if first detId does not match. front exist because of ==0 ->quit test
60  if (r1.begin()->geographicalId() != r2.begin()->geographicalId())
61  return false;
62  //then check hit by hit if they are the same
63  for (auto i1 = r1.begin(), i2 = r2.begin(); i1 != r1.end() && i2 != r2.end(); ++i1, ++i2) {
64  if (!i1->sharesInput(&(*i2), TrackingRecHit::all))
65  return false;
66  }
67  return true;
68 }
RecHitRange recHits() const
unsigned int nHits() const

◆ trackRefBypT()

static bool L3TkMuonProducer::trackRefBypT ( const reco::TrackRef t1,
const reco::TrackRef t2 
)
inlinestaticprivate

Definition at line 76 of file L3TkMuonProducer.h.

References RandomServiceHelper::t1, and RandomServiceHelper::t2.

Member Data Documentation

◆ theL3CollectionLabel

edm::InputTag L3TkMuonProducer::theL3CollectionLabel
private

Definition at line 42 of file L3TkMuonProducer.h.

◆ trackToken_

edm::EDGetTokenT<reco::TrackCollection> L3TkMuonProducer::trackToken_
private

Definition at line 43 of file L3TkMuonProducer.h.