CMS 3D CMS Logo

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

#include <TopQuarkAnalysis/TopPairBSM/plugins/BoostedTopProducer.cc>

Inheritance diagram for BoostedTopProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 BoostedTopProducer (const edm::ParameterSet &)
 
 ~BoostedTopProducer ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void beginJob (const edm::EventSetup &)
 
virtual void endJob ()
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 
double Psi (TLorentzVector p1, TLorentzVector p2, double mass)
 

Private Attributes

double caloIsoCut_
 
edm::Handle< std::vector
< pat::Electron > > 
electronHandle_
 
edm::InputTag eleLabel_
 
edm::Handle< std::vector
< pat::Jet > > 
jetHandle_
 
edm::InputTag jetLabel_
 
edm::Handle< std::vector
< pat::MET > > 
METHandle_
 
edm::InputTag metLabel_
 
double mTop_
 
edm::InputTag muoLabel_
 
edm::Handle< std::vector
< pat::Muon > > 
muonHandle_
 
edm::InputTag solLabel_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Description: Class to examine boosted ttbar pairs in multiple mass regions.

This will produce a ttbar solution, which will take one of two forms: a) lv jj jj Full reconstruction.

ttbar-> (hadt -> (hadW -> hadp + hadq) + hadb) + (lept -> (lepW -> lepton + neutrino) + lepb)

b) lv jj (j) Partial reconstruction, associate at least 1 jet to the lepton hemisphere, and at least one jet in the opposite hemisphere.

ttbar-> (hadt -> (hadJet1 [+ hadJet2] ) ) + (lept -> (lepW -> lepton + neutrino) + lepJet1 )

There will also be two subcategories of (b) that will correspond to physics cases:

b1) Lepton is isolated: Moderate ttbar mass. b2) Lepton is nonisolated: High ttbar mass.

Implementation: To implement this, we use the NamedCompositeCandidate structures from the Candidate model. This provides flexibility in the definition of the output objects and allows automatic plotting in the Starter Kit. We use the PAT objects to construct the ttbar solutions in the different ranges as follows: a) Full reconstruction: We use TtSemiEventSolutions made upstream of this module. b) Partial reconstruction: Association of variables using the "Psi" variable, which is a more rapidity-invariant version of deltaR.

Definition at line 84 of file BoostedTopProducer.h.

Constructor & Destructor Documentation

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

Definition at line 23 of file BoostedTopProducer.cc.

23  :
24  eleLabel_ (iConfig.getParameter<edm::InputTag> ("electronLabel")),
25  muoLabel_ (iConfig.getParameter<edm::InputTag> ("muonLabel")),
26  jetLabel_ (iConfig.getParameter<edm::InputTag> ("jetLabel")),
27  metLabel_ (iConfig.getParameter<edm::InputTag> ("metLabel")),
28  solLabel_ (iConfig.getParameter<edm::InputTag> ("solLabel")),
29  caloIsoCut_ (iConfig.getParameter<double> ("caloIsoCut") ),
30  mTop_ (iConfig.getParameter<double> ("mTop") )
31 {
32  //register products
33  produces<std::vector<reco::CompositeCandidate> > ();
34 }
edm::InputTag muoLabel_
T getParameter(std::string const &) const
edm::InputTag eleLabel_
edm::InputTag jetLabel_
BoostedTopProducer::~BoostedTopProducer ( )

Definition at line 37 of file BoostedTopProducer.cc.

38 {
39 }

Member Function Documentation

void BoostedTopProducer::beginJob ( const edm::EventSetup )
privatevirtual

Definition at line 375 of file BoostedTopProducer.cc.

376 {
377 }
void BoostedTopProducer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDProducer.

Definition at line 381 of file BoostedTopProducer.cc.

381  {
382 }
void BoostedTopProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 48 of file BoostedTopProducer.cc.

