CMS 3D CMS Logo

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

#include <TtDilepEvtSolutionMaker.h>

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

Public Member Functions

void beginJob () override
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 TtDilepEvtSolutionMaker (const edm::ParameterSet &iConfig)
 
 ~TtDilepEvtSolutionMaker () 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
 
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
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
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 calcTopMass_
 
bool eeChannel_
 
edm::EDGetTokenT< std::vector< pat::Electron > > electronSourceToken_
 
bool emuChannel_
 
bool etauChannel_
 
edm::EDGetTokenT< TtGenEventevtSourceToken_
 
int jetCorrScheme_
 
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
 
bool matchToGenEvt_
 
edm::EDGetTokenT< std::vector< pat::MET > > metSourceToken_
 
bool mumuChannel_
 
edm::EDGetTokenT< std::vector< pat::Muon > > muonSourceToken_
 
bool mutauChannel_
 
TtDilepLRSignalSelObservablesmyLRSignalSelObservables
 
unsigned int nrCombJets_
 
std::vector< double > nupars_
 
TtFullLepKinSolversolver
 
edm::EDGetTokenT< std::vector< pat::Tau > > tauSourceToken_
 
bool tautauChannel_
 
double tmassbegin_
 
double tmassend_
 
double tmassstep_
 
bool useMCforBest_
 

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
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>
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)
 
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 14 of file TtDilepEvtSolutionMaker.h.

Constructor & Destructor Documentation

◆ TtDilepEvtSolutionMaker()

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

Definition at line 15 of file TtDilepEvtSolutionMaker.cc.

15  {
16  // configurables
17  electronSourceToken_ = consumes<std::vector<pat::Electron> >(iConfig.getParameter<edm::InputTag>("electronSource"));
18  muonSourceToken_ = consumes<std::vector<pat::Muon> >(iConfig.getParameter<edm::InputTag>("muonSource"));
19  tauSourceToken_ = consumes<std::vector<pat::Tau> >(iConfig.getParameter<edm::InputTag>("tauSource"));
20  metSourceToken_ = consumes<std::vector<pat::MET> >(iConfig.getParameter<edm::InputTag>("metSource"));
21  jetSourceToken_ = consumes<std::vector<pat::Jet> >(iConfig.getParameter<edm::InputTag>("jetSource"));
22  jetCorrScheme_ = iConfig.getParameter<int>("jetCorrectionScheme");
23  evtSourceToken_ = mayConsume<TtGenEvent>(iConfig.getParameter<edm::InputTag>("evtSource"));
24  nrCombJets_ = iConfig.getParameter<unsigned int>("nrCombJets");
25  matchToGenEvt_ = iConfig.getParameter<bool>("matchToGenEvt");
26  calcTopMass_ = iConfig.getParameter<bool>("calcTopMass");
27  useMCforBest_ = iConfig.getParameter<bool>("bestSolFromMC");
28  eeChannel_ = iConfig.getParameter<bool>("eeChannel");
29  emuChannel_ = iConfig.getParameter<bool>("emuChannel");
30  mumuChannel_ = iConfig.getParameter<bool>("mumuChannel");
31  mutauChannel_ = iConfig.getParameter<bool>("mutauChannel");
32  etauChannel_ = iConfig.getParameter<bool>("etauChannel");
33  tautauChannel_ = iConfig.getParameter<bool>("tautauChannel");
34  tmassbegin_ = iConfig.getParameter<double>("tmassbegin");
35  tmassend_ = iConfig.getParameter<double>("tmassend");
36  tmassstep_ = iConfig.getParameter<double>("tmassstep");
37  nupars_ = iConfig.getParameter<std::vector<double> >("neutrino_parameters");
38 
39  // define what will be produced
40  produces<std::vector<TtDilepEvtSolution> >();
41 
43 }

References calcTopMass_, edm::EDConsumerBase::consumesCollector(), eeChannel_, electronSourceToken_, emuChannel_, etauChannel_, evtSourceToken_, edm::ParameterSet::getParameter(), jetCorrScheme_, jetSourceToken_, matchToGenEvt_, metSourceToken_, mumuChannel_, muonSourceToken_, mutauChannel_, myLRSignalSelObservables, nrCombJets_, nupars_, tauSourceToken_, tautauChannel_, tmassbegin_, tmassend_, tmassstep_, and useMCforBest_.

