8 jets_ (cfg.getParameter<edm::InputTag>(
"jets" )),
9 leps_ (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"))
19 <<
"Parameter maxNJets can not be set to " <<
maxNJets_ <<
". \n"
20 <<
"It has to be larger than 4 or can be set to -1 to take all jets.";
22 produces<std::vector<std::vector<int> > >();
23 produces<int>(
"NumberOfConsideredJets");
33 std::auto_ptr<std::vector<std::vector<int> > > pOut(
new std::vector<std::vector<int> >);
34 std::auto_ptr<int> pJetsConsidered(
new int);
36 std::vector<int>
match;
37 for(
unsigned int i = 0;
i < 4; ++
i)
38 match.push_back( -1 );
50 if(leps->empty() || jets->size() < 4){
51 pOut->push_back( match );
53 *pJetsConsidered = jets->size();
54 evt.
put(pJetsConsidered,
"NumberOfConsideredJets");
60 *pJetsConsidered = maxNJets;
61 evt.
put(pJetsConsidered,
"NumberOfConsideredJets");
63 std::vector<bool> isBJet;
64 std::vector<bool> isLJet;
67 for(
unsigned int idx=0; idx<maxNJets; ++idx) {
79 std::vector<int> maxPtIndices;
80 maxPtIndices.push_back(-1);
81 maxPtIndices.push_back(-1);
82 maxPtIndices.push_back(-1);
83 for(
unsigned idx=0; idx<maxNJets; ++idx){
84 if(
useBTagging_ && (!isLJet[idx] || (cntBJets<=2 && isBJet[idx])))
continue;
85 for(
unsigned jdx=(idx+1); jdx<maxNJets; ++jdx){
86 if(jdx==idx || (
useBTagging_ && (!isLJet[jdx] || (cntBJets<=2 && isBJet[jdx]) || (cntBJets==3 && isBJet[idx] && isBJet[jdx]))))
continue;
87 for(
unsigned kdx=0; kdx<maxNJets; ++kdx){
88 if(kdx==idx || kdx==jdx || (
useBTagging_ && !isBJet[kdx]))
continue;
93 if( maxPt<0. || maxPt<sum.pt() ){
96 maxPtIndices.push_back(idx);
97 maxPtIndices.push_back(jdx);
98 maxPtIndices.push_back(kdx);
109 std::vector<int> closestToWMassIndices;
110 closestToWMassIndices.push_back(-1);
111 closestToWMassIndices.push_back(-1);
112 if(
isValid(maxPtIndices[0], jets) &&
isValid(maxPtIndices[1], jets) &&
isValid(maxPtIndices[2], jets)) {
113 for(
unsigned idx=0; idx<maxPtIndices.size(); ++idx){
114 for(
unsigned jdx=0; jdx<maxPtIndices.size(); ++jdx){
115 if( jdx==idx || maxPtIndices[idx]>maxPtIndices[jdx] || (
useBTagging_ && (!isLJet[maxPtIndices[idx]] || !isLJet[maxPtIndices[jdx]] || (cntBJets<=2 && isBJet[maxPtIndices[idx]]) || (cntBJets<=2 && isBJet[maxPtIndices[jdx]]) || (cntBJets==3 && isBJet[maxPtIndices[idx]] && isBJet[maxPtIndices[jdx]]))))
continue;
117 (*jets)[maxPtIndices[idx]].p4()+
118 (*jets)[maxPtIndices[jdx]].p4();
119 if( wDist<0. || wDist>fabs(sum.mass()-
wMass_) ){
120 wDist=fabs(sum.mass()-
wMass_);
121 closestToWMassIndices.clear();
122 closestToWMassIndices.push_back(maxPtIndices[idx]);
123 closestToWMassIndices.push_back(maxPtIndices[jdx]);
129 for(
unsigned idx=0; idx<maxPtIndices.size(); ++idx){
131 if(
std::find( closestToWMassIndices.begin(), closestToWMassIndices.end(), maxPtIndices[idx]) == closestToWMassIndices.end() ){
132 hadB = maxPtIndices[idx];
144 for(
unsigned idx=0; idx<maxNJets; ++idx){
147 if(
std::find(maxPtIndices.begin(), maxPtIndices.end(), idx) == maxPtIndices.end() ){
149 (*jets)[idx].p4()+(*leps)[ 0 ].p4();
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)
std::string bTagAlgorithm_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
double maxBDiscLightJets_
virtual void produce(edm::Event &evt, const edm::EventSetup &setup)
~TtSemiLepJetCombMaxSumPtWMass()
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.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")