test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
AdaptiveVertexReconstructor Class Reference

#include <AdaptiveVertexReconstructor.h>

Inheritance diagram for AdaptiveVertexReconstructor:
VertexReconstructor

Public Member Functions

 AdaptiveVertexReconstructor (float primcut=2.0, float seccut=6.0, float minweight=0.5, bool smoothing=false)
 
 AdaptiveVertexReconstructor (const edm::ParameterSet &s)
 
virtual
AdaptiveVertexReconstructor
clone () const
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &v) const
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &, const reco::BeamSpot &) const
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &primaries, const std::vector< reco::TransientTrack > &tracks, const reco::BeamSpot &) const
 
 ~AdaptiveVertexReconstructor ()
 
- Public Member Functions inherited from VertexReconstructor
 VertexReconstructor ()
 
virtual ~VertexReconstructor ()
 

Private Member Functions

TransientVertex cleanUp (const TransientVertex &old) const
 
std::vector< TransientVertexcleanUpVertices (const std::vector< TransientVertex > &) const
 
void erase (const TransientVertex &newvtx, std::set< reco::TransientTrack > &remainingtrks, float w) const
 
void setupFitters (float primcut, float primT, float primr, float seccut, float secT, float secr, bool smoothing)
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &primaries, const std::vector< reco::TransientTrack > &trks, const reco::BeamSpot &, bool has_primaries, bool usespot) const
 

Private Attributes

float theMinWeight
 
AdaptiveVertexFitterthePrimaryFitter
 
AdaptiveVertexFittertheSecondaryFitter
 
float theWeightThreshold
 

Detailed Description

Definition at line 9 of file AdaptiveVertexReconstructor.h.

Constructor & Destructor Documentation

AdaptiveVertexReconstructor::AdaptiveVertexReconstructor ( float  primcut = 2.0,
float  seccut = 6.0,
float  minweight = 0.5,
bool  smoothing = false 
)

Definition at line 87 of file AdaptiveVertexReconstructor.cc.

References setupFitters().

Referenced by clone().

88  :
90  theMinWeight( min_weight ), theWeightThreshold ( 0.001 )
91 {
92  setupFitters ( primcut, 256., 0.25, seccut, 256., 0.25, smoothing );
93 }
void setupFitters(float primcut, float primT, float primr, float seccut, float secT, float secr, bool smoothing)
AdaptiveVertexFitter * theSecondaryFitter
AdaptiveVertexReconstructor::~AdaptiveVertexReconstructor ( )

Definition at line 95 of file AdaptiveVertexReconstructor.cc.

References thePrimaryFitter, and theSecondaryFitter.

96 {
97  if ( thePrimaryFitter ) delete thePrimaryFitter;
99 }
AdaptiveVertexFitter * theSecondaryFitter
AdaptiveVertexReconstructor::AdaptiveVertexReconstructor ( const edm::ParameterSet s)

The ParameterSet should have the following defined: double primcut double seccut double minweight for descriptions see

Definition at line 134 of file AdaptiveVertexReconstructor.cc.

References alignCSCRings::e, edm::ParameterSet::getParameter(), setupFitters(), theMinWeight, theWeightThreshold, and cms::Exception::what().

136 {
137  float primcut = 2.0;
138  float seccut = 6.0;
139  bool smoothing=false;
140  // float primT = 4096.;
141  // float primr = 0.125;
142  float primT = 256.;
143  float primr = 0.25;
144  float secT = 256.;
145  float secr = 0.25;
146 
147  try {
148  primcut = m.getParameter<double>("primcut");
149  primT = m.getParameter<double>("primT");
150  primr = m.getParameter<double>("primr");
151  seccut = m.getParameter<double>("seccut");
152  secT = m.getParameter<double>("secT");
153  secr = m.getParameter<double>("secr");
154  theMinWeight = m.getParameter<double>("minweight");
155  theWeightThreshold = m.getParameter<double>("weightthreshold");
156  smoothing = m.getParameter<bool>("smoothing");
157  } catch ( edm::Exception & e ) {
158  edm::LogError ("AdaptiveVertexReconstructor") << e.what();
159  }
160 
161  setupFitters ( primcut, primT, primr, seccut, secT, secr, smoothing );
162 }
virtual char const * what() const
Definition: Exception.cc:141
void setupFitters(float primcut, float primT, float primr, float seccut, float secT, float secr, bool smoothing)
AdaptiveVertexFitter * theSecondaryFitter

Member Function Documentation

TransientVertex AdaptiveVertexReconstructor::cleanUp ( const TransientVertex old) const
private

Definition at line 11 of file AdaptiveVertexReconstructor.cc.

