Main Page
Namespaces
Classes
Package Documentation
PhysicsTools
HepMCCandAlgos
src
FlavorHistorySelectorUtil.cc
Go to the documentation of this file.
1
#include "
PhysicsTools/HepMCCandAlgos/interface/FlavorHistorySelectorUtil.h
"
2
3
#include <iostream>
4
5
using namespace
std
;
6
using namespace
reco
;
7
8
FlavorHistorySelectorUtil::FlavorHistorySelectorUtil(
unsigned
int
flavor,
9
unsigned
int
noutput,
10
flavor_vector
const
& flavorSource,
11
double
minDR
,
12
double
maxDR
,
13
bool
verbose
) :
14
flavor_(flavor),
15
noutput_(noutput),
16
flavorSource_(flavorSource),
17
minDR_(minDR),
18
maxDR_(maxDR),
19
verbose_(verbose)
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
}
25
26
bool
FlavorHistorySelectorUtil::select
(
unsigned
int
nb,
27
unsigned
int
nc,
28
unsigned
int
highestFlavor,
29
FlavorHistory::FLAVOR_T
flavorSource,
30
double
dr
)
const
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
59
if
(
flavor_
==
reco::FlavorHistory::bQuarkId
) {
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
}
reco::FlavorHistory::bQuarkId
static const int bQuarkId
Definition:
FlavorHistory.h:60
verbose
Definition:
MagVerbosity.h:13
reco::FlavorHistorySelectorUtil::verbose_
bool verbose_
Definition:
FlavorHistorySelectorUtil.h:80
std
Definition:
JetResolutionObject.h:80
reco::FlavorHistorySelectorUtil::minDR_
double minDR_
Definition:
FlavorHistorySelectorUtil.h:78
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition:
FindCaloHit.cc:20
reco::FlavorHistorySelectorUtil::flavorSource_
flavor_vector flavorSource_
Definition:
FlavorHistorySelectorUtil.h:77
jets_cff.maxDR
maxDR
Definition:
jets_cff.py:127
reco::FlavorHistorySelectorUtil::flavor_vector
std::vector< int > flavor_vector
Definition:
FlavorHistorySelectorUtil.h:57
reco::FlavorHistorySelectorUtil::select
bool select(unsigned int nb, unsigned int nc, unsigned int highestFlavor, FlavorHistory::FLAVOR_T flavorSource, double dr) const
Definition:
FlavorHistorySelectorUtil.cc:26
reco::FlavorHistory::cQuarkId
static const int cQuarkId
Definition:
FlavorHistory.h:61
FlavorHistorySelectorUtil.h
reco::FlavorHistory::FLAVOR_T
FLAVOR_T
Definition:
FlavorHistory.h:51
reco::FlavorHistorySelectorUtil::noutput_
int noutput_
Definition:
FlavorHistorySelectorUtil.h:76
runTauDisplay.dr
dr
Definition:
runTauDisplay.py:333
reco::FlavorHistorySelectorUtil::flavor_
int flavor_
Definition:
FlavorHistorySelectorUtil.h:75
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:44
reco::FlavorHistorySelectorUtil::maxDR_
double maxDR_
Definition:
FlavorHistorySelectorUtil.h:79
gather_cfg.cout
cout
Definition:
gather_cfg.py:144
electronTrackIsolations_cfi.minDR
minDR
Definition:
electronTrackIsolations_cfi.py:7
Generated for CMSSW Reference Manual by
1.8.11