CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FlavorHistoryEvent.h
Go to the documentation of this file.
1 #ifndef HepMCCandidate_FlavorHistoryEvent_h
2 #define HepMCCandidate_FlavorHistoryEvent_h
3 
21 // -------------------------------------------------------------
22 // Identify the class of the event
23 //
24 // Reports nb, nc, nlight genjets that are matched
25 // to partons.
26 //
27 // -------------------------------------------------------------
28 
29 
35 
36 #include <fstream>
37 
38 namespace reco {
39 
40  namespace helpers {
41  // Helper class to decide which type of event this should be classified as.
42  //
43  // Decision is based on a priority weighting of:
44  // 1. flavor (5 > 4)
45  // 2. type:
46  // 2a. Flavor decay
47  // 2b. Matrix element
48  // 2c. Flavor excitation
49  // 2d. Gluon splitting
50  // 3. delta R (if applicable)
51  //
53 
55  FlavorHistory::FLAVOR_T iflavorSource,
56  double idR ) :
57  flavor(iflavor), flavorSource(iflavorSource), dR(idR)
58  {}
60 
61 
62  // Data members
63  int flavor; // pdg id
65  double dR; // if there is a sister, dR
66 
67  // Comparison operators
68  bool operator< ( FlavorHistoryEventHelper const & right) const {
69  if ( flavor > right.flavor ) return false;
70  if ( flavorSource > right.flavorSource ) return false;
71  if ( dR > right.dR ) return false;
72  return true;
73  }
74 
75  bool operator== ( FlavorHistoryEventHelper const & right) const {
76  return flavor == right.flavor &&
77  flavorSource == right.flavorSource &&
78  dR == right.dR;
79  }
80 
81  friend std::ostream & operator<< ( std::ostream & out,
82  FlavorHistoryEventHelper helper ) {
83  char buff[1000];
84  sprintf(buff, "Flavor = %2d, type = %2d, dR = %6f",
85  helper.flavor, helper.flavorSource, helper.dR );
86  out << buff << std::endl;
87  return out;
88  }
89  };
90  }
91 
93 public:
94 
95  // convenient typedefs
97  typedef std::vector<value_type> collection_type;
99  typedef collection_type::iterator iterator;
100  typedef collection_type::const_iterator const_iterator;
101  typedef collection_type::reverse_iterator reverse_iterator;
102  typedef collection_type::const_reverse_iterator const_reverse_iterator;
103  typedef collection_type::pointer pointer;
104  typedef collection_type::const_pointer const_pointer;
106  typedef collection_type::const_reference const_reference;
108 
111 
112  // Set up the heavy flavor content
113  void cache();
114  bool isCached() const { return cached_; }
115 
116  // Accessors to heavy flavor content
117  unsigned int nb() const { if ( isCached() ) return nb_; else return 0;}
118  unsigned int nc() const { if ( isCached() ) return nc_; else return 0;}
119 
120  // Accessor to maximum delta R between highest flavor constituents
121  double deltaR() const { if ( isCached() ) return dR_; else return -1.0; }
122  unsigned int highestFlavor() const { if ( isCached() ) return highestFlavor_; else return 0; }
124 
125  // vector interface.. when mutable, make sure cache is set to false.
126  // only allow const access via begin, end, rbegin, rend
127  size_type size() const { return histories_.size(); }
128  const_iterator begin() const { return histories_.begin(); }
129  const_iterator end() const { return histories_.end(); }
130  const_reverse_iterator rbegin() const { return histories_.rbegin(); }
131  const_reverse_iterator rend() const { return histories_.rend(); }
132  // here is the proper mutable interface... this is done so that the cache is
133  // set by us, not the user
134  void push_back( const value_type& v ) { cached_ = false; histories_.push_back(v); }
135  void resize( size_t n ) { cached_ = false; histories_.resize(n); }
136  void clear() { cached_ = false; histories_.clear(); nb_ = nc_ = 0; dR_ = 0.0; highestFlavor_ = 0; flavorSource_ = FlavorHistory::FLAVOR_NULL; }
137 
138 protected:
139  collection_type histories_; // FlavorHistory vector
140  bool cached_; // cached flag
141  unsigned int nb_; // number of b quark partons with a matched jet
142  unsigned int nc_; // number of c quark partons with a matched jet
143  double dR_; // maximum delta R between highest flavor constituents
144  unsigned int highestFlavor_; // highest flavor, corresponds to dR
145  flavor_type flavorSource_; // flavor source
146 };
147 
148 }
149 
150 #endif
const_iterator begin() const
const_reverse_iterator rend() const
unsigned int nc() const
collection_type::iterator iterator
collection_type::reverse_iterator reverse_iterator
flavor_type flavorSource() const
const_iterator end() const
FlavorHistoryEventHelper(int iflavor, FlavorHistory::FLAVOR_T iflavorSource, double idR)
uint16_t size_type
collection_type::const_iterator const_iterator
unsigned int nb() const
FlavorHistory::FLAVOR_T flavor_type
void push_back(const value_type &v)
unsigned int highestFlavor() const
bool operator==(FlavorHistoryEventHelper const &right) const
collection_type::const_pointer const_pointer
bool operator<(FlavorHistoryEventHelper const &right) const
friend std::ostream & operator<<(std::ostream &out, FlavorHistoryEventHelper helper)
tuple out
Definition: dbtoconf.py:99
const_reverse_iterator rbegin() const
collection_type::const_reverse_iterator const_reverse_iterator
collection_type::const_reference const_reference
std::vector< value_type > collection_type
collection_type::reference reference
collection_type::size_type size_type
collection_type::pointer pointer