References TransientVertex::degreesOfFreedom(), TransientVertex::hasPrior(), TransientVertex::hasRefittedTracks(), i, TransientVertex::originalTracks(), TransientVertex::priorError(), TransientVertex::priorPosition(), TransientVertex::refittedTracks(), runTheMatrix::ret, TransientVertex::totalChiSquared(), TransientVertex::trackWeight(), TransientVertex::vertexState(), and TransientVertex::weightMap().

Referenced by vertices().

12 {
13  vector < reco::TransientTrack > trks = old.originalTracks();
14  vector < reco::TransientTrack > newtrks;
16  static const float minweight = 1.e-8; // discard all tracks with lower weight
17  for ( vector< reco::TransientTrack >::const_iterator i=trks.begin();
18  i!=trks.end() ; ++i )
19  {
20  if ( old.trackWeight ( *i ) > minweight )
21  {
22  newtrks.push_back ( *i );
23  mp[*i]=old.trackWeight ( *i );
24  }
25  }
26 
28 
29  if ( old.hasPrior() )
30  {
31  VertexState priorstate ( old.priorPosition(), old.priorError() );
32  ret=TransientVertex ( priorstate, old.vertexState(), newtrks,
33  old.totalChiSquared(), old.degreesOfFreedom() );
34  } else {
35  ret=TransientVertex ( old.vertexState(), newtrks,
36  old.totalChiSquared(), old.degreesOfFreedom() );
37  }
38  ret.weightMap ( mp ); // set weight map
39 
40  if ( old.hasRefittedTracks() )
41  {
42  // we have refitted tracks -- copy them!
43  vector < reco::TransientTrack > newrfs;
44  vector < reco::TransientTrack > oldrfs=old.refittedTracks();
45  vector < reco::TransientTrack >::const_iterator origtrkiter=trks.begin();
46  for ( vector< reco::TransientTrack >::const_iterator i=oldrfs.begin(); i!=oldrfs.end() ; ++i )
47  {
48  if ( old.trackWeight ( *origtrkiter ) > minweight )
49  {
50  newrfs.push_back ( *i );
51  }
52  origtrkiter++;
53  }
54  if ( newrfs.size() ) ret.refittedTracks ( newrfs ); // copy refitted tracks
55  }
56 
57  if ( ret.refittedTracks().size() > ret.originalTracks().size() )
58  {
59  edm::LogError("AdaptiveVertexReconstructor" )
60  << "More refitted tracks than original tracks!";
61  }
62 
63  return ret;
64 }
int i
Definition: DBlmapReader.cc:9
tuple ret
prodAgent to be discontinued
GlobalError priorError() const
float totalChiSquared() const
std::map< reco::TransientTrack, float > TransientTrackToFloatMap
bool hasRefittedTracks() const
std::vector< reco::TransientTrack > const & originalTracks() const
float degreesOfFreedom() const
bool hasPrior() const
float trackWeight(const reco::TransientTrack &track) const
GlobalPoint priorPosition() const
std::vector< reco::TransientTrack > const & refittedTracks() const
VertexState const & vertexState() const
TransientTrackToFloatMap weightMap() const
vector< TransientVertex > AdaptiveVertexReconstructor::cleanUpVertices ( const std::vector< TransientVertex > &  old) const
private

cleanup reconstructed vertices. discard all with too few significant tracks.

Definition at line 266 of file AdaptiveVertexReconstructor.cc.

References i, runTheMatrix::ret, theWeightThreshold, and w.

Referenced by vertices().

268 {
269  vector < TransientVertex > ret;
270  for ( vector< TransientVertex >::const_iterator i=old.begin(); i!=old.end() ; ++i )
271  {
272  if (!(i->hasTrackWeight()))
273  { // if we dont have track weights, we take the vtx
274  ret.push_back ( *i );
275  continue;
276  }
277 
278  // maybe this should be replaced with asking for the ndf ...
279  // e.g. if ( ndf > - 1. )
280  int nsig=0; // number of significant tracks.
282  for ( TransientVertex::TransientTrackToFloatMap::const_iterator w=wm.begin(); w!=wm.end() ; ++w )
283  {
284  if (w->second > theWeightThreshold) nsig++;
285  }
286  if ( nsig > 1 ) ret.push_back ( *i );
287  }
288 
289  return ret;
290 }
int i
Definition: DBlmapReader.cc:9
tuple ret
prodAgent to be discontinued
const double w
Definition: UKUtility.cc:23
std::map< reco::TransientTrack, float > TransientTrackToFloatMap
virtual AdaptiveVertexReconstructor* AdaptiveVertexReconstructor::clone ( void  ) const
inlinevirtual

