Go to the documentation of this file.00001 #ifndef HepMCCandidate_FlavorHistoryEvent_h
00002 #define HepMCCandidate_FlavorHistoryEvent_h
00003
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "DataFormats/Common/interface/Ptr.h"
00031 #include "DataFormats/Common/interface/OwnVector.h"
00032 #include "DataFormats/Common/interface/Handle.h"
00033 #include "DataFormats/Common/interface/View.h"
00034 #include "DataFormats/HepMCCandidate/interface/FlavorHistory.h"
00035
00036 #include <fstream>
00037
00038 namespace reco {
00039
00040 namespace helpers {
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 struct FlavorHistoryEventHelper{
00053
00054 FlavorHistoryEventHelper( int iflavor,
00055 FlavorHistory::FLAVOR_T iflavorSource,
00056 double idR ) :
00057 flavor(iflavor), flavorSource(iflavorSource), dR(idR)
00058 {}
00059 ~FlavorHistoryEventHelper() {}
00060
00061
00062
00063 int flavor;
00064 FlavorHistory::FLAVOR_T flavorSource;
00065 double dR;
00066
00067
00068 bool operator< ( FlavorHistoryEventHelper const & right) const {
00069 if ( flavor > right.flavor ) return false;
00070 if ( flavorSource > right.flavorSource ) return false;
00071 if ( dR > right.dR ) return false;
00072 return true;
00073 }
00074
00075 bool operator== ( FlavorHistoryEventHelper const & right) const {
00076 return flavor == right.flavor &&
00077 flavorSource == right.flavorSource &&
00078 dR == right.dR;
00079 }
00080
00081 friend std::ostream & operator<< ( std::ostream & out,
00082 FlavorHistoryEventHelper helper ) {
00083 char buff[1000];
00084 sprintf(buff, "Flavor = %2d, type = %2d, dR = %6f",
00085 helper.flavor, helper.flavorSource, helper.dR );
00086 out << buff << std::endl;
00087 return out;
00088 }
00089 };
00090 }
00091
00092 class FlavorHistoryEvent {
00093 public:
00094
00095
00096 typedef FlavorHistory value_type;
00097 typedef std::vector<value_type> collection_type;
00098 typedef collection_type::size_type size_type;
00099 typedef collection_type::iterator iterator;
00100 typedef collection_type::const_iterator const_iterator;
00101 typedef collection_type::reverse_iterator reverse_iterator;
00102 typedef collection_type::const_reverse_iterator const_reverse_iterator;
00103 typedef collection_type::pointer pointer;
00104 typedef collection_type::const_pointer const_pointer;
00105 typedef collection_type::reference reference;
00106 typedef collection_type::const_reference const_reference;
00107 typedef FlavorHistory::FLAVOR_T flavor_type;
00108
00109 FlavorHistoryEvent() { clear(); }
00110 ~FlavorHistoryEvent(){}
00111
00112
00113 void cache();
00114 bool isCached() const { return cached_; }
00115
00116
00117 unsigned int nb() const { if ( isCached() ) return nb_; else return 0;}
00118 unsigned int nc() const { if ( isCached() ) return nc_; else return 0;}
00119
00120
00121 double deltaR() const { if ( isCached() ) return dR_; else return -1.0; }
00122 unsigned int highestFlavor() const { if ( isCached() ) return highestFlavor_; else return 0; }
00123 flavor_type flavorSource() const { if ( isCached() ) return flavorSource_; else return FlavorHistory::FLAVOR_NULL; }
00124
00125
00126
00127 size_type size() const { return histories_.size(); }
00128 const_iterator begin() const { return histories_.begin(); }
00129 const_iterator end() const { return histories_.end(); }
00130 const_reverse_iterator rbegin() const { return histories_.rbegin(); }
00131 const_reverse_iterator rend() const { return histories_.rend(); }
00132
00133
00134 void push_back( value_type v ) { cached_ = false; histories_.push_back(v); }
00135 void resize( size_t n ) { cached_ = false; histories_.resize(n); }
00136 void clear() { cached_ = false; histories_.clear(); nb_ = nc_ = 0; dR_ = 0.0; highestFlavor_ = 0; flavorSource_ = FlavorHistory::FLAVOR_NULL; }
00137
00138 protected:
00139 collection_type histories_;
00140 bool cached_;
00141 unsigned int nb_;
00142 unsigned int nc_;
00143 double dR_;
00144 unsigned int highestFlavor_;
00145 flavor_type flavorSource_;
00146 };
00147
00148 }
00149
00150 #endif