CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FlavorHistoryFilter.cc
Go to the documentation of this file.
1 // This file was removed but it should not have been.
2 // This comment is to restore it.
3 
6 
10 
12 
13 #include <vector>
14 
15 using namespace edm;
16 using namespace reco;
17 using namespace std;
18 
19 
20 //
21 // constants, enums and typedefs
22 //
23 
24 //
25 // static data member definitions
26 //
27 
28 //
29 // constructors and destructor
30 //
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 }
152 
153 
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 }
173 
174 
175 
176 bool
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 }
246 
247 // ------------ method called once each job just after ending the event loop ------------
248 void
250 }
251 
252 //define this as a plug-in
reco::FlavorHistorySelectorUtil * c_me_
T getParameter(std::string const &) const
bool verbose
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
reco::FlavorHistorySelectorUtil * bb_me_
selection
main part
Definition: corrVsCorr.py:98
bool exists(std::string const &parameterName) const
checks if a parameter exists
virtual bool filter(edm::Event &, const edm::EventSetup &) override
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_
int iEvent
Definition: GenABIO.cc:230
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_
FlavorHistoryFilter(const edm::ParameterSet &)
reco::FlavorHistorySelectorUtil * b_me_
reco::FlavorHistorySelectorUtil * b_ps_
edm::EDGetTokenT< reco::FlavorHistoryEvent > csrcToken_
reco::FlavorHistorySelectorUtil * c_ps_