CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
TtFullLepKinSolutionProducer Class Reference

#include <TtFullLepKinSolutionProducer.h>

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

Classes

struct  Compare
 

Public Member Functions

void beginJob () override
 
void endJob () override
 
void produce (edm::Event &evt, const edm::EventSetup &iSetup) override
 
 TtFullLepKinSolutionProducer (const edm::ParameterSet &iConfig)
 
 ~TtFullLepKinSolutionProducer () override
 
- 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
 
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::vector< ModuleDescription const * > &modules, 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

bool HasPositiveCharge (const reco::Candidate *) const
 
bool LepDiffCharge (const reco::Candidate *, const reco::Candidate *) const
 
bool PTComp (const reco::Candidate *, const reco::Candidate *) const
 

Private Attributes

bool eeChannel_
 
edm::EDGetTokenT< std::vector< pat::Electron > > electronsToken_
 
bool emuChannel_
 
std::string jetCorrLevel_
 
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
 
int maxNComb_
 
int maxNJets_
 
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
 
bool mumuChannel_
 
edm::EDGetTokenT< std::vector< pat::Muon > > muonsToken_
 
std::vector< double > nupars_
 
bool searchWrongCharge_
 
TtFullLepKinSolversolver
 
double tmassbegin_
 
double tmassend_
 
double tmassstep_
 

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 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)
 
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<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)
 

Detailed Description

Definition at line 19 of file TtFullLepKinSolutionProducer.h.

Constructor & Destructor Documentation

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

Definition at line 64 of file TtFullLepKinSolutionProducer.h.

References eeChannel_, electronsToken_, emuChannel_, edm::ParameterSet::getParameter(), jetCorrLevel_, jetsToken_, maxNComb_, maxNJets_, metsToken_, mumuChannel_, muonsToken_, nupars_, searchWrongCharge_, AlCaHLTBitMon_QueryRunRegistry::string, tmassbegin_, tmassend_, and tmassstep_.

64  {
65  // configurables
66  jetsToken_ = consumes<std::vector<pat::Jet> >(iConfig.getParameter<edm::InputTag>("jets"));
67  electronsToken_ = consumes<std::vector<pat::Electron> >(iConfig.getParameter<edm::InputTag>("electrons"));
68  muonsToken_ = consumes<std::vector<pat::Muon> >(iConfig.getParameter<edm::InputTag>("muons"));
69  metsToken_ = consumes<std::vector<pat::MET> >(iConfig.getParameter<edm::InputTag>("mets"));
70  jetCorrLevel_ = iConfig.getParameter<std::string>("jetCorrectionLevel");
71  maxNJets_ = iConfig.getParameter<int>("maxNJets");
72  maxNComb_ = iConfig.getParameter<int>("maxNComb");
73  eeChannel_ = iConfig.getParameter<bool>("eeChannel");
74  emuChannel_ = iConfig.getParameter<bool>("emuChannel");
75  mumuChannel_ = iConfig.getParameter<bool>("mumuChannel");
76  searchWrongCharge_ = iConfig.getParameter<bool>("searchWrongCharge");
77  tmassbegin_ = iConfig.getParameter<double>("tmassbegin");
78  tmassend_ = iConfig.getParameter<double>("tmassend");
79  tmassstep_ = iConfig.getParameter<double>("tmassstep");
80  nupars_ = iConfig.getParameter<std::vector<double> >("neutrino_parameters");
81 
82  // define what will be produced
83  produces<std::vector<std::vector<int> > >(); // vector of the particle inices (b, bbar, e1, e2, mu1, mu2)
84  produces<std::vector<reco::LeafCandidate> >("fullLepNeutrinos");
85  produces<std::vector<reco::LeafCandidate> >("fullLepNeutrinoBars");
86  produces<std::vector<double> >("solWeight"); //weight for a specific kin solution
87  produces<bool>("isWrongCharge"); //true if leptons have the same charge
88 }
T getParameter(std::string const &) const
edm::EDGetTokenT< std::vector< pat::Muon > > muonsToken_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::EDGetTokenT< std::vector< pat::Electron > > electronsToken_
TtFullLepKinSolutionProducer::~TtFullLepKinSolutionProducer ( )
override

