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 
48 
49 //
50 // constants, enums and typedefs
51 //
52 
53 const double kMass = 0.49765;
54 const double lamMass = 1.11568;
55 
56 /*limits for the quality criteria*/
57 
58 const double tw_90 = 1.e-2;
59 const double tw_70 = 1.e-1;
60 const double tw_50 = 2.e-1;
61 
62 const double sec_70 = 5.;
63 const double sec_50 = 19.;
64 
65 const double fin_70 = 1.e-1;
66 const double fin_50 = 3.e-1;
67 
72 
73 typedef std::pair<reco::TrackRef, int> TrackQualityPair;
74 typedef std::vector<TrackQualityPair> TrackQualityPairVector;
75 
76 typedef std::pair<reco::VertexRef, int> VertexStepPair;
77 
78 typedef std::pair<reco::VertexRef, TrackQualityPair> VertexTrackQuality;
79 
80 typedef std::pair<reco::VertexRef, float> VertexPtsumPair;
81 typedef std::vector<VertexPtsumPair> VertexPtsumVector;
82 
84 public:
85  //dedicated constructor for the algorithms
88  // virtual destructor needed when virtual functions declared
89  virtual ~PF_PU_AssoMapAlgos() noexcept(false){};
90 
91  //get all needed collections at the beginning
92  virtual void GetInputCollections(edm::Event&, const edm::EventSetup&);
93 
94  //create the track-to-vertex and vertex-to-track maps in one go
95  std::pair<std::unique_ptr<TrackToVertexAssMap>, std::unique_ptr<VertexToTrackAssMap>> createMappings(
96  edm::Handle<reco::TrackCollection> trkcollH, const edm::EventSetup& iSetup);
97 
98  //create the track to vertex association map
99  std::unique_ptr<TrackToVertexAssMap> CreateTrackToVertexMap(edm::Handle<reco::TrackCollection>,
100  const edm::EventSetup&);
101 
102  //create the vertex to track association map
103  std::unique_ptr<VertexToTrackAssMap> CreateVertexToTrackMap(edm::Handle<reco::TrackCollection>,
104  const edm::EventSetup&);
105 
106  //function to sort the vertices in the AssociationMap by the sum of (pT - pT_Error)**2
107  std::unique_ptr<TrackToVertexAssMap> SortAssociationMap(TrackToVertexAssMap*, edm::Handle<reco::TrackCollection>);
108 
109 protected:
110  //protected functions
111 
112  //create helping vertex vector to remove associated vertices
113  std::vector<reco::VertexRef> CreateVertexVector(edm::Handle<reco::VertexCollection>);
114 
115  //erase one vertex from the vertex vector
116  void EraseVertex(std::vector<reco::VertexRef>&, reco::VertexRef);
117 
118  //find an association for a certain track
120  const std::vector<reco::VertexRef>&,
122  const edm::EventSetup&,
124  int);
125 
126  //get the quality for a certain association
127  int DefineQuality(int, int, double);
128 
129 private:
130  // private methods for internal usage
131 
132  //function to find the closest vertex in z for a certain track
133  static reco::VertexRef FindClosestZ(const reco::TrackRef, const std::vector<reco::VertexRef>&, double tWeight = 0.);
134 
135  //function to find the closest vertex in 3D for a certain track
136  static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector<reco::VertexRef>&, double tWeight = 0.);
137 
138  //function to calculate the deltaR between a vector and a vector connecting two points
139  static double dR(const math::XYZPoint&, const math::XYZVector&, edm::Handle<reco::BeamSpot>);
140 
141  //function to filter the conversion collection
142  static std::unique_ptr<reco::ConversionCollection> GetCleanedConversions(edm::Handle<reco::ConversionCollection>,
144  bool);
145 
146  //function to find out if the track comes from a gamma conversion
148 
150  const reco::Conversion&,
152  const edm::EventSetup&,
154  const std::vector<reco::VertexRef>&,
155  double);
156 
157  //function to filter the Kshort collection
158  static std::unique_ptr<reco::VertexCompositeCandidateCollection> GetCleanedKshort(
160 
161  //function to filter the Lambda collection
162  static std::unique_ptr<reco::VertexCompositeCandidateCollection> GetCleanedLambda(
164 
165  //function to find out if the track comes from a V0 decay
166  static bool ComesFromV0Decay(const reco::TrackRef,
170 
174  const edm::EventSetup&,
176  const std::vector<reco::VertexRef>&,
177  double);
178 
179  //function to filter the nuclear interaction collection
180  static std::unique_ptr<reco::PFDisplacedVertexCollection> GetCleanedNI(edm::Handle<reco::PFDisplacedVertexCollection>,
182  bool);
183 
184  //function to find out if the track comes from a nuclear interaction
186 
190  const edm::EventSetup&,
192  const std::vector<reco::VertexRef>&,
193  double);
194 
195  //function to find the vertex with the highest TrackWeight for a certain track
196  template <typename TREF>
197  static reco::VertexRef TrackWeightAssociation(const TREF&, const std::vector<reco::VertexRef>&);
198 
199  // ----------member data ---------------------------
200 
202 
205 
208 
210 
213 
216  std::unique_ptr<reco::ConversionCollection> cleanedConvCollP;
217 
220  std::unique_ptr<reco::VertexCompositeCandidateCollection> cleanedKshortCollP;
221 
224  std::unique_ptr<reco::VertexCompositeCandidateCollection> cleanedLambdaCollP;
225 
228  std::unique_ptr<reco::PFDisplacedVertexCollection> cleanedNICollP;
229 
231 
233  bool missingColls; // is true if there is a diplaced vertex collection in the event
234 
236 
237  int maxNumWarnings_; // CV: print Warning if TrackExtra objects don't exist in input file,
238  int numWarnings_; // but only a few times
239 };
240 
241 #endif
PF_PU_AssoMapAlgos::maxNumWarnings_
int maxNumWarnings_
Definition: PF_PU_AssoMapAlgos.h:237
PF_PU_AssoMapAlgos::CreateVertexVector
std::vector< reco::VertexRef > CreateVertexVector(edm::Handle< reco::VertexCollection >)
Definition: PF_PU_AssoMapAlgos.cc:248
PF_PU_AssoMapAlgos::displVertexCollH
edm::Handle< reco::PFDisplacedVertexCollection > displVertexCollH
Definition: PF_PU_AssoMapAlgos.h:227
PFDisplacedVertexFwd.h
reco::Conversion
Definition: Conversion.h:23
Handle.h
funct::false
false
Definition: Factorize.h:29
PF_PU_AssoMapAlgos::numWarnings_
int numWarnings_
Definition: PF_PU_AssoMapAlgos.h:238
PF_PU_AssoMapAlgos::CreateVertexToTrackMap
std::unique_ptr< VertexToTrackAssMap > CreateVertexToTrackMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
Definition: PF_PU_AssoMapAlgos.cc:161
sec_50
const double sec_50
Definition: PF_PU_AssoMapAlgos.h:63
PF_PU_AssoMapAlgos
Definition: PF_PU_AssoMapAlgos.h:83
edm::EDGetTokenT< reco::VertexCollection >
TrackBase.h
PF_PU_AssoMapAlgos::GetInputCollections
virtual void GetInputCollections(edm::Event &, const edm::EventSetup &)
Definition: PF_PU_AssoMapAlgos.cc:59
AssociationMap.h
VertexToTrackAssMap
edm::AssociationMap< edm::OneToManyWithQuality< reco::TrackCollection, reco::VertexCollection, int > > VertexToTrackAssMap
Definition: PF_PU_AssoMapAlgos.h:71
PF_PU_AssoMapAlgos::GetCleanedConversions
static std::unique_ptr< reco::ConversionCollection > GetCleanedConversions(edm::Handle< reco::ConversionCollection >, edm::Handle< reco::BeamSpot >, bool)
Definition: PF_PU_AssoMapAlgos.cc:367
PF_PU_AssoMapAlgos::createMappings
std::pair< std::unique_ptr< TrackToVertexAssMap >, std::unique_ptr< VertexToTrackAssMap > > createMappings(edm::Handle< reco::TrackCollection > trkcollH, const edm::EventSetup &iSetup)
Definition: PF_PU_AssoMapAlgos.cc:102
PF_PU_AssoMapAlgos::token_VertexCollection_
edm::EDGetTokenT< reco::VertexCollection > token_VertexCollection_
Definition: PF_PU_AssoMapAlgos.h:203
PF_PU_AssoMapAlgos::FindConversionVertex
static reco::VertexRef FindConversionVertex(const reco::TrackRef, const reco::Conversion &, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
Definition: PF_PU_AssoMapAlgos.cc:408
TrackQualityPairVector
std::vector< TrackQualityPair > TrackQualityPairVector
Definition: PF_PU_AssoMapAlgos.h:74
TrackQualityPair
std::pair< reco::TrackRef, int > TrackQualityPair
Definition: PF_PU_AssoMapAlgos.h:73
PF_PU_AssoMapAlgos::dR
static double dR(const math::XYZPoint &, const math::XYZVector &, edm::Handle< reco::BeamSpot >)
Definition: PF_PU_AssoMapAlgos.cc:343
reco::VertexCompositeCandidate
Definition: VertexCompositeCandidate.h:16
PF_PU_AssoMapAlgos::vtxcollH
edm::Handle< reco::VertexCollection > vtxcollH
Definition: PF_PU_AssoMapAlgos.h:204
TransientTrack.h
ConversionFwd.h
edm::Handle< reco::TrackCollection >
reco::PFDisplacedVertexCollection
std::vector< PFDisplacedVertex > PFDisplacedVertexCollection
collection of PFDisplacedVertex objects
Definition: PFDisplacedVertexFwd.h:10
VertexPtsumVector
std::vector< VertexPtsumPair > VertexPtsumVector
Definition: PF_PU_AssoMapAlgos.h:81
PF_PU_AssoMapAlgos::convCollH
edm::Handle< reco::ConversionCollection > convCollH
Definition: PF_PU_AssoMapAlgos.h:215
edm::Ref< VertexCollection >
reco::ConversionCollection
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
Definition: ConversionFwd.h:9
PF_PU_AssoMapAlgos::FindNIVertex
static reco::VertexRef FindNIVertex(const reco::TrackRef, const reco::PFDisplacedVertex &, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
Definition: PF_PU_AssoMapAlgos.cc:648
fin_50
const double fin_50
Definition: PF_PU_AssoMapAlgos.h:66
PF_PU_AssoMapAlgos::input_nTrack_
double input_nTrack_
Definition: PF_PU_AssoMapAlgos.h:235
PF_PU_AssoMapAlgos::ConversionsCollectionToken_
edm::EDGetTokenT< reco::ConversionCollection > ConversionsCollectionToken_
Definition: PF_PU_AssoMapAlgos.h:214
Track.h
TrackFwd.h
OneToManyWithQuality.h
BeamSpot.h
VertexCompositeCandidate.h
PF_PU_AssoMapAlgos::EraseVertex
void EraseVertex(std::vector< reco::VertexRef > &, reco::VertexRef)
Definition: PF_PU_AssoMapAlgos.cc:262
PF_PU_AssoMapAlgos::vertCompCandCollKshortH
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollKshortH
Definition: PF_PU_AssoMapAlgos.h:219
IdealMagneticFieldRecord.h
edm::ESHandle< MagneticField >
PF_PU_AssoMapAlgos::FindClosestZ
static reco::VertexRef FindClosestZ(const reco::TrackRef, const std::vector< reco::VertexRef > &, double tWeight=0.)
Definition: PF_PU_AssoMapAlgos.cc:277
PF_PU_AssoMapAlgos::KshortCollectionToken_
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > KshortCollectionToken_
Definition: PF_PU_AssoMapAlgos.h:218
PF_PU_AssoMapAlgos::ComesFromConversion
static bool ComesFromConversion(const reco::TrackRef, const reco::ConversionCollection &, reco::Conversion *)
Definition: PF_PU_AssoMapAlgos.cc:391
sec_70
const double sec_70
Definition: PF_PU_AssoMapAlgos.h:62
PF_PU_AssoMapAlgos::cleanedConvCollP
std::unique_ptr< reco::ConversionCollection > cleanedConvCollP
Definition: PF_PU_AssoMapAlgos.h:216
PF_PU_AssoMapAlgos::cleanedKshortCollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedKshortCollP
Definition: PF_PU_AssoMapAlgos.h:220
Vertex.h
PF_PU_AssoMapAlgos::GetCleanedNI
static std::unique_ptr< reco::PFDisplacedVertexCollection > GetCleanedNI(edm::Handle< reco::PFDisplacedVertexCollection >, edm::Handle< reco::BeamSpot >, bool)
Definition: PF_PU_AssoMapAlgos.cc:589
PF_PU_AssoMapAlgos::input_FinalAssociation_
int input_FinalAssociation_
Definition: PF_PU_AssoMapAlgos.h:230
PF_PU_AssoMapAlgos::token_BeamSpot_
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot_
Definition: PF_PU_AssoMapAlgos.h:206
edm::ParameterSet
Definition: ParameterSet.h:47
math::XYZPoint
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
reco::PFDisplacedVertex
Block of elements.
Definition: PFDisplacedVertex.h:23
Event.h
PFDisplacedVertex.h
edm::AssociationMap
Definition: AssociationMap.h:48
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PF_PU_AssoMapAlgos::bFieldH
edm::ESHandle< MagneticField > bFieldH
Definition: PF_PU_AssoMapAlgos.h:209
PF_PU_AssoMapAlgos::FindAssociation
VertexStepPair FindAssociation(const reco::TrackRef &, const std::vector< reco::VertexRef > &, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, int)
Definition: PF_PU_AssoMapAlgos.cc:718
PF_PU_AssoMapAlgos::GetCleanedKshort
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedKshort(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
Definition: PF_PU_AssoMapAlgos.cc:433
PF_PU_AssoMapAlgos::DefineQuality
int DefineQuality(int, int, double)
Definition: PF_PU_AssoMapAlgos.cc:811
OneToManyWithQualityGeneric.h
PF_PU_AssoMapAlgos::beamspotH
edm::Handle< reco::BeamSpot > beamspotH
Definition: PF_PU_AssoMapAlgos.h:207
PF_PU_AssoMapAlgos::~PF_PU_AssoMapAlgos
virtual ~PF_PU_AssoMapAlgos() noexcept(false)
Definition: PF_PU_AssoMapAlgos.h:89
PF_PU_AssoMapAlgos::LambdaCollectionToken_
edm::EDGetTokenT< reco::VertexCompositeCandidateCollection > LambdaCollectionToken_
Definition: PF_PU_AssoMapAlgos.h:222
edm::EventSetup
Definition: EventSetup.h:57
PF_PU_AssoMapAlgos::cleanedLambdaCollP
std::unique_ptr< reco::VertexCompositeCandidateCollection > cleanedLambdaCollP
Definition: PF_PU_AssoMapAlgos.h:224
PF_PU_AssoMapAlgos::GetCleanedLambda
static std::unique_ptr< reco::VertexCompositeCandidateCollection > GetCleanedLambda(edm::Handle< reco::VertexCompositeCandidateCollection >, edm::Handle< reco::BeamSpot >, bool)
Definition: PF_PU_AssoMapAlgos.cc:479
PF_PU_AssoMapAlgos::SortAssociationMap
std::unique_ptr< TrackToVertexAssMap > SortAssociationMap(TrackToVertexAssMap *, edm::Handle< reco::TrackCollection >)
Definition: PF_PU_AssoMapAlgos.cc:170
InputTag.h
reco::VertexCompositeCandidateCollection
std::vector< VertexCompositeCandidate > VertexCompositeCandidateCollection
collection of Candidate objects
Definition: VertexCompositeCandidateFwd.h:19
VertexFwd.h
PF_PU_AssoMapAlgos::NIVertexCollectionToken_
edm::EDGetTokenT< reco::PFDisplacedVertexCollection > NIVertexCollectionToken_
Definition: PF_PU_AssoMapAlgos.h:226
TrackToVertexAssMap
edm::AssociationMap< edm::OneToManyWithQuality< reco::VertexCollection, reco::TrackCollection, int > > TrackToVertexAssMap
Definition: PF_PU_AssoMapAlgos.h:69
PF_PU_AssoMapAlgos::ignoremissingpfcollection_
bool ignoremissingpfcollection_
Definition: PF_PU_AssoMapAlgos.h:232
reco::TransientTrack
Definition: TransientTrack.h:19
PF_PU_AssoMapAlgos::CreateTrackToVertexMap
std::unique_ptr< TrackToVertexAssMap > CreateTrackToVertexMap(edm::Handle< reco::TrackCollection >, const edm::EventSetup &)
Definition: PF_PU_AssoMapAlgos.cc:152
PF_PU_AssoMapAlgos::ComesFromNI
static bool ComesFromNI(const reco::TrackRef, const reco::PFDisplacedVertexCollection &, reco::PFDisplacedVertex *)
Definition: PF_PU_AssoMapAlgos.cc:630
lamMass
const double lamMass
Definition: PF_PU_AssoMapAlgos.h:54
fin_70
const double fin_70
Definition: PF_PU_AssoMapAlgos.h:65
VertexTrackQuality
std::pair< reco::VertexRef, TrackQualityPair > VertexTrackQuality
Definition: PF_PU_AssoMapAlgos.h:78
Point3D.h
PF_PU_AssoMapAlgos::cleanedNICollP
std::unique_ptr< reco::PFDisplacedVertexCollection > cleanedNICollP
Definition: PF_PU_AssoMapAlgos.h:228
PF_PU_AssoMapAlgos::vertCompCandCollLambdaH
edm::Handle< reco::VertexCompositeCandidateCollection > vertCompCandCollLambdaH
Definition: PF_PU_AssoMapAlgos.h:223
VertexPtsumPair
std::pair< reco::VertexRef, float > VertexPtsumPair
Definition: PF_PU_AssoMapAlgos.h:80
PF_PU_AssoMapAlgos::FindV0Vertex
static reco::VertexRef FindV0Vertex(const reco::TrackRef, const reco::VertexCompositeCandidate &, edm::ESHandle< MagneticField >, const edm::EventSetup &, edm::Handle< reco::BeamSpot >, const std::vector< reco::VertexRef > &, double)
Definition: PF_PU_AssoMapAlgos.cc:565
ConsumesCollector.h
PF_PU_AssoMapAlgos::FindClosest3D
static reco::VertexRef FindClosest3D(reco::TransientTrack, const std::vector< reco::VertexRef > &, double tWeight=0.)
Definition: PF_PU_AssoMapAlgos.cc:309
tw_70
const double tw_70
Definition: PF_PU_AssoMapAlgos.h:59
View.h
ParameterSet.h
PF_PU_AssoMapAlgos::PF_PU_AssoMapAlgos
PF_PU_AssoMapAlgos(const edm::ParameterSet &iConfig, edm::ConsumesCollector &&iC)
Definition: PF_PU_AssoMapAlgos.h:86
PF_PU_AssoMapAlgos::ComesFromV0Decay
static bool ComesFromV0Decay(const reco::TrackRef, const reco::VertexCompositeCandidateCollection &, const reco::VertexCompositeCandidateCollection &, reco::VertexCompositeCandidate *)
Definition: PF_PU_AssoMapAlgos.cc:525
PF_PU_AssoMapAlgos::TrackWeightAssociation
static reco::VertexRef TrackWeightAssociation(const TREF &, const std::vector< reco::VertexRef > &)
VertexStepPair
std::pair< reco::VertexRef, int > VertexStepPair
Definition: PF_PU_AssoMapAlgos.h:76
PF_PU_AssoMapAlgos::input_MaxNumAssociations_
int input_MaxNumAssociations_
Definition: PF_PU_AssoMapAlgos.h:201
edm::Event
Definition: Event.h:73
PF_PU_AssoMapAlgos::input_doReassociation_
bool input_doReassociation_
Definition: PF_PU_AssoMapAlgos.h:211
PF_PU_AssoMapAlgos::missingColls
bool missingColls
Definition: PF_PU_AssoMapAlgos.h:233
tw_50
const double tw_50
Definition: PF_PU_AssoMapAlgos.h:60
tw_90
const double tw_90
Definition: PF_PU_AssoMapAlgos.h:58
kMass
const double kMass
Definition: PF_PU_AssoMapAlgos.h:53
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
PF_PU_AssoMapAlgos::cleanedColls_
bool cleanedColls_
Definition: PF_PU_AssoMapAlgos.h:212
Conversion.h