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
 
std::vector< bool > const & recordProvenanceList () 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)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~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 &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

Definition at line 19 of file TtFullLepKinSolutionProducer.h.

Constructor & Destructor Documentation

◆ TtFullLepKinSolutionProducer()

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

Definition at line 64 of file TtFullLepKinSolutionProducer.h.

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 }

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

◆ ~TtFullLepKinSolutionProducer()

TtFullLepKinSolutionProducer::~TtFullLepKinSolutionProducer ( )
inlineoverride

Definition at line 90 of file TtFullLepKinSolutionProducer.h.

90 {}

Member Function Documentation

◆ beginJob()

void TtFullLepKinSolutionProducer::beginJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDProducer.

Definition at line 92 of file TtFullLepKinSolutionProducer.h.

References nupars_, solver, tmassbegin_, tmassend_, and tmassstep_.

◆ endJob()

void TtFullLepKinSolutionProducer::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDProducer.

Definition at line 96 of file TtFullLepKinSolutionProducer.h.

96 { delete solver; }

References solver.

◆ HasPositiveCharge()

bool TtFullLepKinSolutionProducer::HasPositiveCharge ( const reco::Candidate l) const
inlineprivate

Definition at line 60 of file TtFullLepKinSolutionProducer.h.

60  {
61  return (l->charge() > 0);
62 }

References cmsLHEtoEOSManager::l.

Referenced by produce().

◆ LepDiffCharge()

bool TtFullLepKinSolutionProducer::LepDiffCharge ( const reco::Candidate l1,
const reco::Candidate l2 
) const
inlineprivate

Definition at line 56 of file TtFullLepKinSolutionProducer.h.

56  {
57  return (l1->charge() != l2->charge());
58 }

References reco::Candidate::charge().

Referenced by produce().

◆ produce()

void TtFullLepKinSolutionProducer::produce ( edm::Event evt,
const edm::EventSetup iSetup 
)
inlineoverridevirtual

Implements edm::EDProducer.

Definition at line 98 of file TtFullLepKinSolutionProducer.h.

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);
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  idcs.reserve(6);
412  for (int i = 0; i < 6; ++i)
413  idcs.push_back(-1);
414 
415  idcsV.push_back(idcs);
416  weightsV.push_back(std::make_pair(-1, 0));
418  nusV.push_back(nu);
419  reco::LeafCandidate nuBar;
420  nuBarsV.push_back(nuBar);
421  }
422 
423  // check if all vectors have correct length
424  int weightL = weightsV.size();
425  int nuL = nusV.size();
426  int nuBarL = nuBarsV.size();
427  int idxL = idcsV.size();
428 
429  if (weightL != nuL || weightL != nuBarL || weightL != idxL) {
430  edm::LogWarning("TtFullLepKinSolutionProducer")
431  << "Output vectors are of different length:"
432  << "\n weight: " << weightL << "\n nu: " << nuL << "\n nubar: " << nuBarL << "\n idcs: " << idxL;
433  }
434 
435  // sort vectors by weight in decreasing order
436  if (weightsV.size() > 1) {
437  sort(weightsV.begin(), weightsV.end(), Compare());
438  }
439 
440  // determine the number of solutions which is written in the event
441  int stop = weightL;
442  if (maxNComb_ > 0 && maxNComb_ < stop)
443  stop = maxNComb_;
444 
445  for (int i = 0; i < stop; ++i) {
446  pWeight->push_back(weightsV[i].first);
447  pNus->push_back(nusV[weightsV[i].second]);
448  pNuBars->push_back(nuBarsV[weightsV[i].second]);
449  pIdcs->push_back(idcsV[weightsV[i].second]);
450  }
451 
452  // put the results in the event
453  evt.put(std::move(pIdcs));
454  evt.put(std::move(pNus), "fullLepNeutrinos");
455  evt.put(std::move(pNuBars), "fullLepNeutrinoBars");
456  evt.put(std::move(pWeight), "solWeight");
457  evt.put(std::move(pWrongCharge), "isWrongCharge");
458 }

References eeChannel_, pwdgSkimBPark_cfi::electrons, electronsToken_, emuChannel_, HCALHighEnergyHPDFilter_cfi::energy, 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, jetUpdater_cfi::sort, trackerHitRTTI::vector, and TtFullLepKinSolver::NeutrinoSolution::weight.

◆ PTComp()

bool TtFullLepKinSolutionProducer::PTComp ( const reco::Candidate l1,
const reco::Candidate l2 
) const
inlineprivate

Definition at line 52 of file TtFullLepKinSolutionProducer.h.

52  {
53  return (l1->pt() > l2->pt());
54 }

References reco::Candidate::pt().

Referenced by produce().

Member Data Documentation

◆ eeChannel_

bool TtFullLepKinSolutionProducer::eeChannel_
private

Definition at line 45 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ electronsToken_

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

Definition at line 39 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ emuChannel_

bool TtFullLepKinSolutionProducer::emuChannel_
private

Definition at line 45 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ jetCorrLevel_

std::string TtFullLepKinSolutionProducer::jetCorrLevel_
private

Definition at line 43 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ jetsToken_

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

Definition at line 38 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ maxNComb_

int TtFullLepKinSolutionProducer::maxNComb_
private

Definition at line 44 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ maxNJets_

int TtFullLepKinSolutionProducer::maxNJets_
private

Definition at line 44 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ metsToken_

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

Definition at line 41 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ mumuChannel_

bool TtFullLepKinSolutionProducer::mumuChannel_
private

Definition at line 45 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ muonsToken_

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

Definition at line 40 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ nupars_

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

Definition at line 47 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

◆ searchWrongCharge_