Implements VertexReconstructor.

Definition at line 45 of file AdaptiveVertexReconstructor.h.

References AdaptiveVertexReconstructor().

45  {
46  return new AdaptiveVertexReconstructor( * this );
47  }
AdaptiveVertexReconstructor(float primcut=2.0, float seccut=6.0, float minweight=0.5, bool smoothing=false)
void AdaptiveVertexReconstructor::erase ( const TransientVertex newvtx,
std::set< reco::TransientTrack > &  remainingtrks,
float  w 
) const
private

contrary to what its name has you believe, ::erase removes all newvtx.originalTracks() above theMinWeight from remainingtrks.

Definition at line 66 of file AdaptiveVertexReconstructor.cc.

References i, TransientVertex::originalTracks(), TransientVertex::trackWeight(), and histoStyle::weight.

Referenced by vertices().

70 {
71  /*
72  * Erase tracks that are in newvtx from remainingtrks
73  * But erase only if trackweight > w
74  */
75  const vector < reco::TransientTrack > & origtrks = newvtx.originalTracks();
76  for ( vector< reco::TransientTrack >::const_iterator i=origtrks.begin();
77  i!=origtrks.end(); ++i )
78  {
79  double weight = newvtx.trackWeight ( *i );
80  if ( weight > w )
81  {
82  remainingtrks.erase ( *i );
83  };
84  };
85 }
int i
Definition: DBlmapReader.cc:9
const double w
Definition: UKUtility.cc:23
std::vector< reco::TransientTrack > const & originalTracks() const
float trackWeight(const reco::TransientTrack &track) const
int weight
Definition: histoStyle.py:50
void AdaptiveVertexReconstructor::setupFitters ( float  primcut,
float  primT,
float  primr,
float  seccut,
float  secT,
float  secr,
bool  smoothing 
)
private

setup the vertex fitters.

Definition at line 101 of file AdaptiveVertexReconstructor.cc.

References AdaptiveVertexFitter::setWeightThreshold(), thePrimaryFitter, theSecondaryFitter, and theWeightThreshold.

Referenced by AdaptiveVertexReconstructor().

104 {
105  VertexSmoother<5> * smoother ;
106  if ( smoothing )
107  {
108  smoother = new KalmanVertexSmoother();
109  } else {
110  smoother = new DummyVertexSmoother<5>();
111  }
112 
113  if ( thePrimaryFitter ) delete thePrimaryFitter;
115 
116  /*
117  edm::LogError ("AdaptiveVertexReconstructor" )
118  << "Tini and r are hardcoded now!";
119  */
123  // if the primary fails, sth is wrong, so here we set a threshold on the weight.
128  // need to set it or else we have
129  // unwanted exceptions to deal with.
130  // cleanup can come later!
131  delete smoother;
132 }
AdaptiveVertexFitter * theSecondaryFitter
vector< TransientVertex > AdaptiveVertexReconstructor::vertices ( const std::vector< reco::TransientTrack > &  ) const
virtual

Reconstruct vertices

Implements VertexReconstructor.

Definition at line 179 of file AdaptiveVertexReconstructor.cc.

Referenced by vertices().

181 {
182  return vertices ( vector<reco::TransientTrack>(), tracks, reco::BeamSpot(),
183  false, false );
184 }
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &v) const
tuple tracks
Definition: testEve_cfg.py:39
vector< TransientVertex > AdaptiveVertexReconstructor::vertices ( const std::vector< reco::TransientTrack > &  t,
const reco::BeamSpot  
) const
virtual

Reconstruct vertices, exploiting the beamspot constraint for the primary vertex

Reimplemented from VertexReconstructor.

Definition at line 165 of file AdaptiveVertexReconstructor.cc.

References vertices().

167 {
168  return vertices ( vector<reco::TransientTrack>(), t, s, false, true );
169 }
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &v) const
vector< TransientVertex > AdaptiveVertexReconstructor::vertices ( const std::vector< reco::TransientTrack > &  primaries,
const std::vector< reco::TransientTrack > &  tracks,
const reco::BeamSpot spot 
) const
virtual

Reconstruct vertices, but exploit the fact that you know that some tracks cannot come from a secondary vertex. primaries Tracks that cannot come from a secondary vertex (but can, in principle, be non-primaries, also). tracks These are the tracks that are of unknown origin. These tracks are subjected to pattern recognition. spot A beamspot constraint is mandatory in this method.

Reimplemented from VertexReconstructor.

Definition at line 172 of file AdaptiveVertexReconstructor.cc.

References vertices().