◆ ~TtDilepEvtSolutionMaker()

TtDilepEvtSolutionMaker::~TtDilepEvtSolutionMaker ( )
override

Definition at line 45 of file TtDilepEvtSolutionMaker.cc.

45 {}

Member Function Documentation

◆ beginJob()

void TtDilepEvtSolutionMaker::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 47 of file TtDilepEvtSolutionMaker.cc.

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

◆ HasPositiveCharge()

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

Definition at line 54 of file TtDilepEvtSolutionMaker.h.

54 { return (l->charge() > 0); }

References cmsLHEtoEOSManager::l.

Referenced by produce().

◆ LepDiffCharge()

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

Definition at line 50 of file TtDilepEvtSolutionMaker.h.

50  {
51  return (l1->charge() != l2->charge());
52 }

References reco::Candidate::charge().

Referenced by produce().

◆ produce()

void TtDilepEvtSolutionMaker::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 51 of file TtDilepEvtSolutionMaker.cc.

51  {
53  iEvent.getByToken(tauSourceToken_, taus);
55  iEvent.getByToken(muonSourceToken_, muons);
59  iEvent.getByToken(metSourceToken_, mets);
61  iEvent.getByToken(jetSourceToken_, jets);
62 
63  int selMuonp = -1, selMuonm = -1;
64  int selElectronp = -1, selElectronm = -1;
65  int selTaup = -1, selTaum = -1;
66  bool leptonFound = false;
67  bool mumu = false;
68  bool emu = false;
69  bool ee = false;
70  bool etau = false;
71  bool mutau = false;
72  bool tautau = false;
73  bool leptonFoundEE = false;
74  bool leptonFoundMM = false;
75  bool leptonFoundTT = false;
76  bool leptonFoundEpMm = false;
77  bool leptonFoundEmMp = false;
78  bool leptonFoundEpTm = false;
79  bool leptonFoundEmTp = false;
80  bool leptonFoundMpTm = false;
81  bool leptonFoundMmTp = false;
82  bool jetsFound = false;
83  bool METFound = false;
84  std::vector<int> JetVetoByTaus;
85 
86  //select MET (TopMET vector is sorted on ET)
87  if (!mets->empty()) {
88  METFound = true;
89  }
90 
91  // If we have electrons and muons available,
92  // build a solutions with electrons and muons.
93  if (muons->size() + electrons->size() >= 2) {
94  // select leptons
95  if (electrons->empty())
96  mumu = true;
97  else if (muons->empty())
98  ee = true;
99  else if (electrons->size() == 1) {
100  if (muons->size() == 1)
101  emu = true;
102  else if (PTComp(&(*electrons)[0], &(*muons)[1]))
103  emu = true;
104  else
105  mumu = true;
106  } else if (electrons->size() > 1) {
107  if (PTComp(&(*electrons)[1], &(*muons)[0]))
108  ee = true;
109  else if (muons->size() == 1)
110  emu = true;
111  else if (PTComp(&(*electrons)[0], &(*muons)[1]))
112  emu = true;
113  else
114  mumu = true;
115  }
116  if (ee) {
117  if (LepDiffCharge(&(*electrons)[0], &(*electrons)[1])) {
118  leptonFound = true;
119  leptonFoundEE = true;
120  if (HasPositiveCharge(&(*electrons)[0])) {
121  selElectronp = 0;
122  selElectronm = 1;
123  } else {
124  selElectronp = 1;
125  selElectronm = 0;
126  }
127  }
128  } else if (emu) {
129  if (LepDiffCharge(&(*electrons)[0], &(*muons)[0])) {
130  leptonFound = true;
131  if (HasPositiveCharge(&(*electrons)[0])) {
132  leptonFoundEpMm = true;
133  selElectronp = 0;
134  selMuonm = 0;
135  } else {
136  leptonFoundEmMp = true;
137  selMuonp = 0;
138  selElectronm = 0;
139  }
140  }
141  } else if (mumu) {
142  if (LepDiffCharge(&(*muons)[0], &(*muons)[1])) {
143  leptonFound = true;
144  leptonFoundMM = true;
145  if (HasPositiveCharge(&(*muons)[0])) {
146  selMuonp = 0;
147  selMuonm = 1;
148  } else {
149  selMuonp = 1;
150  selMuonm = 0;
151  }
152  }
153  }
154  //select Jets (TopJet vector is sorted on ET)
155  if (jets->size() >= 2) {
156  jetsFound = true;
157  }
158  }
159  // If a tau is needed to have two leptons, then only consider the taus.
160  // This is the minimal modification of the dilept selection that includes taus,
161  // since we are considering taus only when no other solution exist.
162  else if (muons->size() + electrons->size() == 1 && !taus->empty()) {
163  // select leptons
164  if (muons->size() == 1) {
165  mutau = true;
166  // depending on the muon charge, set the right muon index and specify channel
167  int expectedCharge = -muons->begin()->charge();
168  int* tauIdx = nullptr;
169  if (expectedCharge < 0) {
170  selMuonp = 0;
171  tauIdx = &selTaum;
172  leptonFoundMpTm = true;
173  } else {
174  selMuonm = 0;
175  tauIdx = &selTaup;
176  leptonFoundMmTp = true;
177  }
178  // loop over the vector of taus to find the ones
179  // that have the charge opposite to the muon one, and do not match in eta-phi
180  std::vector<std::vector<pat::Tau>::const_iterator> subset1;
181  for (std::vector<pat::Tau>::const_iterator tau = taus->begin(); tau < taus->end(); ++tau) {
182  if (tau->charge() * expectedCharge >= 0 && DeltaR<pat::Particle>()(*tau, *(muons->begin())) > 0.1) {
183  *tauIdx = tau - taus->begin();
184  leptonFound = true;
185  subset1.push_back(tau);
186  }
187  }
188  // if there are more than one tau with ecalIsol==0, take the smallest E/P
189  float iso = 999.;
190  for (std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator tau = subset1.begin();
191  tau < subset1.end();
192  ++tau) {
193  if ((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum() < iso) {
194  *tauIdx = *tau - taus->begin();
195  iso = (*tau)->isolationPFChargedHadrCandsPtSum();
196  }
197  }
198 
199  // check that one combination has been found
200  if (!leptonFound) {
201  leptonFoundMpTm = false;
202  leptonFoundMmTp = false;
203  }
204  // discard the jet that matches the tau (if one)
205  if (leptonFound) {
206  for (std::vector<pat::Jet>::const_iterator jet = jets->begin(); jet < jets->end(); ++jet) {
207  if (DeltaR<pat::Particle, pat::Jet>()(*(taus->begin() + *tauIdx), *jet) < 0.1) {
208  JetVetoByTaus.push_back(jet - jets->begin());
209  }
210  }
211  }
212  } else {
213  etau = true;
214  // depending on the electron charge, set the right electron index and specify channel
215  int expectedCharge = -electrons->begin()->charge();
216  int* tauIdx = nullptr;
217  if (expectedCharge < 0) {
218  selElectronp = 0;
219  tauIdx = &selTaum;
220  leptonFoundEpTm = true;
221  } else {
222  selElectronm = 0;
223  tauIdx = &selTaup;
224  leptonFoundEmTp = true;
225  }
226  // loop over the vector of taus to find the ones
227  // that have the charge opposite to the muon one, and do not match in eta-phi
228  std::vector<std::vector<pat::Tau>::const_iterator> subset1;
229  for (std::vector<pat::Tau>::const_iterator tau = taus->begin(); tau < taus->end(); ++tau) {
230  if (tau->charge() * expectedCharge >= 0 && DeltaR<pat::Particle>()(*tau, *(electrons->begin())) > 0.1) {
231  *tauIdx = tau - taus->begin();
232  leptonFound = true;
233  subset1.push_back(tau);
234  }
235  }
236  // if there are more than one tau with ecalIsol==0, take the smallest E/P
237  float iso = 999.;
238  for (std::vector<std::vector<pat::Tau>::const_iterator>::const_iterator tau = subset1.begin();
239  tau < subset1.end();
240  ++tau) {
241  if ((*tau)->isPFTau() && (*tau)->isolationPFChargedHadrCandsPtSum() < iso) {
242  *tauIdx = *tau - taus->begin();
243  iso = (*tau)->isolationPFChargedHadrCandsPtSum();
244  }
245  }
246 
247  // check that one combination has been found
248  if (!leptonFound) {
249  leptonFoundEpTm = false;
250  leptonFoundEmTp = false;
251  }
252  // discard the jet that matches the tau (if one)
253  if (leptonFound) {
254  for (std::vector<pat::Jet>::const_iterator jet = jets->begin(); jet < jets->end(); ++jet) {
255  if (DeltaR<pat::Particle, pat::Jet>()(*(taus->begin() + *tauIdx), *jet) < 0.1) {
256  JetVetoByTaus.push_back(jet - jets->begin());
257  }
258  }
259  }
260  }
261  // select Jets (TopJet vector is sorted on ET)
262  jetsFound = ((jets->size() - JetVetoByTaus.size()) >= 2);
263  } else if (taus->size() > 1) {
264  tautau = true;
265  if (LepDiffCharge(&(*taus)[0], &(*taus)[1])) {
266  leptonFound = true;
267  leptonFoundTT = true;
268  if (HasPositiveCharge(&(*taus)[0])) {
269  selTaup = 0;
270  selTaum = 1;
271  } else {
272  selTaup = 1;
273  selTaum = 0;
274  }
275  }
276  for (std::vector<pat::Jet>::const_iterator jet = jets->begin(); jet < jets->end(); ++jet) {
277  if (DeltaR<pat::Particle, pat::Jet>()((*taus)[0], *jet) < 0.1 ||
278  DeltaR<pat::Particle, pat::Jet>()((*taus)[1], *jet) < 0.1) {
279  JetVetoByTaus.push_back(jet - jets->begin());
280  }
281  }
282  // select Jets (TopJet vector is sorted on ET)
283  jetsFound = ((jets->size() - JetVetoByTaus.size()) >= 2);
284  }
285 
286  // Check that the above work makes sense
287  if (int(ee) + int(emu) + int(mumu) + int(etau) + int(mutau) + int(tautau) > 1)
288  std::cout << "[TtDilepEvtSolutionMaker]: "
289  << "Lepton selection criteria uncorrectly defined" << std::endl;
290 
291  bool correctLepton = (leptonFoundEE && eeChannel_) || ((leptonFoundEmMp || leptonFoundEpMm) && emuChannel_) ||
292  (leptonFoundMM && mumuChannel_) || ((leptonFoundMmTp || leptonFoundMpTm) && mutauChannel_) ||
293  ((leptonFoundEmTp || leptonFoundEpTm) && etauChannel_) || (leptonFoundTT && tautauChannel_);
294 
295  std::vector<TtDilepEvtSolution>* evtsols = new std::vector<TtDilepEvtSolution>();
296  if (correctLepton && METFound && jetsFound) {
297  // protect against reading beyond array boundaries while discounting vetoed jets
298  unsigned int nrCombJets = 0;
299  unsigned int numberOfJets = 0;
300  for (; nrCombJets < jets->size() && numberOfJets < nrCombJets_; ++nrCombJets) {
301  if (find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(nrCombJets)) == JetVetoByTaus.end())
302  ++numberOfJets;
303  }
304  // consider all permutations
305  for (unsigned int ib = 0; ib < nrCombJets; ib++) {
306  // skipped jet vetoed during components-flagging.
307  if (find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(ib)) != JetVetoByTaus.end())
308  continue;
309  // second loop of the permutations
310  for (unsigned int ibbar = 0; ibbar < nrCombJets; ibbar++) {
311  // avoid the diagonal: b and bbar must be distinct jets
312  if (ib == ibbar)
313  continue;
314  // skipped jet vetoed during components-flagging.
315  if (find(JetVetoByTaus.begin(), JetVetoByTaus.end(), int(ibbar)) != JetVetoByTaus.end())
316  continue;
317  // Build and save a solution
318  TtDilepEvtSolution asol;
320  double xconstraint = 0, yconstraint = 0;
321  // Set e+ in the event
322  if (leptonFoundEE || leptonFoundEpMm || leptonFoundEpTm) {
323  asol.setElectronp(electrons, selElectronp);
324  xconstraint += (*electrons)[selElectronp].px();
325  yconstraint += (*electrons)[selElectronp].py();
326  }
327  // Set e- in the event
328  if (leptonFoundEE || leptonFoundEmMp || leptonFoundEmTp) {
329  asol.setElectronm(electrons, selElectronm);
330  xconstraint += (*electrons)[selElectronm].px();
331  yconstraint += (*electrons)[selElectronm].py();
332  }
333  // Set mu+ in the event
334  if (leptonFoundMM || leptonFoundEmMp || leptonFoundMpTm) {
335  asol.setMuonp(muons, selMuonp);
336  xconstraint += (*muons)[selMuonp].px();
337  yconstraint += (*muons)[selMuonp].py();
338  }
339  // Set mu- in the event
340  if (leptonFoundMM || leptonFoundEpMm || leptonFoundMmTp) {
341  asol.setMuonm(muons, selMuonm);
342  xconstraint += (*muons)[selMuonm].px();
343  yconstraint += (*muons)[selMuonm].py();
344  }
345  // Set tau- in the event
346  if (leptonFoundEpTm || leptonFoundMpTm || leptonFoundTT) {
347  asol.setTaum(taus, selTaum);
348  xconstraint += (*taus)[selTaum].px();
349  yconstraint += (*taus)[selTaum].py();
350  }
351  // Set tau+ in the event
352  if (leptonFoundEmTp || leptonFoundMmTp || leptonFoundTT) {
353  asol.setTaup(taus, selTaup);
354  xconstraint += (*taus)[selTaup].px();
355  yconstraint += (*taus)[selTaup].py();
356  }
357  // Set Jets/MET in the event
358  asol.setB(jets, ib);
359  asol.setBbar(jets, ibbar);
360  asol.setMET(mets, 0);
361  xconstraint += (*jets)[ib].px() + (*jets)[ibbar].px() + (*mets)[0].px();
362  yconstraint += (*jets)[ib].py() + (*jets)[ibbar].py() + (*mets)[0].py();
363  // if asked for, match the event solutions to the gen Event
364  if (matchToGenEvt_) {
366  iEvent.getByToken(evtSourceToken_, genEvt);
367  asol.setGenEvt(genEvt);
368  }
369  // If asked, use the kin fitter to compute the top mass
370  if (calcTopMass_) {
371  solver->SetConstraints(xconstraint, yconstraint);
373  asol = solver->addKinSolInfo(&asol);
374  }
375 
376  // these lines calculate the observables to be used in the TtDilepSignalSelection LR
377  (*myLRSignalSelObservables)(asol, iEvent);
378 
379  evtsols->push_back(asol);
380  }
381  }
382  // flag the best solution (MC matching)
383  if (matchToGenEvt_) {
384  double bestSolDR = 9999.;
385  int bestSol = -1;
386  double dR = 0.;
387  for (size_t s = 0; s < evtsols->size(); s++) {
388  dR = (*evtsols)[s].getJetResidual();
389  if (dR < bestSolDR) {
390  bestSolDR = dR;
391  bestSol = s;
392  }
393  }
394  if (bestSol != -1)
395  (*evtsols)[bestSol].setBestSol(true);
396  }
397  // put the result in the event
398  std::unique_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
399  iEvent.put(std::move(pOut));
400  } else {
401  // no solution: put a dummy solution in the event
402  TtDilepEvtSolution asol;
403  evtsols->push_back(asol);
404  std::unique_ptr<std::vector<TtDilepEvtSolution> > pOut(evtsols);
405  iEvent.put(std::move(pOut));
406  }
407 }

