53 #include "fastjet/PseudoJet.hh"
54 #include "fastjet/contrib/Njettiness.hh"
77 std::vector<fastjet::PseudoJet>& currentAxes)
const;
81 const fastjet::PseudoJet& tauAxis,
82 std::vector<float>& tau_trackEtaRel)
const;
128 beta_(iConfig.getParameter<double>(
"beta")),
129 R0_(iConfig.getParameter<double>(
"R0")),
130 maxSVDeltaRToJet_(iConfig.getParameter<double>(
"maxSVDeltaRToJet")),
131 maxDistToAxis_(iConfig.getParameter<edm::
ParameterSet>(
"trackSelection").getParameter<double>(
"maxDistToAxis")),
132 maxDecayLen_(iConfig.getParameter<edm::
ParameterSet>(
"trackSelection").getParameter<double>(
"maxDecayLen")),
137 esConsumes<TransientTrackBuilder, TransientTrackRecord>(
edm::ESInputTag(
"",
"TransientTrackBuilder"));
138 if (!srcWeights.
label().empty())
140 produces<std::vector<reco::BoostedDoubleSVTagInfo>>();
165 auto tagInfos = std::make_unique<std::vector<reco::BoostedDoubleSVTagInfo>>();
168 for (std::vector<reco::CandSecondaryVertexTagInfo>::const_iterator iterTI = svTagInfos->begin();
169 iterTI != svTagInfos->end();
191 float jetNTracks = 0, nSV = 0, tau1_nSecondaryVertices = 0, tau2_nSecondaryVertices = 0;
196 std::vector<fastjet::PseudoJet> currentAxes;
204 pv =
GlobalPoint(vertexRef->x(), vertexRef->y(), vertexRef->z());
208 size_t trackSize = selectedTracks.size();
211 std::vector<float> IP3Ds, IP3Ds_1, IP3Ds_2;
215 for (
size_t itt = 0; itt < trackSize; ++itt) {
218 float track_PVweight = 0.;
220 if (track_PVweight > 0.5)
221 allKinematics.
add(trackRef);
229 bool isfromV0 =
false, isfromV0Tight =
false;
230 std::vector<reco::CandidatePtr> trackPairV0Test(2);
232 trackPairV0Test[0] = trackRef;
234 for (
size_t jtt = 0; jtt < trackSize; ++jtt) {
241 trackPairV0Test[1] = pairTrackRef;
247 isfromV0Tight =
true;
250 if (isfromV0 && isfromV0Tight)
254 if (isSelected && !isfromV0Tight)
258 GlobalVector direction(jet->px(), jet->py(), jet->pz());
261 if (currentAxes.size() > 1 &&
264 direction =
GlobalVector(currentAxes[index].px(), currentAxes[index].py(), currentAxes[index].pz());
267 float decayLengthTau = -1;
268 float distTauAxis = -1;
280 IP3Ds.push_back(IP3Dsig < -50. ? -50. : IP3Dsig);
282 if (currentAxes.size() > 1) {
284 IP3Ds_1.push_back(IP3Dsig < -50. ? -50. : IP3Dsig);
286 IP3Ds_2.push_back(IP3Dsig < -50. ? -50. : IP3Dsig);
288 IP3Ds_1.push_back(IP3Dsig < -50. ? -50. : IP3Dsig);
293 bool charmThreshSet =
false;
296 for (
size_t i = 0;
i < indices.size(); ++
i) {
297 size_t idx = indices[
i];
304 && !charmThreshSet) {
307 charmThreshSet =
true;
313 if ((
i + 1) < indices.size())
314 trackSip2dSigAboveBottom_1 = (ipData[indices[
i + 1]]).ip2d.significance();
320 float dummyTrack = -50.;
322 std::sort(IP3Ds.begin(), IP3Ds.end(), std::greater<float>());
323 std::sort(IP3Ds_1.begin(), IP3Ds_1.end(), std::greater<float>());
324 std::sort(IP3Ds_2.begin(), IP3Ds_2.end(), std::greater<float>());
325 int num_1 = IP3Ds_1.size();
326 int num_2 = IP3Ds_2.size();
331 trackSip3dSig_0 = dummyTrack;
332 trackSip3dSig_1 = dummyTrack;
333 trackSip3dSig_2 = dummyTrack;
334 trackSip3dSig_3 = dummyTrack;
340 trackSip3dSig_0 = IP3Ds.at(0);
341 trackSip3dSig_1 = dummyTrack;
342 trackSip3dSig_2 = dummyTrack;
343 trackSip3dSig_3 = dummyTrack;
349 trackSip3dSig_0 = IP3Ds.at(0);
350 trackSip3dSig_1 = IP3Ds.at(1);
351 trackSip3dSig_2 = dummyTrack;
352 trackSip3dSig_3 = dummyTrack;
358 trackSip3dSig_0 = IP3Ds.at(0);
359 trackSip3dSig_1 = IP3Ds.at(1);
360 trackSip3dSig_2 = IP3Ds.at(2);
361 trackSip3dSig_3 = dummyTrack;
367 trackSip3dSig_0 = IP3Ds.at(0);
368 trackSip3dSig_1 = IP3Ds.at(1);
369 trackSip3dSig_2 = IP3Ds.at(2);
370 trackSip3dSig_3 = IP3Ds.at(3);
376 tau1_trackSip3dSig_0 = dummyTrack;
377 tau1_trackSip3dSig_1 = dummyTrack;
383 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
384 tau1_trackSip3dSig_1 = dummyTrack;
390 tau1_trackSip3dSig_0 = IP3Ds_1.at(0);
391 tau1_trackSip3dSig_1 = IP3Ds_1.at(1);
397 tau2_trackSip3dSig_0 = dummyTrack;
398 tau2_trackSip3dSig_1 = dummyTrack;
403 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
404 tau2_trackSip3dSig_1 = dummyTrack;
410 tau2_trackSip3dSig_0 = IP3Ds_2.at(0);
411 tau2_trackSip3dSig_1 = IP3Ds_2.at(1);
417 std::vector<float> tau1_trackEtaRels, tau2_trackEtaRels;
419 std::map<double, size_t> VTXmap;
420 for (
size_t vtx = 0; vtx < svTagInfo.
nVertices(); ++vtx) {
425 if (currentAxes.size() > 1) {
428 tau2Kinematics = tau2Kinematics + vertexKinematic;
429 if (tau2_flightDistance2dSig < 0) {
434 tau2_nSecondaryVertices += 1.;
436 tau1Kinematics = tau1Kinematics + vertexKinematic;
437 if (tau1_flightDistance2dSig < 0) {
442 tau1_nSecondaryVertices += 1.;
445 }
else if (!currentAxes.empty()) {
446 tau1Kinematics = tau1Kinematics + vertexKinematic;
447 if (tau1_flightDistance2dSig < 0) {
452 tau1_nSecondaryVertices += 1.;
462 if (tau1_nSecondaryVertices > 0.) {
465 tau1_vertexEnergyRatio = tau1_vertexSum.E() / allSum.E();
466 if (tau1_vertexEnergyRatio > 50.)
467 tau1_vertexEnergyRatio = 50.;
469 tau1_vertexMass = tau1_vertexSum.M();
472 if (tau2_nSecondaryVertices > 0.) {
475 tau2_vertexEnergyRatio = tau2_vertexSum.E() / allSum.E();
476 if (tau2_vertexEnergyRatio > 50.)
477 tau2_vertexEnergyRatio = 50.;
479 tau2_vertexMass = tau2_vertexSum.M();
482 float dummyEtaRel = -1.;
484 std::sort(tau1_trackEtaRels.begin(), tau1_trackEtaRels.end());
485 std::sort(tau2_trackEtaRels.begin(), tau2_trackEtaRels.end());
487 switch (tau2_trackEtaRels.size()) {
490 tau2_trackEtaRel_0 = dummyEtaRel;
491 tau2_trackEtaRel_1 = dummyEtaRel;
492 tau2_trackEtaRel_2 = dummyEtaRel;
498 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
499 tau2_trackEtaRel_1 = dummyEtaRel;
500 tau2_trackEtaRel_2 = dummyEtaRel;
506 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
507 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
508 tau2_trackEtaRel_2 = dummyEtaRel;
514 tau2_trackEtaRel_0 = tau2_trackEtaRels.at(0);
515 tau2_trackEtaRel_1 = tau2_trackEtaRels.at(1);
516 tau2_trackEtaRel_2 = tau2_trackEtaRels.at(2);
519 switch (tau1_trackEtaRels.size()) {
522 tau1_trackEtaRel_0 = dummyEtaRel;
523 tau1_trackEtaRel_1 = dummyEtaRel;
524 tau1_trackEtaRel_2 = dummyEtaRel;
530 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
531 tau1_trackEtaRel_1 = dummyEtaRel;
532 tau1_trackEtaRel_2 = dummyEtaRel;
538 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
539 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
540 tau1_trackEtaRel_2 = dummyEtaRel;
546 tau1_trackEtaRel_0 = tau1_trackEtaRels.at(0);
547 tau1_trackEtaRel_1 = tau1_trackEtaRels.at(1);
548 tau1_trackEtaRel_2 = tau1_trackEtaRels.at(2);
556 for (std::map<double, size_t>::iterator iVtx = VTXmap.begin(); iVtx != VTXmap.end(); ++iVtx) {
561 SV_p4_0 = vertex.
p4();
562 vtxMass = SV_p4_0.mass();
565 z_ratio =
reco::deltaR(currentAxes[1], currentAxes[0]) * SV_p4_0.pt() / vtxMass;
569 SV_p4_1 = vertex.
p4();
570 vtxMass = (SV_p4_1 + SV_p4_0).
mass();
573 z_ratio =
reco::deltaR(flightDir_0, flightDir_1) * SV_p4_1.pt() / vtxMass;
581 if ((tau1_vertexMass < 0 && tau2_vertexMass > 0)) {
584 tau2_trackEtaRel_0 =
temp;
588 tau2_trackEtaRel_1 =
temp;
592 tau2_trackEtaRel_2 =
temp;
596 tau2_flightDistance2dSig =
temp;
602 tau2_vertexEnergyRatio =
temp;
606 tau2_vertexMass =
temp;
642 vars,
edm::Ref<std::vector<reco::CandSecondaryVertexTagInfo>>(svTagInfos, iterTI - svTagInfos->begin())));
652 std::vector<fastjet::PseudoJet>& currentAxes)
const {
653 std::vector<fastjet::PseudoJet> fjParticles;
657 if (daughter.isNonnull() && daughter.isAvailable()) {
662 for (
size_t i = 0;
i < daughter->numberOfDaughters(); ++
i) {
667 float valcheck = constit->px() + constit->py() + constit->pz() + constit->energy();
670 <<
"Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
679 <<
"BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection"
682 fjParticles.push_back(
683 fastjet::PseudoJet(constit->px() *
w, constit->py() *
w, constit->pz() *
w, constit->energy() *
w));
685 fjParticles.push_back(fastjet::PseudoJet(constit->px(), constit->py(), constit->pz(), constit->energy()));
688 <<
"Jet constituent required for N-subjettiness computation is missing!";
692 float valcheck = daughter->px() + daughter->py() + daughter->pz() + daughter->energy();
695 <<
"Jet constituent required for N-subjettiness computation contains Nan/Inf values!";
698 if (jet->isWeighted()) {
704 <<
"BoostedDoubleSVProducer: No weights (e.g. PUPPI) given for weighted jet collection" << std::endl;
706 fjParticles.push_back(
707 fastjet::PseudoJet(daughter->px() *
w, daughter->py() *
w, daughter->pz() *
w, daughter->energy() *
w));
709 fjParticles.push_back(fastjet::PseudoJet(daughter->px(), daughter->py(), daughter->pz(), daughter->energy()));
712 edm::LogWarning(
"MissingJetConstituent") <<
"Jet constituent required for N-subjettiness computation is missing!";
717 fastjet::contrib::NormalizedMeasure(
beta_,
R0_));
720 tau1 = njettiness.getTau(1, fjParticles);
721 tau2 = njettiness.getTau(2, fjParticles);
722 currentAxes = njettiness.currentAxes();
727 float& PVweight)
const {
739 if (baseRef == trackBaseRef) {
748 float& PVweight)
const {
766 const fastjet::PseudoJet& tauAxis,
767 std::vector<float>& tau_trackEtaRel)
const {
771 for (std::vector<reco::CandidatePtr>::const_iterator
track = tracks.begin();
track != tracks.end(); ++
track)
784 desc.
add<
double>(
"beta", 1.0);
785 desc.
add<
double>(
"R0", 0.8);
786 desc.
add<
double>(
"maxSVDeltaRToJet", 0.7);
794 trackPairV0Filter.
add<
double>(
"k0sMassWindow", 0.03);
static constexpr float charmThreshold
static constexpr float dummyTrackSip2dSigAbove
reco::Vertex::Point convertPos(const GlobalPoint &p)
const edm::EDGetTokenT< std::vector< reco::CandSecondaryVertexTagInfo > > svTagInfos_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const math::XYZTLorentzVector & weightedVectorSum() const
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_
tuple cont
load Luminosity info ##
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
void setAllowAnything()
allow any parameter label/value pairs
constexpr bool isNotFinite(T x)
#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)
constexpr bool isUninitialized() const noexcept
Global3DPoint GlobalPoint
GlobalPoint globalPosition() const
const Container & selectedTracks() const
static constexpr float dummyTrackEtaRel
const MagneticField * field() const
auto const & tracks
cannot be loose
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
const LorentzVector & p4() const final
four-momentum Lorentz vector
virtual const daughters & daughterPtrVector() const
references to daughtes
const edm::Ref< VertexCollection > & primaryVertex() const
reco::TemplatedSecondaryVertexTagInfo< reco::CandIPTagInfo, reco::VertexCompositePtrCandidate > CandSecondaryVertexTagInfo
~BoostedDoubleSVProducer() override
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
void addDefault(ParameterSetDescription const &psetDescription)
static constexpr float dummyTrackSip3dSig
edm::Handle< edm::ValueMap< float > > weightsHandle_
void beginStream(edm::StreamID) override
const PVAssoc fromPV(size_t ipv=0) const
static constexpr float dummyFlightDistance2dSig
Abs< T >::type abs(const T &t)
trackRef_iterator tracks_end() const
last iterator over tracks
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
static constexpr float dummyVertexEnergyRatio
std::vector< LinkConnSpec >::const_iterator IT
trackRef_iterator tracks_begin() const
first iterator over tracks
ParameterDescriptionBase * add(U const &iLabel, T const &value)
std::vector< size_t > sortedIndexes(btag::SortCriteria mode=reco::btag::IP3DSig) const
const GlobalVector & flightDirection(unsigned int index) const
virtual int isWeighted() const
boolean if weights were applied by algorithm (e.g. PUPPI weights)
bool isNonnull() const
Checks for non-null.
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
const std::vector< btag::TrackIPData > & impactParameterData() const
unsigned int nVertices() const
size_t numberOfDaughters() const override
number of daughters
static constexpr float bottomThreshold
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
double significance() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
virtual CandidatePtr daughterPtr(size_type i) const
reference to daughter at given position
T getParameter(std::string const &) const
edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > trackBuilderToken_
bool isSelected(const std::vector< L1HPSPFTauQualityCut > &qualityCuts, const l1t::PFCandidate &pfCand, float_t primaryVertexZ)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
static constexpr float dummyZ_ratio
Particle reconstructed by the particle flow algorithm.
static constexpr float dummyVertexMass
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
edm::RefToBase< Jet > jet(void) const override
returns a polymorphic reference to the tagged jet
BoostedDoubleSVProducer(const edm::ParameterSet &)
void endStream() override
TrajectoryStateOnSurface impactPointState() const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Log< level::Warning, false > LogWarning
static constexpr float dummyVertexDeltaR
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
edm::EDGetTokenT< edm::ValueMap< float > > weightsToken_
Global3DVector GlobalVector
void insert(const TaggingVariable &variable, bool delayed=false)
tuple trackSelector
Tracks selection.