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<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache 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
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

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 25 of file L3TkMuonProducer.h.

Member Typedef Documentation

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

Definition at line 50 of file L3TkMuonProducer.h.

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

Definition at line 49 of file L3TkMuonProducer.h.

Definition at line 38 of file L3TkMuonProducer.h.

Constructor & Destructor Documentation

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

constructor with config

Definition at line 26 of file L3TkMuonProducer.cc.

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

26  {
27  LogTrace("Muon|RecoMuon|L3TkMuonProducer")<<" constructor called";
28 
29  // StandAlone Collection Label
30  theL3CollectionLabel = parameterSet.getParameter<InputTag>("InputObjects");
31  trackToken_ = consumes<reco::TrackCollection>(theL3CollectionLabel);
32  produces<TrackCollection>();
33  produces<TrackExtraCollection>();
34  produces<TrackingRecHitCollection>();
35 
36 
37 
38  callWhenNewProductsRegistered( [this](const edm::BranchDescription& iBD) {
40  if(iBD.unwrappedTypeID() == id) {
41  this->mayConsume<L3MuonTrajectorySeedCollection>(edm::InputTag{iBD.moduleLabel(), iBD.productInstanceName(),iBD.processName()} );
42  }
43  });
44 
45 
46 
47 }
T getParameter(std::string const &) const
std::string const & processName() const
std::string const & moduleLabel() const
std::string const & productInstanceName() const
TypeID unwrappedTypeID() const
#define LogTrace(id)
edm::EDGetTokenT< reco::TrackCollection > trackToken_
edm::InputTag theL3CollectionLabel
L3TkMuonProducer::~L3TkMuonProducer ( )
override

destructor

Definition at line 50 of file L3TkMuonProducer.cc.

References LogTrace.

50  {
51  LogTrace("Muon|RecoMuon|L3TkMuonProducer")<<" L3TkMuonProducer destructor called";
52 }
#define LogTrace(id)

Member Function Documentation

pseudoRef L3TkMuonProducer::makePseudoRef ( const L3MuonTrajectorySeed s)
inlineprivate

Definition at line 52 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(), L3MuonTrajectorySeed::l1Particle(), L3MuonTrajectorySeed::l2Track(), and indexGen::s2.

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

Definition at line 64 of file L3TkMuonProducer.h.

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

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

Definition at line 54 of file L3TkMuonProducer.cc.

References TrackingRecHit::all, TrajectorySeed::nHits(), diffTwoXMLs::r1, diffTwoXMLs::r2, and TrajectorySeed::recHits().

54  {
55  //quit right away on nH=0
56  if (s1.nHits()==0 || s2.nHits()==0) return false;
57  //quit right away if not the same number of hits
58  if (s1.nHits()!=s2.nHits()) return false;
62  TrajectorySeed::const_iterator & i1_e=r1.second,&i2_e=r2.second;
63  TrajectorySeed::const_iterator & i1_b=r1.first,&i2_b=r2.first;
64  //quit right away if first detId does not match. front exist because of ==0 ->quit test
65  if(i1_b->geographicalId() != i2_b->geographicalId()) return false;
66  //then check hit by hit if they are the same
67  for (i1=i1_b,i2=i2_b;i1!=i1_e && i2!=i2_e;++i1,++i2){
68  if (!i1->sharesInput(&(*i2),TrackingRecHit::all)) return false;
69  }
70  return true;
71 }
recHitContainer::const_iterator const_iterator
std::pair< const_iterator, const_iterator > range
range recHits() const
unsigned int nHits() const
static bool L3TkMuonProducer::trackRefBypT ( const reco::TrackRef t1,
const reco::TrackRef t2 
)
inlinestaticprivate

Definition at line 75 of file L3TkMuonProducer.h.

75  {
76  return (t1->pt()>t2->pt());
77  }

Member Data Documentation

edm::InputTag L3TkMuonProducer::theL3CollectionLabel
private

Definition at line 43 of file L3TkMuonProducer.h.

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

Definition at line 44 of file L3TkMuonProducer.h.