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 Member Functions | Private Attributes
FlavorHistoryFilter Class Reference

#include <PhysicsTools/FlavorHistoryFilter/src/FlavorHistoryFilter.cc>

Inheritance diagram for FlavorHistoryFilter:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef
reco::FlavorHistory::FLAVOR_T 
flavor_type
 
typedef std::vector< int > flavor_vector
 
- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 FlavorHistoryFilter (const edm::ParameterSet &)
 
 ~FlavorHistoryFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void endJob ()
 
virtual bool filter (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

reco::FlavorHistorySelectorUtilb_me_
 
reco::FlavorHistorySelectorUtilb_ps_
 
reco::FlavorHistorySelectorUtilb_ps_comp_
 
reco::FlavorHistorySelectorUtilbb_me_
 
reco::FlavorHistorySelectorUtilbb_me_comp_
 
edm::EDGetTokenT
< reco::FlavorHistoryEvent
bsrcToken_
 
reco::FlavorHistorySelectorUtilc_me_
 
reco::FlavorHistorySelectorUtilc_ps_
 
reco::FlavorHistorySelectorUtilc_ps_comp_
 
reco::FlavorHistorySelectorUtilcc_me_
 
reco::FlavorHistorySelectorUtilcc_me_comp_
 
edm::EDGetTokenT
< reco::FlavorHistoryEvent
csrcToken_
 
double dr_
 
int pathToSelect_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Description:

This now filters events hierarchically. Previously this was done at the python configuration level, which was cumbersome for users to use.

Now, the hierarchy is:

Create prioritized paths to separate HF composition samples.

These are exclusive priorities, so sample "i" will not overlap with "i+1". Note that the "dr" values below correspond to the dr between the matched genjet, and the sister genjet.

1) W+bb with >= 2 jets from the ME (dr > 0.5) 2) W+b or W+bb with 1 jet from the ME 3) W+cc from the ME (dr > 0.5) 4) W+c or W+cc with 1 jet from the ME 5) W+bb with 1 jet from the parton shower (dr == 0.0) 6) W+cc with 1 jet from the parton shower (dr == 0.0)

These are the "trash bin" samples that we're throwing away:

7) W+bb with >= 2 partons but 1 jet from the ME (dr == 0.0) 8) W+cc with >= 2 partons but 1 jet from the ME (dr == 0.0) 9) W+bb with >= 2 partons but 2 jets from the PS (dr > 0.5) 10)W+cc with >= 2 partons but 2 jets from the PS (dr > 0.5)

And here is the true "light flavor" sample:

11) Veto of all the previous (W+ light jets)

Implementation: <Notes on="" implementation>="">

Definition at line 76 of file FlavorHistoryFilter.h.

Member Typedef Documentation

Definition at line 78 of file FlavorHistoryFilter.h.

typedef std::vector<int> FlavorHistoryFilter::flavor_vector

Definition at line 79 of file FlavorHistoryFilter.h.

Constructor & Destructor Documentation

FlavorHistoryFilter::FlavorHistoryFilter ( const edm::ParameterSet iConfig)
explicit

Definition at line 31 of file FlavorHistoryFilter.cc.

References b_me_, b_ps_, b_ps_comp_, bb_me_, bb_me_comp_, c_me_, c_ps_, c_ps_comp_, cc_me_, cc_me_comp_, dr_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), pathToSelect_, and verbose.

