43 #ifdef STANDARD_INTERMEDIARYCLEAN
73 updator, propagatorAlong,propagatorOpposite,
74 estimator, recHitBuilder, measurementTracker, filter, inOutFilter)
152 work.reserve(result.size());
153 for (TrajectoryContainer::iterator traj=result.begin();
154 traj!=result.end(); ++traj) {
159 final.reserve(work.size());
161 for (TempTrajectoryContainer::iterator traj=work.begin();
162 traj!=work.end(); ++traj) {
163 final.push_back(traj->toTrajectory());
184 const bool inOut =
true;
186 if (
work_.empty() )
return ;
203 result.reserve(
work_.size());
204 for (TempTrajectoryContainer::const_iterator it =
work_.begin(), ed =
work_.end(); it != ed; ++it) {
205 result.push_back( it->toTrajectory() );
213 LogDebug(
"CkfPattern")<<
"GroupedCkfTrajectoryBuilder: returning result of size " << result.size();
225 unsigned int nIter=1;
228 candidates.push_back( startingTraj);
230 while ( !candidates.empty()) {
233 for (TempTrajectoryContainer::iterator traj=candidates.begin();
234 traj!=candidates.end(); traj++) {
235 if ( !
advanceOneLayer(*traj, regionalCondition, propagator, inOut, newCand, result) ) {
236 LogDebug(
"CkfPattern")<<
"GCTB: terminating after advanceOneLayer==false";
246 newCand.erase( newCand.begin()+
theMaxCand, newCand.end());
251 LogDebug(
"CkfPattern") <<
"newCand.size() at end = " << newCand.size();
261 #ifdef STANDARD_INTERMEDIARYCLEAN
268 candidates.swap(newCand);
270 LogDebug(
"CkfPattern") <<
"candidates(3): "<<result.size()<<
" candidates after "<<nIter++<<
" groupedCKF iteration: \n"
272 <<
"\n "<<candidates.size()<<
" running candidates are: \n"
278 std::stringstream buffer;
279 vector<const DetLayer*> & nl = stateAndLayers.second;
293 buffer <<
"Trying to go to";
294 for ( vector<const DetLayer*>::iterator il=nl.begin();
308 std::stringstream buffer;
309 buffer <<
"GCTB: starting from "
313 <<
" , pt / phi / pz /charge = "
318 <<
" for layer at "<< l << endl;
319 buffer <<
" errors:";
344 std::pair<TSOS,std::vector<const DetLayer*> > stateAndLayers =
findStateAndLayers(traj);
345 vector<const DetLayer*>::iterator layerBegin = stateAndLayers.second.begin();
346 vector<const DetLayer*>::iterator layerEnd = stateAndLayers.second.end();
355 bool foundSegments(
false);
356 bool foundNewCandidates(
false);
357 for ( vector<const DetLayer*>::iterator il=layerBegin;
358 il!=layerEnd; il++) {
360 TSOS stateToUse = stateAndLayers.first;
363 LogDebug(
"CkfPattern")<<
" self propagating in advanceOneLayer.\n from: \n"<<stateToUse;
370 if (!stateToUse.
isValid())
continue;
371 LogDebug(
"CkfPattern")<<
"to: "<<stateToUse;
385 LogDebug(
"CkfPattern")<<
"GCTB: number of segments = " << segments.size();
387 if ( !segments.empty() ) foundSegments =
true;
389 for ( TempTrajectoryContainer::const_iterator is=segments.begin();
390 is!=segments.end(); is++ ) {
409 LogDebug(
"CkfPattern")<<
"GCTB: adding updated trajectory to candidates: inOut="<<inOut<<
" hits="<<newTraj.
foundHits();
411 newCand.push_back(newTraj);
412 foundNewCandidates =
true;
417 LogDebug(
"CkfPattern")<<
"GCTB: adding completed trajectory to results if passes cuts: inOut="<<inOut<<
" hits="<<newTraj.
foundHits();
424 if ( !foundSegments ){
425 LogDebug(
"CkfPattern")<<
"GCTB: adding input trajectory to result";
428 return foundNewCandidates;
437 if (theTrajectories.empty())
return;
439 int firstLayerSize, secondLayerSize;
440 vector<const DetLayer*> firstLayers, secondLayers;
442 for (TempTrajectoryContainer::iterator firstTraj=theTrajectories.begin();
443 firstTraj!=(theTrajectories.end()-1); firstTraj++) {
445 if ( (!firstTraj->isValid()) ||
446 (!firstTraj->lastMeasurement().recHit()->isValid()) )
continue;
448 layers(firstMeasurements, firstLayers);
449 firstLayerSize = firstLayers.size();
450 if ( firstLayerSize<4 )
continue;
452 for (TempTrajectoryContainer::iterator secondTraj=(firstTraj+1);
453 secondTraj!=theTrajectories.end(); secondTraj++) {
455 if ( (!secondTraj->isValid()) ||
456 (!secondTraj->lastMeasurement().recHit()->isValid()) )
continue;
458 layers(secondMeasurements, secondLayers);
459 secondLayerSize = secondLayers.size();
463 if ( firstLayerSize!=secondLayerSize )
continue;
464 if ( firstLayers[0]!=secondLayers[0] ||
465 firstLayers[1]!=secondLayers[1] ||
466 firstLayers[2]!=secondLayers[2] )
continue;
474 const DetLayer* layerPtr = firstLayers[0];
475 while ( im1!=firstMeasurements.
rend()&&im2!=secondMeasurements.
rend() ) {
476 if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr )
break;
477 if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
486 if ( im1==firstMeasurements.
rend() || im2==secondMeasurements.
rend() ||
487 im1->layer()==layerPtr || im2->layer()==layerPtr || unequal )
continue;
492 layerPtr = firstLayers[1];
494 while ( im1!=firstMeasurements.
rend()&&im1->layer()==layerPtr ) {
495 if ( !im1->recHit()->isValid() ) firstValid =
false;
498 bool secondValid(
true);
499 while ( im2!=secondMeasurements.
rend()&&im2->layer()==layerPtr ) {
500 if ( !im2->recHit()->isValid() ) secondValid =
false;
503 if ( !
tkxor(firstValid,secondValid) )
continue;
508 layerPtr = firstLayers[2];
509 while ( im1!=firstMeasurements.
rend()&&im2!=secondMeasurements.
rend() ) {
510 if ( im1->layer()!=layerPtr || im2->layer()!=layerPtr )
break;
511 if ( !(im1->recHit()->isValid()) || !(im2->recHit()->isValid()) ||
520 if ( im1==firstMeasurements.
rend() || im2==secondMeasurements.
rend() ||
521 im1->layer()==layerPtr || im2->layer()==layerPtr || unequal )
continue;
524 firstTraj->invalidate();
528 secondTraj->invalidate();
541 theTrajectories.erase(std::remove_if( theTrajectories.begin(),theTrajectories.end(),
544 theTrajectories.end());
549 vector<const DetLayer*> &
result)
const
553 if ( measurements.
empty() )
return ;
555 result.push_back(measurements.
back().
layer());
559 im!=measurements.
rend(); --im ) {
560 if ( im->layer()!=result.back() ) result.push_back(im->layer());
563 for (vector<const DetLayer*>::const_iterator iter = result.begin(); iter != result.end(); iter++){
564 if (!*iter)
edm::LogWarning(
"CkfPattern")<<
"Warning: null det layer!! ";
577 LogDebug(
"CkfPattern")<<
"Starting to rebuild " << result.size() <<
" tracks";
586 std::vector<const TrackingRecHit*> seedHits;
593 unsigned int nSeed(rseedHits.second-rseedHits.first);
596 for ( TempTrajectoryContainer::iterator it=result.begin();
597 it!=result.end(); it++ ) {
604 rebuiltTrajectories.push_back(*it);
605 LogDebug(
"CkfPattern")<<
"RebuildSeedingRegion skipped as in-out trajectory does not exceed seed size.";
613 if ( reFitted.size()!=1 ) {
614 rebuiltTrajectories.push_back(*it);
615 LogDebug(
"CkfPattern")<<
"RebuildSeedingRegion skipped as backward fit failed";
627 if ( nRebuilt==0 ) it->invalidate();
629 if ( nRebuilt<=0 ) rebuiltTrajectories.push_back(*it);
635 result.swap(rebuiltTrajectories);
636 result.erase(std::remove_if( result.begin(),result.end(),
678 cout <<
"Before backward building: #measurements = "
685 const bool inOut =
false;
693 int nrOfTrajectories(0);
694 bool orig_ok =
false;
697 for ( TempTrajectoryContainer::iterator it=rebuiltTrajectories.begin();
698 it!=rebuiltTrajectories.end(); it++ ) {
708 LogDebug(
"CkfPattern") <<
"newMeasurements.size()<=candidate.measurements().size()";
717 LogDebug(
"CkfPattern")<<
"seed hits not found in rebuild";
724 TempTrajectory reversedTrajectory(it->seed(),it->seed().direction());
727 reversedTrajectory.
push(*im);
730 result.push_back(reversedTrajectory);
733 LogDebug(
"CkgPattern")<<
"New traj direction = " << reversedTrajectory.direction()<<
"\n"
745 if ( (nrOfTrajectories == 0) && orig_ok ) {
746 nrOfTrajectories = -1;
748 return nrOfTrajectories;
755 std::vector<const TrackingRecHit*>& remainingHits)
const
760 remainingHits.clear();
761 fittedTracks.clear();
767 fittedTracks.clear();
771 LogDebug(
"CkfPattern")<<
"nSeed " << nSeed << endl
772 <<
"Old traj direction = " << candidate.
direction() << endl
784 unsigned int nHit(0);
793 fittedTracks.clear();
797 LogDebug(
"CkfPattern") <<
"Sizes: " << oldMeasurements.size() <<
" / ";
804 std::vector<const DetLayer*> bwdDetLayer;
806 im!=oldMeasurements.rend(); --im) {
813 bwdDetLayer.push_back(im->layer());
830 remainingHits.push_back(hit);
837 fittedTracks.clear();
850 if (bwdFitted.size()){
851 LogDebug(
"CkfPattern")<<
"Obtained " << bwdFitted.size() <<
" bwdFitted trajectories with measurement size " << bwdFitted.front().measurements().size();
859 for ( vector<TM>::const_iterator im=tmsbf.begin();im!=tmsbf.end(); im++ ) {
860 fitted.push(
TM( (*im).forwardPredictedState(),
861 (*im).backwardPredictedState(),
862 (*im).updatedState(),
865 bwdDetLayer[iDetLayer]));
879 fittedTracks.push_back(fitted);
891 const std::vector<const TrackingRecHit*>& hits)
const
896 LogDebug(
"CkfPattern")<<
"Checking for " << hits.size() <<
" hits in "
897 << maxDepth <<
" measurements" << endl;
900 while (maxDepth > 0) { --maxDepth; --rend; }
901 for ( vector<const TrackingRecHit*>::const_iterator ir=hits.begin();
902 ir!=hits.end(); ir++ ) {
904 bool foundHit(
false);
906 if ( im->recHit()->isValid() && (*ir)->sharesInput(im->recHit()->hit(),
TrackingRecHit::some) ) {
911 if ( !foundHit )
return false;
void rescaleError(double factor)
T getParameter(std::string const &) const
const TrajectorySeed & seed() const
Access to the seed used to reconstruct the Trajectory.
const_iterator rend() const
virtual void setEvent(const edm::Event &event) const
set Event for the internal MeasurementTracker data member
static std::string dumpCandidates(collection &candidates)
TempTrajectoryContainer work_
const Propagator * theBackwardPropagator
TrackCharge charge() const
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
TrajectoryContainer trajectories(const TrajectorySeed &) const
trajectories building starting from a seed
const CurvilinearTrajectoryError & curvilinearError() const
void addToResult(TempTrajectory &traj, TrajectoryContainer &result, bool inOut=false) const
PropagationDirection oppositeDirection(PropagationDirection dir) const
change of propagation direction
const DataContainer & measurements() const
GroupedCkfTrajectoryBuilder(const edm::ParameterSet &conf, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *RecHitBuilder, const MeasurementTracker *measurementTracker, const TrajectoryFilter *filter, const TrajectoryFilter *inOutFilter)
constructor from ParameterSet
Geom::Phi< T > phi() const
const TrajectoryStateUpdator * theUpdator
virtual void analyseSeed(const TrajectorySeed &seed) const
GlobalPoint globalPosition() const
ConstRecHitPointer recHit() const
int foundHits() const
obsolete name, use measurements() instead.
TempTrajectoryContainer segments(const TSOS startingState)
new segments within layer
std::string whatIsTheNextStep(TempTrajectory &traj, std::pair< TrajectoryStateOnSurface, std::vector< const DetLayer * > > &stateAndLayers)
static std::string dumpMeasurement(const TrajectoryMeasurement &tm)
static std::string dumpMeasurements(const std::vector< TrajectoryMeasurement > &v)
unsigned int theMinNrOf2dHitsForRebuild
ConstRecHitContainer recHits(bool splitting=false) const
PropagationDirection const & direction() const
const LayerMeasurements * theLayerMeasurements
PropagationDirection direction() const
virtual void analyseResult(const TrajectoryContainer &result) const
void groupedLimitedCandidates(TempTrajectory &startingTraj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &result) const
Scalar radius() const
Radius of the cylinder.
const T & max(const T &a, const T &b)
bool verifyHits(TempTrajectory::DataContainer::const_iterator rbegin, size_t maxDepth, const std::vector< const TrackingRecHit * > &hits) const
Verifies presence of a RecHits in a range of TrajectoryMeasurements.
void groupedIntermediaryClean(TempTrajectoryContainer &theTrajectories) const
intermediate cleaning in the case of grouped measurements
virtual const BoundDisk & specificSurface() const
void backwardFit(TempTrajectory &candidate, unsigned int nSeed, const TrajectoryFitter &fitter, TempTrajectoryContainer &fittedTracks, std::vector< const TrackingRecHit * > &remainingHits) const
const Chi2MeasurementEstimatorBase & estimator() const
std::string whatIsTheStateToUse(TrajectoryStateOnSurface &initial, TrajectoryStateOnSurface &stateToUse, const DetLayer *l)
std::pair< const_iterator, const_iterator > range
void rebuildSeedingRegion(const TrajectorySeed &, TrajectoryContainer &result) const
const DetLayer * layer() const
void buildTrajectories(const TrajectorySeed &, TrajectoryContainer &ret, const TrajectoryFilter *) const
common part of both public trajectory building methods
bool advanceOneLayer(TempTrajectory &traj, const TrajectoryFilter *regionalCondition, const Propagator *propagator, bool inOut, TempTrajectoryContainer &newCand, TempTrajectoryContainer &result) const
TrajectoryStateOnSurface updatedState() const
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
const MeasurementTracker * theMeasurementTracker
TrajectoryMeasurement const & firstMeasurement() const
tuple filter
USE THIS FOR SKIMMED TRACKS process.p = cms.Path(process.hltLevel1GTSeed*process.skimming*process.offlineBeamSpot*process.TrackRefitter2) OTHERWISE USE THIS.
unsigned int theMinNrOfHitsForRebuild
std::vector< TempTrajectory > TempTrajectoryContainer
virtual const BoundCylinder & specificSurface() const
Extension of the interface.
const TrajectoryStateUpdator & updator() const
virtual std::vector< Trajectory > fit(const Trajectory &) const =0
const AlgebraicSymMatrix55 & matrix() const
GlobalVector globalMomentum() const
bool toBeContinued(TempTrajectory &traj, bool inOut=false) const
bool tkxor(bool a, bool b) const
StateAndLayers findStateAndLayers(const TempTrajectory &traj) const
bool theIntermediateCleaning
bool theRequireSeedHitsInRebuild
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
const PositionType & position() const
void push(const TrajectoryMeasurement &tm)
std::vector< Trajectory > TrajectoryContainer
void layers(const TempTrajectory::DataContainer &measurements, std::vector< const DetLayer * > &fillme) const
const Chi2MeasurementEstimatorBase * theEstimator
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
void push(const TrajectoryMeasurement &tm)
const Propagator * theForwardPropagator