File indexing completed on 2024-04-06 12:23:25
0001 #include "PhysicsTools/HepMCCandAlgos/interface/FlavorHistorySelectorUtil.h"
0002
0003 #include <iostream>
0004
0005 using namespace std;
0006 using namespace reco;
0007
0008 FlavorHistorySelectorUtil::FlavorHistorySelectorUtil(unsigned int flavor,
0009 unsigned int noutput,
0010 flavor_vector const& flavorSource,
0011 double minDR,
0012 double maxDR,
0013 bool verbose)
0014 : flavor_(flavor), noutput_(noutput), flavorSource_(flavorSource), minDR_(minDR), maxDR_(maxDR), verbose_(verbose) {
0015
0016 if (maxDR_ - minDR_ <= 0.001)
0017 maxDR_ += 0.001;
0018 }
0019
0020 bool FlavorHistorySelectorUtil::select(unsigned int nb,
0021 unsigned int nc,
0022 unsigned int highestFlavor,
0023 FlavorHistory::FLAVOR_T flavorSource,
0024 double dr) const {
0025
0026 if (verbose_) {
0027 cout << "Looking at flavor history event: " << endl;
0028 cout << "source = " << flavorSource << endl;
0029 cout << "nbjet = " << nb << endl;
0030 cout << "ncjet = " << nc << endl;
0031 cout << "flavor = " << highestFlavor << endl;
0032 cout << "dr = " << dr << endl;
0033 }
0034
0035
0036
0037
0038 if (highestFlavor > static_cast<unsigned int>(flavor_)) {
0039 if (verbose_)
0040 cout << "Rejecting event, highest flavor is " << highestFlavor << endl;
0041 return false;
0042 }
0043
0044
0045 vector<int>::const_iterator iflavorSource =
0046 find(flavorSource_.begin(), flavorSource_.end(), static_cast<int>(flavorSource));
0047 if (iflavorSource == flavorSource_.end()) {
0048 if (verbose_)
0049 cout << "Rejecting event, didn't find flavor source " << static_cast<int>(flavorSource) << endl;
0050 return false;
0051 }
0052
0053
0054 if (flavor_ == reco::FlavorHistory::bQuarkId) {
0055
0056 if (nb <= 0) {
0057 if (verbose_)
0058 cout << "Rejecting event, nb = " << nb << endl;
0059 return false;
0060 }
0061
0062 else {
0063
0064 if (noutput_ == 1 && nb == 1) {
0065 if (verbose_)
0066 cout << "Accepting event" << endl;
0067 return true;
0068 }
0069
0070 else if (noutput_ > 1 && nb > 1) {
0071
0072
0073 if (verbose_)
0074 cout << "Want multiples, dr = " << dr << endl;
0075 return (dr >= minDR_ && dr < maxDR_);
0076 }
0077
0078 else {
0079 if (verbose_)
0080 cout << "Rejecting event, isn't output = 1 + nb = 1, or output > 0 and delta R in proper range" << endl;
0081 return false;
0082 }
0083 }
0084
0085 }
0086
0087
0088 else if (flavor_ == reco::FlavorHistory::cQuarkId) {
0089
0090
0091 if (nb > 0)
0092 return false;
0093
0094
0095 if (nc <= 0)
0096 return false;
0097
0098 else {
0099
0100 if (noutput_ == 1 && nc == 1) {
0101 return true;
0102 }
0103
0104 else if (noutput_ > 1 && nc > 1) {
0105
0106
0107 return (dr >= minDR_ && dr < maxDR_);
0108 }
0109
0110 else {
0111 return false;
0112 }
0113 }
0114
0115 }
0116
0117 else {
0118 if (verbose_)
0119 cout << "Something is weird, flavor is " << flavor_ << endl;
0120 return false;
0121 }
0122 }