174 {
175  return vertices ( primaries, tracks, s, true, true );
176 }
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &v) const
tuple tracks
Definition: testEve_cfg.py:39
vector< TransientVertex > AdaptiveVertexReconstructor::vertices ( const std::vector< reco::TransientTrack > &  primaries,
const std::vector< reco::TransientTrack > &  trks,
const reco::BeamSpot s,
bool  has_primaries,
bool  usespot 
) const
private

the actual fit to avoid code duplication

Definition at line 186 of file AdaptiveVertexReconstructor.cc.

References cleanUp(), cleanUpVertices(), filterCSVwithJSON::copy, alignCSCRings::e, erase(), LogDebug, runTheMatrix::ret, theMinWeight, thePrimaryFitter, theSecondaryFitter, findQualityFiles::v, and AdaptiveVertexFitter::vertex().

190 {
191  vector < TransientVertex > ret;
192  set < reco::TransientTrack > remainingtrks;
193 
194  copy(tracks.begin(), tracks.end(),
195  inserter(remainingtrks, remainingtrks.begin()));
196 
197  int ctr=0;
198  unsigned int n_tracks = remainingtrks.size();
199 
200  // cout << "[AdaptiveVertexReconstructor] DEBUG ::vertices!!" << endl;
201  try {
202  while ( remainingtrks.size() > 1 )
203  {
204  /*
205  cout << "[AdaptiveVertexReconstructor] next round: "
206  << remainingtrks.size() << endl;
207  */
208  ctr++;
209  const AdaptiveVertexFitter * fitter = theSecondaryFitter;
210  if ( ret.size() == 0 )
211  {
212  fitter = thePrimaryFitter;
213  };
214  vector < reco::TransientTrack > fittrks;
215  fittrks.reserve ( remainingtrks.size() );
216 
217  copy(remainingtrks.begin(), remainingtrks.end(), back_inserter(fittrks));
218 
219  TransientVertex tmpvtx;
220  if ( (ret.size() == 0) && has_primaries )
221  {
222  // add the primaries to the fitted tracks.
223  copy ( primaries.begin(), primaries.end(), back_inserter(fittrks) );
224  }
225  if ( (ret.size() == 0) && usespot )
226  {
227  tmpvtx=fitter->vertex ( fittrks, s );
228  } else {
229  tmpvtx=fitter->vertex ( fittrks );
230  }
231  TransientVertex newvtx = cleanUp ( tmpvtx );
232  ret.push_back ( newvtx );
233  erase ( newvtx, remainingtrks, theMinWeight );
234  if ( n_tracks == remainingtrks.size() )
235  {
236  if ( usespot )
237  {
238  // try once more without beamspot constraint!
239  usespot=false;
240  LogDebug("AdaptiveVertexReconstructor")
241  << "no tracks in vertex. trying again without beamspot constraint!";
242  continue;
243  }
244  LogDebug("AdaptiveVertexReconstructor") << "all tracks (" << n_tracks
245  << ") would be recycled for next fit. Trying with low threshold!";
246  erase ( newvtx, remainingtrks, 1.e-5 );
247  if ( n_tracks == remainingtrks.size() )
248  {
249  LogDebug("AdaptiveVertexReconstructor") << "low threshold didnt help! "
250  << "Discontinue procedure!";
251  break;
252  }
253  };
254 
255  // cout << "[AdaptiveVertexReconstructor] erased" << endl;
256  n_tracks = remainingtrks.size();
257  };
258  } catch ( VertexException & v ) {
259  // Will catch all (not enough significant tracks exceptions.
260  // in this case, the iteration can safely terminate.
261  };
262 
263  return cleanUpVertices ( ret );
264 }
#define LogDebug(id)
tuple ret
prodAgent to be discontinued
TransientVertex cleanUp(const TransientVertex &old) const
Common base class.
virtual CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &) const
std::vector< TransientVertex > cleanUpVertices(const std::vector< TransientVertex > &) const
AdaptiveVertexFitter * theSecondaryFitter
tuple tracks
Definition: testEve_cfg.py:39
void erase(const TransientVertex &newvtx, std::set< reco::TransientTrack > &remainingtrks, float w) const

Member Data Documentation

float AdaptiveVertexReconstructor::theMinWeight
private

Definition at line 84 of file AdaptiveVertexReconstructor.h.

Referenced by AdaptiveVertexReconstructor(), and vertices().

AdaptiveVertexFitter* AdaptiveVertexReconstructor::thePrimaryFitter
private
AdaptiveVertexFitter* AdaptiveVertexReconstructor::theSecondaryFitter
private
float AdaptiveVertexReconstructor::theWeightThreshold
private