CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_6/src/CommonTools/RecoUtils/interface/PF_PU_AssoMapAlgos.h

Go to the documentation of this file.
00001 #ifndef PF_PU_AssoMapAlgos_h
00002 #define PF_PU_AssoMapAlgos_h
00003 
00004 
00009 //
00010 // Original Author:  Matthias Geisler,32 4-B20,+41227676487,
00011 //
00012 
00013 #include <string>
00014 
00015 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00016 #include "FWCore/Utilities/interface/InputTag.h"
00017 #include "FWCore/Framework/interface/Event.h"
00018 
00019 #include "DataFormats/Common/interface/AssociationMap.h"
00020 #include "DataFormats/Common/interface/Handle.h"
00021 #include "DataFormats/Common/interface/OneToManyWithQuality.h"
00022 #include "DataFormats/Common/interface/OneToManyWithQualityGeneric.h"
00023 #include "DataFormats/Common/interface/View.h"
00024 
00025 #include "DataFormats/Math/interface/Point3D.h"
00026 #include "DataFormats/TrackReco/interface/Track.h"
00027 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00028 #include "DataFormats/TrackReco/interface/TrackBase.h"
00029 #include "DataFormats/VertexReco/interface/Vertex.h"
00030 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00031 #include "DataFormats/EgammaCandidates/interface/Conversion.h"
00032 #include "DataFormats/EgammaCandidates/interface/ConversionFwd.h"
00033 #include "DataFormats/Candidate/interface/VertexCompositeCandidate.h"
00034 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertex.h"
00035 #include "DataFormats/ParticleFlowReco/interface/PFDisplacedVertexFwd.h"
00036 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00037 #include "TrackingTools/TransientTrack/interface/TransientTrack.h"
00038 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00039 
00040   typedef edm::AssociationMap<edm::OneToManyWithQuality< reco::VertexCollection, reco::TrackCollection, float> > TrackVertexAssMap;
00041 
00042   typedef std::pair<reco::TrackRef, float> TrackQualityPair;
00043   typedef std::pair<reco::VertexRef, TrackQualityPair> VertexTrackQuality;
00044 
00045 class PF_PU_AssoMapAlgos{
00046 
00047  public:
00048 
00049    //dedicated constructor for the algorithms
00050    PF_PU_AssoMapAlgos(const edm::ParameterSet&);
00051 
00052    //get all needed collections at the beginning
00053    bool GetInputCollections(edm::Event&, const edm::EventSetup&);
00054 
00055    //do the association for a certain track
00056    VertexTrackQuality DoTrackAssociation(const reco::TrackRef&, const edm::EventSetup&);
00057 
00058    //returns the first vertex of the vertex collection
00059    reco::VertexRef GetFirstVertex();
00060 
00061    //function to sort the vertices in the AssociationMap by the sum of (pT - pT_Error)**2
00062    static std::auto_ptr<TrackVertexAssMap> SortAssociationMap(TrackVertexAssMap*); 
00063 
00064  protected:
00065   //protected functions 
00066 
00067  private: 
00068 
00069   // private methods for internal usage
00070   
00071    //function to find the vertex with the highest TrackWeight for a certain track
00072    static VertexTrackQuality TrackWeightAssociation(const reco::TrackRef&, edm::Handle<reco::VertexCollection>);
00073 
00074    //function to calculate the deltaR between a vector and a vector connecting two points
00075    static double dR(math::XYZPoint, math::XYZVector, edm::Handle<reco::BeamSpot>);
00076  
00077    //function to associate the track to the closest vertex in z/longitudinal distance      
00078    static VertexTrackQuality AssociateClosestZ(reco::TrackRef, edm::Handle<reco::VertexCollection>, double tWeight = 0.);
00079 
00080    //function to find the closest vertex in 3D for a certain track
00081    static reco::VertexRef FindClosest3D(reco::TransientTrack, edm::Handle<reco::VertexCollection>, double tWeight = 0.);
00082    
00083    //function to associate the track to the closest vertex in 3D
00084    static VertexTrackQuality AssociateClosest3D(reco::TrackRef, edm::Handle<reco::VertexCollection>, 
00085                                                 edm::ESHandle<MagneticField>, const edm::EventSetup&, 
00086                                                 edm::Handle<reco::BeamSpot>, double);
00087 
00088    //function to filter the conversion collection
00089    static std::auto_ptr<reco::ConversionCollection> GetCleanedConversions(edm::Handle<reco::ConversionCollection>, 
00090                                                                           edm::Handle<reco::BeamSpot>, bool);
00091 
00092    //function to find out if the track comes from a gamma conversion
00093    static bool ComesFromConversion(const reco::TrackRef, reco::ConversionCollection, reco::Conversion*);
00094         
00095    static VertexTrackQuality FindConversionVertex(const reco::TrackRef, reco::Conversion,       
00096                                                   edm::ESHandle<MagneticField>, const edm::EventSetup&, 
00097                                                   edm::Handle<reco::BeamSpot>, edm::Handle<reco::VertexCollection>, 
00098                                                   double); 
00099 
00100    //function to filter the Kshort collection
00101    static std::auto_ptr<reco::VertexCompositeCandidateCollection> GetCleanedKshort(edm::Handle<reco::VertexCompositeCandidateCollection>, edm::Handle<reco::BeamSpot>, bool);
00102 
00103    //function to filter the Lambda collection
00104    static std::auto_ptr<reco::VertexCompositeCandidateCollection> GetCleanedLambda(edm::Handle<reco::VertexCompositeCandidateCollection>, edm::Handle<reco::BeamSpot>, bool);
00105     
00106    //function to find out if the track comes from a V0 decay
00107    static bool ComesFromV0Decay(const reco::TrackRef, reco::VertexCompositeCandidateCollection, 
00108                                 reco::VertexCompositeCandidateCollection, reco::VertexCompositeCandidate*);
00109    
00110    static VertexTrackQuality FindV0Vertex(const reco::TrackRef, reco::VertexCompositeCandidate, 
00111                                           edm::ESHandle<MagneticField>, const edm::EventSetup&, 
00112                                           edm::Handle<reco::BeamSpot>, edm::Handle<reco::VertexCollection>, double);  
00113 
00114    //function to filter the nuclear interaction collection
00115    static std::auto_ptr<reco::PFDisplacedVertexCollection> GetCleanedNI(edm::Handle<reco::PFDisplacedVertexCollection>, edm::Handle<reco::BeamSpot>, bool); 
00116 
00117    //function to find out if the track comes from a nuclear interaction
00118    static bool ComesFromNI(const reco::TrackRef, reco::PFDisplacedVertexCollection, reco::PFDisplacedVertex*);
00119    
00120    static VertexTrackQuality FindNIVertex(const reco::TrackRef, reco::PFDisplacedVertex, 
00121                                           edm::ESHandle<MagneticField>, const edm::EventSetup&, 
00122                                           edm::Handle<reco::BeamSpot>, edm::Handle<reco::VertexCollection>, double);
00123    
00124    //function to check if a secondary track is compatible with the BeamSpot
00125    static bool CheckBeamSpotCompability(reco::TransientTrack, double);
00126 
00127 
00128   // ----------member data ---------------------------
00129 
00130    edm::InputTag input_VertexCollection_;
00131    edm::Handle<reco::VertexCollection> vtxcollH;
00132 
00133    double input_PtCut_;
00134 
00135    edm::InputTag input_BeamSpot_;
00136    edm::Handle<reco::BeamSpot> beamspotH;
00137 
00138    edm::ESHandle<MagneticField> bFieldH;
00139 
00140    bool input_doReassociation_;
00141    bool cleanedColls_;
00142 
00143    edm::InputTag ConversionsCollection_;
00144    edm::Handle<reco::ConversionCollection> convCollH;
00145    std::auto_ptr<reco::ConversionCollection> cleanedConvCollP;
00146 
00147    edm::InputTag KshortCollection_;
00148    edm::Handle<reco::VertexCompositeCandidateCollection> vertCompCandCollKshortH;
00149    std::auto_ptr<reco::VertexCompositeCandidateCollection> cleanedKshortCollP;
00150 
00151    edm::InputTag LambdaCollection_;
00152    edm::Handle<reco::VertexCompositeCandidateCollection> vertCompCandCollLambdaH;
00153    std::auto_ptr<reco::VertexCompositeCandidateCollection> cleanedLambdaCollP;
00154 
00155    edm::InputTag NIVertexCollection_;
00156    edm::Handle<reco::PFDisplacedVertexCollection> displVertexCollH;
00157    std::auto_ptr<reco::PFDisplacedVertexCollection> cleanedNICollP;
00158 
00159    bool UseBeamSpotCompatibility_;
00160    double input_BSCut_;
00161 
00162    int input_FinalAssociation_;
00163 
00164    bool ignoremissingpfcollection_;
00165    bool missingColls;       // is true if there is a diplaced vertex collection in the event
00166 
00167    double input_nTrack_;
00168 
00169    int maxNumWarnings_;     // CV: print Warning if TrackExtra objects don't exist in input file,
00170    int numWarnings_;        //     but only a few times
00171     
00172 };
00173 
00174 #endif