CMS 3D CMS Logo

PF_PU_AssoMapAlgos.h
Go to the documentation of this file.
1 #ifndef PF_PU_AssoMapAlgos_h
2 #define PF_PU_AssoMapAlgos_h
3 
8 //
9 // Original Author: Matthias Geisler,32 4-B20,+41227676487,
10 // $Id: PF_PU_AssoMapAlgos.h,v 1.7 2012/11/21 09:45:04 mgeisler Exp $
11 //
12 //
13 
14 #include <string>
15 
20 
22 
26 
29 
34 
37 
40 
44 
46 
49 
50 //
51 // constants, enums and typedefs
52 //
53 
54 const double kMass = 0.49765;
55 const double lamMass = 1.11568;
56 
57 /*limits for the quality criteria*/
58 
59 const double tw_90 = 1.e-2;
60 const double tw_70 = 1.e-1;
61 const double tw_50 = 2.e-1;
62 
63 const double sec_70 = 5.;
64 const double sec_50 = 19.;
65 
66 const double fin_70 = 1.e-1;
67 const double fin_50 = 3.e-1;
68 
73 
74 typedef std::pair<reco::TrackRef, int> TrackQualityPair;
75 typedef std::vector<TrackQualityPair> TrackQualityPairVector;
76 
77 typedef std::pair<reco::VertexRef, int> VertexStepPair;
78 
79 typedef std::pair<reco::VertexRef, TrackQualityPair> VertexTrackQuality;
80 
81 typedef std::pair<reco::VertexRef, float> VertexPtsumPair;
82 typedef std::vector<VertexPtsumPair> VertexPtsumVector;
83 
85 public:
86  //dedicated constructor for the algorithms
89  // virtual destructor needed when virtual functions declared
90  virtual ~PF_PU_AssoMapAlgos() noexcept(false){};
91 
92  //get all needed collections at the beginning
93  virtual void GetInputCollections(edm::Event&, const edm::EventSetup&);
94 
95  //create the track-to-vertex and vertex-to-track maps in one go
96  std::pair<std::unique_ptr<TrackToVertexAssMap>, std::unique_ptr<VertexToTrackAssMap>> createMappings(
98 
99  //create the track to vertex association map
100  std::unique_ptr<TrackToVertexAssMap> CreateTrackToVertexMap(edm::Handle<reco::TrackCollection>);
101 
102  //create the vertex to track association map
103  std::unique_ptr<VertexToTrackAssMap> CreateVertexToTrackMap(edm::Handle<reco::TrackCollection>);
104 
105  //function to sort the vertices in the AssociationMap by the sum of (pT - pT_Error)**2
106  std::unique_ptr<TrackToVertexAssMap> SortAssociationMap(TrackToVertexAssMap*, edm::Handle<reco::TrackCollection>);
107 
108 protected:
109  //protected functions
110 
111  //create helping vertex vector to remove associated vertices
112  std::vector<reco::VertexRef> CreateVertexVector(edm::Handle<reco::VertexCollection>);
113 
114  //erase one vertex from the vertex vector
115  void EraseVertex(std::vector<reco::VertexRef>&, reco::VertexRef);
116 
117  //find an association for a certain track
119  const std::vector<reco::VertexRef>&,
123  int);
124 
125  //get the quality for a certain association
126  int DefineQuality(int, int, double);
127 
128 private:
129  // private methods for internal usage
130 
131  //function to find the closest vertex in z for a certain track
132  static reco::VertexRef FindClosestZ(const reco::TrackRef, const std::vector<reco::VertexRef>&, double tWeight = 0.);
133 
134  //function to find the closest vertex in 3D for a certain track
135  static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector<reco::VertexRef>&, double tWeight = 0.);
136 
137  //function to calculate the deltaR between a vector and a vector connecting two points
138  static double dR(const math::XYZPoint&, const math::XYZVector&, edm::Handle<reco::BeamSpot>);
139 
140  //function to filter the conversion collection
141  static std::unique_ptr<reco::ConversionCollection> GetCleanedConversions(edm::Handle<reco::ConversionCollection>,
143  bool);
144 
145  //function to find out if the track comes from a gamma conversion
147 
149  const reco::Conversion&,
153  const std::vector<reco::VertexRef>&,
154  double);
155 
156  //function to filter the Kshort collection
157  static std::unique_ptr<reco::VertexCompositeCandidateCollection> GetCleanedKshort(
159 
160  //function to filter the Lambda collection
161  static std::unique_ptr<reco::VertexCompositeCandidateCollection> GetCleanedLambda(
163 
164  //function to find out if the track comes from a V0 decay
165  static bool ComesFromV0Decay(const reco::TrackRef,
169 
175  const std::vector<reco::VertexRef>&,
176  double);
177 
178  //function to filter the nuclear interaction collection
179  static std::unique_ptr<reco::PFDisplacedVertexCollection> GetCleanedNI(edm::Handle<reco::PFDisplacedVertexCollection>,
181  bool);
182 
183  //function to find out if the track comes from a nuclear interaction
185 
191  const std::vector<reco::VertexRef>&,
192  double);
193 
194  //function to find the vertex with the highest TrackWeight for a certain track
195  template <typename TREF>
196  static reco::VertexRef TrackWeightAssociation(const TREF&, const std::vector<reco::VertexRef>&);
197 
198  // ----------member data ---------------------------
199 
201 
204 
207 
212 
215 
218  std::unique_ptr<reco::ConversionCollection> cleanedConvCollP;
219 
222  std::unique_ptr<reco::VertexCompositeCandidateCollection> cleanedKshortCollP;
223 
226  std::unique_ptr<reco::VertexCompositeCandidateCollection> cleanedLambdaCollP;
227 
230  std::unique_ptr<reco::PFDisplacedVertexCollection> cleanedNICollP;
231 
233 
235  bool missingColls; // is true if there is a diplaced vertex collection in the event
236 
238 
239  int maxNumWarnings_; // CV: print Warning if TrackExtra objects don't exist in input file,
240  int numWarnings_; // but only a few times
241 };
242 
243 #endif
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > LambdaCollectionToken_
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedLambda(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
edm::ESHandle< MagneticField > bFieldH
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot_
std::unique_ptr< VertexToTrackAssMap > CreateVertexToTrackMap(edm::Handle< reco::TrackCollection >)
static reco::VertexRef FindNIVertex(const reco::TrackRef, const reco::PFDisplacedVertex &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
const double lamMass
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
static std::unique_ptr< reco::PFDisplacedVertexCollection > GetCleanedNI(edm::Handle< reco::PFDisplacedVertexCollection >, edm::Handle< reco::BeamSpot >, bool)
std::unique_ptr< TrackToVertexAssMap > SortAssociationMap(TrackToVertexAssMap *, edm::Handle< reco::TrackCollection >)
const double kMass
static bool ComesFromNI(const reco::TrackRef, const reco::PFDisplacedVertexCollection &, reco::PFDisplacedVertex *)
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedKshort(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
int DefineQuality(int, int, double)
static reco::VertexRef TrackWeightAssociation(const TREF &, const std::vector< reco::VertexRef > &)
VertexStepPair FindAssociation(const reco::TrackRef &, const std::vector< reco::VertexRef > &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, int)
const double tw_70
std::pair< reco::VertexRef, TrackQualityPair > VertexTrackQuality
const double fin_70
edm::ESHandle< GlobalTrackingGeometry > trackingGeometryH
virtual ~PF_PU_AssoMapAlgos() noexcept(false)
std::unique_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
static reco::VertexRef FindConversionVertex(const reco::TrackRef, const reco::Conversion &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
std::pair< reco::VertexRef, int > VertexStepPair
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
std::vector< VertexPtsumPair > VertexPtsumVector
std::unique_ptr< TrackToVertexAssMap > CreateTrackToVertexMap(edm::Handle< reco::TrackCollection >)
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH)
static std::unique_ptr< reco::ConversionCollection > GetCleanedConversions(edm::Handle< reco::ConversionCollection >, edm::Handle< reco::BeamSpot >, bool)
const edm::ESGetToken< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > token_TrackingGeometry_
PF_PU_AssoMapAlgos(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
edm::Handle< reco::PFDisplacedVertexCollection > displVertexCollH
virtual void GetInputCollections(edm::Event &, const edm::EventSetup &)
static bool ComesFromV0Decay(const reco::TrackRef, const reco::VertexCompositeCandidateCollection &, const reco::VertexCompositeCandidateCollection &, reco::VertexCompositeCandidate *)
edm::AssociationMap< edm::OneToManyWithQuality< reco::VertexCollection, reco::TrackCollection, int > > TrackToVertexAssMap
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > NIVertexCollectionToken_
edm::Handle< reco::VertexCollection > vtxcollH
const double sec_50
static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
std::vector< reco::VertexRef > CreateVertexVector(edm::Handle< reco::VertexCollection >)
Block of elements.
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > KshortCollectionToken_
std::pair< reco::VertexRef, float > VertexPtsumPair
std::vector< TrackQualityPair > TrackQualityPairVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::EDGetTokenT< reco::ConversionCollection > ConversionsCollectionToken_
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollLambdaH
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
static reco::VertexRef FindV0Vertex(const reco::TrackRef, const reco::VertexCompositeCandidate &, edm::ESHandle< MagneticField >, edm::ESHandle< GlobalTrackingGeometry >, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedKshortCollP
void EraseVertex(std::vector< reco::VertexRef > &, reco::VertexRef)
const double tw_50
const double sec_70
static bool ComesFromConversion(const reco::TrackRef, const reco::ConversionCollection &, reco::Conversion *)
std::pair< reco::TrackRef, int > TrackQualityPair
edm::Handle< reco::BeamSpot > beamspotH
edm::Handle< reco::ConversionCollection > convCollH
static reco::VertexRef FindClosestZ(const reco::TrackRef, const std::vector< reco::VertexRef > &, double tWeight=0.)
edm::AssociationMap< edm::OneToManyWithQuality< reco::TrackCollection, reco::VertexCollection, int > > VertexToTrackAssMap
const double tw_90
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollKshortH
const double fin_50
std::unique_ptr< reco::ConversionCollection > cleanedConvCollP
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > token_bField_