CMS 3D CMS Logo

FlavorHistoryEvent.h
Go to the documentation of this file.
1 #ifndef HepMCCandidate_FlavorHistoryEvent_h
2 #define HepMCCandidate_FlavorHistoryEvent_h
3 
20 // -------------------------------------------------------------
21 // Identify the class of the event
22 //
23 // Reports nb, nc, nlight genjets that are matched
24 // to partons.
25 //
26 // -------------------------------------------------------------
27 
33 
34 #include <fstream>
35 
36 namespace reco {
37 
38  namespace helpers {
39  // Helper class to decide which type of event this should be classified as.
40  //
41  // Decision is based on a priority weighting of:
42  // 1. flavor (5 > 4)
43  // 2. type:
44  // 2a. Flavor decay
45  // 2b. Matrix element
46  // 2c. Flavor excitation
47  // 2d. Gluon splitting
48  // 3. delta R (if applicable)
49  //
51  FlavorHistoryEventHelper(int iflavor, FlavorHistory::FLAVOR_T iflavorSource, double idR)
52  : flavor(iflavor), flavorSource(iflavorSource), dR(idR) {}
54 
55  // Data members
56  int flavor; // pdg id
58  double dR; // if there is a sister, dR
59 
60  // Comparison operators
61  bool operator<(FlavorHistoryEventHelper const& right) const {
62  if (flavor > right.flavor)
63  return false;
64  if (flavorSource > right.flavorSource)
65  return false;
66  if (dR > right.dR)
67  return false;
68  return true;
69  }
70 
71  bool operator==(FlavorHistoryEventHelper const& right) const {
72  return flavor == right.flavor && flavorSource == right.flavorSource && dR == right.dR;
73  }
74 
75  friend std::ostream& operator<<(std::ostream& out, FlavorHistoryEventHelper helper) {
76  char buff[1000];
77  sprintf(buff, "Flavor = %2d, type = %2d, dR = %6f", helper.flavor, helper.flavorSource, helper.dR);
78  out << buff << std::endl;
79  return out;
80  }
81  };
82  } // namespace helpers
83 
85  public:
86  // convenient typedefs
88  typedef std::vector<value_type> collection_type;
90  typedef collection_type::iterator iterator;
91  typedef collection_type::const_iterator const_iterator;
92  typedef collection_type::reverse_iterator reverse_iterator;
93  typedef collection_type::const_reverse_iterator const_reverse_iterator;
94  typedef collection_type::pointer pointer;
95  typedef collection_type::const_pointer const_pointer;
97  typedef collection_type::const_reference const_reference;
99 
102 
103  // Set up the heavy flavor content
104  void cache();
105  bool isCached() const { return cached_; }
106 
107  // Accessors to heavy flavor content
108  unsigned int nb() const {
109  if (isCached())
110  return nb_;
111  else
112  return 0;
113  }
114  unsigned int nc() const {
115  if (isCached())
116  return nc_;
117  else
118  return 0;
119  }
120 
121  // Accessor to maximum delta R between highest flavor constituents
122  double deltaR() const {
123  if (isCached())
124  return dR_;
125  else
126  return -1.0;
127  }
128  unsigned int highestFlavor() const {
129  if (isCached())
130  return highestFlavor_;
131  else
132  return 0;
133  }
135  if (isCached())
136  return flavorSource_;
137  else
139  }
140 
141  // vector interface.. when mutable, make sure cache is set to false.
142  // only allow const access via begin, end, rbegin, rend
143  size_type size() const { return histories_.size(); }
144  const_iterator begin() const { return histories_.begin(); }
145  const_iterator end() const { return histories_.end(); }
146  const_reverse_iterator rbegin() const { return histories_.rbegin(); }
147  const_reverse_iterator rend() const { return histories_.rend(); }
148  // here is the proper mutable interface... this is done so that the cache is
149  // set by us, not the user
150  void push_back(const value_type& v) {
151  cached_ = false;
152  histories_.push_back(v);
153  }
154  void resize(size_t n) {
155  cached_ = false;
156  histories_.resize(n);
157  }
158  void clear() {
159  cached_ = false;
160  histories_.clear();
161  nb_ = nc_ = 0;
162  dR_ = 0.0;
163  highestFlavor_ = 0;
165  }
166 
167  protected:
168  collection_type histories_; // FlavorHistory vector
169  bool cached_; // cached flag
170  unsigned int nb_; // number of b quark partons with a matched jet
171  unsigned int nc_; // number of c quark partons with a matched jet
172  double dR_; // maximum delta R between highest flavor constituents
173  unsigned int highestFlavor_; // highest flavor, corresponds to dR
174  flavor_type flavorSource_; // flavor source
175  };
176 
177 } // namespace reco
178 
179 #endif
FlavorHistory.h
reco::FlavorHistoryEvent::cache
void cache()
Definition: FlavorHistoryEvent.cc:11
Handle.h
reco::FlavorHistory
Definition: FlavorHistory.h:45
reco::FlavorHistoryEvent::rend
const_reverse_iterator rend() const
Definition: FlavorHistoryEvent.h:147
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
reco::FlavorHistoryEvent::isCached
bool isCached() const
Definition: FlavorHistoryEvent.h:105
reco::FlavorHistoryEvent::flavor_type
FlavorHistory::FLAVOR_T flavor_type
Definition: FlavorHistoryEvent.h:98
reco::FlavorHistoryEvent::begin
const_iterator begin() const
Definition: FlavorHistoryEvent.h:144
reco::FlavorHistoryEvent::reference
collection_type::reference reference
Definition: FlavorHistoryEvent.h:96
reco::helpers::FlavorHistoryEventHelper::~FlavorHistoryEventHelper
~FlavorHistoryEventHelper()
Definition: FlavorHistoryEvent.h:53
reco::FlavorHistoryEvent::flavorSource_
flavor_type flavorSource_
Definition: FlavorHistoryEvent.h:174
reco::FlavorHistoryEvent::nb
unsigned int nb() const
Definition: FlavorHistoryEvent.h:108
reco::FlavorHistoryEvent
Definition: FlavorHistoryEvent.h:84
reco::FlavorHistoryEvent::~FlavorHistoryEvent
~FlavorHistoryEvent()
Definition: FlavorHistoryEvent.h:101
reco::FlavorHistoryEvent::nc
unsigned int nc() const
Definition: FlavorHistoryEvent.h:114
reco::FlavorHistoryEvent::cached_
bool cached_
Definition: FlavorHistoryEvent.h:169
reco::FlavorHistoryEvent::const_reference
collection_type::const_reference const_reference
Definition: FlavorHistoryEvent.h:97
reco::FlavorHistoryEvent::highestFlavor_
unsigned int highestFlavor_
Definition: FlavorHistoryEvent.h:173
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
reco::FlavorHistoryEvent::nb_
unsigned int nb_
Definition: FlavorHistoryEvent.h:170
findQualityFiles.v
v
Definition: findQualityFiles.py:179
reco::FlavorHistoryEvent::size_type
collection_type::size_type size_type
Definition: FlavorHistoryEvent.h:89
reco::helpers::FlavorHistoryEventHelper
Definition: FlavorHistoryEvent.h:50
reco::FlavorHistoryEvent::const_reverse_iterator
collection_type::const_reverse_iterator const_reverse_iterator
Definition: FlavorHistoryEvent.h:93
reco::helpers::FlavorHistoryEventHelper::FlavorHistoryEventHelper
FlavorHistoryEventHelper(int iflavor, FlavorHistory::FLAVOR_T iflavorSource, double idR)
Definition: FlavorHistoryEvent.h:51
reco::FlavorHistoryEvent::size
size_type size() const
Definition: FlavorHistoryEvent.h:143
reco::helpers::FlavorHistoryEventHelper::operator<
bool operator<(FlavorHistoryEventHelper const &right) const
Definition: FlavorHistoryEvent.h:61
reco::FlavorHistoryEvent::flavorSource
flavor_type flavorSource() const
Definition: FlavorHistoryEvent.h:134
reco::FlavorHistoryEvent::highestFlavor
unsigned int highestFlavor() const
Definition: FlavorHistoryEvent.h:128
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
reco::FlavorHistoryEvent::iterator
collection_type::iterator iterator
Definition: FlavorHistoryEvent.h:90
reco::FlavorHistory::FLAVOR_T
FLAVOR_T
Definition: FlavorHistory.h:47
reco::FlavorHistoryEvent::pointer
collection_type::pointer pointer
Definition: FlavorHistoryEvent.h:94
reco::FlavorHistoryEvent::deltaR
double deltaR() const
Definition: FlavorHistoryEvent.h:122
reco::FlavorHistoryEvent::clear
void clear()
Definition: FlavorHistoryEvent.h:158
reco::helpers::FlavorHistoryEventHelper::dR
double dR
Definition: FlavorHistoryEvent.h:58
helpers
Definition: makeCompositeCandidate.h:8
reco::FlavorHistoryEvent::collection_type
std::vector< value_type > collection_type
Definition: FlavorHistoryEvent.h:88
reco::FlavorHistoryEvent::nc_
unsigned int nc_
Definition: FlavorHistoryEvent.h:171
helper
Definition: helper.py:1
reco::helpers::FlavorHistoryEventHelper::operator<<
friend std::ostream & operator<<(std::ostream &out, FlavorHistoryEventHelper helper)
Definition: FlavorHistoryEvent.h:75
RecoTauValidation_cfi.reference
reference
Definition: RecoTauValidation_cfi.py:234
Ptr.h
reco::FlavorHistoryEvent::FlavorHistoryEvent
FlavorHistoryEvent()
Definition: FlavorHistoryEvent.h:100
reco::FlavorHistoryEvent::end
const_iterator end() const
Definition: FlavorHistoryEvent.h:145
reco::helpers::FlavorHistoryEventHelper::flavorSource
FlavorHistory::FLAVOR_T flavorSource
Definition: FlavorHistoryEvent.h:57
reco::FlavorHistory::FLAVOR_NULL
Definition: FlavorHistory.h:48
reco::FlavorHistoryEvent::value_type
FlavorHistory value_type
Definition: FlavorHistoryEvent.h:87
reco::FlavorHistoryEvent::const_pointer
collection_type::const_pointer const_pointer
Definition: FlavorHistoryEvent.h:95
reco::FlavorHistoryEvent::push_back
void push_back(const value_type &v)
Definition: FlavorHistoryEvent.h:150
reco::FlavorHistoryEvent::dR_
double dR_
Definition: FlavorHistoryEvent.h:172
reco::helpers::FlavorHistoryEventHelper::operator==
bool operator==(FlavorHistoryEventHelper const &right) const
Definition: FlavorHistoryEvent.h:71
reco::FlavorHistoryEvent::const_iterator
collection_type::const_iterator const_iterator
Definition: FlavorHistoryEvent.h:91
reco::FlavorHistoryEvent::reverse_iterator
collection_type::reverse_iterator reverse_iterator
Definition: FlavorHistoryEvent.h:92
reco::helpers::FlavorHistoryEventHelper::flavor
int flavor
Definition: FlavorHistoryEvent.h:56
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
View.h
OwnVector.h
reco::FlavorHistoryEvent::resize
void resize(size_t n)
Definition: FlavorHistoryEvent.h:154
reco::FlavorHistoryEvent::histories_
collection_type histories_
Definition: FlavorHistoryEvent.h:168
reco::FlavorHistoryEvent::rbegin
const_reverse_iterator rbegin() const
Definition: FlavorHistoryEvent.h:146