79 : theLayerMeasurements(nullptr),
80 theTrackTransformer(nullptr),
81 theRegionBuilder(nullptr),
83 theGlbRefitter(nullptr) {
168 if ((muonRecHits.size() > 1) &&
169 (muonRecHits.front()->globalPosition().mag() > muonRecHits.back()->globalPosition().mag())) {
173 for (
auto&& it : tkTrajs) {
175 LogTrace(
theCategory) <<
" Track p and pT " << it->trackerTrack()->p() <<
" " << it->trackerTrack()->pt();
176 if (it->trackerTrack()->p() <
thePCut || it->trackerTrack()->pt() <
thePtCut)
182 if (it->trackerTrack().isNonnull()) {
190 if (
std::abs(it->trackerTrack()->eta()) > 0.95 &&
std::abs(it->trackerTrack()->eta()) < 1.15 &&
191 it->trackerTrack()->pt() < 60) {
200 reverse(trackerRecHits.begin(), trackerRecHits.end());
206 if (it->trackerTrack()->seedRef().isAvailable())
207 tmpSeed = it->trackerTrack()->seedRef();
209 if (!innerTsos.isValid()) {
214 innerTsos.rescaleError(100.);
216 TC refitted0, refitted1;
217 std::unique_ptr<Trajectory> tkTrajectory;
220 if (!(it->trackerTrajectory() && it->trackerTrajectory()->isValid())) {
222 if (!refitted0.empty())
223 tkTrajectory = std::make_unique<Trajectory>(*(refitted0.begin()));
227 tkTrajectory = it->releaseTrackerTrajectory();
229 tkTrajectory->setSeedRef(tmpSeed);
233 allRecHits.insert(allRecHits.end(), muonRecHits.begin(), muonRecHits.end());
235 LogTrace(
theCategory) <<
" This track-sta refitted to " << refitted1.size() <<
" trajectories";
237 std::unique_ptr<Trajectory> glbTrajectory1;
238 if (!refitted1.empty())
239 glbTrajectory1 = std::make_unique<Trajectory>(*(refitted1.begin()));
243 glbTrajectory1->setSeedRef(tmpSeed);
245 if (glbTrajectory1 && tkTrajectory) {
246 refittedResult.emplace_back(std::make_unique<MuonCandidate>(
247 std::move(glbTrajectory1), it->muonTrack(), it->trackerTrack(),
std::move(tkTrajectory)));
251 if (it->trackerTrack()->seedRef().isAvailable())
252 tmpSeed = it->trackerTrack()->seedRef();
255 std::unique_ptr<Trajectory> tkTrajectory;
256 if (!(it->trackerTrajectory() && it->trackerTrajectory()->isValid())) {
258 if (!refitted0.empty()) {
259 tkTrajectory = std::make_unique<Trajectory>(*(refitted0.begin()));
263 tkTrajectory = it->releaseTrackerTrajectory();
264 std::unique_ptr<Trajectory> cpy;
266 tkTrajectory->setSeedRef(tmpSeed);
267 cpy = std::make_unique<Trajectory>(*tkTrajectory);
270 refittedResult.emplace_back(std::make_unique<MuonCandidate>(
277 std::unique_ptr<MuonCandidate> tmpCand;
280 for (
auto&&
cand : refittedResult) {
292 selectedResult.push_back(
std::move(tmpCand));
294 refittedResult.clear();
296 return selectedResult;
303 const TrackCand& staCand,
const std::vector<TrackCand>& tkTs) {
311 std::vector<TrackCand>
result;
313 double deltaR_max = 1.0;
315 for (
auto&& is : tkTs) {
317 static_cast<double>(regionOfInterest.
direction().
phi()),
323 if (deltaR_tmp < deltaR_max) {
325 result.push_back(tmpCand);
340 std::abs(region1->etaRange().max() - region1->etaRange().mean()));
345 region1->originRBound(),
346 region1->originZBound(),
348 region1->phiMargin());
357 if (
track.ndof() > 0 &&
track.chiSquared() > 0) {
369 for (
auto&& ir :
hits) {
370 if (!ir->isValid()) {
378 <<
" dimension = " << ir->dimension() <<
" " << ir->det()->geographicalId().det() <<
" "
379 << ir->det()->subDetector();
389 ConstRecHitContainer::const_iterator frontHit =
recHits.begin();
390 ConstRecHitContainer::const_iterator backHit =
recHits.end() - 1;
391 while (!(*frontHit)->isValid() && frontHit != backHit) {
394 while (!(*backHit)->isValid() && backHit != frontHit) {
398 double rFirst = (*frontHit)->globalPosition().mag();
399 double rLast = (*backHit)->globalPosition().mag();
403 else if (rFirst > rLast)
423 for (
auto&&
i :
all) {
444 ConstRecHitContainer::iterator lone_tec;
446 for (ConstRecHitContainer::iterator
i =
all.begin();
i !=
all.end();
i++) {
447 if (!(*i)->isValid())
455 if ((
i + 1) !=
all.end() && (*(
i + 1))->isValid() &&
467 int hitDet = (*lone_tec)->hit()->geographicalId().det();
468 int hitSubDet = (*lone_tec)->hit()->geographicalId().subdetId();
474 if ((*lone_tec)->detUnit()) {
475 const StripTopology* topology = dynamic_cast<const StripTopology*>(&(*lone_tec)->detUnit()->topology());
481 LocalError scaledError(rotError.
xx() * scl_x * scl_x, 0, rotError.
yy() * scl_y * scl_y);
507 auto hitCloner = tkbuilder->cloner();
509 if ((*hit)->isValid()) {
510 DetId recoid = (*hit)->geographicalId();
512 if (!(*hit)->hasPositionAndError()) {
519 <<
"Could not get a tsos on the hit surface. We will miss a tracking hit.";
523 auto h = (**hit).cloneForFit(*tkbuilder->geometry()->idToDet((**hit).geographicalId()));
524 result.emplace_back(hitCloner.makeShared(
h, predTsos));
526 result.push_back((*hit)->cloneSH());
529 if ((*hit)->geographicalId().subdetId() == 3 && !
theRPCInTheFit) {