10 jets_ (cfg.getParameter<edm::InputTag>(
"jets" )),
11 leps_ (cfg.getParameter<edm::InputTag>(
"leps" )),
12 mets_ (cfg.getParameter<edm::InputTag>(
"mets" )),
13 maxNJets_ (cfg.getParameter<int> (
"maxNJets" )),
14 wMass_ (cfg.getParameter<double> (
"wMass" )),
15 useBTagging_ (cfg.getParameter<bool> (
"useBTagging" )),
16 bTagAlgorithm_ (cfg.getParameter<std::string> (
"bTagAlgorithm" )),
17 minBDiscBJets_ (cfg.getParameter<double> (
"minBDiscBJets" )),
18 maxBDiscLightJets_(cfg.getParameter<double> (
"maxBDiscLightJets")),
19 neutrinoSolutionType_(cfg.getParameter<int> (
"neutrinoSolutionType"))
23 <<
"Parameter maxNJets can not be set to " <<
maxNJets_ <<
". \n"
24 <<
"It has to be larger than 4 or can be set to -1 to take all jets.";
26 produces<std::vector<std::vector<int> > >();
27 produces<int>(
"NumberOfConsideredJets");
37 std::auto_ptr<std::vector<std::vector<int> > > pOut(
new std::vector<std::vector<int> >);
38 std::auto_ptr<int> pJetsConsidered(
new int);
40 std::vector<int>
match;
41 for(
unsigned int i = 0;
i < 4; ++
i)
42 match.push_back( -1 );
57 if(leps->empty() || jets->size() < 4 || mets->empty()){
58 pOut->push_back( match );
60 *pJetsConsidered = jets->size();
61 evt.
put(pJetsConsidered,
"NumberOfConsideredJets");
67 *pJetsConsidered = maxNJets;
68 evt.
put(pJetsConsidered,
"NumberOfConsideredJets");
70 std::vector<bool> isBJet;
71 std::vector<bool> isLJet;
74 for(
unsigned int idx=0; idx<maxNJets; ++idx) {
86 std::vector<int> closestToWMassIndices;
87 closestToWMassIndices.push_back(-1);
88 closestToWMassIndices.push_back(-1);
89 for(
unsigned idx=0; idx<maxNJets; ++idx){
90 if(
useBTagging_ && (!isLJet[idx] || (cntBJets<=2 && isBJet[idx])))
continue;
91 for(
unsigned jdx=(idx+1); jdx<maxNJets; ++jdx){
92 if(
useBTagging_ && (!isLJet[jdx] || (cntBJets<=2 && isBJet[jdx]) || (cntBJets==3 && isBJet[idx] && isBJet[jdx])))
continue;
96 if( wDist<0. || wDist>fabs(sum.mass()-
wMass_) ){
97 wDist=fabs(sum.mass()-
wMass_);
98 closestToWMassIndices.clear();
99 closestToWMassIndices.push_back(idx);
100 closestToWMassIndices.push_back(jdx);
108 double neutrino_pz = 0.;
111 mez.
SetMET( *mets->begin() );
112 if( dynamic_cast<const reco::Muon*>(&(leps->front())) )
114 else if( dynamic_cast<const reco::GsfElectron*>(&(leps->front())) )
117 throw cms::Exception(
"UnimplementedFeature") <<
"Type of lepton given together with MET for solving neutrino kinematics is neither muon nor electron.\n";
120 const math::XYZTLorentzVector neutrino( mets->begin()->px(), mets->begin()->py(), neutrino_pz,
sqrt(mets->begin()->px()*mets->begin()->px()
121 + mets->begin()->py()*mets->begin()->py()
122 + neutrino_pz*neutrino_pz) );
133 if(
isValid(closestToWMassIndices[0], jets) &&
isValid(closestToWMassIndices[1], jets)) {
135 (*jets)[closestToWMassIndices[0]].p4()+
136 (*jets)[closestToWMassIndices[1]].p4();
138 for(
unsigned idx=0; idx<maxNJets; ++idx){
141 if( (
int)idx!=closestToWMassIndices[0] && (
int)idx!=closestToWMassIndices[1] ){
144 for(
unsigned jdx=0; jdx<maxNJets; ++jdx){
147 if( (
int)jdx!=closestToWMassIndices[0] && (
int)jdx!=closestToWMassIndices[1] && jdx!=idx ){
149 if( deltaTop<0. || deltaTop>fabs(hadTop.mass()-lepTop.mass()) ){
150 deltaTop=fabs(hadTop.mass()-lepTop.mass());
165 pOut->push_back( match );
void SetLepton(const pat::Particle &lepton, bool isMuon=true)
Set lepton.
virtual void produce(edm::Event &evt, const edm::EventSetup &setup)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void SetMET(const pat::MET &MET)
Set MET.
double Calculate(int type=1)
member functions
int neutrinoSolutionType_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
double maxBDiscLightJets_
TtSemiLepJetCombWMassDeltaTopMass(const edm::ParameterSet &)
std::string bTagAlgorithm_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
~TtSemiLepJetCombWMassDeltaTopMass()
math::XYZTLorentzVector LorentzVector
Lorentz vector.
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")