27 LogTrace(
"Muon|RecoMuon|L3TkMuonProducer") <<
" constructor called";
31 trackToken_ = consumes<reco::TrackCollection>(theL3CollectionLabel);
32 produces<TrackCollection>();
33 produces<TrackExtraCollection>();
34 produces<TrackingRecHitCollection>();
39 this->mayConsume<L3MuonTrajectorySeedCollection>(
47 LogTrace(
"Muon|RecoMuon|L3TkMuonProducer") <<
" L3TkMuonProducer destructor called";
60 if (
r1.begin()->geographicalId() !=
r2.begin()->geographicalId())
63 for (
auto i1 =
r1.begin(), i2 =
r2.begin(); i1 !=
r1.end() && i2 !=
r2.end(); ++i1, ++i2) {
72 for (
unsigned int i = 0;
i != v.size(); ++
i) {
75 ss <<
"track with ref: " << v[
i].id().id() <<
":" << v[
i].key() <<
" and pT: " << v[
i]->pt()
76 <<
" with seedRef: " << v[
i]->seedRef().id().id() <<
":" << v[
i]->seedRef().key();
83 for (
unsigned int i = 0;
i != v.size(); ++
i) {
86 ss <<
"seed ref: " << v[
i].id().id() <<
":" << v[
i].key();
87 if (v[
i]->l2Track().isNull())
88 ss <<
" and pT: " << v[
i]->l1Particle()->pt() <<
" of L1: " << v[
i]->l1Particle().id().id() <<
":"
89 << v[
i]->l1Particle().key();
91 ss <<
" and pT: " << v[
i]->l2Track()->pt() <<
" of L2: " << v[
i]->l2Track().id().id() <<
":"
92 << v[
i]->l2Track().key();
99 ss <<
" seed ref: " << s.
id().
id() <<
":" << s.
key() <<
" has " << s->nHits() <<
"rechits";
100 for (
auto const&
hit : s->recHits()) {
101 ss <<
"\n detId: " << std::hex <<
hit.geographicalId().rawId() <<
std::dec <<
" position: " <<
hit.localPosition()
102 <<
" and error: " <<
hit.localPositionError();
109 const string metname =
"Muon|RecoMuon|L3TkMuonProducer";
112 LogDebug(metname) <<
" Taking the L3/GLB muons: " << theL3CollectionLabel.label();
114 event.getByToken(trackToken_, tracks);
119 unsigned int maxI = tracks->size();
120 bool gotL3seeds =
false;
124 vector<TrackRef> orderedTrackTracks(maxI);
125 for (
unsigned int i = 0;
i !=
maxI;
i++)
127 LogDebug(metname) <<
"vector of L3 tracks before ordering:\n" <<
printvector(orderedTrackTracks);
129 sort(orderedTrackTracks.begin(), orderedTrackTracks.end(), trackRefBypT);
130 LogDebug(metname) <<
"vector of L3 tracks after ordering:\n" <<
printvector(orderedTrackTracks);
132 for (
unsigned int i = 0;
i !=
maxI;
i++) {
136 vector<SeedRef> allPossibleOrderedLx;
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();
148 event.getByLabel(l3seedsTag, l3seeds);
150 LogDebug(metname) <<
"got seeds handle from: " << l3seedsTag;
153 for (
unsigned int iS = 0; iS != l3seeds->size(); ++iS) {
156 if (l3seedRef.
key() == iS)
159 if (sharedSeed(seed, thisSeed)) {
160 SeedRef thisSharedSeedRef(l3seeds, iS);
161 LogDebug(metname) <<
"shared seeds: \n"
164 <<
"\nadding ANOTHER seed ref: " << thisSharedSeedRef.
id().
id() <<
":"
165 << thisSharedSeedRef.
key() <<
" for this tracker track: " << tk.
id().
id() <<
":" << tk.
key();
167 allPossibleOrderedLx.push_back(thisSharedSeedRef);
173 LogDebug(metname) <<
"list of possible Lx objects for tracker track: " << tk.
id().
id() <<
":" << tk.
key()
174 <<
" before ordering\n"
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"
181 for (
unsigned int iL = 0; iL != allPossibleOrderedLx.size(); ++iL) {
182 SeedRef thisRef = allPossibleOrderedLx[iL];
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()) {
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();
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);
210 auto outTracks = std::make_unique<TrackCollection>(LXtoL3s.size());
211 auto outTrackExtras = std::make_unique<TrackExtraCollection>(LXtoL3s.size());
213 auto outRecHits = std::make_unique<TrackingRecHitCollection>();
216 LogDebug(metname) <<
"reading the map to make " << LXtoL3s.size() <<
"products.";
218 LXtoL3sMap::iterator
f = LXtoL3s.begin();
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);
226 LogDebug(metname) <<
"copy the trackExtra too, and change the seedref";
242 LogDebug(metname) <<
"copy the hits too";
243 unsigned int iRH = 0;
245 outRecHits->push_back((*hit)->clone());
247 (*outTrackExtras)[
i].setHits(rHits, 0, iRH);
250 LogDebug(metname) <<
"made: " << outTracks->size() <<
" tracks, " << outTrackExtras->size() <<
" extras and "
251 << outRecHits->size() <<
" rechits.";
258 LogDebug(metname) <<
" Event loaded"
259 <<
"================================";
PropagationDirection direction() const
uint16_t *__restrict__ id
string printseed(const L3TkMuonProducer::SeedRef &s)
const std::string metname
bool innerOk() const
return true if the innermost hit is valid
auto const & tracks
cannot be loose
edm::Ref< TrackExtraCollection > TrackExtraRef
persistent reference to a TrackExtra
std::string const & processName() const
key_type key() const
Accessor for product key.
const math::XYZPoint & outerPosition() const
position of the outermost hit
ProductID id() const
Accessor for product ID.
bool sharedSeed(const L3MuonTrajectorySeed &s1, const L3MuonTrajectorySeed &s2)
const math::XYZPoint & innerPosition() const
position of the innermost hit
std::map< pseudoRef, std::pair< reco::TrackRef, SeedRef > > LXtoL3sMap
void produce(edm::Event &, const edm::EventSetup &) override
produce candidates
std::string const & productInstanceName() const
std::string const & moduleLabel() const
std::string const & productInstanceName() const
CovarianceMatrix outerStateCovariance() const
outermost trajectory state curvilinear errors
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
TypeID unwrappedTypeID() const
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
L3TkMuonProducer(const edm::ParameterSet &)
constructor with config
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
RecHitRange recHits() const
std::vector< TrackExtra > TrackExtraCollection
collection of TrackExtra objects
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
bool outerOk() const
return true if the outermost hit is valid
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
CovarianceMatrix innerStateCovariance() const
innermost trajectory state curvilinear errors
T getParameter(std::string const &) const
std::pair< unsigned int, unsigned int > pseudoRef
~L3TkMuonProducer() override
destructor
unsigned int nHits() const
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
std::string const & processName() const
std::string const & moduleLabel() const
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
string printvector(const vector< TrackRef > &v)
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.