References TtFullLepKinSolver::addKinSolInfo(), calcTopMass_, gather_cfg::cout, HGC3DClusterGenMatchSelector_cfi::dR, eeChannel_, pwdgSkimBPark_cfi::electrons, electronSourceToken_, emuChannel_, etauChannel_, evtSourceToken_, spr::find(), TtGenEvtProducer_cfi::genEvt, HasPositiveCharge(), cuy::ib, iEvent, createfilelist::int, metsig::jet, jetCorrScheme_, singleTopDQM_cfi::jets, jetSourceToken_, LepDiffCharge(), matchToGenEvt_, singleTopDQM_cfi::mets, metSourceToken_, eostools::move(), mumuChannel_, PDWG_BPHSkim_cff::muons, muonSourceToken_, mutauChannel_, TtDilepEvtSolProducer_cfi::nrCombJets, nrCombJets_, PTComp(), alignCSCRings::s, TtDilepEvtSolution::setB(), TtDilepEvtSolution::setBbar(), TtFullLepKinSolver::SetConstraints(), TtDilepEvtSolution::setElectronm(), TtDilepEvtSolution::setElectronp(), TtDilepEvtSolution::setGenEvt(), TtDilepEvtSolution::setJetCorrectionScheme(), TtDilepEvtSolution::setMET(), TtDilepEvtSolution::setMuonm(), TtDilepEvtSolution::setMuonp(), TtDilepEvtSolution::setTaum(), TtDilepEvtSolution::setTaup(), solver, metsig::tau, Tau3MuMonitor_cff::taus, tauSourceToken_, tautauChannel_, useMCforBest_, and TtFullLepKinSolver::useWeightFromMC().

