120 : genJetPtMin_(iConfig.getParameter<double>(
"genJetPtMin")),
121 genJetAbsEtaMax_(iConfig.getParameter<double>(
"genJetAbsEtaMax")),
125 genBHadFromTopWeakDecayToken_(
127 genBHadPlusMothersToken_(
129 genBHadPlusMothersIndicesToken_(
132 genBHadLeptonHadronIndexToken_(
134 genBHadLeptonViaTauToken_(
138 genCHadFromTopWeakDecayToken_(
141 produces<int>(
"genTtbarId");
194 std::map<int, int> bJetFromTopIds;
196 std::map<int, int> bJetFromWIds;
198 std::map<int, int> cJetFromWIds;
200 std::map<int, int> bJetAdditionalIds;
202 std::map<int, int> cJetAdditionalIds;
205 for (
size_t hadronId = 0; hadronId <
genBHadIndex->size(); ++hadronId) {
207 const int jetIndex = genBHadJetIndex->at(hadronId);
220 if (bJetFromTopIds.count(jetIndex) < 1)
221 bJetFromTopIds[jetIndex] = 1;
223 bJetFromTopIds[jetIndex]++;
228 if (bJetFromWIds.count(jetIndex) < 1)
229 bJetFromWIds[jetIndex] = 1;
231 bJetFromWIds[jetIndex]++;
235 if (bJetAdditionalIds.count(jetIndex) < 1)
236 bJetAdditionalIds[jetIndex] = 1;
238 bJetAdditionalIds[jetIndex]++;
242 for (std::map<int, int>::iterator
it = bJetFromWIds.begin();
it != bJetFromWIds.end();) {
244 if (bJetFromTopIds.count(
it->first) > 0)
245 bJetFromWIds.erase(
it++);
251 for (std::map<int, int>::iterator
it = bJetAdditionalIds.begin();
it != bJetAdditionalIds.end();) {
253 if (bJetFromTopIds.count(
it->first) > 0)
254 bJetAdditionalIds.erase(
it++);
256 else if (bJetFromWIds.count(
it->first) > 0)
257 bJetAdditionalIds.erase(
it++);
263 for (
size_t hadronId = 0; hadronId < genCHadJetIndex->size(); ++hadronId) {
265 const int jetIndex = genCHadJetIndex->at(hadronId);
270 if (genCHadBHadronId->at(hadronId) >= 0)
278 if (bJetFromTopIds.count(jetIndex) > 0)
280 if (bJetFromWIds.count(jetIndex) > 0)
282 if (bJetAdditionalIds.count(jetIndex) > 0)
285 const int flavour = genCHadFlavour->at(hadronId);
288 if (cJetFromWIds.count(jetIndex) < 1)
289 cJetFromWIds[jetIndex] = 1;
291 cJetFromWIds[jetIndex]++;
295 if (cJetAdditionalIds.count(jetIndex) < 1)
296 cJetAdditionalIds[jetIndex] = 1;
298 cJetAdditionalIds[jetIndex]++;
302 for (std::map<int, int>::iterator
it = cJetAdditionalIds.begin();
it != cJetAdditionalIds.end();) {
304 if (cJetFromWIds.count(
it->first) > 0)
305 cJetAdditionalIds.erase(
it++);
312 int additionalJetEventId = bJetFromTopIds.size() * 100 + bJetFromWIds.size() * 1000 + cJetFromWIds.size() * 10000;
314 if (bJetAdditionalIds.size() == 1) {
315 const int nHadronsInJet = bJetAdditionalIds.begin()->second;
317 if (nHadronsInJet == 1)
318 additionalJetEventId += 51;
321 additionalJetEventId += 52;
324 else if (bJetAdditionalIds.size() > 1) {
327 int nHadronsInJet1 = bJetAdditionalIds.at(orderedJetIndices.at(0));
328 int nHadronsInJet2 = bJetAdditionalIds.at(orderedJetIndices.at(1));
330 if (
std::max(nHadronsInJet1, nHadronsInJet2) == 1)
331 additionalJetEventId += 53;
333 else if (
std::min(nHadronsInJet1, nHadronsInJet2) == 1 &&
std::max(nHadronsInJet1, nHadronsInJet2) > 1)
334 additionalJetEventId += 54;
336 else if (
std::min(nHadronsInJet1, nHadronsInJet2) > 1)
337 additionalJetEventId += 55;
342 if (cJetAdditionalIds.size() == 1) {
343 const int nHadronsInJet = cJetAdditionalIds.begin()->second;
345 if (nHadronsInJet == 1)
346 additionalJetEventId += 41;
349 additionalJetEventId += 42;
352 else if (cJetAdditionalIds.size() > 1) {
355 int nHadronsInJet1 = cJetAdditionalIds.at(orderedJetIndices.at(0));
356 int nHadronsInJet2 = cJetAdditionalIds.at(orderedJetIndices.at(1));
358 if (
std::max(nHadronsInJet1, nHadronsInJet2) == 1)
359 additionalJetEventId += 43;
361 else if (
std::min(nHadronsInJet1, nHadronsInJet2) == 1 &&
std::max(nHadronsInJet1, nHadronsInJet2) > 1)
362 additionalJetEventId += 44;
364 else if (
std::min(nHadronsInJet1, nHadronsInJet2) > 1)
365 additionalJetEventId += 45;
370 additionalJetEventId += 0;
374 std::unique_ptr<int> ttbarId(
new int);
375 *ttbarId = additionalJetEventId;
381 const int nElements = m_jetIndex.size();
382 std::vector<std::pair<int, int> > v_jetNhadIndexPair;
383 v_jetNhadIndexPair.reserve(nElements);
384 for (std::map<int, int>::const_iterator
it = m_jetIndex.begin();
it != m_jetIndex.end(); ++
it) {
385 const int jetIndex =
it->first;
386 const int nHadrons =
it->second;
387 v_jetNhadIndexPair.push_back(std::pair<int, int>(nHadrons, jetIndex));
390 std::sort(v_jetNhadIndexPair.begin(), v_jetNhadIndexPair.end(), std::greater<std::pair<int, int> >());
392 std::vector<int> v_orderedJetIndices;
393 v_orderedJetIndices.reserve(nElements);
394 for (
std::vector<std::pair<int, int> >::const_iterator
it = v_jetNhadIndexPair.begin();
395 it != v_jetNhadIndexPair.end();
397 v_orderedJetIndices.push_back(
it->second);
400 return v_orderedJetIndices;
409 desc.add<
double>(
"genJetPtMin", 20.);
410 desc.add<
double>(
"genJetAbsEtaMax", 2.4);
426 descriptions.
add(
"categorizeGenTtbar",
desc);
const edm::EDGetTokenT< std::vector< int > > genBHadFromTopWeakDecayToken_
const edm::EDGetTokenT< std::vector< int > > genBHadJetIndexToken_
const edm::EDGetTokenT< std::vector< int > > genCHadFromTopWeakDecayToken_
std::vector< GenJet > GenJetCollection
collection of GenJet objects
const double genJetPtMin_
std::vector< int > nHadronsOrderedJetIndices(const std::map< int, int > &m_jetIndex) const
const edm::EDGetTokenT< std::vector< int > > genCHadFlavourToken_
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const double genJetAbsEtaMax_
const edm::EDGetTokenT< std::vector< int > > genBHadFlavourToken_
Abs< T >::type abs(const T &t)
#define DEFINE_FWK_MODULE(type)
genBHadPlusMothersIndices
const edm::EDGetTokenT< std::vector< std::vector< int > > > genBHadPlusMothersIndicesToken_
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonHadronIndexToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< std::vector< int > > genBHadIndexToken_
const edm::EDGetTokenT< std::vector< int > > genBHadLeptonViaTauToken_
const edm::EDGetTokenT< std::vector< reco::GenParticle > > genBHadPlusMothersToken_
GenTtbarCategorizer(const edm::ParameterSet &)
const edm::EDGetTokenT< std::vector< int > > genCHadJetIndexToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< std::vector< int > > genCHadBHadronIdToken_
const edm::EDGetTokenT< reco::GenJetCollection > genJetsToken_