CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
TtFullLepKinSolutionProducer Class Reference
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 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 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<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
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)
 
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 ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
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< Bconsumes (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 ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
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 14 of file TtFullLepKinSolutionProducer.cc.

Constructor & Destructor Documentation

◆ TtFullLepKinSolutionProducer()

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

Definition at line 59 of file TtFullLepKinSolutionProducer.cc.

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

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

◆ ~TtFullLepKinSolutionProducer()

TtFullLepKinSolutionProducer::~TtFullLepKinSolutionProducer ( )
inlineoverride

Definition at line 85 of file TtFullLepKinSolutionProducer.cc.

85 {}

Member Function Documentation

◆ beginJob()

void TtFullLepKinSolutionProducer::beginJob ( void  )
inlineoverridevirtual

◆ endJob()

void TtFullLepKinSolutionProducer::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDProducer.

Definition at line 91 of file TtFullLepKinSolutionProducer.cc.

References solver.

91 { delete solver; }

◆ HasPositiveCharge()

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

Definition at line 55 of file TtFullLepKinSolutionProducer.cc.

References cmsLHEtoEOSManager::l.

Referenced by produce().

55  {
56  return (l->charge() > 0);
57 }

◆ LepDiffCharge()

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

Definition at line 51 of file TtFullLepKinSolutionProducer.cc.

References reco::Candidate::charge().

Referenced by produce().

51  {
52  return (l1->charge() != l2->charge());
53 }
virtual int charge() const =0
electric charge

◆ produce()

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

Implements edm::EDProducer.

Definition at line 93 of file TtFullLepKinSolutionProducer.cc.

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.

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

◆ PTComp()

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

Definition at line 47 of file TtFullLepKinSolutionProducer.cc.

References reco::Candidate::pt().

Referenced by produce().

47  {
48  return (l1->pt() > l2->pt());
49 }
virtual double pt() const =0
transverse momentum

Member Data Documentation

◆ eeChannel_

bool TtFullLepKinSolutionProducer::eeChannel_
private

Definition at line 40 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ electronsToken_

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

Definition at line 34 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ emuChannel_

bool TtFullLepKinSolutionProducer::emuChannel_
private

Definition at line 40 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ jetCorrLevel_

std::string TtFullLepKinSolutionProducer::jetCorrLevel_
private

Definition at line 38 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ jetsToken_

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

Definition at line 33 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ maxNComb_

int TtFullLepKinSolutionProducer::maxNComb_
private

Definition at line 39 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ maxNJets_

int TtFullLepKinSolutionProducer::maxNJets_
private

Definition at line 39 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ metsToken_

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

Definition at line 36 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ mumuChannel_

bool TtFullLepKinSolutionProducer::mumuChannel_
private

Definition at line 40 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ muonsToken_

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

Definition at line 35 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ nupars_

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

Definition at line 42 of file TtFullLepKinSolutionProducer.cc.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

◆ searchWrongCharge_

bool TtFullLepKinSolutionProducer::searchWrongCharge_
private

Definition at line 40 of file TtFullLepKinSolutionProducer.cc.

Referenced by produce(), and TtFullLepKinSolutionProducer().

◆ solver

TtFullLepKinSolver* TtFullLepKinSolutionProducer::solver
private

Definition at line 44 of file TtFullLepKinSolutionProducer.cc.

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

◆ tmassbegin_

double TtFullLepKinSolutionProducer::tmassbegin_
private

Definition at line 41 of file TtFullLepKinSolutionProducer.cc.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

◆ tmassend_

double TtFullLepKinSolutionProducer::tmassend_
private

Definition at line 41 of file TtFullLepKinSolutionProducer.cc.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().

◆ tmassstep_

double TtFullLepKinSolutionProducer::tmassstep_
private

Definition at line 41 of file TtFullLepKinSolutionProducer.cc.

Referenced by beginJob(), and TtFullLepKinSolutionProducer().