CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HICTrajectoryBuilder.cc
Go to the documentation of this file.
3 
5 
7 
11 
16 
17 
23 
29 
30 
38 //#include "TrackingTools/PatternTools/interface/TrajectoryStateClosestToBeamLineBuilder.h"
39 
40 using namespace std;
41 using namespace cms;
42 
43 //#define DEBUG
44 
47  const edm::EventSetup& es1,
48  const TrajectoryStateUpdator* updator,
49  const Propagator* propagatorAlong,
50  const Propagator* propagatorOpposite,
51  const Chi2MeasurementEstimatorBase* estimator,
52  const TransientTrackingRecHitBuilder* RecHitBuilder,
53  const MeasurementTracker* measurementTracker,
54  const TrajectoryFilter* filter):
55 
57  updator, propagatorAlong,propagatorOpposite,
58  estimator, RecHitBuilder, measurementTracker,filter),
59  theUpdator(updator),thePropagatorAlong(propagatorAlong),
60  thePropagatorOpposite(propagatorOpposite),theEstimator(estimator),
61  theTTRHBuilder(RecHitBuilder),theMeasurementTracker(measurementTracker),
62  theLayerMeasurements(new LayerMeasurements(theMeasurementTracker)),
63  theForwardPropagator(0), theBackwardPropagator(0)
64 {
65  theMaxCand = 1;
66  theMaxLostHit = 0;
68  theLostHitPenalty = 0.;
73 // es1.get<TrackingComponentsRecord>().get("KFFitterForRefitInsideOut",theFitterTrack);
74 // es1.get<TrackingComponentsRecord>().get("KFSmootherForRefitInsideOut",theSmootherTrack);
75  es1.get<TrajectoryFitter::Record>().get("KFFitterForRefitInsideOut",theFitterTrack);
76  es1.get<TrajectoryFitter::Record>().get("KFSmootherForRefitInsideOut",theSmootherTrack);
77  es1.get<TrackingComponentsRecord>().get("SmartPropagatorAny",thePropagatorTrack);
78 
79 #ifdef DEBUG
80  cout<<" HICTrajectoryBuilder::contructor "<<endl;
81 #endif
82 }
83 
85 {
86  delete theLayerMeasurements;
87 // delete theMinPtCondition;
88 // delete theMaxHitsCondition;
89 }
90 
92 {
93  theMeasurementTracker->update(event);
94 }
95 
98 {
100 #ifdef DEBUG
101  cout<<" HICTrajectoryBuilder::trajectories start with seed"<<endl;
102 #endif
104 
105  TempTrajectory startingTraj = createStartingTrajectory( seed );
106 #ifdef DEBUG
107  cout<<" HICTrajectoryBuilder::trajectories starting trajectories created "<<endl;
108 #endif
109  if(startingTraj.empty()) {
110 #ifdef DEBUG
111  cout<<" Problem with starting trajectory "<<endl;
112 #endif
113  return result;
114  }
115 
118 
119  limitedCandidates( startingTraj, result);
120 #ifdef DEBUG
121  cout<<" HICTrajectoryBuilder::trajectories candidates found "<<result.size()<<endl;
122 #endif
123 
124  return result;
125 }
126 
129 {
130 #ifdef DEBUG
131  cout<<" HICTrajectoryBuilder::createStartingTrajectory "<<seed.direction()<<endl;
132 #endif
134  theForwardPropagator = &(*thePropagatorOpposite);
135  theBackwardPropagator = &(*thePropagatorAlong);
136 
137  std::vector<TM> seedMeas = seedMeasurements(seed);
138 
139 #ifdef DEBUG
140  std::cout<<" Size of seed "<<seedMeas.size()<<endl;
141 #endif
142  if ( !seedMeas.empty()) {
143 #ifdef DEBUG
144  std::cout<<" TempTrajectory "<<std::endl;
145 #endif
146  for (std::vector<TM>::const_iterator i=seedMeas.begin(); i!=seedMeas.end(); i++){
147 
148  result.push(*i);
149 
150 
151  }
152  }
153 
154  return result;
155 
156 }
157 
161 {
162  TempTrajectoryContainer candidates; // = TrajectoryContainer();
163  TempTrajectoryContainer newCand; // = TrajectoryContainer();
164  candidates.push_back( startingTraj);
165 // Add the additional stuff
166 #ifdef DEBUG
167  cout<<" HICTrajectoryBuilder::limitedCandidates "<<candidates.size()<<endl;
168 #endif
169 
170  int theIniSign = 1;
171  dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->setSign(theIniSign);
172 #ifdef DEBUG
173  cout<<" Number of measurements "<<startingTraj.measurements().size()<<endl;
174 #endif
175 //
176 // Calculate the number of final trajectories. Allow no more then 4.
177 //
178 
179  int numtraj = 0;
180 
181  while ( !candidates.empty()) {
182 #ifdef DEBUG
183  cout<<" HICTrajectoryBuilder::limitedCandidates::cycle "<<candidates.size()<<endl;
184 #endif
185  newCand.clear();
186 
187  for (TempTrajectoryContainer::iterator traj=candidates.begin();
188  traj!=candidates.end(); traj++) {
189 #ifdef DEBUG
190  cout<< " Before findCompatibleMeasurements "<<endl;
191 #endif
192  std::vector<TM> meas = findCompatibleMeasurements(*traj);
193 #ifdef DEBUG
194  cout<< " After findCompatibleMeasurements "<<meas.size()<<endl;
195 #endif
196 
197  if ( meas.empty()) {
198 #ifdef DEBUG
199  cout<<": Measurements empty : "<<endl;
200 #endif
201  if ( qualityFilter( *traj)) {addToResult( *traj, result); numtraj++;}
202  }
203  else {
204 #ifdef DEBUG
205  cout<<" : Update trajectoris : "<<endl;
206 #endif
207  for( std::vector<TM>::const_iterator itm = meas.begin();
208  itm != meas.end(); itm++) {
209  TempTrajectory newTraj = *traj;
210  bool good = updateTrajectory( newTraj, *itm);
211  if(good)
212  {
213  if ( toBeContinued(newTraj)) {
214  newCand.push_back(newTraj);
215 #ifdef DEBUG
216  cout<<": toBeContinued : increase "<<newCand.size()<<" maximal size "<<theMaxCand<<endl;
217 #endif
218  }
219  else {
220 #ifdef DEBUG
221  cout<<": good TM : to be stored :"<<endl;
222 #endif
223  if ( qualityFilter(newTraj)) {addToResult( newTraj, result); numtraj++;}
225  }
226  } // good
227  else
228  {
229 #ifdef DEBUG
230  cout<<": bad TM : to be stored :"<<endl;
231 #endif
232  if ( qualityFilter( *traj)) {addToResult( *traj, result);numtraj++;}
233  }
234  } //meas
235  }
236 
237 // if ((int)newCand.size() > theMaxCand) {
238 // sort( newCand.begin(), newCand.end(), TrajCandLess<TempTrajectory>(theLostHitPenalty));
239 // newCand.erase( newCand.begin()+theMaxCand, newCand.end());
240 // }
241 
242  if(numtraj > 4) break;
243  } // trajectories
244  if(numtraj > 4) break;
245  candidates.swap(newCand);
246  }
247 
248 #ifdef DEBUG
249  std::cout<<" qualityFilter::Number of trajectories "<<numtraj<<std::endl;
250 #endif
251 
252 }
253 
254 
255 
259 
260 std::vector<TrajectoryMeasurement>
262 {
263  std::vector<TrajectoryMeasurement> result;
264 // TrajectoryStateTransform tsTransform;
265 
266 #ifdef DEBUG
267  cout<<" HICTrajectoryBuilder::seedMeasurements number of TM "<<dynamic_cast<DiMuonTrajectorySeed*>(const_cast<TrajectorySeed*>(&seed))->measurements().size()<<endl;
268 #endif
269 
270  std::vector<TrajectoryMeasurement> start = dynamic_cast<DiMuonTrajectorySeed*>(const_cast<TrajectorySeed*>(&seed))->measurements();
271  for(std::vector<TrajectoryMeasurement>::iterator imh = start.begin(); imh != start.end(); imh++)
272  {
273 #ifdef DEBUG
274  cout<<" HICTrajectoryBuilder::seedMeasurements::RecHit "<<endl;
275 #endif
276  result.push_back(*imh);
277  }
278 
279  return result;
280 }
281 
283 {
284 #ifdef DEBUG
285  cout << "qualityFilter called for trajectory with "
286  << traj.foundHits() << " found hits and Chi2 = "
287  << traj.chiSquared() << endl;
288 #endif
289  if ( traj.foundHits() < theMinimumNumberOfHits) {
290  return false;
291  }
292 
293  Trajectory traj0 = traj.toTrajectory();
294 // Check the number of pixels
295  const Trajectory::DataContainer tms = traj0.measurements();
296  int ipix = 0;
297  for( Trajectory::DataContainer::const_iterator itm = tms.begin(); itm != tms.end(); itm++) {
298  if((*itm).layer()->subDetector() == GeomDetEnumerators::PixelEndcap || (*itm).layer()->subDetector() == GeomDetEnumerators::PixelBarrel) ipix++;
299  }
300 
301 #ifdef DEBUG
302  cout<<" Number of pixels "<<ipix<<endl;
303 #endif
304 
305  if(ipix < 1) return false;
306 
307 //
308 // Refit the trajectory
309 //
310 
312  matrix(2,2) = 0.001;
313  matrix(3,3) = 0.001;
314 
316  0.1,
317  0.,
318  0.,
319  0.,
320  matrix
321  );
322 
323  enum RefitDirection{insideOut,outsideIn,undetermined};
324 
325  Trajectory::ConstRecHitContainer recHitsForReFit = traj0.recHits();
326 
327 #ifdef DEBUG
328  cout<<" Take recHits for reFit "<<endl;
329 #endif
330 
331 
332  PTrajectoryStateOnDet garbage1;
334 // TrajectoryStateOnSurface firstTSOS = traj0.firstMeasurement().updatedState();
335 
337  Trajectory::ConstRecHitContainer newRecHitsForReFit;
338  for(Trajectory::ConstRecHitContainer::const_iterator it=recHitsForReFit.end()-1; it!=recHitsForReFit.begin()-1; it--){
339 // cout<<" RecHIT is valid "<<(*it)->isValid()<<endl;
340  if((*it)->isValid()) {
341 // cout<<(*it)->globalPosition()<<endl;
342  newRecHitsForReFit.push_back(*it);
343  }
344 // else{cout<<" Invalid! "<<endl;
345 // }
346  }
347 
348 
349 
350 
351 #ifdef DEBUG
352  cout<<" Take firstTSOS "<<firstTSOS.isValid()<<endl;
353  if(firstTSOS.isValid()) cout<<firstTSOS.freeTrajectoryState()->charge()<<" "<<firstTSOS.freeTrajectoryState()->position()<<" "<<firstTSOS.freeTrajectoryState()->momentum()<<endl;
354 #endif
355 
356 // PropagationDirection propDir = oppositeToMomentum;
358  TrajectorySeed seed(garbage1,garbage2,propDir);
359  vector<Trajectory> trajectories = theFitterTrack->fit(seed,newRecHitsForReFit,firstTSOS);
360 
361  // vector<Trajectory> trajectories = theFitterTrack->fit(seed,recHitsForReFit,firstTSOS);
362  // vector<Trajectory> trajectories = theFitterTrack->fit(seed,recHitsForReFit);
363  // vector<Trajectory> trajectories = theFitterTrack->fit(traj0);
364 
365 #ifdef DEBUG
366  cout<<" fit Trajectory "<<endl;
367 #endif
368 
369 
370 
371  TrajectoryStateOnSurface innertsos;
372 
373  if (traj0.direction() == alongMomentum) {
374  // cout<<" Direction is along momentum "<<endl;
375  innertsos = traj0.firstMeasurement().updatedState();
376  } else {
377  innertsos = traj0.lastMeasurement().updatedState();
378  // cout<<" Direction is opposite to momentum "<<endl;
379 
380  }
381 
382 #ifdef DEBUG
383  cout<<" take inertsos "<<endl;
384 #endif
385 
386 
387  TSCBLBuilderNoMaterial tscblBuilder;
388 
389  //TrajectoryStateClosestToBeamLineBuilder tscblBuilder;
390  TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(*(innertsos.freeState()),bs);
391 
392 #ifdef DEBUG
393  cout<<" closest to Beam "<<endl;
394 #endif
395 
396 
397  if (tscbl.isValid()==false) {
398  //cout<<" false track "<<endl;
399  return false;
400  }
401 
403  math::XYZPoint pos( v.x(), v.y(), v.z() );
404 
405 #ifdef DEBUG
406  cout<<" check vertex constraints "<<endl;
407 #endif
408 
409 
410  if(v.perp() > 0.1 ) return false;
411  if(fabs(v.z() - theHICConst->zvert ) > 0.4 ) return false;
412 
413  return true;
414 
415 }
416 
417 
420 {
421  Trajectory traj = tmptraj.toTrajectory();
422  result.push_back( traj);
423 }
424 
426  const TM& tm) const
427 {
428  bool good=false;
429 #ifdef DEBUG
430  std::cout<<"HICTrajectoryBuilder::updateTrajectory::start"<<std::endl;
431 #endif
432  TSOS predictedState = tm.predictedState();
434  Trajectory traj0 = traj.toTrajectory();
435 
436 // My update
437  vector<double> theCut = dynamic_cast<HICMeasurementEstimator*>
438  (const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->setCuts(traj0,tm.layer());
439  int icut = 3;
441  const MagneticField * mf = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->getField();
442  HICMuonUpdator hicup(theCut[2],theCut[3], mf,theHICConst);
443  double chi2rz,chi2rf;
444 
445  if ( hit->isValid()) {
446 // Check the charge
447 // if() {
448 
449  TrajectoryMeasurement tmlast = traj.lastMeasurement();
450  TM::ConstRecHitPointer lasthit = tmlast.recHit();
451  double dfi1 = predictedState.freeTrajectoryState()->position().phi() - lasthit->globalPosition().phi();
452  double dfi2 = hit->globalPosition().phi() - lasthit->globalPosition().phi();
453 
454 
455  if(dfi1*dfi2<0) {
456 // cout<<" Need to change charge "<<endl;
457  TrackCharge aCharge = -1*predictedState.freeTrajectoryState()->charge();
458  GlobalPoint xnew = predictedState.globalPosition();
459  GlobalVector pnew = predictedState.globalMomentum();
461  GlobalTrajectoryParameters(xnew, pnew, aCharge, predictedState.magneticField()),
462  predictedState.curvilinearError(), predictedState.surface());
463  predictedState = tsos;
464  }
465 
466 // Update trajectory
467 //
468  TrajectoryStateOnSurface newUpdateState=hicup.update(traj0, predictedState, tm, tm.layer(), chi2rz, chi2rf);
469 
470  bool accept=
471  (dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->estimate(newUpdateState,*hit)).first;
472  if(accept)
473  {
474 #ifdef DEBUG
475  std::cout<<" updateTrajectory::UpdateState::New momentum "<<newUpdateState.freeTrajectoryState()->momentum().perp()<<" "<<newUpdateState.freeTrajectoryState()->momentum().z()<<std::endl;
476 #endif
477  TM tmp = TM(predictedState, newUpdateState, hit, tm.estimate(), tm.layer());
478 
479  traj.push(tmp );
480  good=true;
481  return good;
482  }
483  else
484  {
485 #ifdef DEBUG
486  std::cout<<" updateTrajectory::failed after update "<<accept<<std::endl;
487 #endif
488  return good;
489  }
490  }
491  else {
492  return good;
493  }
494 }
495 
497 {
498  if ( traj.lostHits() > theMaxLostHit) return false;
499 
500  // check for conscutive lost hits only at the end
501  // (before the last valid hit),
502  // since if there was an unacceptable gap before the last
503  // valid hit the trajectory would have been stopped already
504 
505  int consecLostHit = 0;
506 
507  const TempTrajectory::DataContainer & tms = traj.measurements();
508  //for( TempTrajectory::DataContainer::const_iterator itm=tms.end()-1; itm>=tms.begin(); itm--) {
509  for( TempTrajectory::DataContainer::const_iterator itm=tms.rbegin(), itb = tms.rend(); itm != itb; --itm) {
510  if (itm->recHit()->isValid()) break;
511  else if ( // FIXME: restore this: !Trajectory::inactive(itm->recHit()->det()) &&
512  Trajectory::lost(*itm->recHit())) consecLostHit++;
513  }
514  if (consecLostHit > theMaxConsecLostHit) return false;
515 
516  // stopping condition from region has highest priority
517  // if ( regionalCondition && !(*regionalCondition)(traj) ) return false;
518  // next: pt-cut
519  //if ( !(*theMinPtCondition)(traj) ) return false;
520  //if ( !(*theMaxHitsCondition)(traj) ) return false;
521  // finally: configurable condition
522  // FIXME: restore this: if ( !(*theConfigurableCondition)(traj) ) return false;
523 
524  return true;
525 }
526 
527 std::vector<TrajectoryMeasurement>
529 {
530  //cout<<" HICTrajectoryBuilder::FindCompatibleMeasurement start "<<traj.empty()<<endl;
531  vector<TM> result;
532  // int invalidHits = 0;
533  int theLowMult = 1;
534 
535  TSOS currentState( traj.lastMeasurement().updatedState());
536 
537  vector<const DetLayer*> nl =
538  traj.lastLayer()->nextLayers( *currentState.freeState(), traj.direction());
539 #ifdef DEBUG
540  std::cout<<" Number of layers "<<nl.size()<<std::endl;
541 #endif
542 
543  if (nl.empty()) return result;
544 
545  int seedLayerCode = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->
546  getDetectorCode(traj.measurements().front().layer());
547 #ifdef DEBUG
548  std::cout<<"findCompatibleMeasurements Point 0 "<<seedLayerCode<<std::endl;
549 #endif
550 
551  int currentLayerCode = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->
552  getDetectorCode(traj.lastLayer());
553 #ifdef DEBUG
554  std::cout<<"findCompatibleMeasurements Point 1 "<<currentLayerCode<<std::endl;
555 #endif
556  for (vector<const DetLayer*>::iterator il = nl.begin();
557  il != nl.end(); il++) {
558 
559  int nextLayerCode = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->
560  getDetectorCode((*il));
561 #ifdef DEBUG
562  std::cout<<"findCompatibleMeasurements Point 2 "<<nextLayerCode<<std::endl;
563 #endif
564 
565  if( traj.lastLayer()->location() == GeomDetEnumerators::endcap && (**il).location() == GeomDetEnumerators::barrel )
566  {
567  if( abs(seedLayerCode) > 100 && abs(seedLayerCode) < 108 )
568  {
569  if( (**il).subDetector() == GeomDetEnumerators::PixelEndcap ) continue;
570  } // 100-108
571  else
572  {
573  if(theLowMult == 0 )
574  {
575  if( nextLayerCode == 0 ) continue;
576  }
577  if( (**il).subDetector() == GeomDetEnumerators::TID || (**il).subDetector() == GeomDetEnumerators::TEC) continue;
578  } // 100-108
579  } // barrel and endcap
580 
581  if( currentLayerCode == 101 && nextLayerCode < 100 ) {
582  continue;
583  } // currentLayer-nextLayer
584 #ifdef DEBUG
585  std::cout<<" findCompatibleMeasurements Point 3 "<<nextLayerCode<<std::endl;
586 #endif
587 
588  Trajectory traj0 = traj.toTrajectory();
589 
590  vector<double> theCut = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->setCuts(traj0,(*il));
591 
592  // Choose Win
593  int icut = 1;
595 #ifdef DEBUG
596  std::cout<<" findCompatibleMeasurements::current state : "<<
597  " charge "<< currentState.freeTrajectoryState()->parameters().charge()<<
598  " pt "<<currentState.freeTrajectoryState()->parameters().momentum().perp()<<
599  " pz "<<currentState.freeTrajectoryState()->parameters().momentum().z()<<
600  " r "<<currentState.freeTrajectoryState()->parameters().position().perp()<<
601  " phi "<<currentState.freeTrajectoryState()->parameters().position().phi()<<
602  " z "<<currentState.freeTrajectoryState()->parameters().position().z()<<
603  endl;
604 #endif
605  const MagneticField * mf = dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->getField();
606  vector<TM> tmp0;
607 
608 //
609 // We must check the charge of the high pt track after first step
610 //
611 
612 /*
613  if(abs(currentLayerCode) > 100&&traj0.measurements().size()>1) {
614  HICMuonPropagator hmp(mf);
615 #ifdef DEBUG
616  std::cout<<" findCompatibleMeasurements::HICMuonPropagator::for forward::start "<<std::endl;
617 #endif
618  tmp0 =
619  theLayerMeasurements->measurements((**il), currentState, hmp, *theEstimator);
620  for( vector<TM>::iterator itm = tmp0.begin(); itm != tmp0.end(); itm++ )
621  {
622  TM tm = (*itm);
623  TSOS predictedState = tm.predictedState();
624  TM::ConstRecHitPointer hit = tm.recHit();
625  TSOS updateState = traj0.lastMeasurement().updatedState();
626 #ifdef DEBUG
627  std::cout<<" findCompatibleMeasurements::Size of trajectory "<<traj0.measurements().size()<<
628  " valid updated state "<< updateState.isValid()<<" Predicted state is valid "
629  <<predictedState.isValid()<<
630  " charge "<< predictedState.freeTrajectoryState()->parameters().charge()<<
631  " pt "<<predictedState.freeTrajectoryState()->parameters().momentum().perp()<<
632  " pz "<<predictedState.freeTrajectoryState()->parameters().momentum().z()<<
633  " r "<<predictedState.freeTrajectoryState()->parameters().position().perp()<<
634  " phi "<<predictedState.freeTrajectoryState()->parameters().position().phi()<<
635  " z "<<predictedState.freeTrajectoryState()->parameters().position().z()<<
636  std::endl;
637 #endif
638  }
639 #ifdef DEBUG
640  std::cout<<" findCompatibleMeasurements::HICMuonPropagator::for forward::end "<<std::endl;
641 #endif
642  }
643 */
644  tmp0 = theLayerMeasurements->measurements((**il), currentState, *theForwardPropagator, *theEstimator);
645 
646 #ifdef DEBUG
647  std::cout<<" findCompatibleMeasurements Point 6 "<<theCut[0]<<" "<<theCut[1]<<std::endl;
648  std::cout<<" findCompatibleMeasurements Point 7 "<<traj0.measurements().size()<<std::endl;
649 #endif
650 //
651 // ========================= Choose Cut and filter =================================
652 //
653  vector<TM> tmp;
654  icut = 2;
656 #ifdef DEBUG
657  std::cout<<" findCompatibleMeasurements Point 8 "<<theCut[0]<<" "<<theCut[1]<<" Size of candidates "<<tmp0.size()<<std::endl;
658 #endif
659  int numtmp = 0;
660  for( vector<TM>::iterator itm = tmp0.begin(); itm != tmp0.end(); itm++ )
661  {
662  TM tm = (*itm);
663  TSOS predictedState = tm.predictedState();
665  TSOS updateState = traj0.lastMeasurement().updatedState();
666 //
667 // If track is not valid - stop with this hit
668 //
669  if(!(*hit).isValid()) {
670 #ifdef DEBUG
671  cout<<" findCompatibleMeasurements::hit is not valid "<<endl;
672 #endif
673  continue;
674  }
675 
676 #ifdef DEBUG
677  std::cout<<" findCompatibleMeasurements::Size of trajectory "<<traj0.measurements().size()
678  <<" Number of TM "<< numtmp<<
679  " valid updated state "<< updateState.isValid()<<" Predicted state is valid "
680  <<predictedState.isValid()<<
681  " charge "<< predictedState.freeTrajectoryState()->parameters().charge()<<
682  " pt "<<predictedState.freeTrajectoryState()->parameters().momentum().perp()<<
683  " pz "<<predictedState.freeTrajectoryState()->parameters().momentum().z()<<
684  " r "<<predictedState.freeTrajectoryState()->parameters().position().perp()<<
685  " phi "<<predictedState.freeTrajectoryState()->parameters().position().phi()<<
686  " z "<<predictedState.freeTrajectoryState()->parameters().position().z()<<
687  std::endl;
688 #endif
689 
690  if( traj0.measurements().size() == 1 )
691  {
692 #ifdef DEBUG
693  std::cout<<" findCompatibleMeasurements::start corrector "<<std::endl;
694 #endif
695  HICTrajectoryCorrector theCorrector(mf,theHICConst);
696 #ifdef DEBUG
697  std::cout<<" findCompatibleMeasurements::corrector::initialized "<<std::endl;
698 #endif
699  TSOS predictedState0 = theCorrector.correct( (*traj0.lastMeasurement().updatedState().freeTrajectoryState()),
700  (*(predictedState.freeTrajectoryState())),
701  hit->det() );
702 #ifdef DEBUG
703  std::cout<<" findCompatibleMeasurements::end corrector "<<std::endl;
704 #endif
705  if(predictedState0.isValid())
706  {
707 #ifdef DEBUG
708  std::cout<<" Accept the corrected state "<<numtmp<<" Hit Valid "<<(*hit).isValid()<<std::endl;
709 #endif
710  predictedState = predictedState0;
711 
712  if((*hit).isValid())
713  {
714 #ifdef DEBUG
715  std::cout<<" findCompatibleMeasurements::end corrector::hit valid "<<std::endl;
716 #endif
717  bool accept= true;
718  accept = (dynamic_cast<HICMeasurementEstimator*>(const_cast<Chi2MeasurementEstimatorBase*>(theEstimator))->estimate(predictedState,*hit)).first;
719 
720  if(!accept) {
721 #ifdef DEBUG
722  std::cout<<" findCompatibleMeasurements::failed after the first step "<<numtmp<<std::endl;
723 #endif
724  numtmp++;
725  continue;
726  } // accept
727 #ifdef DEBUG
728  std::cout<<" findCompatibleMeasurements::estimate at the first step is ok "<<numtmp<<std::endl;
729 #endif
730 // Add trajectory measurements
731  tmp.push_back(TM(predictedState, updateState, hit, tm.estimate(), tm.layer()));
732 #ifdef DEBUG
733  std::cout<<" findCompatibleMeasurements::fill estimate "<<numtmp<<std::endl;
734 #endif
735  } // Hit Valid
736 
737  } // predicted state is valid
738  } // first step
739  else
740  {
741 // tmp.push_back(TM(predictedState, updateState, hit, tm.estimate(), tm.layer()));
742 #ifdef DEBUG
743  std::cout<<" findCompatibleMeasurements::Add TM to collection::Predicted state is valid "<<predictedState.isValid()<<" Hit is valid "<<(*hit).isValid()<<std::endl;
744 #endif
745  if( predictedState.isValid() && (*hit).isValid() ) tmp.push_back(*itm);
746  }
747  numtmp++;
748 
749  } // tm
750 #ifdef DEBUG
751  std::cout<<" findCompatibleMeasurements::point 9 "<<std::endl;
752 #endif
753  if ( !tmp.empty()) {
754  if ( result.empty() ) result = tmp;
755  else {
756  // keep one dummy TM at the end, skip the others
757  result.insert( result.end(), tmp.begin(), tmp.end());
758  }
759  }
760  // std::cout<<" Results size "<<result.size()<<std::endl;
761  } // next layers
762 
763  // sort the final result, keep dummy measurements at the end
764  if ( result.size() > 1) {
765  sort( result.begin(), result.end(), TrajMeasLessEstim());
766  }
767 #ifdef DEBUG
768  std::cout<<" findCompatibleMeasurements::point 10 "<<std::endl;
769 #endif
770  return result;
771 }
772 
PropagationDirection direction() const
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:32
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
const_iterator rend() const
Definition: bqueue.h:145
int i
Definition: DBlmapReader.cc:9
edm::ESHandle< Propagator > thePropagatorTrack
bool qualityFilter(const TempTrajectory &traj) const
T perp() const
Definition: PV3DBase.h:71
static bool lost(const TransientTrackingRecHit &hit)
Definition: Trajectory.cc:205
bool empty() const
True if trajectory has no measurements.
virtual Location location() const =0
Which part of the detector (barrel, endcap)
const GlobalTrajectoryParameters & parameters() const
float zvert
Definition: HICConst.h:25
const MeasurementTracker * theMeasurementTracker
FreeTrajectoryState * freeTrajectoryState(bool withErrors=true) const
const CurvilinearTrajectoryError & curvilinearError() const
std::vector< TempTrajectory > TempTrajectoryContainer
const DataContainer & measurements() const
virtual std::vector< const DetLayer * > nextLayers(NavigationDirection direction) const
Definition: DetLayer.cc:35
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
T y() const
Definition: PV3DBase.h:62
#define abs(x)
Definition: mlp_lapack.h:159
GlobalPoint globalPosition() const
bool toBeContinued(const TempTrajectory &traj) const
ConstRecHitPointer recHit() const
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:30
int foundHits() const
obsolete name, use measurements() instead.
PropagationDirection
TrackCharge charge() const
virtual std::vector< double > setCuts(Trajectory &traj, const DetLayer *theCurrentLayer)
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:22
const MagneticField * magneticField() const
const Chi2MeasurementEstimatorBase * theEstimator
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
Definition: Trajectory.h:43
ConstRecHitContainer recHits(bool splitting=false) const
Definition: Trajectory.cc:67
const TrajectoryMeasurement & lastMeasurement() const
PropagationDirection const & direction() const
Definition: Trajectory.cc:195
edm::ESHandle< GlobalTrackingGeometry > globTkGeomHandle
PropagationDirection direction() const
DataContainer const & measurements() const
Definition: Trajectory.h:203
int TrackCharge
Definition: TrackCharge.h:4
virtual TrajectoryContainer trajectories(const TrajectorySeed &seed) const
trajectories building starting from a seed
std::vector< TrajectoryMeasurement > findCompatibleMeasurements(const TempTrajectory &traj) const
std::vector< TrajectoryMeasurement > DataContainer
Definition: Trajectory.h:42
FreeTrajectoryState * freeState(bool withErrors=true) const
Trajectory toTrajectory() const
Convert to a standard Trajectory.
const MagneticField * getField()
std::vector< Trajectory > TrajectoryContainer
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:181
const LayerMeasurements * theLayerMeasurements
T z() const
Definition: PV3DBase.h:63
tuple result
Definition: query.py:137
const DetLayer * layer() const
TrajectoryStateOnSurface updatedState() const
TrajectoryStateOnSurface predictedState() const
virtual void setSign(int &i)
HICTrajectoryBuilder(const edm::ParameterSet &conf, const edm::EventSetup &es, const TrajectoryStateUpdator *updator, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const Chi2MeasurementEstimatorBase *estimator, const TransientTrackingRecHitBuilder *RecHitBuilder, const MeasurementTracker *measurementTracker, const TrajectoryFilter *filter)
cms::HICConst * theHICConst
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
bool first
Definition: L1TdeRCT.cc:94
const Propagator * theForwardPropagator
GlobalVector momentum() const
double chiSquared() const
Value of the raw Chi2 of the trajectory, not normalised to the N.D.F.
tuple conf
Definition: dbtoconf.py:185
void limitedCandidates(TempTrajectory &startingTraj, TrajectoryContainer &result) const
GlobalPoint position() const
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:194
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
const T & get() const
Definition: EventSetup.h:55
iterator rbegin()
Definition: bqueue.h:143
void addToResult(TempTrajectory &traj, TrajectoryContainer &result) const
TrajectoryStateOnSurface correct(FreeTrajectoryState &rh, FreeTrajectoryState &ftsnew, const GeomDet *plane) const
std::vector< TrajectoryMeasurement > seedMeasurements(const TrajectorySeed &seed) const
virtual void setEvent(const edm::Event &event) const
set Event for the internal MeasurementTracker data member
TrajectoryMeasurement TM
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
GlobalVector globalMomentum() const
bool updateTrajectory(TempTrajectory &traj, const TM &tm) const
const Surface & surface() const
const Propagator * theBackwardPropagator
edm::ESHandle< TrajectorySmoother > theSmootherTrack
tuple cout
Definition: gather_cfg.py:121
size_type size() const
Definition: bqueue.h:146
TempTrajectory createStartingTrajectory(const TrajectorySeed &seed) const
edm::ESHandle< TrajectoryFitter > theFitterTrack
virtual std::pair< bool, double > estimate(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const
TrajectoryStateOnSurface update(const Trajectory &mt, const TrajectoryStateOnSurface &, const TrajectoryMeasurement &, const DetLayer *, double &, double &) const
const DetLayer * lastLayer() const
Redundant method, returns the layer of lastMeasurement() .
T x() const
Definition: PV3DBase.h:61
mathSSE::Vec4< T > v
std::vector< TrajectoryMeasurement > measurements() const
int lostHits() const
void push(const TrajectoryMeasurement &tm)