CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Private Attributes
TtSemiEvtSolutionMaker Class Reference

#include <TtSemiEvtSolutionMaker.h>

Inheritance diagram for TtSemiEvtSolutionMaker:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

TtSemiLepKinFitter::Constraint constraint (unsigned)
 
std::vector
< TtSemiLepKinFitter::Constraint
constraints (std::vector< unsigned > &)
 
TtSemiLepKinFitter::Param param (unsigned)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 TtSemiEvtSolutionMaker (const edm::ParameterSet &iConfig)
 constructor More...
 
 ~TtSemiEvtSolutionMaker () override
 destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector
< edm::ProductResolverIndex >
const & 
indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector
< edm::ProductResolverIndex >
const & 
putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex >
const & 
esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector
< ProductResolverIndexAndSkipBit >
const & 
itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const * > *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

bool addLRJetComb_
 
bool addLRSignalSel_
 
std::vector< unsigned > constraints_
 
bool doKinFit_
 
edm::EDGetTokenT< std::vector
< pat::Electron > > 
electronSrcToken_
 
edm::EDGetTokenT< TtGenEventgenEvtToken_
 
int jetCorrScheme_
 
int jetParam_
 
edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetSrcToken_
 
int lepParam_
 
std::string leptonFlavour_
 
std::string lrJetCombFile_
 
std::vector< int > lrJetCombObs_
 
std::string lrSignalSelFile_
 
std::vector< int > lrSignalSelObs_
 
int matchingAlgo_
 
bool matchToGenEvt_
 
double maxDeltaS_
 
double maxDist_
 
double maxF_
 
int maxNrIter_
 
int metParam_
 
edm::EDGetTokenT< std::vector
< pat::MET > > 
metSrcToken_
 
edm::EDGetTokenT< std::vector
< pat::Muon > > 
muonSrcToken_
 
TtSemiLepKinFittermyKinFitter
 
TtSemiLRJetCombCalcmyLRJetCombCalc
 
TtSemiLRJetCombObservablesmyLRJetCombObservables
 
TtSemiLRSignalSelCalcmyLRSignalSelCalc
 
TtSemiLRSignalSelObservablesmyLRSignalSelObservables
 
TtSemiSimpleBestJetCombmySimpleBestJetComb
 
unsigned int nrCombJets_
 
bool useDeltaR_
 
bool useMaxDist_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 23 of file TtSemiEvtSolutionMaker.h.

Constructor & Destructor Documentation

TtSemiEvtSolutionMaker::TtSemiEvtSolutionMaker ( const edm::ParameterSet iConfig)
explicit

constructor

Definition at line 21 of file TtSemiEvtSolutionMaker.cc.

References addLRJetComb_, addLRSignalSel_, constraints(), constraints_, edm::EDConsumerBase::consumesCollector(), doKinFit_, electronSrcToken_, contentValuesFiles::fullPath, genEvtToken_, edm::ParameterSet::getParameter(), HLT_FULL_cff::InputTag, jetCorrScheme_, jetParam_, jetSrcToken_, lepParam_, leptonFlavour_, lrJetCombFile_, lrJetCombObs_, lrSignalSelFile_, lrSignalSelObs_, matchingAlgo_, matchToGenEvt_, maxDeltaS_, maxDist_, maxF_, maxNrIter_, metParam_, metSrcToken_, muonSrcToken_, myKinFitter, myLRJetCombCalc, myLRJetCombObservables, myLRSignalSelCalc, myLRSignalSelObservables, mySimpleBestJetComb, nrCombJets_, param(), AlCaHLTBitMon_QueryRunRegistry::string, useDeltaR_, and useMaxDist_.