References reco::CompositeCandidate::addDaughter(), METzCalculator::Calculate(), caloIsoCut_, gather_cfg::cout, debug, metsig::electron, HI_PhotonSkim_cff::electrons, eleLabel_, reco::LeafCandidate::energy(), edm::Event::getByLabel(), METzCalculator::IsComplex(), reco::isMuon(), edm::HandleBase::isValid(), jetLabel_, fwrapper::jets, TtEvent::kMVADisc, metLabel_, mTop_, muoLabel_, metsig::muon, patZpeak::muons, reco::CompositeCandidate::numberOfDaughters(), Pi, Psi(), edm::Event::put(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), alignCSCRings::s, METzCalculator::SetMET(), METzCalculator::SetMuon(), reco::LeafCandidate::setPz(), solLabel_, and TablePrint::write.

49 {
50 
51  using namespace edm;
52 
53  bool debug = false;
54 
55  // -----------------------------------------------------
56  // get the bare PAT objects
57  // -----------------------------------------------------
59  iEvent.getByLabel(muoLabel_,muonHandle);
60  std::vector<pat::Muon> const & muons = *muonHandle;
61 
63  iEvent.getByLabel(jetLabel_,jetHandle);
64  std::vector<pat::Jet> const & jets = *jetHandle;
65 
67  iEvent.getByLabel(eleLabel_,electronHandle);
68  std::vector<pat::Electron> const & electrons = *electronHandle;
69 
71  iEvent.getByLabel(metLabel_,metHandle);
72  std::vector<pat::MET> const & mets = *metHandle;
73 
74  // -----------------------------------------------------
75  // Event Preselection:
76  // <= 1 isolated electron or muon
77  // >= 1 electron or muon
78  // >= 2 jets
79  // >= 1 missing et
80  //
81  // To explain:
82  // We want to look at leptons within "top jets" in some
83  // cases. This means the isolation will kill those events.
84  // However, if there IS an isolated lepton, we want only
85  // one of them.
86  //
87  // So to select the prompt W lepton, the logic is:
88  // 1. If there is an isolated lepton, accept it as the W lepton.
89  // 2. Else, take the highest Pt lepton (possibly non-isolated)
90  //
91  // -----------------------------------------------------
92  bool preselection = true;
93 
94  // This will hold the prompt W lepton candidate, and a
95  // maximum pt decision variable
96  double maxWLeptonPt = -1;
97  reco::Candidate const * Wlepton = 0;
98 
99  // ----------------------
100  // Find isolated muons, and highest pt lepton
101  // ----------------------
102  std::vector<pat::Muon>::const_iterator isolatedMuon = muons.end();
103  std::vector<pat::Muon>::const_iterator muon = muons.end();
104  bool nIsolatedMuons = 0;
105  std::vector<pat::Muon>::const_iterator muonIt = muons.begin(),
106  muonEnd = muons.end();
107  for (; muonIt != muonEnd; ++muonIt ) {
108 
109  // Find highest pt lepton
110  double pt = muonIt->pt();
111  if ( pt > maxWLeptonPt ) {
112  maxWLeptonPt = pt;
113  muon = muonIt;
114  }
115 
116  // Find any isolated muons
117  double caloIso = muonIt->caloIso();
118  if ( caloIso >= 0 && caloIso < caloIsoCut_ ) {
119  nIsolatedMuons++;
120  isolatedMuon = muonIt;
121  }
122  }
123 
124  // ----------------------
125  // Find isolated electrons, and highest pt lepton
126  // ----------------------
127  std::vector<pat::Electron>::const_iterator isolatedElectron = electrons.end();
128  std::vector<pat::Electron>::const_iterator electron = electrons.end();
129  bool nIsolatedElectrons = 0;
130  std::vector<pat::Electron>::const_iterator electronIt = electrons.begin(),
131  electronEnd = electrons.end();
132  for (; electronIt != electronEnd; ++electronIt ) {
133 
134  // Find highest pt lepton
135  double pt = electronIt->pt();
136  if ( pt > maxWLeptonPt ) {
137  maxWLeptonPt = pt;
138  electron = electronIt;
139  }
140 
141  // Find any isolated electrons
142  double caloIso = electronIt->caloIso();
143  if ( caloIso >= 0 && caloIso < caloIsoCut_ ) {
144  nIsolatedElectrons++;
145  isolatedElectron = electronIt;
146  }
147  }
148 
149 
150  // ----------------------
151  // Now decide on the "prompt" lepton from the W:
152  // Choose isolated leptons over all, and if no isolated,
153  // then take highest pt lepton.
154  // ----------------------
155  bool isMuon = true;
156  if ( isolatedMuon != muonEnd ) { muon = isolatedMuon; isMuon = true; }
157  else if ( isolatedElectron != electronEnd ) { electron = isolatedElectron; isMuon = false; }
158  else {
159  // Set to the highest pt lepton
160  if ( muon != muonEnd && electron == electronEnd ) isMuon = true;
161  else if ( muon == muonEnd && electron != electronEnd ) isMuon = false;
162  else if ( muon != muonEnd && electron != electronEnd ) {
163  isMuon = muon->pt() > electron->pt();
164  }
165  }
166 
167  // ----------------------
168  // Veto events that have more than one isolated lepton
169  // ----------------------
170  int nIsolatedLeptons = nIsolatedMuons + nIsolatedElectrons;
171  if ( nIsolatedLeptons > 1 ) {
172  preselection = false;
173  }
174 
175  // ----------------------
176  // Veto events that have no prompt lepton candidates
177  // ----------------------
178  if ( muon == muonEnd && electron == electronEnd ) {
179  preselection = false;
180  }
181 
182  // ----------------------
183  // Veto events with < 2 jets or no missing et
184  // ----------------------
185  if ( jets.size() < 2 ||
186  mets.size() == 0 ) {
187  preselection = false;
188  }
189 
190  bool write = false;
191 
192 
193 
194  // -----------------------------------------------------
195  //
196  // CompositeCandidates to store the event solution.
197  // This will take one of two forms:
198  // a) lv jj jj Full reconstruction.
199  //
200  // ttbar->
201  // (hadt -> (hadW -> hadp + hadq) + hadb) +
202  // (lept -> (lepW -> lepton + neutrino) + lepb)
203  //
204  // b) lv jj (j) Partial reconstruction, associate
205  // at least 1 jet to the lepton
206  // hemisphere, and at least one jet in
207  // the opposite hemisphere.
208  //
209  // ttbar->
210  // (hadt -> (hadJet1 [+ hadJet2] ) ) +
211  // (lept -> (lepW -> lepton + neutrino) + lepJet1 )
212  //
213  // There will also be two subcategories of (b) that
214  // will correspond to physics cases:
215  //
216  // b1) Lepton is isolated: Moderate ttbar mass.
217  // b2) Lepton is nonisolated: High ttbar mass.
218  //
219  // -----------------------------------------------------
220  reco::CompositeCandidate ttbar("ttbar");
221  AddFourMomenta addFourMomenta;
222 
223 
224  // Main decisions after preselection
225  if ( preselection ) {
226 
227  if ( debug ) cout << "Preselection is satisfied" << endl;
228 
229  if ( debug ) cout << "Jets.size() = " << jets.size() << endl;
230 
231  // This will be modified for the z solution, so make a copy
232  pat::MET neutrino( mets[0] );
233 
234 
235  // 1. First examine the low mass case with 4 jets and widely separated
236  // products. We take out the TtSemiLeptonicEvent from the TQAF and
237  // form the ttbar invariant mass.
238  if ( jets.size() >= 4 ) {
239 
240  if ( debug ) cout << "Getting ttbar semileptonic solution" << endl;
241 
242  // get the ttbar semileptonic event solution if there are more than 3 jets
244  iEvent.getByLabel(solLabel_, eSol);
245 
246  // Have solution, continue
247  if ( eSol.isValid() ) {
248  if ( debug ) cout << "Got a nonzero size solution vector" << endl;
249  // Just set the ttbar solution to the best ttbar solution from
250  // TtSemiEvtSolutionMaker
251  ttbar = eSol->eventHypo(TtSemiLeptonicEvent::kMVADisc);
252  write = true;
253  }
254  // No ttbar solution with 4 jets, something is weird, print a warning
255  else {
256  edm::LogWarning("DataNotFound") << "BoostedTopProducer: Cannot find TtSemiEvtSolution\n";
257  }
258  }
259  // 2. With 2 or 3 jets, we decide based on the separation between
260  // the lepton and the closest jet in that hemisphere whether to
261  // consider it "moderate" or "high" mass.
262  else if ( jets.size() == 2 || jets.size() == 3 ) {
263 
264  // ------------------------------------------------------------------
265  // First create a leptonic W candidate
266  // ------------------------------------------------------------------
267  reco::CompositeCandidate lepW("lepW");
268 
269  if ( isMuon ) {
270  if ( debug ) cout << "Adding muon as daughter" << endl;
271  lepW.addDaughter( *muon, "muon" );
272  } else {
273  if ( debug ) cout << "Adding electron as daughter" << endl;
274  lepW.addDaughter( *electron, "electron" );
275  }
276  if ( debug ) cout << "Adding neutrino as daughter" << endl;
277  lepW.addDaughter ( neutrino, "neutrino");
278  addFourMomenta.set( lepW );
279 
280  bool nuzHasComplex = false;
281  METzCalculator zcalculator;
282 
283  zcalculator.SetMET( neutrino );
284  if ( isMuon )
285  zcalculator.SetMuon( *muon );
286  else
287  zcalculator.SetMuon( *electron ); // This name is misleading, should be setLepton
288  double neutrinoPz = zcalculator.Calculate(1);// closest to the lepton Pz
289  if (zcalculator.IsComplex()) nuzHasComplex = true;
290  // Set the neutrino pz
291  neutrino.setPz( neutrinoPz );
292 
293  if ( debug ) cout << "Set neutrino pz to " << neutrinoPz << endl;
294 
295  // ------------------------------------------------------------------
296  // Next ensure that there is a jet within the hemisphere of the
297  // leptonic W, and one in the opposite hemisphere
298  // ------------------------------------------------------------------
299  reco::CompositeCandidate hadt("hadt");
300  reco::CompositeCandidate lept("lept");
301  if ( debug ) cout << "Adding lepW as daughter" << endl;
302  lept.addDaughter( lepW, "lepW" );
303 
304  std::string hadName("hadJet");
305  std::string lepName("lepJet");
306 
307  // Get the W momentum
308  TLorentzVector p4_W (lepW.px(), lepW.py(), lepW.pz(), lepW.energy() );
309 
310  // Loop over the jets
311  std::vector<pat::Jet>::const_iterator jetit = jets.begin(),
312  jetend = jets.end();
313  unsigned long ii = 1; // Count by 1 for naming histograms
314  for ( ; jetit != jetend; ++jetit, ++ii ) {
315  // Get this jet's momentum
316  TLorentzVector p4_jet (jetit->px(), jetit->py(), jetit->pz(), jetit->energy() );
317 
318  // Calculate psi (like DeltaR, only more invariant under Rapidity)
319  double psi = Psi( p4_W, p4_jet, mTop_ );
320 
321  // Get jets that are in the leptonic hemisphere
322  if ( psi < TMath::Pi() ) {
323  // Add this jet to the leptonic top
324  std::stringstream s;
325  s << lepName << ii;
326  if ( debug ) cout << "Adding daughter " << s.str() << endl;
327  lept.addDaughter( *jetit, s.str() );
328  }
329  // Get jets that are in the hadronic hemisphere
330  if ( psi > TMath::Pi() ) {
331  // Add this jet to the hadronic top. We don't
332  // make any W hypotheses in this case, since
333  // we cannot determine which of the three
334  // jets are merged.
335  std::stringstream s;
336  s << hadName << ii;
337  if ( debug ) cout << "Adding daughter " << s.str() << endl;
338  hadt.addDaughter( *jetit, s.str() );
339 
340  }
341  } // end loop over jets
342 
343  addFourMomenta.set( lept );
344  addFourMomenta.set( hadt );
345 
346  bool lepWHasJet = lept.numberOfDaughters() >= 2; // W and >= 1 jet
347  bool hadWHasJet = hadt.numberOfDaughters() >= 1; // >= 1 jet
348  if ( lepWHasJet && hadWHasJet ) {
349  if ( debug ) cout << "Adding daughters lept and hadt" << endl;
350  ttbar.addDaughter( lept, "lept");
351  ttbar.addDaughter( hadt, "hadt");
352  addFourMomenta.set( ttbar );
353  write = true;
354  } // end of hadronic jet and leptonic jet
355 
356 
357  } // end if there are 2 or 3 jets
358 
359  } // end if preselection is satisfied
360 
361  // Write the solution to the event record
362  std::vector<reco::CompositeCandidate> ttbarList;
363  if ( write ) {
364  if ( debug ) cout << "Writing out" << endl;
365  ttbarList.push_back( ttbar );
366  }
367  std::auto_ptr<std::vector<reco::CompositeCandidate> > pTtbar ( new std::vector<reco::CompositeCandidate>(ttbarList) );
368  iEvent.put( pTtbar );
369 
370 
371 }
edm::InputTag muoLabel_
const double Pi
Analysis-level MET class.
Definition: MET.h:42
double Psi(TLorentzVector p1, TLorentzVector p2, double mass)
bool isMuon(const Candidate &part)
Definition: pdgIdUtils.h:11
std::map< std::string, int, std::less< std::string > > psi
void SetMET(const pat::MET &MET)
Set MET.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
vector< PseudoJet > jets
void SetMuon(const pat::Particle &lepton)
Set Muon.
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
bool IsComplex() const
check for complex root
double Calculate(int type=0)
member functions
edm::InputTag eleLabel_
tuple muons
Definition: patZpeak.py:38
tuple cout
Definition: gather_cfg.py:121
edm::InputTag jetLabel_
#define debug
Definition: MEtoEDMFormat.h:34
double BoostedTopProducer::Psi ( TLorentzVector  p1,
TLorentzVector  p2,
double  mass 
)
private