31  :
32  bsrcToken_ ( consumes<FlavorHistoryEvent>( iConfig.getParameter<edm::InputTag>("bsrc" ) ) ),
33  csrcToken_ ( consumes<FlavorHistoryEvent>( iConfig.getParameter<edm::InputTag>("csrc" ) ) )
34 {
35  if ( iConfig.exists("pathToSelect") )
36  pathToSelect_ = iConfig.getParameter<int> ("pathToSelect");
37  else
38  pathToSelect_ = -1;
39 
40  // This is the "interface" delta R with which to decide
41  // where to take the event from
42  dr_ = iConfig.getParameter<double> ("dr" ) ;
43  bool verbose ( iConfig.getParameter<bool> ("verbose") );
44 
45  // Set up the boundaries.
46  // dr0 = 0.0
47  // dr1 = set by user
48  // dr2 = infinity
49  double dr0 = 0.0;
50  double dr1 = dr_;
51  double dr2 = 99999.0;
52 
53 
54  // These are the processes that can come from the matrix element calculation
55  std::vector<int> me_ids;
56  me_ids.push_back(2); // flavor excitation
57  me_ids.push_back(3); // flavor creation
58 
59  // These are the processes that can come from the parton shower calculation
60  std::vector<int> ps_ids;
61  ps_ids.push_back(1); // gluon splitting
62 
63 
64  // To select bb->2 events from matrix element... Path 1
66  2,
67  me_ids,
68  dr1,
69  dr2,
70  verbose );
71 
72  // To select b->1 events from matrix element... Path 2
74  1,
75  me_ids,
76  dr0,
77  dr0,
78  verbose );
79 
80 
81  // To select cc->2 events from matrix element... Path 3
83  2,
84  me_ids,
85  dr1,
86  dr2,
87  verbose );
88 
89  // To select c->1 events from matrix element... Path 4
91  1,
92  me_ids,
93  dr0,
94  dr0,
95  verbose );
96 
97  // To select bb->2 events from parton shower ... Path 5
99  1,
100  ps_ids,
101  dr0,
102  dr1,
103  verbose );
104 
105 
106  // To select cc->2 events from parton shower ... Path 6
108  1,
109  ps_ids,
110  dr0,
111  dr1,
112  verbose );
113 
114  // To select bb->1 events from matrix element... Path 7
116  2,
117  me_ids,
118  dr0,
119  dr1,
120  verbose );
121 
122  // To select cc->1 events from matrix element... Path 8
124  2,
125  me_ids,
126  dr0,
127  dr1,
128  verbose );
129 
130  // To select bb->2 events from parton shower ... Path 9
132  2,
133  ps_ids,
134  dr1,
135  dr2,
136  verbose );
137 
138  // To select cc->1 events from parton shower ... Path 10
140  2,
141  ps_ids,
142  dr1,
143  dr2,
144  verbose );
145 
146  // The veto of all of these is ... Path 11
147 
148 
149  // This will write 1-11 (the path number), or 0 if error.
150  produces<unsigned int>();
151 }
reco::FlavorHistorySelectorUtil * c_me_
T getParameter(std::string const &) const
bool verbose
reco::FlavorHistorySelectorUtil * bb_me_
bool exists(std::string const &parameterName) const
checks if a parameter exists
reco::FlavorHistorySelectorUtil * b_ps_comp_
reco::FlavorHistorySelectorUtil * cc_me_
edm::EDGetTokenT< reco::FlavorHistoryEvent > bsrcToken_
reco::FlavorHistorySelectorUtil * c_ps_comp_
reco::FlavorHistorySelectorUtil * bb_me_comp_
reco::FlavorHistorySelectorUtil * cc_me_comp_
reco::FlavorHistorySelectorUtil * b_me_
reco::FlavorHistorySelectorUtil * b_ps_
edm::EDGetTokenT< reco::FlavorHistoryEvent > csrcToken_
reco::FlavorHistorySelectorUtil * c_ps_
FlavorHistoryFilter::~FlavorHistoryFilter ( )

Definition at line 154 of file FlavorHistoryFilter.cc.

References b_me_, b_ps_, b_ps_comp_, bb_me_, bb_me_comp_, c_me_, c_ps_, c_ps_comp_, cc_me_, and cc_me_comp_.

155 {
156 
157  if ( bb_me_ ) delete bb_me_;
158  if ( b_me_ ) delete b_me_;
159  if ( cc_me_ ) delete cc_me_;
160  if ( c_me_ ) delete c_me_;
161  if ( b_ps_ ) delete b_ps_;
162  if ( c_ps_ ) delete c_ps_;
163 
164  if ( bb_me_comp_ ) delete bb_me_comp_;
165  if ( cc_me_comp_ ) delete cc_me_comp_;
166  if ( b_ps_comp_ ) delete b_ps_comp_;
167  if ( c_ps_comp_ ) delete c_ps_comp_;
168 
169 
170 
171 
172 }
reco::FlavorHistorySelectorUtil * c_me_
reco::FlavorHistorySelectorUtil * bb_me_
reco::FlavorHistorySelectorUtil * b_ps_comp_
reco::FlavorHistorySelectorUtil * cc_me_
reco::FlavorHistorySelectorUtil * c_ps_comp_
reco::FlavorHistorySelectorUtil * bb_me_comp_
reco::FlavorHistorySelectorUtil * cc_me_comp_
reco::FlavorHistorySelectorUtil * b_me_
reco::FlavorHistorySelectorUtil * b_ps_
reco::FlavorHistorySelectorUtil * c_ps_

Member Function Documentation

void FlavorHistoryFilter::endJob ( void  )
privatevirtual

Reimplemented from edm::EDFilter.

Definition at line 249 of file FlavorHistoryFilter.cc.

249  {
250 }
bool FlavorHistoryFilter::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::EDFilter.

Definition at line 177 of file FlavorHistoryFilter.cc.

References b_me_, b_ps_, b_ps_comp_, bb_me_, bb_me_comp_, bsrcToken_, c_me_, c_ps_, c_ps_comp_, cc_me_, cc_me_comp_, csrcToken_, edm::Event::getByToken(), pathToSelect_, edm::Event::put(), benchmark_cfg::select, reco::FlavorHistorySelectorUtil::select(), and corrVsCorr::selection.

