CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Attributes

reco::FlavorHistoryEvent Class Reference

#include <FlavorHistoryEvent.h>

List of all members.

Public Types

typedef std::vector< value_typecollection_type
typedef
collection_type::const_iterator 
const_iterator
typedef
collection_type::const_pointer 
const_pointer
typedef
collection_type::const_reference 
const_reference
typedef
collection_type::const_reverse_iterator 
const_reverse_iterator
typedef FlavorHistory::FLAVOR_T flavor_type
typedef collection_type::iterator iterator
typedef collection_type::pointer pointer
typedef collection_type::reference reference
typedef
collection_type::reverse_iterator 
reverse_iterator
typedef collection_type::size_type size_type
typedef FlavorHistory value_type

Public Member Functions

const_iterator begin () const
void cache ()
void clear ()
double deltaR () const
const_iterator end () const
 FlavorHistoryEvent ()
flavor_type flavorSource () const
unsigned int highestFlavor () const
bool isCached () const
unsigned int nb () const
unsigned int nc () const
void push_back (value_type v)
const_reverse_iterator rbegin () const
const_reverse_iterator rend () const
void resize (size_t n)
size_type size () const
 ~FlavorHistoryEvent ()

Protected Attributes

bool cached_
double dR_
flavor_type flavorSource_
unsigned int highestFlavor_
collection_type histories_
unsigned int nb_
unsigned int nc_

Detailed Description

Stores a vector of information about the flavor history of partons as well as a classification of the event.

It will return the following: nb = number of genjets that are matched to b partons nc = number of genjets that are matched to c partons

This can be used to classify the event, for instance, as W+bb (2 b partons), W+c (1 c parton), etc.

Author:
: Salvatore Rappoccio (JHU)

Definition at line 92 of file FlavorHistoryEvent.h.


Member Typedef Documentation

Definition at line 97 of file FlavorHistoryEvent.h.

typedef collection_type::const_iterator reco::FlavorHistoryEvent::const_iterator

Definition at line 100 of file FlavorHistoryEvent.h.

typedef collection_type::const_pointer reco::FlavorHistoryEvent::const_pointer

Definition at line 104 of file FlavorHistoryEvent.h.

typedef collection_type::const_reference reco::FlavorHistoryEvent::const_reference

Definition at line 106 of file FlavorHistoryEvent.h.

typedef collection_type::const_reverse_iterator reco::FlavorHistoryEvent::const_reverse_iterator

Definition at line 102 of file FlavorHistoryEvent.h.

Definition at line 107 of file FlavorHistoryEvent.h.

typedef collection_type::iterator reco::FlavorHistoryEvent::iterator

Definition at line 99 of file FlavorHistoryEvent.h.

typedef collection_type::pointer reco::FlavorHistoryEvent::pointer

Definition at line 103 of file FlavorHistoryEvent.h.

typedef collection_type::reference reco::FlavorHistoryEvent::reference

Definition at line 105 of file FlavorHistoryEvent.h.

typedef collection_type::reverse_iterator reco::FlavorHistoryEvent::reverse_iterator

Definition at line 101 of file FlavorHistoryEvent.h.

typedef collection_type::size_type reco::FlavorHistoryEvent::size_type

Definition at line 98 of file FlavorHistoryEvent.h.

Definition at line 96 of file FlavorHistoryEvent.h.


Constructor & Destructor Documentation

reco::FlavorHistoryEvent::FlavorHistoryEvent ( ) [inline]

Definition at line 109 of file FlavorHistoryEvent.h.

References clear().

{ clear(); }
reco::FlavorHistoryEvent::~FlavorHistoryEvent ( ) [inline]

Definition at line 110 of file FlavorHistoryEvent.h.

{}

Member Function Documentation

const_iterator reco::FlavorHistoryEvent::begin ( void  ) const [inline]

Definition at line 128 of file FlavorHistoryEvent.h.

References histories_.

{ return histories_.begin(); }
void FlavorHistoryEvent::cache ( )

Definition at line 11 of file FlavorHistoryEvent.cc.

