CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Attributes
reco::FlavorHistoryEvent Class Reference

#include <FlavorHistoryEvent.h>

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 (const 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 hitfit::clear().

reco::FlavorHistoryEvent::~FlavorHistoryEvent ( )
inline

Definition at line 110 of file FlavorHistoryEvent.h.

110 {}

Member Function Documentation

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

Definition at line 128 of file FlavorHistoryEvent.h.

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

Definition at line 11 of file FlavorHistoryEvent.cc.

References funct::abs(), popcon2dropbox::copy(), gather_cfg::cout, PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, reco::helpers::FlavorHistoryEventHelper::dR, reco::LeafCandidate::energy(), reco::helpers::FlavorHistoryEventHelper::flavor, reco::FlavorHistory::FLAVOR_NULL, reco::helpers::FlavorHistoryEventHelper::flavorSource, reco::FlavorHistory::flavorSource(), mps_fire::i, edm::Ptr< T >::isNonnull(), reco::ShallowClonePtrCandidate::masterClonePtr(), reco::FlavorHistory::matchedJet(), reco::FlavorHistory::parton(), cosmictrackingParticleSelector_cfi::pdgId, reco::Candidate::pdgId(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), and reco::LeafCandidate::pz().

12 {
13 
14  bool verbose = false;
15 
16  if ( verbose ) cout << "----- Caching Flavor History Event -----" << endl;
17  // Set cached to false
18  cached_ = false;
19  nb_ = nc_ = 0;
20  highestFlavor_ = 0;
21  dR_ = 0.0;
23 
24  // get list of flavor --> type --> dR.
25  // Will sort this later to determine event classification
26  vector<helpers::FlavorHistoryEventHelper> classification;
27 
28  // get iterators to the history vector
29  const_iterator i = histories_.begin(),
30  ibegin = histories_.begin(),
31  iend = histories_.end();
32  // loop over the history vector and count the number of
33  // partons of flavors "b" and "c" that have a matched genjet.
34  for ( ; i != iend; ++i ) {
35  FlavorHistory const & flavHist = *i;
36  if ( verbose ) cout << " Processing flavor history: " << i - ibegin << " = " << endl << flavHist << endl;
37  CandidatePtr const & parton = flavHist.parton();
39 
40  // Now examine the matched jets to see what the classification should be.
41  int pdgId = -1;
42  if ( parton.isNonnull() ) pdgId = abs(parton->pdgId());
43  ShallowClonePtrCandidate const & matchedJet = flavHist.matchedJet();
44  // Only count events with a matched genjet
45  if ( matchedJet.masterClonePtr().isNonnull() ) {
46  TLorentzVector p41 ( matchedJet.px(), matchedJet.py(), matchedJet.pz(), matchedJet.energy() );
47  if ( pdgId == 5 ) nb_++;
48  if ( pdgId == 4 ) nc_++;
49 
50  // Get the sister genjet
51  ShallowClonePtrCandidate const & sisterJet = i->sisterJet();
52  TLorentzVector p42 ( sisterJet.px(), sisterJet.py(), sisterJet.pz(), sisterJet.energy() );
53 
54 
55  // Now check the source.
56  double dR = -1;
57  if ( sisterJet.masterClonePtr().isNonnull() ) {
58  dR = p41.DeltaR( p42 );
59  }
60  // Add to the vector to be sorted later
61  if ( verbose ) cout << "Adding classification: pdgId = " << pdgId << ", flavorSource = " << flavorSource << ", dR = " << dR << endl;
62  classification.push_back( helpers::FlavorHistoryEventHelper ( pdgId, flavorSource, dR ) );
63  } else{
64  if ( verbose ) cout << "No matched jet found, not adding to classification list" << endl;
65  }
66  }
67 
68 
69  // Sort by priority
70 
71  // Priority is:
72  //
73  // 1. flavor (5 > 4)
74  // 2. type:
75  // 2a. Flavor decay
76  // 2b. Matrix element
77  // 2c. Flavor excitation
78  // 2d. Gluon splitting
79  // 3. delta R (if applicable)
80  if ( classification.size() > 0 ) {
81 
82 
83  std::sort( classification.begin(), classification.end() );
84 
85  if ( verbose ){ cout << "Writing out list of classifications" << endl;
86  copy(classification.begin(), classification.end(),
87  ostream_iterator<helpers::FlavorHistoryEventHelper>(cout, ""));
88  }
89 
90  helpers::FlavorHistoryEventHelper const & best = *(classification.rbegin());
91  dR_ = best.dR;
92  highestFlavor_ = best.flavor;
93  flavorSource_ = best.flavorSource;
94  }
95  else {
96  dR_ = -1.0;
97  highestFlavor_ = 0;
99  }
100 
101  // now we're cached, can return values quickly
102  cached_ = true;
103 }
flavor_type flavorSource() const
virtual const CandidatePtr & masterClonePtr() const
returns reference to master clone pointer
const reco::ShallowClonePtrCandidate & matchedJet() const
Definition: FlavorHistory.h:99
FLAVOR_T flavorSource() const
Definition: FlavorHistory.h:89
collection_type::const_iterator const_iterator
FlavorHistory::FLAVOR_T flavor_type
virtual int pdgId() const =0
PDG identifier.
virtual double px() const final
x coordinate of momentum vector
virtual double energy() const final
energy
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:169
virtual double pz() const final
z coordinate of momentum vector
virtual double py() const final
y coordinate of momentum vector
const reco::CandidatePtr & parton() const
Definition: FlavorHistory.h:95
void reco::FlavorHistoryEvent::clear ( void  )
inline
double reco::FlavorHistoryEvent::deltaR ( ) const
inline

Definition at line 121 of file FlavorHistoryEvent.h.

Referenced by FlavorHistoryFilter::filter().

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

Definition at line 129 of file FlavorHistoryEvent.h.

Referenced by Types.LuminosityBlockRange::cppID(), and Types.EventRange::cppID().

129 { return histories_.end(); }
flavor_type reco::FlavorHistoryEvent::flavorSource ( ) const
inline
unsigned int reco::FlavorHistoryEvent::highestFlavor ( ) const
inline

Definition at line 122 of file FlavorHistoryEvent.h.

Referenced by FlavorHistoryFilter::filter().

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

Definition at line 114 of file FlavorHistoryEvent.h.

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

Definition at line 117 of file FlavorHistoryEvent.h.

Referenced by FlavorHistoryFilter::filter().

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

Definition at line 118 of file FlavorHistoryEvent.h.

Referenced by FlavorHistoryFilter::filter().

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

Definition at line 134 of file FlavorHistoryEvent.h.

const_reverse_iterator reco::FlavorHistoryEvent::rbegin ( ) const
inline

Definition at line 130 of file FlavorHistoryEvent.h.

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

Definition at line 131 of file FlavorHistoryEvent.h.

131 { return histories_.rend(); }
void reco::FlavorHistoryEvent::resize ( size_t  n)
inline
size_type reco::FlavorHistoryEvent::size ( void  ) const
inline

Definition at line 127 of file FlavorHistoryEvent.h.

Referenced by ntupleDataFormat._Collection::__iter__(), and ntupleDataFormat._Collection::__len__().

127 { return histories_.size(); }

Member Data Documentation

bool reco::FlavorHistoryEvent::cached_
protected

Definition at line 140 of file FlavorHistoryEvent.h.

double reco::FlavorHistoryEvent::dR_
protected

Definition at line 143 of file FlavorHistoryEvent.h.

flavor_type reco::FlavorHistoryEvent::flavorSource_
protected

Definition at line 145 of file FlavorHistoryEvent.h.

unsigned int reco::FlavorHistoryEvent::highestFlavor_
protected

Definition at line 144 of file FlavorHistoryEvent.h.

collection_type reco::FlavorHistoryEvent::histories_
protected

Definition at line 139 of file FlavorHistoryEvent.h.

unsigned int reco::FlavorHistoryEvent::nb_
protected

Definition at line 141 of file FlavorHistoryEvent.h.

unsigned int reco::FlavorHistoryEvent::nc_
protected

Definition at line 142 of file FlavorHistoryEvent.h.