Definition at line 90 of file TtFullLepKinSolutionProducer.h.

90 {}

Member Function Documentation

void TtFullLepKinSolutionProducer::beginJob ( void  )
overridevirtual
void TtFullLepKinSolutionProducer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 96 of file TtFullLepKinSolutionProducer.h.

References solver.

96 { delete solver; }
bool TtFullLepKinSolutionProducer::HasPositiveCharge ( const reco::Candidate l) const
inlineprivate

Definition at line 60 of file TtFullLepKinSolutionProducer.h.

References reco::Candidate::charge().

Referenced by produce().

60  {
61  return (l->charge() > 0);
62 }
virtual int charge() const =0
electric charge
bool TtFullLepKinSolutionProducer::LepDiffCharge ( const reco::Candidate l1,
const reco::Candidate l2 
) const
inlineprivate

Definition at line 56 of file TtFullLepKinSolutionProducer.h.

References reco::Candidate::charge().

Referenced by produce().

56  {
57  return (l1->charge() != l2->charge());
58 }
virtual int charge() const =0
electric charge
void TtFullLepKinSolutionProducer::produce ( edm::Event evt,
const edm::EventSetup iSetup 
)
override

Definition at line 98 of file TtFullLepKinSolutionProducer.h.

References eeChannel_, pwdgSkimBPark_cfi::electrons, electronsToken_, emuChannel_, HCALHighEnergyHPDFilter_cfi::energy, dqmdumpme::first, edm::Event::getByToken(), TtFullLepKinSolver::getNuSolution(), HasPositiveCharge(), mps_fire::i, cuy::ib, createfilelist::int, jetCorrLevel_, singleTopDQM_cfi::jets, jetsToken_, LepDiffCharge(), maxNComb_, maxNJets_, singleTopDQM_cfi::mets, metsToken_, eostools::move(), mumuChannel_, PDWG_BPHSkim_cff::muons, muonsToken_, TtFullLepKinSolver::NeutrinoSolution::neutrino, TtFullLepKinSolver::NeutrinoSolution::neutrinoBar, PTComp(), edm::Event::put(), multPhiCorr_741_25nsDY_cfi::px, multPhiCorr_741_25nsDY_cfi::py, searchWrongCharge_, edm::second(), TtFullLepKinSolver::SetConstraints(), reco::Candidate::size, solver, and TtFullLepKinSolver::NeutrinoSolution::weight.