◆ PTComp()

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

Definition at line 46 of file TtDilepEvtSolutionMaker.h.

46  {
47  return (l1->pt() > l2->pt());
48 }

References reco::Candidate::pt().

Referenced by produce().

Member Data Documentation

◆ calcTopMass_

bool TtDilepEvtSolutionMaker::calcTopMass_
private

Definition at line 37 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ eeChannel_

bool TtDilepEvtSolutionMaker::eeChannel_
private

Definition at line 38 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ electronSourceToken_

edm::EDGetTokenT<std::vector<pat::Electron> > TtDilepEvtSolutionMaker::electronSourceToken_
private

Definition at line 29 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ emuChannel_

bool TtDilepEvtSolutionMaker::emuChannel_
private

Definition at line 38 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ etauChannel_

bool TtDilepEvtSolutionMaker::etauChannel_
private

Definition at line 38 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ evtSourceToken_

edm::EDGetTokenT<TtGenEvent> TtDilepEvtSolutionMaker::evtSourceToken_
private

Definition at line 34 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ jetCorrScheme_

int TtDilepEvtSolutionMaker::jetCorrScheme_
private

Definition at line 35 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ jetSourceToken_

edm::EDGetTokenT<std::vector<pat::Jet> > TtDilepEvtSolutionMaker::jetSourceToken_
private