bool TtFullLepKinSolutionProducer::searchWrongCharge_
private

Definition at line 45 of file TtFullLepKinSolutionProducer.h.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ solver

TtFullLepKinSolver* TtFullLepKinSolutionProducer::solver
private

Definition at line 49 of file TtFullLepKinSolutionProducer.h.

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

◆ tmassbegin_

double TtFullLepKinSolutionProducer::tmassbegin_
private

Definition at line 46 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

◆ tmassend_

double TtFullLepKinSolutionProducer::tmassend_
private

Definition at line 46 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

◆ tmassstep_

double TtFullLepKinSolutionProducer::tmassstep_
private

Definition at line 46 of file TtFullLepKinSolutionProducer.h.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
mps_fire.i
i
Definition: mps_fire.py:428
TtFullLepKinSolutionProducer::jetsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
Definition: TtFullLepKinSolutionProducer.h:38
TtFullLepKinSolutionProducer::searchWrongCharge_
bool searchWrongCharge_
Definition: TtFullLepKinSolutionProducer.h:45
TtFullLepKinSolutionProducer::tmassstep_
double tmassstep_
Definition: TtFullLepKinSolutionProducer.h:46
multPhiCorr_741_25nsDY_cfi.py
py
Definition: multPhiCorr_741_25nsDY_cfi.py:12
TtFullLepKinSolutionProducer::maxNComb_
int maxNComb_
Definition: TtFullLepKinSolutionProducer.h:44
TtFullLepKinSolutionProducer::LepDiffCharge
bool LepDiffCharge(const reco::Candidate *, const reco::Candidate *) const
Definition: TtFullLepKinSolutionProducer.h:56
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
TtFullLepKinSolver::SetConstraints
void SetConstraints(const double xx=0, const double yy=0)
Definition: TtFullLepKinSolver.cc:120
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
TtFullLepKinSolutionProducer::emuChannel_
bool emuChannel_
Definition: TtFullLepKinSolutionProducer.h:45
TtFullLepKinSolver::NeutrinoSolution::neutrino
reco::LeafCandidate neutrino
Definition: TtFullLepKinSolver.h:30
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
singleTopDQM_cfi.mets
mets
Definition: singleTopDQM_cfi.py:43
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
TtFullLepKinSolutionProducer::tmassend_
double tmassend_
Definition: TtFullLepKinSolutionProducer.h:46
TtFullLepKinSolutionProducer::HasPositiveCharge
bool HasPositiveCharge(const reco::Candidate *) const
Definition: TtFullLepKinSolutionProducer.h:60
TtFullLepKinSolutionProducer::PTComp
bool PTComp(const reco::Candidate *, const reco::Candidate *) const
Definition: TtFullLepKinSolutionProducer.h:52
TtFullLepKinSolutionProducer::jetCorrLevel_
std::string jetCorrLevel_
Definition: TtFullLepKinSolutionProducer.h:43
TtFullLepKinSolutionProducer::mumuChannel_
bool mumuChannel_
Definition: TtFullLepKinSolutionProducer.h:45
TtFullLepKinSolver::NeutrinoSolution::weight
double weight
Definition: TtFullLepKinSolver.h:29
TtFullLepKinSolutionProducer::tmassbegin_
double tmassbegin_
Definition: TtFullLepKinSolutionProducer.h:46
TtFullLepKinSolver::getNuSolution
NeutrinoSolution getNuSolution(const TLorentzVector &LV_l, const TLorentzVector &LV_l_, const TLorentzVector &LV_b, const TLorentzVector &LV_b_)
Definition: TtFullLepKinSolver.cc:125
reco::Candidate::charge
virtual int charge() const =0
electric charge
TtFullLepKinSolutionProducer::electronsToken_
edm::EDGetTokenT< std::vector< pat::Electron > > electronsToken_
Definition: TtFullLepKinSolutionProducer.h:39
TtFullLepKinSolver::NeutrinoSolution
Definition: TtFullLepKinSolver.h:28
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
TtFullLepKinSolutionProducer::muonsToken_
edm::EDGetTokenT< std::vector< pat::Muon > > muonsToken_
Definition: TtFullLepKinSolutionProducer.h:40
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:125
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
TtFullLepKinSolver::NeutrinoSolution::neutrinoBar
reco::LeafCandidate neutrinoBar
Definition: TtFullLepKinSolver.h:31
createfilelist.int
int
Definition: createfilelist.py:10
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
TtFullLepKinSolutionProducer::solver
TtFullLepKinSolver * solver
Definition: TtFullLepKinSolutionProducer.h:49
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
cuy.ib
ib
Definition: cuy.py:661
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
multPhiCorr_741_25nsDY_cfi.px
px
Definition: multPhiCorr_741_25nsDY_cfi.py:10
TtFullLepKinSolutionProducer::maxNJets_
int maxNJets_
Definition: TtFullLepKinSolutionProducer.h:44
eostools.move
def move(src, dest)
Definition: eostools.py:511
reco::Candidate::size
Definition: Candidate.h:48
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
TtFullLepKinSolutionProducer::nupars_
std::vector< double > nupars_
Definition: TtFullLepKinSolutionProducer.h:47
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TtFullLepKinSolutionProducer::eeChannel_
bool eeChannel_
Definition: TtFullLepKinSolutionProducer.h:45
reco::LeafCandidate
Definition: LeafCandidate.h:16
TtFullLepKinSolutionProducer::metsToken_
edm::EDGetTokenT< std::vector< pat::MET > > metsToken_
Definition: TtFullLepKinSolutionProducer.h:41
edm::InputTag
Definition: InputTag.h:15
TtFullLepKinSolver
Definition: TtFullLepKinSolver.h:25