5 #include "fastjet/ClusterSequence.hh"
15 #include "fastjet/JetDefinition.hh"
26 bool isBHadron(
const unsigned int pdgId)
const;
32 std::auto_ptr<reco::GenParticleCollection>& outColl)
const;
46 typedef fastjet::JetDefinition
JetDef;
58 minLeptonPt_(pset.getParameter<double>(
"minLeptonPt")),
59 maxLeptonEta_(pset.getParameter<double>(
"maxLeptonEta")),
60 minJetPt_(pset.getParameter<double>(
"minJetPt")),
61 maxJetEta_(pset.getParameter<double>(
"maxJetEta")),
62 wMass_(pset.getParameter<double>(
"wMass")),
63 tMass_(pset.getParameter<double>(
"tMass")),
64 minLeptonPtDilepton_(pset.getParameter<double>(
"minLeptonPtDilepton")),
65 maxLeptonEtaDilepton_(pset.getParameter<double>(
"maxLeptonEtaDilepton")),
66 minDileptonMassDilepton_(pset.getParameter<double>(
"minDileptonMassDilepton")),
67 minLeptonPtSemilepton_(pset.getParameter<double>(
"minLeptonPtSemilepton")),
68 maxLeptonEtaSemilepton_(pset.getParameter<double>(
"maxLeptonEtaSemilepton")),
69 minVetoLeptonPtSemilepton_(pset.getParameter<double>(
"minVetoLeptonPtSemilepton")),
70 maxVetoLeptonEtaSemilepton_(pset.getParameter<double>(
"maxVetoLeptonEtaSemilepton")),
71 minMETSemiLepton_(pset.getParameter<double>(
"minMETSemiLepton")),
72 minMtWSemiLepton_(pset.getParameter<double>(
"minMtWSemiLepton")) {
73 const double leptonConeSize = pset.
getParameter<
double>(
"leptonConeSize");
74 const double jetConeSize = pset.
getParameter<
double>(
"jetConeSize");
75 fjLepDef_ = std::make_shared<JetDef>(fastjet::antikt_algorithm, leptonConeSize);
76 fjJetDef_ = std::make_shared<JetDef>(fastjet::antikt_algorithm, jetConeSize);
80 produces<reco::GenParticleCollection>(
"neutrinos");
81 produces<reco::GenJetCollection>(
"leptons");
82 produces<reco::GenJetCollection>(
"jets");
84 produces<reco::GenParticleCollection>();
105 std::set<int> bHadronIdxs;
106 for (
size_t i = 0,
n = genParticleHandle->size();
i <
n; ++
i) {
114 bHadronIdxs.insert(-
i - 1);
119 std::vector<size_t> leptonIdxs;
120 for (
size_t i = 0, n = finalStateHandle->size();
i <
n; ++
i) {
122 const int absPdgId =
abs(p.
pdgId());
137 leptonIdxs.push_back(
i);
152 std::vector<fastjet::PseudoJet> fjLepInputs;
153 fjLepInputs.reserve(leptonIdxs.size());
154 for (
auto index : leptonIdxs) {
159 fjLepInputs.push_back(fastjet::PseudoJet(p.
px(), p.
py(), p.
pz(), p.
energy()));
160 fjLepInputs.back().set_user_index(
index);
164 fastjet::ClusterSequence fjLepClusterSeq(fjLepInputs, *
fjLepDef_);
165 std::vector<fastjet::PseudoJet> fjLepJets = fastjet::sorted_by_pt(fjLepClusterSeq.inclusive_jets(
minLeptonPt_));
168 leptons->reserve(fjLepJets.size());
169 std::set<size_t> lepDauIdxs;
170 for (
auto& fjJet : fjLepJets) {
175 const std::vector<fastjet::PseudoJet> fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
177 std::vector<reco::CandidatePtr> constituents;
179 for (
auto& fjConstituent : fjConstituents) {
180 const size_t index = fjConstituent.user_index();
182 const int absPdgId =
abs(cand->pdgId());
183 if (absPdgId == 11
or absPdgId == 13) {
184 if (lepCand.
isNonnull() and lepCand->pt() > cand->pt())
188 constituents.push_back(cand);
193 const LorentzVector jetP4(fjJet.px(), fjJet.py(), fjJet.pz(), fjJet.E());
197 lepJet.setPdgId(lepCand->pdgId());
198 lepJet.setCharge(lepCand->charge());
200 const double jetArea = fjJet.has_area() ? fjJet.area() : 0;
201 lepJet.setJetArea(jetArea);
203 leptons->push_back(lepJet);
206 for (
auto& fjConstituent : fjConstituents) {
207 lepDauIdxs.insert(fjConstituent.user_index());
214 std::vector<fastjet::PseudoJet> fjJetInputs;
215 fjJetInputs.reserve(nStables);
216 for (
size_t i = 0, n = finalStateHandle->size();
i <
n; ++
i) {
224 if (absId == 12
or absId == 14
or absId == 16)
226 if (lepDauIdxs.find(
i) != lepDauIdxs.end())
229 fjJetInputs.push_back(fastjet::PseudoJet(p.
px(), p.
py(), p.
pz(), p.
energy()));
230 fjJetInputs.back().set_user_index(
i);
233 for (
auto index : bHadronIdxs) {
238 const double scale = 1
e-20 / p.
p();
240 fjJetInputs.back().set_user_index(
index);
244 fastjet::ClusterSequence fjJetClusterSeq(fjJetInputs, *
fjJetDef_);
245 std::vector<fastjet::PseudoJet> fjJets = fastjet::sorted_by_pt(fjJetClusterSeq.inclusive_jets(
minJetPt_));
248 jets->reserve(fjJets.size());
249 std::vector<size_t> bjetIdxs, ljetIdxs;
250 for (
auto& fjJet : fjJets) {
255 const std::vector<fastjet::PseudoJet> fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
257 std::vector<reco::CandidatePtr> constituents;
258 bool hasBHadron =
false;
259 for (
size_t j = 0,
m = fjConstituents.size();
j <
m; ++
j) {
260 const int index = fjConstituents[
j].user_index();
261 if (bHadronIdxs.find(index) != bHadronIdxs.end()) {
266 constituents.push_back(cand);
269 const LorentzVector jetP4(fjJet.px(), fjJet.py(), fjJet.pz(), fjJet.E());
273 const double jetArea = fjJet.has_area() ? fjJet.area() : 0;
274 genJet.setJetArea(jetArea);
277 bjetIdxs.push_back(jets->size());
279 ljetIdxs.push_back(jets->size());
282 jets->push_back(genJet);
288 if (bjetIdxs.size() < 2)
292 if (leptons->size() == 2 and neutrinos->size() >= 2) {
294 const int q1 = leptons->at(0).charge();
295 const int q2 = leptons->at(1).charge();
299 const auto& lepton1 = q1 > 0 ? leptons->at(0) : leptons->at(1);
300 const auto& lepton2 = q1 > 0 ? leptons->at(1) : leptons->at(0);
310 int selNu1 = -1, selNu2 = -1;
311 for (
int i = 0;
i < 2; ++
i) {
313 for (
int j = 0;
j < 2; ++
j) {
317 const double newDm = dm1 + dm2;
329 const auto& nu1 = neutrinos->at(selNu1);
330 const auto& nu2 = neutrinos->at(selNu2);
331 const auto w1LVec = lepton1.p4() + nu1.p4();
332 const auto w2LVec = lepton2.p4() + nu2.p4();
336 int selB1 = -1, selB2 = -1;
337 for (
auto i : bjetIdxs) {
339 for (
auto j : bjetIdxs) {
343 const double newDm = dm1 + dm2;
355 const auto&
bJet1 = jets->at(selB1);
356 const auto&
bJet2 = jets->at(selB2);
357 const auto t1LVec = w1LVec +
bJet1.p4();
358 const auto t2LVec = w2LVec +
bJet2.p4();
361 const int lepQ1 = lepton1.charge();
362 const int lepQ2 = lepton2.charge();
377 pseudoTop->push_back(t1);
378 pseudoTop->push_back(t2);
380 pseudoTop->push_back(w1);
381 pseudoTop->push_back(
b1);
382 pseudoTop->push_back(l1);
383 pseudoTop->push_back(n1);
385 pseudoTop->push_back(w2);
386 pseudoTop->push_back(
b2);
387 pseudoTop->push_back(l2);
388 pseudoTop->push_back(n2);
389 }
else if (!leptons->empty() and !neutrinos->empty() and ljetIdxs.size() >= 2) {
391 const auto& lepton = leptons->at(0);
396 bool hasVetoLepton =
false;
397 for (
auto vetoLeptonItr =
next(leptons->begin()); vetoLeptonItr != leptons->end(); ++vetoLeptonItr) {
400 hasVetoLepton =
true;
407 double metX = 0, metY = 0;
408 for (
const auto& neutrino : *neutrinos) {
409 metX += neutrino.
px();
410 metY += neutrino.py();
412 const double metPt = std::hypot(metX, metY);
416 const double mtW =
std::sqrt(2 * lepton.pt() * metPt *
cos(lepton.phi() - atan2(metX, metY)));
426 const double lpz = lepton.pz(), le = lepton.energy(), lpt = lepton.pt();
427 const double cf = (
wMass_ *
wMass_) / 2 + lepton.px() * metX + lepton.py() * metY;
428 const double det = cf * cf * lpz * lpz - lpt * lpt * (le * le * metPt * metPt - cf * cf);
429 const double pz = (cf * lpz + (cf < 0 ? -
sqrt(det) :
sqrt(det))) / lpt / lpt;
431 const auto w1LVec = lepton.p4() + nu1P4;
436 for (
auto b1Itr = bjetIdxs.begin(); b1Itr != bjetIdxs.end(); ++b1Itr) {
437 const double dR =
deltaR(jets->at(*b1Itr).p4(), w1LVec);
445 const auto&
bJet1 = jets->at(selB1);
446 const auto t1LVec = w1LVec +
bJet1.p4();
449 const auto& wJet1 = jets->at(ljetIdxs[0]);
450 const auto& wJet2 = jets->at(ljetIdxs[1]);
451 const auto w2LVec = wJet1.p4() + wJet2.p4();
456 for (
auto i : bjetIdxs) {
468 const auto&
bJet2 = jets->at(selB2);
469 const auto t2LVec = w2LVec +
bJet2.p4();
471 const int q = lepton.charge();
485 pseudoTop->push_back(t1);
486 pseudoTop->push_back(t2);
488 pseudoTop->push_back(w1);
489 pseudoTop->push_back(
b1);
490 pseudoTop->push_back(l1);
491 pseudoTop->push_back(n1);
493 pseudoTop->push_back(w2);
494 pseudoTop->push_back(
b2);
495 pseudoTop->push_back(
u2);
496 pseudoTop->push_back(d2);
500 if (pseudoTop->size() == 10)
527 event.put(
std::move(neutrinos),
"neutrinos");
528 event.put(
std::move(leptons),
"leptons");
550 const int pdgId =
abs(mother->
pdgId());
561 const unsigned int absPdgId =
abs(p->
pdgId());
579 if (absPdgId >= 1000000000)
585 const int nq3 = (absPdgId / 10) % 10;
586 const int nq2 = (absPdgId / 100) % 10;
587 const int nq1 = (absPdgId / 1000) % 10;
591 if (nq1 == 0 and nq2 == 5)
601 std::auto_ptr<reco::GenParticleCollection>& outColl)
const {
608 outColl->push_back(pOut);
const edm::EDGetTokenT< edm::View< reco::Candidate > > genParticleToken_
bool isBHadron(const reco::Candidate *p) const
PseudoTopProducer(const edm::ParameterSet &pset)
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
reco::Particle::Point genVertex_
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 double maxLeptonEtaSemilepton_
common ppss p3p6s2 common epss epspn46 common const1 w2
tuple bJet1
do the razor with one or two b jets (medium CSV)
const double maxLeptonEta_
const double minVetoLeptonPtSemilepton_
fastjet::JetDefinition JetDef
virtual const Candidate * mother(size_type i=0) const =0
return pointer to mother
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
const double maxLeptonEtaDilepton_
virtual double pt() const =0
transverse momentum
#define DEFINE_FWK_MODULE(type)
std::shared_ptr< JetDef > fjJetDef_
virtual int status() const =0
status word
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
std::vector< GenJet > GenJetCollection
collection of GenJet objects
virtual double pz() const =0
z coordinate of momentum vector
virtual size_type numberOfMothers() const =0
number of mothers (zero or one in most of but not all the cases)
bool isFromHadron(const reco::Candidate *p) const
void writeSpecific(reco::CaloJet &jet, reco::Particle::LorentzVector const &p4, reco::Particle::Point const &point, std::vector< reco::CandidatePtr > const &constituents, CaloGeometry const &geometry, HcalTopology const &topology)
std::shared_ptr< JetDef > fjLepDef_
const double minMtWSemiLepton_
const double minMETSemiLepton_
reco::Particle::LorentzVector LorentzVector
void clearDaughters()
clear daughter references
void addDaughter(const typename daughters::value_type &)
add a daughter via a reference
void resetDaughters(const edm::ProductID &id)
set daughters product ID
const double minLeptonPtSemilepton_
virtual size_type numberOfDaughters() const =0
number of daughters
virtual double p() const =0
magnitude of momentum vector
double px() const final
x coordinate of momentum vector
const reco::Candidate * getLast(const reco::Candidate *p)
Cos< T >::type cos(const T &t)
void produce(edm::Event &event, const edm::EventSetup &eventSetup) override
bool isNull() const
Checks for null.
math::XYZPoint Point
point in the space
Abs< T >::type abs(const T &t)
Jets made from MC generator particles.
virtual const Point & vertex() const =0
vertex position
virtual int charge() const =0
electric charge
virtual double py() const =0
y coordinate of momentum vector
void insertAllDaughters(const reco::Candidate *p, std::set< const reco::Candidate * > &list) const
bool isNonnull() const
Checks for non-null.
virtual double px() const =0
x coordinate of momentum vector
virtual int pdgId() const =0
PDG identifier.
reco::GenParticleRef buildGenParticle(const reco::Candidate *p, reco::GenParticleRefProd &refHandle, std::auto_ptr< reco::GenParticleCollection > &outColl) const
T getParameter(std::string const &) const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
const double maxVetoLeptonEtaSemilepton_
const double minLeptonPt_
ProductID id() const
Accessor for product ID.
const double minDileptonMassDilepton_
static constexpr float b2
void resetMothers(const edm::ProductID &id)
set mother product ID
const edm::EDGetTokenT< edm::View< reco::Candidate > > finalStateToken_
const double minLeptonPtDilepton_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
void clearMothers()
clear mother references
static constexpr float b1
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector