128 : genJetPtMin_(iConfig.getParameter<double>(
"genJetPtMin")),
129 genJetAbsEtaMax_(iConfig.getParameter<double>(
"genJetAbsEtaMax")),
131 genBHadJetIndexToken_(consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genBHadJetIndex"))),
132 genBHadFlavourToken_(consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genBHadFlavour"))),
133 genBHadFromTopWeakDecayToken_(
134 consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genBHadFromTopWeakDecay"))),
135 genBHadPlusMothersToken_(
137 genBHadPlusMothersIndicesToken_(
138 consumes<
std::vector<
std::vector<
int> > >(iConfig.getParameter<
edm::
InputTag>(
"genBHadPlusMothersIndices"))),
139 genBHadIndexToken_(consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genBHadIndex"))),
140 genBHadLeptonHadronIndexToken_(
141 consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genBHadLeptonHadronIndex"))),
142 genBHadLeptonViaTauToken_(
143 consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genBHadLeptonViaTau"))),
144 genCHadJetIndexToken_(consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genCHadJetIndex"))),
145 genCHadFlavourToken_(consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genCHadFlavour"))),
146 genCHadFromTopWeakDecayToken_(
147 consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genCHadFromTopWeakDecay"))),
148 genCHadBHadronIdToken_(consumes<
std::vector<
int> >(iConfig.getParameter<
edm::
InputTag>(
"genCHadBHadronId"))) {
149 produces<int>(
"genTtbarId");
204 std::map<int, int> bJetFromTopIds;
206 std::map<int, int> bJetFromWIds;
208 std::map<int, int> cJetFromWIds;
210 std::map<int, int> bJetAdditionalIds;
212 std::map<int, int> cJetAdditionalIds;
215 for (
size_t hadronId = 0; hadronId <
genBHadIndex->size(); ++hadronId) {
230 if (bJetFromTopIds.count(jetIndex) < 1)
231 bJetFromTopIds[jetIndex] = 1;
233 bJetFromTopIds[jetIndex]++;
238 if (bJetFromWIds.count(jetIndex) < 1)
239 bJetFromWIds[jetIndex] = 1;
241 bJetFromWIds[jetIndex]++;
245 if (bJetAdditionalIds.count(jetIndex) < 1)
246 bJetAdditionalIds[jetIndex] = 1;
248 bJetAdditionalIds[jetIndex]++;
252 for (std::map<int, int>::iterator it = bJetFromWIds.begin(); it != bJetFromWIds.end();) {
254 if (bJetFromTopIds.count(it->first) > 0)
255 bJetFromWIds.erase(it++);
261 for (std::map<int, int>::iterator it = bJetAdditionalIds.begin(); it != bJetAdditionalIds.end();) {
263 if (bJetFromTopIds.count(it->first) > 0)
264 bJetAdditionalIds.erase(it++);
266 else if (bJetFromWIds.count(it->first) > 0)
267 bJetAdditionalIds.erase(it++);
273 for (
size_t hadronId = 0; hadronId <
genCHadJetIndex->size(); ++hadronId) {
288 if (bJetFromTopIds.count(jetIndex) > 0)
290 if (bJetFromWIds.count(jetIndex) > 0)
292 if (bJetAdditionalIds.count(jetIndex) > 0)
298 if (cJetFromWIds.count(jetIndex) < 1)
299 cJetFromWIds[jetIndex] = 1;
301 cJetFromWIds[jetIndex]++;
305 if (cJetAdditionalIds.count(jetIndex) < 1)
306 cJetAdditionalIds[jetIndex] = 1;
308 cJetAdditionalIds[jetIndex]++;
312 for (std::map<int, int>::iterator it = cJetAdditionalIds.begin(); it != cJetAdditionalIds.end();) {
314 if (cJetFromWIds.count(it->first) > 0)
315 cJetAdditionalIds.erase(it++);
322 int additionalJetEventId = bJetFromTopIds.size() * 100 + bJetFromWIds.size() * 1000 + cJetFromWIds.size() * 10000;
324 if (bJetAdditionalIds.size() == 1) {
325 const int nHadronsInJet = bJetAdditionalIds.begin()->second;
327 if (nHadronsInJet == 1)
328 additionalJetEventId += 51;
331 additionalJetEventId += 52;
334 else if (bJetAdditionalIds.size() > 1) {
337 int nHadronsInJet1 = bJetAdditionalIds.at(orderedJetIndices.at(0));
338 int nHadronsInJet2 = bJetAdditionalIds.at(orderedJetIndices.at(1));
340 if (
std::max(nHadronsInJet1, nHadronsInJet2) == 1)
341 additionalJetEventId += 53;
343 else if (
std::min(nHadronsInJet1, nHadronsInJet2) == 1 &&
std::max(nHadronsInJet1, nHadronsInJet2) > 1)
344 additionalJetEventId += 54;
346 else if (
std::min(nHadronsInJet1, nHadronsInJet2) > 1)
347 additionalJetEventId += 55;
352 if (cJetAdditionalIds.size() == 1) {
353 const int nHadronsInJet = cJetAdditionalIds.begin()->second;
355 if (nHadronsInJet == 1)
356 additionalJetEventId += 41;
359 additionalJetEventId += 42;
362 else if (cJetAdditionalIds.size() > 1) {
365 int nHadronsInJet1 = cJetAdditionalIds.at(orderedJetIndices.at(0));
366 int nHadronsInJet2 = cJetAdditionalIds.at(orderedJetIndices.at(1));
368 if (
std::max(nHadronsInJet1, nHadronsInJet2) == 1)
369 additionalJetEventId += 43;
371 else if (
std::min(nHadronsInJet1, nHadronsInJet2) == 1 &&
std::max(nHadronsInJet1, nHadronsInJet2) > 1)
372 additionalJetEventId += 44;
374 else if (
std::min(nHadronsInJet1, nHadronsInJet2) > 1)
375 additionalJetEventId += 45;
380 additionalJetEventId += 0;
384 std::unique_ptr<int> ttbarId(
new int);
385 *ttbarId = additionalJetEventId;
429 const int nElements = m_jetIndex.size();
430 std::vector<std::pair<int, int> > v_jetNhadIndexPair;
431 v_jetNhadIndexPair.reserve(nElements);
432 for (std::map<int, int>::const_iterator it = m_jetIndex.begin(); it != m_jetIndex.end(); ++it) {
433 const int jetIndex = it->first;
434 const int nHadrons = it->second;
435 v_jetNhadIndexPair.push_back(std::pair<int, int>(nHadrons, jetIndex));
438 std::sort(v_jetNhadIndexPair.begin(), v_jetNhadIndexPair.end(), std::greater<std::pair<int, int> >());
440 std::vector<int> v_orderedJetIndices;
441 v_orderedJetIndices.reserve(nElements);
442 for (std::vector<std::pair<int, int> >::const_iterator it = v_jetNhadIndexPair.begin();
443 it != v_jetNhadIndexPair.end();
445 v_orderedJetIndices.push_back(it->second);
448 return v_orderedJetIndices;