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 84 of file FlavorHistoryEvent.h.

Member Typedef Documentation

◆ collection_type

Definition at line 88 of file FlavorHistoryEvent.h.

◆ const_iterator

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

Definition at line 91 of file FlavorHistoryEvent.h.

◆ const_pointer

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

Definition at line 95 of file FlavorHistoryEvent.h.

◆ const_reference

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

Definition at line 97 of file FlavorHistoryEvent.h.

◆ const_reverse_iterator

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

Definition at line 93 of file FlavorHistoryEvent.h.

◆ flavor_type

Definition at line 98 of file FlavorHistoryEvent.h.

◆ iterator

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

Definition at line 90 of file FlavorHistoryEvent.h.

◆ pointer

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

Definition at line 94 of file FlavorHistoryEvent.h.

◆ reference

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

Definition at line 96 of file FlavorHistoryEvent.h.

◆ reverse_iterator

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

Definition at line 92 of file FlavorHistoryEvent.h.

◆ size_type

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

Definition at line 89 of file FlavorHistoryEvent.h.

◆ value_type

Definition at line 87 of file FlavorHistoryEvent.h.

Constructor & Destructor Documentation

◆ FlavorHistoryEvent()

reco::FlavorHistoryEvent::FlavorHistoryEvent ( )
inline

Definition at line 100 of file FlavorHistoryEvent.h.

References clear().

◆ ~FlavorHistoryEvent()

reco::FlavorHistoryEvent::~FlavorHistoryEvent ( )
inline

Definition at line 101 of file FlavorHistoryEvent.h.

101 {}

Member Function Documentation

◆ begin()

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

Definition at line 144 of file FlavorHistoryEvent.h.

References histories_.

144 { return histories_.begin(); }

◆ cache()

void FlavorHistoryEvent::cache ( )

Definition at line 11 of file FlavorHistoryEvent.cc.

References funct::abs(), filterCSVwithJSON::copy, gather_cfg::cout, HGC3DClusterGenMatchSelector_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(), EgammaValidation_cff::pdgId, reco::Candidate::pdgId(), reco::LeafCandidate::px(), reco::LeafCandidate::py(), reco::LeafCandidate::pz(), jetUpdater_cfi::sort, and verbose.

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

◆ clear()

void reco::FlavorHistoryEvent::clear ( void  )
inline

◆ deltaR()

double reco::FlavorHistoryEvent::deltaR ( ) const
inline

Definition at line 122 of file FlavorHistoryEvent.h.

References dR_, and isCached().

Referenced by FlavorHistoryFilter::filter().

122  {
123  if (isCached())
124  return dR_;
125  else
126  return -1.0;
127  }

◆ end()

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

Definition at line 145 of file FlavorHistoryEvent.h.

References histories_.

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

145 { return histories_.end(); }

◆ flavorSource()

flavor_type reco::FlavorHistoryEvent::flavorSource ( ) const
inline

Definition at line 134 of file FlavorHistoryEvent.h.

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

Referenced by FlavorHistoryFilter::filter().

134  {
135  if (isCached())
136  return flavorSource_;
137  else
139  }

◆ highestFlavor()

unsigned int reco::FlavorHistoryEvent::highestFlavor ( ) const
inline

Definition at line 128 of file FlavorHistoryEvent.h.

References highestFlavor_, and isCached().

Referenced by FlavorHistoryFilter::filter().

128  {
129  if (isCached())
130  return highestFlavor_;
131  else
132  return 0;
133  }

◆ isCached()

bool reco::FlavorHistoryEvent::isCached ( ) const
inline

Definition at line 105 of file FlavorHistoryEvent.h.

References cached_.

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

105 { return cached_; }

◆ nb()

unsigned int reco::FlavorHistoryEvent::nb ( ) const
inline

Definition at line 108 of file FlavorHistoryEvent.h.

References isCached(), and nb_.

Referenced by FlavorHistoryFilter::filter().

108  {
109  if (isCached())
110  return nb_;
111  else
112  return 0;
113  }

◆ nc()

unsigned int reco::FlavorHistoryEvent::nc ( ) const
inline

Definition at line 114 of file FlavorHistoryEvent.h.

References isCached(), and nc_.

Referenced by FlavorHistoryFilter::filter().

114  {
115  if (isCached())
116  return nc_;
117  else
118  return 0;
119  }

◆ push_back()

void reco::FlavorHistoryEvent::push_back ( const value_type v)
inline

Definition at line 150 of file FlavorHistoryEvent.h.

References cached_, histories_, and findQualityFiles::v.

150  {
151  cached_ = false;
152  histories_.push_back(v);
153  }

◆ rbegin()

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

Definition at line 146 of file FlavorHistoryEvent.h.

References histories_.

146 { return histories_.rbegin(); }

◆ rend()

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

Definition at line 147 of file FlavorHistoryEvent.h.

References histories_.

147 { return histories_.rend(); }

◆ resize()

void reco::FlavorHistoryEvent::resize ( size_t  n)
inline

Definition at line 154 of file FlavorHistoryEvent.h.

References cached_, histories_, and dqmiodumpmetadata::n.

154  {
155  cached_ = false;
156  histories_.resize(n);
157  }

◆ size()

size_type reco::FlavorHistoryEvent::size ( void  ) const
inline

Definition at line 143 of file FlavorHistoryEvent.h.

References histories_.

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

143 { return histories_.size(); }

Member Data Documentation

◆ cached_

bool reco::FlavorHistoryEvent::cached_
protected

Definition at line 169 of file FlavorHistoryEvent.h.

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

◆ dR_

double reco::FlavorHistoryEvent::dR_
protected

Definition at line 172 of file FlavorHistoryEvent.h.

Referenced by clear(), and deltaR().

◆ flavorSource_

flavor_type reco::FlavorHistoryEvent::flavorSource_
protected

Definition at line 174 of file FlavorHistoryEvent.h.

Referenced by clear(), and flavorSource().

◆ highestFlavor_

unsigned int reco::FlavorHistoryEvent::highestFlavor_
protected

Definition at line 173 of file FlavorHistoryEvent.h.

Referenced by clear(), and highestFlavor().

◆ histories_

collection_type reco::FlavorHistoryEvent::histories_
protected

Definition at line 168 of file FlavorHistoryEvent.h.

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

◆ nb_

unsigned int reco::FlavorHistoryEvent::nb_
protected

Definition at line 170 of file FlavorHistoryEvent.h.

Referenced by clear(), and nb().

◆ nc_

unsigned int reco::FlavorHistoryEvent::nc_
protected

Definition at line 171 of file FlavorHistoryEvent.h.

Referenced by clear(), and nc().