6 #include "fastjet/ClusterSequence.hh"
13 leptonMinPt_(pset.getParameter<double>(
"leptonMinPt")),
14 leptonMaxEta_(pset.getParameter<double>(
"leptonMaxEta")),
15 jetMinPt_(pset.getParameter<double>(
"jetMinPt")),
16 jetMaxEta_(pset.getParameter<double>(
"jetMaxEta")),
17 wMass_(pset.getParameter<double>(
"wMass")),
18 tMass_(pset.getParameter<double>(
"tMass"))
23 const double leptonConeSize = pset.
getParameter<
double>(
"leptonConeSize");
24 const double jetConeSize = pset.
getParameter<
double>(
"jetConeSize");
25 fjLepDef_ = std::shared_ptr<JetDef>(
new JetDef(fastjet::antikt_algorithm, leptonConeSize));
26 fjJetDef_ = std::shared_ptr<JetDef>(
new JetDef(fastjet::antikt_algorithm, jetConeSize));
30 produces<reco::GenParticleCollection>(
"neutrinos");
31 produces<reco::GenJetCollection>(
"leptons");
32 produces<reco::GenJetCollection>(
"jets");
34 produces<reco::GenParticleCollection>();
57 std::set<int> bHadronIdxs;
58 for (
size_t i=0,
n=genParticleHandle->size();
i<
n; ++
i )
62 if ( status == 1 )
continue;
70 std::vector<size_t> leptonIdxs;
71 std::set<size_t> neutrinoIdxs;
72 for (
size_t i=0, n=finalStateHandle->size();
i<
n; ++
i )
76 if ( p.
status() != 1 )
continue;
86 leptonIdxs.push_back(
i);
88 case 12:
case 14:
case 16:
89 neutrinoIdxs.insert(
i);
100 std::vector<fastjet::PseudoJet> fjLepInputs;
101 fjLepInputs.reserve(leptonIdxs.size());
102 for (
auto index : leptonIdxs )
107 fjLepInputs.push_back(fastjet::PseudoJet(p.
px(), p.
py(), p.
pz(), p.
energy()));
108 fjLepInputs.back().set_user_index(
index);
112 fastjet::ClusterSequence fjLepClusterSeq(fjLepInputs, *
fjLepDef_);
113 std::vector<fastjet::PseudoJet> fjLepJets = fastjet::sorted_by_pt(fjLepClusterSeq.inclusive_jets(
leptonMinPt_));
116 leptons->reserve(fjLepJets.size());
117 std::set<size_t> lepDauIdxs;
118 for (
auto& fjJet : fjLepJets )
123 const std::vector<fastjet::PseudoJet> fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
125 std::vector<reco::CandidatePtr> constituents;
127 for (
auto& fjConstituent : fjConstituents )
129 const size_t index = fjConstituent.user_index();
131 const int absPdgId =
abs(cand->pdgId());
132 if ( absPdgId == 11
or absPdgId == 13 )
134 if ( lepCand.
isNonnull() and lepCand->pt() > cand->pt() )
continue;
137 constituents.push_back(cand);
139 if ( lepCand.
isNull() )
continue;
140 if ( lepCand->pt() < fjJet.pt()/2 )
continue;
142 const LorentzVector jetP4(fjJet.px(), fjJet.py(), fjJet.pz(), fjJet.E());
146 lepJet.setPdgId(lepCand->pdgId());
147 lepJet.setCharge(lepCand->charge());
149 const double jetArea = fjJet.has_area() ? fjJet.area() : 0;
150 lepJet.setJetArea(jetArea);
152 leptons->push_back(lepJet);
155 for (
auto& fjConstituent : fjConstituents )
157 lepDauIdxs.insert(fjConstituent.user_index());
164 std::vector<fastjet::PseudoJet> fjJetInputs;
165 fjJetInputs.reserve(nStables);
166 for (
size_t i=0, n=finalStateHandle->size();
i<
n; ++
i )
169 if ( p.
status() != 1 )
continue;
172 if ( neutrinoIdxs.find(
i) != neutrinoIdxs.end() )
continue;
173 if ( lepDauIdxs.find(
i) != lepDauIdxs.end() )
continue;
175 fjJetInputs.push_back(fastjet::PseudoJet(p.
px(), p.
py(), p.
pz(), p.
energy()));
176 fjJetInputs.back().set_user_index(
i);
179 for (
auto index : bHadronIdxs )
184 const double scale = 1
e-20/p.
p();
186 fjJetInputs.back().set_user_index(
index);
190 fastjet::ClusterSequence fjJetClusterSeq(fjJetInputs, *
fjJetDef_);
191 std::vector<fastjet::PseudoJet> fjJets = fastjet::sorted_by_pt(fjJetClusterSeq.inclusive_jets(
jetMinPt_));
194 jets->reserve(fjJets.size());
195 std::vector<size_t> bjetIdxs, ljetIdxs;
196 for (
auto& fjJet : fjJets )
201 const std::vector<fastjet::PseudoJet> fjConstituents = fastjet::sorted_by_pt(fjJet.constituents());
203 std::vector<reco::CandidatePtr> constituents;
204 bool hasBHadron =
false;
205 for (
size_t j=0,
m=fjConstituents.size();
j<
m; ++
j )
207 const int index = fjConstituents[
j].user_index();
208 if ( bHadronIdxs.find(index) != bHadronIdxs.end() ) {
213 constituents.push_back(cand);
216 const LorentzVector jetP4(fjJet.px(), fjJet.py(), fjJet.pz(), fjJet.E());
220 const double jetArea = fjJet.has_area() ? fjJet.area() : 0;
221 genJet.setJetArea(jetArea);
225 bjetIdxs.push_back(jets->size());
229 ljetIdxs.push_back(jets->size());
232 jets->push_back(genJet);
240 const size_t nLepton = leptons->size();
243 std::vector<std::pair<int, int> > wCandIdxs;
244 for (
auto lep = leptons->begin(); lep != leptons->end(); ++lep )
246 const size_t iLep = lep-leptons->begin();
247 for (
auto nu = neutrinos->begin(); nu != neutrinos->end(); ++nu )
250 const double m = (lep->p4()+nu->p4()).
mass();
251 if ( m > 300 )
continue;
253 const size_t iNu = nu-neutrinos->begin();
254 wCandIdxs.push_back(make_pair(iLep, iNu));
258 if ( nLepton == 0
or wCandIdxs.empty() )
break;
259 else if ( nLepton == 1 and wCandIdxs.size() >= 1 )
262 int bestLepIdx = -1, bestNuIdx = -1;
263 for (
auto wCandIdx : wCandIdxs )
265 const int lepIdx = wCandIdx.first;
266 const int nuIdx = wCandIdx.second;
269 const double mW = (lepLVec + nuLVec).
mass();
270 if ( mW > 300 )
continue;
280 if ( bestLepIdx < 0 )
break;
281 const auto& lepton = leptons->at(bestLepIdx);
282 const auto& neutrino = neutrinos->at(bestNuIdx);
288 int bestJ1Idx = -1, bestJ2Idx = -1;
289 for (
auto j1Idx = ljetIdxs.begin(); j1Idx != ljetIdxs.end(); ++j1Idx )
291 const auto& j1 = jets->at(*j1Idx);
292 for (
auto j2Idx = j1Idx+1; j2Idx != ljetIdxs.end(); ++j2Idx )
294 const auto& j2 = jets->at(*j2Idx);
295 const double mW = (j1.p4()+j2.p4()).
mass();
296 if ( mW > 300 )
continue;
307 if ( bestJ1Idx < 0 )
break;
308 const auto& wJet1 = jets->at(bestJ1Idx);
309 const auto& wJet2 = jets->at(bestJ2Idx);
315 int bestB1Idx = -1, bestB2Idx = -1;
316 if ( bjetIdxs.size() < 2 )
break;
317 for (
auto b1Idx : bjetIdxs )
319 const double t1Mass = (w1LVec + jets->at(b1Idx).p4()).
mass();
320 if ( t1Mass > 300 )
continue;
321 for (
auto b2Idx : bjetIdxs )
323 if ( b1Idx == b2Idx )
continue;
324 const double t2Mass = (w2LVec + jets->at(b2Idx).p4()).
mass();
325 if ( t2Mass > 300 )
continue;
336 if ( bestB1Idx < 0 )
break;
337 const auto&
bJet1 = jets->at(bestB1Idx);
338 const auto&
bJet2 = jets->at(bestB2Idx);
345 const int lepQ = lepton.charge();
359 pseudoTop->push_back(t1);
360 pseudoTop->push_back(w1);
361 pseudoTop->push_back(b1);
362 pseudoTop->push_back(l1);
363 pseudoTop->push_back(n1);
365 pseudoTop->push_back(t2);
366 pseudoTop->push_back(w2);
367 pseudoTop->push_back(b2);
368 pseudoTop->push_back(qA);
369 pseudoTop->push_back(qB);
372 else if ( nLepton == 2 and wCandIdxs.size() >= 2 )
375 int bestLep1Idx = -1, bestLep2Idx = -1, bestNu1Idx = -1, bestNu2Idx = -1;
376 for (
auto i : wCandIdxs )
378 const auto& lepton1 = leptons->at(
i.first);
379 if ( lepton1.charge() < 0 )
continue;
380 const auto& neutrino1 = neutrinos->at(
i.second);
381 const double mW1 = (lepton1.p4()+neutrino1.p4()).
mass();
382 if ( mW1 > 300 )
continue;
383 for (
auto j : wCandIdxs )
385 if (
i ==
j )
continue;
386 const auto& lepton2 = leptons->at(
j.first);
387 if ( lepton2.charge() > 0 )
continue;
388 const auto& neutrino2 = neutrinos->at(
j.second);
389 const double mW2 = (lepton2.p4()+neutrino2.p4()).
mass();
390 if ( mW2 > 300 )
continue;
396 bestLep1Idx =
i.first;
397 bestLep2Idx =
j.first;
398 bestNu1Idx =
i.second;
399 bestNu2Idx =
j.second;
403 if ( bestLep1Idx < 0 )
break;
404 const auto& lepton1 = leptons->at(bestLep1Idx);
405 const auto& lepton2 = leptons->at(bestLep2Idx);
406 const auto& neutrino1 = neutrinos->at(bestNu1Idx);
407 const auto& neutrino2 = neutrinos->at(bestNu2Idx);
413 int bestB1Idx = -1, bestB2Idx = -1;
414 if ( bjetIdxs.size() < 2 )
break;
415 for (
auto b1Idx : bjetIdxs )
417 const double t1Mass = (w1LVec + jets->at(b1Idx).p4()).
mass();
418 if ( t1Mass > 300 )
continue;
419 for (
auto b2Idx : bjetIdxs )
421 if ( b1Idx == b2Idx )
continue;
422 const double t2Mass = (w2LVec + jets->at(b2Idx).p4()).
mass();
423 if ( t2Mass > 300 )
continue;
434 if ( bestB1Idx < 0 )
break;
435 const auto&
bJet1 = jets->at(bestB1Idx);
436 const auto&
bJet2 = jets->at(bestB2Idx);
443 const int lep1Q = lepton1.charge();
444 const int lep2Q = lepton2.charge();
458 pseudoTop->push_back(t1);
459 pseudoTop->push_back(w1);
460 pseudoTop->push_back(b1);
461 pseudoTop->push_back(l1);
462 pseudoTop->push_back(n1);
464 pseudoTop->push_back(t2);
465 pseudoTop->push_back(w2);
466 pseudoTop->push_back(b2);
467 pseudoTop->push_back(l2);
468 pseudoTop->push_back(n2);
472 if ( pseudoTop->size() == 10 )
500 event.put(neutrinos,
"neutrinos");
501 event.put(leptons,
"leptons");
502 event.put(jets,
"jets");
504 event.put(pseudoTop);
525 if ( pdgId > 100 )
return true;
533 const unsigned int absPdgId =
abs(p->
pdgId());
534 if ( !
isBHadron(absPdgId) )
return false;
549 if ( absPdgId <= 100 )
return false;
550 if ( absPdgId >= 1000000000 )
return false;
555 const int nq3 = (absPdgId / 10) % 10;
556 const int nq2 = (absPdgId / 100) % 10;
557 const int nq1 = (absPdgId / 1000) % 10;
559 if ( nq3 == 0 )
return false;
560 if ( nq1 == 0 and nq2 == 5 )
return true;
561 if ( nq1 == 5 )
return true;
567 std::auto_ptr<reco::GenParticleCollection>& outColl)
const
575 outColl->push_back(pOut);
bool isBHadron(const reco::Candidate *p) const
PseudoTopProducer(const edm::ParameterSet &pset)
const double leptonMaxEta_
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
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 leptonMinPt_
common ppss p3p6s2 common epss epspn46 common const1 w2
edm::EDGetTokenT< edm::View< reco::Candidate > > finalStateToken_
tuple bJet1
do the razor with one or two b jets (medium CSV)
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
virtual double pt() const =0
transverse momentum
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
std::shared_ptr< JetDef > fjLepDef_
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
virtual size_type numberOfDaughters() const =0
number of daughters
virtual double p() const =0
magnitude of momentum vector
auto const T2 &decltype(t1.eta()) t2
const reco::Candidate * getLast(const reco::Candidate *p)
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
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
edm::EDGetTokenT< edm::View< reco::Candidate > > genParticleToken_
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
ProductID id() const
Accessor for product ID.
void resetMothers(const edm::ProductID &id)
set mother product ID
void clearMothers()
clear mother references
void writeSpecific(reco::CaloJet &jet, reco::Particle::LorentzVector const &p4, reco::Particle::Point const &point, std::vector< reco::CandidatePtr > const &constituents, edm::EventSetup const &c)
virtual const LorentzVector & p4() const =0
four-momentum Lorentz vector