11 #include <boost/foreach.hpp>
12 #define foreach BOOST_FOREACH
14 #define TRACK_SORT 1 // just use all hits from inner track, then append from outer outside it
15 #define DET_SORT 0 // sort hits using global position of detector
16 #define HIT_SORT 0 // sort hits using global position of hit
20 useInnermostState_(iConfig.getParameter<bool>(
"useInnermostState")),
21 debug_(iConfig.getUntrackedParameter<bool>(
"debug",
false)),
22 theBuilderName(iConfig.getParameter<std::
string>(
"ttrhBuilderName"))
40 std::vector<const TrackingRecHit *> hits;
44 hits.push_back(&**it);
46 DetId id(hits.back()->geographicalId());
47 std::cout <<
" subdet " <<
id.subdetId() <<
" layer " <<
theTrkTopo->layer(
id) <<
" valid " << hits.back()->
isValid() <<
" detid: " << id() << std::endl;
53 DetId lastId(hits.back()->geographicalId());
55 unsigned int lastLayer =
theTrkTopo->layer(lastId);
60 if (thisSubdet > lastSubdet || (thisSubdet == lastSubdet &&
theTrkTopo->layer(
id) > lastLayer)) {
62 if (
debug_)
std::cout <<
" adding subdet " <<
id.subdetId() <<
" layer " <<
theTrkTopo->layer(
id) <<
" valid " << hit->
isValid() <<
" detid: " << id() << std::endl;
64 if (
debug_)
std::cout <<
" skipping subdet " << thisSubdet <<
" layer " <<
theTrkTopo->layer(
id) <<
" valid " << hit->
isValid() <<
" detid: " << id() << std::endl;
68 size_t nHitsFirstTrack = hits.size();
75 if (
debug_)
std::cout <<
" subdet " <<
id.subdetId() <<
" layer " <<
theTrkTopo->layer(
id) <<
" valid " << valid <<
" detid: " << id() << std::endl;
78 ++iHit;
if (iHit > nHitsFirstTrack)
break;
80 if (
id.subdetId() != id2.
subdetId())
continue;
83 if (
debug_)
std::cout <<
" discared as duplicate of other hit" << id() << std::endl;
87 if (
debug_)
std::cout <<
" replacing old invalid hit on detid " << id2() << std::endl;
88 hit2 = hit; shared =
true;
break;
90 if (
debug_)
std::cout <<
" discared as additional hit on layer that already contains hit with detid " << id() << std::endl;
103 unsigned int nhits = hits.
size();
120 std::vector<TransientTrackingRecHit::RecHitPointer> ttrh(nhits);
121 for (
unsigned int i = 0;
i < nhits; ++
i) ttrh[
i] =
theBuilder->build(hits[
i]);
166 return (p2 - p1).dot(
dir_) > 0;
171 GlobalPoint p1 = hit1->isValid() ? hit1->globalPosition() : hit1->det()->position();
172 GlobalPoint p2 = hit2->isValid() ? hit2->globalPosition() : hit2->det()->position();
173 return (p2 - p1).dot(
dir_) > 0;
edm::ESHandle< TrackerTopology > theTrkTopo
const TrackerGeometry * geom_
std::string theBuilderName
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.
virtual bool sharesInput(const TrackingRecHit *other, SharedInputType what) const
const Vector & momentum() const
track momentum vector
const math::XYZPoint & outerPosition() const
position of the outermost hit
void init(const edm::EventSetup &iSetup)
TrackCandidate merge(const reco::Track &inner, const reco::Track &outer) const
bool operator()(const TransientTrackingRecHit::RecHitPointer &hit1, const TransientTrackingRecHit::RecHitPointer &hit2) const
const math::XYZPoint & innerPosition() const
position of the innermost hit
bool operator()(const TrackingRecHit *hit1, const TrackingRecHit *hit2) const
unsigned int outerDetId() const
DetId of the detector on which surface the outermost state is located.
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
std::shared_ptr< TrackingRecHit const > RecHitPointer
const math::XYZVector & outerMomentum() const
momentum vector at the outermost hit position
XYZVectorD XYZVector
spatial vector with cartesian internal representation
edm::ESHandle< TransientTrackingRecHitBuilder > theBuilder
const math::XYZVector & innerMomentum() const
momentum vector at the innermost hit position
DetId geographicalId() const
volatile std::atomic< bool > shutdown_flag false
TrackMerger(const edm::ParameterSet &iConfig)
unsigned int innerDetId() const
DetId of the detector on which surface the innermost state is located.
edm::ESHandle< MagneticField > theMagField
edm::ESHandle< TrackerGeometry > theGeometry
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection
virtual const TrackerGeomDet * idToDet(DetId) const
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.