53 #include "fastjet/PseudoJet.hh" 54 #include "fastjet/contrib/Njettiness.hh" 119 beta_(iConfig.getParameter<double>(
"beta")),
120 R0_(iConfig.getParameter<double>(
"R0")),
127 produces<std::vector<reco::BoostedDoubleSVTagInfo> >();
157 auto tagInfos = std::make_unique<std::vector<reco::BoostedDoubleSVTagInfo> >();
160 for(std::vector<reco::CandSecondaryVertexTagInfo>::const_iterator iterTI = svTagInfos->begin(); iterTI != svTagInfos->end(); ++iterTI)
175 float jetNTracks = 0, nSV = 0, tau1_nSecondaryVertices = 0, tau2_nSecondaryVertices = 0;
180 std::vector<fastjet::PseudoJet> currentAxes;
188 pv =
GlobalPoint(vertexRef->x(),vertexRef->y(),vertexRef->z());
192 size_t trackSize = selectedTracks.size();
196 std::vector<float> IP3Ds, IP3Ds_1, IP3Ds_2;
200 for (
size_t itt=0; itt < trackSize; ++itt)
204 float track_PVweight = 0.;
206 if (track_PVweight>0.5) allKinematics.
add(trackRef);
209 bool isSelected =
false;
210 if (
trackSelector(trackRef, data, *jet, pv)) isSelected =
true;
213 bool isfromV0 =
false, isfromV0Tight =
false;
214 std::vector<reco::CandidatePtr> trackPairV0Test(2);
216 trackPairV0Test[0] = trackRef;
218 for (
size_t jtt=0; jtt < trackSize; ++jtt)
220 if (itt == jtt)
continue;
225 trackPairV0Test[1] = pairTrackRef;
232 isfromV0Tight =
true;
235 if (isfromV0 && isfromV0Tight)
239 if( isSelected && !isfromV0Tight ) jetNTracks += 1.;
242 GlobalVector direction(jet->px(), jet->py(), jet->pz());
245 if (currentAxes.size() > 1 &&
reco::deltaR2(trackRef->momentum(),currentAxes[1]) <
reco::deltaR2(trackRef->momentum(),currentAxes[0]))
247 direction =
GlobalVector(currentAxes[index].px(), currentAxes[index].py(), currentAxes[index].pz());
250 float decayLengthTau=-1;
251 float distTauAxis=-1;
263 IP3Ds.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
265 if (currentAxes.size() > 1)
268 IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
270 IP3Ds_2.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
273 IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
278 bool charmThreshSet =
false;
281 for (
size_t i=0;
i<indices.size(); ++
i)
283 size_t idx = indices[
i];
294 charmThreshSet =
true;
300 if ( (
i+1)<indices.size() ) trackSip2dSigAboveBottom_1 = (ipData[indices[
i+1]]).ip2d.significance();
306 float dummyTrack = -50.;
308 std::sort( IP3Ds.begin(),IP3Ds.end(),std::greater<float>() );
309 std::sort( IP3Ds_1.begin(),IP3Ds_1.end(),std::greater<float>() );
310 std::sort( IP3Ds_2.begin(),IP3Ds_2.end(),std::greater<float>() );
311 int num_1 = IP3Ds_1.size();
312 int num_2 = IP3Ds_2.size();
317 trackSip3dSig_0 = dummyTrack;
318 trackSip3dSig_1 = dummyTrack;
319 trackSip3dSig_2 = dummyTrack;
320 trackSip3dSig_3 = dummyTrack;
326 trackSip3dSig_0 = IP3Ds.at(0);
327 trackSip3dSig_1 = dummyTrack;
328 trackSip3dSig_2 = dummyTrack;
329 trackSip3dSig_3 = dummyTrack;
335 trackSip3dSig_0 = IP3Ds.at(0);
336 trackSip3dSig_1 = IP3Ds.at(1);
337 trackSip3dSig_2 = dummyTrack;
338 trackSip3dSig_3 = dummyTrack;
344 trackSip3dSig_0 = IP3Ds.at(0);
345 trackSip3dSig_1 = IP3Ds.at(1);
346 trackSip3dSig_2 = IP3Ds.at(2);
347 trackSip3dSig_3 = dummyTrack;
353 trackSip3dSig_0 = IP3Ds.at(0);
354 trackSip3dSig_1 = IP3Ds.at(1);
355 trackSip3dSig_2 = IP3Ds.at(2);
356 trackSip3dSig_3 = IP3Ds.at(3);
363 tau1_trackSip3dSig_0 = dummyTrack;
364 tau1_trackSip3dSig_1 = dummyTrack;
370 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
371 tau1_trackSip3dSig_1 = dummyTrack;
377 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
378 tau1_trackSip3dSig_1 = IP3Ds_1.at(1);
385 tau2_trackSip3dSig_0 = dummyTrack;
386 tau2_trackSip3dSig_1 = dummyTrack;
391 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
392 tau2_trackSip3dSig_1 = dummyTrack;
398 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
399 tau2_trackSip3dSig_1 = IP3Ds_2.at(1);
406 std::vector<float> tau1_trackEtaRels, tau2_trackEtaRels;
408 std::map<double, size_t> VTXmap;
415 if (currentAxes.size() > 1)
419 tau2Kinematics = tau2Kinematics + vertexKinematic;
420 if( tau2_flightDistance2dSig < 0 )
426 tau2_nSecondaryVertices += 1.;
430 tau1Kinematics = tau1Kinematics + vertexKinematic;
431 if( tau1_flightDistance2dSig < 0 )
437 tau1_nSecondaryVertices += 1.;
441 else if (!currentAxes.empty())
443 tau1Kinematics = tau1Kinematics + vertexKinematic;
444 if( tau1_flightDistance2dSig < 0 )
450 tau1_nSecondaryVertices += 1.;
461 if ( tau1_nSecondaryVertices > 0. )
464 if ( allSum.E() > 0. ) tau1_vertexEnergyRatio = tau1_vertexSum.E() / allSum.E();
465 if ( tau1_vertexEnergyRatio > 50. ) tau1_vertexEnergyRatio = 50.;
467 tau1_vertexMass = tau1_vertexSum.M();
470 if ( tau2_nSecondaryVertices > 0. )
473 if ( allSum.E() > 0. ) tau2_vertexEnergyRatio = tau2_vertexSum.E() / allSum.E();
474 if ( tau2_vertexEnergyRatio > 50. ) tau2_vertexEnergyRatio = 50.;
476 tau2_vertexMass= tau2_vertexSum.M();
480 float dummyEtaRel = -1.;
482 std::sort( tau1_trackEtaRels.begin(),tau1_trackEtaRels.end() );
483 std::sort( tau2_trackEtaRels.begin(),tau2_trackEtaRels.end() );
485 switch(tau2_trackEtaRels.size()){
488 tau2_trackEtaRel_0 = dummyEtaRel;
489 tau2_trackEtaRel_1 = dummyEtaRel;
490 tau2_trackEtaRel_2 = dummyEtaRel;
496 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
497 tau2_trackEtaRel_1 = dummyEtaRel;
498 tau2_trackEtaRel_2 = dummyEtaRel;
504 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
505 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
506 tau2_trackEtaRel_2 = dummyEtaRel;
512 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
513 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
514 tau2_trackEtaRel_2 = tau2_trackEtaRels.at(2);
518 switch(tau1_trackEtaRels.size()){
521 tau1_trackEtaRel_0 = dummyEtaRel;
522 tau1_trackEtaRel_1 = dummyEtaRel;
523 tau1_trackEtaRel_2 = dummyEtaRel;
529 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
530 tau1_trackEtaRel_1 = dummyEtaRel;
531 tau1_trackEtaRel_2 = dummyEtaRel;
537 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
538 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
539 tau1_trackEtaRel_2 = dummyEtaRel;
545 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
546 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
547 tau1_trackEtaRel_2 = tau1_trackEtaRels.at(2);
556 for ( std::map<double, size_t>::iterator iVtx=VTXmap.begin(); iVtx!=VTXmap.end(); ++iVtx)
563 SV_p4_0 = vertex.
p4();
564 vtxMass = SV_p4_0.mass();
572 SV_p4_1 = vertex.
p4();
573 vtxMass = (SV_p4_1+SV_p4_0).
mass();
584 if( (tau1_vertexMass<0 && tau2_vertexMass>0) )
588 tau2_trackEtaRel_0=
temp;
592 tau2_trackEtaRel_1=
temp;
596 tau2_trackEtaRel_2=
temp;
600 tau2_flightDistance2dSig=
temp;
606 tau2_vertexEnergyRatio=
temp;
610 tau2_vertexMass=
temp;
656 std::vector<fastjet::PseudoJet> fjParticles;
661 if ( daughter.isNonnull() && daughter.isAvailable() )
668 for(
size_t i=0;
i<daughter->numberOfDaughters(); ++
i)
674 float valcheck = constit->
px() + constit->
py() + constit->
pz() + constit->
energy();
677 <<
"Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
680 fjParticles.push_back(fastjet::PseudoJet(constit->
px(), constit->
py(), constit->
pz(), constit->
energy()));
683 <<
"Jet constituent required for N-subjettiness computation is missing!";
687 float valcheck = daughter->px() + daughter->py() + daughter->pz() + daughter->energy();
690 <<
"Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
693 fjParticles.push_back(fastjet::PseudoJet(daughter->px(), daughter->py(), daughter->pz(), daughter->energy()));
696 edm::LogWarning(
"MissingJetConstituent") <<
"Jet constituent required for N-subjettiness computation is missing!";
703 tau1 = njettiness.getTau(1, fjParticles);
704 tau2 = njettiness.getTau(2, fjParticles);
705 currentAxes = njettiness.currentAxes();
724 if( baseRef == trackBaseRef )
762 for(std::vector<reco::CandidatePtr>::const_iterator
track = tracks.begin();
track != tracks.end(); ++
track)
reco::Vertex::Point convertPos(const GlobalPoint &p)
const edm::EDGetTokenT< std::vector< reco::CandSecondaryVertexTagInfo > > svTagInfos_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
static float dummyVertexEnergyRatio
const math::XYZTLorentzVector & weightedVectorSum() const
virtual double pz() const =0
z coordinate of momentum vector
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isNonnull() const
Checks for non-null.
const double maxDistToAxis_
const double maxDecayLen_
trackRef_iterator tracks_end() const
last iterator over tracks
const double maxSVDeltaRToJet_
void add(const reco::Track &track, double weight=1.0)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const VTX & secondaryVertex(unsigned int index) const
constexpr bool isNotFinite(T x)
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)
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
Global3DPoint GlobalPoint
reco::TransientTrack build(const reco::Track *p) const
static float dummyVertexMass
edm::RefToBase< Jet > jet(void) const override
returns a polymorphic reference to the tagged jet
GlobalPoint globalPosition() const
const Container & selectedTracks() const
const MagneticField * field() const
reco::V0Filter trackPairV0Filter
void setTracksPVBase(const reco::TrackRef &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
void etaRelToTauAxis(const reco::VertexCompositePtrCandidate &vertex, const fastjet::PseudoJet &tauAxis, std::vector< float > &tau_trackEtaRel) const
reco::TrackSelector trackSelector
reco::TemplatedSecondaryVertexTagInfo< reco::CandIPTagInfo, reco::VertexCompositePtrCandidate > CandSecondaryVertexTagInfo
static float charmThreshold
virtual const daughters & daughterPtrVector() const
references to daughtes
const edm::Ref< VertexCollection > & primaryVertex() const
static float dummyFlightDistance2dSig
~BoostedDoubleSVProducer() override
size_t numberOfDaughters() const override
number of daughters
reco::TrackRef trackRef() const
U second(std::pair< T, U > const &p)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void calcNsubjettiness(const reco::JetBaseRef &jet, float &tau1, float &tau2, std::vector< fastjet::PseudoJet > ¤tAxes) const
void produce(edm::Event &, const edm::EventSetup &) override
virtual double energy() const =0
energy
virtual double py() const =0
y coordinate of momentum vector
#define DEFINE_FWK_MODULE(type)
void addDefault(ParameterSetDescription const &psetDescription)
static float dummyZ_ratio
void beginStream(edm::StreamID) override
const PVAssoc fromPV(size_t ipv=0) const
Abs< T >::type abs(const T &t)
const LorentzVector & p4() const final
four-momentum Lorentz vector
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
std::vector< LinkConnSpec >::const_iterator IT
std::vector< size_t > sortedIndexes(btag::SortCriteria mode=reco::btag::IP3DSig) const
const GlobalVector & flightDirection(unsigned int index) const
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const std::vector< btag::TrackIPData > & impactParameterData() const
unsigned int nVertices() const
static float dummyVertexDeltaR
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double significance() const
static float dummyTrackSip3dSig
XYZVectorD XYZVector
spatial vector with cartesian internal representation
static float bottomThreshold
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Particle reconstructed by the particle flow algorithm.
char data[epos_bytes_allocation]
const math::XYZTLorentzVector & vectorSum() const
Measurement1D flightDistance(unsigned int index, int dim=0) const
void setTracksPV(const reco::CandidatePtr &trackRef, const reco::VertexRef &vertexRef, float &PVweight) const
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
BoostedDoubleSVProducer(const edm::ParameterSet &)
void endStream() override
TrajectoryStateOnSurface impactPointState() const
static float dummyTrackEtaRel
trackRef_iterator tracks_begin() const
first iterator over tracks
virtual double px() const =0
x coordinate of momentum vector
static float dummyTrackSip2dSigAbove
Global3DVector GlobalVector
void insert(const TaggingVariable &variable, bool delayed=false)