1 #ifndef TtSemiLepKinFitProducer_h
2 #define TtSemiLepKinFitProducer_h
12 template <
typename LeptonCollection>
29 std::vector<TtSemiLepKinFitter::Constraint>
constraints(std::vector<unsigned>&);
32 std::string&
bTagAlgo_,
double& minBTagValueBJets_,
double& maxBTagValueNonBJets_);
85 template<
typename LeptonCollection>
87 jets_ (cfg.getParameter<edm::InputTag>(
"jets")),
88 leps_ (cfg.getParameter<edm::InputTag>(
"leps")),
89 mets_ (cfg.getParameter<edm::InputTag>(
"mets")),
90 match_ (cfg.getParameter<edm::InputTag>(
"match")),
91 useOnlyMatch_ (cfg.getParameter<bool> (
"useOnlyMatch" )),
92 bTagAlgo_ (cfg.getParameter<std::string> (
"bTagAlgo" )),
93 minBTagValueBJet_ (cfg.getParameter<double> (
"minBDiscBJets" )),
94 maxBTagValueNonBJet_(cfg.getParameter<double> (
"maxBDiscLightJets" )),
95 useBTag_ (cfg.getParameter<bool> (
"useBTagging" )),
96 maxNJets_ (cfg.getParameter<int> (
"maxNJets" )),
97 maxNComb_ (cfg.getParameter<int> (
"maxNComb" )),
98 maxNrIter_ (cfg.getParameter<unsigned> (
"maxNrIter" )),
99 maxDeltaS_ (cfg.getParameter<double> (
"maxDeltaS" )),
100 maxF_ (cfg.getParameter<double> (
"maxF" )),
101 jetParam_ (cfg.getParameter<unsigned> (
"jetParametrisation")),
102 lepParam_ (cfg.getParameter<unsigned> (
"lepParametrisation")),
103 metParam_ (cfg.getParameter<unsigned> (
"metParametrisation")),
104 constraints_ (cfg.getParameter<std::vector<unsigned> >(
"constraints")),
105 mW_ (cfg.getParameter<double> (
"mW" )),
106 mTop_ (cfg.getParameter<double> (
"mTop" ))
111 produces< std::vector<pat::Particle> >(
"PartonsHadP");
112 produces< std::vector<pat::Particle> >(
"PartonsHadQ");
113 produces< std::vector<pat::Particle> >(
"PartonsHadB");
114 produces< std::vector<pat::Particle> >(
"PartonsLepB");
115 produces< std::vector<pat::Particle> >(
"Leptons");
116 produces< std::vector<pat::Particle> >(
"Neutrinos");
118 produces< std::vector<std::vector<int> > >();
119 produces< std::vector<double> >(
"Chi2");
120 produces< std::vector<double> >(
"Prob");
121 produces< std::vector<int> >(
"Status");
124 template<
typename LeptonCollection>
130 template<
typename LeptonCollection>
132 std::string& bTagAlgo_,
double& minBTagValueBJet_,
double& maxBTagValueNonBJet_){
149 template<
typename LeptonCollection>
152 std::auto_ptr< std::vector<pat::Particle> > pPartonsHadP(
new std::vector<pat::Particle> );
153 std::auto_ptr< std::vector<pat::Particle> > pPartonsHadQ(
new std::vector<pat::Particle> );
154 std::auto_ptr< std::vector<pat::Particle> > pPartonsHadB(
new std::vector<pat::Particle> );
155 std::auto_ptr< std::vector<pat::Particle> > pPartonsLepB(
new std::vector<pat::Particle> );
156 std::auto_ptr< std::vector<pat::Particle> > pLeptons (
new std::vector<pat::Particle> );
157 std::auto_ptr< std::vector<pat::Particle> > pNeutrinos (
new std::vector<pat::Particle> );
159 std::auto_ptr< std::vector<std::vector<int> > > pCombi (
new std::vector<std::vector<int> > );
160 std::auto_ptr< std::vector<double> > pChi2 (
new std::vector<double> );
161 std::auto_ptr< std::vector<double> > pProb (
new std::vector<double> );
162 std::auto_ptr< std::vector<int> > pStatus(
new std::vector<int> );
175 std::vector<int>
match;
176 bool invalidMatch =
false;
180 match = *(matchHandle->begin());
182 if(match.size()!=
nPartons) invalidMatch=
true;
184 for(
unsigned int idx=0; idx<match.size(); ++idx) {
185 if(match[idx]<0 || match[idx]>=(
int)jets->size()) {
198 if( leps->empty() || mets->empty() || jets->size()<nPartons || invalidMatch ) {
200 pPartonsHadP->push_back( fitter->fittedHadP() );
201 pPartonsHadQ->push_back( fitter->fittedHadQ() );
202 pPartonsHadB->push_back( fitter->fittedHadB() );
203 pPartonsLepB->push_back( fitter->fittedLepB() );
204 pLeptons ->push_back( fitter->fittedLepton() );
205 pNeutrinos ->push_back( fitter->fittedNeutrino() );
207 std::vector<int> invalidCombi;
209 invalidCombi.push_back( -1 );
210 pCombi->push_back( invalidCombi );
212 pChi2->push_back( -1. );
214 pProb->push_back( -1. );
216 pStatus->push_back( -1 );
219 evt.
put(pPartonsHadP,
"PartonsHadP");
220 evt.
put(pPartonsHadQ,
"PartonsHadQ");
221 evt.
put(pPartonsHadB,
"PartonsHadB");
222 evt.
put(pPartonsLepB,
"PartonsLepB");
223 evt.
put(pLeptons ,
"Leptons" );
224 evt.
put(pNeutrinos ,
"Neutrinos" );
225 evt.
put(pChi2 ,
"Chi2" );
226 evt.
put(pProb ,
"Prob" );
227 evt.
put(pStatus ,
"Status" );
236 std::vector<int> jetIndices;
238 for(
unsigned int i=0;
i<jets->size(); ++
i){
239 if(maxNJets_ >= (
int) nPartons && maxNJets_ == (int)
i)
break;
240 jetIndices.push_back(
i);
244 std::vector<int> combi;
246 if(useOnlyMatch_) combi.push_back( match[
i] );
247 else combi.push_back(i);
250 std::list<KinFitResult> FitResultList;
253 for(
int cnt = 0; cnt < TMath::Factorial( combi.size() ); ++cnt){
257 || useOnlyMatch_ ) && doBTagging(useBTag_, jets, combi, bTagAlgo_, minBTagValueBJet_, maxBTagValueNonBJet_) ){
259 std::vector<pat::Jet> jetCombi;
260 jetCombi.resize(nPartons);
267 int status = fitter->fit(jetCombi, (*leps)[0], (*mets)[0]);
272 result.
Chi2 = fitter->fitS();
273 result.
Prob = fitter->fitProb();
274 result.
HadB = fitter->fittedHadB();
275 result.
HadP = fitter->fittedHadP();
276 result.
HadQ = fitter->fittedHadQ();
277 result.
LepB = fitter->fittedLepB();
278 result.
LepL = fitter->fittedLepton();
279 result.
LepN = fitter->fittedNeutrino();
282 FitResultList.push_back(result);
286 if(useOnlyMatch_)
break;
287 next_permutation( combi.begin(), combi.end() );
289 if(useOnlyMatch_)
break;
294 FitResultList.sort();
301 if( FitResultList.size() < 1 ) {
302 pPartonsHadP->push_back( fitter->fittedHadP() );
303 pPartonsHadQ->push_back( fitter->fittedHadQ() );
304 pPartonsHadB->push_back( fitter->fittedHadB() );
305 pPartonsLepB->push_back( fitter->fittedLepB() );
306 pLeptons ->push_back( fitter->fittedLepton() );
307 pNeutrinos ->push_back( fitter->fittedNeutrino() );
309 std::vector<int> invalidCombi;
311 invalidCombi.push_back( -1 );
312 pCombi->push_back( invalidCombi );
314 pChi2->push_back( -1. );
316 pProb->push_back( -1. );
318 pStatus->push_back( -1 );
321 unsigned int iComb = 0;
322 for(
typename std::list<KinFitResult>::const_iterator
result = FitResultList.begin();
result != FitResultList.end(); ++
result) {
323 if(maxNComb_ >= 1 && iComb == (
unsigned int) maxNComb_)
break;
326 pPartonsHadP->push_back(
result->HadP );
327 pPartonsHadQ->push_back(
result->HadQ );
328 pPartonsHadB->push_back(
result->HadB );
329 pPartonsLepB->push_back(
result->LepB );
331 pLeptons->push_back(
result->LepL );
333 pNeutrinos->push_back(
result->LepN );
335 pCombi->push_back(
result->JetCombi );
337 pChi2->push_back(
result->Chi2 );
339 pProb->push_back(
result->Prob );
341 pStatus->push_back(
result->Status );
345 evt.
put(pPartonsHadP,
"PartonsHadP");
346 evt.
put(pPartonsHadQ,
"PartonsHadQ");
347 evt.
put(pPartonsHadB,
"PartonsHadB");
348 evt.
put(pPartonsLepB,
"PartonsLepB");
349 evt.
put(pLeptons ,
"Leptons" );
350 evt.
put(pNeutrinos ,
"Neutrinos" );
351 evt.
put(pChi2 ,
"Chi2" );
352 evt.
put(pProb ,
"Prob" );
353 evt.
put(pStatus ,
"Status" );
356 template<
typename LeptonCollection>
366 <<
"Chosen jet parametrization is not supported: " << val <<
"\n";
372 template<
typename LeptonCollection>
385 <<
"Chosen fit constraint is not supported: " << val <<
"\n";
391 template<
typename LeptonCollection>
394 std::vector<TtSemiLepKinFitter::Constraint>
result;
395 for(
unsigned i=0;
i<val.size(); ++
i){
396 result.push_back(constraint(val[
i]));
double maxBTagValueNonBJet_
max value of bTag for a non-b-jet
std::string bTagAlgo_
input tag for b-tagging algorithm
static const unsigned int nPartons
double minBTagValueBJet_
min value of bTag for a b-jet
Param
supported parameterizations
std::vector< int > JetCombi
std::vector< TtSemiLepKinFitter::Constraint > constraints(std::vector< unsigned > &)
virtual void produce(edm::Event &, const edm::EventSetup &)
int maxNJets_
maximal number of jets (-1 possible to indicate 'all')
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
TtSemiLepKinFitter * fitter
std::vector< unsigned > constraints_
unsigned int maxNrIter_
maximal number of iterations to be performed for the fit
bool operator<(const KinFitResult &rhs)
bool doBTagging(bool &useBTag_, edm::Handle< std::vector< pat::Jet > > &jets, std::vector< int > &combi, std::string &bTagAlgo_, double &minBTagValueBJets_, double &maxBTagValueNonBJets_)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
int maxNComb_
maximal number of combinations to be written to the event
double maxF_
maximal deviation for contstraints
Analysis-level particle class.
~TtSemiLepKinFitProducer()
TtSemiLepKinFitter::Constraint constraint(unsigned)
bool useOnlyMatch_
switch to use only a combination given by another hypothesis
bool useBTag_
switch to tell whether to use b-tagging or not
TtSemiLepKinFitter::Param param(unsigned)
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
TtSemiLepKinFitProducer(const edm::ParameterSet &)
double maxDeltaS_
maximal chi2 equivalent
bool next_combination(BidIt n_begin, BidIt n_end, BidIt r_begin, BidIt r_end)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
Constraint
supported constraints