CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CandidateBoostedDoubleSecondaryVertexComputer.cc
Go to the documentation of this file.
2 
4 
16 
17 #include "fastjet/contrib/Njettiness.hh"
18 
20  beta_(parameters.getParameter<double>("beta")),
21  R0_(parameters.getParameter<double>("R0")),
22  maxSVDeltaRToJet_(parameters.getParameter<double>("maxSVDeltaRToJet")),
23  useCondDB_(parameters.getParameter<bool>("useCondDB")),
24  gbrForestLabel_(parameters.existsAs<std::string>("gbrForestLabel") ? parameters.getParameter<std::string>("gbrForestLabel") : ""),
25  weightFile_(parameters.existsAs<edm::FileInPath>("weightFile") ? parameters.getParameter<edm::FileInPath>("weightFile") : edm::FileInPath()),
26  useGBRForest_(parameters.existsAs<bool>("useGBRForest") ? parameters.getParameter<bool>("useGBRForest") : false),
27  useAdaBoost_(parameters.existsAs<bool>("useAdaBoost") ? parameters.getParameter<bool>("useAdaBoost") : false),
28  maxDistToAxis_(parameters.getParameter<edm::ParameterSet>("trackSelection").getParameter<double>("maxDistToAxis")),
29  maxDecayLen_(parameters.getParameter<edm::ParameterSet>("trackSelection").getParameter<double>("maxDecayLen")),
30  trackPairV0Filter(parameters.getParameter<edm::ParameterSet>("trackPairV0Filter")),
31  trackSelector(parameters.getParameter<edm::ParameterSet>("trackSelection"))
32 {
33  uses(0, "ipTagInfos");
34  uses(1, "svTagInfos");
35 
36  mvaID.reset(new TMVAEvaluator());
37 }
38 
40 {
41  // variable names and order need to be the same as in the training
42  std::vector<std::string> variables({"z_ratio",
43  "trackSipdSig_3","trackSipdSig_2","trackSipdSig_1","trackSipdSig_0",
44  "trackSipdSig_1_0","trackSipdSig_0_0","trackSipdSig_1_1","trackSipdSig_0_1",
45  "trackSip2dSigAboveCharm_0","trackSip2dSigAboveBottom_0","trackSip2dSigAboveBottom_1",
46  "tau0_trackEtaRel_0","tau0_trackEtaRel_1","tau0_trackEtaRel_2",
47  "tau1_trackEtaRel_0","tau1_trackEtaRel_1","tau1_trackEtaRel_2",
48  "tau_vertexMass_0","tau_vertexEnergyRatio_0","tau_vertexDeltaR_0","tau_flightDistance2dSig_0",
49  "tau_vertexMass_1","tau_vertexEnergyRatio_1","tau_flightDistance2dSig_1",
50  "jetNTracks","nSV"});
51  // book TMVA readers
52  std::vector<std::string> spectators({"massPruned", "flavour", "nbHadrons", "ptPruned", "etaPruned"});
53 
54  if (useCondDB_)
55  {
56  const GBRWrapperRcd & gbrWrapperRecord = record.getRecord<GBRWrapperRcd>();
57 
58  edm::ESHandle<GBRForest> gbrForestHandle;
59  gbrWrapperRecord.get(gbrForestLabel_.c_str(), gbrForestHandle);
60 
61  mvaID->initializeGBRForest(gbrForestHandle.product(), variables, spectators, useAdaBoost_);
62  }
63  else
64  mvaID->initialize("Color:Silent:Error", "BDT", weightFile_.fullPath(), variables, spectators, useGBRForest_, useAdaBoost_);
65 
66  // get TransientTrackBuilder
67  const TransientTrackRecord & transientTrackRcd = record.getRecord<TransientTrackRecord>();
68  transientTrackRcd.get("TransientTrackBuilder", trackBuilder);
69 }
70 
72 {
73  // get TagInfos
74  const reco::CandIPTagInfo & ipTagInfo = tagInfo.get<reco::CandIPTagInfo>(0);
76 
77  // default discriminator value
78  float value = -10.;
79 
80  // default variable values
81  float z_ratio = dummyZ_ratio;
82  float trackSip3dSig_3 = dummyTrackSip3dSig, trackSip3dSig_2 = dummyTrackSip3dSig, trackSip3dSig_1 = dummyTrackSip3dSig, trackSip3dSig_0 = dummyTrackSip3dSig;
83  float tau2_trackSip3dSig_0 = dummyTrackSip3dSig, tau1_trackSip3dSig_0 = dummyTrackSip3dSig, tau2_trackSip3dSig_1 = dummyTrackSip3dSig, tau1_trackSip3dSig_1 = dummyTrackSip3dSig;
84  float trackSip2dSigAboveCharm_0 = dummyTrackSip2dSigAbove, trackSip2dSigAboveBottom_0 = dummyTrackSip2dSigAbove, trackSip2dSigAboveBottom_1 = dummyTrackSip2dSigAbove;
85  float tau1_trackEtaRel_0 = dummyTrackEtaRel, tau1_trackEtaRel_1 = dummyTrackEtaRel, tau1_trackEtaRel_2 = dummyTrackEtaRel;
86  float tau2_trackEtaRel_0 = dummyTrackEtaRel, tau2_trackEtaRel_1 = dummyTrackEtaRel, tau2_trackEtaRel_2 = dummyTrackEtaRel;
87  float tau1_vertexMass = dummyVertexMass, tau1_vertexEnergyRatio = dummyVertexEnergyRatio, tau1_vertexDeltaR = dummyVertexDeltaR, tau1_flightDistance2dSig = dummyFlightDistance2dSig;
88  float tau2_vertexMass = dummyVertexMass, tau2_vertexEnergyRatio = dummyVertexEnergyRatio, tau2_vertexDeltaR = dummyVertexDeltaR, tau2_flightDistance2dSig = dummyFlightDistance2dSig;
89  float jetNTracks = 0, nSV = 0, tau1_nSecondaryVertices = 0, tau2_nSecondaryVertices = 0;
90 
91  // get the jet reference
92  const reco::JetBaseRef jet = svTagInfo.jet();
93 
94  std::vector<fastjet::PseudoJet> currentAxes;
95  float tau2, tau1;
96  // calculate N-subjettiness
97  calcNsubjettiness(jet, tau1, tau2, currentAxes);
98 
99  const reco::VertexRef & vertexRef = ipTagInfo.primaryVertex();
100  GlobalPoint pv(0.,0.,0.);
101  if ( ipTagInfo.primaryVertex().isNonnull() )
102  pv = GlobalPoint(vertexRef->x(),vertexRef->y(),vertexRef->z());
103 
104  const std::vector<reco::CandidatePtr> & selectedTracks = ipTagInfo.selectedTracks();
105  const std::vector<reco::btag::TrackIPData> & ipData = ipTagInfo.impactParameterData();
106  size_t trackSize = selectedTracks.size();
107 
108 
109  reco::TrackKinematics allKinematics;
110  std::vector<float> IP3Ds, IP3Ds_1, IP3Ds_2;
111  int contTrk=0;
112 
113  // loop over tracks associated to the jet
114  for (size_t itt=0; itt < trackSize; ++itt)
115  {
116  const reco::CandidatePtr ptrackRef = selectedTracks[itt];
117  const reco::Track * ptrackPtr = reco::btag::toTrack(ptrackRef);
118  const reco::Track & ptrack = *ptrackPtr;
119 
120  float track_PVweight = 0.;
121  setTracksPV(ptrackRef, vertexRef, track_PVweight);
122  if (track_PVweight>0.5) allKinematics.add(ptrack, track_PVweight);
123 
124  const reco::btag::TrackIPData &data = ipData[itt];
125  bool isSelected = false;
126  if (trackSelector(ptrack, data, *jet, pv)) isSelected = true;
127 
128  // check if the track is from V0
129  bool isfromV0 = false, isfromV0Tight = false;
130  const reco::Track * trackPairV0Test[2];
131 
132  trackPairV0Test[0] = ptrackPtr;
133 
134  for (size_t jtt=0; jtt < trackSize; ++jtt)
135  {
136  if (itt == jtt) continue;
137 
138  const reco::btag::TrackIPData & pairTrackData = ipData[jtt];
139  const reco::CandidatePtr pairTrackRef = selectedTracks[jtt];
140  const reco::Track * pairTrackPtr = reco::btag::toTrack(pairTrackRef);
141  const reco::Track & pairTrack = *pairTrackPtr;
142 
143  trackPairV0Test[1] = pairTrackPtr;
144 
145  if (!trackPairV0Filter(trackPairV0Test, 2))
146  {
147  isfromV0 = true;
148 
149  if ( trackSelector(pairTrack, pairTrackData, *jet, pv) )
150  isfromV0Tight = true;
151  }
152 
153  if (isfromV0 && isfromV0Tight)
154  break;
155  }
156 
157  if( isSelected && !isfromV0Tight ) jetNTracks += 1.;
158 
159  reco::TransientTrack transientTrack = trackBuilder->build(ptrack);
160  GlobalVector direction(jet->px(), jet->py(), jet->pz());
161 
162  int index = 0;
163  if (currentAxes.size() > 1 && reco::deltaR2(ptrack,currentAxes[1]) < reco::deltaR2(ptrack,currentAxes[0]))
164  index = 1;
165  direction = GlobalVector(currentAxes[index].px(), currentAxes[index].py(), currentAxes[index].pz());
166 
167  // decay distance and track distance wrt to the closest tau axis
168  float decayLengthTau=-1;
169  float distTauAxis=-1;
170 
171  TrajectoryStateOnSurface closest = IPTools::closestApproachToJet(transientTrack.impactPointState(), *vertexRef , direction, transientTrack.field());
172  if (closest.isValid())
173  decayLengthTau = (closest.globalPosition() - RecoVertex::convertPos(vertexRef->position())).mag();
174 
175  distTauAxis = std::abs(IPTools::jetTrackDistance(transientTrack, direction, *vertexRef ).second.value());
176 
177  float IP3Dsig = ipTagInfo.impactParameterData()[itt].ip3d.significance();
178 
179  if( !isfromV0 && decayLengthTau<maxDecayLen_ && distTauAxis<maxDistToAxis_ )
180  {
181  IP3Ds.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
182  ++contTrk;
183  if (currentAxes.size() > 1)
184  {
185  if (reco::deltaR2(ptrack,currentAxes[0]) < reco::deltaR2(ptrack,currentAxes[1]))
186  IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
187  else
188  IP3Ds_2.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
189  }
190  else
191  IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
192  }
193  }
194 
195  std::vector<size_t> indices = ipTagInfo.sortedIndexes(reco::btag::IP2DSig);
196  bool charmThreshSet = false;
197 
199  for (size_t i=0; i<indices.size(); ++i)
200  {
201  size_t idx = indices[i];
202  const reco::btag::TrackIPData & data = ipData[idx];
203  const reco::CandidatePtr ptrackRef = selectedTracks[idx];
204  const reco::Track * ptrackPtr = reco::btag::toTrack(ptrackRef);
205  const reco::Track & track = (*ptrackPtr);
206 
207  kin.add(track);
208 
209  if ( kin.vectorSum().M() > charmThreshold // charm cut
210  && !charmThreshSet )
211  {
212  trackSip2dSigAboveCharm_0 = data.ip2d.significance();
213 
214  charmThreshSet = true;
215  }
216 
217  if ( kin.vectorSum().M() > bottomThreshold ) // bottom cut
218  {
219  trackSip2dSigAboveBottom_0 = data.ip2d.significance();
220  if ( (i+1)<indices.size() ) trackSip2dSigAboveBottom_1 = (ipData[indices[i+1]]).ip2d.significance();
221 
222  break;
223  }
224  }
225 
226  float dummyTrack = -50.;
227 
228  std::sort( IP3Ds.begin(),IP3Ds.end(),std::greater<float>() );
229  std::sort( IP3Ds_1.begin(),IP3Ds_1.end(),std::greater<float>() );
230  std::sort( IP3Ds_2.begin(),IP3Ds_2.end(),std::greater<float>() );
231  int num_1 = IP3Ds_1.size();
232  int num_2 = IP3Ds_2.size();
233 
234  switch(contTrk){
235  case 0:
236 
237  trackSip3dSig_0 = dummyTrack;
238  trackSip3dSig_1 = dummyTrack;
239  trackSip3dSig_2 = dummyTrack;
240  trackSip3dSig_3 = dummyTrack;
241 
242  break;
243 
244  case 1:
245 
246  trackSip3dSig_0 = IP3Ds.at(0);
247  trackSip3dSig_1 = dummyTrack;
248  trackSip3dSig_2 = dummyTrack;
249  trackSip3dSig_3 = dummyTrack;
250 
251  break;
252 
253  case 2:
254 
255  trackSip3dSig_0 = IP3Ds.at(0);
256  trackSip3dSig_1 = IP3Ds.at(1);
257  trackSip3dSig_2 = dummyTrack;
258  trackSip3dSig_3 = dummyTrack;
259 
260  break;
261 
262  case 3:
263 
264  trackSip3dSig_0 = IP3Ds.at(0);
265  trackSip3dSig_1 = IP3Ds.at(1);
266  trackSip3dSig_2 = IP3Ds.at(2);
267  trackSip3dSig_3 = dummyTrack;
268 
269  break;
270 
271  default:
272 
273  trackSip3dSig_0 = IP3Ds.at(0);
274  trackSip3dSig_1 = IP3Ds.at(1);
275  trackSip3dSig_2 = IP3Ds.at(2);
276  trackSip3dSig_3 = IP3Ds.at(3);
277 
278  }
279 
280  switch(num_1){
281  case 0:
282 
283  tau1_trackSip3dSig_0 = dummyTrack;
284  tau1_trackSip3dSig_1 = dummyTrack;
285 
286  break;
287 
288  case 1:
289 
290  tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
291  tau1_trackSip3dSig_1 = dummyTrack;
292 
293  break;
294 
295  default:
296 
297  tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
298  tau1_trackSip3dSig_1 = IP3Ds_1.at(1);
299 
300  }
301 
302  switch(num_2){
303  case 0:
304 
305  tau2_trackSip3dSig_0 = dummyTrack;
306  tau2_trackSip3dSig_1 = dummyTrack;
307 
308  break;
309 
310  case 1:
311  tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
312  tau2_trackSip3dSig_1 = dummyTrack;
313 
314  break;
315 
316  default:
317 
318  tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
319  tau2_trackSip3dSig_1 = IP3Ds_2.at(1);
320 
321  }
322 
323  math::XYZVector jetDir = jet->momentum().Unit();
324  reco::TrackKinematics tau1Kinematics;
325  reco::TrackKinematics tau2Kinematics;
326  std::vector<float> tau1_trackEtaRels, tau2_trackEtaRels;
327 
328  std::map<double, size_t> VTXmap;
329  for (size_t vtx = 0; vtx < svTagInfo.nVertices(); ++vtx)
330  {
331  reco::TrackKinematics vertexKinematic;
332 
333  // get the vertex kinematics
334  const reco::VertexCompositePtrCandidate vertex = svTagInfo.secondaryVertex(vtx);
335  vertexKinematics(vertex, vertexKinematic);
336 
337  if (currentAxes.size() > 1)
338  {
339  if (reco::deltaR2(svTagInfo.flightDirection(vtx),currentAxes[1]) < reco::deltaR2(svTagInfo.flightDirection(vtx),currentAxes[0]))
340  {
341  tau2Kinematics = tau2Kinematics + vertexKinematic;
342  if( tau2_flightDistance2dSig < 0 )
343  {
344  tau2_flightDistance2dSig = svTagInfo.flightDistance(vtx,true).significance();
345  tau2_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[1]);
346  }
347  etaRelToTauAxis(vertex, currentAxes[1], tau2_trackEtaRels);
348  tau2_nSecondaryVertices += 1.;
349  }
350  else
351  {
352  tau1Kinematics = tau1Kinematics + vertexKinematic;
353  if( tau1_flightDistance2dSig < 0 )
354  {
355  tau1_flightDistance2dSig =svTagInfo.flightDistance(vtx,true).significance();
356  tau1_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[0]);
357  }
358  etaRelToTauAxis(vertex, currentAxes[0], tau1_trackEtaRels);
359  tau1_nSecondaryVertices += 1.;
360  }
361 
362  }
363  else if (currentAxes.size() > 0)
364  {
365  tau1Kinematics = tau1Kinematics + vertexKinematic;
366  if( tau1_flightDistance2dSig < 0 )
367  {
368  tau1_flightDistance2dSig =svTagInfo.flightDistance(vtx,true).significance();
369  tau1_vertexDeltaR = reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[0]);
370  }
371  etaRelToTauAxis(vertex, currentAxes[1], tau1_trackEtaRels);
372  tau1_nSecondaryVertices += 1.;
373  }
374 
375  GlobalVector flightDir = svTagInfo.flightDirection(vtx);
376  if (reco::deltaR2(flightDir, jetDir)<(maxSVDeltaRToJet_*maxSVDeltaRToJet_))
377  VTXmap[svTagInfo.flightDistance(vtx).error()]=vtx;
378  }
379  nSV = VTXmap.size();
380 
381 
382  math::XYZTLorentzVector allSum = allKinematics.weightedVectorSum() ;
383  if ( tau1_nSecondaryVertices > 0. )
384  {
385  math::XYZTLorentzVector tau1_vertexSum = tau1Kinematics.weightedVectorSum();
386  tau1_vertexEnergyRatio = tau1_vertexSum.E() / allSum.E();
387  if ( tau1_vertexEnergyRatio > 50. ) tau1_vertexEnergyRatio = 50.;
388 
389  tau1_vertexMass = tau1_vertexSum.M();
390  }
391 
392  if ( tau2_nSecondaryVertices > 0. )
393  {
394  math::XYZTLorentzVector tau2_vertexSum = tau2Kinematics.weightedVectorSum();
395  tau2_vertexEnergyRatio = tau2_vertexSum.E() / allSum.E();
396  if ( tau2_vertexEnergyRatio > 50. ) tau2_vertexEnergyRatio = 50.;
397 
398  tau2_vertexMass= tau2_vertexSum.M();
399  }
400 
401 
402  float dummyEtaRel = -1.;
403 
404  std::sort( tau1_trackEtaRels.begin(),tau1_trackEtaRels.end() );
405  std::sort( tau2_trackEtaRels.begin(),tau2_trackEtaRels.end() );
406 
407  switch(tau2_trackEtaRels.size()){
408  case 0:
409 
410  tau2_trackEtaRel_0 = dummyEtaRel;
411  tau2_trackEtaRel_1 = dummyEtaRel;
412  tau2_trackEtaRel_2 = dummyEtaRel;
413 
414  break;
415 
416  case 1:
417 
418  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
419  tau2_trackEtaRel_1 = dummyEtaRel;
420  tau2_trackEtaRel_2 = dummyEtaRel;
421 
422  break;
423 
424  case 2:
425 
426  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
427  tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
428  tau2_trackEtaRel_2 = dummyEtaRel;
429 
430  break;
431 
432  default:
433 
434  tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
435  tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
436  tau2_trackEtaRel_2 = tau2_trackEtaRels.at(2);
437 
438  }
439 
440  switch(tau1_trackEtaRels.size()){
441  case 0:
442 
443  tau1_trackEtaRel_0 = dummyEtaRel;
444  tau1_trackEtaRel_1 = dummyEtaRel;
445  tau1_trackEtaRel_2 = dummyEtaRel;
446 
447  break;
448 
449  case 1:
450 
451  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
452  tau1_trackEtaRel_1 = dummyEtaRel;
453  tau1_trackEtaRel_2 = dummyEtaRel;
454 
455  break;
456 
457  case 2:
458 
459  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
460  tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
461  tau1_trackEtaRel_2 = dummyEtaRel;
462 
463  break;
464 
465  default:
466 
467  tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
468  tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
469  tau1_trackEtaRel_2 = tau1_trackEtaRels.at(2);
470 
471  }
472 
473  int cont=0;
474  GlobalVector flightDir_0, flightDir_1;
475  reco::Candidate::LorentzVector SV_p4_0 , SV_p4_1;
476  double vtxMass = 0.;
477 
478  for ( std::map<double, size_t>::iterator iVtx=VTXmap.begin(); iVtx!=VTXmap.end(); ++iVtx)
479  {
480  ++cont;
481  const reco::VertexCompositePtrCandidate &vertex = svTagInfo.secondaryVertex(iVtx->second);
482  if (cont==1)
483  {
484  flightDir_0 = svTagInfo.flightDirection(iVtx->second);
485  SV_p4_0 = vertex.p4();
486  vtxMass = SV_p4_0.mass();
487 
488  if(vtxMass > 0.)
489  z_ratio = reco::deltaR(currentAxes[1],currentAxes[0])*SV_p4_0.pt()/vtxMass;
490  }
491  if (cont==2)
492  {
493  flightDir_1 = svTagInfo.flightDirection(iVtx->second);
494  SV_p4_1 = vertex.p4();
495  vtxMass = (SV_p4_1+SV_p4_0).mass();
496 
497  if(vtxMass > 0.)
498  z_ratio = reco::deltaR(flightDir_0,flightDir_1)*SV_p4_1.pt()/vtxMass;
499 
500  break;
501  }
502  }
503 
504  // when only one tau axis has SVs assigned, they are all assigned to the 1st tau axis
505  // in the special case below need to swap values
506  if( (tau1_vertexMass<0 && tau2_vertexMass>0) )
507  {
508  float temp = tau1_trackEtaRel_0;
509  tau1_trackEtaRel_0= tau2_trackEtaRel_0;
510  tau2_trackEtaRel_0= temp;
511 
512  temp = tau1_trackEtaRel_1;
513  tau1_trackEtaRel_1= tau2_trackEtaRel_1;
514  tau2_trackEtaRel_1= temp;
515 
516  temp = tau1_trackEtaRel_2;
517  tau1_trackEtaRel_2= tau2_trackEtaRel_2;
518  tau2_trackEtaRel_2= temp;
519 
520  temp = tau1_flightDistance2dSig;
521  tau1_flightDistance2dSig= tau2_flightDistance2dSig;
522  tau2_flightDistance2dSig= temp;
523 
524  tau1_vertexDeltaR= tau2_vertexDeltaR;
525 
526  temp = tau1_vertexEnergyRatio;
527  tau1_vertexEnergyRatio= tau2_vertexEnergyRatio;
528  tau2_vertexEnergyRatio= temp;
529 
530  temp = tau1_vertexMass;
531  tau1_vertexMass= tau2_vertexMass;
532  tau2_vertexMass= temp;
533  }
534 
535 
536  std::map<std::string,float> inputs;
537  inputs["z_ratio"] = z_ratio;
538  inputs["trackSipdSig_3"] = trackSip3dSig_3;
539  inputs["trackSipdSig_2"] = trackSip3dSig_2;
540  inputs["trackSipdSig_1"] = trackSip3dSig_1;
541  inputs["trackSipdSig_0"] = trackSip3dSig_0;
542  inputs["trackSipdSig_1_0"] = tau2_trackSip3dSig_0;
543  inputs["trackSipdSig_0_0"] = tau1_trackSip3dSig_0;
544  inputs["trackSipdSig_1_1"] = tau2_trackSip3dSig_1;
545  inputs["trackSipdSig_0_1"] = tau1_trackSip3dSig_1;
546  inputs["trackSip2dSigAboveCharm_0"] = trackSip2dSigAboveCharm_0;
547  inputs["trackSip2dSigAboveBottom_0"] = trackSip2dSigAboveBottom_0;
548  inputs["trackSip2dSigAboveBottom_1"] = trackSip2dSigAboveBottom_1;
549  inputs["tau1_trackEtaRel_0"] = tau2_trackEtaRel_0;
550  inputs["tau1_trackEtaRel_1"] = tau2_trackEtaRel_1;
551  inputs["tau1_trackEtaRel_2"] = tau2_trackEtaRel_2;
552  inputs["tau0_trackEtaRel_0"] = tau1_trackEtaRel_0;
553  inputs["tau0_trackEtaRel_1"] = tau1_trackEtaRel_1;
554  inputs["tau0_trackEtaRel_2"] = tau1_trackEtaRel_2;
555  inputs["tau_vertexMass_0"] = tau1_vertexMass;
556  inputs["tau_vertexEnergyRatio_0"] = tau1_vertexEnergyRatio;
557  inputs["tau_vertexDeltaR_0"] = tau1_vertexDeltaR;
558  inputs["tau_flightDistance2dSig_0"] = tau1_flightDistance2dSig;
559  inputs["tau_vertexMass_1"] = tau2_vertexMass;
560  inputs["tau_vertexEnergyRatio_1"] = tau2_vertexEnergyRatio;
561  inputs["tau_flightDistance2dSig_1"] = tau2_flightDistance2dSig;
562  inputs["jetNTracks"] = jetNTracks;
563  inputs["nSV"] = nSV;
564 
565  // evaluate the MVA
566  value = mvaID->evaluate(inputs);
567 
568  // return the final discriminator value
569  return value;
570 }
571 
572 
573 void CandidateBoostedDoubleSecondaryVertexComputer::calcNsubjettiness(const reco::JetBaseRef & jet, float & tau1, float & tau2, std::vector<fastjet::PseudoJet> & currentAxes) const
574 {
575  std::vector<fastjet::PseudoJet> fjParticles;
576 
577  // loop over jet constituents and push them in the vector of FastJet constituents
578  for(const reco::CandidatePtr & daughter : jet->daughterPtrVector())
579  {
580  if ( daughter.isNonnull() && daughter.isAvailable() )
581  fjParticles.push_back( fastjet::PseudoJet( daughter->px(), daughter->py(), daughter->pz(), daughter->energy() ) );
582  else
583  edm::LogWarning("MissingJetConstituent") << "Jet constituent required for N-subjettiness computation is missing!";
584  }
585 
586  // N-subjettiness calculator
587  fastjet::contrib::Njettiness njettiness(fastjet::contrib::OnePass_KT_Axes(), fastjet::contrib::NormalizedMeasure(beta_,R0_));
588 
589  // calculate N-subjettiness
590  tau1 = njettiness.getTau(1, fjParticles);
591  tau2 = njettiness.getTau(2, fjParticles);
592  currentAxes = njettiness.currentAxes();
593 }
594 
595 
596 void CandidateBoostedDoubleSecondaryVertexComputer::setTracksPVBase(const reco::TrackRef & trackRef, const reco::VertexRef & vertexRef, float & PVweight) const
597 {
598  PVweight = 0.;
599 
600  const reco::TrackBaseRef trackBaseRef( trackRef );
601 
603 
604  const reco::Vertex & vtx = *(vertexRef);
605  // loop over tracks in vertices
606  for(IT it=vtx.tracks_begin(); it!=vtx.tracks_end(); ++it)
607  {
608  const reco::TrackBaseRef & baseRef = *it;
609  // one of the tracks in the vertex is the same as the track considered in the function
610  if( baseRef == trackBaseRef )
611  {
612  PVweight = vtx.trackWeight(baseRef);
613  break;
614  }
615  }
616 }
617 
618 
619 void CandidateBoostedDoubleSecondaryVertexComputer::setTracksPV(const reco::CandidatePtr & trackRef, const reco::VertexRef & vertexRef, float & PVweight) const
620 {
621  PVweight = 0.;
622 
623  const pat::PackedCandidate * pcand = dynamic_cast<const pat::PackedCandidate *>(trackRef.get());
624 
625  if(pcand) // MiniAOD case
626  {
627  if( pcand->fromPV() == pat::PackedCandidate::PVUsedInFit )
628  {
629  PVweight = 1.;
630  }
631  }
632  else
633  {
634  const reco::PFCandidate * pfcand = dynamic_cast<const reco::PFCandidate *>(trackRef.get());
635 
636  setTracksPVBase(pfcand->trackRef(), vertexRef, PVweight);
637  }
638 }
639 
640 
642 {
643  const std::vector<reco::CandidatePtr> & tracks = vertex.daughterPtrVector();
644 
645  for(std::vector<reco::CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track) {
646  const reco::Track& mytrack = *(*track)->bestTrack();
647  vtxKinematics.add(mytrack, 1.0);
648  }
649 }
650 
651 
653  fastjet::PseudoJet & tauAxis, std::vector<float> & tau_trackEtaRel) const
654 {
655  math::XYZVector direction(tauAxis.px(), tauAxis.py(), tauAxis.pz());
656  const std::vector<reco::CandidatePtr> & tracks = vertex.daughterPtrVector();
657 
658  for(std::vector<reco::CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track)
659  tau_trackEtaRel.push_back(std::abs(reco::btau::etaRel(direction.Unit(), (*track)->momentum())));
660 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
const math::XYZTLorentzVector & weightedVectorSum() const
const T & get(unsigned int index=0) const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
tuple cont
load Luminosity info ##
Definition: generateEDF.py:622
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
JetCorrectorParameters::Record record
Definition: classes.h:7
void add(const reco::Track &track, double weight=1.0)
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:143
double etaRel(const math::XYZVector &dir, const math::XYZVector &track)
Measurement1D ip2d
Definition: IPTagInfo.h:31
void setTracksPV(const reco::CandidatePtr &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
virtual Vector momentum() const
spatial momentum vector
GlobalPoint globalPosition() const
const Container & selectedTracks() const
Definition: IPTagInfo.h:101
TrajectoryStateOnSurface closestApproachToJet(const TrajectoryStateOnSurface &state, const reco::Vertex &vertex, const GlobalVector &aJetDirection, const MagneticField *field)
Definition: IPTools.cc:177
const MagneticField * field() const
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
void etaRelToTauAxis(const reco::VertexCompositePtrCandidate &vertex, fastjet::PseudoJet &tauAxis, std::vector< float > &tau_trackEtaRel) const
const reco::Track * toTrack(const reco::TrackBaseRef &t)
Definition: IPTagInfo.h:24
const edm::Ref< VertexCollection > & primaryVertex() const
Definition: IPTagInfo.h:133
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:200
reco::TrackRef trackRef() const
Definition: PFCandidate.cc:433
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
const PVAssoc fromPV(size_t ipv=0) const
void get(HolderT &iHolder) const
void uses(unsigned int id, const std::string &label)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
void setTracksPVBase(const reco::TrackRef &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
std::vector< LinkConnSpec >::const_iterator IT
std::vector< size_t > sortedIndexes(btag::SortCriteria mode=reco::btag::IP3DSig) const
Definition: IPTagInfo.h:238
const std::vector< btag::TrackIPData > & impactParameterData() const
Definition: IPTagInfo.h:91
double significance() const
Definition: Measurement1D.h:32
virtual double px() const
x coordinate of momentum vector
tuple tracks
Definition: testEve_cfg.py:39
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void vertexKinematics(const reco::VertexCompositePtrCandidate &vertex, reco::TrackKinematics &vertexKinematics) const
virtual double pz() const
z coordinate of momentum vector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:39
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
const math::XYZTLorentzVector & vectorSum() const
void calcNsubjettiness(const reco::JetBaseRef &jet, float &tau1, float &tau2, std::vector< fastjet::PseudoJet > &currentAxes) const
const daughters & daughterPtrVector() const
references to daughtes
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:37
float discriminator(const TagInfoHelper &tagInfos) const override
TrajectoryStateOnSurface impactPointState() const
volatile std::atomic< bool > shutdown_flag false
std::string fullPath() const
Definition: FileInPath.cc:165
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
virtual double py() const
y coordinate of momentum vector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
tuple trackSelector
Tracks selection.
Definition: valSkim_cff.py:4