Skip to content

Commit e5ee69a

Browse files
committed
Merge After Cristian included jet Ele and Mu fractions
Merge branch 'master' of github.com:RazorCMS/SUSYBSMAnalysis-RunOneRazorTuplizer
2 parents 166f45a + 000b840 commit e5ee69a

5 files changed

Lines changed: 265 additions & 98 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Instructions for compiling in CMSSW
1111
cmsenv
1212
git clone git@github.com:RazorCMS/SUSYBSMAnalysis-RunOneRazorTuplizer SUSYBSMAnalysis/RunOneRazorTuplizer
1313
git clone https://github.com/RazorCMS/RunOneRazorTuplizer-RecoEgamma-EgammaTools.git RecoEgamma/EgammaTools
14-
git clone https://github.com/latinos/UserCode-CMG-CMGTools-External.git CMGTools/External
14+
git clone https://github.com/RazorCMS/RunOneRazorTuplizer-CMGTools-External.git CMGTools/External
1515
scram b -j 12
1616

1717
Running the BASE ntuplizer

plugins/RazorAux.cc

Lines changed: 98 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -165,56 +165,116 @@ bool RazorTuplizer::isGoodPV( const reco::Vertex *v) {
165165

166166

167167

168-
168+
// **********************************************************
169+
// Old PFNoPU procedure
170+
// **********************************************************
171+
// bool RazorTuplizer::isPFNoPU( const reco::PFCandidate candidate, const reco::Vertex *PV, edm::Handle<reco::VertexCollection> vertices) {
172+
173+
// bool tmpIsPFNoPU = true;
174+
// if(candidate.particleId() == reco::PFCandidate::h) {
175+
// if(candidate.trackRef().isNonnull() && PV &&
176+
// PV->trackWeight(candidate.trackRef()) > 0) {
177+
// tmpIsPFNoPU = true;
178+
// } else {
179+
180+
// bool vertexFound = false;
181+
// const reco::Vertex *closestVtx = 0;
182+
// double dzmin = 10000;
183+
184+
// // loop over vertices
185+
// for (reco::VertexCollection::const_iterator inV = vertices->begin();
186+
// inV != vertices->end(); ++inV) {
187+
// if(candidate.trackRef().isNonnull() &&
188+
// inV->trackWeight(candidate.trackRef()) > 0) {
189+
// vertexFound = true;
190+
// closestVtx = &(*inV);
191+
// break;
192+
// }
193+
// double dz = fabs(candidate.vertex().z() - inV->z());
194+
// if(dz < dzmin) {
195+
// closestVtx = &(*inV);
196+
// dzmin = dz;
197+
// }
198+
// }
199+
200+
// bool fCheckClosestZVertex = true; //we use option 1
201+
// if(fCheckClosestZVertex) {
202+
// // Fallback: if track is not associated with any vertex,
203+
// // associate it with the vertex closest in z
204+
// if(vertexFound || closestVtx != PV) {
205+
// tmpIsPFNoPU = kFALSE;
206+
// } else {
207+
// tmpIsPFNoPU = kTRUE;
208+
// }
209+
// } else {
210+
// if(vertexFound && closestVtx != PV) {
211+
// tmpIsPFNoPU = kFALSE;
212+
// } else {
213+
// tmpIsPFNoPU = kTRUE;
214+
// }
215+
// }
216+
// } //charged hadron & trk stuff
217+
// } else { // neutrals
218+
// //
219+
// tmpIsPFNoPU = kTRUE;
220+
// }
221+
222+
// return tmpIsPFNoPU;
223+
// }
224+
225+
// **********************************************************
226+
// PFNoPU procedure synchronized with the Vecbos sequence
227+
// **********************************************************
169228
bool RazorTuplizer::isPFNoPU( const reco::PFCandidate candidate, const reco::Vertex *PV, edm::Handle<reco::VertexCollection> vertices) {
170229

171230
bool tmpIsPFNoPU = true;
172231
if(candidate.particleId() == reco::PFCandidate::h) {
173-
if(candidate.trackRef().isNonnull() && PV &&
174-
PV->trackWeight(candidate.trackRef()) > 0) {
175-
tmpIsPFNoPU = true;
176-
} else {
177-
178-
bool vertexFound = false;
179-
const reco::Vertex *closestVtx = 0;
180-
double dzmin = 10000;
181-
182-
// loop over vertices
183-
for (reco::VertexCollection::const_iterator inV = vertices->begin();
184-
inV != vertices->end(); ++inV) {
185-
if(candidate.trackRef().isNonnull() &&
186-
inV->trackWeight(candidate.trackRef()) > 0) {
232+
233+
bool vertexFound = false;
234+
const reco::Vertex *closestVtx = 0;
235+
double bestweight = -1;
236+
double dzmin = 10000;
237+
238+
// loop over vertices and find the vertex with largest weight for given track
239+
for (reco::VertexCollection::const_iterator inV = vertices->begin();
240+
inV != vertices->end(); ++inV) {
241+
if(!isGoodPV(&(*inV))) continue;
242+
if(candidate.trackRef().isNonnull()) {
243+
double w = inV->trackWeight(candidate.trackRef());
244+
if ( w > 0 && w > bestweight ) {
187245
vertexFound = true;
246+
bestweight = w;
188247
closestVtx = &(*inV);
189248
break;
190249
}
191-
double dz = fabs(candidate.vertex().z() - inV->z());
192-
if(dz < dzmin) {
193-
closestVtx = &(*inV);
194-
dzmin = dz;
195-
}
196250
}
197-
198-
bool fCheckClosestZVertex = true; //we use option 1
199-
if(fCheckClosestZVertex) {
200-
// Fallback: if track is not associated with any vertex,
201-
// associate it with the vertex closest in z
202-
if(vertexFound || closestVtx != PV) {
203-
tmpIsPFNoPU = kFALSE;
204-
} else {
205-
tmpIsPFNoPU = kTRUE;
206-
}
207-
} else {
208-
if(vertexFound && closestVtx != PV) {
209-
tmpIsPFNoPU = kFALSE;
210-
} else {
211-
tmpIsPFNoPU = kTRUE;
251+
}
252+
253+
//cout << "best weight: " << bestweight << " : " << vertexFound << " " << bool(closestVtx == PV) << "\n";
254+
//fall back option is to find the vertex closest in z to the track
255+
if (!vertexFound) {
256+
for (reco::VertexCollection::const_iterator inV = vertices->begin();
257+
inV != vertices->end(); ++inV) {
258+
if(!isGoodPV(&(*inV))) continue;
259+
double dz = fabs( candidate.vertex().z() - inV->z() );
260+
//cout << "dz " << candidate.vertex().z() << " " << inV->z() << " " << dz << "\n";
261+
if (dz < dzmin) {
262+
dzmin = dz;
263+
vertexFound = true;
264+
closestVtx = &(*inV);
212265
}
213266
}
214-
} //charged hadron & trk stuff
267+
//cout << "fall back dz : " << dzmin << " " << vertexFound << " " << bool(closestVtx == PV) << "\n";
268+
}
269+
270+
if (!vertexFound || closestVtx == PV) {
271+
tmpIsPFNoPU = true;
272+
} else {
273+
tmpIsPFNoPU = false;
274+
}
215275
} else { // neutrals
216276
//
217-
tmpIsPFNoPU = kTRUE;
277+
tmpIsPFNoPU = true;
218278
}
219279

220280
return tmpIsPFNoPU;
@@ -223,6 +283,7 @@ bool RazorTuplizer::isPFNoPU( const reco::PFCandidate candidate, const reco::Ve
223283

224284

225285

286+
226287
double RazorTuplizer::getPFMiniIsolation(edm::Handle<reco::PFCandidateCollection> pfcands,
227288
const reco::Candidate* ptcl,
228289
double r_iso_min, double r_iso_max, double kt_scale,

0 commit comments

Comments
 (0)