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.

100 { clear(); }

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.

144 { return histories_.begin(); }

References histories_.

◆ cache()

void FlavorHistoryEvent::cache ( )

Definition at line 11 of file FlavorHistoryEvent.cc.

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 }

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.

◆ clear()

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

Definition at line 158 of file FlavorHistoryEvent.h.

158  {
159  cached_ = false;
160  histories_.clear();
161  nb_ = nc_ = 0;
162  dR_ = 0.0;
163  highestFlavor_ = 0;
165  }

References cached_, dR_, reco::FlavorHistory::FLAVOR_NULL, flavorSource_, highestFlavor_, histories_, nb_, and nc_.

Referenced by FlavorHistoryEvent(), and BeautifulSoup.Tag::setString().

◆ deltaR()

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

Definition at line 122 of file FlavorHistoryEvent.h.

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

References dR_, and isCached().

Referenced by FlavorHistoryFilter::filter().

◆ end()

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

Definition at line 145 of file FlavorHistoryEvent.h.

145 { return histories_.end(); }

References histories_.

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

◆ flavorSource()

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

Definition at line 134 of file FlavorHistoryEvent.h.

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

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

Referenced by FlavorHistoryFilter::filter().

◆ highestFlavor()

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

Definition at line 128 of file FlavorHistoryEvent.h.

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

References highestFlavor_, and isCached().

Referenced by FlavorHistoryFilter::filter().

◆ isCached()

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

Definition at line 105 of file FlavorHistoryEvent.h.

105 { return cached_; }

References cached_.

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

◆ nb()

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

Definition at line 108 of file FlavorHistoryEvent.h.

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

References isCached(), and nb_.

Referenced by FlavorHistoryFilter::filter().

◆ nc()

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

Definition at line 114 of file FlavorHistoryEvent.h.

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

References isCached(), and nc_.

Referenced by FlavorHistoryFilter::filter().

◆ push_back()

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

Definition at line 150 of file FlavorHistoryEvent.h.

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

References cached_, histories_, and findQualityFiles::v.

◆ rbegin()

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

Definition at line 146 of file FlavorHistoryEvent.h.

146 { return histories_.rbegin(); }

References histories_.

◆ rend()

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

Definition at line 147 of file FlavorHistoryEvent.h.

147 { return histories_.rend(); }

References histories_.

◆ resize()

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

Definition at line 154 of file FlavorHistoryEvent.h.

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

References cached_, histories_, and dqmiodumpmetadata::n.

◆ size()

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

Definition at line 143 of file FlavorHistoryEvent.h.

143 { return histories_.size(); }

References histories_.

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

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().

mps_fire.i
i
Definition: mps_fire.py:428
reco::FlavorHistory
Definition: FlavorHistory.h:45
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
reco::FlavorHistoryEvent::isCached
bool isCached() const
Definition: FlavorHistoryEvent.h:105
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
reco::FlavorHistory::flavorSource
FLAVOR_T flavorSource() const
Definition: FlavorHistory.h:85
reco::FlavorHistoryEvent::flavor_type
FlavorHistory::FLAVOR_T flavor_type
Definition: FlavorHistoryEvent.h:98
reco::FlavorHistoryEvent::flavorSource_
flavor_type flavorSource_
Definition: FlavorHistoryEvent.h:174
gather_cfg.cout
cout
Definition: gather_cfg.py:144
reco::FlavorHistoryEvent::cached_
bool cached_
Definition: FlavorHistoryEvent.h:169
reco::FlavorHistoryEvent::highestFlavor_
unsigned int highestFlavor_
Definition: FlavorHistoryEvent.h:173
reco::FlavorHistoryEvent::nb_
unsigned int nb_
Definition: FlavorHistoryEvent.h:170
findQualityFiles.v
v
Definition: findQualityFiles.py:179
reco::FlavorHistoryEvent::flavorSource
flavor_type flavorSource() const
Definition: FlavorHistoryEvent.h:134
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
reco::FlavorHistoryEvent::clear
void clear()
Definition: FlavorHistoryEvent.h:158
reco::FlavorHistory::parton
const reco::CandidatePtr & parton() const
Definition: FlavorHistory.h:91
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
reco::FlavorHistoryEvent::nc_
unsigned int nc_
Definition: FlavorHistoryEvent.h:171
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
reco::FlavorHistory::FLAVOR_NULL
Definition: FlavorHistory.h:48
reco::Candidate::pdgId
virtual int pdgId() const =0
PDG identifier.
edm::Ptr< Candidate >
reco::FlavorHistoryEvent::dR_
double dR_
Definition: FlavorHistoryEvent.h:172
reco::FlavorHistoryEvent::const_iterator
collection_type::const_iterator const_iterator
Definition: FlavorHistoryEvent.h:91
edm::Ptr::isNonnull
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:146
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
reco::ShallowClonePtrCandidate
Definition: ShallowClonePtrCandidate.h:15
reco::ShallowClonePtrCandidate::masterClonePtr
const CandidatePtr & masterClonePtr() const override
returns reference to master clone pointer
Definition: ShallowClonePtrCandidate.cc:20
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140
reco::LeafCandidate::pz
double pz() const final
z coordinate of momentum vector
Definition: LeafCandidate.h:144
reco::FlavorHistory::matchedJet
const reco::ShallowClonePtrCandidate & matchedJet() const
Definition: FlavorHistory.h:94
reco::FlavorHistoryEvent::histories_
collection_type histories_
Definition: FlavorHistoryEvent.h:168