25 using namespace TopEventSelectionTools;
31 JetFlavorPlots::JetFlavorPlots(
const std::string&
name,
34 m_nominalHashValue(0),
39 m_doRadHighNoVar3c(false),
40 m_doRadLowNoVar3c(false),
42 m_ptBins(
"15:20:30:45:60:80:110:160:210:260:310:400:500:600:800:1000:1200:1500:1800:2500"),
43 m_etaBins(
"0.:0.3:0.8:1.2:2.1:2.8:3.6:4.5"),
47 m_PMGTruthWeights(nullptr),
48 m_throwwarningPMG(true) {
59 const std::string truthWeightToolName =
"PMGTruthWeightTool";
60 if (asg::ToolStore::contains<PMGTools::PMGTruthWeightTool>(truthWeightToolName))
m_PMGTruthWeights =
61 asg::ToolStore::get<PMGTools::PMGTruthWeightTool>(truthWeightToolName);
72 else if (
s.substr(0, 3) ==
"pt:" ||
s.substr(0, 3) ==
"pT:")
m_ptBins =
s.substr(3,
s.size() - 3);
73 else if (
s.substr(0, 7) ==
"abseta:")
m_etaBins =
s.substr(7,
s.size() - 7);
75 else if (
s ==
"nominal" ||
s ==
"NOMINAL" ||
s ==
"Nominal")
m_doNominal =
true;
76 else if (
s ==
"radiationhigh" ||
s ==
"RADIATIONHIGH" ||
s ==
"RadiationHigh" ||
78 else if (
s ==
"radiationlow" ||
s ==
"RADIATIONLOW" ||
s ==
"RadiationLow" ||
80 else if (
s ==
"radiationhighnovar3c" ||
s ==
"RADIATIONHIGHNOVAR3C" ||
s ==
"RadiationHighNoVar3c" ||
82 else if (
s ==
"radiationlownovar3c" ||
s ==
"RADIATIONLOWNOVAR3C" ||
s ==
"RadiationLowNoVar3c" ||
85 throw std::runtime_error(
"ERROR: Can't understand argument " +
s +
"For JETFLAVORPLOTS");
106 std::vector<double> ptBinning;
107 std::vector<double> etaBinning;
111 msgInfo <<
"Here is the binning used for JETFLAVORPLOTS in selection " <<
name <<
":\n";
113 for (
auto pt:ptBinning) msgInfo <<
pt <<
" ";
115 msgInfo <<
"abseta: ";
116 for (
auto eta:etaBinning) msgInfo <<
eta <<
" ";
117 msgInfo << std::endl;
139 for (std::string flavour:{
"gluon",
"lightquark",
"cquark",
"bquark",
"other"}) {
144 ptBins.size() - 1, ptBins.data(),
etaBins.size() - 1,
etaBins.data());
147 h_ptr->addHist(flavour +
"_jets_" +
m_jetCollection,
";pT [GeV];|#eta^{jet}|;Events",
148 ptBins.size() - 1, ptBins.data(),
etaBins.size() - 1,
etaBins.data());
151 h_ptr->addHist(
"quark_jets_" +
m_jetCollection,
";pT [GeV];|#eta^{jet}|;Events",
152 ptBins.size() - 1, ptBins.data(),
etaBins.size() - 1,
etaBins.data());
155 h_ptr->addHist(
"quark_jets_" +
m_jetCollection,
";pT [GeV];|#eta^{jet}|;Events",
156 ptBins.size() - 1, ptBins.data(),
etaBins.size() - 1,
etaBins.data());
157 h_ptr->addHist(
"gluon_jets_" +
m_jetCollection,
";pT [GeV];|#eta^{jet}|;Events",
158 ptBins.size() - 1, ptBins.data(),
etaBins.size() - 1,
etaBins.data());
170 if (
event.m_isLoose && !
m_config->doLooseEvents())
return true;
172 if (!
event.m_isLoose && !
m_config->doTightEvents())
return true;
174 double nominalWeight =
event.m_info->auxdata<
float>(
"AnalysisTop_eventWeight");
177 double eventWeight = nominalWeight;
184 double scaleWeight = 1.;
194 double eventWeight = scaleWeight;
208 double scaleWeight = 1.;
218 double eventWeight = scaleWeight;
235 bool throwWarning =
false;
237 for (
const auto*
const jetPtr :
event.m_jets) {
238 int jet_flavor = -99;
239 bool status = jetPtr->getAttribute<
int>(
"PartonTruthLabelID", jet_flavor);
243 if ((
unsigned int)
m_nJetsMax >=
event.m_jets.size()) {
249 else if (jet_flavor >= 1 && jet_flavor <= 3) sprintf(
name,
"lightquark_jets_njet%lu_%s",
event.m_jets.size(),
m_jetCollection.c_str());
256 static_cast<TH2D*
>(h_ptr->hist(
name))->Fill(jetPtr->pt() *
toGeV,
261 if (jet_flavor >= 1 && jet_flavor <= 4) {
264 static_cast<TH2D*
>(h_ptr->hist(
name))->Fill(jetPtr->pt() *
toGeV,
268 }
else throwWarning =
true;
272 if (jet_flavor == 21) sprintf(shortname,
"gluon_jets_%s",
m_jetCollection.c_str());
274 else if (jet_flavor >= 1 && jet_flavor <= 3) sprintf(shortname,
"lightquark_jets_%s",
m_jetCollection.c_str());
276 else if (jet_flavor == 4) sprintf(shortname,
"cquark_jets_%s",
m_jetCollection.c_str());
278 else if (jet_flavor == 5) sprintf(shortname,
"bquark_jets_%s",
m_jetCollection.c_str());
281 static_cast<TH2D*
>(h_ptr->hist(shortname))->Fill(jetPtr->pt() *
toGeV,
290 else if (jet_flavor >= 1 && jet_flavor <= 4) sprintf(
name,
"quark_jets_%s",
m_jetCollection.c_str());
294 static_cast<TH2D*
>(h_ptr->hist(
name))->Fill(jetPtr->pt() *
toGeV,
302 <<
", but histograms have been booked up to " <<
m_nJetsMax
303 <<
". Exclusive histograms in number of jets have not been filled.\n");
309 std::stringstream
ss(
str);
311 char separator =
':';
312 while (std::getline(
ss, tok, separator)) {
313 binEdges.push_back(
std::atof(tok.c_str()));
318 return "JETFLAVORPLOTS";