48 bool enableDTMeasurement = par.
getParameter<
bool>(
"EnableDTMeasurement");
49 bool enableCSCMeasurement = par.
getParameter<
bool>(
"EnableCSCMeasurement");
50 bool enableRPCMeasurement = par.
getParameter<
bool>(
"EnableRPCMeasurement");
66 enableRPCMeasurement);
92 category_ =
"Muon|RecoMuon|CosmicMuon|CosmicMuonTrajectoryBuilder";
132 vector<Trajectory*> trajL = vector<Trajectory*>();
137 DetId did(ptsd1.detId());
147 vector<const DetLayer*> navLayers;
160 LogTrace(
category_) <<
"found "<<navLayers.size()<<
" compatible DetLayers for the Seed";
162 if (navLayers.empty())
return trajL;
164 vector<DetWithState> detsWithStates;
166 for ( vector<const DetLayer*>::const_iterator layer = navLayers.begin();
167 layer != navLayers.end(); layer++) {
168 LogTrace(
category_) << debug.dumpMuonId((*layer)->basicComponents().front()->geographicalId())
169 << debug.dumpLayer(*layer);
172 detsWithStates = navLayers.front()->compatibleDets(lastTsos, *
propagator(), *(
updator()->estimator()));
173 LogTrace(
category_) <<
"Number of compatible dets: " << detsWithStates.size() << endl;
175 if ( !detsWithStates.empty() ) {
177 if ( detsWithStates.front().second.isValid() ) {
179 LogTrace(
category_) << debug.dumpMuonId(detsWithStates.front().first->geographicalId())
180 << debug.dumpLayer(navLayers.front());
181 lastTsos = detsWithStates.front().second;
186 detsWithStates.clear();
187 if ( !lastTsos.
isValid() )
return trajL;
208 int DTChamberUsedBack = 0;
209 int CSCChamberUsedBack = 0;
210 int RPCChamberUsedBack = 0;
211 int TotalChamberUsedBack = 0;
213 vector<TrajectoryMeasurement> measL;
217 for ( vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin(); rnxtlayer!= navLayers.end(); ++rnxtlayer) {
220 LogTrace(
category_) << debug.dumpMuonId((*rnxtlayer)->basicComponents().front()->geographicalId())
221 << debug.dumpLayer(*rnxtlayer);
226 if ( measL.empty() && (fabs(
theService->magneticField()->inTesla(
GlobalPoint(0,0,0)).z()) < 0.01) && (
theService->propagator(
"StraightLinePropagator").isValid() ) ) {
230 if ( measL.empty() )
continue;
232 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
237 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
238 secondLast = lastTsos;
239 if ( (!theTraj->
empty()) && result.second.isValid() ) {
240 lastTsos = result.second;
242 }
else if ((theMeas)->predictedState().isValid()) lastTsos = (theMeas)->predictedState();
247 while (!theTraj->
empty()) {
251 if (!theTraj->
isValid() || TotalChamberUsedBack < 2 || (DTChamberUsedBack+CSCChamberUsedBack) == 0 || !lastTsos.
isValid()) {
259 DTChamberUsedBack = 0;
260 CSCChamberUsedBack = 0;
261 RPCChamberUsedBack = 0;
262 TotalChamberUsedBack = 0;
272 if ( lastPos.basicVector().dot(momDir.
basicVector()) > 0 ) {
282 std::reverse(navLayers.begin(), navLayers.end());
287 LogTrace(
category_) <<
"Begin backward refitting, with " << navLayers.size() <<
" layers" << endl;
289 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin();
290 rnxtlayer!= navLayers.end(); ++rnxtlayer) {
296 if ( measL.empty() ) {
298 for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin();
299 ihit != tmpHits.end(); ++ihit ) {
300 allUnusedHits.push_back(*ihit);
305 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
308 if (rnxtlayer != navLayers.begin()) {
310 vector<const DetLayer*>::const_iterator lastlayer = rnxtlayer;
313 if ( (*rnxtlayer)->location() != (*lastlayer)->location() ) {
316 GlobalPoint thisPos = (theMeas)->predictedState().globalPosition();
320 if ( momDir.
mag() > 0.01 ) {
328 (lastTsos.
globalPosition().
z() * (theMeas)->predictedState().globalPosition().z() < 0) ) {
336 pair<bool,TrajectoryStateOnSurface> bkresult
339 if (bkresult.first ) {
341 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
346 allUnusedHits.insert(allUnusedHits.end(),tmpUnusedHits.begin(),tmpUnusedHits.end());
348 if ( (!myTraj.
empty()) && bkresult.second.isValid() )
349 lastTsos = bkresult.second;
350 else if ((theMeas)->predictedState().isValid())
351 lastTsos = (theMeas)->predictedState();
356 for ( vector<Trajectory*>::iterator
t = trajL.begin();
t != trajL.end(); ++
t )
delete *
t;
360 if (( !myTraj.
isValid() ) || ( myTraj.
empty() ) || ( (
selfDuplicate(myTraj)) )|| TotalChamberUsedBack < 2 || (DTChamberUsedBack+CSCChamberUsedBack) < 1) {
377 if ( myTraj.
empty() )
return trajL;
382 if ( !smoothed.empty() && smoothed.front().foundHits()> 3 ) {
384 myTraj = smoothed.front();
413 if ( !myTraj.
isValid() )
return trajL;
433 if (dir != propDir ) {
437 if ( myTraj.
empty() )
return trajL;
453 for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin();
454 ihit != tmpHits.end(); ++ihit ) {
455 if ((*ihit)->geographicalId() != meas.
recHit()->geographicalId() ){
456 result.push_back(*ihit);
478 vector<const DetLayer*> navLayers;
505 if (navLayers.empty())
return;
509 int DTChamberUsedBack = 0;
510 int CSCChamberUsedBack = 0;
511 int RPCChamberUsedBack = 0;
512 int TotalChamberUsedBack = 0;
525 vector<TrajectoryMeasurement> measL;
526 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin();
527 rnxtlayer!= navLayers.end(); ++rnxtlayer) {
532 if ( measL.empty() )
continue;
534 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
536 pair<bool,TrajectoryStateOnSurface> bkresult
538 if (bkresult.first ) {
541 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
543 if ( (!traj.
empty()) && bkresult.second.isValid() )
544 lastTsos = bkresult.second;
545 else if ((theMeas)->predictedState().isValid())
546 lastTsos = (theMeas)->predictedState();
572 if (traj.
empty())
return;
598 if ( predTsos.isValid() )
599 LogTrace(
category_)<<
"intermediateState: a intermediate state: pos: "<<predTsos.globalPosition() <<
"mom: " << predTsos.globalMomentum();
611 if ( hits.size() < 2 )
return;
614 vector<bool>
keep(hits.size(),
true);
618 for (MuonRecHitContainer::const_iterator ihit = hits.begin();
619 ihit != hits.end(); ++ihit ) {
620 if ( !
keep[i] ) { i++;
continue; };
622 for (MuonRecHitContainer::const_iterator ihit2 = ihit + 1;
623 ihit2 != hits.end(); ++ihit2 ) {
624 if ( !
keep[j] ) { j++;
continue; }
625 if ((*ihit)->geographicalId() == (*ihit2)->geographicalId() ) {
626 if ( (*ihit)->dimension() > (*ihit2)->dimension() ) {
628 }
else if ( (*ihit)->dimension() < (*ihit2)->dimension() ) {
631 if ( (*ihit)->transientHits().size()>(*ihit2)->transientHits().size() ) {
633 }
else if ( (*ihit)->transientHits().size()<(*ihit2)->transientHits().size() ) {
636 else if ( (*ihit)->degreesOfFreedom() != 0 && (*ihit2)->degreesOfFreedom() != 0) {
637 if (((*ihit)->chi2()/(*ihit)->degreesOfFreedom()) > ((*ihit2)->chi2()/(*ihit)->degreesOfFreedom()))
keep[
i] =
false;
638 else keep[
j] =
false;
648 for (MuonRecHitContainer::const_iterator ihit = hits.begin();
649 ihit != hits.end(); ++ihit ) {
650 if (
keep[i] ) tmp.push_back(*ihit);
669 if (traj.
empty())
return true;
672 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
673 if ( !(*ir)->isValid() )
continue;
674 for (ConstRecHitContainer::const_iterator ir2 = ir+1; ir2 != hits.end(); ir2++ ) {
675 if ( !(*ir2)->isValid() )
continue;
676 if ( (*ir) == (*ir2) ) result =
true;
704 std::vector<TrajectoryMeasurement>
const & meas = traj.
measurements();
705 for (
auto itm = meas.rbegin(); itm != meas.rend(); ++itm ) {
724 std::reverse(hits.begin(), hits.end());
731 if ( refittedback.empty() ) {
735 LogTrace(
category_) <<
"flipTrajectory: first "<< refittedback.front().firstMeasurement().updatedState()
736 <<
"\nflipTrajectory: last "<<refittedback.front().lastMeasurement().updatedState();
738 traj = refittedback.front();
753 const std::vector<TrajectoryMeasurement>& meas = traj.
measurements();
755 for (std::vector<TrajectoryMeasurement>::const_iterator itm = meas.begin(); itm != meas.end(); ++itm) {
759 while (!traj.
empty()) {
796 if ( !refitted.empty() ) traj = refitted.front();
799 std::reverse(hits.begin(), hits.end());
802 if ( !refittedback.empty() ) traj = refittedback.front();
818 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
819 if ( !(*ir)->isValid() ) {
827 <<
"radius " << pos.
perp()
828 <<
" dim " << (*ir)->dimension()
829 <<
" det " << (*ir)->det()->geographicalId().det()
830 <<
" sub det " << (*ir)->det()->subDetector()<<endl;
832 if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 6) {
837 if ((*rechit).isValid())
LogTrace(
category_)<<
"csc from collection tpeak "<<(*rechit).tpeak();
840 if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 7) {
845 if ((*rechit).isValid())
LogTrace(
category_)<<
"dt from collection digitime "<<(*rechit).digiTime();
858 std::vector<TrajectoryMeasurement>
864 std::vector<TrajectoryMeasurement>
result;
865 std::vector<TrajectoryMeasurement> measurements;
868 std::vector<TrajectoryMeasurementGroup> measurementGroups =
871 for (std::vector<TrajectoryMeasurementGroup>::const_iterator tmGroupItr = measurementGroups.begin();
872 tmGroupItr != measurementGroups.end(); ++tmGroupItr) {
874 measurements = tmGroupItr->measurements();
878 if (bestMeasurement) result.push_back(*bestMeasurement);
886 if (bestMeasurement) result.push_back(*bestMeasurement);
888 measurements.clear();
902 int& totalChambers) {
917 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
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.