48 bool enableDTMeasurement = par.
getParameter<
bool>(
"EnableDTMeasurement");
49 bool enableCSCMeasurement = par.
getParameter<
bool>(
"EnableCSCMeasurement");
50 bool enableRPCMeasurement = par.
getParameter<
bool>(
"EnableRPCMeasurement");
97 category_ =
"Muon|RecoMuon|CosmicMuon|CosmicMuonTrajectoryBuilder";
137 vector<Trajectory*> trajL = vector<Trajectory*>();
142 DetId did(ptsd1.detId());
152 vector<const DetLayer*> navLayers;
165 LogTrace(
category_) <<
"found "<<navLayers.size()<<
" compatible DetLayers for the Seed";
167 if (navLayers.empty())
return trajL;
169 vector<DetWithState> detsWithStates;
171 for ( vector<const DetLayer*>::const_iterator layer = navLayers.begin();
172 layer != navLayers.end(); layer++) {
173 LogTrace(
category_) << debug.dumpMuonId((*layer)->basicComponents().front()->geographicalId())
174 << debug.dumpLayer(*layer);
178 LogTrace(
category_) <<
"Number of compatible dets: " << detsWithStates.size() << endl;
180 if ( !detsWithStates.empty() ) {
182 if ( detsWithStates.front().second.isValid() ) {
184 LogTrace(
category_) << debug.dumpMuonId(detsWithStates.front().first->geographicalId())
185 << debug.dumpLayer(navLayers.front());
186 lastTsos = detsWithStates.front().second;
191 detsWithStates.clear();
192 if ( !lastTsos.
isValid() )
return trajL;
213 int DTChamberUsedBack = 0;
214 int CSCChamberUsedBack = 0;
215 int RPCChamberUsedBack = 0;
216 int TotalChamberUsedBack = 0;
218 vector<TrajectoryMeasurement> measL;
222 for ( vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin(); rnxtlayer!= navLayers.end(); ++rnxtlayer) {
225 LogTrace(
category_) << debug.dumpMuonId((*rnxtlayer)->basicComponents().front()->geographicalId())
226 << debug.dumpLayer(*rnxtlayer);
231 if ( measL.empty() && (fabs(
theService->magneticField()->inTesla(
GlobalPoint(0,0,0)).z()) < 0.01) && (
theService->propagator(
"StraightLinePropagator").isValid() ) ) {
235 if ( measL.empty() )
continue;
237 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
242 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
243 secondLast = lastTsos;
244 if ( (!theTraj->
empty()) && result.second.isValid() ) {
245 lastTsos = result.second;
247 }
else if ((theMeas)->predictedState().isValid()) lastTsos = (theMeas)->predictedState();
252 while (!theTraj->
empty()) {
256 if (!theTraj->
isValid() || TotalChamberUsedBack < 2 || (DTChamberUsedBack+CSCChamberUsedBack) == 0 || !lastTsos.
isValid()) {
264 DTChamberUsedBack = 0;
265 CSCChamberUsedBack = 0;
266 RPCChamberUsedBack = 0;
267 TotalChamberUsedBack = 0;
277 if ( lastPos.basicVector().dot(momDir.
basicVector()) > 0 ) {
287 std::reverse(navLayers.begin(), navLayers.end());
292 LogTrace(
category_) <<
"Begin backward refitting, with " << navLayers.size() <<
" layers" << endl;
294 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin();
295 rnxtlayer!= navLayers.end(); ++rnxtlayer) {
301 if ( measL.empty() ) {
303 for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin();
304 ihit != tmpHits.end(); ++ihit ) {
305 allUnusedHits.push_back(*ihit);
310 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
313 if (rnxtlayer != navLayers.begin()) {
315 vector<const DetLayer*>::const_iterator lastlayer = rnxtlayer;
318 if ( (*rnxtlayer)->location() != (*lastlayer)->location() ) {
321 GlobalPoint thisPos = (theMeas)->predictedState().globalPosition();
325 if ( momDir.
mag() > 0.01 ) {
333 (lastTsos.
globalPosition().
z() * (theMeas)->predictedState().globalPosition().z() < 0) ) {
341 pair<bool,TrajectoryStateOnSurface> bkresult
344 if (bkresult.first ) {
346 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
351 allUnusedHits.insert(allUnusedHits.end(),tmpUnusedHits.begin(),tmpUnusedHits.end());
353 if ( (!myTraj.
empty()) && bkresult.second.isValid() )
354 lastTsos = bkresult.second;
355 else if ((theMeas)->predictedState().isValid())
356 lastTsos = (theMeas)->predictedState();
361 for ( vector<Trajectory*>::iterator
t = trajL.begin();
t != trajL.end(); ++
t )
delete *
t;
365 if (( !myTraj.
isValid() ) || ( myTraj.
empty() ) || ( (
selfDuplicate(myTraj)) )|| TotalChamberUsedBack < 2 || (DTChamberUsedBack+CSCChamberUsedBack) < 1) {
382 if ( myTraj.
empty() )
return trajL;
387 if ( !smoothed.empty() && smoothed.front().foundHits()> 3 ) {
389 myTraj = smoothed.front();
418 if ( !myTraj.
isValid() )
return trajL;
438 if (dir != propDir ) {
442 if ( myTraj.
empty() )
return trajL;
458 for (MuonRecHitContainer::const_iterator ihit = tmpHits.begin();
459 ihit != tmpHits.end(); ++ihit ) {
460 if ((*ihit)->geographicalId() != meas.
recHit()->geographicalId() ){
461 result.push_back(*ihit);
483 vector<const DetLayer*> navLayers;
510 if (navLayers.empty())
return;
514 int DTChamberUsedBack = 0;
515 int CSCChamberUsedBack = 0;
516 int RPCChamberUsedBack = 0;
517 int TotalChamberUsedBack = 0;
530 vector<TrajectoryMeasurement> measL;
531 for (vector<const DetLayer*>::const_iterator rnxtlayer = navLayers.begin();
532 rnxtlayer!= navLayers.end(); ++rnxtlayer) {
537 if ( measL.empty() )
continue;
539 for (vector<TrajectoryMeasurement>::const_iterator theMeas = measL.begin(); theMeas != measL.end(); ++theMeas) {
541 pair<bool,TrajectoryStateOnSurface> bkresult
543 if (bkresult.first ) {
546 incrementChamberCounters((*rnxtlayer), DTChamberUsedBack, CSCChamberUsedBack, RPCChamberUsedBack, TotalChamberUsedBack);
548 if ( (!traj.
empty()) && bkresult.second.isValid() )
549 lastTsos = bkresult.second;
550 else if ((theMeas)->predictedState().isValid())
551 lastTsos = (theMeas)->predictedState();
577 if (traj.
empty())
return;
603 if ( predTsos.isValid() )
604 LogTrace(
category_)<<
"intermediateState: a intermediate state: pos: "<<predTsos.globalPosition() <<
"mom: " << predTsos.globalMomentum();
616 if ( hits.size() < 2 )
return;
619 vector<bool>
keep(hits.size(),
true);
623 for (MuonRecHitContainer::const_iterator ihit = hits.begin();
624 ihit != hits.end(); ++ihit ) {
625 if ( !
keep[i] ) { i++;
continue; };
627 for (MuonRecHitContainer::const_iterator ihit2 = ihit + 1;
628 ihit2 != hits.end(); ++ihit2 ) {
629 if ( !
keep[j] ) { j++;
continue; }
630 if ((*ihit)->geographicalId() == (*ihit2)->geographicalId() ) {
631 if ( (*ihit)->dimension() > (*ihit2)->dimension() ) {
633 }
else if ( (*ihit)->dimension() < (*ihit2)->dimension() ) {
636 if ( (*ihit)->transientHits().size()>(*ihit2)->transientHits().size() ) {
638 }
else if ( (*ihit)->transientHits().size()<(*ihit2)->transientHits().size() ) {
641 else if ( (*ihit)->degreesOfFreedom() != 0 && (*ihit2)->degreesOfFreedom() != 0) {
642 if (((*ihit)->chi2()/(*ihit)->degreesOfFreedom()) > ((*ihit2)->chi2()/(*ihit)->degreesOfFreedom()))
keep[
i] =
false;
643 else keep[
j] =
false;
653 for (MuonRecHitContainer::const_iterator ihit = hits.begin();
654 ihit != hits.end(); ++ihit ) {
655 if (
keep[i] ) tmp.push_back(*ihit);
674 if (traj.
empty())
return true;
677 for (ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
678 if ( !(*ir)->isValid() )
continue;
679 for (ConstRecHitContainer::const_iterator ir2 = ir+1; ir2 != hits.end(); ir2++ ) {
680 if ( !(*ir2)->isValid() )
continue;
681 if ( (*ir) == (*ir2) ) result =
true;
709 std::vector<TrajectoryMeasurement>
const & meas = traj.
measurements();
710 for (
auto itm = meas.rbegin(); itm != meas.rend(); ++itm ) {
729 std::reverse(hits.begin(), hits.end());
736 if ( refittedback.empty() ) {
740 LogTrace(
category_) <<
"flipTrajectory: first "<< refittedback.front().firstMeasurement().updatedState()
741 <<
"\nflipTrajectory: last "<<refittedback.front().lastMeasurement().updatedState();
743 traj = refittedback.front();
758 const std::vector<TrajectoryMeasurement>& meas = traj.
measurements();
760 for (std::vector<TrajectoryMeasurement>::const_iterator itm = meas.begin(); itm != meas.end(); ++itm) {
764 while (!traj.
empty()) {
801 if ( !refitted.empty() ) traj = refitted.front();
804 std::reverse(hits.begin(), hits.end());
807 if ( !refittedback.empty() ) traj = refittedback.front();
823 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator ir = hits.begin(); ir != hits.end(); ir++ ) {
824 if ( !(*ir)->isValid() ) {
832 <<
"radius " << pos.
perp()
833 <<
" dim " << (*ir)->dimension()
834 <<
" det " << (*ir)->det()->geographicalId().det()
835 <<
" sub det " << (*ir)->det()->subDetector()<<endl;
837 if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 6) {
842 if ((*rechit).isValid())
LogTrace(
category_)<<
"csc from collection tpeak "<<(*rechit).tpeak();
845 if ((*ir)->det()->geographicalId().det() == 2 && (*ir)->det()->subDetector() == 7) {
850 if ((*rechit).isValid())
LogTrace(
category_)<<
"dt from collection digitime "<<(*rechit).digiTime();
863 std::vector<TrajectoryMeasurement>
869 std::vector<TrajectoryMeasurement>
result;
870 std::vector<TrajectoryMeasurement> measurements;
873 std::vector<TrajectoryMeasurementGroup> measurementGroups =
876 for (std::vector<TrajectoryMeasurementGroup>::const_iterator tmGroupItr = measurementGroups.begin();
877 tmGroupItr != measurementGroups.end(); ++tmGroupItr) {
879 measurements = tmGroupItr->measurements();
883 if (bestMeasurement) result.push_back(*bestMeasurement);
891 if (bestMeasurement) result.push_back(*bestMeasurement);
893 measurements.clear();
907 int& totalChambers) {
922 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 FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
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
if(c.getParameter< edm::InputTag >("puppiValueMap").label().size()!=0)
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
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.