Definition at line 385 of file BoostedTopProducer.cc.

References p2, and Pi.

Referenced by produce().

385  {
386 
387  TLorentzVector ptot = p1 + p2;
388  Double_t theta1 = TMath::ACos( (p1.Vect().Dot(ptot.Vect()))/(p1.P()*ptot.P()) );
389  Double_t theta2 = TMath::ACos( (p2.Vect().Dot(ptot.Vect()))/(p2.P()*ptot.P()) );
390  //Double_t sign = 1.;
391  //if ( (theta1+theta2) > (TMath::Pi()/2) ) sign = -1.;
392  double th1th2 = theta1 + theta2;
393  double psi = (p1.P()+p2.P())*TMath::Abs(TMath::Sin(th1th2))/(2.* mass );
394  if ( th1th2 > (TMath::Pi()/2) )
395  psi = (p1.P()+p2.P())*( 1. + TMath::Abs(TMath::Cos(th1th2)))/(2.* mass );
396 
397  return psi;
398 }
const double Pi
std::map< std::string, int, std::less< std::string > > psi
double p2[4]
Definition: TauolaWrapper.h:90
double p1[4]
Definition: TauolaWrapper.h:89
tuple mass
Definition: scaleCards.py:27

Member Data Documentation

double BoostedTopProducer::caloIsoCut_
private