Definition at line 33 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ matchToGenEvt_

bool TtDilepEvtSolutionMaker::matchToGenEvt_
private

Definition at line 37 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ metSourceToken_

edm::EDGetTokenT<std::vector<pat::MET> > TtDilepEvtSolutionMaker::metSourceToken_
private

Definition at line 32 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ mumuChannel_

bool TtDilepEvtSolutionMaker::mumuChannel_
private

Definition at line 38 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ muonSourceToken_

edm::EDGetTokenT<std::vector<pat::Muon> > TtDilepEvtSolutionMaker::muonSourceToken_
private

Definition at line 30 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ mutauChannel_

bool TtDilepEvtSolutionMaker::mutauChannel_
private

Definition at line 38 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ myLRSignalSelObservables

TtDilepLRSignalSelObservables* TtDilepEvtSolutionMaker::myLRSignalSelObservables
private

Definition at line 42 of file TtDilepEvtSolutionMaker.h.

Referenced by TtDilepEvtSolutionMaker().

◆ nrCombJets_

unsigned int TtDilepEvtSolutionMaker::nrCombJets_
private

Definition at line 36 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ nupars_

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

Definition at line 40 of file TtDilepEvtSolutionMaker.h.

Referenced by beginJob(), and TtDilepEvtSolutionMaker().

