ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
PyAlgorithmExample.PyAlgorithmExample Class Reference

The example algorithm. More...

Inheritance diagram for PyAlgorithmExample.PyAlgorithmExample:
Collaboration diagram for PyAlgorithmExample.PyAlgorithmExample:

Public Member Functions

def __init__ (self, name, args)
 
def execute (self)
 
def get_electrons (self)
 
def get_muons (self)
 
def get_taujets (self)
 
def get_met (self)
 
def find_zll (self, llist, h)
 
def find_ztt (self, parts, met, zll, h)
 
def find_hzz (self, candlist, h)
 

Public Attributes

 args
 
 h
 

Detailed Description

The example algorithm.

We derive from PyAlgorithm, which means that this is a Gaudi algorithm in every sense.

Definition at line 343 of file PyAlgorithmExample.py.

Constructor & Destructor Documentation

◆ __init__()

def PyAlgorithmExample.PyAlgorithmExample.__init__ (   self,
  name,
  args 
)

Definition at line 346 of file PyAlgorithmExample.py.

346  def __init__ (self, name, args):
347  # Initialze base class.
348  PyAlgorithm.__init__ (self, name)
349 
350  # Save the arguments.
351  self.args = args
352 
353  # Make the class to hold the histograms.
354  # We stick them in a separate instance to that they can be easily
355  # saved via root_pickle.
356  h = Holder()
357  self.h = h
358 
359  # Create histograms.
360  h.ele0 = Partlisthists_Ele ('ele0')
361  h.ele1 = Partlisthists_Ele ('ele1')
362  h.ele2 = Partlisthists_Ele ('ele2')
363 
364  h.muo0 = Partlisthists_Muo ('muo0')
365  h.muo1 = Partlisthists_Muo ('muo1')
366 
367  h.taujet0 = Partlisthists_Taujet ('taujet0')
368  h.taujet1 = Partlisthists_Taujet ('taujet1')
369 
370  h.metx = mybook ("metx", 100, 0, 500*GeV)
371  h.mety = mybook ("mety", 100, 0, 500*GeV)
372  h.met = mybook ("met", 100, 0, 500*GeV)
373 
374  h.zee = [Partlisthists_Z('zee0'), Partlisthists_Z('zee1')]
375  h.zmm = [Partlisthists_Z('zmm0'), Partlisthists_Z('zmm1')]
376  h.zll = Partlisthists_Z('zll')
377 
378  h.ztt = [Partlisthists_Z('ztt0'), Partlisthists_Z('ztt1')]
379 
380  h.hzz = [Partlisthists_Z ('hzz0', m_max=500*GeV),
381  Partlisthists_Z ('hzz1', m_max=500*GeV)]
382 
383  h.ncand = mybook ("ncand", 10, 0, 10)
384 
385  # Initialize event counters.
386  h.n_in = 0
387  h.n_met_cut = 0
388  h.n_zll_cut = 0
389  h.n_4parts_cut = 0
390  h.n_cand_cut = 0
391  h.n_hzz_cut = 0
392  return
393 
394 

Member Function Documentation

◆ execute()

def PyAlgorithmExample.PyAlgorithmExample.execute (   self)

Definition at line 396 of file PyAlgorithmExample.py.

396  def execute (self):
397  args = self.args
398  h = self.h
399 
400  # Get particles from storegate.
401  eles = self.get_electrons()
402  muos = self.get_muons()
403  taujets = self.get_taujets()
404  met = self.get_met()
405 
406  # Find Z->ll decays.
407  # Find them Z->ee and Z->mm separately, then combine the lists,
408  # and then fill histograms from the combined list.
409  zees = self.find_zll (eles, h.zee)
410  zmms = self.find_zll (muos, h.zmm)
411  zlls = zees + zmms
412  h.zll.fill (zlls)
413 
414  # Make preliminary cuts.
415  # Count the events passing the cuts.
416  h.n_in += 1
417 
418  # Missing et cut.
419  if met.pt < args.met_cut: return 1
420  h.n_met_cut += 1
421 
422  # Must find at least one Z->ll.
423  if len (zlls) == 0: return 1
424  h.n_zll_cut += 1
425 
426  # Need at least four final-state particles.
427  if len (eles) + len (muos) + len (taujets) < 4: return 1
428  h.n_4parts_cut += 1
429 
430  # Combine all final-state particles into a single list.
431  # We'll use this to search for Z->tautau decays.
432  parts = eles + muos + taujets
433 
434  # For each Z->ll decay, we look for Z->tautau decays.
435  # In general, for a given Z->ll decay, we may have 0, 1, or more
436  # Z->tautau candidates. In CANDLIST, we make a list of all the
437  # candiate (zll, ztt) decays we find.
438  candlist = []
439 
440  # Loop over Z->ll candidates.
441  for z in zlls:
442  # Search for Z->tautau candidates, given a specific Z->ll
443  # candidate.
444  ztts = self.find_ztt (parts, met, z, h.ztt)
445  # Append all of our candidates to the list.
446  for z2 in ztts: candlist.append ((z, z2))
447 
448  # Now require that we find at least one
449  # Z->ll, Z->tautau pair.
450  if len (candlist) == 0: return 1
451  h.n_cand_cut += 1
452  h.ncand.Fill (len (candlist))
453 
454  # Construct the H->ZZ candidates.
455  hzzs = self.find_hzz (candlist, h.hzz)
456  h.n_hzz_cut += 1
457  return 1
458 
459 