References abs, filterCSVwithJSON::copy, gather_cfg::cout, reco::helpers::FlavorHistoryEventHelper::dR, reco::LeafCandidate::energy(), reco::helpers::FlavorHistoryEventHelper::flavor, reco::FlavorHistory::FLAVOR_NULL, reco::helpers::FlavorHistoryEventHelper::flavorSource, reco::FlavorHistory::flavorSource(), i, edm::Ptr< T >::isNonnull(), reco::ShallowClonePtrCandidate::masterClonePtr(), reco::FlavorHistory::matchedJet(), reco::FlavorHistory::parton(), benchmark_cfg::pdgId, reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), and python::multivaluedict::sort().

{

  bool verbose = false;
  
  if ( verbose ) cout << "----- Caching Flavor History Event  -----" << endl;
  // Set cached to false
  cached_ = false;
  nb_ = nc_ = 0;
  highestFlavor_ = 0;
  dR_ = 0.0;
  flavorSource_ = FlavorHistory::FLAVOR_NULL;

  // get list of flavor --> type --> dR.
  // Will sort this later to determine event classification
  vector<helpers::FlavorHistoryEventHelper> classification;

  // get iterators to the history vector
  const_iterator i = histories_.begin(),
    ibegin = histories_.begin(),
    iend = histories_.end();
  // loop over the history vector and count the number of 
  // partons of flavors "b" and "c" that have a matched genjet.
  for ( ; i != iend; ++i ) {
    FlavorHistory const & flavHist = *i;
    if ( verbose ) cout << "  Processing flavor history: " << i - ibegin << " = " << endl << flavHist << endl;
    CandidatePtr const & parton = flavHist.parton();
    flavor_type flavorSource = flavHist.flavorSource();

    // Now examine the matched jets to see what the classification should be.
    int pdgId = -1;
    if ( parton.isNonnull() ) pdgId = abs(parton->pdgId());
    ShallowClonePtrCandidate const & matchedJet = flavHist.matchedJet();
    // Only count events with a matched genjet
    if ( matchedJet.masterClonePtr().isNonnull() ) {
      TLorentzVector p41 ( matchedJet.px(), matchedJet.py(), matchedJet.pz(), matchedJet.energy() );
      if ( pdgId == 5 ) nb_++;
      if ( pdgId == 4 ) nc_++;

      // Get the sister genjet
      ShallowClonePtrCandidate const & sisterJet = i->sisterJet();
      TLorentzVector p42 ( sisterJet.px(), sisterJet.py(), sisterJet.pz(), sisterJet.energy() );


      // Now check the source.
      double dR = -1;
      if ( sisterJet.masterClonePtr().isNonnull() ) {
        dR = p41.DeltaR( p42 );
      }
      // Add to the vector to be sorted later
      if ( verbose ) cout << "Adding classification: pdgId = " << pdgId << ", flavorSource = " << flavorSource << ", dR = " << dR << endl;
      classification.push_back( helpers::FlavorHistoryEventHelper ( pdgId, flavorSource, dR ) );
    } else{
      if ( verbose ) cout << "No matched jet found, not adding to classification list" << endl;
    }
  } 


  // Sort by priority
  
  // Priority is:
  // 
  //  1. flavor (5 > 4)
  //  2. type:
  //      2a. Flavor decay
  //      2b. Matrix element
  //      2c. Flavor excitation
  //      2d. Gluon splitting
  //  3. delta R (if applicable)
  if ( classification.size() > 0 ) { 


    std::sort( classification.begin(), classification.end() );

    if ( verbose ){ cout << "Writing out list of classifications" << endl;
    copy(classification.begin(), classification.end(), 
         ostream_iterator<helpers::FlavorHistoryEventHelper>(cout, ""));
    }

    helpers::FlavorHistoryEventHelper const & best = *(classification.rbegin());
    dR_ = best.dR;
    highestFlavor_ = best.flavor;
    flavorSource_ = best.flavorSource;
  }
  else {
    dR_ = -1.0;
    highestFlavor_ = 0;
    flavorSource_ = FlavorHistory::FLAVOR_NULL;
  }

  // now we're cached, can return values quickly
  cached_ = true;
}
void reco::FlavorHistoryEvent::clear ( void  ) [inline]
double reco::FlavorHistoryEvent::deltaR ( ) const [inline]