◆ solver

TtFullLepKinSolver* TtDilepEvtSolutionMaker::solver
private

Definition at line 43 of file TtDilepEvtSolutionMaker.h.

Referenced by beginJob(), and produce().

◆ tauSourceToken_

edm::EDGetTokenT<std::vector<pat::Tau> > TtDilepEvtSolutionMaker::tauSourceToken_
private

Definition at line 31 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ tautauChannel_

bool TtDilepEvtSolutionMaker::tautauChannel_
private

Definition at line 38 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

◆ tmassbegin_

double TtDilepEvtSolutionMaker::tmassbegin_
private

Definition at line 39 of file TtDilepEvtSolutionMaker.h.

Referenced by beginJob(), and TtDilepEvtSolutionMaker().

◆ tmassend_

double TtDilepEvtSolutionMaker::tmassend_
private

Definition at line 39 of file TtDilepEvtSolutionMaker.h.

Referenced by beginJob(), and TtDilepEvtSolutionMaker().

◆ tmassstep_

double TtDilepEvtSolutionMaker::tmassstep_
private

Definition at line 39 of file TtDilepEvtSolutionMaker.h.

Referenced by beginJob(), and TtDilepEvtSolutionMaker().

◆ useMCforBest_

bool TtDilepEvtSolutionMaker::useMCforBest_
private

