52 #include "fastjet/PseudoJet.hh" 53 #include "fastjet/contrib/Njettiness.hh" 118 beta_(iConfig.getParameter<double>(
"beta")),
119 R0_(iConfig.getParameter<double>(
"R0")),
126 produces<std::vector<reco::BoostedDoubleSVTagInfo> >();
156 auto tagInfos = std::make_unique<std::vector<reco::BoostedDoubleSVTagInfo> >();
159 for(std::vector<reco::CandSecondaryVertexTagInfo>::const_iterator iterTI = svTagInfos->begin(); iterTI != svTagInfos->end(); ++iterTI)
174 float jetNTracks = 0, nSV = 0, tau1_nSecondaryVertices = 0, tau2_nSecondaryVertices = 0;
179 std::vector<fastjet::PseudoJet> currentAxes;
187 pv =
GlobalPoint(vertexRef->x(),vertexRef->y(),vertexRef->z());
191 size_t trackSize = selectedTracks.size();
195 std::vector<float> IP3Ds, IP3Ds_1, IP3Ds_2;
199 for (
size_t itt=0; itt < trackSize; ++itt)
203 float track_PVweight = 0.;
205 if (track_PVweight>0.5) allKinematics.
add(trackRef);
208 bool isSelected =
false;
209 if (
trackSelector(trackRef, data, *jet, pv)) isSelected =
true;
212 bool isfromV0 =
false, isfromV0Tight =
false;
213 std::vector<reco::CandidatePtr> trackPairV0Test(2);
215 trackPairV0Test[0] = trackRef;
217 for (
size_t jtt=0; jtt < trackSize; ++jtt)
219 if (itt == jtt)
continue;
224 trackPairV0Test[1] = pairTrackRef;
231 isfromV0Tight =
true;
234 if (isfromV0 && isfromV0Tight)
238 if( isSelected && !isfromV0Tight ) jetNTracks += 1.;
241 GlobalVector direction(jet->px(), jet->py(), jet->pz());
244 if (currentAxes.size() > 1 &&
reco::deltaR2(trackRef->momentum(),currentAxes[1]) <
reco::deltaR2(trackRef->momentum(),currentAxes[0]))
246 direction =
GlobalVector(currentAxes[index].px(), currentAxes[index].py(), currentAxes[index].pz());
249 float decayLengthTau=-1;
250 float distTauAxis=-1;
262 IP3Ds.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
264 if (currentAxes.size() > 1)
267 IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
269 IP3Ds_2.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
272 IP3Ds_1.push_back( IP3Dsig<-50. ? -50. : IP3Dsig );
277 bool charmThreshSet =
false;
280 for (
size_t i=0;
i<indices.size(); ++
i)
282 size_t idx = indices[
i];
293 charmThreshSet =
true;
299 if ( (
i+1)<indices.size() ) trackSip2dSigAboveBottom_1 = (ipData[indices[
i+1]]).ip2d.significance();
305 float dummyTrack = -50.;
307 std::sort( IP3Ds.begin(),IP3Ds.end(),std::greater<float>() );
308 std::sort( IP3Ds_1.begin(),IP3Ds_1.end(),std::greater<float>() );
309 std::sort( IP3Ds_2.begin(),IP3Ds_2.end(),std::greater<float>() );
310 int num_1 = IP3Ds_1.size();
311 int num_2 = IP3Ds_2.size();
316 trackSip3dSig_0 = dummyTrack;
317 trackSip3dSig_1 = dummyTrack;
318 trackSip3dSig_2 = dummyTrack;
319 trackSip3dSig_3 = dummyTrack;
325 trackSip3dSig_0 = IP3Ds.at(0);
326 trackSip3dSig_1 = dummyTrack;
327 trackSip3dSig_2 = dummyTrack;
328 trackSip3dSig_3 = dummyTrack;
334 trackSip3dSig_0 = IP3Ds.at(0);
335 trackSip3dSig_1 = IP3Ds.at(1);
336 trackSip3dSig_2 = dummyTrack;
337 trackSip3dSig_3 = dummyTrack;
343 trackSip3dSig_0 = IP3Ds.at(0);
344 trackSip3dSig_1 = IP3Ds.at(1);
345 trackSip3dSig_2 = IP3Ds.at(2);
346 trackSip3dSig_3 = dummyTrack;
352 trackSip3dSig_0 = IP3Ds.at(0);
353 trackSip3dSig_1 = IP3Ds.at(1);
354 trackSip3dSig_2 = IP3Ds.at(2);
355 trackSip3dSig_3 = IP3Ds.at(3);
362 tau1_trackSip3dSig_0 = dummyTrack;
363 tau1_trackSip3dSig_1 = dummyTrack;
369 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
370 tau1_trackSip3dSig_1 = dummyTrack;
376 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
377 tau1_trackSip3dSig_1 = IP3Ds_1.at(1);
384 tau2_trackSip3dSig_0 = dummyTrack;
385 tau2_trackSip3dSig_1 = dummyTrack;
390 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
391 tau2_trackSip3dSig_1 = dummyTrack;
397 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
398 tau2_trackSip3dSig_1 = IP3Ds_2.at(1);
405 std::vector<float> tau1_trackEtaRels, tau2_trackEtaRels;
407 std::map<double, size_t> VTXmap;
414 if (currentAxes.size() > 1)
418 tau2Kinematics = tau2Kinematics + vertexKinematic;
419 if( tau2_flightDistance2dSig < 0 )
425 tau2_nSecondaryVertices += 1.;
429 tau1Kinematics = tau1Kinematics + vertexKinematic;
430 if( tau1_flightDistance2dSig < 0 )
436 tau1_nSecondaryVertices += 1.;
440 else if (currentAxes.size() > 0)
442 tau1Kinematics = tau1Kinematics + vertexKinematic;
443 if( tau1_flightDistance2dSig < 0 )
449 tau1_nSecondaryVertices += 1.;
460 if ( tau1_nSecondaryVertices > 0. )
463 if ( allSum.E() > 0. ) tau1_vertexEnergyRatio = tau1_vertexSum.E() / allSum.E();
464 if ( tau1_vertexEnergyRatio > 50. ) tau1_vertexEnergyRatio = 50.;
466 tau1_vertexMass = tau1_vertexSum.M();
469 if ( tau2_nSecondaryVertices > 0. )
472 if ( allSum.E() > 0. ) tau2_vertexEnergyRatio = tau2_vertexSum.E() / allSum.E();
473 if ( tau2_vertexEnergyRatio > 50. ) tau2_vertexEnergyRatio = 50.;
475 tau2_vertexMass= tau2_vertexSum.M();
479 float dummyEtaRel = -1.;
481 std::sort( tau1_trackEtaRels.begin(),tau1_trackEtaRels.end() );
482 std::sort( tau2_trackEtaRels.begin(),tau2_trackEtaRels.end() );
484 switch(tau2_trackEtaRels.size()){
487 tau2_trackEtaRel_0 = dummyEtaRel;
488 tau2_trackEtaRel_1 = dummyEtaRel;
489 tau2_trackEtaRel_2 = dummyEtaRel;
495 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
496 tau2_trackEtaRel_1 = dummyEtaRel;
497 tau2_trackEtaRel_2 = dummyEtaRel;
503 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
504 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
505 tau2_trackEtaRel_2 = dummyEtaRel;
511 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
512 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
513 tau2_trackEtaRel_2 = tau2_trackEtaRels.at(2);
517 switch(tau1_trackEtaRels.size()){
520 tau1_trackEtaRel_0 = dummyEtaRel;
521 tau1_trackEtaRel_1 = dummyEtaRel;
522 tau1_trackEtaRel_2 = dummyEtaRel;
528 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
529 tau1_trackEtaRel_1 = dummyEtaRel;
530 tau1_trackEtaRel_2 = dummyEtaRel;
536 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
537 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
538 tau1_trackEtaRel_2 = dummyEtaRel;
544 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
545 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
546 tau1_trackEtaRel_2 = tau1_trackEtaRels.at(2);
555 for ( std::map<double, size_t>::iterator iVtx=VTXmap.begin(); iVtx!=VTXmap.end(); ++iVtx)
562 SV_p4_0 = vertex.
p4();
563 vtxMass = SV_p4_0.mass();
566 z_ratio =
reco::deltaR(currentAxes[1],currentAxes[0])*SV_p4_0.pt()/vtxMass;
571 SV_p4_1 = vertex.
p4();
572 vtxMass = (SV_p4_1+SV_p4_0).
mass();
575 z_ratio =
reco::deltaR(flightDir_0,flightDir_1)*SV_p4_1.pt()/vtxMass;
583 if( (tau1_vertexMass<0 && tau2_vertexMass>0) )
587 tau2_trackEtaRel_0=
temp;
591 tau2_trackEtaRel_1=
temp;
595 tau2_trackEtaRel_2=
temp;
599 tau2_flightDistance2dSig=
temp;
605 tau2_vertexEnergyRatio=
temp;
609 tau2_vertexMass=
temp;
655 std::vector<fastjet::PseudoJet> fjParticles;
660 if ( daughter.isNonnull() && daughter.isAvailable() )
667 for(
size_t i=0;
i<daughter->numberOfDaughters(); ++
i)
672 fjParticles.push_back( fastjet::PseudoJet( constit->
px(), constit->
py(), constit->
pz(), constit->
energy() ) );
674 edm::LogWarning(
"MissingJetConstituent") <<
"Jet constituent required for N-subjettiness computation is missing!";
678 fjParticles.push_back( fastjet::PseudoJet( daughter->px(), daughter->py(), daughter->pz(), daughter->energy() ) );
681 edm::LogWarning(
"MissingJetConstituent") <<
"Jet constituent required for N-subjettiness computation is missing!";
688 tau1 = njettiness.getTau(1, fjParticles);
689 tau2 = njettiness.getTau(2, fjParticles);
690 currentAxes = njettiness.currentAxes();
709 if( baseRef == trackBaseRef )
747 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_
~BoostedDoubleSVProducer()
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
#define DEFINE_FWK_MODULE(type)
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
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
const edm::Ref< VertexCollection > & primaryVertex() const
static float dummyFlightDistance2dSig
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
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
virtual void produce(edm::Event &, const edm::EventSetup &) override
virtual double energy() const =0
energy
virtual double py() const =0
y coordinate of momentum vector
virtual size_t numberOfDaughters() const
number of daughters
void addDefault(ParameterSetDescription const &psetDescription)
static float dummyZ_ratio
virtual void beginStream(edm::StreamID) override
const PVAssoc fromPV(size_t ipv=0) const
Abs< T >::type abs(const T &t)
auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
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
const std::vector< btag::TrackIPData > & impactParameterData() const
unsigned int nVertices() const
static float dummyVertexDeltaR
double significance() const
static float dummyTrackSip3dSig
XYZVectorD XYZVector
spatial vector with cartesian internal representation
static float bottomThreshold
math::XYZTLorentzVector LorentzVector
Lorentz vector.
T1 deltaR2(T1 eta1, T2 phi1, T3 eta2, T4 phi2)
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
const daughters & daughterPtrVector() const
references to daughtes
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
BoostedDoubleSVProducer(const edm::ParameterSet &)
virtual 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
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
static float dummyTrackSip2dSigAbove
Global3DVector GlobalVector
void insert(const TaggingVariable &variable, bool delayed=false)
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet