49 bool enableDTMeasurement = par.
getParameter<
bool>(
"EnableDTMeasurement");
50 bool enableCSCMeasurement = par.
getParameter<
bool>(
"EnableCSCMeasurement");
51 bool enableRPCMeasurement = par.
getParameter<
bool>(
"EnableRPCMeasurement");
101 category_ =
"Muon|RecoMuon|CosmicMuon|CosmicMuonTrajectoryBuilder";
141 DetId did(ptsd1.detId());
151 vector<const DetLayer*> navLayers;
163 LogTrace(
category_) <<
"found " << navLayers.size() <<
" compatible DetLayers for the Seed";
165 if (navLayers.empty())
166 return emptyContainer;
168 vector<DetWithState> detsWithStates;
170 for (vector<const DetLayer*>::const_iterator layer = navLayers.begin(); layer != navLayers.end(); layer++) {
172 <<
debug.dumpLayer(*layer);
176 LogTrace(
category_) <<
"Number of compatible dets: " << detsWithStates.size() << endl;
178 if (!detsWithStates.empty()) {
180 if (detsWithStates.front().second.isValid()) {
183 <<
debug.dumpLayer(navLayers.front());
184 lastTsos = detsWithStates.front().second;
189 detsWithStates.clear();
191 return emptyContainer;
211 int DTChamberUsedBack = 0;
212 int CSCChamberUsedBack = 0;
213 int RPCChamberUsedBack = 0;
214 int TotalChamberUsedBack = 0;
216 vector<TrajectoryMeasurement> measL;
220 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin(); rnxtlayer != navLayers.end();
225 <<
debug.dumpLayer(*rnxtlayer);
230 if (measL.empty() && (fabs(
theService->magneticField()->inTesla(
GlobalPoint(0, 0, 0)).z()) < 0.01) &&
231 (
theService->propagator(
"StraightLinePropagator").isValid())) {
239 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
245 (*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
246 secondLast = lastTsos;
247 if ((!theTraj.
empty()) &&
result.second.isValid()) {
251 }
else if ((theMeas)->predictedState().isValid())
252 lastTsos = (theMeas)->predictedState();
257 while (!theTraj.
empty()) {
261 if (!theTraj.
isValid() || TotalChamberUsedBack < 2 || (DTChamberUsedBack + CSCChamberUsedBack) == 0 ||
263 return emptyContainer;
267 DTChamberUsedBack = 0;
268 CSCChamberUsedBack = 0;
269 RPCChamberUsedBack = 0;
270 TotalChamberUsedBack = 0;
280 if (lastPos.basicVector().dot(momDir.
basicVector()) > 0) {
296 LogTrace(
category_) <<
"Begin backward refitting, with " << navLayers.size() <<
" layers" << endl;
298 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin(); rnxtlayer != navLayers.end();
306 for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin(); ihit != tmpHits.end(); ++ihit) {
307 allUnusedHits.push_back(*ihit);
312 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
314 if (rnxtlayer != navLayers.begin()) {
315 vector<const DetLayer*>::const_iterator lastlayer = rnxtlayer;
318 if ((*rnxtlayer)->location() != (*lastlayer)->location()) {
320 GlobalPoint thisPos = (theMeas)->predictedState().globalPosition();
324 if (momDir.
mag() > 0.01) {
333 (lastTsos.
globalPosition().
z() * (theMeas)->predictedState().globalPosition().z() < 0)) {
343 if (bkresult.first) {
345 (*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
349 allUnusedHits.insert(allUnusedHits.end(), tmpUnusedHits.begin(), tmpUnusedHits.end());
351 if ((!myTraj.
empty()) && bkresult.second.isValid())
352 lastTsos = bkresult.second;
353 else if ((theMeas)->predictedState().isValid())
354 lastTsos = (theMeas)->predictedState();
360 (DTChamberUsedBack + CSCChamberUsedBack) < 1) {
361 return emptyContainer;
371 return emptyContainer;
374 return emptyContainer;
383 return emptyContainer;
388 if (!smoothed.empty() && smoothed.front().foundHits() > 3) {
390 myTraj = smoothed.front();
420 return emptyContainer;
425 myTraj.
measurements().front().recHit()->globalPosition();
428 return emptyContainer;
435 << myTraj.
measurements().back().updatedState().globalMomentum() << endl;
437 << myTraj.
measurements().front().updatedState().globalMomentum() << endl;
447 if (
dir != propDir) {
452 return emptyContainer;
457 ret.emplace_back(std::make_unique<Trajectory>(myTraj));
468 for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin(); ihit != tmpHits.end(); ++ihit) {
469 if ((*ihit)->geographicalId() != meas.
recHit()->geographicalId()) {
491 vector<const DetLayer*> navLayers;
516 if (navLayers.empty())
521 int DTChamberUsedBack = 0;
522 int CSCChamberUsedBack = 0;
523 int RPCChamberUsedBack = 0;
524 int TotalChamberUsedBack = 0;
537 vector<TrajectoryMeasurement> measL;
538 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin(); rnxtlayer != navLayers.end();
546 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
548 if (bkresult.first) {
552 (*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
554 if ((!traj.
empty()) && bkresult.second.isValid())
555 lastTsos = bkresult.second;
556 else if ((theMeas)->predictedState().isValid())
557 lastTsos = (theMeas)->predictedState();
605 if (predTsos.isValid())
606 LogTrace(
category_) <<
"intermediateState: a intermediate state: pos: " << predTsos.globalPosition()
607 <<
"mom: " << predTsos.globalMomentum();
620 vector<bool>
keep(
hits.size(),
true);
624 for (MuonRecHitContainer::const_iterator ihit =
hits.begin(); ihit !=
hits.end(); ++ihit) {
630 for (MuonRecHitContainer::const_iterator ihit2 = ihit + 1; ihit2 !=
hits.end(); ++ihit2) {
635 if ((*ihit)->geographicalId() == (*ihit2)->geographicalId()) {
636 if ((*ihit)->dimension() > (*ihit2)->dimension()) {
638 }
else if ((*ihit)->dimension() < (*ihit2)->dimension()) {
641 if ((*ihit)->transientHits().size() > (*ihit2)->transientHits().size()) {
643 }
else if ((*ihit)->transientHits().size() < (*ihit2)->transientHits().size()) {
645 }
else if ((*ihit)->degreesOfFreedom() != 0 && (*ihit2)->degreesOfFreedom() != 0) {
646 if (((*ihit)->chi2() / (*ihit)->degreesOfFreedom()) > ((*ihit2)->chi2() / (*ihit)->degreesOfFreedom()))
659 for (MuonRecHitContainer::const_iterator ihit =
hits.begin(); ihit !=
hits.end(); ++ihit) {
661 tmp.push_back(*ihit);
681 for (ConstRecHitContainer::const_iterator ir =
hits.begin(); ir !=
hits.end(); ir++) {
682 if (!(*ir)->isValid())
684 for (ConstRecHitContainer::const_iterator ir2 = ir + 1; ir2 !=
hits.end(); ir2++) {
685 if (!(*ir2)->isValid())
714 std::vector<TrajectoryMeasurement>
const& meas = traj.
measurements();
715 for (
auto itm = meas.rbegin(); itm != meas.rend(); ++itm) {
737 if (refittedback.empty()) {
741 LogTrace(
category_) <<
"flipTrajectory: first " << refittedback.front().firstMeasurement().updatedState()
742 <<
"\nflipTrajectory: last " << refittedback.front().lastMeasurement().updatedState();
744 traj = refittedback.front();
757 const std::vector<TrajectoryMeasurement>& meas = traj.
measurements();
759 for (std::vector<TrajectoryMeasurement>::const_iterator itm = meas.begin(); itm != meas.end(); ++itm) {
763 while (!traj.
empty()) {
795 if (!refitted.empty())
796 traj = refitted.front();
802 if (!refittedback.empty())
803 traj = refittedback.front();
815 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ir =
hits.begin(); ir !=
hits.end(); ir++) {
816 if (!(*ir)->isValid()) {
823 << (*ir)->det()->geographicalId().det() <<
" sub det " << (*ir)->det()->subDetector() << endl;
825 if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 6) {
830 if ((*rechit).isValid())
834 if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 7) {
839 if ((*rechit).isValid())
856 std::vector<TrajectoryMeasurement>
result;
857 std::vector<TrajectoryMeasurement> measurements;
860 std::vector<TrajectoryMeasurementGroup> measurementGroups =
863 for (std::vector<TrajectoryMeasurementGroup>::const_iterator tmGroupItr = measurementGroups.begin();
864 tmGroupItr != measurementGroups.end();
866 measurements = tmGroupItr->measurements();
871 result.push_back(*bestMeasurement);
879 result.push_back(*bestMeasurement);
881 measurements.clear();
890 const DetLayer* layer,
int& dtChambers,
int& cscChambers,
int& rpcChambers,
int& totalChambers) {
905 if ((dtseg ==
nullptr) || (!dtseg->
hasPhi()))
932 if (dtseg1 == dtseg2 ||
t0(dtseg1) ==
t0(dtseg2))