6 : jetsToken_(consumes<std::
vector<pat::
Jet> >(cfg.getParameter<edm::
InputTag>(
"jets"))),
7 lepsToken_(consumes<edm::
View<
reco::RecoCandidate> >(cfg.getParameter<edm::
InputTag>(
"leps"))),
8 maxNJets_(cfg.getParameter<int>(
"maxNJets")),
9 wMass_(cfg.getParameter<double>(
"wMass")),
10 useBTagging_(cfg.getParameter<bool>(
"useBTagging")),
11 bTagAlgorithm_(cfg.getParameter<std::
string>(
"bTagAlgorithm")),
12 minBDiscBJets_(cfg.getParameter<double>(
"minBDiscBJets")),
13 maxBDiscLightJets_(cfg.getParameter<double>(
"maxBDiscLightJets")) {
16 <<
"It has to be larger than 4 or can be set to -1 to take all jets.";
18 produces<std::vector<std::vector<int> > >();
19 produces<int>(
"NumberOfConsideredJets");
25 std::unique_ptr<std::vector<std::vector<int> > > pOut(
new std::vector<std::vector<int> >);
26 std::unique_ptr<int> pJetsConsidered(
new int);
28 std::vector<int>
match;
29 for (
unsigned int i = 0;
i < 4; ++
i)
41 if (leps->empty() || jets->size() < 4) {
42 pOut->push_back(match);
44 *pJetsConsidered = jets->size();
45 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
51 maxNJets = jets->size();
52 *pJetsConsidered = maxNJets;
53 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
55 std::vector<bool> isBJet;
56 std::vector<bool> isLJet;
59 for (
unsigned int idx = 0; idx < maxNJets; ++idx) {
72 std::vector<int> closestToWMassIndices;
73 closestToWMassIndices.push_back(-1);
74 closestToWMassIndices.push_back(-1);
75 for (
unsigned idx = 0; idx < maxNJets; ++idx) {
76 if (
useBTagging_ && (!isLJet[idx] || (cntBJets <= 2 && isBJet[idx])))
78 for (
unsigned jdx = (idx + 1); jdx < maxNJets; ++jdx) {
80 (!isLJet[jdx] || (cntBJets <= 2 && isBJet[jdx]) || (cntBJets == 3 && isBJet[idx] && isBJet[jdx])))
83 if (wDist < 0. || wDist > fabs(sum.mass() -
wMass_)) {
84 wDist = fabs(sum.mass() -
wMass_);
85 closestToWMassIndices.clear();
86 closestToWMassIndices.push_back(idx);
87 closestToWMassIndices.push_back(jdx);
98 if (
isValid(closestToWMassIndices[0], jets) &&
isValid(closestToWMassIndices[1], jets)) {
99 for (
unsigned idx = 0; idx < maxNJets; ++idx) {
103 if ((
int)idx != closestToWMassIndices[0] && (
int)idx != closestToWMassIndices[1]) {
105 (*jets)[closestToWMassIndices[0]].p4() + (*jets)[closestToWMassIndices[1]].p4() + (*jets)[idx].p4();
106 if (maxPt < 0. || maxPt < sum.pt()) {
121 for (
unsigned idx = 0; idx < maxNJets; ++idx) {
125 if ((
int)idx != closestToWMassIndices[0] && (
int)idx != closestToWMassIndices[1] && (
int)idx != hadB) {
127 if (maxPt < 0. || maxPt < sum.pt()) {
139 pOut->push_back(match);
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
TtSemiLepJetCombWMassMaxSumPt(const edm::ParameterSet &)
void produce(edm::Event &evt, const edm::EventSetup &setup) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~TtSemiLepJetCombWMassMaxSumPt() override
std::string bTagAlgorithm_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
double maxBDiscLightJets_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
math::XYZTLorentzVector LorentzVector
Lorentz vector.