◆ find_hzz()

def PyAlgorithmExample.PyAlgorithmExample.find_hzz (   self,
  candlist,
  h 
)

Definition at line 628 of file PyAlgorithmExample.py.

628  def find_hzz (self, candlist, h):
629  # For each candidate pair, construct a higgs object.
630  # Reuse the Z class for this.
631  # Then fill histograms.
632  hzzs = [Z (zll, ztt, PDG.Higgs0) for (zll, ztt) in candlist]
633  h[0].fill (hzzs)
634 
635  # Make a DR cut and fill histograms again.
636  def select (hg):
637  return hg.dr() < args.hzz_deltar_cut
638  hzzs = [hg for hg in hzzs if select (hg)]
639  h[1].fill (hzzs)
640 
641  # Return the candidate list.
642  return hzzs

◆ find_zll()

def PyAlgorithmExample.PyAlgorithmExample.find_zll (   self,
  llist,
  h 
)

Definition at line 557 of file PyAlgorithmExample.py.

557  def find_zll (self, llist, h):
558  args = self.args
559 
560  # Make a candidate Z particle for each opposite-sign lepton pair
561  # combination and fill histograms.
562  zlist = [Z (l1, l2) for (l1,l2) in combo.combinations (llist, 2)
563  if l1.charge()*l2.charge() < 0]
564  h[0].fill (zlist)
565 
566  # Now filter candiates, applying a mass window and DR cut.
567  # Then histogram the results.
568  def select (z):
569  return (z.dr() < args.zll_deltar_cut and
570  abs(z.m() - MZ) < args.zll_deltam_cut)
571  zlist = [z for z in zlist if select (z)]
572  h[1].fill (zlist)
573  return zlist
574 
575 

◆ find_ztt()

def PyAlgorithmExample.PyAlgorithmExample.find_ztt (   self,
  parts,
  met,
  zll,
  h 
)

Definition at line 583 of file PyAlgorithmExample.py.

583  def find_ztt (self, parts, met, zll, h):
584  args = self.args
585 
586  # Remove particles that were used in the Z->ll decay.
587  parts = [p for p in parts if p not in zll]
588 
589  # List of candidates we're building.
590  zlist = []
591 
592  # Loop over all pairs of remaining particles.
593  for (l1, l2) in combo.combinations (parts, 2):
594  # Use only oppositely-charged pairs.
595  # Does this work for tau jets?
596  if l1.charge() * l2.charge() > 0: continue
597 
598  # Build the candidate Z.
599  z = Z (l1, l2)
600 
601  # Calculate the neutrino momenta, and add them to the Z candidate.
602  (nu1, nu2) = neutrinos_from_colinear_approximation (l1, l2,
603  met.etx(),
604  met.ety())
605  z.add (nu1)
606  z.add (nu2)
607  zlist.append (z)
608 
609  # Fill histograms from the initial set of candidates.
610  h[0].fill (zlist)
611 
612  # Make mass and dr cuts and fill another set of histograms.
613  def select (z):
614  return (z.dr() < args.ztt_deltar_cut and
615  abs(z.m() - MZ) < args.ztt_deltam_cut)
616  zlist = [z for z in zlist if select (z)]
617  h[1].fill (zlist)
618 
619  # Return candidates.
620  return zlist
621 
622 