21  {
22  // configurables
23  electronSrcToken_ = mayConsume<std::vector<pat::Electron> >(iConfig.getParameter<edm::InputTag>("electronSource"));
24  muonSrcToken_ = mayConsume<std::vector<pat::Muon> >(iConfig.getParameter<edm::InputTag>("muonSource"));
25  metSrcToken_ = consumes<std::vector<pat::MET> >(iConfig.getParameter<edm::InputTag>("metSource"));
26  jetSrcToken_ = consumes<std::vector<pat::Jet> >(iConfig.getParameter<edm::InputTag>("jetSource"));
27  leptonFlavour_ = iConfig.getParameter<std::string>("leptonFlavour");
28  jetCorrScheme_ = iConfig.getParameter<int>("jetCorrectionScheme");
29  nrCombJets_ = iConfig.getParameter<unsigned int>("nrCombJets");
30  doKinFit_ = iConfig.getParameter<bool>("doKinFit");
31  addLRSignalSel_ = iConfig.getParameter<bool>("addLRSignalSel");
32  lrSignalSelObs_ = iConfig.getParameter<std::vector<int> >("lrSignalSelObs");
33  lrSignalSelFile_ = iConfig.getParameter<std::string>("lrSignalSelFile");
34  addLRJetComb_ = iConfig.getParameter<bool>("addLRJetComb");
35  lrJetCombObs_ = iConfig.getParameter<std::vector<int> >("lrJetCombObs");
36  lrJetCombFile_ = iConfig.getParameter<std::string>("lrJetCombFile");
37  maxNrIter_ = iConfig.getParameter<int>("maxNrIter");
38  maxDeltaS_ = iConfig.getParameter<double>("maxDeltaS");
39  maxF_ = iConfig.getParameter<double>("maxF");
40  jetParam_ = iConfig.getParameter<int>("jetParametrisation");
41  lepParam_ = iConfig.getParameter<int>("lepParametrisation");
42  metParam_ = iConfig.getParameter<int>("metParametrisation");
43  constraints_ = iConfig.getParameter<std::vector<unsigned> >("constraints");
44  matchToGenEvt_ = iConfig.getParameter<bool>("matchToGenEvt");
45  matchingAlgo_ = iConfig.getParameter<int>("matchingAlgorithm");
46  useMaxDist_ = iConfig.getParameter<bool>("useMaximalDistance");
47  useDeltaR_ = iConfig.getParameter<bool>("useDeltaR");
48  maxDist_ = iConfig.getParameter<double>("maximalDistance");
49  genEvtToken_ = mayConsume<TtGenEvent>(edm::InputTag("genEvt"));
50 
51  // define kinfitter
52  if (doKinFit_) {
55  }
56 
57  // define jet combinations related calculators
61  if (addLRJetComb_)
63 
64  // instantiate signal selection calculator
65  if (addLRSignalSel_)
67 
68  // define what will be produced
69  produces<std::vector<TtSemiEvtSolution> >();
70 }
TtSemiLRJetCombCalc * myLRJetCombCalc
edm::EDGetTokenT< std::vector< pat::Electron > > electronSrcToken_
TtSemiLepKinFitter * myKinFitter
TtSemiLRJetCombObservables * myLRJetCombObservables
TtSemiSimpleBestJetComb * mySimpleBestJetComb
std::vector< unsigned > constraints_
TtSemiLepKinFitter::Param param(unsigned)
edm::EDGetTokenT< std::vector< pat::Muon > > muonSrcToken_
Simple method to get the correct jet combination in semileptonic ttbar events.
Class to calculate the jet combination LR value and purity from a root-file with fit functions...
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_
Class to calculate the jet combination LR value and purity from a root-file with fit functions...
Steering class for the overall top-lepton likelihood.
edm::EDGetTokenT< std::vector< pat::Jet > > jetSrcToken_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< TtGenEvent > genEvtToken_
std::vector< int > lrSignalSelObs_
std::vector< TtSemiLepKinFitter::Constraint > constraints(std::vector< unsigned > &)
TtSemiLRSignalSelObservables * myLRSignalSelObservables
std::vector< int > lrJetCombObs_
TtSemiLRSignalSelCalc * myLRSignalSelCalc
TtSemiEvtSolutionMaker::~TtSemiEvtSolutionMaker ( )
override

destructor

Definition at line 73 of file TtSemiEvtSolutionMaker.cc.

