6 #define TRACK_SORT 1 // just use all hits from inner track, then append from outer outside it
7 #define DET_SORT 0 // sort hits using global position of detector
8 #define HIT_SORT 0 // sort hits using global position of hit
15 #define DPRINT(x) std::cout << x << ": "
16 #define PRINT std::cout
18 #define DPRINT(x) LogTrace(x)
19 #define PRINT LogTrace("")
23 : useInnermostState_(iConfig.getParameter<bool>(
"useInnermostState")),
25 theBuilderName(iConfig.getParameter<std::
string>(
"ttrhBuilderName")),
45 << inner.
eta() <<
'/' << outer.
eta() << std::endl;
47 std::vector<const TrackingRecHit *> hits;
49 DPRINT(
"TrackMerger") <<
"Inner track hits: " << std::endl;
51 hits.push_back(&**it);
53 DetId id(hits.back()->geographicalId());
54 PRINT <<
" subdet " <<
id.subdetId() <<
" layer " <<
theTrkTopo->layer(
id) <<
" valid "
55 << hits.back()->
isValid() <<
" detid: " <<
id() << std::endl;
58 DPRINT(
"TrackMerger") <<
"Outer track hits: " << std::endl;
62 DetId lastId(hits.back()->geographicalId());
64 unsigned int lastLayer =
theTrkTopo->layer(lastId);
68 int thisSubdet =
id.subdetId();
69 if (thisSubdet > lastSubdet || (thisSubdet == lastSubdet &&
theTrkTopo->layer(
id) > lastLayer)) {
71 PRINT <<
" adding subdet " <<
id.subdetId() <<
" layer " <<
theTrkTopo->layer(
id) <<
" valid "
72 << hit->
isValid() <<
" detid: " <<
id() << std::endl;
74 PRINT <<
" skipping subdet " << thisSubdet <<
" layer " <<
theTrkTopo->layer(
id) <<
" valid "
75 << hit->
isValid() <<
" detid: " <<
id() << std::endl;
91 unsigned int nhits = hits.size();
97 std::reverse(hits.begin(), hits.end());
103 for (
auto hit : hits)
148 size_t nHitsFirstTrack = hits.size();
155 PRINT <<
" subdet " <<
id.subdetId() <<
" layer " <<
theTrkTopo->layer(
id) <<
" valid " << valid
156 <<
" detid: " <<
id() << std::endl;
158 for (
auto hit2 : hits) {
160 if (iHit > nHitsFirstTrack)
162 DetId id2 = hit2->geographicalId();
163 if (
id.subdetId() != id2.
subdetId())
168 PRINT <<
" discared as duplicate of other hit" <<
id() << std::endl;
172 if (hit2->isValid() && !valid) {
173 PRINT <<
" replacing old invalid hit on detid " << id2() << std::endl;
178 PRINT <<
" discared as additional hit on layer that already contains hit with detid " <<
id() << std::endl;
189 const std::vector<const TrackingRecHit *> &hits,
192 unsigned int nhits = hits.size();
193 std::vector<TransientTrackingRecHit::RecHitPointer> ttrh(nhits);
194 for (
unsigned int i = 0;
i <
nhits; ++
i)
197 for (
const auto &
hit : ttrh)
206 return (p2 - p1).dot(
dir_) > 0;
211 GlobalPoint p1 = hit1->isValid() ? hit1->globalPosition() : hit1->det()->position();
212 GlobalPoint p2 = hit2->isValid() ? hit2->globalPosition() : hit2->det()->position();
213 return (p2 - p1).dot(
dir_) > 0;
edm::ESHandle< TrackerTopology > theTrkTopo
tuple ret
prodAgent to be discontinued
Point3DBase< Scalar, LocalTag > LocalPoint
const TrackerGeometry * geom_
TrackCandidate merge(const reco::Track &inner, const reco::Track &outer, DuplicateTrackType duplicateType) const
uint16_t *__restrict__ id
size_t recHitsSize() const
Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits)...
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
void sortByHitPosition(const GlobalVector &v, const std::vector< const TrackingRecHit * > &hits, TrackCandidate::RecHitContainer &ownHits) const
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
edm::ESGetToken< TransientTrackingRecHitBuilder, TransientRecHitRecord > builderToken_
const Vector & momentum() const
track momentum vector
const math::XYZPoint & outerPosition() const
position of the outermost hit
void addSecondTrackHits(std::vector< const TrackingRecHit * > &hits, const reco::Track &outer) const
void init(const edm::EventSetup &iSetup)
bool operator()(const TransientTrackingRecHit::RecHitPointer &hit1, const TransientTrackingRecHit::RecHitPointer &hit2) const
const math::XYZPoint & innerPosition() const
position of the innermost hit
TrackAlgorithm algo() const
bool operator()(const TrackingRecHit *hit1, const TrackingRecHit *hit2) const
double eta() const
pseudorapidity of momentum vector
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
Abs< T >::type abs(const T &t)
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
void setStopReason(uint8_t value)
const TrackerGeomDet * idToDet(DetId) const override
std::shared_ptr< TrackingRecHit const > RecHitPointer
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magFieldToken_
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
XYZVectorD XYZVector
spatial vector with cartesian internal representation
edm::ESHandle< TransientTrackingRecHitBuilder > theBuilder
TrackMerger(const edm::ParameterSet &iConfig, edm::ConsumesCollector)
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geometryToken_
DetId geographicalId() const
edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > trackerTopoToken_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
edm::ESHandle< MagneticField > theMagField
edm::ESHandle< TrackerGeometry > theGeometry
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.