178 {
179 
180  // Get the flavor history
181  Handle<FlavorHistoryEvent > bFlavorHistoryEvent;
182  iEvent.getByToken(bsrcToken_,bFlavorHistoryEvent);
183 
184  Handle<FlavorHistoryEvent > cFlavorHistoryEvent;
185  iEvent.getByToken(csrcToken_,cFlavorHistoryEvent);
186 
187  std::auto_ptr<unsigned int> selection ( new unsigned int() );
188 
189  // Get the number of matched b-jets in the event
190  unsigned int nb = bFlavorHistoryEvent->nb();
191  // Get the number of matched c-jets in the event
192  unsigned int nc = cFlavorHistoryEvent->nc();
193  // Get the two flavor sources. The highest takes precedence
194  // over the rest.
195  FlavorHistory::FLAVOR_T bFlavorSource = bFlavorHistoryEvent->flavorSource();
196  FlavorHistory::FLAVOR_T cFlavorSource = cFlavorHistoryEvent->flavorSource();
197  FlavorHistory::FLAVOR_T flavorSource = FlavorHistory::FLAVOR_NULL;
198  // Get the highest flavor in the event
199  unsigned int highestFlavor = 0;
200  // Get the delta r between the two heavy flavor matched jets.
201  double dr = -1;
202 
203  // Preference is in increasing priority:
204  // 1: gluon splitting
205  // 2: flavor excitation
206  // 3: flavor creation (matrix element)
207  // 4: flavor decay
208  if ( bFlavorSource >= cFlavorSource ) {
209  flavorSource = bFlavorHistoryEvent->flavorSource();
210  highestFlavor = bFlavorHistoryEvent->highestFlavor();
211  dr = bFlavorHistoryEvent->deltaR();
212  }
213  else {
214  flavorSource = cFlavorHistoryEvent->flavorSource();
215  highestFlavor = cFlavorHistoryEvent->highestFlavor();
216  dr = cFlavorHistoryEvent->deltaR();
217  }
218 
219 
220  *selection = 0;
221  // Now make hierarchical determination
222  if ( bb_me_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 1;
223  else if ( b_me_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 2;
224  else if ( cc_me_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 3;
225  else if ( c_me_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 4;
226  else if ( b_ps_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 5;
227  else if ( c_ps_ ->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 6;
228  else if ( bb_me_comp_->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 7;
229  else if ( cc_me_comp_->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 8;
230  else if ( b_ps_comp_->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 9;
231  else if ( c_ps_comp_->select( nb, nc, highestFlavor, flavorSource, dr ) ) *selection = 10;
232  else *selection = 11;
233 
234  bool pass = false;
235  if ( pathToSelect_ > 0 ) {
236  pass = (*selection > 0 && *selection == static_cast<unsigned int>(pathToSelect_ ) );
237  } else {
238  pass = true;
239  }
240 
241  iEvent.put( selection );
242 
243  return pass;
244 
245 }
reco::FlavorHistorySelectorUtil * c_me_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
reco::FlavorHistorySelectorUtil * bb_me_
selection
main part
Definition: corrVsCorr.py:98
bool select(unsigned int nb, unsigned int nc, unsigned int highestFlavor, FlavorHistory::FLAVOR_T flavorSource, double dr) const
reco::FlavorHistorySelectorUtil * b_ps_comp_
reco::FlavorHistorySelectorUtil * cc_me_
edm::EDGetTokenT< reco::FlavorHistoryEvent > bsrcToken_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
reco::FlavorHistorySelectorUtil * c_ps_comp_
reco::FlavorHistorySelectorUtil * bb_me_comp_
reco::FlavorHistorySelectorUtil * cc_me_comp_
reco::FlavorHistorySelectorUtil * b_me_
reco::FlavorHistorySelectorUtil * b_ps_
edm::EDGetTokenT< reco::FlavorHistoryEvent > csrcToken_
reco::FlavorHistorySelectorUtil * c_ps_

Member Data Documentation

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::b_me_
private

Definition at line 95 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::b_ps_
private

Definition at line 98 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::b_ps_comp_
private

Definition at line 102 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::bb_me_
private

Definition at line 94 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::bb_me_comp_
private

Definition at line 100 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

edm::EDGetTokenT<reco::FlavorHistoryEvent> FlavorHistoryFilter::bsrcToken_
private

Definition at line 89 of file FlavorHistoryFilter.h.

Referenced by filter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::c_me_
private

Definition at line 97 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::c_ps_
private

Definition at line 99 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::c_ps_comp_
private

Definition at line 103 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::cc_me_
private

Definition at line 96 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

reco::FlavorHistorySelectorUtil* FlavorHistoryFilter::cc_me_comp_
private

Definition at line 101 of file FlavorHistoryFilter.h.

Referenced by filter(), FlavorHistoryFilter(), and ~FlavorHistoryFilter().

edm::EDGetTokenT<reco::FlavorHistoryEvent> FlavorHistoryFilter::csrcToken_
private

Definition at line 90 of file FlavorHistoryFilter.h.

Referenced by filter().

double FlavorHistoryFilter::dr_
private

Definition at line 92 of file FlavorHistoryFilter.h.

Referenced by FlavorHistoryFilter().

int FlavorHistoryFilter::pathToSelect_
private

Definition at line 91 of file FlavorHistoryFilter.h.

Referenced by filter(), and FlavorHistoryFilter().