References addLRJetComb_, addLRSignalSel_, doKinFit_, myKinFitter, myLRJetCombCalc, myLRJetCombObservables, myLRSignalSelCalc, myLRSignalSelObservables, and mySimpleBestJetComb.

73  {
74  if (doKinFit_)
75  delete myKinFitter;
76  delete mySimpleBestJetComb;
79  if (addLRSignalSel_)
80  delete myLRSignalSelCalc;
81  if (addLRJetComb_)
82  delete myLRJetCombCalc;
83 }
TtSemiLRJetCombCalc * myLRJetCombCalc
TtSemiLepKinFitter * myKinFitter
TtSemiLRJetCombObservables * myLRJetCombObservables
TtSemiSimpleBestJetComb * mySimpleBestJetComb
TtSemiLRSignalSelObservables * myLRSignalSelObservables
TtSemiLRSignalSelCalc * myLRSignalSelCalc

Member Function Documentation

TtSemiLepKinFitter::Constraint TtSemiEvtSolutionMaker::constraint ( unsigned  val)

Definition at line 307 of file TtSemiEvtSolutionMaker.cc.

References Exception, TtSemiLepKinFitter::kNeutrinoMass, TtSemiLepKinFitter::kTopHadMass, TtSemiLepKinFitter::kTopLepMass, TtSemiLepKinFitter::kWHadMass, TtSemiLepKinFitter::kWLepMass, and mps_fire::result.

Referenced by constraints().

307  {
309  switch (val) {
312  break;
315  break;
318  break;
321  break;
324  break;
325  default:
326  throw cms::Exception("WrongConfig") << "Chosen fit constraint is not supported: " << val << "\n";
327  break;
328  }
329  return result;
330 }
tuple result
Definition: mps_fire.py:311
Constraint
supported constraints
std::vector< TtSemiLepKinFitter::Constraint > TtSemiEvtSolutionMaker::constraints ( std::vector< unsigned > &  val)

Definition at line 332 of file TtSemiEvtSolutionMaker.cc.

References constraint(), mps_fire::i, and mps_fire::result.

Referenced by TtSemiEvtSolutionMaker().

332  {
333  std::vector<TtSemiLepKinFitter::Constraint> result;
334  for (unsigned i = 0; i < val.size(); ++i) {
335  result.push_back(constraint(val[i]));
336  }
337  return result;
338 }
tuple result
Definition: mps_fire.py:311
TtSemiLepKinFitter::Constraint constraint(unsigned)
TtSemiLepKinFitter::Param TtSemiEvtSolutionMaker::param ( unsigned  val)

Definition at line 288 of file TtSemiEvtSolutionMaker.cc.

References Exception, TopKinFitter::kEMom, TopKinFitter::kEtEtaPhi, TopKinFitter::kEtThetaPhi, and mps_fire::result.

Referenced by TtSemiEvtSolutionMaker().

288  {
290  switch (val) {
292  result = TtSemiLepKinFitter::kEMom;
293  break;
296  break;
299  break;
300  default:
301  throw cms::Exception("WrongConfig") << "Chosen jet parametrization is not supported: " << val << "\n";
302  break;
303  }
304  return result;
305 }
Param
supported parameterizations
Definition: TopKinFitter.h:20
tuple result
Definition: mps_fire.py:311
void TtSemiEvtSolutionMaker::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 85 of file TtSemiEvtSolutionMaker.cc.

