ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitEdm/ConversionRejection/src/ConversionMatcher.cc
Revision: 1.1
Committed: Tue Jun 8 20:17:28 2010 UTC (14 years, 10 months ago) by bendavid
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, V07-05-00, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, ConvRejection-10-06-09, HEAD
Branch point for: Mit_025c_branch
Log Message:
Add simple tool to do conversion selection and matching

File Contents

# Content
1 // $Id: HitDropper.cc,v 1.11 2009/12/15 23:27:34 bendavid Exp $
2
3 #include <TMath.h>
4 #include "MitEdm/ConversionRejection/interface/ConversionMatcher.h"
5 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
6 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
7 #include "DataFormats/TrackReco/interface/TrackFwd.h"
8 #include "DataFormats/TrackReco/interface/Track.h"
9 #include "DataFormats/Common/interface/RefToPtr.h"
10
11 using namespace edm;
12 using namespace mitedm;
13
14 //--------------------------------------------------------------------------------------------------
15 std::vector<edm::Ptr<DecayPart> > ConversionMatcher::allMatchedConversions(const reco::GsfElectron &ele,
16 const edm::Handle<std::vector<DecayPart> > &convCol) const
17 {
18 //Return vector of ptr's to conversion candidates from the collection which match to the given
19 //electron candidate (through the gsf track)
20
21 std::vector<edm::Ptr<DecayPart> > outCol;
22 if (!convCol.isValid())
23 return outCol;
24
25 const std::vector<DecayPart> *convv = convCol.product();
26
27 for (std::vector<DecayPart>::const_iterator it = convv->begin(); it!=convv->end(); ++it) {
28 if ( matchesConversion(ele,*it) ) {
29 outCol.push_back(edm::Ptr<DecayPart>(convCol,it - convv->begin()));
30 }
31 }
32
33 return outCol;
34
35 }
36
37 //--------------------------------------------------------------------------------------------------
38 std::vector<edm::Ptr<DecayPart> > ConversionMatcher::goodMatchedConversions(const reco::GsfElectron &ele,
39 const edm::Handle<std::vector<DecayPart> > &convCol) const
40 {
41 //Return vector of ptr's to conversion candidates from the collection which both match to the given
42 //electron candidate (through the gsf track) and also pass the selection cuts
43
44 std::vector<edm::Ptr<DecayPart> > outCol;
45 if (!convCol.isValid())
46 return outCol;
47
48 const std::vector<DecayPart> *convv = convCol.product();
49
50 for (std::vector<DecayPart>::const_iterator it = convv->begin(); it!=convv->end(); ++it) {
51 if ( matchesConversion(ele,*it) && isGoodConversion(*it)) {
52 outCol.push_back(edm::Ptr<DecayPart>(convCol,it - convv->begin()));
53 }
54 }
55
56 return outCol;
57
58 }
59
60 //--------------------------------------------------------------------------------------------------
61 bool ConversionMatcher::matchesAnyConversion(const reco::GsfElectron &ele,
62 const edm::Handle<std::vector<DecayPart> > &convCol) const
63 {
64 //check if a given electron candidate matches to at least one conversion candidate in the
65 //collection
66
67 if (!convCol.isValid())
68 return false;
69
70 const std::vector<DecayPart> *convv = convCol.product();
71
72 for (std::vector<DecayPart>::const_iterator it = convv->begin(); it!=convv->end(); ++it) {
73 if ( matchesConversion(ele,*it) ) {
74 return true;
75 }
76 }
77
78 return false;
79
80 }
81
82
83 //--------------------------------------------------------------------------------------------------
84 bool ConversionMatcher::matchesGoodConversion(const reco::GsfElectron &ele,
85 const edm::Handle<std::vector<DecayPart> > &convCol) const
86 {
87 //check if a given electron candidate matches to at least one conversion candidate in the
88 //collection which also passes the selection cuts
89
90 if (!convCol.isValid())
91 return false;
92
93 const std::vector<DecayPart> *convv = convCol.product();
94
95 for (std::vector<DecayPart>::const_iterator it = convv->begin(); it!=convv->end(); ++it) {
96 if ( matchesConversion(ele,*it) && isGoodConversion(*it)) {
97 return true;
98 }
99 }
100
101 return false;
102
103 }
104
105
106 //--------------------------------------------------------------------------------------------------
107 bool ConversionMatcher::matchesConversion(const reco::GsfElectron &ele,
108 const DecayPart &conv) const
109 {
110
111 //Check if a given electron candidate matches a given conversion candidate
112
113 for (int i=0; i<conv.nStableChild(); ++i) {
114 const StableData &sd = conv.getStableData(i);
115 const StablePart *sp = dynamic_cast<const StablePart*>(sd.originalPtr().get());
116 if ( sp->trackPtr() == edm::Ptr<reco::Track>(refToPtr(ele.gsfTrack())) ) {
117 return true;
118 }
119 }
120
121 return false;
122 }
123
124
125 //--------------------------------------------------------------------------------------------------
126 bool ConversionMatcher::isGoodConversion(const DecayPart &conv) const
127 {
128
129 //Check if a given conversion candidate passes the selection cuts to be used for
130 //conversion rejection
131
132 if (TMath::Prob(conv.chi2(),conv.ndof()) < probMin_)
133 return false;
134
135 if ( conv.lxy()<lxyMin_ )
136 return false;
137
138 if ( conv.lz()<lzMin_ )
139 return false;
140
141 if (conv.position().rho() < radiusMin_)
142 return false;
143
144 //loop through daughters
145 for (int i=0; i<conv.nStableChild(); ++i) {
146 const StableData &sd = conv.getStableData(i);
147
148 if (sd.nWrongHits() > wrongHitsMax_)
149 return false;
150
151 const StablePart *sp = dynamic_cast<const StablePart*>(sd.originalPtr().get());
152 const reco::Track *trk = sp->track();
153
154 //don't apply the track proabability cut to gsf tracks
155 if (trk->algo()!=29 && TMath::Prob(trk->chi2(),trk->ndof()) < trackProbMin_)
156 return false;
157
158 }
159
160 return true;
161 }