Definition at line 110 of file BoostedTopProducer.h.

Referenced by produce().

edm::Handle<std::vector<pat::Electron> > BoostedTopProducer::electronHandle_
private

Definition at line 105 of file BoostedTopProducer.h.

edm::InputTag BoostedTopProducer::eleLabel_
private

Definition at line 97 of file BoostedTopProducer.h.

Referenced by produce().

edm::Handle<std::vector<pat::Jet> > BoostedTopProducer::jetHandle_
private

Definition at line 106 of file BoostedTopProducer.h.

edm::InputTag BoostedTopProducer::jetLabel_
private

Definition at line 99 of file BoostedTopProducer.h.

Referenced by produce().

edm::Handle<std::vector<pat::MET> > BoostedTopProducer::METHandle_
private

Definition at line 107 of file BoostedTopProducer.h.

edm::InputTag BoostedTopProducer::metLabel_
private

Definition at line 100 of file BoostedTopProducer.h.

Referenced by produce().

double BoostedTopProducer::mTop_
private

Definition at line 111 of file BoostedTopProducer.h.

Referenced by produce().

edm::InputTag BoostedTopProducer::muoLabel_
private

Definition at line 98 of file BoostedTopProducer.h.

Referenced by produce().

edm::Handle<std::vector<pat::Muon> > BoostedTopProducer::muonHandle_
private

Definition at line 104 of file BoostedTopProducer.h.

edm::InputTag BoostedTopProducer::solLabel_
private

Definition at line 101 of file BoostedTopProducer.h.

Referenced by produce().