References TtSemiLepKinFitter::addKinFitInfo(), addLRJetComb_, addLRSignalSel_, doKinFit_, HI_PhotonSkim_cff::electrons, electronSrcToken_, TtGenEvtProducer_cfi::genEvt, genEvtToken_, EgammaValidation_cff::genp, edm::Event::getByToken(), JetPartonMatching::getDistanceForParton(), JetPartonMatching::getMatchForParton(), JetPartonMatching::getSumDistances(), iEvent, jetCorrScheme_, jetParam_, fwrapper::jets, jetSrcToken_, lepParam_, leptonFlavour_, matchingAlgo_, matchToGenEvt_, maxDist_, metParam_, metSrcToken_, eostools::move(), patZpeak::muons, muonSrcToken_, myKinFitter, nrCombJets_, AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), submitPVResolutionJobs::q, alignCSCRings::s, TtSemiEvtSolution::setElectron(), TtSemiEvtSolution::setGenEvt(), TtSemiEvtSolution::setHadb(), TtSemiEvtSolution::setHadp(), TtSemiEvtSolution::setHadq(), TtSemiEvtSolution::setJetCorrectionScheme(), TtSemiEvtSolution::setJetParametrisation(), TtSemiEvtSolution::setLepb(), TtSemiEvtSolution::setLeptonParametrisation(), TtSemiEvtSolution::setMuon(), TtSemiEvtSolution::setNeutrino(), TtSemiEvtSolution::setNeutrinoParametrisation(), useDeltaR_, and useMaxDist_.

