CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConfigurableTertiaryTracksVertexFinder.cc
Go to the documentation of this file.
1 
3 
9 
10 using namespace reco;
11 using namespace std;
12 
13 //-----------------------------------------------------------------------------
14 // constructor
15 
17  const VertexFitter<5> * vf,
19 {
20  theTKVF = new ConfigurableTrimmedVertexFinder(vf,vu,ve);
21 
22  theMinTrackPt = 1.0;
23  theMaxVtxMass = 6.5;
24  theMaxSigOnDistTrackToB = 3.0; // this is being overwritten to 10 in AddTvTtrack (why?)
25 
26  theMaxInPvFrac = 0.65;
27 
28  // set up V0SvFilter
29  theK0sMassWindow = 0.05; // mass window around K0s
30  theV0SvFilter = new V0SvFilter(theK0sMassWindow);
31 
32  // set up Flight2DSvFilter
33  theMaxDist2D = 2.5; // max transv. dist to beam line
34  theMinDist2D = 0.01; // min transv. dist to beam line
35  theMinSign2D = 3.0; // min transverse distance significance
36  theMinTracks = 2; // min number of tracks
37  theFlight2DSvFilter= new Flight2DSvFilter(theMaxDist2D,theMinDist2D,
38  theMinSign2D,theMinTracks);
39 
40  // thePrimaryVertex = new TransientVertex;
41  // FIXME this is incomplete!? -> get real primary vertex!
42 
43  //theNewTrackInfoVector = new NewTrackInfoVector;
44 
45 }
46 
47 //-----------------------------------------------------------------------------
48 // destructor
49 
51 {
52  delete theTKVF;
53  delete theV0SvFilter;
54  delete theFlight2DSvFilter;
55 }
56 
57 //-----------------------------------------------------------------------------
58 
60  const std::vector<reco::TransientTrack> & tracks, const TransientVertex& pv) const
61 {
62  // there is a PV
63  if (pv.isValid()) {
64  theFlight2DSvFilter->setPrimaryVertex( pv);
65  if (debug) cout <<"[TTVF] calling with a real PV ...\n";
66  return this->reconstruct(tracks,pv);
67  }
68  else return this->vertices(tracks);
69 
70 }
71 
72 //-----------------------------------------------------------------------------
73 
75  const std::vector<reco::TransientTrack> & tracks) const
76 {
77  // there is no PV
78  theFlight2DSvFilter->useNotPV();
79  TransientVertex dummyVertex;
80  if (debug) cout <<"[TTVF] calling with a dummy PV ...\n";
81  return this->reconstruct(tracks,dummyVertex);
82 
83 }
84 
85 //-----------------------------------------------------------------------------
86 
88  const std::vector<reco::TransientTrack> & tracks, const TransientVertex& pv) const
89 {
90  // get primary vertices;
91  std::vector<TransientVertex> primaryVertices;
92  if(pv.isValid()) { primaryVertices.push_back(pv);
93  if (debug) cout <<"[TTVF] add PV ...\n";
94  }
95 
96  VertexMass theVertexMass;
97 
98  //filter tracks in pt
99  std::vector<reco::TransientTrack> filteredTracks;
100  for (std::vector<reco::TransientTrack>::const_iterator it=tracks.begin();
101  it!=tracks.end();it++)
102  if ((*it).impactPointState().globalMomentum().perp() > theMinTrackPt)
103  filteredTracks.push_back(*it);
104 
105  if (debug) cout <<"[TTVF] tracks: " << filteredTracks.size() <<endl;
106 
107  // get vertices
108  std::vector<TransientVertex> vertices;
109  if (filteredTracks.size()>1) vertices = theTKVF->vertices(filteredTracks);
110 
111  if (debug) cout <<"[TTVF] found secondary vertices with TKVF: "<<vertices.size()<<endl;
112 
113  std::vector<TransientVertex> secondaryVertices;
114 
115  for(std::vector<TransientVertex>::const_iterator ivx=vertices.begin();
116  ivx!=vertices.end(); ivx++) {
117  TransientVertex vtx=*ivx;
118 
119  double mass=theVertexMass(vtx);
120  if (debug) cout <<"[TTVF] new svx: mass: "<<mass<<endl;
121 
122  if ((*theV0SvFilter)(vtx)) {
123  if (debug) cout <<"[TTVF] survived V0SvFilter\n";
124  if((*theFlight2DSvFilter)(vtx)) {
125  if (debug) cout <<"[TTVF] survived 2DSvFilter\n";
126  if (mass<theMaxVtxMass) {
127  if (!primaryVertices.empty()) {
128  PvSvFilter thePvSvFilter(theMaxInPvFrac,primaryVertices[0]);
129  if (thePvSvFilter(vtx)) secondaryVertices.push_back(vtx);
130  else { if (debug) cout <<"[TTVF] failed PvSvFilter\n";}
131  }
132  else secondaryVertices.push_back(vtx);
133  }
134  else {if(debug)cout<<"[TTVF] failed mass cut\n";}
135  }
136  }
137 
138  }
139 
140  if (debug) cout<<"[TTVF] remaining svx: "<<secondaryVertices.size()<<endl;
141 
142  if (primaryVertices.empty() || secondaryVertices.empty())
143  return secondaryVertices; // unable to reconstruct b-flight-trajectory
144 
145  if (debug) cout<<"[TTVF] still here ...\n";
146 
147  // find tracks not used in primaryVertex or in vertices
148  vector<TransientTrack> unusedTracks;
149  for( vector<TransientTrack>::const_iterator itT = filteredTracks.begin();
150  itT != filteredTracks.end(); itT++ )
151  if( (!TransientTrackInVertices::isInVertex((*itT),primaryVertices))
152  && (!TransientTrackInVertices::isInVertex((*itT),vertices)) )
153  unusedTracks.push_back( *itT );
154  if (debug) cout <<"[TTVF] remaining tracks: "<<unusedTracks.size()<<endl;
155 
156  // now add tracks to the SV candidate
157  AddTvTrack MyAddTVTrack( &primaryVertices, &secondaryVertices,
158  theMaxSigOnDistTrackToB);
159  vector<TransientVertex> newVertices =
160  MyAddTVTrack.getSecondaryVertices(unusedTracks);
161 
162  // for tdr studies
163  theTrackInfoVector = MyAddTVTrack.getTrackInfo();
164 
165  //std::vector<pair<reco::TransientTrack,double> > theTrackInfo;
166  //std::vector<pair<reco::TransientTrack,double* > > theTrackInfo2;
167  //theTrackInfo = MyAddTVTrack.getTrackInfo();
168  //theTrackInfo2= MyAddTVTrack.getTrackInfo2();
169 
170  //TrackInfo = theTrackInfo;
171  //TrackInfo2= theTrackInfo2;
172 
173  if (debug) cout <<"[TTVF] vertices found: "<<newVertices.size()<<endl;
174  return newVertices;
175 
176 }
177 
178 
179 
reco::TrackRefVector filteredTracks(reco::TrackRefVector theInitialTracks, double tkminPt, int tkminPixelHitsn, int tkminTrackerHitsn, double tkmaxipt, double tkmaxChi2, reco::Vertex pV)
Definition: TauTagTools.cc:77
ConfigurableTertiaryTracksVertexFinder(const VertexFitter< 5 > *vf, const VertexUpdator< 5 > *vu, const VertexTrackCompatibilityEstimator< 5 > *ve)
std::vector< TransientVertex > reconstruct(const std::vector< reco::TransientTrack > &tracks, const TransientVertex &pv) const
std::vector< TransientVertex > getSecondaryVertices(const std::vector< reco::TransientTrack > &)
Definition: AddTvTrack.cc:31
TrackInfoVector getTrackInfo()
Definition: AddTvTrack.h:50
#define debug
Definition: HDRShower.cc:19
tuple tracks
Definition: testEve_cfg.py:39
virtual std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &) const
static bool isInVertex(const reco::TransientTrack &aTrack, const TransientVertex &aVertex)
void push_back(value_type const &ref)
Add a Ref&lt;C, T&gt; to the RefVector.
Definition: RefVector.h:64
tuple cout
Definition: gather_cfg.py:121
bool isValid() const