CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
reco::FlavorHistorySelectorUtil Class Reference

#include <FlavorHistorySelectorUtil.h>

Public Types

typedef
reco::FlavorHistory::FLAVOR_T 
flavor_type
 
typedef std::vector< int > flavor_vector
 

Public Member Functions

 FlavorHistorySelectorUtil (unsigned int flavor, unsigned int noutput, flavor_vector const &flavorSource, double minDR, double maxDR, bool verbose)
 
bool select (unsigned int nb, unsigned int nc, unsigned int highestFlavor, FlavorHistory::FLAVOR_T flavorSource, double dr) const
 
 ~FlavorHistorySelectorUtil ()
 

Private Attributes

int flavor_
 
flavor_vector flavorSource_
 
double maxDR_
 
double minDR_
 
int noutput_
 
bool verbose_
 

Detailed Description

Definition at line 54 of file FlavorHistorySelectorUtil.h.

Member Typedef Documentation

Definition at line 56 of file FlavorHistorySelectorUtil.h.

Definition at line 57 of file FlavorHistorySelectorUtil.h.

Constructor & Destructor Documentation

FlavorHistorySelectorUtil::FlavorHistorySelectorUtil ( unsigned int  flavor,
unsigned int  noutput,
flavor_vector const &  flavorSource,
double  minDR,
double  maxDR,
bool  verbose 
)

Definition at line 8 of file FlavorHistorySelectorUtil.cc.

References maxDR_, and minDR_.

13  :
14  flavor_(flavor),
15  noutput_(noutput),
16  flavorSource_(flavorSource),
17  minDR_(minDR),
18  maxDR_(maxDR),
20 {
21 
22  // Deal with the case if minDR == maxDR, just increment maxDR by epsilon
23  if ( maxDR_ - minDR_ <= 0.001 ) maxDR_ += 0.001;
24 }
reco::FlavorHistorySelectorUtil::~FlavorHistorySelectorUtil ( )
inline

Definition at line 65 of file FlavorHistorySelectorUtil.h.

65 {}

Member Function Documentation

bool FlavorHistorySelectorUtil::select ( unsigned int  nb,
unsigned int  nc,
unsigned int  highestFlavor,
FlavorHistory::FLAVOR_T  flavorSource,
double  dr 
) const

Definition at line 26 of file FlavorHistorySelectorUtil.cc.

References reco::FlavorHistory::bQuarkId, gather_cfg::cout, reco::FlavorHistory::cQuarkId, spr::find(), flavor_, flavorSource_, maxDR_, minDR_, noutput_, and verbose_.

Referenced by FlavorHistoryFilter::filter().

31 {
32 
33  // Print out some information about this event
34  if ( verbose_ ) {
35  cout << "Looking at flavor history event: " << endl;
36  cout << "source = " << flavorSource << endl;
37  cout << "nbjet = " << nb << endl;
38  cout << "ncjet = " << nc << endl;
39  cout << "flavor = " << highestFlavor << endl;
40  cout << "dr = " << dr << endl;
41  }
42 
43  // First check that the highest flavor in the event is what this
44  // filter is checking. Otherwise we need to fail the event,
45  // since it should be handled by another filter
46  if ( highestFlavor > static_cast<unsigned int>(flavor_) ) {
47  if ( verbose_ ) cout << "Rejecting event, highest flavor is " << highestFlavor << endl;
48  return false;
49  }
50 
51  // Next check that the flavor source is one of the desired ones
52  vector<int>::const_iterator iflavorSource = find( flavorSource_.begin(), flavorSource_.end(), static_cast<int>(flavorSource) );
53  if ( iflavorSource == flavorSource_.end() ) {
54  if ( verbose_ ) cout << "Rejecting event, didn't find flavor source " << static_cast<int>(flavorSource) << endl;
55  return false;
56  }
57 
58  // If we are examining b quarks
60  // if we have no b quarks, return false
61  if ( nb <= 0 ) {
62  if ( verbose_ ) cout << "Rejecting event, nb = " << nb << endl;
63  return false;
64  }
65  // here, nb > 0
66  else {
67  // if we want 1 b, require nb == 1
68  if ( noutput_ == 1 && nb == 1 ) {
69  if ( verbose_ ) cout << "Accepting event" << endl;
70  return true;
71  }
72  // if we want 2 b, then look at delta R
73  else if ( noutput_ > 1 && nb > 1 ) {
74  // If dr is within the range we want, pass.
75  // Otherwise, fail.
76  if ( verbose_ ) cout << "Want multiples, dr = " << dr << endl;
77  return ( dr >= minDR_ && dr < maxDR_ );
78  }
79  // otherwise return false
80  else {
81  if ( verbose_ ) cout << "Rejecting event, isn't output = 1 + nb = 1, or output > 0 and delta R in proper range" << endl;
82  return false;
83  }
84  }// end if nb > 0
85 
86  } // end if flavor is b quark
87 
88  // If we are examining c quarks
89  else if ( flavor_ == reco::FlavorHistory::cQuarkId ) {
90  // make sure there are no b quarks in the event.
91  // If there are, another filter should handle it.
92  if ( nb > 0 ) return false;
93 
94  // if we have no c quarks, return false
95  if ( nc <= 0 ) return false;
96  // here, nc > 0
97  else {
98  // if we want 1 c, require nc == 1
99  if ( noutput_ == 1 && nc == 1 ) {
100  return true;
101  }
102  // if we want 2 c, then look at delta R
103  else if ( noutput_ > 1 && nc > 1 ) {
104  // If dr is within the range we want, pass.
105  // Otherwise, fail.
106  return ( dr >= minDR_ && dr < maxDR_ );
107  }
108  // otherwise return false
109  else {
110  return false;
111  }
112  }// end if nc > 0
113 
114  }
115  // Otherwise return false
116  else {
117  if ( verbose_ ) cout << "Something is weird, flavor is " << flavor_ << endl;
118  return false;
119  }
120 }
static const int bQuarkId
Definition: FlavorHistory.h:60
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static const int cQuarkId
Definition: FlavorHistory.h:61
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

int reco::FlavorHistorySelectorUtil::flavor_
private

Definition at line 75 of file FlavorHistorySelectorUtil.h.

Referenced by select().

flavor_vector reco::FlavorHistorySelectorUtil::flavorSource_
private

Definition at line 77 of file FlavorHistorySelectorUtil.h.

Referenced by select().

double reco::FlavorHistorySelectorUtil::maxDR_
private

Definition at line 79 of file FlavorHistorySelectorUtil.h.

Referenced by FlavorHistorySelectorUtil(), and select().

double reco::FlavorHistorySelectorUtil::minDR_
private

Definition at line 78 of file FlavorHistorySelectorUtil.h.

Referenced by FlavorHistorySelectorUtil(), and select().

int reco::FlavorHistorySelectorUtil::noutput_
private

Definition at line 76 of file FlavorHistorySelectorUtil.h.

Referenced by select().

bool reco::FlavorHistorySelectorUtil::verbose_
private

Definition at line 80 of file FlavorHistorySelectorUtil.h.

Referenced by select().