|
ATLAS Offline Software
|
An example of how to quickly make some plots at a certain point in the cutflow.
More...
#include <JetFlavorPlots.h>
An example of how to quickly make some plots at a certain point in the cutflow.
Definition at line 27 of file JetFlavorPlots.h.
◆ JetFlavorPlots()
top::JetFlavorPlots::JetFlavorPlots |
( |
const std::string & |
name, |
|
|
TFile * |
outputFile, |
|
|
const std::string & |
params, |
|
|
std::shared_ptr< top::TopConfig > |
config, |
|
|
EL::Worker * |
wk = nullptr |
|
) |
| |
Setup some example plots.
Add a bunch of histograms.
- Parameters
-
name | The name of the directory to store histograms in, in the output file. e.g. you might have ee, mumu and emu. |
outputFile | The output file. Needs setting up at the very start so that we can attach the files. |
params | The arguments, e.g. for the binning of the plots. |
config | Instance of TopConfig |
wk | Only used by EventLoop, ok as nullptr as default. |
Definition at line 31 of file JetFlavorPlots.cxx.
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"),
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;
◆ apply()
Fill the histograms.
- Returns
- True because it doesn't select any events.
Implements top::EventSelectorBase.
Definition at line 162 of file JetFlavorPlots.cxx.
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;
◆ applyParticleLevel()
This does stuff based on the information in a particle level event.
The idea is that you implement this to return either true or false, based on the information held within the top::ParticleLevelEvent. If this function returns true, then the event is kept, otherwise it is removed. The function has a default implementation (which returns true) because it is expected that many EventSelector objects do not operate on ParticleLevelEvent objects.
- Parameters
-
top::ParticleLevelEvent | the current particle level event. |
true | if the event should be kept (i.e. it passed the selector criteria), false otherwise. |
Reimplemented in top::JetNGhostSelector, top::PrintEventSelector, top::PseudoTopRecoRun, top::NElectronNMuonTightSelector, top::NElectronNMuonSelector, top::NFwdElectronSelector, top::HTSelector, top::OSLeptonTightSelector, top::MLLSelector, top::MWTSelector, top::NElectronTightSelector, top::NFwdElectronTightSelector, top::NMuonTightSelector, top::OSLeptonSelector, top::METMWTSelector, top::METSelector, top::MLLWindow, top::NElectronSelector, top::NJetSelector, top::NMuonSelector, top::NPhotonSelector, top::NSoftMuonSelector, top::NTauSelector, top::SSLeptonTightSelector, top::SSLeptonSelector, top::ParticleLevelSelector, top::RecoLevelSelector, top::NVarRCJetSelector, top::NLargeJetSelector, and top::NRCJetSelector.
Definition at line 73 of file EventSelectorBase.h.
◆ BookHistograms()
void top::JetFlavorPlots::BookHistograms |
( |
std::shared_ptr< PlotManager > |
h_ptr, |
|
|
std::vector< double > |
ptBins, |
|
|
std::vector< double > |
etaBins |
|
) |
| |
|
private |
Definition at line 136 of file JetFlavorPlots.cxx.
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());
◆ FillHistograms()
Definition at line 234 of file JetFlavorPlots.cxx.
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");
◆ formatBinning()
void top::JetFlavorPlots::formatBinning |
( |
const std::string & |
str, |
|
|
std::vector< double > & |
binEdges |
|
) |
| |
|
private |
Definition at line 308 of file JetFlavorPlots.cxx.
309 std::stringstream
ss(
str);
311 char separator =
':';
312 while (std::getline(
ss, tok, separator)) {
313 binEdges.push_back(
std::atof(tok.c_str()));
◆ name()
std::string top::JetFlavorPlots::name |
( |
| ) |
const |
|
overridevirtual |
◆ m_config
◆ m_detailed
bool top::JetFlavorPlots::m_detailed |
|
private |
◆ m_doNominal
bool top::JetFlavorPlots::m_doNominal |
|
private |
◆ m_doRadHigh
bool top::JetFlavorPlots::m_doRadHigh |
|
private |
◆ m_doRadHighNoVar3c
bool top::JetFlavorPlots::m_doRadHighNoVar3c |
|
private |
◆ m_doRadLow
bool top::JetFlavorPlots::m_doRadLow |
|
private |
◆ m_doRadLowNoVar3c
bool top::JetFlavorPlots::m_doRadLowNoVar3c |
|
private |
◆ m_etaBins
std::string top::JetFlavorPlots::m_etaBins |
|
private |
◆ m_hists
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists = nullptr |
|
private |
◆ m_hists_Loose
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_Loose = nullptr |
|
private |
◆ m_hists_RadHigh
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_RadHigh = nullptr |
|
private |
◆ m_hists_RadHigh_Loose
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_RadHigh_Loose = nullptr |
|
private |
◆ m_hists_RadHighNoVar3c
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_RadHighNoVar3c = nullptr |
|
private |
◆ m_hists_RadHighNoVar3c_Loose
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_RadHighNoVar3c_Loose = nullptr |
|
private |
◆ m_hists_RadLow
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_RadLow = nullptr |
|
private |
◆ m_hists_RadLow_Loose
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_RadLow_Loose = nullptr |
|
private |
◆ m_hists_RadLowNoVar3c
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_RadLowNoVar3c = nullptr |
|
private |
◆ m_hists_RadLowNoVar3c_Loose
std::shared_ptr<PlotManager> top::JetFlavorPlots::m_hists_RadLowNoVar3c_Loose = nullptr |
|
private |
◆ m_jetCollection
std::string top::JetFlavorPlots::m_jetCollection |
|
private |
◆ m_nJetsMax
int top::JetFlavorPlots::m_nJetsMax |
|
private |
◆ m_nominalHashValue
std::size_t top::JetFlavorPlots::m_nominalHashValue |
|
private |
◆ m_PMGTruthWeights
◆ m_ptBins
std::string top::JetFlavorPlots::m_ptBins |
|
private |
◆ m_throwwarningPMG
std::atomic<bool> top::JetFlavorPlots::m_throwwarningPMG |
|
mutableprivate |
◆ toGeV
const double top::JetFlavorPlots::toGeV = 0.001 |
|
staticprivate |
The documentation for this class was generated from the following files:
std::shared_ptr< PlotManager > m_hists_Loose
void BookHistograms(std::shared_ptr< PlotManager > h_ptr, std::vector< double > ptBins, std::vector< double > etaBins)
std::string name() const override
Return the name for the cutflow table.
void formatBinning(const std::string &str, std::vector< double > &binEdges)
Scalar eta() const
pseudorapidity method
Class to wrap a set of SystematicVariations.
std::shared_ptr< PlotManager > m_hists_RadLowNoVar3c_Loose
std::string m_jetCollection
std::atomic< bool > m_throwwarningPMG
static const double toGeV
std::size_t m_nominalHashValue
POOL::TEvent event(POOL::TEvent::kClassAccess)
std::shared_ptr< PlotManager > m_hists
std::shared_ptr< top::TopConfig > m_config
std::shared_ptr< PlotManager > m_hists_RadLow
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
std::shared_ptr< PlotManager > m_hists_RadHighNoVar3c
bool isSimulation(const top::Event &event)
Is this event MC simulation (True) or data (False)?
std::shared_ptr< PlotManager > m_hists_RadHighNoVar3c_Loose
double atof(std::string_view str)
Converts a string into a double / float.
PMGTools::PMGTruthWeightTool * m_PMGTruthWeights
std::string to_string(const DetectorType &type)
void FillHistograms(std::shared_ptr< PlotManager > h_ptr, double w_event, const top::Event &event) const
#define ATH_MSG_WARNING(x)
std::shared_ptr< PlotManager > m_hists_RadLowNoVar3c
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
std::shared_ptr< PlotManager > m_hists_RadHigh_Loose
std::shared_ptr< PlotManager > m_hists_RadLow_Loose
std::shared_ptr< PlotManager > m_hists_RadHigh