CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes
MultiVertexFitter Class Reference

#include <MultiVertexFitter.h>

Public Types

typedef std::map< int, double > SeedToWeightMap
 
typedef std::map< reco::TransientTrack, SeedToWeightMapTrackAndSeedToWeightMap
 
typedef std::pair< reco::TransientTrack, float > TrackAndWeight
 

Public Member Functions

 MultiVertexFitter (const AnnealingSchedule &sched=DefaultMVFAnnealing(), const LinearizationPointFinder &seeder=DefaultLinearizationPointFinder(), float revive_below=-1.)
 
 MultiVertexFitter (const MultiVertexFitter &)
 
std::vector< CachingVertex< 5 > > vertices (const std::vector< std::vector< reco::TransientTrack > > &, const std::vector< reco::TransientTrack > &primaries=std::vector< reco::TransientTrack >())
 
std::vector< CachingVertex< 5 > > vertices (const std::vector< std::vector< TrackAndWeight > > &, const std::vector< reco::TransientTrack > &primaries=std::vector< reco::TransientTrack >())
 
std::vector< CachingVertex< 5 > > vertices (const std::vector< CachingVertex< 5 > > &, const std::vector< reco::TransientTrack > &primaries=std::vector< reco::TransientTrack >())
 
std::vector< CachingVertex< 5 > > vertices (const std::vector< TransientVertex > &, const std::vector< reco::TransientTrack > &primaries=std::vector< reco::TransientTrack >())
 
 ~MultiVertexFitter ()
 

Private Types

typedef ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
 
typedef CachingVertex< 5 >::RefCountedVertexTrack RefCountedVertexTrack
 

Private Member Functions

void clear ()
 
void createPrimaries (const std::vector< reco::TransientTrack > &tracks)
 
void createSeed (const std::vector< reco::TransientTrack > &tracks)
 
void createSeed (const std::vector< TrackAndWeight > &tracks)
 
std::vector< CachingVertex< 5 > > fit ()
 
void lostVertexClaimer ()
 
void printSeeds () const
 
void printWeights () const
 
void printWeights (const reco::TransientTrack &) const
 
void resetSeedNr ()
 
int seedNr ()
 
bool updateSeeds ()
 
void updateWeights ()
 

Private Attributes

AnnealingScheduletheAssComp
 
LinTrackCache theCache
 
std::set< reco::TransientTrackthePrimaries
 
float theReviveBelow
 
LinearizationPointFindertheSeeder
 
std::vector< reco::TransientTracktheTracks
 
int theVertexStateNr
 
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
 
TrackAndSeedToWeightMap theWeights
 

Detailed Description

fits n vertices in parallel, associating weights for every track-vertex std::pair. The special constructor's arguments take precedence over the SimpleConfigurables.

SimpleConfigurables:

MultiVertexFitter:Debug = 0 MultiVertexFitter:DisplacementLimit = 0.00001 MultiVertexFitter:MaxIterations = 30 MultiVertexFitter:ClaimLostVertices = true MultiVertexFitter:MinimumWeightFraction = 1e-6 MultiVertexFitter:ReviveBelow = 0.3 MultiVertexFitter:DiscardLightWeights = true

Definition at line 15 of file MultiVertexFitter.h.

Member Typedef Documentation

Definition at line 106 of file MultiVertexFitter.h.

Definition at line 105 of file MultiVertexFitter.h.

typedef std::map< int , double > MultiVertexFitter::SeedToWeightMap

Definition at line 44 of file MultiVertexFitter.h.

Definition at line 45 of file MultiVertexFitter.h.

Definition at line 43 of file MultiVertexFitter.h.

Constructor & Destructor Documentation

MultiVertexFitter::MultiVertexFitter ( const AnnealingSchedule sched = DefaultMVFAnnealing(),
const LinearizationPointFinder seeder = DefaultLinearizationPointFinder(),
float  revive_below = -1. 
)

Definition at line 334 of file MultiVertexFitter.cc.

336  :
337  theVertexStateNr ( 0 ), theReviveBelow ( revive_below ),
338  theAssComp ( ann.clone() ), theSeeder ( seeder.clone() )
339 {}
LinearizationPointFinder * theSeeder
virtual LinearizationPointFinder * clone() const =0
AnnealingSchedule * theAssComp
MultiVertexFitter::MultiVertexFitter ( const MultiVertexFitter o)

Definition at line 341 of file MultiVertexFitter.cc.

341  :
344 {}
LinearizationPointFinder * theSeeder
virtual LinearizationPointFinder * clone() const =0
virtual AnnealingSchedule * clone() const =0
AnnealingSchedule * theAssComp
MultiVertexFitter::~MultiVertexFitter ( )