Definition at line 37 of file TtDilepEvtSolutionMaker.h.

Referenced by produce(), and TtDilepEvtSolutionMaker().

TtDilepEvtSolutionMaker::muonSourceToken_
edm::EDGetTokenT< std::vector< pat::Muon > > muonSourceToken_
Definition: TtDilepEvtSolutionMaker.h:30
PDWG_BPHSkim_cff.muons
muons
Definition: PDWG_BPHSkim_cff.py:47
TtDilepEvtSolutionMaker::tauSourceToken_
edm::EDGetTokenT< std::vector< pat::Tau > > tauSourceToken_
Definition: TtDilepEvtSolutionMaker.h:31
TtDilepEvtSolutionMaker::emuChannel_
bool emuChannel_
Definition: TtDilepEvtSolutionMaker.h:38
TtDilepEvtSolution::setGenEvt
void setGenEvt(const edm::Handle< TtGenEvent > &)
Definition: TtDilepEvtSolution.cc:137
metsig::tau
Definition: SignAlgoResolutions.h:49
TtDilepEvtSolutionMaker::matchToGenEvt_
bool matchToGenEvt_
Definition: TtDilepEvtSolutionMaker.h:37
Tau3MuMonitor_cff.taus
taus
Definition: Tau3MuMonitor_cff.py:7
TtDilepEvtSolution::setBbar
void setBbar(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
Definition: TtDilepEvtSolution.h:170
TtFullLepKinSolver::addKinSolInfo
TtDilepEvtSolution addKinSolInfo(TtDilepEvtSolution *asol)
Definition: TtFullLepKinSolver.cc:24
TtFullLepKinSolver::useWeightFromMC
void useWeightFromMC(bool useMC)
Definition: TtFullLepKinSolver.h:43
gather_cfg.cout
cout
Definition: gather_cfg.py:144
TtDilepEvtSolutionMaker::metSourceToken_
edm::EDGetTokenT< std::vector< pat::MET > > metSourceToken_
Definition: TtDilepEvtSolutionMaker.h:32
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::EDConsumerBase::consumesCollector
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
Definition: EDConsumerBase.cc:71
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
singleTopDQM_cfi.mets
mets
Definition: singleTopDQM_cfi.py:43
TtDilepEvtSolutionMaker::tautauChannel_
bool tautauChannel_
Definition: TtDilepEvtSolutionMaker.h:38
DeltaR
Definition: deltaR.h:58
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
TtDilepEvtSolutionMaker::jetSourceToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetSourceToken_
Definition: TtDilepEvtSolutionMaker.h:33
edm::Handle
Definition: AssociativeIterator.h:50
TtDilepEvtSolutionMaker::HasPositiveCharge
bool HasPositiveCharge(const reco::Candidate *) const
Definition: TtDilepEvtSolutionMaker.h:54
alignCSCRings.s
s
Definition: alignCSCRings.py:92
TtDilepEvtSolutionMaker::mumuChannel_
bool mumuChannel_
Definition: TtDilepEvtSolutionMaker.h:38
TtDilepEvtSolutionMaker::evtSourceToken_
edm::EDGetTokenT< TtGenEvent > evtSourceToken_
Definition: TtDilepEvtSolutionMaker.h:34
reco::Candidate::charge
virtual int charge() const =0
electric charge
TtDilepEvtSolutionMaker::etauChannel_
bool etauChannel_
Definition: TtDilepEvtSolutionMaker.h:38
TtDilepEvtSolutionMaker::nrCombJets_
unsigned int nrCombJets_
Definition: TtDilepEvtSolutionMaker.h:36
TtDilepEvtSolutionMaker::mutauChannel_
bool mutauChannel_
Definition: TtDilepEvtSolutionMaker.h:38
TtDilepEvtSolution::setJetCorrectionScheme
void setJetCorrectionScheme(int jetCorrScheme)
Definition: TtDilepEvtSolution.h:166
TtDilepEvtSolutionMaker::PTComp
bool PTComp(const reco::Candidate *, const reco::Candidate *) const
Definition: TtDilepEvtSolutionMaker.h:46
TtDilepEvtSolProducer_cfi.nrCombJets
nrCombJets
Definition: TtDilepEvtSolProducer_cfi.py:35
TtDilepEvtSolutionMaker::tmassstep_
double tmassstep_
Definition: TtDilepEvtSolutionMaker.h:39
TtDilepEvtSolutionMaker::nupars_
std::vector< double > nupars_
Definition: TtDilepEvtSolutionMaker.h:40
TtDilepEvtSolutionMaker::electronSourceToken_
edm::EDGetTokenT< std::vector< pat::Electron > > electronSourceToken_
Definition: TtDilepEvtSolutionMaker.h:29
TtDilepEvtSolutionMaker::tmassend_
double tmassend_
Definition: TtDilepEvtSolutionMaker.h:39
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
TtDilepEvtSolution::setTaup
void setTaup(const edm::Handle< std::vector< pat::Tau > > &tau, int i)
Definition: TtDilepEvtSolution.h:181
cuy.ib
ib
Definition: cuy.py:662
TtDilepEvtSolution::setElectronp
void setElectronp(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
Definition: TtDilepEvtSolution.h:189
TtDilepEvtSolutionMaker::tmassbegin_
double tmassbegin_
Definition: TtDilepEvtSolutionMaker.h:39
TtDilepEvtSolutionMaker::useMCforBest_
bool useMCforBest_
Definition: TtDilepEvtSolutionMaker.h:37
TtDilepEvtSolution::setMET
void setMET(const edm::Handle< std::vector< pat::MET > > &met, int i)
Definition: TtDilepEvtSolution.h:197
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:193
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
TtDilepEvtSolutionMaker::myLRSignalSelObservables
TtDilepLRSignalSelObservables * myLRSignalSelObservables
Definition: TtDilepEvtSolutionMaker.h:42
eostools.move
def move(src, dest)
Definition: eostools.py:511
TtDilepEvtSolutionMaker::solver
TtFullLepKinSolver * solver
Definition: TtDilepEvtSolutionMaker.h:43
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
TtDilepEvtSolution::setTaum
void setTaum(const edm::Handle< std::vector< pat::Tau > > &tau, int i)
Definition: TtDilepEvtSolution.h:185
metsig::jet
Definition: SignAlgoResolutions.h:47
TtDilepEvtSolutionMaker::calcTopMass_
bool calcTopMass_
Definition: TtDilepEvtSolutionMaker.h:37
TtDilepEvtSolutionMaker::jetCorrScheme_
int jetCorrScheme_
Definition: TtDilepEvtSolutionMaker.h:35
TtDilepEvtSolution::setMuonp
void setMuonp(const edm::Handle< std::vector< pat::Muon > > &muon, int i)
Definition: TtDilepEvtSolution.h:173
TtDilepEvtSolution::setMuonm
void setMuonm(const edm::Handle< std::vector< pat::Muon > > &muon, int i)
Definition: TtDilepEvtSolution.h:177
TtDilepEvtSolution::setB
void setB(const edm::Handle< std::vector< pat::Jet > > &jet, int i)
Definition: TtDilepEvtSolution.h:167
TtDilepEvtSolution::setElectronm
void setElectronm(const edm::Handle< std::vector< pat::Electron > > &elec, int i)
Definition: TtDilepEvtSolution.h:193
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
TtDilepLRSignalSelObservables
Definition: TtDilepLRSignalSelObservables.h:16
TtDilepEvtSolutionMaker::eeChannel_
bool eeChannel_
Definition: TtDilepEvtSolutionMaker.h:38
edm::InputTag
Definition: InputTag.h:15
TtGenEvtProducer_cfi.genEvt
genEvt
Definition: TtGenEvtProducer_cfi.py:7
TtFullLepKinSolver
Definition: TtFullLepKinSolver.h:25
TtDilepEvtSolution
Definition: TtDilepEvtSolution.h:25
TtDilepEvtSolutionMaker::LepDiffCharge
bool LepDiffCharge(const reco::Candidate *, const reco::Candidate *) const
Definition: TtDilepEvtSolutionMaker.h:50