8 : jetsToken_(consumes<std::
vector<pat::
Jet> >(cfg.getParameter<edm::
InputTag>(
"jets"))),
9 lepsToken_(consumes<edm::
View<
reco::RecoCandidate> >(cfg.getParameter<edm::
InputTag>(
"leps"))),
10 maxNJets_(cfg.getParameter<int>(
"maxNJets")),
11 wMass_(cfg.getParameter<double>(
"wMass")),
12 useBTagging_(cfg.getParameter<bool>(
"useBTagging")),
13 bTagAlgorithm_(cfg.getParameter<std::
string>(
"bTagAlgorithm")),
14 minBDiscBJets_(cfg.getParameter<double>(
"minBDiscBJets")),
15 maxBDiscLightJets_(cfg.getParameter<double>(
"maxBDiscLightJets")) {
18 <<
"It has to be larger than 4 or can be set to -1 to take all jets.";
20 produces<std::vector<std::vector<int> > >();
21 produces<int>(
"NumberOfConsideredJets");
27 std::unique_ptr<std::vector<std::vector<int> > > pOut(
new std::vector<std::vector<int> >);
28 std::unique_ptr<int> pJetsConsidered(
new int);
30 std::vector<int>
match;
31 for (
unsigned int i = 0;
i < 4; ++
i)
43 if (leps->empty() || jets->size() < 4) {
44 pOut->push_back(match);
46 *pJetsConsidered = jets->size();
47 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
53 maxNJets = jets->size();
54 *pJetsConsidered = maxNJets;
55 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
57 std::vector<bool> isBJet;
58 std::vector<bool> isLJet;
61 for (
unsigned int idx = 0; idx < maxNJets; ++idx) {
74 std::vector<int> maxPtIndices;
75 maxPtIndices.push_back(-1);
76 maxPtIndices.push_back(-1);
77 maxPtIndices.push_back(-1);
78 for (
unsigned idx = 0; idx < maxNJets; ++idx) {
79 if (
useBTagging_ && (!isLJet[idx] || (cntBJets <= 2 && isBJet[idx])))
81 for (
unsigned jdx = (idx + 1); jdx < maxNJets; ++jdx) {
82 if (jdx == idx || (
useBTagging_ && (!isLJet[jdx] || (cntBJets <= 2 && isBJet[jdx]) ||
83 (cntBJets == 3 && isBJet[idx] && isBJet[jdx]))))
85 for (
unsigned kdx = 0; kdx < maxNJets; ++kdx) {
86 if (kdx == idx || kdx == jdx || (
useBTagging_ && !isBJet[kdx]))
89 if (maxPt < 0. || maxPt < sum.pt()) {
92 maxPtIndices.push_back(idx);
93 maxPtIndices.push_back(jdx);
94 maxPtIndices.push_back(kdx);
105 std::vector<int> closestToWMassIndices;
106 closestToWMassIndices.push_back(-1);
107 closestToWMassIndices.push_back(-1);
108 if (
isValid(maxPtIndices[0], jets) &&
isValid(maxPtIndices[1], jets) &&
isValid(maxPtIndices[2], jets)) {
109 for (
unsigned idx = 0; idx < maxPtIndices.size(); ++idx) {
110 for (
unsigned jdx = 0; jdx < maxPtIndices.size(); ++jdx) {
111 if (jdx == idx || maxPtIndices[idx] > maxPtIndices[jdx] ||
113 (!isLJet[maxPtIndices[idx]] || !isLJet[maxPtIndices[jdx]] ||
114 (cntBJets <= 2 && isBJet[maxPtIndices[idx]]) || (cntBJets <= 2 && isBJet[maxPtIndices[jdx]]) ||
115 (cntBJets == 3 && isBJet[maxPtIndices[idx]] && isBJet[maxPtIndices[jdx]]))))
118 if (wDist < 0. || wDist > fabs(sum.mass() -
wMass_)) {
119 wDist = fabs(sum.mass() -
wMass_);
120 closestToWMassIndices.clear();
121 closestToWMassIndices.push_back(maxPtIndices[idx]);
122 closestToWMassIndices.push_back(maxPtIndices[jdx]);
128 for (
unsigned idx = 0; idx < maxPtIndices.size(); ++idx) {
130 if (
std::find(closestToWMassIndices.begin(), closestToWMassIndices.end(), maxPtIndices[idx]) ==
131 closestToWMassIndices.end()) {
132 hadB = maxPtIndices[idx];
144 for (
unsigned idx = 0; idx < maxNJets; ++idx) {
148 if (
std::find(maxPtIndices.begin(), maxPtIndices.end(), idx) == maxPtIndices.end()) {
150 if (maxPt < 0. || maxPt < sum.pt()) {
162 pOut->push_back(match);
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
~TtSemiLepJetCombMaxSumPtWMass() override
std::string bTagAlgorithm_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
void produce(edm::Event &evt, const edm::EventSetup &setup) override
double maxBDiscLightJets_
TtSemiLepJetCombMaxSumPtWMass(const edm::ParameterSet &)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
math::XYZTLorentzVector LorentzVector
Lorentz vector.