1 #ifndef TtSemiLepHitFitProducer_h 2 #define TtSemiLepHitFitProducer_h 19 template <
typename LeptonCollection>
100 template<
typename LeptonCollection>
110 useBTag_ (cfg.getParameter<bool> (
"useBTagging" )),
111 mW_ (cfg.getParameter<double> (
"mW" )),
112 mTop_ (cfg.getParameter<double> (
"mTop" )),
114 jes_ (cfg.getParameter<double> (
"jes" )),
115 jesB_ (cfg.getParameter<double> (
"jesB" )),
120 edm::FileInPath(
std::
string(
"TopQuarkAnalysis/TopHitFit/data/setting/RunHitFitConfiguration.txt")))),
122 edm::FileInPath(
std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafElectronResolution.txt")))),
124 edm::FileInPath(
std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafMuonResolution.txt")))),
126 edm::FileInPath(
std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafUdscJetResolution.txt")))),
128 edm::FileInPath(
std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafBJetResolution.txt")))),
130 edm::FileInPath(
std::
string(
"TopQuarkAnalysis/TopHitFit/data/resolution/tqafKtResolution.txt")))),
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::unique_ptr< std::vector<pat::Particle> > pPartonsHadP(
new std::vector<pat::Particle> );
193 std::unique_ptr< std::vector<pat::Particle> > pPartonsHadQ(
new std::vector<pat::Particle> );
194 std::unique_ptr< std::vector<pat::Particle> > pPartonsHadB(
new std::vector<pat::Particle> );
195 std::unique_ptr< std::vector<pat::Particle> > pPartonsLepB(
new std::vector<pat::Particle> );
196 std::unique_ptr< std::vector<pat::Particle> > pLeptons (
new std::vector<pat::Particle> );
197 std::unique_ptr< std::vector<pat::Particle> > pNeutrinos (
new std::vector<pat::Particle> );
199 std::unique_ptr< std::vector<std::vector<int> > > pCombi (
new std::vector<std::vector<int> > );
200 std::unique_ptr< std::vector<double> > pChi2 (
new std::vector<double> );
201 std::unique_ptr< std::vector<double> > pProb (
new std::vector<double> );
202 std::unique_ptr< std::vector<double> > pMT (
new std::vector<double> );
203 std::unique_ptr< std::vector<double> > pSigMT (
new std::vector<double> );
204 std::unique_ptr< std::vector<int> > pStatus(
new std::vector<int> );
205 std::unique_ptr< int > pJetsConsidered(
new int );
227 bool foundLepton =
false;
230 if( !dynamic_cast<const reco::Muon*>(&((*leps)[0])) )
232 for(
unsigned iLep=0; iLep<(*leps).size() && !foundLepton; ++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();
252 *pJetsConsidered = nJetsFound;
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 );
293 evt.
put(
std::move(pJetsConsidered),
"NumberOfConsideredJets");
297 std::list<FitResult> FitResultList;
310 size_t nHitFitJet = 0 ;
313 std::vector<hitfit::Fit_Result> hitFitResult;
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
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) {
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 );
490 evt.
put(
std::move(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 ...
std::vector< Lepjets_Event > GetUnfittedEvent()
Return the unfitted events for all permutations.
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_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::FileInPath hitfitMETResolution_
Jets made from CaloTowers.
std::vector< Fit_Result >::size_type FitAllPermutation()
Fit all permutations of the internal event. Returns the number of permutations.
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 &)
def setup(process, global_tag, zero_tesla=False)
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
void SetMet(const AMet &met, bool useObjRes=false)
Set the missing transverse energy of the internal event.
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 ...
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int & type()
Return a reference to the type code.
edm::FileInPath hitfitUdscJetResolution_
std::vector< Fit_Result > GetFitAllPermutation()
Return the results of fitting all permutations of the internal event.
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_
std::string fullPath() const
double maxEtaMu_
maximum eta value for muons, needed to limited range in which resolutions are provided ...
double minBTagValueBJet_
min value of bTag for a b-jet
void AddLepton(const AElectron &electron, bool useObjRes=false)
Add one electron into the internal event.
void clear()
Clear the internal event, fit results, and jets.
std::string bTagAlgo_
input tag for b-tagging algorithm
void AddJet(const AJet &jet, bool useObjRes=false)
Add one jet into the internal event. This function will do nothing if the internal event has already ...
double jes_
jet energy scale