85  {
86  //
87  // TopObject Selection
88  //
89 
90  // select lepton (the TtLepton vectors are, for the moment, sorted on pT)
91  bool leptonFound = false;
93  if (leptonFlavour_ == "muon") {
94  iEvent.getByToken(muonSrcToken_, muons);
95  if (!muons->empty())
96  leptonFound = true;
97  }
99  if (leptonFlavour_ == "electron") {
100  iEvent.getByToken(electronSrcToken_, electrons);
101  if (!electrons->empty())
102  leptonFound = true;
103  }
104 
105  // select MET (TopMET vector is sorted on ET)
106  bool metFound = false;
108  iEvent.getByToken(metSrcToken_, mets);
109  if (!mets->empty())
110  metFound = true;
111 
112  // select Jets
113  bool jetsFound = false;
115  iEvent.getByToken(jetSrcToken_, jets);
116  if (jets->size() >= 4)
117  jetsFound = true;
118 
119  //
120  // Build Event solutions according to the ambiguity in the jet combination
121  //
122  std::vector<TtSemiEvtSolution>* evtsols = new std::vector<TtSemiEvtSolution>();
123  if (leptonFound && metFound && jetsFound) {
124  // protect against reading beyond array boundaries
125  unsigned int nrCombJets = nrCombJets_; // do not overwrite nrCombJets_
126  if (jets->size() < nrCombJets)
127  nrCombJets = jets->size();
128  // loop over all jets
129  for (unsigned int p = 0; p < nrCombJets; p++) {
130  for (unsigned int q = 0; q < nrCombJets; q++) {
131  for (unsigned int bh = 0; bh < nrCombJets; bh++) {
132  if (q > p && !(bh == p || bh == q)) {
133  for (unsigned int bl = 0; bl < nrCombJets; bl++) {
134  if (!(bl == p || bl == q || bl == bh)) {
135  TtSemiEvtSolution asol;
137  if (leptonFlavour_ == "muon")
138  asol.setMuon(muons, 0);
139  if (leptonFlavour_ == "electron")
140  asol.setElectron(electrons, 0);
141  asol.setNeutrino(mets, 0);
142  asol.setHadp(jets, p);
143  asol.setHadq(jets, q);
144  asol.setHadb(jets, bh);
145  asol.setLepb(jets, bl);
146  if (doKinFit_) {
147  asol = myKinFitter->addKinFitInfo(&asol);
148  // just to keep a record in the event (drop? -> present in provenance anyway...)
152  }
153  if (matchToGenEvt_) {
155  iEvent.getByToken(genEvtToken_, genEvt);
156  if (genEvt->numberOfBQuarks() ==
157  2 && // FIXME: in rare cases W->bc decay, resulting in a wrong filled genEvt leading to a segmentation fault
158  genEvt->numberOfLeptons() ==
159  1) { // FIXME: temporary solution to avoid crash in JetPartonMatching for non semi-leptonic events
160  asol.setGenEvt(genEvt);
161  }
162  }
163  // these lines calculate the observables to be used in the TtSemiSignalSelection LR
164  (*myLRSignalSelObservables)(asol, *jets);
165 
166  // if asked for, calculate with these observable values the LRvalue and
167  // (depending on the configuration) probability this event is signal
168  // FIXME: DO WE NEED TO DO THIS FOR EACH SOLUTION??? (S.L.20/8/07)
169  if (addLRSignalSel_)
170  (*myLRSignalSelCalc)(asol);
171 
172  // these lines calculate the observables to be used in the TtSemiJetCombination LR
173  //(*myLRJetCombObservables)(asol);
174 
175  (*myLRJetCombObservables)(asol, iEvent);
176 
177  // if asked for, calculate with these observable values the LRvalue and
178  // (depending on the configuration) probability a jet combination is correct
179  if (addLRJetComb_)
180  (*myLRJetCombCalc)(asol);
181 
182  //std::cout<<"SignalSelLRval = "<<asol.getLRSignalEvtLRval()<<" JetCombProb = "<<asol.getLRSignalEvtProb()<<std::endl;
183  //std::cout<<"JetCombLRval = "<<asol.getLRJetCombLRval()<<" JetCombProb = "<<asol.getLRJetCombProb()<<std::endl;
184 
185  // fill solution to vector
186  asol.setupHyp();
187  evtsols->push_back(asol);
188  }
189  }
190  }
191  }
192  }
193  }
194 
195  // if asked for, match the event solutions to the gen Event
196  if (matchToGenEvt_) {
197  int bestSolution = -999;
198  int bestSolutionChangeWQ = -999;
200  iEvent.getByToken(genEvtToken_, genEvt);
201  if (genEvt->numberOfBQuarks() ==
202  2 && // FIXME: in rare cases W->bc decay, resulting in a wrong filled genEvt leading to a segmentation fault
203  genEvt->numberOfLeptons() ==
204  1) { // FIXME: temporary solution to avoid crash in JetPartonMatching for non semi-leptonic events
205  std::vector<const reco::Candidate*> quarks;
206  const reco::Candidate& genp = *(genEvt->hadronicDecayQuark());
207  const reco::Candidate& genq = *(genEvt->hadronicDecayQuarkBar());
208  const reco::Candidate& genbh = *(genEvt->hadronicDecayB());
209  const reco::Candidate& genbl = *(genEvt->leptonicDecayB());
210  quarks.push_back(&genp);
211  quarks.push_back(&genq);
212  quarks.push_back(&genbh);
213  quarks.push_back(&genbl);
214  std::vector<const reco::Candidate*> recjets;
215  for (size_t s = 0; s < evtsols->size(); s++) {
216  recjets.clear();
217  const reco::Candidate& jetp = (*evtsols)[s].getRecHadp();
218  const reco::Candidate& jetq = (*evtsols)[s].getRecHadq();
219  const reco::Candidate& jetbh = (*evtsols)[s].getRecHadb();
220  const reco::Candidate& jetbl = (*evtsols)[s].getRecLepb();
221  recjets.push_back(&jetp);
222  recjets.push_back(&jetq);
223  recjets.push_back(&jetbh);
224  recjets.push_back(&jetbl);
225  JetPartonMatching aMatch(quarks, recjets, matchingAlgo_, useMaxDist_, useDeltaR_, maxDist_);
226  (*evtsols)[s].setGenEvt(genEvt);
227  (*evtsols)[s].setMCBestSumAngles(aMatch.getSumDistances());
228  (*evtsols)[s].setMCBestAngleHadp(aMatch.getDistanceForParton(0));
229  (*evtsols)[s].setMCBestAngleHadq(aMatch.getDistanceForParton(1));
230  (*evtsols)[s].setMCBestAngleHadb(aMatch.getDistanceForParton(2));
231  (*evtsols)[s].setMCBestAngleLepb(aMatch.getDistanceForParton(3));
232  if (aMatch.getMatchForParton(2) == 2 && aMatch.getMatchForParton(3) == 3) {
233  if (aMatch.getMatchForParton(0) == 0 && aMatch.getMatchForParton(1) == 1) {
234  bestSolution = s;
235  bestSolutionChangeWQ = 0;
236  } else if (aMatch.getMatchForParton(0) == 1 && aMatch.getMatchForParton(1) == 0) {
237  bestSolution = s;
238  bestSolutionChangeWQ = 1;
239  }
240  }
241  }
242  }
243  for (size_t s = 0; s < evtsols->size(); s++) {
244  (*evtsols)[s].setMCBestJetComb(bestSolution);
245  (*evtsols)[s].setMCChangeWQ(bestSolutionChangeWQ);
246  }
247  }
248 
249  // add TtSemiSimpleBestJetComb to solutions
250  int simpleBestJetComb = (*mySimpleBestJetComb)(*evtsols);
251  for (size_t s = 0; s < evtsols->size(); s++)
252  (*evtsols)[s].setSimpleBestJetComb(simpleBestJetComb);
253 
254  // choose the best jet combination according to LR value
255  if (addLRJetComb_ && !evtsols->empty()) {
256  float bestLRVal = -1000000;
257  int bestSol = (*evtsols)[0].getLRBestJetComb(); // duplicate the default
258  for (size_t s = 0; s < evtsols->size(); s++) {
259  if ((*evtsols)[s].getLRJetCombLRval() > bestLRVal) {
260  bestLRVal = (*evtsols)[s].getLRJetCombLRval();
261  bestSol = s;
262  }
263  }
264  for (size_t s = 0; s < evtsols->size(); s++) {
265  (*evtsols)[s].setLRBestJetComb(bestSol);
266  }
267  }
268 
269  //store the vector of solutions to the event
270  std::unique_ptr<std::vector<TtSemiEvtSolution> > pOut(evtsols);
271  iEvent.put(std::move(pOut));
272 
273  } else {
274  /*
275  std::cout<<"No calibrated solutions built, because: ";
276  if(jets->size()<4) std::cout<<"nr sel jets < 4"<<std::endl;
277  if(leptonFlavour_ == "muon" && muons->size() == 0) std::cout<<"no good muon candidate"<<std::endl;
278  if(leptonFlavour_ == "electron" && electrons->size() == 0) std::cout<<"no good electron candidate"<<std::endl;
279  if(mets->size() == 0) std::cout<<"no MET reconstruction"<<std::endl;
280  */
281  // TtSemiEvtSolution asol;
282  // evtsols->push_back(asol);
283  std::unique_ptr<std::vector<TtSemiEvtSolution> > pOut(evtsols);
284  iEvent.put(std::move(pOut));
285  }
286 }
void setLepb(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< std::vector< pat::Electron > > electronSrcToken_
TtSemiLepKinFitter * myKinFitter
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void setGenEvt(const edm::Handle< TtGenEvent > &aGenEvt)
edm::EDGetTokenT< std::vector< pat::Muon > > muonSrcToken_
void setHadp(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
void setLeptonParametrisation(int lp)
void setMuon(const edm::Handle< std::vector< pat::Muon > > &muon, int i)
int iEvent
Definition: GenABIO.cc:224
void setJetCorrectionScheme(int scheme)
vector< PseudoJet > jets
def move
Definition: eostools.py:511
edm::EDGetTokenT< std::vector< pat::MET > > metSrcToken_
void setJetParametrisation(int jp)
tuple genp
produce generated paricles in acceptance #
void setElectron(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
TtSemiEvtSolution addKinFitInfo(TtSemiEvtSolution *asol)
add kin fit information to the old event solution (in for legacy reasons)
edm::EDGetTokenT< std::vector< pat::Jet > > jetSrcToken_
void setNeutrinoParametrisation(int mp)
tuple muons
Definition: patZpeak.py:39
edm::EDGetTokenT< TtGenEvent > genEvtToken_
void setNeutrino(const edm::Handle< std::vector< pat::MET > > &met, int i)
void setHadb(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
void setHadq(const edm::Handle< std::vector< pat::Jet > > &jet, int i)

Member Data Documentation

bool TtSemiEvtSolutionMaker::addLRJetComb_
private
bool TtSemiEvtSolutionMaker::addLRSignalSel_
private
std::vector<unsigned> TtSemiEvtSolutionMaker::constraints_
private

Definition at line 55 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker().

bool TtSemiEvtSolutionMaker::doKinFit_
private
edm::EDGetTokenT<std::vector<pat::Electron> > TtSemiEvtSolutionMaker::electronSrcToken_
private

Definition at line 39 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

edm::EDGetTokenT<TtGenEvent> TtSemiEvtSolutionMaker::genEvtToken_
private

Definition at line 56 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

int TtSemiEvtSolutionMaker::jetCorrScheme_
private

Definition at line 44 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

int TtSemiEvtSolutionMaker::jetParam_
private

Definition at line 53 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

edm::EDGetTokenT<std::vector<pat::Jet> > TtSemiEvtSolutionMaker::jetSrcToken_
private

Definition at line 42 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

int TtSemiEvtSolutionMaker::lepParam_
private

Definition at line 53 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

std::string TtSemiEvtSolutionMaker::leptonFlavour_
private

Definition at line 43 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

std::string TtSemiEvtSolutionMaker::lrJetCombFile_
private

Definition at line 46 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker().

std::vector<int> TtSemiEvtSolutionMaker::lrJetCombObs_
private

Definition at line 54 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker().

std::string TtSemiEvtSolutionMaker::lrSignalSelFile_
private

Definition at line 46 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker().

std::vector<int> TtSemiEvtSolutionMaker::lrSignalSelObs_
private

Definition at line 54 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker().

int TtSemiEvtSolutionMaker::matchingAlgo_
private

Definition at line 48 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

bool TtSemiEvtSolutionMaker::matchToGenEvt_
private

Definition at line 47 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

double TtSemiEvtSolutionMaker::maxDeltaS_
private

Definition at line 52 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker().

double TtSemiEvtSolutionMaker::maxDist_
private

Definition at line 50 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

double TtSemiEvtSolutionMaker::maxF_
private

Definition at line 52 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker().

int TtSemiEvtSolutionMaker::maxNrIter_
private

Definition at line 51 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker().

int TtSemiEvtSolutionMaker::metParam_
private

Definition at line 53 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

edm::EDGetTokenT<std::vector<pat::MET> > TtSemiEvtSolutionMaker::metSrcToken_
private

Definition at line 41 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

edm::EDGetTokenT<std::vector<pat::Muon> > TtSemiEvtSolutionMaker::muonSrcToken_
private

Definition at line 40 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

TtSemiLepKinFitter* TtSemiEvtSolutionMaker::myKinFitter
private
TtSemiLRJetCombCalc* TtSemiEvtSolutionMaker::myLRJetCombCalc
private

Definition at line 61 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker(), and ~TtSemiEvtSolutionMaker().

TtSemiLRJetCombObservables* TtSemiEvtSolutionMaker::myLRJetCombObservables
private

Definition at line 60 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker(), and ~TtSemiEvtSolutionMaker().

TtSemiLRSignalSelCalc* TtSemiEvtSolutionMaker::myLRSignalSelCalc
private

Definition at line 63 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker(), and ~TtSemiEvtSolutionMaker().

TtSemiLRSignalSelObservables* TtSemiEvtSolutionMaker::myLRSignalSelObservables
private

Definition at line 62 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker(), and ~TtSemiEvtSolutionMaker().

TtSemiSimpleBestJetComb* TtSemiEvtSolutionMaker::mySimpleBestJetComb
private

Definition at line 59 of file TtSemiEvtSolutionMaker.h.

Referenced by TtSemiEvtSolutionMaker(), and ~TtSemiEvtSolutionMaker().

unsigned int TtSemiEvtSolutionMaker::nrCombJets_
private

Definition at line 45 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

bool TtSemiEvtSolutionMaker::useDeltaR_
private

Definition at line 49 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().

bool TtSemiEvtSolutionMaker::useMaxDist_
private

Definition at line 49 of file TtSemiEvtSolutionMaker.h.

Referenced by produce(), and TtSemiEvtSolutionMaker().