17 #include "fastjet/contrib/Njettiness.hh"
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") :
""),
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)
118 float track_PVweight = 0.;
120 if (track_PVweight>0.5) allKinematics.
add(trackRef);
123 bool isSelected =
false;
124 if (
trackSelector(trackRef, data, *jet, pv)) isSelected =
true;
127 bool isfromV0 =
false, isfromV0Tight =
false;
128 std::vector<reco::CandidatePtr> trackPairV0Test(2);
130 trackPairV0Test[0] = trackRef;
132 for (
size_t jtt=0; jtt < trackSize; ++jtt)
134 if (itt == jtt)
continue;
139 trackPairV0Test[1] = pairTrackRef;
146 isfromV0Tight =
true;
149 if (isfromV0 && isfromV0Tight)
153 if( isSelected && !isfromV0Tight ) jetNTracks += 1.;
159 if (currentAxes.size() > 1 &&
reco::deltaR2(trackRef->momentum(),currentAxes[1]) <
reco::deltaR2(trackRef->momentum(),currentAxes[0]))
161 direction =
GlobalVector(currentAxes[index].px(), currentAxes[index].py(), currentAxes[index].pz());
164 float decayLengthTau=-1;
165 float distTauAxis=-1;
177 IP3Ds.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
179 if (currentAxes.size() > 1)
182 IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
184 IP3Ds_2.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
187 IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
192 bool charmThreshSet =
false;
195 for (
size_t i=0;
i<indices.size(); ++
i)
197 size_t idx = indices[
i];
208 charmThreshSet =
true;
214 if ( (
i+1)<indices.size() ) trackSip2dSigAboveBottom_1 = (ipData[indices[
i+1]]).ip2d.significance();
220 float dummyTrack = -50.;
222 std::sort( IP3Ds.begin(),IP3Ds.end(),std::greater<float>() );
223 std::sort( IP3Ds_1.begin(),IP3Ds_1.end(),std::greater<float>() );
224 std::sort( IP3Ds_2.begin(),IP3Ds_2.end(),std::greater<float>() );
225 int num_1 = IP3Ds_1.size();
226 int num_2 = IP3Ds_2.size();
231 trackSip3dSig_0 = dummyTrack;
232 trackSip3dSig_1 = dummyTrack;
233 trackSip3dSig_2 = dummyTrack;
234 trackSip3dSig_3 = dummyTrack;
240 trackSip3dSig_0 = IP3Ds.at(0);
241 trackSip3dSig_1 = dummyTrack;
242 trackSip3dSig_2 = dummyTrack;
243 trackSip3dSig_3 = dummyTrack;
249 trackSip3dSig_0 = IP3Ds.at(0);
250 trackSip3dSig_1 = IP3Ds.at(1);
251 trackSip3dSig_2 = dummyTrack;
252 trackSip3dSig_3 = dummyTrack;
258 trackSip3dSig_0 = IP3Ds.at(0);
259 trackSip3dSig_1 = IP3Ds.at(1);
260 trackSip3dSig_2 = IP3Ds.at(2);
261 trackSip3dSig_3 = dummyTrack;
267 trackSip3dSig_0 = IP3Ds.at(0);
268 trackSip3dSig_1 = IP3Ds.at(1);
269 trackSip3dSig_2 = IP3Ds.at(2);
270 trackSip3dSig_3 = IP3Ds.at(3);
277 tau1_trackSip3dSig_0 = dummyTrack;
278 tau1_trackSip3dSig_1 = dummyTrack;
284 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
285 tau1_trackSip3dSig_1 = dummyTrack;
291 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
292 tau1_trackSip3dSig_1 = IP3Ds_1.at(1);
299 tau2_trackSip3dSig_0 = dummyTrack;
300 tau2_trackSip3dSig_1 = dummyTrack;
305 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
306 tau2_trackSip3dSig_1 = dummyTrack;
312 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
313 tau2_trackSip3dSig_1 = IP3Ds_2.at(1);
320 std::vector<float> tau1_trackEtaRels, tau2_trackEtaRels;
322 std::map<double, size_t> VTXmap;
323 for (
size_t vtx = 0; vtx < svTagInfo.nVertices(); ++vtx)
329 if (currentAxes.size() > 1)
331 if (
reco::deltaR2(svTagInfo.flightDirection(vtx),currentAxes[1]) <
reco::deltaR2(svTagInfo.flightDirection(vtx),currentAxes[0]))
333 tau2Kinematics = tau2Kinematics + vertexKinematic;
334 if( tau2_flightDistance2dSig < 0 )
336 tau2_flightDistance2dSig = svTagInfo.flightDistance(vtx,
true).significance();
337 tau2_vertexDeltaR =
reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[1]);
340 tau2_nSecondaryVertices += 1.;
344 tau1Kinematics = tau1Kinematics + vertexKinematic;
345 if( tau1_flightDistance2dSig < 0 )
347 tau1_flightDistance2dSig =svTagInfo.flightDistance(vtx,
true).significance();
348 tau1_vertexDeltaR =
reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[0]);
351 tau1_nSecondaryVertices += 1.;
355 else if (currentAxes.size() > 0)
357 tau1Kinematics = tau1Kinematics + vertexKinematic;
358 if( tau1_flightDistance2dSig < 0 )
360 tau1_flightDistance2dSig =svTagInfo.flightDistance(vtx,
true).significance();
361 tau1_vertexDeltaR =
reco::deltaR(svTagInfo.flightDirection(vtx),currentAxes[0]);
364 tau1_nSecondaryVertices += 1.;
367 GlobalVector flightDir = svTagInfo.flightDirection(vtx);
369 VTXmap[svTagInfo.flightDistance(vtx).error()]=vtx;
375 if ( tau1_nSecondaryVertices > 0. )
378 tau1_vertexEnergyRatio = tau1_vertexSum.E() / allSum.E();
379 if ( tau1_vertexEnergyRatio > 50. ) tau1_vertexEnergyRatio = 50.;
381 tau1_vertexMass = tau1_vertexSum.M();
384 if ( tau2_nSecondaryVertices > 0. )
387 tau2_vertexEnergyRatio = tau2_vertexSum.E() / allSum.E();
388 if ( tau2_vertexEnergyRatio > 50. ) tau2_vertexEnergyRatio = 50.;
390 tau2_vertexMass= tau2_vertexSum.M();
394 float dummyEtaRel = -1.;
396 std::sort( tau1_trackEtaRels.begin(),tau1_trackEtaRels.end() );
397 std::sort( tau2_trackEtaRels.begin(),tau2_trackEtaRels.end() );
399 switch(tau2_trackEtaRels.size()){
402 tau2_trackEtaRel_0 = dummyEtaRel;
403 tau2_trackEtaRel_1 = dummyEtaRel;
404 tau2_trackEtaRel_2 = dummyEtaRel;
410 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
411 tau2_trackEtaRel_1 = dummyEtaRel;
412 tau2_trackEtaRel_2 = dummyEtaRel;
418 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
419 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
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 = tau2_trackEtaRels.at(2);
432 switch(tau1_trackEtaRels.size()){
435 tau1_trackEtaRel_0 = dummyEtaRel;
436 tau1_trackEtaRel_1 = dummyEtaRel;
437 tau1_trackEtaRel_2 = dummyEtaRel;
443 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
444 tau1_trackEtaRel_1 = dummyEtaRel;
445 tau1_trackEtaRel_2 = dummyEtaRel;
451 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
452 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
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 = tau1_trackEtaRels.at(2);
470 for ( std::map<double, size_t>::iterator iVtx=VTXmap.begin(); iVtx!=VTXmap.end(); ++iVtx)
476 flightDir_0 = svTagInfo.flightDirection(iVtx->second);
477 SV_p4_0 = vertex.
p4();
478 vtxMass = SV_p4_0.mass();
481 z_ratio =
reco::deltaR(currentAxes[1],currentAxes[0])*SV_p4_0.pt()/vtxMass;
485 flightDir_1 = svTagInfo.flightDirection(iVtx->second);
486 SV_p4_1 = vertex.
p4();
487 vtxMass = (SV_p4_1+SV_p4_0).mass();
490 z_ratio =
reco::deltaR(flightDir_0,flightDir_1)*SV_p4_1.pt()/vtxMass;
498 if( (tau1_vertexMass<0 && tau2_vertexMass>0) )
500 float temp = tau1_trackEtaRel_0;
501 tau1_trackEtaRel_0= tau2_trackEtaRel_0;
502 tau2_trackEtaRel_0=
temp;
504 temp = tau1_trackEtaRel_1;
505 tau1_trackEtaRel_1= tau2_trackEtaRel_1;
506 tau2_trackEtaRel_1=
temp;
508 temp = tau1_trackEtaRel_2;
509 tau1_trackEtaRel_2= tau2_trackEtaRel_2;
510 tau2_trackEtaRel_2=
temp;
512 temp = tau1_flightDistance2dSig;
513 tau1_flightDistance2dSig= tau2_flightDistance2dSig;
514 tau2_flightDistance2dSig=
temp;
516 tau1_vertexDeltaR= tau2_vertexDeltaR;
518 temp = tau1_vertexEnergyRatio;
519 tau1_vertexEnergyRatio= tau2_vertexEnergyRatio;
520 tau2_vertexEnergyRatio=
temp;
522 temp = tau1_vertexMass;
523 tau1_vertexMass= tau2_vertexMass;
524 tau2_vertexMass=
temp;
528 std::map<std::string,float>
inputs;
529 inputs[
"z_ratio"] = z_ratio;
530 inputs[
"trackSipdSig_3"] = trackSip3dSig_3;
531 inputs[
"trackSipdSig_2"] = trackSip3dSig_2;
532 inputs[
"trackSipdSig_1"] = trackSip3dSig_1;
533 inputs[
"trackSipdSig_0"] = trackSip3dSig_0;
534 inputs[
"trackSipdSig_1_0"] = tau2_trackSip3dSig_0;
535 inputs[
"trackSipdSig_0_0"] = tau1_trackSip3dSig_0;
536 inputs[
"trackSipdSig_1_1"] = tau2_trackSip3dSig_1;
537 inputs[
"trackSipdSig_0_1"] = tau1_trackSip3dSig_1;
538 inputs[
"trackSip2dSigAboveCharm_0"] = trackSip2dSigAboveCharm_0;
539 inputs[
"trackSip2dSigAboveBottom_0"] = trackSip2dSigAboveBottom_0;
540 inputs[
"trackSip2dSigAboveBottom_1"] = trackSip2dSigAboveBottom_1;
541 inputs[
"tau1_trackEtaRel_0"] = tau2_trackEtaRel_0;
542 inputs[
"tau1_trackEtaRel_1"] = tau2_trackEtaRel_1;
543 inputs[
"tau1_trackEtaRel_2"] = tau2_trackEtaRel_2;
544 inputs[
"tau0_trackEtaRel_0"] = tau1_trackEtaRel_0;
545 inputs[
"tau0_trackEtaRel_1"] = tau1_trackEtaRel_1;
546 inputs[
"tau0_trackEtaRel_2"] = tau1_trackEtaRel_2;
547 inputs[
"tau_vertexMass_0"] = tau1_vertexMass;
548 inputs[
"tau_vertexEnergyRatio_0"] = tau1_vertexEnergyRatio;
549 inputs[
"tau_vertexDeltaR_0"] = tau1_vertexDeltaR;
550 inputs[
"tau_flightDistance2dSig_0"] = tau1_flightDistance2dSig;
551 inputs[
"tau_vertexMass_1"] = tau2_vertexMass;
552 inputs[
"tau_vertexEnergyRatio_1"] = tau2_vertexEnergyRatio;
553 inputs[
"tau_flightDistance2dSig_1"] = tau2_flightDistance2dSig;
558 value =
mvaID->evaluate(inputs);
567 std::vector<fastjet::PseudoJet> fjParticles;
572 if ( daughter.isNonnull() && daughter.isAvailable() )
579 for(
size_t i=0;
i<daughter->numberOfDaughters(); ++
i)
584 fjParticles.push_back( fastjet::PseudoJet( constit->
px(), constit->
py(), constit->
pz(), constit->
energy() ) );
586 edm::LogWarning(
"MissingJetConstituent") <<
"Jet constituent required for N-subjettiness computation is missing!";
590 fjParticles.push_back( fastjet::PseudoJet( daughter->px(), daughter->py(), daughter->pz(), daughter->energy() ) );
593 edm::LogWarning(
"MissingJetConstituent") <<
"Jet constituent required for N-subjettiness computation is missing!";
600 tau1 = njettiness.getTau(1, fjParticles);
601 tau2 = njettiness.getTau(2, fjParticles);
602 currentAxes = njettiness.currentAxes();
620 if( baseRef == trackBaseRef )
652 fastjet::PseudoJet & tauAxis, std::vector<float> & tau_trackEtaRel)
const
657 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
virtual double energy() const =0
energy
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
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.
Base class for all types of Jets.
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_
virtual double pz() const =0
z coordinate of momentum vector
Global3DPoint GlobalPoint
GlobalPoint globalPosition() const
const Container & selectedTracks() const
const MagneticField * field() const
edm::ESHandle< TransientTrackBuilder > trackBuilder
void etaRelToTauAxis(const reco::VertexCompositePtrCandidate &vertex, fastjet::PseudoJet &tauAxis, std::vector< float > &tau_trackEtaRel) const
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
virtual size_t numberOfDaughters() const
number of daughters
reco::V0Filter trackPairV0Filter
static float charmThreshold
static float dummyZ_ratio
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)
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
virtual double py() const final
y coordinate of momentum vector
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
void setTracksPVBase(const reco::TrackRef &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
virtual double py() const =0
y coordinate of momentum vector
std::vector< LinkConnSpec >::const_iterator IT
std::vector< size_t > sortedIndexes(btag::SortCriteria mode=reco::btag::IP3DSig) const
virtual double pz() const final
z coordinate of momentum vector
static float dummyTrackSip3dSig
const std::vector< btag::TrackIPData > & impactParameterData() const
virtual double px() const =0
x coordinate of momentum vector
double significance() const
virtual Vector momentum() const final
spatial momentum vector
static float bottomThreshold
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
math::XYZTLorentzVector LorentzVector
Lorentz vector.
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
const double maxDistToAxis_
reco::TrackSelector trackSelector
Particle reconstructed by the particle flow algorithm.
char data[epos_bytes_allocation]
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
virtual double px() const final
x coordinate of momentum vector
TrajectoryStateOnSurface impactPointState() const
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 final
four-momentum Lorentz vector
Global3DVector GlobalVector
tuple trackSelector
Tracks selection.