CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoVertex/TertiaryTracksVertexFinder/src/ConfigurableTertiaryTracksVertexFinder.cc

Go to the documentation of this file.
00001 
00002 #include "RecoVertex/TertiaryTracksVertexFinder/interface/ConfigurableTertiaryTracksVertexFinder.h"
00003 
00004 #include "RecoVertex/TertiaryTracksVertexFinder/interface/VertexMass.h"
00005 #include "RecoVertex/TertiaryTracksVertexFinder/interface/V0SvFilter.h"
00006 #include "RecoVertex/TertiaryTracksVertexFinder/interface/Flight2DSvFilter.h"
00007 #include "RecoVertex/TertiaryTracksVertexFinder/interface/PvSvFilter.h"
00008 #include "RecoVertex/TertiaryTracksVertexFinder/interface/TransientTrackInVertices.h"
00009 
00010 using namespace reco;
00011 using namespace std;
00012 
00013 //-----------------------------------------------------------------------------
00014 // constructor
00015 
00016 ConfigurableTertiaryTracksVertexFinder::ConfigurableTertiaryTracksVertexFinder(
00017   const VertexFitter<5> * vf, 
00018   const VertexUpdator<5> * vu, const VertexTrackCompatibilityEstimator<5> * ve)
00019 {
00020   theTKVF = new ConfigurableTrimmedVertexFinder(vf,vu,ve);
00021 
00022   theMinTrackPt = 1.0;
00023   theMaxVtxMass = 6.5;
00024   theMaxSigOnDistTrackToB = 3.0; // this is being overwritten to 10 in AddTvTtrack (why?)
00025 
00026   theMaxInPvFrac = 0.65;
00027 
00028   // set up V0SvFilter
00029   theK0sMassWindow = 0.05; // mass window around K0s
00030   theV0SvFilter = new V0SvFilter(theK0sMassWindow);
00031 
00032   // set up Flight2DSvFilter
00033   theMaxDist2D = 2.5;  // max transv. dist to beam line
00034   theMinDist2D = 0.01; // min transv. dist to beam line
00035   theMinSign2D = 3.0;  // min transverse distance significance
00036   theMinTracks = 2;    // min number of tracks
00037   theFlight2DSvFilter= new Flight2DSvFilter(theMaxDist2D,theMinDist2D,
00038                                             theMinSign2D,theMinTracks);
00039 
00040   //  thePrimaryVertex = new TransientVertex;
00041   // FIXME this is incomplete!? -> get real primary vertex!
00042 
00043   //theNewTrackInfoVector = new NewTrackInfoVector;
00044 
00045 }
00046 
00047 //-----------------------------------------------------------------------------
00048 // destructor
00049 
00050 ConfigurableTertiaryTracksVertexFinder::~ConfigurableTertiaryTracksVertexFinder()
00051 {
00052   delete theTKVF;
00053   delete theV0SvFilter;
00054   delete theFlight2DSvFilter;
00055 }
00056 
00057 //-----------------------------------------------------------------------------
00058 
00059 std::vector<TransientVertex> ConfigurableTertiaryTracksVertexFinder::vertices(
00060                                                                               const std::vector<reco::TransientTrack> & tracks, const TransientVertex& pv) const
00061 {
00062   // there is a PV
00063   if (pv.isValid()) {
00064     theFlight2DSvFilter->setPrimaryVertex( pv);
00065     if (debug) cout <<"[TTVF] calling with a real PV ...\n";
00066     return this->reconstruct(tracks,pv);
00067   }
00068   else return this->vertices(tracks);
00069 
00070 }
00071 
00072 //-----------------------------------------------------------------------------
00073 
00074 std::vector<TransientVertex> ConfigurableTertiaryTracksVertexFinder::vertices(
00075   const std::vector<reco::TransientTrack> & tracks) const 
00076 {
00077   // there is no PV
00078   theFlight2DSvFilter->useNotPV();
00079   TransientVertex dummyVertex;
00080   if (debug) cout <<"[TTVF] calling with a dummy PV ...\n";
00081   return this->reconstruct(tracks,dummyVertex);
00082 
00083 }
00084 
00085 //-----------------------------------------------------------------------------
00086 
00087 std::vector<TransientVertex> ConfigurableTertiaryTracksVertexFinder::reconstruct(
00088                                                                                  const std::vector<reco::TransientTrack> & tracks, const TransientVertex& pv) const
00089 {
00090   // get  primary vertices;
00091   std::vector<TransientVertex> primaryVertices;
00092   if(pv.isValid()) { primaryVertices.push_back(pv); 
00093     if (debug) cout <<"[TTVF] add PV ...\n";
00094   }
00095 
00096   VertexMass theVertexMass;
00097 
00098   //filter tracks in pt
00099   std::vector<reco::TransientTrack> filteredTracks;
00100   for (std::vector<reco::TransientTrack>::const_iterator it=tracks.begin();
00101        it!=tracks.end();it++)
00102     if ((*it).impactPointState().globalMomentum().perp() > theMinTrackPt) 
00103       filteredTracks.push_back(*it);
00104 
00105   if (debug) cout <<"[TTVF] tracks: " << filteredTracks.size() <<endl;
00106 
00107   // get vertices
00108   std::vector<TransientVertex> vertices;
00109   if (filteredTracks.size()>1) vertices = theTKVF->vertices(filteredTracks);
00110 
00111   if (debug) cout <<"[TTVF] found secondary vertices with TKVF: "<<vertices.size()<<endl;
00112 
00113   std::vector<TransientVertex> secondaryVertices;
00114 
00115   for(std::vector<TransientVertex>::const_iterator ivx=vertices.begin();
00116       ivx!=vertices.end(); ivx++) {
00117     TransientVertex vtx=*ivx;
00118 
00119     double mass=theVertexMass(vtx);
00120     if (debug) cout <<"[TTVF] new svx: mass: "<<mass<<endl;
00121 
00122     if ((*theV0SvFilter)(vtx)) {
00123       if (debug) cout <<"[TTVF] survived V0SvFilter\n";
00124       if((*theFlight2DSvFilter)(vtx)) {
00125         if (debug) cout <<"[TTVF] survived 2DSvFilter\n";
00126         if (mass<theMaxVtxMass) {
00127           if (!primaryVertices.empty()) {
00128             PvSvFilter thePvSvFilter(theMaxInPvFrac,primaryVertices[0]);
00129             if (thePvSvFilter(vtx)) secondaryVertices.push_back(vtx);
00130             else { if (debug) cout <<"[TTVF] failed PvSvFilter\n";}
00131           }
00132           else secondaryVertices.push_back(vtx);
00133         }
00134         else {if(debug)cout<<"[TTVF] failed mass cut\n";}
00135       }
00136     }
00137 
00138   }
00139 
00140   if (debug) cout<<"[TTVF] remaining svx: "<<secondaryVertices.size()<<endl;
00141 
00142   if (primaryVertices.empty() || secondaryVertices.empty()) 
00143     return secondaryVertices; // unable to reconstruct b-flight-trajectory
00144 
00145   if (debug) cout<<"[TTVF] still here ...\n";
00146 
00147   // find tracks not used in primaryVertex or in vertices
00148   vector<TransientTrack> unusedTracks;
00149   for( vector<TransientTrack>::const_iterator itT = filteredTracks.begin(); 
00150     itT != filteredTracks.end(); itT++ ) 
00151     if( (!TransientTrackInVertices::isInVertex((*itT),primaryVertices)) 
00152      && (!TransientTrackInVertices::isInVertex((*itT),vertices)) )
00153        unusedTracks.push_back( *itT ); 
00154   if (debug) cout <<"[TTVF] remaining tracks: "<<unusedTracks.size()<<endl;
00155 
00156   // now add tracks to the SV candidate
00157   AddTvTrack MyAddTVTrack( &primaryVertices, &secondaryVertices, 
00158                            theMaxSigOnDistTrackToB);  
00159   vector<TransientVertex> newVertices =
00160     MyAddTVTrack.getSecondaryVertices(unusedTracks); 
00161 
00162   // for tdr studies
00163   theTrackInfoVector = MyAddTVTrack.getTrackInfo();
00164 
00165   //std::vector<pair<reco::TransientTrack,double> > theTrackInfo;
00166   //std::vector<pair<reco::TransientTrack,double* > > theTrackInfo2;
00167   //theTrackInfo = MyAddTVTrack.getTrackInfo();
00168   //theTrackInfo2= MyAddTVTrack.getTrackInfo2();
00169 
00170   //TrackInfo = theTrackInfo;
00171   //TrackInfo2= theTrackInfo2;
00172 
00173   if (debug) cout <<"[TTVF] vertices found: "<<newVertices.size()<<endl;
00174   return newVertices;
00175 
00176 }
00177 
00178 
00179