1 #ifndef TtSemiLepHitFitProducer_h
2 #define TtSemiLepHitFitProducer_h
19 template <
typename LeptonCollection>
100 template<
typename LeptonCollection>
102 jetsToken_ (consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>(
"jets"))),
103 lepsToken_ (consumes<LeptonCollection>(cfg.getParameter<edm::InputTag>(
"leps"))),
104 metsToken_ (consumes<std::vector<pat::
MET> >(cfg.getParameter<edm::InputTag>(
"mets"))),
105 maxNJets_ (cfg.getParameter<int> (
"maxNJets" )),
106 maxNComb_ (cfg.getParameter<int> (
"maxNComb" )),
107 bTagAlgo_ (cfg.getParameter<std::
string> (
"bTagAlgo" )),
108 minBTagValueBJet_ (cfg.getParameter<double> (
"minBDiscBJets" )),
109 maxBTagValueNonBJet_ (cfg.getParameter<double> (
"maxBDiscLightJets" )),
110 useBTag_ (cfg.getParameter<bool> (
"useBTagging" )),
111 mW_ (cfg.getParameter<double> (
"mW" )),
112 mTop_ (cfg.getParameter<double> (
"mTop" )),
113 jetCorrectionLevel_ (cfg.getParameter<std::
string> (
"jetCorrectionLevel" )),
114 jes_ (cfg.getParameter<double> (
"jes" )),
115 jesB_ (cfg.getParameter<double> (
"jesB" )),
119 hitfitDefault_ (cfg.getUntrackedParameter<edm::
FileInPath>(std::
string(
"hitfitDefault"),
120 edm::
FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/setting/RunHitFitConfiguration.txt")))),
121 hitfitElectronResolution_(cfg.getUntrackedParameter<edm::
FileInPath>(std::
string(
"hitfitElectronResolution"),
122 edm::
FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafElectronResolution.txt")))),
123 hitfitMuonResolution_ (cfg.getUntrackedParameter<edm::
FileInPath>(std::
string(
"hitfitMuonResolution"),
124 edm::
FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafMuonResolution.txt")))),
125 hitfitUdscJetResolution_ (cfg.getUntrackedParameter<edm::
FileInPath>(std::
string(
"hitfitUdscJetResolution"),
126 edm::
FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafUdscJetResolution.txt")))),
127 hitfitBJetResolution_ (cfg.getUntrackedParameter<edm::
FileInPath>(std::
string(
"hitfitBJetResolution"),
128 edm::
FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafBJetResolution.txt")))),
129 hitfitMETResolution_ (cfg.getUntrackedParameter<edm::
FileInPath>(std::
string(
"hitfitMETResolution"),
130 edm::
FileInPath(std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafKtResolution.txt")))),
134 electronTranslator_(hitfitElectronResolution_.fullPath()),
135 muonTranslator_ (hitfitMuonResolution_.fullPath()),
136 jetTranslator_ (hitfitUdscJetResolution_.fullPath(), hitfitBJetResolution_.fullPath(), jetCorrectionLevel_, jes_, jesB_),
137 metTranslator_ (hitfitMETResolution_.fullPath())
156 <<
"+++++++++++ TtSemiLepHitFitProducer ++++++++++++ \n"
157 <<
" Due to the eta ranges for which resolutions \n"
158 <<
" are provided in \n"
159 <<
" TopQuarkAnalysis/TopHitFit/data/resolution/ \n"
160 <<
" so far, the following cuts are currently \n"
161 <<
" implemented in the TtSemiLepHitFitProducer: \n"
162 <<
" |eta(muons )| <= " << maxEtaMu_ <<
" \n"
163 <<
" |eta(electrons)| <= " <<
maxEtaEle_ <<
" \n"
165 <<
"++++++++++++++++++++++++++++++++++++++++++++++++ \n";
167 produces< std::vector<pat::Particle> >(
"PartonsHadP");
168 produces< std::vector<pat::Particle> >(
"PartonsHadQ");
169 produces< std::vector<pat::Particle> >(
"PartonsHadB");
170 produces< std::vector<pat::Particle> >(
"PartonsLepB");
171 produces< std::vector<pat::Particle> >(
"Leptons");
172 produces< std::vector<pat::Particle> >(
"Neutrinos");
174 produces< std::vector<std::vector<int> > >();
175 produces< std::vector<double> >(
"Chi2");
176 produces< std::vector<double> >(
"Prob");
177 produces< std::vector<double> >(
"MT");
178 produces< std::vector<double> >(
"SigMT");
179 produces< std::vector<int> >(
"Status");
180 produces< int >(
"NumberOfConsideredJets");
183 template<
typename LeptonCollection>
189 template<
typename LeptonCollection>
192 std::auto_ptr< std::vector<pat::Particle> > pPartonsHadP(
new std::vector<pat::Particle> );
193 std::auto_ptr< std::vector<pat::Particle> > pPartonsHadQ(
new std::vector<pat::Particle> );
194 std::auto_ptr< std::vector<pat::Particle> > pPartonsHadB(
new std::vector<pat::Particle> );
195 std::auto_ptr< std::vector<pat::Particle> > pPartonsLepB(
new std::vector<pat::Particle> );
196 std::auto_ptr< std::vector<pat::Particle> > pLeptons (
new std::vector<pat::Particle> );
197 std::auto_ptr< std::vector<pat::Particle> > pNeutrinos (
new std::vector<pat::Particle> );
199 std::auto_ptr< std::vector<std::vector<int> > > pCombi (
new std::vector<std::vector<int> > );
200 std::auto_ptr< std::vector<double> > pChi2 (
new std::vector<double> );
201 std::auto_ptr< std::vector<double> > pProb (
new std::vector<double> );
202 std::auto_ptr< std::vector<double> > pMT (
new std::vector<double> );
203 std::auto_ptr< std::vector<double> > pSigMT (
new std::vector<double> );
204 std::auto_ptr< std::vector<int> > pStatus(
new std::vector<int> );
205 std::auto_ptr< int > pJetsConsidered(
new int );
227 bool foundLepton =
false;
229 double maxEtaLep = maxEtaMu_;
230 if( !dynamic_cast<const reco::Muon*>(&((*leps)[0])) )
231 maxEtaLep = maxEtaEle_;
232 for(
unsigned iLep=0; iLep<(*leps).size() && !foundLepton; ++iLep) {
234 HitFit->AddLepton((*leps)[iLep]);
241 unsigned int nJetsFound = 0;
242 for(
unsigned iJet=0; iJet<(*jets).size() && (int)nJetsFound!=maxNJets_; ++iJet) {
243 double jet_eta = (*jets)[iJet].eta();
244 if ( (*jets)[iJet].isCaloJet() ) {
245 jet_eta = ((
reco::CaloJet*) ((*jets)[iJet]).originalObject())->detectorP4().eta();
247 if(
std::abs(jet_eta) <= maxEtaJet_) {
248 HitFit->AddJet((*jets)[iJet]);
252 *pJetsConsidered = nJetsFound;
256 HitFit->SetMet((*mets)[0]);
258 if( !foundLepton || mets->empty() || nJetsFound<
nPartons ) {
267 std::vector<int> invalidCombi;
269 invalidCombi.push_back( -1 );
270 pCombi->push_back( invalidCombi );
272 pChi2->push_back( -1. );
274 pProb->push_back( -1. );
276 pMT->push_back( -1. );
277 pSigMT->push_back( -1. );
279 pStatus->push_back( -1 );
282 evt.
put(pPartonsHadP,
"PartonsHadP");
283 evt.
put(pPartonsHadQ,
"PartonsHadQ");
284 evt.
put(pPartonsHadB,
"PartonsHadB");
285 evt.
put(pPartonsLepB,
"PartonsLepB");
286 evt.
put(pLeptons ,
"Leptons" );
287 evt.
put(pNeutrinos ,
"Neutrinos" );
288 evt.
put(pChi2 ,
"Chi2" );
289 evt.
put(pProb ,
"Prob" );
290 evt.
put(pMT ,
"MT" );
291 evt.
put(pSigMT ,
"SigMT" );
292 evt.
put(pStatus ,
"Status" );
293 evt.
put(pJetsConsidered,
"NumberOfConsideredJets");
297 std::list<FitResult> FitResultList;
310 size_t nHitFitJet = 0 ;
313 std::vector<hitfit::Fit_Result> hitFitResult;
321 nHitFit = HitFit->FitAllPermutation();
328 nHitFitJet = HitFit->GetUnfittedEvent()[0].njets();
331 hitFitResult = HitFit->GetFitAllPermutation();
334 for (
size_t fit = 0 ; fit != nHitFit ; ++fit) {
346 std::vector<int> hitCombi(4);
347 for (
size_t jet = 0 ;
jet != nHitFitJet ; ++
jet) {
381 if ( hitFitResult[fit].chisq() > 0
382 && (!useBTag_ || ( useBTag_
383 && jets->at(hitCombi[TtSemiLepEvtPartons::LightQ ]).bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_
384 && jets->at(hitCombi[TtSemiLepEvtPartons::LightQBar]).bDiscriminator(bTagAlgo_) < maxBTagValueNonBJet_
385 && jets->at(hitCombi[TtSemiLepEvtPartons::HadB ]).bDiscriminator(bTagAlgo_) > minBTagValueBJet_
386 && jets->at(hitCombi[TtSemiLepEvtPartons::LepB ]).bDiscriminator(bTagAlgo_) > minBTagValueBJet_
392 result.
Chi2 = hitFitResult[fit].chisq();
393 result.
Prob =
exp(-1.0*(hitFitResult[fit].chisq())/2.0);
394 result.
MT = hitFitResult[fit].mt();
395 result.
SigMT= hitFitResult[fit].sigmt();
416 FitResultList.push_back(result);
422 FitResultList.sort();
429 if( ((
unsigned)FitResultList.size())<1 ) {
437 std::vector<int> invalidCombi;
439 invalidCombi.push_back( -1 );
440 pCombi->push_back( invalidCombi );
442 pChi2->push_back( -1. );
444 pProb->push_back( -1. );
446 pMT->push_back( -1. );
447 pSigMT->push_back( -1. );
449 pStatus->push_back( -1 );
452 unsigned int iComb = 0;
453 for(
typename std::list<FitResult>::const_iterator
result = FitResultList.begin();
result != FitResultList.end(); ++
result) {
454 if(maxNComb_ >= 1 && iComb == (
unsigned int) maxNComb_)
break;
457 pPartonsHadP->push_back(
result->HadP );
458 pPartonsHadQ->push_back(
result->HadQ );
459 pPartonsHadB->push_back(
result->HadB );
460 pPartonsLepB->push_back(
result->LepB );
462 pLeptons->push_back(
result->LepL );
464 pNeutrinos->push_back(
result->LepN );
466 pCombi->push_back(
result->JetCombi );
468 pChi2->push_back(
result->Chi2 );
470 pProb->push_back(
result->Prob );
472 pMT->push_back(
result->MT );
473 pSigMT->push_back(
result->SigMT );
475 pStatus->push_back(
result->Status );
479 evt.
put(pPartonsHadP,
"PartonsHadP");
480 evt.
put(pPartonsHadQ,
"PartonsHadQ");
481 evt.
put(pPartonsHadB,
"PartonsHadB");
482 evt.
put(pPartonsLepB,
"PartonsLepB");
483 evt.
put(pLeptons ,
"Leptons" );
484 evt.
put(pNeutrinos ,
"Neutrinos" );
485 evt.
put(pChi2 ,
"Chi2" );
486 evt.
put(pProb ,
"Prob" );
487 evt.
put(pMT ,
"MT" );
488 evt.
put(pSigMT ,
"SigMT" );
489 evt.
put(pStatus ,
"Status" );
490 evt.
put(pJetsConsidered,
"NumberOfConsideredJets");
int maxNComb_
maximal number of combinations to be written to the event
double maxEtaEle_
maximum eta value for electrons, needed to limited range in which resolutions are provided ...
double maxBTagValueNonBJet_
max value of bTag for a non-b-jet
static const unsigned int nPartons
bool operator<(const FitResult &rhs)
hitfit::JetTranslatorBase< pat::Jet > jetTranslator_
edm::FileInPath hitfitMETResolution_
Jets made from CaloTowers.
Represent a lepton in an instance of Lepjets_Event class. This class hold the following information: ...
bool getByToken(EDGetToken token, Handle< PROD > &result) const
hitfit::LeptonTranslatorBase< pat::Electron > electronTranslator_
std::vector< int > JetCombi
TtSemiLepHitFitProducer(const edm::ParameterSet &)
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
hitfit::LeptonTranslatorBase< pat::Muon > muonTranslator_
Lepjets_Event_Jet & jet(std::vector< Lepjets_Event_Jet >::size_type i)
Return a reference to jet at index position i.
double maxEtaJet_
maximum eta value for jets, needed to limited range in which resolutions are provided ...
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int & type()
Return a reference to the type code.
edm::FileInPath hitfitUdscJetResolution_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::FileInPath hitfitMuonResolution_
A class to hold functions to calculate kinematic quantities of interest in events.
bool useBTag_
switch to tell whether to use b-tagging or not
Represent a simple event consisting of lepton(s) and jet(s). An instance of this class holds a list o...
hitfit::RunHitFit< pat::Electron, pat::Muon, pat::Jet, pat::MET > PatHitFit
edm::FileInPath hitfitBJetResolution_
Abs< T >::type abs(const T &t)
Template class of function object to translate missing transverse energy object to HitFit's Fourvec o...
A class to represent a jet in an instance of Lepjets_Event class. The class is derived from the Lepje...
int maxNJets_
maximal number of jets (-1 possible to indicate 'all')
Template class of experiment-independent interface to HitFit.
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Template class of experiment-independent interface to HitFit. This class is intended to be used insid...
hitfit::METTranslatorBase< pat::MET > metTranslator_
Template class of function object to translate jet physics object to HitFit's Lepjets_Event_Jet objec...
~TtSemiLepHitFitProducer()
Fourvec & met()
Return a reference to the missing transverse energy.
Lepjets_Event_Lep & lep(std::vector< Lepjets_Event_Lep >::size_type i)
Return a reference to lepton at index position i.
edm::EDGetTokenT< LeptonCollection > lepsToken_
Template class of function object to translate lepton physics object to HitFit's Lepjets_Event_Lep ob...
XYZPointD XYZPoint
point in space with cartesian internal representation
edm::FileInPath hitfitElectronResolution_
Analysis-level particle class.
std::string jetCorrectionLevel_
jet correction level
Fourvec & p()
Return a reference to the four-momentum.
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::FileInPath hitfitDefault_
double maxEtaMu_
maximum eta value for muons, needed to limited range in which resolutions are provided ...
std::string fullPath() const
double minBTagValueBJet_
min value of bTag for a b-jet
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
std::string bTagAlgo_
input tag for b-tagging algorithm
double jes_
jet energy scale