CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoVertex/AdaptiveVertexFinder/src/TracksClusteringFromDisplacedSeed.cc

Go to the documentation of this file.
00001 #include "RecoVertex/AdaptiveVertexFinder/interface/TracksClusteringFromDisplacedSeed.h"
00002 //#define VTXDEBUG 1
00003 
00004 
00005 TracksClusteringFromDisplacedSeed::TracksClusteringFromDisplacedSeed(const edm::ParameterSet &params) :
00006 //      maxNTracks(params.getParameter<unsigned int>("maxNTracks")),
00007         min3DIPSignificance(params.getParameter<double>("seedMin3DIPSignificance")),
00008         min3DIPValue(params.getParameter<double>("seedMin3DIPValue")),
00009         clusterMaxDistance(params.getParameter<double>("clusterMaxDistance")),
00010         clusterMaxSignificance(params.getParameter<double>("clusterMaxSignificance")), //3
00011         clusterScale(params.getParameter<double>("clusterScale")),//10.
00012         clusterMinAngleCosine(params.getParameter<double>("clusterMinAngleCosine")) //0.0
00013 
00014 {
00015         
00016 }
00017 
00018 std::pair<std::vector<reco::TransientTrack>,GlobalPoint> TracksClusteringFromDisplacedSeed::nearTracks(const reco::TransientTrack &seed, const std::vector<reco::TransientTrack> & tracks, const  reco::Vertex & primaryVertex) const
00019 {
00020       VertexDistance3D distanceComputer;
00021       GlobalPoint pv(primaryVertex.position().x(),primaryVertex.position().y(),primaryVertex.position().z());
00022       std::vector<reco::TransientTrack> result;
00023       TwoTrackMinimumDistance dist;
00024       GlobalPoint seedingPoint;
00025       float sumWeights=0;
00026       std::pair<bool,Measurement1D> ipSeed = IPTools::absoluteImpactParameter3D(seed,primaryVertex);
00027       float pvDistance = ipSeed.second.value();
00028 //      float densityFactor = 2./sqrt(20.*tracks.size()); // assuming all tracks being in 2 narrow jets of cone 0.3
00029       float densityFactor = 2./sqrt(20.*80); // assuming 80 tracks being in 2 narrow jets of cone 0.3
00030       for(std::vector<reco::TransientTrack>::const_iterator tt = tracks.begin();tt!=tracks.end(); ++tt )   {
00031 
00032        if(*tt==seed) continue;
00033 
00034        std::pair<bool,Measurement1D> ip = IPTools::absoluteImpactParameter3D(*tt,primaryVertex);
00035        if(dist.calculate(tt->impactPointState(),seed.impactPointState()))
00036             {
00037                  GlobalPoint ttPoint          = dist.points().first;
00038                  GlobalError ttPointErr       = tt->impactPointState().cartesianError().position();
00039                  GlobalPoint seedPosition     = dist.points().second;
00040                  GlobalError seedPositionErr  = seed.impactPointState().cartesianError().position();
00041                  Measurement1D m = distanceComputer.distance(VertexState(seedPosition,seedPositionErr), VertexState(ttPoint, ttPointErr));
00042                  GlobalPoint cp(dist.crossingPoint()); 
00043 
00044 
00045                  float distanceFromPV =  (dist.points().second-pv).mag();
00046                  float distance = dist.distance();
00047                  GlobalVector trackDir2D(tt->impactPointState().globalDirection().x(),tt->impactPointState().globalDirection().y(),0.); 
00048                  GlobalVector seedDir2D(seed.impactPointState().globalDirection().x(),seed.impactPointState().globalDirection().y(),0.); 
00049                  //SK:UNUSED//    float dotprodTrackSeed2D = trackDir2D.unit().dot(seedDir2D.unit());
00050 
00051                  float dotprodTrack = (dist.points().first-pv).unit().dot(tt->impactPointState().globalDirection().unit());
00052                  float dotprodSeed = (dist.points().second-pv).unit().dot(seed.impactPointState().globalDirection().unit());
00053 
00054                  float w = distanceFromPV*distanceFromPV/(pvDistance*distance);
00055                  bool selected = (m.significance() < clusterMaxSignificance && 
00056                     dotprodSeed > clusterMinAngleCosine && //Angles between PV-PCAonSeed vectors and seed directions
00057                     dotprodTrack > clusterMinAngleCosine && //Angles between PV-PCAonTrack vectors and track directions
00058 //                    dotprodTrackSeed2D > clusterMinAngleCosine && //Angle between track and seed
00059         //      distance*clusterScale*tracks.size() < (distanceFromPV+pvDistance)*(distanceFromPV+pvDistance)/pvDistance && // cut scaling with track density
00060                    distance*clusterScale < densityFactor*distanceFromPV && // cut scaling with track density
00061                     distance < clusterMaxDistance);  // absolute distance cut
00062 
00063 #ifdef VTXDEBUG
00064                     std::cout << tt->trackBaseRef().key() << " :  " << (selected?"+":" ")<< " " << m.significance() << " < " << clusterMaxSignificance <<  " &&  " << 
00065                     dotprodSeed  << " > " <<  clusterMinAngleCosine << "  && " << 
00066                     dotprodTrack  << " > " <<  clusterMinAngleCosine << "  && " << 
00067                     dotprodTrackSeed2D  << " > " <<  clusterMinAngleCosine << "  &&  "  << 
00068                     distance*clusterScale  << " < " <<  densityFactor*distanceFromPV << "  crossingtoPV: " << distanceFromPV << " dis*scal " <<  distance*clusterScale << "  <  " << densityFactor*distanceFromPV << " dist: " << distance << " < " << clusterMaxDistance <<  std::endl; // cut scaling with track density
00069 #endif           
00070                  if(selected)
00071                  {
00072                      result.push_back(*tt);
00073                      seedingPoint = GlobalPoint(cp.x()*w+seedingPoint.x(),cp.y()*w+seedingPoint.y(),cp.z()*w+seedingPoint.z());  
00074                      sumWeights+=w; 
00075                  }
00076             }
00077        }
00078 
00079    seedingPoint = GlobalPoint(seedingPoint.x()/sumWeights,seedingPoint.y()/sumWeights,seedingPoint.z()/sumWeights);
00080    return std::pair<std::vector<reco::TransientTrack>,GlobalPoint>(result,seedingPoint);
00081 
00082 }
00083 
00084 
00085 
00086 
00087 
00088 std::vector<TracksClusteringFromDisplacedSeed::Cluster> TracksClusteringFromDisplacedSeed::clusters(
00089          const reco::Vertex &pv,
00090          const std::vector<reco::TransientTrack> & selectedTracks
00091  )
00092 {
00093         using namespace reco;
00094         std::vector<TransientTrack> seeds;
00095         for(std::vector<TransientTrack>::const_iterator it = selectedTracks.begin(); it != selectedTracks.end(); it++){
00096                 std::pair<bool,Measurement1D> ip = IPTools::absoluteImpactParameter3D(*it,pv);
00097                 if(ip.first && ip.second.value() >= min3DIPValue && ip.second.significance() >= min3DIPSignificance)
00098                   { 
00099 #ifdef VTXDEBUG
00100                     std::cout << "new seed " <<  it-selectedTracks.begin() << " ref " << it->trackBaseRef().key()  << " " << ip.second.value() << " " << ip.second.significance() << " " << it->track().hitPattern().trackerLayersWithMeasurement() << " " << it->track().pt() << " " << it->track().eta() << std::endl;
00101 #endif
00102                     seeds.push_back(*it);  
00103                   }
00104  
00105         }
00106 
00107         std::vector< Cluster > clusters;
00108         int i = 0;
00109         for(std::vector<TransientTrack>::const_iterator s = seeds.begin();
00110             s != seeds.end(); ++s, ++i)
00111         {
00112 #ifdef VTXDEBUG
00113                 std::cout << "Seed N. "<<i <<   std::endl;
00114 #endif // VTXDEBUG
00115                 std::pair<std::vector<reco::TransientTrack>,GlobalPoint>  ntracks = nearTracks(*s,selectedTracks,pv);
00116 //              std::cout << ntracks.first.size() << " " << ntracks.first.size()  << std::endl;
00117 //                if(ntracks.first.size() == 0 || ntracks.first.size() > maxNTracks ) continue;
00118                 ntracks.first.push_back(*s);
00119                 Cluster aCl;
00120                 aCl.seedingTrack = *s;
00121                 aCl.seedPoint = ntracks.second; 
00122                 aCl.tracks = ntracks.first; 
00123                 clusters.push_back(aCl); 
00124        }
00125                 
00126 return clusters;
00127 }
00128