![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Perform the event selection on a top::Event object.
More...
#include <EventSelection.h>
Perform the event selection on a top::Event object.
Class to perform the event selection and keep track of the number of events passing each cut. It is also responsible for writing out the 4-vectors in the output file if the user so wished.
Definition at line 37 of file EventSelection.h.
◆ EventSelection() [1/4]
Construct using a vector of cuts.
The user supplies a simple vector of string that contains the cuts that should be applied. The tool will try to load each cut (and quit with and error message if it can't).
It also sets up a histogram which contains all the cuts on the x-axis and each bin is the number of events passing a cut (in order).
Definition at line 34 of file EventSelection.cxx.
77 if (
config->doTightEvents()) {
78 m_cutflow =
new TH1D(
"cutflow", (
name +
" cutflow").c_str(), cutNames.size(), -0.5, cutNames.size() - 0.5);
80 cutNames.size(), -0.5, cutNames.size() - 0.5);
82 cutNames.size(), -0.5, cutNames.size() - 0.5);
84 cutNames.size(), -0.5, cutNames.size() - 0.5);
86 cutNames.size(), -0.5, cutNames.size() - 0.5);
88 if (
config->doLooseEvents()) {
90 cutNames.size(), -0.5, cutNames.size() - 0.5);
92 (
name +
" cutflow_Loose MC weights").c_str(),
93 cutNames.size(), -0.5, cutNames.size() - 0.5);
95 (
name +
" cutflow_Loose PU weights").c_str(),
96 cutNames.size(), -0.5, cutNames.size() - 0.5);
98 (
name +
" cutflow_Loose MC*PU weights").c_str(),
99 cutNames.size(), -0.5, cutNames.size() - 0.5);
101 (
name +
" cutflow_Loose ScaleFactors").c_str(),
102 cutNames.size(), -0.5, cutNames.size() - 0.5);
105 if (
config->doTopParticleLevel()) {
107 (
name +
" cutflow_particle_level").c_str(),
108 cutNames.size(), -0.5, cutNames.size() - 0.5);
110 (
name +
" cutflow_particle_level_mc").c_str(),
111 cutNames.size(), -0.5, cutNames.size() - 0.5);
115 for (
const auto& currentCutName : cutNames) {
118 for (
const auto& libraryPtr : toolLoaders) {
123 if (
tool !=
nullptr) {
126 throw std::runtime_error(
"Could not find " + currentCutName);
130 if (currentCutName ==
"INITIAL") {
135 if (currentCutName ==
"GRL") {
140 if (currentCutName ==
"GOODCALO") {
145 if (currentCutName ==
"PRIVTX") {
151 if (
config->doTightEvents()) {
158 if (
config->doLooseEvents()) {
174 if (currentCutName ==
"SAVE") {
◆ ~EventSelection()
virtual top::EventSelection::~EventSelection |
( |
| ) |
|
|
inlinevirtual |
◆ EventSelection() [2/4]
◆ EventSelection() [3/4]
top::EventSelection::EventSelection |
( |
| ) |
|
|
delete |
Default constructor is not allowed.
◆ EventSelection() [4/4]
◆ apply()
Apply the selection for each event.
This loops through all the configured cuts in order and looks to see if the top::Event passes them or not. It fills the cutflow histogram if the events passes.
- Parameters
-
event | This is not modified by the cuts so is const. In the event loop each event is passed to this function and the cuts are applied and the results recorded. |
- Returns
- If the event passes all cuts, or at least all those before SAVE then true will be returned - which means that this event passes the selection - and false otherwise. The selection flag will be set accordingly. In case of true if SAVE is present then the event will be saved.
Definition at line 301 of file EventSelection.cxx.
303 bool passEvent(
false);
305 for (
const auto& currentCut :
m_allCuts) {
310 double mcweight = 1.;
311 double puweight = 1.;
312 double leptonSF = 1.;
315 mcweight =
event.m_info->auxdataConst<
float>(
"AnalysisTop_eventWeight");
326 bool countThisCut(
true);
328 countThisCut =
false;
331 countThisCut =
false;
334 countThisCut =
false;
337 countThisCut =
false;
357 passEvent |= (currentCut->name() ==
"SAVE");
◆ applyParticleLevel()
Apply the selection for each particle level event.
This loops through all the cuts configured for reco (nominal) level to see if the top::ParticleLevelEvent passes them or not. It also fills the particle level cutflow histogram corresponding to the stage up to which the event passes through the event selection.
- Parameters
-
plEvent | This is the particle level event which is in question. It will not be modified by any of the cuts. |
- Returns
- If the event passes all cuts, or at least all those before SAVE then true will be returned - which means that this event passes the selection - and false otherwise. The selection flag will be set accordingly. In case of true if SAVE is present then the event will be saved.
Definition at line 367 of file EventSelection.cxx.
380 bool passEvent(
false);
382 for (
const auto& currentCut :
m_allCuts) {
383 const bool passed = currentCut->applyParticleLevel(plEvent);
392 passEvent |= (currentCut->name() ==
"SAVE");
◆ countGoodCalo()
void top::EventSelection::countGoodCalo |
( |
const float |
mcEventWeight, |
|
|
const float |
pileupWeight |
|
) |
| const |
|
virtual |
◆ countGRL()
void top::EventSelection::countGRL |
( |
const float |
mcEventWeight, |
|
|
const float |
pileupWeight |
|
) |
| const |
|
virtual |
◆ countInitial()
void top::EventSelection::countInitial |
( |
const float |
mcEventWeight, |
|
|
const float |
pileupWeight |
|
) |
| const |
|
virtual |
◆ countPrimaryVertex()
void top::EventSelection::countPrimaryVertex |
( |
const float |
mcEventWeight, |
|
|
const float |
pileupWeight |
|
) |
| const |
|
virtual |
◆ finalise()
void top::EventSelection::finalise |
( |
| ) |
const |
|
virtual |
Print some yield information.
This is not done in the destructor because we might not have a file open at that point in time.
Definition at line 402 of file EventSelection.cxx.
405 msgInfo << std::right;
406 if (
m_isMC) msgInfo << std::fixed << std::setprecision(2);
410 msgInfo <<
" - " <<
m_name <<
" cutflow:\n";
413 msgInfo << std::setw(7) <<
"" <<
414 std::setw(30) <<
"cut" <<
415 std::setw(15) <<
"events";
418 msgInfo << std::setw(15) <<
"mc weights" <<
419 std::setw(15) <<
"mc*pu weights" <<
420 std::setw(15) <<
"lepton SF" <<
421 std::setw(15) <<
"b-tag SF";
424 msgInfo << std::setw(15) <<
"particle level";
428 msgInfo << std::setw(15) <<
"particle level mc";
435 msgInfo <<
" " << std::setw(3) <<
i
436 << std::setw(30) <<
m_cutflow->GetXaxis()->GetBinLabel(
i)
437 << std::setw(15) <<
m_cutflow->GetBinContent(
i);
457 msgInfo <<
" - " <<
m_name <<
" cutflow (Loose):\n";
460 msgInfo << std::setw(7) <<
"" <<
461 std::setw(30) <<
"cut" <<
462 std::setw(15) <<
"events";
465 msgInfo << std::setw(15) <<
"mc weights" <<
466 std::setw(15) <<
"mc*pu weights" <<
467 std::setw(15) <<
"lepton SF" <<
468 std::setw(15) <<
"b-tag SF";
471 msgInfo << std::setw(15) <<
"particle level";
475 msgInfo << std::setw(15) <<
"particle level mc";
482 msgInfo <<
" " << std::setw(3) <<
i
◆ GetFakesMMConfigs()
std::vector< std::string > top::EventSelection::GetFakesMMConfigs |
( |
| ) |
const |
Gives you the lists of the Fakes MM configurations associated to this selection.
- Returns
- The list of configurations
Definition at line 510 of file EventSelection.cxx.
511 std::vector<std::string> configs;
512 for (
const auto& currentCutName :
m_allCuts) {
513 if (currentCutName->name() !=
"FAKESMMCONFIGS")
continue;
515 FakesMMConfigs*
conf =
dynamic_cast<FakesMMConfigs*
>(currentCutName.get());
516 for (
const std::string&
s :
conf->configurations())
517 configs.push_back(
s);
◆ initialiseTopScaleFactorRetriever()
void top::EventSelection::initialiseTopScaleFactorRetriever |
( |
const std::shared_ptr< TopConfig > & |
config | ) |
|
|
private |
Function to setup the tool in one place.
Definition at line 221 of file EventSelection.cxx.
223 if (asg::ToolStore::contains<ScaleFactorRetriever>(
"top::ScaleFactorRetriever")) {
224 m_sfRetriever = asg::ToolStore::get<ScaleFactorRetriever>(
"top::ScaleFactorRetriever");
227 top::check(asg::setProperty(topSFR,
"config",
config),
"Failed to set config");
◆ name()
const std::string top::EventSelection::name |
( |
| ) |
const |
Tells you the name of this event selection.
- Returns
- The name of this event selection
Definition at line 506 of file EventSelection.cxx.
◆ operator=()
Assignment is not allowed.
◆ printCuts()
void top::EventSelection::printCuts |
( |
| ) |
|
|
privatevirtual |
Print a cutflow showing the number of events passing each cut.
Definition at line 523 of file EventSelection.cxx.
525 msgInfo <<
"\n - " <<
m_name <<
":\n";
528 msgInfo <<
" " << std::setw(3) <<
i
529 << std::setw(30) <<
m_cutflow->GetXaxis()->GetBinLabel(
i)
532 }
else if (
m_config->doLooseEvents()) {
534 msgInfo <<
" " << std::setw(3) <<
i
539 msgInfo << std::endl;
◆ ToBeSaved()
bool top::EventSelection::ToBeSaved |
( |
| ) |
const |
|
inline |
Tells if the event should be saved if it passes this selection.
- Returns
- If one of the cuts is called SAVE, returns true
Definition at line 157 of file EventSelection.h.
◆ m_allCuts
Vector of all the tools that will be used in the analysis.
Definition at line 165 of file EventSelection.h.
◆ m_config
std::shared_ptr<TopConfig> top::EventSelection::m_config |
|
private |
◆ m_containsGoodCalo
bool top::EventSelection::m_containsGoodCalo |
|
private |
◆ m_containsGRL
bool top::EventSelection::m_containsGRL |
|
private |
◆ m_containsInitial
bool top::EventSelection::m_containsInitial |
|
private |
◆ m_containsPrimaryVertex
bool top::EventSelection::m_containsPrimaryVertex |
|
private |
◆ m_cutflow
TH1D* top::EventSelection::m_cutflow |
|
mutableprivate |
◆ m_cutflow_Loose
TH1D* top::EventSelection::m_cutflow_Loose |
|
mutableprivate |
◆ m_cutflowMCPUWeights
TH1D* top::EventSelection::m_cutflowMCPUWeights |
|
mutableprivate |
Cutflow counting MC*Pileup weights instead of events.
Definition at line 180 of file EventSelection.h.
◆ m_cutflowMCPUWeights_Loose
TH1D* top::EventSelection::m_cutflowMCPUWeights_Loose |
|
mutableprivate |
◆ m_cutflowMCWeights
TH1D* top::EventSelection::m_cutflowMCWeights |
|
mutableprivate |
◆ m_cutflowMCWeights_Loose
TH1D* top::EventSelection::m_cutflowMCWeights_Loose |
|
mutableprivate |
◆ m_cutflowParticleLevel
TH1D* top::EventSelection::m_cutflowParticleLevel |
|
mutableprivate |
The particle level cutflow histogram filled by the tool.
Definition at line 188 of file EventSelection.h.
◆ m_cutflowParticleLevelMCWeights
TH1D* top::EventSelection::m_cutflowParticleLevelMCWeights |
|
mutableprivate |
◆ m_cutflowPUWeights
TH1D* top::EventSelection::m_cutflowPUWeights |
|
mutableprivate |
Cutflow counting PileUp weights instead of events.
Definition at line 176 of file EventSelection.h.
◆ m_cutflowPUWeights_Loose
TH1D* top::EventSelection::m_cutflowPUWeights_Loose |
|
mutableprivate |
◆ m_cutflowScaleFactors
TH1D* top::EventSelection::m_cutflowScaleFactors |
|
mutableprivate |
Cutflow counting ScaleFactors instead of events.
Definition at line 184 of file EventSelection.h.
◆ m_cutflowScaleFactors_Loose
TH1D* top::EventSelection::m_cutflowScaleFactors_Loose |
|
mutableprivate |
◆ m_isMC
bool top::EventSelection::m_isMC |
|
mutableprivate |
To turn on/off confusing messages about mc weights when running on data.
Definition at line 198 of file EventSelection.h.
◆ m_name
std::string top::EventSelection::m_name |
|
private |
Name of this selection (you can have multiple selections run in the same job.
Definition at line 195 of file EventSelection.h.
◆ m_nominalHashValue
std::size_t top::EventSelection::m_nominalHashValue |
|
private |
◆ m_positionGoodCalo
unsigned int top::EventSelection::m_positionGoodCalo |
|
private |
◆ m_positionGRL
unsigned int top::EventSelection::m_positionGRL |
|
private |
◆ m_positionInitial
unsigned int top::EventSelection::m_positionInitial |
|
private |
◆ m_positionPrimaryVertex
unsigned int top::EventSelection::m_positionPrimaryVertex |
|
private |
◆ m_sfRetriever
◆ m_toBeSaved
bool top::EventSelection::m_toBeSaved |
|
private |
The documentation for this class was generated from the following files:
std::shared_ptr< TopConfig > m_config
const xAOD::EventInfo * m_info
Pointer to the event info object.
TH1D * m_cutflowParticleLevel
The particle level cutflow histogram filled by the tool.
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
TH1D * m_cutflowMCWeights
Cutflow counting MC weights instead of events.
TH1D * m_cutflowMCWeights_Loose
virtual void printCuts()
Print a cutflow showing the number of events passing each cut.
static bool hasPileupSF(const top::Event &event)
TH1D * m_cutflowMCPUWeights
Cutflow counting MC*Pileup weights instead of events.
TH1D * m_cutflowParticleLevelMCWeights
Class to wrap a set of SystematicVariations.
TH1D * m_cutflowScaleFactors
Cutflow counting ScaleFactors instead of events.
unsigned int m_positionGRL
unsigned int m_positionPrimaryVertex
TH1D * m_cutflowPUWeights_Loose
std::size_t m_nominalHashValue
float leptonSF(const top::Event &event, const top::topSFSyst SFSyst) const
POOL::TEvent event(POOL::TEvent::kClassAccess)
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
StatusCode initialize()
Dummy implementation of the initialisation function.
TH1D * m_cutflow
The cutflow histogram filled by the tool.
This should apply event-level cuts and perform simple plotting on top::Event objects.
unsigned int m_positionInitial
const std::string name() const
Tells you the name of this event selection.
unsigned int m_positionGoodCalo
static float pileupSF(const top::Event &event, int var=0)
std::vector< std::string > config
bool m_containsPrimaryVertex
void initialiseTopScaleFactorRetriever(const std::shared_ptr< TopConfig > &config)
Function to setup the tool in one place.
bool m_isMC
To turn on/off confusing messages about mc weights when running on data.
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
std::vector< std::unique_ptr< EventSelectorBase > > m_allCuts
Vector of all the tools that will be used in the analysis.
ScaleFactorRetriever * m_sfRetriever
Scale factors.
TH1D * m_cutflowMCPUWeights_Loose
TH1D * m_cutflowPUWeights
Cutflow counting PileUp weights instead of events.
std::string m_name
Name of this selection (you can have multiple selections run in the same job.
TH1D * m_cutflowScaleFactors_Loose