Go to the documentation of this file.00001 #include "PhysicsTools/HepMCCandAlgos/interface/FlavorHistorySelectorUtil.h"
00002
00003 #include <iostream>
00004
00005 using namespace std;
00006 using namespace reco;
00007
00008 FlavorHistorySelectorUtil::FlavorHistorySelectorUtil( unsigned int flavor,
00009 unsigned int noutput,
00010 flavor_vector const & flavorSource,
00011 double minDR,
00012 double maxDR,
00013 bool verbose ) :
00014 flavor_(flavor),
00015 noutput_(noutput),
00016 flavorSource_(flavorSource),
00017 minDR_(minDR),
00018 maxDR_(maxDR),
00019 verbose_(verbose)
00020 {
00021
00022
00023 if ( maxDR_ - minDR_ <= 0.001 ) maxDR_ += 0.001;
00024 }
00025
00026 bool FlavorHistorySelectorUtil::select(unsigned int nb,
00027 unsigned int nc,
00028 unsigned int highestFlavor,
00029 FlavorHistory::FLAVOR_T flavorSource,
00030 double dr ) const
00031 {
00032
00033
00034 if ( verbose_ ) {
00035 cout << "Looking at flavor history event: " << endl;
00036 cout << "source = " << flavorSource << endl;
00037 cout << "nbjet = " << nb << endl;
00038 cout << "ncjet = " << nc << endl;
00039 cout << "flavor = " << highestFlavor << endl;
00040 cout << "dr = " << dr << endl;
00041 }
00042
00043
00044
00045
00046 if ( highestFlavor > static_cast<unsigned int>(flavor_) ) {
00047 if ( verbose_ ) cout << "Rejecting event, highest flavor is " << highestFlavor << endl;
00048 return false;
00049 }
00050
00051
00052 vector<int>::const_iterator iflavorSource = find( flavorSource_.begin(), flavorSource_.end(), static_cast<int>(flavorSource) );
00053 if ( iflavorSource == flavorSource_.end() ) {
00054 if ( verbose_ ) cout << "Rejecting event, didn't find flavor source " << static_cast<int>(flavorSource) << endl;
00055 return false;
00056 }
00057
00058
00059 if ( flavor_ == reco::FlavorHistory::bQuarkId ) {
00060
00061 if ( nb <= 0 ) {
00062 if ( verbose_ ) cout << "Rejecting event, nb = " << nb << endl;
00063 return false;
00064 }
00065
00066 else {
00067
00068 if ( noutput_ == 1 && nb == 1 ) {
00069 if ( verbose_ ) cout << "Accepting event" << endl;
00070 return true;
00071 }
00072
00073 else if ( noutput_ > 1 && nb > 1 ) {
00074
00075
00076 if ( verbose_ ) cout << "Want multiples, dr = " << dr << endl;
00077 return ( dr >= minDR_ && dr < maxDR_ );
00078 }
00079
00080 else {
00081 if ( verbose_ ) cout << "Rejecting event, isn't output = 1 + nb = 1, or output > 0 and delta R in proper range" << endl;
00082 return false;
00083 }
00084 }
00085
00086 }
00087
00088
00089 else if ( flavor_ == reco::FlavorHistory::cQuarkId ) {
00090
00091
00092 if ( nb > 0 ) return false;
00093
00094
00095 if ( nc <= 0 ) return false;
00096
00097 else {
00098
00099 if ( noutput_ == 1 && nc == 1 ) {
00100 return true;
00101 }
00102
00103 else if ( noutput_ > 1 && nc > 1 ) {
00104
00105
00106 return ( dr >= minDR_ && dr < maxDR_ );
00107 }
00108
00109 else {
00110 return false;
00111 }
00112 }
00113
00114 }
00115
00116 else {
00117 if ( verbose_ ) cout << "Something is weird, flavor is " << flavor_ << endl;
00118 return false;
00119 }
00120 }