212 std::map<int, int> bJetFromTopIds;
214 std::map<int, int> bJetFromWIds;
216 std::map<int, int> cJetFromWIds;
218 std::map<int, int> bJetAdditionalIds;
220 std::map<int, int> cJetAdditionalIds;
224 for(
size_t hadronId = 0; hadronId < genBHadIndex->size(); ++hadronId) {
226 const int jetIndex = genBHadJetIndex->at(hadronId);
228 if(jetIndex < 0)
continue;
233 const int flavour = genBHadFlavour->at(hadronId);
236 if(bJetFromTopIds.count(jetIndex) < 1) bJetFromTopIds[jetIndex] = 1;
237 else bJetFromTopIds[jetIndex]++;
242 if(bJetFromWIds.count(jetIndex) < 1) bJetFromWIds[jetIndex] = 1;
243 else bJetFromWIds[jetIndex]++;
247 if(bJetAdditionalIds.count(jetIndex) < 1) bJetAdditionalIds[jetIndex] = 1;
248 else bJetAdditionalIds[jetIndex]++;
252 for(std::map<int, int>::iterator it = bJetFromWIds.begin(); it != bJetFromWIds.end(); ) {
254 if(bJetFromTopIds.count(it->first) > 0) bJetFromWIds.erase(it++);
259 for(std::map<int, int>::iterator it = bJetAdditionalIds.begin(); it != bJetAdditionalIds.end(); ) {
261 if(bJetFromTopIds.count(it->first) > 0) bJetAdditionalIds.erase(it++);
263 else if(bJetFromWIds.count(it->first) > 0) bJetAdditionalIds.erase(it++);
268 for(
size_t hadronId = 0; hadronId < genCHadJetIndex->size(); ++hadronId) {
270 const int jetIndex = genCHadJetIndex->at(hadronId);
272 if(jetIndex < 0)
continue;
274 if(genCHadBHadronId->at(hadronId) >= 0)
continue;
279 if(bJetFromTopIds.count(jetIndex) > 0)
continue;
280 if(bJetFromWIds.count(jetIndex) > 0)
continue;
281 if(bJetAdditionalIds.count(jetIndex) > 0)
continue;
283 const int flavour = genCHadFlavour->at(hadronId);
286 if(cJetFromWIds.count(jetIndex) < 1) cJetFromWIds[jetIndex] = 1;
287 else cJetFromWIds[jetIndex]++;
291 if(cJetAdditionalIds.count(jetIndex) < 1) cJetAdditionalIds[jetIndex] = 1;
292 else cJetAdditionalIds[jetIndex]++;
296 for(std::map<int, int>::iterator it = cJetAdditionalIds.begin(); it != cJetAdditionalIds.end(); ) {
298 if(cJetFromWIds.count(it->first) > 0) cJetAdditionalIds.erase(it++);
304 int additionalJetEventId = bJetFromTopIds.size()*100 + bJetFromWIds.size()*1000 + cJetFromWIds.size()*10000;
306 if(bJetAdditionalIds.size() == 1){
307 const int nHadronsInJet = bJetAdditionalIds.begin()->second;
309 if(nHadronsInJet == 1) additionalJetEventId += 51;
311 else additionalJetEventId += 52;
314 else if(bJetAdditionalIds.size() > 1){
317 int nHadronsInJet1 = bJetAdditionalIds.at(orderedJetIndices.at(0));
318 int nHadronsInJet2 = bJetAdditionalIds.at(orderedJetIndices.at(1));
320 if(
std::max(nHadronsInJet1, nHadronsInJet2) == 1) additionalJetEventId += 53;
322 else if(
std::min(nHadronsInJet1, nHadronsInJet2) == 1 &&
std::max(nHadronsInJet1, nHadronsInJet2) > 1) additionalJetEventId += 54;
324 else if(
std::min(nHadronsInJet1, nHadronsInJet2) > 1) additionalJetEventId += 55;
329 if(cJetAdditionalIds.size() == 1){
330 const int nHadronsInJet = cJetAdditionalIds.begin()->second;
332 if(nHadronsInJet == 1) additionalJetEventId += 41;
334 else additionalJetEventId += 42;
337 else if(cJetAdditionalIds.size() > 1){
340 int nHadronsInJet1 = cJetAdditionalIds.at(orderedJetIndices.at(0));
341 int nHadronsInJet2 = cJetAdditionalIds.at(orderedJetIndices.at(1));
343 if(
std::max(nHadronsInJet1, nHadronsInJet2) == 1) additionalJetEventId += 43;
345 else if(
std::min(nHadronsInJet1, nHadronsInJet2) == 1 &&
std::max(nHadronsInJet1, nHadronsInJet2) > 1) additionalJetEventId += 44;
347 else if(
std::min(nHadronsInJet1, nHadronsInJet2) > 1) additionalJetEventId += 45;
352 additionalJetEventId += 0;
356 std::unique_ptr<int> ttbarId(
new int);
357 *ttbarId = additionalJetEventId;
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
const edm::EDGetTokenT< std::vector< int > > genBHadFromTopWeakDecayToken_
const edm::EDGetTokenT< std::vector< int > > genBHadJetIndexToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
const edm::EDGetTokenT< std::vector< int > > genCHadFromTopWeakDecayToken_
const double genJetPtMin_
const edm::EDGetTokenT< std::vector< int > > genCHadFlavourToken_
const double genJetAbsEtaMax_
std::vector< int > nHadronsOrderedJetIndices(const std::map< int, int > &m_jetIndex)
const edm::EDGetTokenT< std::vector< int > > genBHadFlavourToken_
Abs< T >::type abs(const T &t)
genBHadPlusMothersIndices
const edm::EDGetTokenT< std::vector< std::vector< int > > > genBHadPlusMothersIndicesToken_
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonHadronIndexToken_
const edm::EDGetTokenT< std::vector< int > > genBHadIndexToken_
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonViaTauToken_
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genBHadPlusMothersToken_
const edm::EDGetTokenT< std::vector< int > > genCHadJetIndexToken_
const edm::EDGetTokenT< std::vector< int > > genCHadBHadronIdToken_
const edm::EDGetTokenT< reco::GenJetCollection > genJetsToken_