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"))
17 <<
"Parameter maxNJets can not be set to " <<
maxNJets_ <<
". \n"
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");
31 std::unique_ptr<std::vector<std::vector<int> > > pOut(
new std::vector<std::vector<int> >);
32 std::unique_ptr<int> pJetsConsidered(
new int);
34 std::vector<int>
match;
35 for(
unsigned int i = 0;
i < 4; ++
i)
36 match.push_back( -1 );
48 if(leps->empty() || jets->size() < 4){
49 pOut->push_back( match );
51 *pJetsConsidered = jets->size();
52 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
59 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
61 std::vector<bool> isBJet;
62 std::vector<bool> isLJet;
65 for(
unsigned int idx=0; idx<
maxNJets; ++idx) {
77 std::vector<int> closestToWMassIndices;
78 closestToWMassIndices.push_back(-1);
79 closestToWMassIndices.push_back(-1);
80 for(
unsigned idx=0; idx<
maxNJets; ++idx){
81 if(
useBTagging_ && (!isLJet[idx] || (cntBJets<=2 && isBJet[idx])))
continue;
82 for(
unsigned jdx=(idx+1); jdx<
maxNJets; ++jdx){
83 if(
useBTagging_ && (!isLJet[jdx] || (cntBJets<=2 && isBJet[jdx]) || (cntBJets==3 && isBJet[idx] && isBJet[jdx])))
continue;
87 if( wDist<0. || wDist>fabs(sum.mass()-
wMass_) ){
88 wDist=fabs(sum.mass()-
wMass_);
89 closestToWMassIndices.clear();
90 closestToWMassIndices.push_back(idx);
91 closestToWMassIndices.push_back(jdx);
102 if(
isValid(closestToWMassIndices[0], jets) &&
isValid(closestToWMassIndices[1], jets)) {
103 for(
unsigned idx=0; idx<
maxNJets; ++idx){
106 if( (
int)idx!=closestToWMassIndices[0] && (
int)idx!=closestToWMassIndices[1] ){
108 (*jets)[closestToWMassIndices[0]].p4()+
109 (*jets)[closestToWMassIndices[1]].p4()+
111 if( maxPt<0. || maxPt<sum.pt() ){
126 for(
unsigned idx=0; idx<
maxNJets; ++idx){
129 if( (
int)idx!=closestToWMassIndices[0] && (
int)idx!=closestToWMassIndices[1] && (
int)idx!=hadB) {
131 (*jets)[idx].p4()+(*leps)[ 0 ].p4();
132 if( maxPt<0. || maxPt<sum.pt() ){
144 pOut->push_back( match );
~TtSemiLepJetCombWMassMaxSumPt()
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 &)
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::string bTagAlgorithm_
double maxBDiscLightJets_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
virtual void produce(edm::Event &evt, const edm::EventSetup &setup)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
math::XYZTLorentzVector LorentzVector
Lorentz vector.