◆ get_electrons()

def PyAlgorithmExample.PyAlgorithmExample.get_electrons (   self)

Definition at line 463 of file PyAlgorithmExample.py.

463  def get_electrons (self):
464  args = self.args
465  h = self.h
466 
467  # Helper function: apply particle ID cuts to candidate E.
468  def track_select (e):
469  if not fulldata(e): return 1
470  return e.hasTrack() and e.isEM()%16 == 0
471 
472  # Helper function: apply kinematic cuts to candidate E.
473  def select (e):
474  return e.pt() > args.ele_pt_cut and abs(e.eta()) < args.ele_eta_cut
475 
476  # Fetch electrons from storegate, apply particle ID cuts,
477  # then kinematic cuts, then return the results. Fill histograms
478  # after each step.
479  eles = PyParticleTools.getElectrons (args.electron_container)
480  h.ele0.fill (eles)
481  eles = [e for e in eles if track_select (e)]
482  h.ele1.fill (eles)
483  eles = [e for e in eles if select (e)]
484  h.ele2.fill (eles)
485  return eles
486 
487 

◆ get_met()

def PyAlgorithmExample.PyAlgorithmExample.get_met (   self)

Definition at line 540 of file PyAlgorithmExample.py.

540  def get_met (self):
541  args = self.args
542  h = self.h
543  met = PyParticleTools.getMissingET (args.met_container)
544  h.metx.Fill (met.etx())
545  h.mety.Fill (met.ety())
546  met.pt = math.hypot (met.etx(), met.ety())
547  h.met.Fill (met.pt)
548  return met
549 
550 

◆ get_muons()

def PyAlgorithmExample.PyAlgorithmExample.get_muons (   self)

Definition at line 491 of file PyAlgorithmExample.py.

491  def get_muons (self):
492  args = self.args
493  h = self.h
494 
495  # Helper function: apply kinematic cuts to candidate M.
496  def select (m):
497  return m.pt() > args.muo_pt_cut and abs(m.eta()) < args.muo_eta_cut
498 
499  # Fetch muons from storegate, apply
500  # kinematic cuts, then return the results. Fill histograms
501  # after each step.
502  muos = PyParticleTools.getMuons (args.muon_container)
503  h.muo0.fill (muos)
504  muos = [m for m in muos if select (m)]
505  h.muo1.fill (muos)
506  return muos
507 
508 

◆ get_taujets()

def PyAlgorithmExample.PyAlgorithmExample.get_taujets (   self)

Definition at line 512 of file PyAlgorithmExample.py.

512  def get_taujets (self):
513  args = self.args
514  h = self.h
515 
516  # Helper function: apply quality and kinematic cuts to candidate T.
517  def select (t):
518  if (t.pt() < args.taujet_pt_cut or
519  abs(t.eta()) > args.taujet_eta_cut):
520  return 0
521  if not fulldata(t): return 1
522  if t.likelihood() < args.taujet_likeli_cut: return 0
523  emfrac = t.etEM() / (t.etEM() + t.etHad())
524  if emfrac > args.taujet_max_emfrac: return 0
525  return 1
526 
527  # Fetch tau jets from storegate, apply quality and kinematic cuts,
528  # then return the results. Fill histograms before and after
529  # the cuts.
530  taujets = PyParticleTools.getTauJets (args.taujet_container)
531  h.taujet0.fill (taujets)
532  taujets = [t for t in taujets if select (t)]
533  h.taujet1.fill (taujets)
534  return taujets
535 
536 

Member Data Documentation

◆ args

PyAlgorithmExample.PyAlgorithmExample.args

Definition at line 351 of file PyAlgorithmExample.py.

◆ h

PyAlgorithmExample.PyAlgorithmExample.h

Definition at line 357 of file PyAlgorithmExample.py.


The documentation for this class was generated from the following file:
PyAlgorithmExample.fulldata
def fulldata(p)
Definition: PyAlgorithmExample.py:332
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
PyAlgorithmExample.Partlisthists_Z
def Partlisthists_Z(name, m_max=250 *GeV)
Definition: PyAlgorithmExample.py:322
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
DerivationFramework::ClustersInCone::select
void select(const xAOD::IParticle *particle, const float coneSize, const xAOD::CaloClusterContainer *clusters, std::vector< bool > &mask)
Definition: ClustersInCone.cxx:14