98  {
99  //create vectors fo runsorted output
100  std::vector<std::vector<int> > idcsV;
101  std::vector<reco::LeafCandidate> nusV;
102  std::vector<reco::LeafCandidate> nuBarsV;
103  std::vector<std::pair<double, int> > weightsV;
104 
105  //create pointer for products
106  std::unique_ptr<std::vector<std::vector<int> > > pIdcs(new std::vector<std::vector<int> >);
107  std::unique_ptr<std::vector<reco::LeafCandidate> > pNus(new std::vector<reco::LeafCandidate>);
108  std::unique_ptr<std::vector<reco::LeafCandidate> > pNuBars(new std::vector<reco::LeafCandidate>);
109  std::unique_ptr<std::vector<double> > pWeight(new std::vector<double>);
110  std::unique_ptr<bool> pWrongCharge(new bool);
111 
113  evt.getByToken(jetsToken_, jets);
115  evt.getByToken(electronsToken_, electrons);
117  evt.getByToken(muonsToken_, muons);
119  evt.getByToken(metsToken_, mets);
120 
121  int selMuon1 = -1, selMuon2 = -1;
122  int selElectron1 = -1, selElectron2 = -1;
123  bool ee = false;
124  bool emu = false;
125  bool mumu = false;
126  bool isWrongCharge = false;
127  bool jetsFound = false;
128  bool METFound = false;
129  bool electronsFound = false;
130  bool electronMuonFound = false;
131  bool muonsFound = false;
132 
133  //select Jets (TopJet vector is sorted on ET)
134  if (jets->size() >= 2) {
135  jetsFound = true;
136  }
137 
138  //select MET (TopMET vector is sorted on ET)
139  if (!mets->empty()) {
140  METFound = true;
141  }
142 
143  // If we have electrons and muons available,
144  // build a solutions with electrons and muons.
145  if (muons->size() + electrons->size() >= 2) {
146  // select leptons
147  if (electrons->empty())
148  mumu = true;
149  else if (muons->empty())
150  ee = true;
151  else if (electrons->size() == 1) {
152  if (muons->size() == 1)
153  emu = true;
154  else if (PTComp(&(*electrons)[0], &(*muons)[1]))
155  emu = true;
156  else
157  mumu = true;
158  } else if (electrons->size() > 1) {
159  if (PTComp(&(*electrons)[1], &(*muons)[0]))
160  ee = true;
161  else if (muons->size() == 1)
162  emu = true;
163  else if (PTComp(&(*electrons)[0], &(*muons)[1]))
164  emu = true;
165  else
166  mumu = true;
167  }
168  if (ee && eeChannel_) {
169  if (LepDiffCharge(&(*electrons)[0], &(*electrons)[1]) || searchWrongCharge_) {
170  if (HasPositiveCharge(&(*electrons)[0]) || !LepDiffCharge(&(*electrons)[0], &(*electrons)[1])) {
171  selElectron1 = 0;
172  selElectron2 = 1;
173  } else {
174  selElectron1 = 1;
175  selElectron2 = 0;
176  }
177  electronsFound = true;
178  if (!LepDiffCharge(&(*electrons)[0], &(*electrons)[1]))
179  isWrongCharge = true;
180  }
181  } else if (emu && emuChannel_) {
182  if (LepDiffCharge(&(*electrons)[0], &(*muons)[0]) || searchWrongCharge_) {
183  selElectron1 = 0;
184  selMuon1 = 0;
185  electronMuonFound = true;
186  if (!LepDiffCharge(&(*electrons)[0], &(*muons)[0]))
187  isWrongCharge = true;
188  }
189  } else if (mumu && mumuChannel_) {
190  if (LepDiffCharge(&(*muons)[0], &(*muons)[1]) || searchWrongCharge_) {
191  if (HasPositiveCharge(&(*muons)[0]) || !LepDiffCharge(&(*muons)[0], &(*muons)[1])) {
192  selMuon1 = 0;
193  selMuon2 = 1;
194  } else {
195  selMuon1 = 1;
196  selMuon2 = 0;
197  }
198  muonsFound = true;
199  if (!LepDiffCharge(&(*muons)[0], &(*muons)[1]))
200  isWrongCharge = true;
201  }
202  }
203  }
204 
205  *pWrongCharge = isWrongCharge;
206 
207  // Check that the above work makes sense
208  if (int(ee) + int(emu) + int(mumu) > 1) {
209  edm::LogWarning("TtFullLepKinSolutionProducer") << "Lepton selection criteria uncorrectly defined";
210  }
211 
212  // Check if the leptons for the required Channel are available
213  bool correctLeptons =
214  ((electronsFound && eeChannel_) || (muonsFound && mumuChannel_) || (electronMuonFound && emuChannel_));
215  // Check for equally charged leptons if for wrong charge combinations is searched
216  if (isWrongCharge) {
217  correctLeptons = correctLeptons && searchWrongCharge_;
218  }
219 
220  if (correctLeptons && METFound && jetsFound) {
221  // run over all jets if input parameter maxNJets is -1 or
222  // adapt maxNJets if number of present jets is smaller than selected
223  // number of jets
224  int stop = maxNJets_;
225  if (jets->size() < static_cast<unsigned int>(stop) || stop < 0)
226  stop = jets->size();
227 
228  // counter for number of found kinematic solutions
229  int nSol = 0;
230 
231  // consider all permutations
232  for (int ib = 0; ib < stop; ib++) {
233  // second loop of the permutations
234  for (int ibbar = 0; ibbar < stop; ibbar++) {
235  // avoid the diagonal: b and bbar must be distinct jets
236  if (ib == ibbar)
237  continue;
238 
239  std::vector<int> idcs;
240 
241  // push back the indices of the jets
242  idcs.push_back(ib);
243  idcs.push_back(ibbar);
244 
245  TLorentzVector LV_l1;
246  TLorentzVector LV_l2;
247  TLorentzVector LV_b = TLorentzVector((*jets)[ib].correctedJet(jetCorrLevel_, "bottom").px(),
248  (*jets)[ib].correctedJet(jetCorrLevel_, "bottom").py(),
249  (*jets)[ib].correctedJet(jetCorrLevel_, "bottom").pz(),
250  (*jets)[ib].correctedJet(jetCorrLevel_, "bottom").energy());
251  TLorentzVector LV_bbar = TLorentzVector((*jets)[ibbar].correctedJet(jetCorrLevel_, "bottom").px(),
252  (*jets)[ibbar].correctedJet(jetCorrLevel_, "bottom").py(),
253  (*jets)[ibbar].correctedJet(jetCorrLevel_, "bottom").pz(),
254  (*jets)[ibbar].correctedJet(jetCorrLevel_, "bottom").energy());
255 
256  double xconstraint = 0, yconstraint = 0;
257 
258  if (ee) {
259  idcs.push_back(selElectron1);
260  LV_l1.SetXYZT((*electrons)[selElectron1].px(),
261  (*electrons)[selElectron1].py(),
262  (*electrons)[selElectron1].pz(),
263  (*electrons)[selElectron1].energy());
264  xconstraint += (*electrons)[selElectron1].px();
265  yconstraint += (*electrons)[selElectron1].py();
266 
267  idcs.push_back(selElectron2);
268  LV_l2.SetXYZT((*electrons)[selElectron2].px(),
269  (*electrons)[selElectron2].py(),
270  (*electrons)[selElectron2].pz(),
271  (*electrons)[selElectron2].energy());
272  xconstraint += (*electrons)[selElectron2].px();
273  yconstraint += (*electrons)[selElectron2].py();
274 
275  idcs.push_back(-1);
276  idcs.push_back(-1);
277  }
278 
279  else if (emu) {
280  if (!isWrongCharge) {
281  if (HasPositiveCharge(&(*electrons)[selElectron1])) {
282  idcs.push_back(selElectron1);
283  LV_l1.SetXYZT((*electrons)[selElectron1].px(),
284  (*electrons)[selElectron1].py(),
285  (*electrons)[selElectron1].pz(),
286  (*electrons)[selElectron1].energy());
287  xconstraint += (*electrons)[selElectron1].px();
288  yconstraint += (*electrons)[selElectron1].py();
289 
290  idcs.push_back(-1);
291  idcs.push_back(-1);
292 
293  idcs.push_back(selMuon1);
294  LV_l2.SetXYZT((*muons)[selMuon1].px(),
295  (*muons)[selMuon1].py(),
296  (*muons)[selMuon1].pz(),
297  (*muons)[selMuon1].energy());
298  xconstraint += (*muons)[selMuon1].px();
299  yconstraint += (*muons)[selMuon1].py();
300  } else {
301  idcs.push_back(-1);
302 
303  idcs.push_back(selMuon1);
304  LV_l1.SetXYZT((*muons)[selMuon1].px(),
305  (*muons)[selMuon1].py(),
306  (*muons)[selMuon1].pz(),
307  (*muons)[selMuon1].energy());
308  xconstraint += (*muons)[selMuon1].px();
309  yconstraint += (*muons)[selMuon1].py();
310 
311  idcs.push_back(selElectron1);
312  LV_l2.SetXYZT((*electrons)[selElectron1].px(),
313  (*electrons)[selElectron1].py(),
314  (*electrons)[selElectron1].pz(),
315  (*electrons)[selElectron1].energy());
316  xconstraint += (*electrons)[selElectron1].px();
317  yconstraint += (*electrons)[selElectron1].py();
318 
319  idcs.push_back(-1);
320  }
321  } else { // means "if wrong charge"
322  if (HasPositiveCharge(&(*electrons)[selElectron1])) { // both leps positive
323  idcs.push_back(selElectron1);
324  LV_l1.SetXYZT((*electrons)[selElectron1].px(),
325  (*electrons)[selElectron1].py(),
326  (*electrons)[selElectron1].pz(),
327  (*electrons)[selElectron1].energy());
328  xconstraint += (*electrons)[selElectron1].px();
329  yconstraint += (*electrons)[selElectron1].py();
330 
331  idcs.push_back(-1);
332 
333  idcs.push_back(selMuon1);
334  LV_l2.SetXYZT((*muons)[selMuon1].px(),
335  (*muons)[selMuon1].py(),
336  (*muons)[selMuon1].pz(),
337  (*muons)[selMuon1].energy());
338  xconstraint += (*muons)[selMuon1].px();
339  yconstraint += (*muons)[selMuon1].py();
340 
341  idcs.push_back(-1);
342  } else { // both leps negative
343  idcs.push_back(-1);
344 
345  idcs.push_back(selElectron1);
346  LV_l2.SetXYZT((*electrons)[selElectron1].px(),
347  (*electrons)[selElectron1].py(),
348  (*electrons)[selElectron1].pz(),
349  (*electrons)[selElectron1].energy());
350  xconstraint += (*electrons)[selElectron1].px();
351  yconstraint += (*electrons)[selElectron1].py();
352 
353  idcs.push_back(-1);
354 
355  idcs.push_back(selMuon1);
356  LV_l1.SetXYZT((*muons)[selMuon1].px(),
357  (*muons)[selMuon1].py(),
358  (*muons)[selMuon1].pz(),
359  (*muons)[selMuon1].energy());
360  xconstraint += (*muons)[selMuon1].px();
361  yconstraint += (*muons)[selMuon1].py();
362  }
363  }
364  }
365 
366  else if (mumu) {
367  idcs.push_back(-1);
368  idcs.push_back(-1);
369 
370  idcs.push_back(selMuon1);
371  LV_l1.SetXYZT(
372  (*muons)[selMuon1].px(), (*muons)[selMuon1].py(), (*muons)[selMuon1].pz(), (*muons)[selMuon1].energy());
373  xconstraint += (*muons)[selMuon1].px();
374  yconstraint += (*muons)[selMuon1].py();
375 
376  idcs.push_back(selMuon2);
377  LV_l2.SetXYZT(
378  (*muons)[selMuon2].px(), (*muons)[selMuon2].py(), (*muons)[selMuon2].pz(), (*muons)[selMuon2].energy());
379  xconstraint += (*muons)[selMuon2].px();
380  yconstraint += (*muons)[selMuon2].py();
381  }
382 
383  xconstraint += (*jets)[ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
384  yconstraint += (*jets)[ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
385 
386  // calculate neutrino momenta and eventweight
387  solver->SetConstraints(xconstraint, yconstraint);
388  TtFullLepKinSolver::NeutrinoSolution nuSol = solver->getNuSolution(LV_l1, LV_l2, LV_b, LV_bbar);
389 
390  // add solution to the vectors of solutions if solution exists
391  if (nuSol.weight > 0) {
392  // add the leptons and jets indices to the vector of combinations
393  idcsV.push_back(idcs);
394 
395  // add the neutrinos
396  nusV.push_back(nuSol.neutrino);
397  nuBarsV.push_back(nuSol.neutrinoBar);
398 
399  // add the solution weight
400  weightsV.push_back(std::make_pair(nuSol.weight, nSol));
401 
402  nSol++;
403  }
404  }
405  }
406  }
407 
408  if (weightsV.empty()) {
409  //create dmummy vector
410  std::vector<int> idcs;
411  for (int i = 0; i < 6; ++i)
412  idcs.push_back(-1);
413 
414  idcsV.push_back(idcs);
415  weightsV.push_back(std::make_pair(-1, 0));
417  nusV.push_back(nu);
418  reco::LeafCandidate nuBar;
419  nuBarsV.push_back(nuBar);
420  }
421 
422  // check if all vectors have correct length
423  int weightL = weightsV.size();
424  int nuL = nusV.size();
425  int nuBarL = nuBarsV.size();
426  int idxL = idcsV.size();
427 
428  if (weightL != nuL || weightL != nuBarL || weightL != idxL) {
429  edm::LogWarning("TtFullLepKinSolutionProducer")
430  << "Output vectors are of different length:"
431  << "\n weight: " << weightL << "\n nu: " << nuL << "\n nubar: " << nuBarL << "\n idcs: " << idxL;
432  }
433 
434  // sort vectors by weight in decreasing order
435  if (weightsV.size() > 1) {
436  sort(weightsV.begin(), weightsV.end(), Compare());
437  }
438 
439  // determine the number of solutions which is written in the event
440  int stop = weightL;
441  if (maxNComb_ > 0 && maxNComb_ < stop)
442  stop = maxNComb_;
443 
444  for (int i = 0; i < stop; ++i) {
445  pWeight->push_back(weightsV[i].first);
446  pNus->push_back(nusV[weightsV[i].second]);
447  pNuBars->push_back(nuBarsV[weightsV[i].second]);
448  pIdcs->push_back(idcsV[weightsV[i].second]);
449  }
450 
451  // put the results in the event
452  evt.put(std::move(pIdcs));
453  evt.put(std::move(pNus), "fullLepNeutrinos");
454  evt.put(std::move(pNuBars), "fullLepNeutrinoBars");
455  evt.put(std::move(pWeight), "solWeight");
456  evt.put(std::move(pWrongCharge), "isWrongCharge");
457 }
edm::EDGetTokenT< std::vector< pat::Muon > > muonsToken_
bool LepDiffCharge(const reco::Candidate *, const reco::Candidate *) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
NeutrinoSolution getNuSolution(const TLorentzVector &LV_l, const TLorentzVector &LV_l_, const TLorentzVector &LV_b, const TLorentzVector &LV_b_)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
bool HasPositiveCharge(const reco::Candidate *) const
void SetConstraints(const double xx=0, const double yy=0)
U second(std::pair< T, U > const &p)
bool PTComp(const reco::Candidate *, const reco::Candidate *) const
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
edm::EDGetTokenT< std::vector< pat::Electron > > electronsToken_
def move(src, dest)
Definition: eostools.py:511
ib
Definition: cuy.py:662
bool TtFullLepKinSolutionProducer::PTComp ( const reco::Candidate l1,
const reco::Candidate l2 
) const
inlineprivate

Definition at line 52 of file TtFullLepKinSolutionProducer.h.

References reco::Candidate::pt().

Referenced by produce().

52  {
53  return (l1->pt() > l2->pt());
54 }
virtual double pt() const =0
transverse momentum

Member Data Documentation

bool TtFullLepKinSolutionProducer::eeChannel_
private

Definition at line 45 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

edm::EDGetTokenT<std::vector<pat::Electron> > TtFullLepKinSolutionProducer::electronsToken_
private

Definition at line 39 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

bool TtFullLepKinSolutionProducer::emuChannel_
private

Definition at line 45 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

std::string TtFullLepKinSolutionProducer::jetCorrLevel_
private

Definition at line 43 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

edm::EDGetTokenT<std::vector<pat::Jet> > TtFullLepKinSolutionProducer::jetsToken_
private

Definition at line 38 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

int TtFullLepKinSolutionProducer::maxNComb_
private

Definition at line 44 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

int TtFullLepKinSolutionProducer::maxNJets_
private

Definition at line 44 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

edm::EDGetTokenT<std::vector<pat::MET> > TtFullLepKinSolutionProducer::metsToken_
private

Definition at line 41 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

bool TtFullLepKinSolutionProducer::mumuChannel_
private

Definition at line 45 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

edm::EDGetTokenT<std::vector<pat::Muon> > TtFullLepKinSolutionProducer::muonsToken_
private

Definition at line 40 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

std::vector<double> TtFullLepKinSolutionProducer::nupars_
private

Definition at line 47 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

bool TtFullLepKinSolutionProducer::searchWrongCharge_
private

Definition at line 45 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

TtFullLepKinSolver* TtFullLepKinSolutionProducer::solver
private

Definition at line 49 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), endJob(), and produce().

double TtFullLepKinSolutionProducer::tmassbegin_
private

Definition at line 46 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

double TtFullLepKinSolutionProducer::tmassend_
private

Definition at line 46 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

double TtFullLepKinSolutionProducer::tmassstep_
private

Definition at line 46 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().