48 bool enableDTMeasurement = par.
getParameter<
bool>(
"EnableDTMeasurement");
49 bool enableCSCMeasurement = par.
getParameter<
bool>(
"EnableCSCMeasurement");
50 bool enableRPCMeasurement = par.
getParameter<
bool>(
"EnableRPCMeasurement");
101 category_ =
"Muon|RecoMuon|CosmicMuon|CosmicMuonTrajectoryBuilder";
141 vector<Trajectory*> trajL = vector<Trajectory*>();
146 DetId did(ptsd1.detId());
156 vector<const DetLayer*> navLayers;
169 LogTrace(
category_) <<
"found "<<navLayers.size()<<
" compatible DetLayers for the Seed";
171 if (navLayers.empty())
return trajL;
173 vector<DetWithState> detsWithStates;
175 for ( vector<const DetLayer*>::const_iterator layer = navLayers.begin();
176 layer != navLayers.end(); layer++) {
177 LogTrace(
category_) << debug.dumpMuonId((*layer)->basicComponents().front()->geographicalId())
178 << debug.dumpLayer(*layer);
182 LogTrace(
category_) <<
"Number of compatible dets: " << detsWithStates.size() << endl;
184 if ( !detsWithStates.empty() ) {
186 if ( detsWithStates.front().second.isValid() ) {
188 LogTrace(
category_) << debug.dumpMuonId(detsWithStates.front().first->geographicalId())
189 << debug.dumpLayer(navLayers.front());
190 lastTsos = detsWithStates.front().second;
195 detsWithStates.clear();
196 if ( !lastTsos.
isValid() )
return trajL;
217 int DTChamberUsedBack = 0;
218 int CSCChamberUsedBack = 0;
219 int RPCChamberUsedBack = 0;
220 int TotalChamberUsedBack = 0;
222 vector<TrajectoryMeasurement> measL;
226 for ( vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin(); rnxtlayer!= navLayers.end(); ++rnxtlayer) {
229 LogTrace(
category_) << debug.dumpMuonId((*rnxtlayer)->basicComponents().front()->geographicalId())
230 << debug.dumpLayer(*rnxtlayer);
235 if ( measL.empty() && (fabs(
theService->magneticField()->inTesla(
GlobalPoint(0,0,0)).z()) < 0.01) && (
theService->propagator(
"StraightLinePropagator").isValid() ) ) {
239 if ( measL.empty() )
continue;
241 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
246 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
247 secondLast = lastTsos;
248 if ( (!theTraj->
empty()) && result.second.isValid() ) {
249 lastTsos = result.second;
251 }
else if ((theMeas)->predictedState().isValid()) lastTsos = (theMeas)->predictedState();
256 while (!theTraj->
empty()) {
260 if (!theTraj->
isValid() || TotalChamberUsedBack < 2 || (DTChamberUsedBack+CSCChamberUsedBack) == 0 || !lastTsos.
isValid()) {
268 DTChamberUsedBack = 0;
269 CSCChamberUsedBack = 0;
270 RPCChamberUsedBack = 0;
271 TotalChamberUsedBack = 0;
281 if ( lastPos.basicVector().dot(momDir.
basicVector()) > 0 ) {
291 std::reverse(navLayers.begin(), navLayers.end());
296 LogTrace(
category_) <<
"Begin backward refitting, with " << navLayers.size() <<
" layers" << endl;
298 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin();
299 rnxtlayer!= navLayers.end(); ++rnxtlayer) {
305 if ( measL.empty() ) {
307 for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin();
308 ihit != tmpHits.end(); ++ihit ) {
309 allUnusedHits.push_back(*ihit);
314 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
317 if (rnxtlayer != navLayers.begin()) {
319 vector<const DetLayer*>::const_iterator lastlayer = rnxtlayer;
322 if ( (*rnxtlayer)->location() != (*lastlayer)->location() ) {
325 GlobalPoint thisPos = (theMeas)->predictedState().globalPosition();
329 if ( momDir.
mag() > 0.01 ) {
337 (lastTsos.
globalPosition().
z() * (theMeas)->predictedState().globalPosition().z() < 0) ) {
345 pair<bool,TrajectoryStateOnSurface> bkresult
348 if (bkresult.first ) {
350 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
355 allUnusedHits.insert(allUnusedHits.end(),tmpUnusedHits.begin(),tmpUnusedHits.end());
357 if ( (!myTraj.
empty()) && bkresult.second.isValid() )
358 lastTsos = bkresult.second;
359 else if ((theMeas)->predictedState().isValid())
360 lastTsos = (theMeas)->predictedState();
365 for ( vector<Trajectory*>::iterator
t = trajL.begin();
t != trajL.end(); ++
t )
delete *
t;
369 if (( !myTraj.
isValid() ) || ( myTraj.
empty() ) || ( (
selfDuplicate(myTraj)) )|| TotalChamberUsedBack < 2 || (DTChamberUsedBack+CSCChamberUsedBack) < 1) {
386 if ( myTraj.
empty() )
return trajL;
391 if ( !smoothed.empty() && smoothed.front().foundHits()> 3 ) {
393 myTraj = smoothed.front();
422 if ( !myTraj.
isValid() )
return trajL;
442 if (dir != propDir ) {
446 if ( myTraj.
empty() )
return trajL;
462 for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin();
463 ihit != tmpHits.end(); ++ihit ) {
464 if ((*ihit)->geographicalId() != meas.
recHit()->geographicalId() ){
465 result.push_back(*ihit);
487 vector<const DetLayer*> navLayers;
514 if (navLayers.empty())
return;
518 int DTChamberUsedBack = 0;
519 int CSCChamberUsedBack = 0;
520 int RPCChamberUsedBack = 0;
521 int TotalChamberUsedBack = 0;
534 vector<TrajectoryMeasurement> measL;
535 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin();
536 rnxtlayer!= navLayers.end(); ++rnxtlayer) {
541 if ( measL.empty() )
continue;
543 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
545 pair<bool,TrajectoryStateOnSurface> bkresult
547 if (bkresult.first ) {
550 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
552 if ( (!traj.
empty()) && bkresult.second.isValid() )
553 lastTsos = bkresult.second;
554 else if ((theMeas)->predictedState().isValid())
555 lastTsos = (theMeas)->predictedState();
581 if (traj.
empty())
return;
607 if ( predTsos.isValid() )
608 LogTrace(
category_)<<
"intermediateState: a intermediate state: pos: "<<predTsos.globalPosition() <<
"mom: " << predTsos.globalMomentum();
620 if ( hits.size() < 2 )
return;
623 vector<bool>
keep(hits.size(),
true);
627 for (MuonRecHitContainer::const_iterator ihit = hits.begin();
628 ihit != hits.end(); ++ihit ) {
629 if ( !
keep[i] ) { i++;
continue; };
631 for (MuonRecHitContainer::const_iterator ihit2 = ihit + 1;
632 ihit2 != hits.end(); ++ihit2 ) {
633 if ( !
keep[j] ) { j++;
continue; }
634 if ((*ihit)->geographicalId() == (*ihit2)->geographicalId() ) {
635 if ( (*ihit)->dimension() > (*ihit2)->dimension() ) {
637 }
else if ( (*ihit)->dimension() < (*ihit2)->dimension() ) {
640 if ( (*ihit)->transientHits().size()>(*ihit2)->transientHits().size() ) {
642 }
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()))
keep[
i] =
false;
647 else keep[
j] =
false;
657 for (MuonRecHitContainer::const_iterator ihit = hits.begin();
658 ihit != hits.end(); ++ihit ) {
659 if (
keep[i] ) tmp.push_back(*ihit);
678 if (traj.
empty())
return true;
681 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
682 if ( !(*ir)->isValid() )
continue;
683 for (ConstRecHitContainer::const_iterator ir2 = ir+1; ir2 != hits.end(); ir2++ ) {
684 if ( !(*ir2)->isValid() )
continue;
685 if ( (*ir) == (*ir2) ) result =
true;
713 std::vector<TrajectoryMeasurement>
const & meas = traj.
measurements();
714 for (
auto itm = meas.rbegin(); itm != meas.rend(); ++itm ) {
733 std::reverse(hits.begin(), hits.end());
740 if ( refittedback.empty() ) {
744 LogTrace(
category_) <<
"flipTrajectory: first "<< refittedback.front().firstMeasurement().updatedState()
745 <<
"\nflipTrajectory: last "<<refittedback.front().lastMeasurement().updatedState();
747 traj = refittedback.front();
762 const std::vector<TrajectoryMeasurement>& meas = traj.
measurements();
764 for (std::vector<TrajectoryMeasurement>::const_iterator itm = meas.begin(); itm != meas.end(); ++itm) {
768 while (!traj.
empty()) {
805 if ( !refitted.empty() ) traj = refitted.front();
808 std::reverse(hits.begin(), hits.end());
811 if ( !refittedback.empty() ) traj = refittedback.front();
827 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
828 if ( !(*ir)->isValid() ) {
836 <<
"radius " << pos.
perp()
837 <<
" dim " << (*ir)->dimension()
838 <<
" det " << (*ir)->det()->geographicalId().det()
839 <<
" sub det " << (*ir)->det()->subDetector()<<endl;
841 if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 6) {
846 if ((*rechit).isValid())
LogTrace(
category_)<<
"csc from collection tpeak "<<(*rechit).tpeak();
849 if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 7) {
854 if ((*rechit).isValid())
LogTrace(
category_)<<
"dt from collection digitime "<<(*rechit).digiTime();
867 std::vector<TrajectoryMeasurement>
873 std::vector<TrajectoryMeasurement>
result;
874 std::vector<TrajectoryMeasurement> measurements;
877 std::vector<TrajectoryMeasurementGroup> measurementGroups =
880 for (std::vector<TrajectoryMeasurementGroup>::const_iterator tmGroupItr = measurementGroups.begin();
881 tmGroupItr != measurementGroups.end(); ++tmGroupItr) {
883 measurements = tmGroupItr->measurements();
887 if (bestMeasurement) result.push_back(*bestMeasurement);
895 if (bestMeasurement) result.push_back(*bestMeasurement);
897 measurements.clear();
911 int& totalChambers) {
926 if ( (dtseg == 0) || (!dtseg->
hasPhi()) )
return 0;
bool empty() const
True if trajectory has no measurements.
void rescaleError(double factor)
void reverseTrajectoryPropagationDirection(Trajectory &) const
reverse the propagation direction of a trajectory
T getParameter(std::string const &) const
const Propagator * propagator() const
virtual TrajectoryContainer trajectories(const Trajectory &traj) const override
double t0(const DTRecSegment4D *deseg) const
std::pair< const_iterator, const_iterator > range
iterator range
TrajectoryStateOnSurface const & predictedState() const
const MeasurementEstimator * estimator() const
accasso at the propagator
ConstRecHitPointer const & recHit() const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
std::vector< const DetLayer * > compatibleEndcapLayers(const FreeTrajectoryState &fts, PropagationDirection timeDirection) const
CosmicMuonSmoother * theSmoother
void estimateDirection(Trajectory &) const
check the direction of trajectory by checking eta spread
void makeFirstTime()
reset the theFirstTSOSFlag
TrajectoryStateOnSurface intermediateState(const TrajectoryStateOnSurface &) const
edm::Handle< CSCRecHit2DCollection > cschits_
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
unsigned long long theCacheId_DG
Global3DPoint GlobalPoint
virtual SubDetector subDetector() const =0
The type of detector (PixelBarrel, PixelEndcap, TIB, TOB, TID, TEC, CSC, DT, RPCBarrel, RPCEndcap)
MuonTrajectoryUpdator * backwardUpdator() const
GlobalPoint globalPosition() const
ConstRecHitContainer recHits() const
std::vector< Trajectory * > trajectories(const TrajectorySeed &)
build trajectories from seed
MuonCandidate::TrajectoryContainer TrajectoryContainer
std::string thePropagatorName
edm::Handle< DTRecHitCollection > dthits_
const Propagator * propagatorOpposite() const
MuonDetLayerMeasurements * theLayerMeasurements
bool theTraversingMuonFlag
const CosmicMuonUtilities * utilities() const
DirectMuonNavigation * theNavigation
std::vector< TrajectoryMeasurementGroup > groupedMeasurements(const DetLayer *layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est, const edm::Event &iEvent)
std::vector< const DetLayer * > compatibleLayers(const FreeTrajectoryState &fts, PropagationDirection timeDirection) const
PropagationDirection const & direction() const
DataContainer const & measurements() const
DirectMuonNavigation * navigation() const
void flipTrajectory(Trajectory &) const
flip a trajectory with refit (the momentum direction is opposite)
MuonTrajectoryUpdator * updator() const
MuonRecHitContainer recHits(const DetLayer *layer, const edm::Event &iEvent)
returns the rechits which are on the layer
void reverseTrajectory(Trajectory &) const
reverse a trajectory without refit (out the measurements order changed)
MuonBestMeasurementFinder * theBestMeasurementFinder
void setFitDirection(NavigationDirection fitDirection)
set fit direction
TrajectoryMeasurement const & lastMeasurement() const
FreeTrajectoryState const * freeState(bool withErrors=true) const
MuonTrajectoryUpdator * theBKUpdator
void incrementChamberCounters(const DetLayer *layer, int &dtChambers, int &cscChambers, int &rpcChambers, int &totalChambers)
bool hasPhi() const
Does it have the Phi projection?
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
MeasurementContainer measurements(const DetLayer *layer, const GeomDet *det, const TrajectoryStateOnSurface &stateOnDet, const MeasurementEstimator &est, const edm::Event &iEvent)
GlobalVector momentum() const
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
std::vector< ConstRecHitPointer > ConstRecHitContainer
void getDirectionByTime(Trajectory &) const
check the direction of trajectory by checking the timing
GlobalPoint position() const
PropagationDirection checkDirectionByT0(const DTRecSegment4D *, const DTRecSegment4D *) const
TrajectoryMeasurement const & firstMeasurement() const
PTrajectoryStateOnDet const & startingState() const
std::vector< Trajectory > fit(const Trajectory &) const
edm::ParameterSet theNavigationPSet
MuonTrajectoryUpdator * theUpdator
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
const MuonServiceProxy * theService
virtual ~CosmicMuonTrajectoryBuilder()
Destructor.
void selectHits(MuonTransientTrackingRecHit::MuonRecHitContainer &) const
std::vector< std::vector< double > > tmp
void setEvent(const edm::Event &)
set event
GlobalVector globalMomentum() const
CosmicMuonTrajectoryBuilder(const edm::ParameterSet &, const MuonServiceProxy *service, edm::ConsumesCollector &iC)
Constructor.
const Propagator * propagatorAlong() const
TrajectoryMeasurement * findBestMeasurement(std::vector< TrajectoryMeasurement > &measC, const Propagator *propagator)
return the Tm with the best chi2: no cut applied.
MuonTransientTrackingRecHit::MuonRecHitContainer MuonRecHitContainer
std::vector< TrajectoryMeasurement > findBestMeasurements(const DetLayer *, const TrajectoryStateOnSurface &, const Propagator *, const MeasurementEstimator *)
virtual std::pair< bool, TrajectoryStateOnSurface > update(const TrajectoryMeasurement *measurement, Trajectory &trajectory, const Propagator *propagator)
update the Trajectory with the TrajectoryMeasurement
void buildSecondHalf(Trajectory &)
bool selfDuplicate(const Trajectory &) const
check if the trajectory iterates the same hit more than once
TrajectoryStateOnSurface const & updatedState() const
MuonTransientTrackingRecHit::MuonRecHitContainer unusedHits(const DetLayer *, const TrajectoryMeasurement &) const
double t0() const
Get the segment t0 (if recomputed, 0 is returned otherwise)
void reverseDirection(TrajectoryStateOnSurface &, const MagneticField *) const
void build(const TrajectoryStateOnSurface &, const NavigationDirection &, Trajectory &)
const BasicVectorType & basicVector() const
std::vector< MuonRecHitPointer > MuonRecHitContainer
GlobalVector globalDirection() const
virtual void setEvent(const edm::Event &)
pass the Event to the algo at each event
T dot(const Basic3DVector &rh) const
Scalar product, or "dot" product, with a vector of same type.