Definition at line 346 of file MultiVertexFitter.cc.

References theAssComp, and theSeeder.

347 {
348  delete theAssComp;
349  delete theSeeder;
350 }
LinearizationPointFinder * theSeeder
AnnealingSchedule * theAssComp

Member Function Documentation

void MultiVertexFitter::clear ( void  )
private

Definition at line 88 of file MultiVertexFitter.cc.

89 {
91  theTracks.clear();
92  thePrimaries.clear();
93  theVertexStates.clear();
94  theWeights.clear();
95  theCache.clear();
96 }
std::set< reco::TransientTrack > thePrimaries
std::vector< reco::TransientTrack > theTracks
LinTrackCache theCache
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
virtual void resetAnnealing()=0
AnnealingSchedule * theAssComp
TrackAndSeedToWeightMap theWeights
void MultiVertexFitter::createPrimaries ( const std::vector< reco::TransientTrack > &  tracks)
private

Definition at line 118 of file MultiVertexFitter.cc.

References mps_fire::i.

119 {
120  // cout << "[MultiVertexFitter] creating primaries: ";
121  for ( vector< reco::TransientTrack >::const_iterator i=tracks.begin();
122  i!=tracks.end() ; ++i )
123  {
124  thePrimaries.insert ( *i );
125  // cout << i->id() << " ";
126  }
127  // cout << endl;
128 }
std::set< reco::TransientTrack > thePrimaries
void MultiVertexFitter::createSeed ( const std::vector< reco::TransientTrack > &  tracks)
private

Definition at line 101 of file MultiVertexFitter.cc.

References HiIsolationCommonParameters_cff::track, and extraflags_cff::vtx.