Definition at line 121 of file FlavorHistoryEvent.h.

References dR_, and isCached().

{ if ( isCached() ) return dR_; else return -1.0; }
const_iterator reco::FlavorHistoryEvent::end ( void  ) const [inline]

Definition at line 129 of file FlavorHistoryEvent.h.

References histories_.

{ return histories_.end(); }
flavor_type reco::FlavorHistoryEvent::flavorSource ( ) const [inline]

Definition at line 123 of file FlavorHistoryEvent.h.

References reco::FlavorHistory::FLAVOR_NULL, flavorSource_, and isCached().

{ if ( isCached() ) return flavorSource_; else return FlavorHistory::FLAVOR_NULL; }
unsigned int reco::FlavorHistoryEvent::highestFlavor ( ) const [inline]

Definition at line 122 of file FlavorHistoryEvent.h.

References highestFlavor_, and isCached().

{ if ( isCached() ) return highestFlavor_; else return 0; }
bool reco::FlavorHistoryEvent::isCached ( ) const [inline]

Definition at line 114 of file FlavorHistoryEvent.h.

References cached_.

Referenced by deltaR(), flavorSource(), highestFlavor(), nb(), and nc().

{ return cached_; }
unsigned int reco::FlavorHistoryEvent::nb ( ) const [inline]

Definition at line 117 of file FlavorHistoryEvent.h.

References isCached(), and nb_.

{ if ( isCached() ) return nb_; else return 0;}
unsigned int reco::FlavorHistoryEvent::nc ( ) const [inline]

Definition at line 118 of file FlavorHistoryEvent.h.

References isCached(), and nc_.

{ if ( isCached() ) return nc_; else return 0;}
void reco::FlavorHistoryEvent::push_back ( value_type  v) [inline]

Definition at line 134 of file FlavorHistoryEvent.h.

References cached_, and histories_.

{ cached_ = false; histories_.push_back(v); }
const_reverse_iterator reco::FlavorHistoryEvent::rbegin ( ) const [inline]

Definition at line 130 of file FlavorHistoryEvent.h.

References histories_.

{ return histories_.rbegin(); }
const_reverse_iterator reco::FlavorHistoryEvent::rend ( ) const [inline]

Definition at line 131 of file FlavorHistoryEvent.h.

References histories_.

{ return histories_.rend(); }
void reco::FlavorHistoryEvent::resize ( size_t  n) [inline]

Definition at line 135 of file FlavorHistoryEvent.h.

References cached_, and histories_.

{ cached_ = false; histories_.resize(n); }
size_type reco::FlavorHistoryEvent::size ( void  ) const [inline]

Definition at line 127 of file FlavorHistoryEvent.h.

References histories_.

{ return histories_.size(); }

Member Data Documentation

Definition at line 140 of file FlavorHistoryEvent.h.

Referenced by clear(), isCached(), push_back(), and resize().

double reco::FlavorHistoryEvent::dR_ [protected]

Definition at line 143 of file FlavorHistoryEvent.h.

Referenced by clear(), and deltaR().

Definition at line 145 of file FlavorHistoryEvent.h.

Referenced by clear(), and flavorSource().

unsigned int reco::FlavorHistoryEvent::highestFlavor_ [protected]

Definition at line 144 of file FlavorHistoryEvent.h.

Referenced by clear(), and highestFlavor().

Definition at line 139 of file FlavorHistoryEvent.h.

Referenced by begin(), clear(), end(), push_back(), rbegin(), rend(), resize(), and size().

unsigned int reco::FlavorHistoryEvent::nb_ [protected]

Definition at line 141 of file FlavorHistoryEvent.h.

Referenced by clear(), and nb().

unsigned int reco::FlavorHistoryEvent::nc_ [protected]

Definition at line 142 of file FlavorHistoryEvent.h.

Referenced by clear(), and nc().