19 beta_(parameters.getParameter<double>(
"beta")),
20 R0_(parameters.getParameter<double>(
"R0")),
21 njettiness_(fastjet::contrib::OnePass_KT_Axes(), fastjet::contrib::NormalizedMeasure(beta_,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") :
""),
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")),
33 uses(0,
"ipTagInfos");
34 uses(1,
"svTagInfos");
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",
52 std::vector<std::string> spectators({
"massPruned",
"flavour",
"nbHadrons",
"ptPruned",
"etaPruned"});
89 float jetNTracks = 0, nSV = 0, tau1_nSecondaryVertices = 0, tau2_nSecondaryVertices = 0;
94 std::vector<fastjet::PseudoJet> currentAxes;
102 pv =
GlobalPoint(vertexRef->x(),vertexRef->y(),vertexRef->z());
106 size_t trackSize = selectedTracks.size();
110 std::vector<float> IP3Ds, IP3Ds_1, IP3Ds_2;
114 for (
size_t itt=0; itt < trackSize; ++itt)
120 float track_PVweight = 0.;
122 if (track_PVweight>0.5) allKinematics.
add(ptrack, track_PVweight);
125 bool isSelected =
false;
126 if (
trackSelector(ptrack, data, *jet, pv)) isSelected =
true;
129 bool isfromV0 =
false, isfromV0Tight =
false;
132 trackPairV0Test[0] = ptrackPtr;
134 for (
size_t jtt=0; jtt < trackSize; ++jtt)
136 if (itt == jtt)
continue;
143 trackPairV0Test[1] = pairTrackPtr;
150 isfromV0Tight =
true;
153 if (isfromV0 && isfromV0Tight)
157 if( isSelected && !isfromV0Tight ) jetNTracks += 1.;
165 direction =
GlobalVector(currentAxes[index].px(), currentAxes[index].py(), currentAxes[index].pz());
168 float decayLengthTau=-1;
169 float distTauAxis=-1;
181 IP3Ds.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
183 if (currentAxes.size() > 1)
186 IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
188 IP3Ds_2.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
191 IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
196 bool charmThreshSet =
false;
199 for (
size_t i=0;
i<indices.size(); ++
i)
201 size_t idx = indices[
i];
214 charmThreshSet =
true;
220 if ( (
i+1)<indices.size() ) trackSip2dSigAboveBottom_1 = (ipData[indices[
i+1]]).ip2d.significance();
226 float dummyTrack = -50.;
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();
237 trackSip3dSig_0 = dummyTrack;
238 trackSip3dSig_1 = dummyTrack;
239 trackSip3dSig_2 = dummyTrack;
240 trackSip3dSig_3 = dummyTrack;
246 trackSip3dSig_0 = IP3Ds.at(0);
247 trackSip3dSig_1 = dummyTrack;
248 trackSip3dSig_2 = dummyTrack;
249 trackSip3dSig_3 = dummyTrack;
255 trackSip3dSig_0 = IP3Ds.at(0);
256 trackSip3dSig_1 = IP3Ds.at(1);
257 trackSip3dSig_2 = dummyTrack;
258 trackSip3dSig_3 = dummyTrack;
264 trackSip3dSig_0 = IP3Ds.at(0);
265 trackSip3dSig_1 = IP3Ds.at(1);
266 trackSip3dSig_2 = IP3Ds.at(2);
267 trackSip3dSig_3 = dummyTrack;
273 trackSip3dSig_0 = IP3Ds.at(0);
274 trackSip3dSig_1 = IP3Ds.at(1);
275 trackSip3dSig_2 = IP3Ds.at(2);
276 trackSip3dSig_3 = IP3Ds.at(3);
283 tau1_trackSip3dSig_0 = dummyTrack;
284 tau1_trackSip3dSig_1 = dummyTrack;
290 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
291 tau1_trackSip3dSig_1 = dummyTrack;
297 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
298 tau1_trackSip3dSig_1 = IP3Ds_1.at(1);
305 tau2_trackSip3dSig_0 = dummyTrack;
306 tau2_trackSip3dSig_1 = dummyTrack;
311 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
312 tau2_trackSip3dSig_1 = dummyTrack;
318 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
319 tau2_trackSip3dSig_1 = IP3Ds_2.at(1);
326 std::vector<float> tau1_trackEtaRels, tau2_trackEtaRels;
328 std::map<double, size_t> VTXmap;
329 for (
size_t vtx = 0; vtx < svTagInfo.nVertices(); ++vtx)
337 if (currentAxes.size() > 1)
339 if (
reco::deltaR2(svTagInfo.flightDirection(vtx),currentAxes[1]) <
reco::deltaR2(svTagInfo.flightDirection(vtx),currentAxes[0]))
341 tau2Kinematics = tau2Kinematics + vertexKinematic;
342 if( tau2_flightDistance2dSig < 0 )
344 tau2_flightDistance2dSig = svTagInfo.flightDistance(vtx,
true).significance();
345 tau2_vertexDeltaR =
reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[1]);
348 tau2_nSecondaryVertices += 1.;
352 tau1Kinematics = tau1Kinematics + vertexKinematic;
353 if( tau1_flightDistance2dSig < 0 )
355 tau1_flightDistance2dSig =svTagInfo.flightDistance(vtx,
true).significance();
356 tau1_vertexDeltaR =
reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[0]);
359 tau1_nSecondaryVertices += 1.;
363 else if (currentAxes.size() > 0)
365 tau1Kinematics = tau1Kinematics + vertexKinematic;
366 if( tau1_flightDistance2dSig < 0 )
368 tau1_flightDistance2dSig =svTagInfo.flightDistance(vtx,
true).significance();
369 tau1_vertexDeltaR =
reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[0]);
372 tau1_nSecondaryVertices += 1.;
375 GlobalVector flightDir = svTagInfo.flightDirection(vtx);
377 VTXmap[svTagInfo.flightDistance(vtx).error()]=vtx;
383 if ( tau1_nSecondaryVertices > 0. )
386 tau1_vertexEnergyRatio = tau1_vertexSum.E() / allSum.E();
387 if ( tau1_vertexEnergyRatio > 50. ) tau1_vertexEnergyRatio = 50.;
389 tau1_vertexMass = tau1_vertexSum.M();
392 if ( tau2_nSecondaryVertices > 0. )
395 tau2_vertexEnergyRatio = tau2_vertexSum.E() / allSum.E();
396 if ( tau2_vertexEnergyRatio > 50. ) tau2_vertexEnergyRatio = 50.;
398 tau2_vertexMass= tau2_vertexSum.M();
402 float dummyEtaRel = -1.;
404 std::sort( tau1_trackEtaRels.begin(),tau1_trackEtaRels.end() );
405 std::sort( tau2_trackEtaRels.begin(),tau2_trackEtaRels.end() );
407 switch(tau2_trackEtaRels.size()){
410 tau2_trackEtaRel_0 = dummyEtaRel;
411 tau2_trackEtaRel_1 = dummyEtaRel;
412 tau2_trackEtaRel_2 = dummyEtaRel;
418 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
419 tau2_trackEtaRel_1 = dummyEtaRel;
420 tau2_trackEtaRel_2 = dummyEtaRel;
426 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
427 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
428 tau2_trackEtaRel_2 = dummyEtaRel;
434 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
435 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
436 tau2_trackEtaRel_2 = tau2_trackEtaRels.at(2);
440 switch(tau1_trackEtaRels.size()){
443 tau1_trackEtaRel_0 = dummyEtaRel;
444 tau1_trackEtaRel_1 = dummyEtaRel;
445 tau1_trackEtaRel_2 = dummyEtaRel;
451 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
452 tau1_trackEtaRel_1 = dummyEtaRel;
453 tau1_trackEtaRel_2 = dummyEtaRel;
459 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
460 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
461 tau1_trackEtaRel_2 = dummyEtaRel;
467 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
468 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
469 tau1_trackEtaRel_2 = tau1_trackEtaRels.at(2);
478 for ( std::map<double, size_t>::iterator iVtx=VTXmap.begin(); iVtx!=VTXmap.end(); ++iVtx)
484 flightDir_0 = svTagInfo.flightDirection(iVtx->second);
485 SV_p4_0 = vertex.
p4();
486 vtxMass = SV_p4_0.mass();
489 z_ratio =
reco::deltaR(currentAxes[1],currentAxes[0])*SV_p4_0.pt()/vtxMass;
493 flightDir_1 = svTagInfo.flightDirection(iVtx->second);
494 SV_p4_1 = vertex.
p4();
495 vtxMass = (SV_p4_1+SV_p4_0).mass();
498 z_ratio =
reco::deltaR(flightDir_0,flightDir_1)*SV_p4_1.pt()/vtxMass;
506 if( (tau1_vertexMass<0 && tau2_vertexMass>0) )
508 float temp = tau1_trackEtaRel_0;
509 tau1_trackEtaRel_0= tau2_trackEtaRel_0;
510 tau2_trackEtaRel_0=
temp;
512 temp = tau1_trackEtaRel_1;
513 tau1_trackEtaRel_1= tau2_trackEtaRel_1;
514 tau2_trackEtaRel_1=
temp;
516 temp = tau1_trackEtaRel_2;
517 tau1_trackEtaRel_2= tau2_trackEtaRel_2;
518 tau2_trackEtaRel_2=
temp;
520 temp = tau1_flightDistance2dSig;
521 tau1_flightDistance2dSig= tau2_flightDistance2dSig;
522 tau2_flightDistance2dSig=
temp;
524 tau1_vertexDeltaR= tau2_vertexDeltaR;
526 temp = tau1_vertexEnergyRatio;
527 tau1_vertexEnergyRatio= tau2_vertexEnergyRatio;
528 tau2_vertexEnergyRatio=
temp;
530 temp = tau1_vertexMass;
531 tau1_vertexMass= tau2_vertexMass;
532 tau2_vertexMass=
temp;
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;
566 value =
mvaID->evaluate(inputs);
575 std::vector<fastjet::PseudoJet> fjParticles;
580 if ( daughter.isNonnull() && daughter.isAvailable() )
581 fjParticles.push_back( fastjet::PseudoJet( daughter->px(), daughter->py(), daughter->pz(), daughter->energy() ) );
583 edm::LogWarning(
"MissingJetConstituent") <<
"Jet constituent required for N-subjettiness computation is missing!";
607 if( baseRef == trackBaseRef )
642 for(std::vector<reco::CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track) {
643 const reco::Track& mytrack = *(*track)->bestTrack();
644 vtxKinematics.
add(mytrack, 1.0);
650 fastjet::PseudoJet & tauAxis, std::vector<float> & tau_trackEtaRel)
const
655 for(std::vector<reco::CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track)
static float dummyTrackSip2dSigAbove
reco::Vertex::Point convertPos(const GlobalPoint &p)
static float dummyTrackEtaRel
const math::XYZTLorentzVector & weightedVectorSum() const
const T & get(unsigned int index=0) const
bool isNonnull() const
Checks for non-null.
static float dummyVertexDeltaR
tuple cont
load Luminosity info ##
trackRef_iterator tracks_end() const
last iterator over tracks
void add(const reco::Track &track, double weight=1.0)
static float dummyVertexMass
T const * get() const
Returns C++ pointer to the item.
double etaRel(const math::XYZVector &dir, const math::XYZVector &track)
void setTracksPV(const reco::CandidatePtr &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
const std::string gbrForestLabel_
Global3DPoint GlobalPoint
virtual Vector momentum() const
spatial momentum vector
GlobalPoint globalPosition() const
const Container & selectedTracks() const
const MagneticField * field() const
edm::ESHandle< TransientTrackBuilder > trackBuilder
double deltaR(const T1 &t1, const T2 &t2)
void etaRelToTauAxis(const reco::VertexCompositePtrCandidate &vertex, fastjet::PseudoJet &tauAxis, std::vector< float > &tau_trackEtaRel) const
const reco::Track * toTrack(const reco::TrackBaseRef &t)
const edm::Ref< VertexCollection > & primaryVertex() const
reco::TrackRef trackRef() const
std::unique_ptr< TMVAEvaluator > mvaID
const edm::FileInPath weightFile_
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
const DepRecordT & getRecord() const
reco::V0Filter trackPairV0Filter
static float charmThreshold
static float dummyZ_ratio
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)
double deltaR2(const T1 &t1, const T2 &t2)
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
static float dummyTrackSip3dSig
const std::vector< btag::TrackIPData > & impactParameterData() const
double significance() const
static float bottomThreshold
virtual double px() const
x coordinate of momentum vector
const double maxSVDeltaRToJet_
XYZVectorD XYZVector
spatial vector with cartesian internal representation
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
void initialize(const JetTagComputerRecord &) override
void vertexKinematics(const reco::VertexCompositePtrCandidate &vertex, reco::TrackKinematics &vertexKinematics) const
virtual double pz() const
z coordinate of momentum vector
math::XYZTLorentzVector LorentzVector
Lorentz vector.
const double maxDistToAxis_
reco::TrackSelector trackSelector
Particle reconstructed by the particle flow algorithm.
const double maxDecayLen_
const math::XYZTLorentzVector & vectorSum() const
void calcNsubjettiness(const reco::JetBaseRef &jet, float &tau1, float &tau2, std::vector< fastjet::PseudoJet > ¤tAxes) const
const daughters & daughterPtrVector() const
references to daughtes
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
float discriminator(const TagInfoHelper &tagInfos) const override
TrajectoryStateOnSurface impactPointState() const
fastjet::contrib::Njettiness njettiness_
volatile std::atomic< bool > shutdown_flag false
std::string fullPath() const
trackRef_iterator tracks_begin() const
first iterator over tracks
static float dummyFlightDistance2dSig
CandidateBoostedDoubleSecondaryVertexComputer(const edm::ParameterSet ¶meters)
static float dummyVertexEnergyRatio
virtual const LorentzVector & p4() const
four-momentum Lorentz vector
virtual double py() const
y coordinate of momentum vector
Global3DVector GlobalVector
tuple trackSelector
Tracks selection.