102 {
103  if ( tracks.size() > 1 )
104  {
105  CachingVertex<5> vtx = createSeedFromLinPt (
107  int snr= seedNr();
108  theVertexStates.push_back ( pair < int, CachingVertex<5> > ( snr, vtx ) );
109  for ( vector< TransientTrack >::const_iterator track=tracks.begin();
110  track!=tracks.end() ; ++track )
111  {
112  theWeights[*track][snr]=1.;
113  theTracks.push_back ( *track );
114  };
115  };
116 }
LinearizationPointFinder * theSeeder
std::vector< reco::TransientTrack > theTracks
virtual GlobalPoint getLinearizationPoint(const std::vector< reco::TransientTrack > &) const =0
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
TrackAndSeedToWeightMap theWeights
void MultiVertexFitter::createSeed ( const std::vector< TrackAndWeight > &  tracks)
private

Definition at line 140 of file MultiVertexFitter.cc.

References gather_cfg::cout, mps_fire::i, HiIsolationCommonParameters_cff::track, KalmanVertexFitter::vertex(), VertexTrackFactory< N >::vertexTrack(), extraflags_cff::vtx, and mps_merge::weight.

141 {
142  // create initial seed for every bundle
143  vector < RefCountedVertexTrack> newTracks;
144 
145  for ( vector< TrackAndWeight >::const_iterator track=tracks.begin();
146  track!=tracks.end() ; ++track )
147  {
148  double weight = validWeight ( track->second );
149  const GlobalPoint & pos = track->first.impactPointState().globalPosition();
150  GlobalError err; // FIXME
151  VertexState realseed ( pos, err );
152 
154  theCache.linTrack ( pos, track->first );
155 
156  VertexTrackFactory<5> vTrackFactory;
157  RefCountedVertexTrack vTrData = vTrackFactory.vertexTrack(
158  lTrData, realseed, weight );
159  newTracks.push_back ( vTrData );
160  };
161 
162  if ( newTracks.size() > 1 )
163  {
164  CachingVertex<5> vtx = KalmanVertexFitter().vertex ( newTracks );
165  int snr = seedNr();
166  theVertexStates.push_back ( pair < int, CachingVertex<5> > ( snr, vtx ) );
167 
168  // We initialise the weights with the original
169  // user supplied weights.
170  for ( vector< TrackAndWeight >::const_iterator track=tracks.begin();
171  track!=tracks.end() ; ++track )
172  {
173  if ( thePrimaries.count ( track->first ) )
174  {
175  /*
176  cout << "[MultiVertexFitter] " << track->first.id() << " is a primary."
177  << " setting weight for state " << theVertexStates[0].first
178  << " to " << track->second
179  << endl;
180  */
181  theWeights[track->first][theVertexStates[0].first]=track->second;
182  continue;
183  };
184  float weight = track->second;
185  if ( weight > 1.0 )
186  {
187  cout << "[MultiVertexFitter] error weight " << weight << " > 1.0 given."
188  << endl;
189  cout << "[MultiVertexFitter] will revert to 1.0" << endl;
190  weight=1.0;
191  };
192  if ( weight < 0.0 )
193  {
194  cout << "[MultiVertexFitter] error weight " << weight << " < 0.0 given."
195  << endl;
196  cout << "[MultiVertexFitter] will revert to 0.0" << endl;
197  weight=0.0;
198  };
199  theWeights[track->first][snr]=weight;
200  theTracks.push_back ( track->first );
201  };
202  };
203 
204  // this thing will actually have to discard tracks
205  // that have been submitted - attached to a different vertex - already.
206  // sort ( theTracks.begin(), theTracks.end(), CompareRaveTracks() );
207  sort ( theTracks.begin(), theTracks.end() );
208  for ( vector< TransientTrack >::iterator i=theTracks.begin();
209  i<theTracks.end() ; ++i )
210  {
211  if ( i != theTracks.begin() )
212  {
213  if ( (*i) == ( *(i-1) ) )
214  {
215  theTracks.erase ( i );
216  };
217  };
218  };
219 }
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
Definition: weight.py:1
std::set< reco::TransientTrack > thePrimaries
std::vector< reco::TransientTrack > theTracks
LinTrackCache theCache
ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
RefCountedLinearizedTrackState linTrack(const GlobalPoint &, const reco::TransientTrack &)
CachingVertex< 5 >::RefCountedVertexTrack RefCountedVertexTrack
TrackAndSeedToWeightMap theWeights
vector< CachingVertex< 5 > > MultiVertexFitter::fit ( void  )
private

Definition at line 582 of file MultiVertexFitter.cc.

References AnnealingSchedule::anneal(), gather_cfg::cout, mps_fire::i, AnnealingSchedule::isAnnealed(), printWeights(), resetSeedNr(), theAssComp, theVertexStates, updateSeeds(), and verbose.

Referenced by trackingPlots.Iteration::modules().

583 {
584  if ( verbose() & 2 ) printWeights();
585  int ctr=1;
586  static const int ctr_max = 50; /* SimpleConfigurable<int>(100,
587  "MultiVertexFitter:MaxIterations").value(); */
588  while ( updateSeeds() || !(theAssComp->isAnnealed()) )
589  {
590  if ( ++ctr >= ctr_max ) break;
591  theAssComp->anneal();
592  // lostVertexClaimer(); // was a silly(?) idea to "revive" vertex candidates.
593  resetSeedNr();
594  };
595 
596  if ( verbose() )
597  {
598  cout << "[MultiVertexFitter] number of iterations: " << ctr << endl;
599  cout << "[MultiVertexFitter] remaining seeds: "
600  << theVertexStates.size() << endl;
601  printWeights();
602  };
603 
604  vector < CachingVertex<5> > ret;
605  for ( vector< pair < int, CachingVertex<5> > >::const_iterator
606  i=theVertexStates.begin(); i!=theVertexStates.end() ; ++i )
607  {
608  ret.push_back ( i->second );
609  };
610 
611  return ret;
612 }
void printWeights() const
virtual bool isAnnealed() const =0
static int verbose
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
virtual void anneal()=0
AnnealingSchedule * theAssComp
void MultiVertexFitter::lostVertexClaimer ( )
private

Definition at line 659 of file MultiVertexFitter.cc.

References gather_cfg::cout, mps_fire::i, printWeights(), theReviveBelow, theTracks, theVertexStates, theWeights, and verbose.

660 {
661  if ( !(theReviveBelow < 0.) ) return;
662  // this experimental method is used to get almost lost vertices
663  // back into the play by upweighting vertices with very low total weights
664 
665  bool has_revived = false;
666  // find out about total weight
667  for ( vector< pair < int, CachingVertex<5> > >::const_iterator i=theVertexStates.begin();
668  i!=theVertexStates.end() ; ++i )
669  {
670  double totweight=0.;
671  for ( vector< TransientTrack >::const_iterator trk=theTracks.begin();
672  trk!=theTracks.end() ; ++trk )
673  {
674  totweight+=theWeights[*trk][i->first];
675  };
676 
677  /*
678  cout << "[MultiVertexFitter] vertex seed " << TransientVertexNamer().name(*i)
679  << " total weight=" << totweight << endl;*/
680 
681  if ( totweight < theReviveBelow && totweight > 0.0 )
682  {
683  cout << "[MultiVertexFitter] now trying to revive vertex"
684  << " revive_below=" << theReviveBelow << endl;
685  has_revived=true;
686  for ( vector< TransientTrack >::const_iterator trk=theTracks.begin();
687  trk!=theTracks.end() ; ++trk )
688  {
689  theWeights[*trk][i->first]/=totweight;
690  };
691  };
692  };
693  if ( has_revived && verbose() ) printWeights();
694 }
void printWeights() const
static int verbose
std::vector< reco::TransientTrack > theTracks
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
TrackAndSeedToWeightMap theWeights
void MultiVertexFitter::printSeeds ( ) const
private

Definition at line 647 of file MultiVertexFitter.cc.

References gather_cfg::cout.

Referenced by updateSeeds().

648 {
649  cout << endl << "Seed table: " << endl << "=====================" << endl;
650  /*
651  for ( vector < pair < int, CachingVertex<5> > >::const_iterator seed=theVertexStates.begin();
652  seed!=theVertexStates.end(); ++seed )
653  {
654  cout << " Vertex[" << TransientVertexNamer().name(seed->second) << "] at "
655  << seed->second.position() << endl;
656  };*/
657 }
void MultiVertexFitter::printWeights ( ) const
private

Definition at line 632 of file MultiVertexFitter.cc.

References gather_cfg::cout, thePrimaries, and theTracks.

Referenced by fit(), lostVertexClaimer(), and updateWeights().

633 {
634  cout << endl << "Weight table: " << endl << "=================" << endl;
635  for ( set < TransientTrack >::const_iterator trk=thePrimaries.begin();
636  trk!=thePrimaries.end() ; ++trk )
637  {
638  printWeights ( *trk );
639  };
640  for ( vector< TransientTrack >::const_iterator trk=theTracks.begin();
641  trk!=theTracks.end() ; ++trk )
642  {
643  printWeights ( *trk );
644  };
645 }
void printWeights() const
std::set< reco::TransientTrack > thePrimaries
std::vector< reco::TransientTrack > theTracks
void MultiVertexFitter::printWeights ( const reco::TransientTrack t) const
private

Definition at line 614 of file MultiVertexFitter.cc.

References a, b, gather_cfg::cout, SurveyInfoScenario_cff::seed, theVertexStates, theWeights, and heppy_batch::val.

615 {
616  // cout << "Trk " << t.id();
617  for ( vector < pair < int, CachingVertex<5> > >::const_iterator seed=theVertexStates.begin();
618  seed!=theVertexStates.end(); ++seed )
619  {
620  double val = 0;
621  auto a = theWeights.find(t);
622  if ( a != theWeights.end()){
623  auto b = a->second.find(seed->first);
624  if (b != a->second.end()) val = b->second;
625  }
626  cout << " -- Vertex[" << seed->first << "] with " << setw(12)
627  << setprecision(3) << val;
628  };
629  cout << endl;
630 }
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
TrackAndSeedToWeightMap theWeights
void MultiVertexFitter::resetSeedNr ( )
private

Definition at line 135 of file MultiVertexFitter.cc.

Referenced by fit().

136 {
138 }
int MultiVertexFitter::seedNr ( )
private

Definition at line 130 of file MultiVertexFitter.cc.

Referenced by updateSeeds().

131 {
132  return theVertexStateNr++;
133 }
bool MultiVertexFitter::updateSeeds ( )
private

Definition at line 437 of file MultiVertexFitter.cc.

References gather_cfg::cout, MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, FrontierConditions_GlobalTag_cff::file, mps_fire::i, LinTrackCache::linTrack(), mag(), CachingVertex< N >::position(), printSeeds(), SurveyInfoScenario_cff::seed, seedNr(), theCache, thePrimaries, theTracks, theVertexStates, theWeights, HiIsolationCommonParameters_cff::track, updateWeights(), verbose, KalmanVertexFitter::vertex(), and VertexTrackFactory< N >::vertexTrack().

Referenced by fit().

438 {
439  double max_disp=0.;
440  // need to fit with the right weights.
441  // also trigger an updateWeights.
442  // if the seeds dont move much we return true
443 
444  vector < pair < int, CachingVertex<5> > > newSeeds;
445 
446  for ( vector< pair < int, CachingVertex<5> > >::const_iterator seed=theVertexStates.begin();
447  seed!=theVertexStates.end() ; ++seed )
448  {
449  // for each seed get the tracks with the right weights.
450  // TransientVertex rv = seed->second;
451  // const GlobalPoint & seedpos = seed->second.position();
452  int snr = seed->first;
453  VertexState realseed ( seed->second.position(), seed->second.error() );
454 
455  double totweight=0.;
456  for ( vector< TransientTrack >::const_iterator track=theTracks.begin();
457  track!=theTracks.end() ; ++track )
458  {
459  totweight+=theWeights[*track][snr];
460  };
461 
462 
463  int nr_good_trks=0; // how many tracks above weight limit
464  // we count those tracks, because that way
465  // we can discard lightweights if there are enough tracks
466  // and not discard the lightweights if that would give us
467  // fewer than two tracks ( we would loose a seed, then ).
468  if ( discardLightWeights() )
469  {
470  for ( vector< TransientTrack >::const_iterator track=theTracks.begin();
471  track!=theTracks.end() ; ++track )
472  {
473  if ( theWeights[*track][snr] > totweight * minWeightFraction() )
474  {
475  nr_good_trks++;
476  };
477  };
478  };
479 
480  vector<RefCountedVertexTrack> newTracks;
481  for ( vector< TransientTrack >::const_iterator track=theTracks.begin();
482  track!=theTracks.end() ; ++track )
483  {
484  double weight = validWeight ( theWeights[*track][snr] );
485  // Now we add a track, if
486  // a. we consider all tracks or
487  // b. we discard the lightweights but the track's weight is high enough or
488  // c. we discard the lightweights but there arent enough good tracks,
489  // so we add all lightweights again (too expensive to figure out
490  // which lightweights are the most important)
491  if ( !discardLightWeights() || weight > minWeightFraction() * totweight
492  || nr_good_trks < 2 )
493  {
494  // if the linearization point didnt move too much,
495  // we take the old LinTrackState.
496  // Otherwise we relinearize.
497 
499  theCache.linTrack ( seed->second.position(), *track );
500 
501  VertexTrackFactory<5> vTrackFactory;
502  RefCountedVertexTrack vTrData = vTrackFactory.vertexTrack(
503  lTrData, realseed, weight );
504  newTracks.push_back ( vTrData );
505  };
506  };
507 
508  for ( set< TransientTrack >::const_iterator track=thePrimaries.begin();
509  track!=thePrimaries.end() ; ++track )
510  {
511  double weight = validWeight ( theWeights[*track][snr] );
512 
514  theCache.linTrack ( seed->second.position(), *track );
515 
516  VertexTrackFactory<5> vTrackFactory;
517  RefCountedVertexTrack vTrData = vTrackFactory.vertexTrack(
518  lTrData, realseed, weight );
519  newTracks.push_back ( vTrData );
520 
521  };
522 
523  try {
524  if ( newTracks.size() < 2 )
525  {
526  throw VertexException("less than two tracks in vector" );
527  };
528 
529  if ( verbose() )
530  {
531  cout << "[MultiVertexFitter] now fitting with Kalman: ";
532  for ( vector< RefCountedVertexTrack >::const_iterator i=newTracks.begin();
533  i!=newTracks.end() ; ++i )
534  {
535  cout << (**i).weight() << " ";
536  };
537  cout << endl;
538  };
539 
540  if ( newTracks.size() > 1 )
541  {
542  KalmanVertexFitter fitter;
543  // warning! first track determines lin pt!
544  CachingVertex<5> newVertex = fitter.vertex ( newTracks );
545  int snr = seedNr();
546  double disp = ( newVertex.position() - seed->second.position() ).mag();
547  if ( disp > max_disp ) max_disp = disp;
548  newSeeds.push_back (
549  pair < int, CachingVertex<5> > ( snr, newVertex ) );
550  };
551  } catch ( exception & e )
552  {
553  cout << "[MultiVertexFitter] exception: " << e.what() << endl;
554  }
555  };
556 
557  // now discard all old seeds and weights, compute new ones.
558  theVertexStates.clear();
559  theWeights.clear();
560  theVertexStates=newSeeds;
561  #ifdef MVFHarvestingDebug
562  for ( vector< CachingVertex<5> >::const_iterator i=theVertexStates.begin();
563  i!=theVertexStates.end() ; ++i )
564  PrimitivesHarvester::file()->save(*i);
565  #endif
566  updateWeights();
567 
568  static const double disp_limit = 1e-4; /* SimpleConfigurable<double>
569  (0.0001, "MultiVertexFitter:DisplacementLimit" ).value(); */
570 
571  if ( verbose() & 2 )
572  {
573  printSeeds();
574  cout << "[MultiVertexFitter] max displacement in this iteration: "
575  << max_disp << endl;
576  };
577  if ( max_disp < disp_limit ) return false;
578  return true;
579 }
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
Common base class.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: weight.py:1
std::set< reco::TransientTrack > thePrimaries
static int verbose
std::vector< reco::TransientTrack > theTracks
LinTrackCache theCache
ReferenceCountingPointer< LinearizedTrackState< 5 > > RefCountedLinearizedTrackState
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
void printSeeds() const
RefCountedLinearizedTrackState linTrack(const GlobalPoint &, const reco::TransientTrack &)
GlobalPoint position() const
CachingVertex< 5 >::RefCountedVertexTrack RefCountedVertexTrack
TrackAndSeedToWeightMap theWeights
void MultiVertexFitter::updateWeights ( )
private

add the primary only tracks to primary vertex only.

now add "free tracks" to all vertices

Definition at line 352 of file MultiVertexFitter.cc.

References gather_cfg::cout, AnnealingSchedule::cutoff(), KalmanVertexTrackCompatibilityEstimator< N >::estimate(), objects.autophobj::float, LinTrackCache::linTrack(), AnnealingSchedule::phi(), CachingVertex< N >::position(), printWeights(), mps_fire::result, SurveyInfoScenario_cff::seed, theAssComp, theCache, thePrimaries, theTracks, theVertexStates, theWeights, verbose, w, and mps_merge::weight.

Referenced by updateSeeds().

353 {
354  theWeights.clear();
355  if ( verbose() & 4 )
356  {
357  cout << "[MultiVertexFitter] Start weight update." << endl;
358  };
359 
361 
365  for ( set < TransientTrack >::const_iterator trk=thePrimaries.begin();
366  trk!=thePrimaries.end() ; ++trk )
367  {
368  int seednr = theVertexStates[0].first;
370  pair<bool, double> result = theComp.estimate ( seed, theCache.linTrack ( seed.position(), *trk ) );
371  double weight = 0.;
372  if (result.first) weight = theAssComp->phi ( result.second );
373  theWeights[*trk][seednr]= weight; // FIXME maybe "hard" 1.0 or "soft" weight?
374  }
375 
379  for ( vector< TransientTrack >::const_iterator trk=theTracks.begin();
380  trk!=theTracks.end() ; ++trk )
381  {
382  double tot_weight=theAssComp->phi ( theAssComp->cutoff() * theAssComp->cutoff() );
383 
384  for ( vector < pair < int, CachingVertex<5> > >::const_iterator
385  seed=theVertexStates.begin(); seed!=theVertexStates.end(); ++seed )
386  {
387 
388  pair<bool, double> result = theComp.estimate ( seed->second, theCache.linTrack ( seed->second.position(),
389  *trk ) );
390  double weight = 0.;
391  if (result.first) weight = theAssComp->phi ( result.second );
392  tot_weight+=weight;
393  theWeights[*trk][seed->first]=weight;
394  /* cout << "[MultiVertexFitter] w[" << TransientTrackNamer().name(*trk)
395  << "," << seed->position() << "] = " << weight << endl;*/
396  };
397 
398  // normalize to sum of all weights of one track equals 1.
399  // (if we include the "cutoff", as well)
400  if ( tot_weight > 0.0 )
401  {
402  for ( vector < pair < int, CachingVertex<5> > >::const_iterator
403  seed=theVertexStates.begin();
404  seed!=theVertexStates.end(); ++seed )
405  {
406  double normedweight=theWeights[*trk][seed->first]/tot_weight;
407  if ( normedweight > 1.0 )
408  {
409  cout << "[MultiVertexFitter] he? w[" // << TransientTrackNamer().name(*trk)
410  << "," << seed->second.position() << "] = " << normedweight
411  << " totw=" << tot_weight << endl;
412  normedweight=1.0;
413  };
414  if ( normedweight < 0.0 )
415  {
416  cout << "[MultiVertexFitter] he? weight=" << normedweight
417  << " totw=" << tot_weight << endl;
418  normedweight=0.0;
419  };
420  theWeights[*trk][seed->first]=normedweight;
421  };
422  } else {
423  // total weight equals zero? restart, with uniform distribution!
424  cout << "[MultiVertexFitter] track found with no assignment - ";
425  cout << "will assign uniformly." << endl;
426  float w = .5 / (float) theVertexStates.size();
427  for ( vector < pair < int, CachingVertex<5> > >::const_iterator seed=theVertexStates.begin();
428  seed!=theVertexStates.end(); ++seed )
429  {
430  theWeights[*trk][seed->first]=w;
431  };
432  };
433  };
434  if ( verbose() & 2 ) printWeights();
435 }
const double w
Definition: UKUtility.cc:23
BDpair estimate(const CachingVertex< N > &vrt, const RefCountedVertexTrack track, unsigned int hint=UINT_MAX) const override
void printWeights() const
Definition: weight.py:1
std::set< reco::TransientTrack > thePrimaries
static int verbose
std::vector< reco::TransientTrack > theTracks
LinTrackCache theCache
virtual double phi(double chi2) const =0
virtual double cutoff() const =0
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
RefCountedLinearizedTrackState linTrack(const GlobalPoint &, const reco::TransientTrack &)
GlobalPoint position() const
AnnealingSchedule * theAssComp
TrackAndSeedToWeightMap theWeights
vector< CachingVertex< 5 > > MultiVertexFitter::vertices ( const std::vector< std::vector< reco::TransientTrack > > &  tracks,
const std::vector< reco::TransientTrack > &  primaries = std::vector < reco::TransientTrack > () 
)

Supply simple clusters of reco::TransientTracks. primaries: supply tracks which are hard coded to the primary vertex.

Definition at line 290 of file MultiVertexFitter.cc.

References hitfit::clear(), FrontierConditions_GlobalTag_cff::file, trackingPlots::fit, mps_fire::i, l1t::tracks, and verbose.

Referenced by MultiVertexReconstructor::vertices().

293 {
294  clear();
295  createPrimaries ( primaries );
296 
297  for ( vector< vector < TransientTrack > >::const_iterator cluster=
298  tracks.begin(); cluster!=tracks.end() ; ++cluster )
299  {
300  createSeed ( *cluster );
301  };
302  if ( verbose() )
303  {
304  printSeeds();
305  };
306  #ifdef MVFHarvestingDebug
307  for ( vector< CachingVertex<5> >::const_iterator i=theVertexStates.begin();
308  i!=theVertexStates.end() ; ++i )
309  PrimitivesHarvester::file()->save(*i);
310  #endif
311  return fit();
312 }
void createPrimaries(const std::vector< reco::TransientTrack > &tracks)
static int verbose
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
void printSeeds() const
void createSeed(const std::vector< reco::TransientTrack > &tracks)
std::vector< CachingVertex< 5 > > fit()
vector< CachingVertex< 5 > > MultiVertexFitter::vertices ( const std::vector< std::vector< TrackAndWeight > > &  tracks,
const std::vector< reco::TransientTrack > &  primaries = std::vector < reco::TransientTrack > () 
)

Supply clusters of tracks with weights, association weights of the other vertices is considered zero. FIXME weights are currently ignored. primaries: supply tracks which are hard coded to the primary vertex.

Definition at line 314 of file MultiVertexFitter.cc.

References hitfit::clear(), trackingPlots::fit, l1t::tracks, and verbose.

317 {
318  clear();
319  createPrimaries ( primaries );
320 
321  for ( vector< vector < TrackAndWeight > >::const_iterator cluster=
322  tracks.begin(); cluster!=tracks.end() ; ++cluster )
323  {
324  createSeed ( *cluster );
325  };
326  if ( verbose() )
327  {
328  printSeeds();
329  };
330 
331  return fit();
332 }
void createPrimaries(const std::vector< reco::TransientTrack > &tracks)
static int verbose
void printSeeds() const
void createSeed(const std::vector< reco::TransientTrack > &tracks)
std::vector< CachingVertex< 5 > > fit()
vector< CachingVertex< 5 > > MultiVertexFitter::vertices ( const std::vector< CachingVertex< 5 > > &  initials,
const std::vector< reco::TransientTrack > &  primaries = std::vector < reco::TransientTrack > () 
)

Supply full CachingVertices; CachingVertices are the first seeds. primaries: supply tracks which are hard coded to the primary vertex.

Definition at line 251 of file MultiVertexFitter.cc.

References hitfit::clear(), gather_cfg::cout, FrontierConditions_GlobalTag_cff::file, trackingPlots::fit, mps_fire::i, TransientVertex::originalTracks(), and extraflags_cff::vtx.

254 {
255  clear();
256  createPrimaries ( primaries );
257  // FIXME if initials size < 1 return sth that includes the primaries
258  if ( initials.empty() ) return initials;
259  for ( vector< CachingVertex<5> >::const_iterator vtx=initials.begin();
260  vtx!=initials.end() ; ++vtx )
261  {
262  int snr = seedNr();
263  theVertexStates.push_back ( pair < int, CachingVertex<5> >
264  ( snr, *vtx ) );
265  TransientVertex rvtx = *vtx;
266  const vector < TransientTrack > & trks = rvtx.originalTracks();
267  for ( vector< TransientTrack >::const_iterator trk=trks.begin();
268  trk!=trks.end() ; ++trk )
269  {
270  if ( !(thePrimaries.count (*trk )) )
271  {
272  // cout << "[MultiVertexFitter] free track " << trk->id() << endl;
273  theTracks.push_back ( *trk );
274  } else {
275  // cout << "[MultiVertexFitter " << trk->id() << " is not free." << endl;
276  }
277  cout << "[MultiVertexFitter] error! track weight currently set to one"
278  << " FIXME!!!" << endl;
279  theWeights[*trk][snr]=1.0;
280  };
281  };
282  #ifdef MVFHarvestingDebug
283  for ( vector< CachingVertex<5> >::const_iterator i=theVertexStates.begin();
284  i!=theVertexStates.end() ; ++i )
285  PrimitivesHarvester::file()->save(*i);
286  #endif
287  return fit();
288 }
void createPrimaries(const std::vector< reco::TransientTrack > &tracks)
std::set< reco::TransientTrack > thePrimaries
std::vector< reco::TransientTrack > const & originalTracks() const
std::vector< reco::TransientTrack > theTracks
std::vector< std::pair< int, CachingVertex< 5 > > > theVertexStates
std::vector< CachingVertex< 5 > > fit()
TrackAndSeedToWeightMap theWeights
vector< CachingVertex< 5 > > MultiVertexFitter::vertices ( const std::vector< TransientVertex > &  vtces,
const std::vector< reco::TransientTrack > &  primaries = std::vector < reco::TransientTrack > () 
)

Same as above.

Definition at line 221 of file MultiVertexFitter.cc.

References MillePedeFileConverter_cfg::e, tmp, electrons_cff::vertices, extraflags_cff::vtx, and w.

224 {
225  // FIXME if vtces.size < 1 return sth that includes the primaries
226  if ( vtces.empty() )
227  {
228  return vector < CachingVertex<5> > ();
229  };
230  vector < vector < TrackAndWeight > > bundles;
231  for ( vector< TransientVertex >::const_iterator vtx=vtces.begin();
232  vtx!=vtces.end() ; ++vtx )
233  {
234  vector < TransientTrack > trks = vtx->originalTracks();
235  vector < TrackAndWeight > tnws;
236  for ( vector< TransientTrack >::const_iterator trk=trks.begin();
237  trk!=trks.end() ; ++trk )
238  {
239  float w = vtx->trackWeight ( *trk );
240  if ( w > 1e-5 )
241  {
242  TrackAndWeight tmp ( *trk, w );
243  tnws.push_back ( tmp );
244  };
245  };
246  bundles.push_back ( tnws );
247  };
248  return vertices ( bundles, primaries );
249 }
std::vector< CachingVertex< 5 > > vertices(const std::vector< std::vector< reco::TransientTrack > > &, const std::vector< reco::TransientTrack > &primaries=std::vector< reco::TransientTrack >())
std::pair< reco::TransientTrack, float > TrackAndWeight
const double w
Definition: UKUtility.cc:23
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100

Member Data Documentation

AnnealingSchedule* MultiVertexFitter::theAssComp
private

Definition at line 116 of file MultiVertexFitter.h.

Referenced by fit(), updateWeights(), and ~MultiVertexFitter().

LinTrackCache MultiVertexFitter::theCache
private

Definition at line 119 of file MultiVertexFitter.h.

Referenced by updateSeeds(), and updateWeights().

std::set< reco::TransientTrack > MultiVertexFitter::thePrimaries
private

Definition at line 115 of file MultiVertexFitter.h.

Referenced by printWeights(), updateSeeds(), and updateWeights().

float MultiVertexFitter::theReviveBelow
private

Definition at line 113 of file MultiVertexFitter.h.

Referenced by lostVertexClaimer().

LinearizationPointFinder* MultiVertexFitter::theSeeder
private

Definition at line 117 of file MultiVertexFitter.h.

Referenced by ~MultiVertexFitter().

std::vector< reco::TransientTrack > MultiVertexFitter::theTracks
private

Definition at line 114 of file MultiVertexFitter.h.

Referenced by lostVertexClaimer(), printWeights(), updateSeeds(), and updateWeights().

int MultiVertexFitter::theVertexStateNr
private

Definition at line 112 of file MultiVertexFitter.h.

std::vector< std::pair < int, CachingVertex<5> > > MultiVertexFitter::theVertexStates
private

Definition at line 111 of file MultiVertexFitter.h.

Referenced by fit(), lostVertexClaimer(), printWeights(), updateSeeds(), and updateWeights().

TrackAndSeedToWeightMap MultiVertexFitter::theWeights
private

Definition at line 118 of file MultiVertexFitter.h.

Referenced by lostVertexClaimer(), printWeights(), updateSeeds(), and updateWeights().