ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
top::EventSelection Class Referencefinal

Perform the event selection on a top::Event object. More...

#include <EventSelection.h>

Collaboration diagram for top::EventSelection:

Public Member Functions

 EventSelection (const std::string &name, const std::vector< std::string > &cutNames, TFile *outputFile, const std::vector< std::unique_ptr< top::ToolLoaderBase > > &toolLoaders, const std::shared_ptr< top::TopConfig > &config, EL::Worker *wk)
 Construct using a vector of cuts. More...
 
virtual ~EventSelection ()
 Does not do anything. More...
 
 EventSelection (EventSelection &&other)
 Move constructor. More...
 
 EventSelection ()=delete
 Default constructor is not allowed. More...
 
 EventSelection (const EventSelection &)=delete
 Copy is not allowed. More...
 
EventSelectionoperator= (const EventSelection &)=delete
 Assignment is not allowed. More...
 
virtual void countInitial (const float mcEventWeight, const float pileupWeight) const
 Count the number of initial events. More...
 
virtual void countGRL (const float mcEventWeight, const float pileupWeight) const
 Count the number of events passing GRL. More...
 
virtual void countGoodCalo (const float mcEventWeight, const float pileupWeight) const
 Count the number of events passing Good Calo. More...
 
virtual void countPrimaryVertex (const float mcEventWeight, const float pileupWeight) const
 Count the number of events passing Primary Vertex. More...
 
virtual bool apply (const top::Event &event) const
 Apply the selection for each event. More...
 
virtual bool applyParticleLevel (const top::ParticleLevelEvent &plEvent) const
 Apply the selection for each particle level event. More...
 
virtual void finalise () const
 Print some yield information. More...
 
const std::string name () const
 Tells you the name of this event selection. More...
 
std::vector< std::string > GetFakesMMConfigs () const
 Gives you the lists of the Fakes MM configurations associated to this selection. More...
 
bool ToBeSaved () const
 Tells if the event should be saved if it passes this selection. More...
 

Private Member Functions

virtual void printCuts ()
 Print a cutflow showing the number of events passing each cut. More...
 
void initialiseTopScaleFactorRetriever (const std::shared_ptr< TopConfig > &config)
 Function to setup the tool in one place. More...
 

Private Attributes

std::vector< std::unique_ptr< EventSelectorBase > > m_allCuts
 Vector of all the tools that will be used in the analysis. More...
 
TH1Dm_cutflow
 The cutflow histogram filled by the tool. More...
 
TH1Dm_cutflow_Loose
 
TH1Dm_cutflowMCWeights
 Cutflow counting MC weights instead of events. More...
 
TH1Dm_cutflowMCWeights_Loose
 
TH1Dm_cutflowPUWeights
 Cutflow counting PileUp weights instead of events. More...
 
TH1Dm_cutflowPUWeights_Loose
 
TH1Dm_cutflowMCPUWeights
 Cutflow counting MC*Pileup weights instead of events. More...
 
TH1Dm_cutflowMCPUWeights_Loose
 
TH1Dm_cutflowScaleFactors
 Cutflow counting ScaleFactors instead of events. More...
 
TH1Dm_cutflowScaleFactors_Loose
 
TH1Dm_cutflowParticleLevel
 The particle level cutflow histogram filled by the tool. More...
 
TH1Dm_cutflowParticleLevelMCWeights
 
std::string m_name
 Name of this selection (you can have multiple selections run in the same job. More...
 
bool m_isMC
 To turn on/off confusing messages about mc weights when running on data. More...
 
std::shared_ptr< TopConfigm_config
 
ScaleFactorRetrieverm_sfRetriever
 Scale factors. More...
 
std::size_t m_nominalHashValue
 
bool m_containsInitial
 
bool m_containsGRL
 
bool m_containsGoodCalo
 
bool m_containsPrimaryVertex
 
unsigned int m_positionInitial
 
unsigned int m_positionGRL
 
unsigned int m_positionGoodCalo
 
unsigned int m_positionPrimaryVertex
 
bool m_toBeSaved
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ EventSelection() [1/4]

top::EventSelection::EventSelection ( const std::string &  name,
const std::vector< std::string > &  cutNames,
TFile *  outputFile,
const std::vector< std::unique_ptr< top::ToolLoaderBase > > &  toolLoaders,
const std::shared_ptr< top::TopConfig > &  config,
EL::Worker wk 
)

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.

36  :
37  m_cutflow(nullptr),
38  m_cutflow_Loose(nullptr),
39  m_cutflowMCWeights(nullptr),
40  m_cutflowMCWeights_Loose(nullptr),
41  m_cutflowPUWeights(nullptr),
42  m_cutflowPUWeights_Loose(nullptr),
43  m_cutflowMCPUWeights(nullptr),
45  m_cutflowScaleFactors(nullptr),
47  m_cutflowParticleLevel(nullptr),
49  m_name(name),
50  m_isMC(false),
51  m_sfRetriever(nullptr),
53  m_containsInitial(false),
54  m_containsGRL(false),
55  m_containsGoodCalo(false),
58  m_positionGRL(0),
61  m_toBeSaved(false) {
62  // We use the nominal hash value so we don't do
63  // string comparisions during the event loop
65  m_nominalHashValue = nominal.hash();
66 
67  // need that later for the sf in the cutflow, not especially elegant but works for now
68  m_config = config;
69  m_isMC = config->isMC();
70 
71  if (m_isMC) {
73  }
74 
75  TDirectory* plotDir = outputFile->mkdir(m_name.c_str());
76  plotDir->cd();
77  if (config->doTightEvents()) {
78  m_cutflow = new TH1D("cutflow", (name + " cutflow").c_str(), cutNames.size(), -0.5, cutNames.size() - 0.5);
79  m_cutflowMCWeights = new TH1D("cutflow_mc", (name + " cutflow MC weights").c_str(),
80  cutNames.size(), -0.5, cutNames.size() - 0.5);
81  m_cutflowPUWeights = new TH1D("cutflow_pu", (name + " cutflow PU weights").c_str(),
82  cutNames.size(), -0.5, cutNames.size() - 0.5);
83  m_cutflowMCPUWeights = new TH1D("cutflow_mc_pu", (name + " cutflow MC*PU weights").c_str(),
84  cutNames.size(), -0.5, cutNames.size() - 0.5);
85  m_cutflowScaleFactors = new TH1D("cutflow_scale_factors", (name + " cutflow ScaleFactors").c_str(),
86  cutNames.size(), -0.5, cutNames.size() - 0.5);
87  }
88  if (config->doLooseEvents()) {
89  m_cutflow_Loose = new TH1D("cutflow_Loose", (name + " cutflow_Loose").c_str(),
90  cutNames.size(), -0.5, cutNames.size() - 0.5);
91  m_cutflowMCWeights_Loose = new TH1D("cutflow_mc_Loose",
92  (name + " cutflow_Loose MC weights").c_str(),
93  cutNames.size(), -0.5, cutNames.size() - 0.5);
94  m_cutflowPUWeights_Loose = new TH1D("cutflow_pu_Loose",
95  (name + " cutflow_Loose PU weights").c_str(),
96  cutNames.size(), -0.5, cutNames.size() - 0.5);
97  m_cutflowMCPUWeights_Loose = new TH1D("cutflow_mc_pu_Loose",
98  (name + " cutflow_Loose MC*PU weights").c_str(),
99  cutNames.size(), -0.5, cutNames.size() - 0.5);
100  m_cutflowScaleFactors_Loose = new TH1D("cutflow_scale_factors_Loose",
101  (name + " cutflow_Loose ScaleFactors").c_str(),
102  cutNames.size(), -0.5, cutNames.size() - 0.5);
103  }
104 
105  if (config->doTopParticleLevel()) {
106  m_cutflowParticleLevel = new TH1D("cutflow_particle_level",
107  (name + " cutflow_particle_level").c_str(),
108  cutNames.size(), -0.5, cutNames.size() - 0.5);
109  m_cutflowParticleLevelMCWeights = new TH1D("cutflow_particle_level_mc",
110  (name + " cutflow_particle_level_mc").c_str(),
111  cutNames.size(), -0.5, cutNames.size() - 0.5);
112  }
113 
114  unsigned int i(0);
115  for (const auto& currentCutName : cutNames) {
116  //look through all the libraries and load any tools
117  top::EventSelectorBase* tool = nullptr;
118  for (const auto& libraryPtr : toolLoaders) {
119  tool = libraryPtr->initTool(m_name, currentCutName, outputFile, config, wk);
120  if (tool) break;
121  }
122 
123  if (tool != nullptr) {
124  m_allCuts.emplace_back(std::move(tool));
125  } else {
126  throw std::runtime_error("Could not find " + currentCutName);
127  }
128 
129  // Initlal and GRL
130  if (currentCutName == "INITIAL") {
131  m_containsInitial = true;
133  }
134 
135  if (currentCutName == "GRL") {
136  m_containsGRL = true;
137  m_positionGRL = i;
138  }
139 
140  if (currentCutName == "GOODCALO") {
141  m_containsGoodCalo = true;
143  }
144 
145  if (currentCutName == "PRIVTX") {
148  }
149 
150  //some cutflow histograms
151  if (config->doTightEvents()) {
152  m_cutflow->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
153  m_cutflowMCWeights->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
154  m_cutflowPUWeights->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
155  m_cutflowMCPUWeights->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
156  m_cutflowScaleFactors->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
157  }
158  if (config->doLooseEvents()) {
159  m_cutflow_Loose->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
160  m_cutflowMCWeights_Loose->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
161  m_cutflowPUWeights_Loose->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
162  m_cutflowMCPUWeights_Loose->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
163  m_cutflowScaleFactors_Loose->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
164  }
165 
167  m_cutflowParticleLevel->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
168  }
169 
171  m_cutflowParticleLevelMCWeights->GetXaxis()->SetBinLabel(i + 1, m_allCuts[i]->name().c_str());
172  }
173 
174  if (currentCutName == "SAVE") {
175  m_toBeSaved = true;
176  }
177 
178  ++i;
179  }
180 
181  //be nice to the user and tell them what they enabled
182  //at the very start of the run. It allows them to quit the program
183  //if they notice a problem.
184  printCuts();
185  }

◆ ~EventSelection()

virtual top::EventSelection::~EventSelection ( )
inlinevirtual

Does not do anything.

Definition at line 56 of file EventSelection.h.

56 {}

◆ EventSelection() [2/4]

top::EventSelection::EventSelection ( EventSelection &&  other)

Move constructor.

Definition at line 187 of file EventSelection.cxx.

187  :
188  m_allCuts(std::move(other.m_allCuts)),
189  m_cutflow(std::move(other.m_cutflow)),
190  m_cutflow_Loose(std::move(other.m_cutflow_Loose)),
191  m_cutflowMCWeights(std::move(other.m_cutflowMCWeights)),
192  m_cutflowMCWeights_Loose(std::move(other.m_cutflowMCWeights_Loose)),
193  m_cutflowPUWeights(std::move(other.m_cutflowPUWeights)),
194  m_cutflowPUWeights_Loose(std::move(other.m_cutflowPUWeights_Loose)),
195  m_cutflowMCPUWeights(std::move(other.m_cutflowMCPUWeights)),
196  m_cutflowMCPUWeights_Loose(std::move(other.m_cutflowMCPUWeights_Loose)),
197  m_cutflowScaleFactors(std::move(other.m_cutflowScaleFactors)),
198  m_cutflowScaleFactors_Loose(std::move(other.m_cutflowScaleFactors_Loose)),
199  m_cutflowParticleLevel(std::move(other.m_cutflowParticleLevel)),
200  m_cutflowParticleLevelMCWeights(std::move(other.m_cutflowParticleLevelMCWeights)),
201  m_name(std::move(other.m_name)),
202  m_isMC(std::move(other.m_isMC)),
203  m_config(std::move(other.m_config)),
204  m_sfRetriever(nullptr),
205  m_nominalHashValue(std::move(other.m_nominalHashValue)),
206  m_containsInitial(std::move(other.m_containsInitial)),
207  m_containsGRL(std::move(other.m_containsGRL)),
208  m_containsGoodCalo(std::move(other.m_containsGoodCalo)),
209  m_containsPrimaryVertex(std::move(other.m_containsPrimaryVertex)),
210  m_positionInitial(std::move(other.m_positionInitial)),
211  m_positionGRL(std::move(other.m_positionGRL)),
212  m_positionGoodCalo(std::move(other.m_positionGoodCalo)),
213  m_positionPrimaryVertex(std::move(other.m_positionPrimaryVertex)),
214  m_toBeSaved(std::move(other.m_toBeSaved)) {
215  // need this to calculate the lepton SF for the cutflow
216  if (m_isMC) {
218  }
219  }

◆ EventSelection() [3/4]

top::EventSelection::EventSelection ( )
delete

Default constructor is not allowed.

◆ EventSelection() [4/4]

top::EventSelection::EventSelection ( const EventSelection )
delete

Copy is not allowed.

Member Function Documentation

◆ apply()

bool top::EventSelection::apply ( const top::Event event) const
virtual

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
eventThis 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.

301  {
302  unsigned int i(0);
303  bool passEvent(false);
304 
305  for (const auto& currentCut : m_allCuts) {
306  const bool passed = currentCut->apply(event);
307 
308  if (!passed) break;
309 
310  double mcweight = 1.;
311  double puweight = 1.;
312  double leptonSF = 1.;
313 
314  if (m_isMC) {
315  mcweight = event.m_info->auxdataConst<float>("AnalysisTop_eventWeight");
316 
318 
320  }
321 
322  //add cutflow information for the nominal (not systematic) selection
323  //For data we have (sometimes) the same event with loose and tight
324  //The cutflow is just the "analysis" -> tight to avoid double counting
325  if (event.m_hashValue == m_nominalHashValue) {
326  bool countThisCut(true);
328  countThisCut = false;
329  }
330  if (m_containsGRL && i == m_positionGRL) {
331  countThisCut = false;
332  }
334  countThisCut = false;
335  }
337  countThisCut = false;
338  }
339  if (countThisCut) {
340  if (m_config->doTightEvents() && !event.m_isLoose) {
341  m_cutflow->Fill(i);
342  m_cutflowMCWeights->Fill(i, mcweight);
343  m_cutflowPUWeights->Fill(i, puweight);
344  m_cutflowMCPUWeights->Fill(i, mcweight * puweight);
345  m_cutflowScaleFactors->Fill(i, leptonSF);
346  }
347  if (m_config->doLooseEvents() && event.m_isLoose) {
348  m_cutflow_Loose->Fill(i);
349  m_cutflowMCWeights_Loose->Fill(i, mcweight);
350  m_cutflowPUWeights_Loose->Fill(i, puweight);
351  m_cutflowMCPUWeights_Loose->Fill(i, mcweight * puweight);
352  m_cutflowScaleFactors_Loose->Fill(i, leptonSF);
353  }
354  }
355  }
356 
357  passEvent |= (currentCut->name() == "SAVE");
358  ++i;
359  }
360 
361  // If "SAVE" wasn't found but event passes all cuts, event passes the selection
362  passEvent |= (i == m_allCuts.size());
363 
364  return passEvent;
365  }

◆ applyParticleLevel()

bool top::EventSelection::applyParticleLevel ( const top::ParticleLevelEvent plEvent) const
virtual

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
plEventThis 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.

367  {
368  // In principle, this function should never be called for non-active
369  // particle level. However, for code safetly, include a null pointer
370  // check. Return false here because "do-not-do-particle-level" is equivalent
371  // to "do-no-save-particle-level".
372  if (not m_cutflowParticleLevel) {
373  return false;
374  }
376  return false;
377  }
378 
379  unsigned int i(0);
380  bool passEvent(false);
381 
382  for (const auto& currentCut : m_allCuts) {
383  const bool passed = currentCut->applyParticleLevel(plEvent);
384 
385  if (!passed) break;
386 
387  m_cutflowParticleLevel->Fill(i);
388 
389  double mcweight = plEvent.m_info->mcEventWeight(0);
390  m_cutflowParticleLevelMCWeights->Fill(i, mcweight);
391 
392  passEvent |= (currentCut->name() == "SAVE");
393  ++i;
394  }
395 
396  // If "SAVE" wasn't found but event passes all cuts, event passes the selection
397  passEvent |= (i == m_allCuts.size());
398 
399  return passEvent;
400  }

◆ countGoodCalo()

void top::EventSelection::countGoodCalo ( const float  mcEventWeight,
const float  pileupWeight 
) const
virtual

Count the number of events passing Good Calo.

Definition at line 267 of file EventSelection.cxx.

267  {
268  if (m_containsGoodCalo) {
269  if (m_config->doTightEvents()) {
271  m_cutflowMCWeights->Fill(m_positionGoodCalo, mcEventWeight);
272  m_cutflowPUWeights->Fill(m_positionGoodCalo, pileupWeight);
273  m_cutflowMCPUWeights->Fill(m_positionGoodCalo, mcEventWeight * pileupWeight);
274  }
275  if (m_config->doLooseEvents()) {
277  m_cutflowMCWeights_Loose->Fill(m_positionGoodCalo, mcEventWeight);
278  m_cutflowPUWeights_Loose->Fill(m_positionGoodCalo, pileupWeight);
279  m_cutflowMCPUWeights_Loose->Fill(m_positionGoodCalo, mcEventWeight * pileupWeight);
280  }
281  }
282  }

◆ countGRL()

void top::EventSelection::countGRL ( const float  mcEventWeight,
const float  pileupWeight 
) const
virtual

Count the number of events passing GRL.

Definition at line 250 of file EventSelection.cxx.

250  {
251  if (m_containsGRL) {
252  if (m_config->doTightEvents()) {
253  m_cutflow->Fill(m_positionGRL);
254  m_cutflowMCWeights->Fill(m_positionGRL, mcEventWeight);
255  m_cutflowPUWeights->Fill(m_positionGRL, pileupWeight);
256  m_cutflowMCPUWeights->Fill(m_positionGRL, mcEventWeight * pileupWeight);
257  }
258  if (m_config->doLooseEvents()) {
260  m_cutflowMCWeights_Loose->Fill(m_positionGRL, mcEventWeight);
261  m_cutflowPUWeights_Loose->Fill(m_positionGRL, pileupWeight);
262  m_cutflowMCPUWeights_Loose->Fill(m_positionGRL, mcEventWeight * pileupWeight);
263  }
264  }
265  }

◆ countInitial()

void top::EventSelection::countInitial ( const float  mcEventWeight,
const float  pileupWeight 
) const
virtual

Count the number of initial events.

Definition at line 233 of file EventSelection.cxx.

233  {
234  if (m_containsInitial) {
235  if (m_config->doTightEvents()) {
237  m_cutflowMCWeights->Fill(m_positionInitial, mcEventWeight);
238  m_cutflowPUWeights->Fill(m_positionInitial, pileupWeight);
239  m_cutflowMCPUWeights->Fill(m_positionInitial, mcEventWeight * pileupWeight);
240  }
241  if (m_config->doLooseEvents()) {
243  m_cutflowMCWeights_Loose->Fill(m_positionInitial, mcEventWeight);
244  m_cutflowPUWeights_Loose->Fill(m_positionInitial, pileupWeight);
245  m_cutflowMCPUWeights_Loose->Fill(m_positionInitial, mcEventWeight * pileupWeight);
246  }
247  }
248  }

◆ countPrimaryVertex()

void top::EventSelection::countPrimaryVertex ( const float  mcEventWeight,
const float  pileupWeight 
) const
virtual

Count the number of events passing Primary Vertex.

Definition at line 284 of file EventSelection.cxx.

284  {
286  if (m_config->doTightEvents()) {
288  m_cutflowMCWeights->Fill(m_positionPrimaryVertex, mcEventWeight);
289  m_cutflowPUWeights->Fill(m_positionPrimaryVertex, pileupWeight);
290  m_cutflowMCPUWeights->Fill(m_positionPrimaryVertex, mcEventWeight * pileupWeight);
291  }
292  if (m_config->doLooseEvents()) {
296  m_cutflowMCPUWeights_Loose->Fill(m_positionPrimaryVertex, mcEventWeight * pileupWeight);
297  }
298  }
299  }

◆ 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.

402  {
403  //2dp, neater output for numbers
404  MsgStream& msgInfo = msg(MSG::Level::INFO);
405  msgInfo << std::right;
406  if (m_isMC) msgInfo << std::fixed << std::setprecision(2);
407 
408  if (m_config->doTightEvents()) {
409  //channel name
410  msgInfo << " - " << m_name << " cutflow:\n";
411 
412  //some headings
413  msgInfo << std::setw(7) << "" <<
414  std::setw(30) << "cut" <<
415  std::setw(15) << "events";
416 
417  if (m_isMC)
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";
422 
424  msgInfo << std::setw(15) << "particle level";
425  }
426 
428  msgInfo << std::setw(15) << "particle level mc";
429  }
430 
431  msgInfo << "\n";
432 
433  //cutflow table content
434  for (int i = 1; i <= m_cutflow->GetNbinsX(); ++i) {
435  msgInfo << " " << std::setw(3) << i
436  << std::setw(30) << m_cutflow->GetXaxis()->GetBinLabel(i)
437  << std::setw(15) << m_cutflow->GetBinContent(i);
438 
439  if (m_isMC)
440  msgInfo << std::setw(15) << m_cutflowMCWeights->GetBinContent(i)
441  << std::setw(15) << m_cutflowMCPUWeights->GetBinContent(i)
442  << std::setw(15) << m_cutflowScaleFactors->GetBinContent(i);
443 
445  msgInfo << std::setw(15) << m_cutflowParticleLevel->GetBinContent(i);
446  }
447 
449  msgInfo << std::setw(15) << m_cutflowParticleLevelMCWeights->GetBinContent(i);
450  }
451 
452  msgInfo << "\n";
453  }
454  }
455  if (m_config->doLooseEvents()) {
456  //channel name
457  msgInfo << " - " << m_name << " cutflow (Loose):\n";
458 
459  //some headings
460  msgInfo << std::setw(7) << "" <<
461  std::setw(30) << "cut" <<
462  std::setw(15) << "events";
463 
464  if (m_isMC)
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";
469 
471  msgInfo << std::setw(15) << "particle level";
472  }
473 
475  msgInfo << std::setw(15) << "particle level mc";
476  }
477 
478  msgInfo << "\n";
479 
480  //cutflow table content
481  for (int i = 1; i <= m_cutflow_Loose->GetNbinsX(); ++i) {
482  msgInfo << " " << std::setw(3) << i
483  << std::setw(30) << m_cutflow_Loose->GetXaxis()->GetBinLabel(i)
484  << std::setw(15) << m_cutflow_Loose->GetBinContent(i);
485 
486  if (m_isMC)
487  msgInfo << std::setw(15) << m_cutflowMCWeights_Loose->GetBinContent(i)
488  << std::setw(15) << m_cutflowMCPUWeights_Loose->GetBinContent(i)
489  << std::setw(15) << m_cutflowScaleFactors_Loose->GetBinContent(i);
490 
492  msgInfo << std::setw(15) << m_cutflowParticleLevel->GetBinContent(i);
493  }
494 
496  msgInfo << std::setw(15) << m_cutflowParticleLevelMCWeights->GetBinContent(i);
497  }
498 
499  msgInfo << "\n";
500  }
501  }
502  msgInfo << "\n";
503  msgInfo.doOutput();
504  }

◆ 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.

510  {
511  std::vector<std::string> configs;
512  for (const auto& currentCutName : m_allCuts) {
513  if (currentCutName->name() != "FAKESMMCONFIGS") continue;
514  else {
515  FakesMMConfigs* conf = dynamic_cast<FakesMMConfigs*>(currentCutName.get());
516  for (const std::string& s : conf->configurations())
517  configs.push_back(s);
518  }
519  }
520  return configs;
521  }

◆ 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.

221  {
222  // Define this once, and then use it when needed
223  if (asg::ToolStore::contains<ScaleFactorRetriever>("top::ScaleFactorRetriever")) {
224  m_sfRetriever = asg::ToolStore::get<ScaleFactorRetriever>("top::ScaleFactorRetriever");
225  } else {
226  top::ScaleFactorRetriever* topSFR = new top::ScaleFactorRetriever("top::ScaleFactorRetriever");
227  top::check(asg::setProperty(topSFR, "config", config), "Failed to set config");
228  top::check(topSFR->initialize(), "Failed to initalialise");
229  m_sfRetriever = topSFR;
230  }
231  }

◆ 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.

506  {
507  return m_name;
508  }

◆ operator=()

EventSelection& top::EventSelection::operator= ( const EventSelection )
delete

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.

523  {
524  MsgStream& msgInfo = msg(MSG::Level::INFO);
525  msgInfo << "\n - " << m_name << ":\n";
526  if (m_config->doTightEvents()) {
527  for (int i = 1; i <= m_cutflow->GetNbinsX(); ++i) {
528  msgInfo << " " << std::setw(3) << i
529  << std::setw(30) << m_cutflow->GetXaxis()->GetBinLabel(i)
530  << "\n";
531  }
532  } else if (m_config->doLooseEvents()) {
533  for (int i = 1; i <= m_cutflow_Loose->GetNbinsX(); ++i) {
534  msgInfo << " " << std::setw(3) << i
535  << std::setw(30) << m_cutflow_Loose->GetXaxis()->GetBinLabel(i)
536  << "\n";
537  }
538  }
539  msgInfo << std::endl;
540  msgInfo.doOutput();
541  }

◆ 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.

157 {return m_toBeSaved;};

Member Data Documentation

◆ m_allCuts

std::vector<std::unique_ptr<EventSelectorBase> > top::EventSelection::m_allCuts
private

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

Definition at line 201 of file EventSelection.h.

◆ m_containsGoodCalo

bool top::EventSelection::m_containsGoodCalo
private

Definition at line 215 of file EventSelection.h.

◆ m_containsGRL

bool top::EventSelection::m_containsGRL
private

Definition at line 214 of file EventSelection.h.

◆ m_containsInitial

bool top::EventSelection::m_containsInitial
private

Definition at line 213 of file EventSelection.h.

◆ m_containsPrimaryVertex

bool top::EventSelection::m_containsPrimaryVertex
private

Definition at line 216 of file EventSelection.h.

◆ m_cutflow

TH1D* top::EventSelection::m_cutflow
mutableprivate

The cutflow histogram filled by the tool.

Definition at line 168 of file EventSelection.h.

◆ m_cutflow_Loose

TH1D* top::EventSelection::m_cutflow_Loose
mutableprivate

Definition at line 169 of file EventSelection.h.

◆ 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

Definition at line 181 of file EventSelection.h.

◆ m_cutflowMCWeights

TH1D* top::EventSelection::m_cutflowMCWeights
mutableprivate

Cutflow counting MC weights instead of events.

Definition at line 172 of file EventSelection.h.

◆ m_cutflowMCWeights_Loose

TH1D* top::EventSelection::m_cutflowMCWeights_Loose
mutableprivate

Definition at line 173 of file EventSelection.h.

◆ 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

Definition at line 189 of file EventSelection.h.

◆ 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

Definition at line 177 of file EventSelection.h.

◆ 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

Definition at line 185 of file EventSelection.h.

◆ 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

Definition at line 209 of file EventSelection.h.

◆ m_positionGoodCalo

unsigned int top::EventSelection::m_positionGoodCalo
private

Definition at line 219 of file EventSelection.h.

◆ m_positionGRL

unsigned int top::EventSelection::m_positionGRL
private

Definition at line 218 of file EventSelection.h.

◆ m_positionInitial

unsigned int top::EventSelection::m_positionInitial
private

Definition at line 217 of file EventSelection.h.

◆ m_positionPrimaryVertex

unsigned int top::EventSelection::m_positionPrimaryVertex
private

Definition at line 220 of file EventSelection.h.

◆ m_sfRetriever

ScaleFactorRetriever* top::EventSelection::m_sfRetriever
private

Scale factors.

Definition at line 204 of file EventSelection.h.

◆ m_toBeSaved

bool top::EventSelection::m_toBeSaved
private

Definition at line 225 of file EventSelection.h.


The documentation for this class was generated from the following files:
top::EventSelection::m_toBeSaved
bool m_toBeSaved
Definition: EventSelection.h:225
top::EventSelection::m_config
std::shared_ptr< TopConfig > m_config
Definition: EventSelection.h:201
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
top::ParticleLevelEvent::m_info
const xAOD::EventInfo * m_info
Pointer to the event info object.
Definition: ParticleLevelEvent.h:39
top::EventSelection::m_cutflowParticleLevel
TH1D * m_cutflowParticleLevel
The particle level cutflow histogram filled by the tool.
Definition: EventSelection.h:188
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
top::EventSelection::m_containsGRL
bool m_containsGRL
Definition: EventSelection.h:214
top::EventSelection::m_cutflowMCWeights
TH1D * m_cutflowMCWeights
Cutflow counting MC weights instead of events.
Definition: EventSelection.h:172
top::EventSelection::m_cutflowMCWeights_Loose
TH1D * m_cutflowMCWeights_Loose
Definition: EventSelection.h:173
top::EventSelection::printCuts
virtual void printCuts()
Print a cutflow showing the number of events passing each cut.
Definition: EventSelection.cxx:523
top::ScaleFactorRetriever::hasPileupSF
static bool hasPileupSF(const top::Event &event)
Definition: ScaleFactorRetriever.cxx:63
top::EventSelection::m_cutflowMCPUWeights
TH1D * m_cutflowMCPUWeights
Cutflow counting MC*Pileup weights instead of events.
Definition: EventSelection.h:180
top::EventSelection::m_cutflowParticleLevelMCWeights
TH1D * m_cutflowParticleLevelMCWeights
Definition: EventSelection.h:189
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
top::EventSelection::m_cutflowScaleFactors
TH1D * m_cutflowScaleFactors
Cutflow counting ScaleFactors instead of events.
Definition: EventSelection.h:184
top::EventSelection::m_containsInitial
bool m_containsInitial
Definition: EventSelection.h:213
top::EventSelection::m_positionGRL
unsigned int m_positionGRL
Definition: EventSelection.h:218
top::EventSelection::m_positionPrimaryVertex
unsigned int m_positionPrimaryVertex
Definition: EventSelection.h:220
top::EventSelection::m_cutflowPUWeights_Loose
TH1D * m_cutflowPUWeights_Loose
Definition: EventSelection.h:177
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
top::EventSelection::m_nominalHashValue
std::size_t m_nominalHashValue
Definition: EventSelection.h:209
top::ScaleFactorRetriever::leptonSF
float leptonSF(const top::Event &event, const top::topSFSyst SFSyst) const
Definition: ScaleFactorRetriever.cxx:85
compareGeometries.outputFile
string outputFile
Definition: compareGeometries.py:25
python.ConfigurableDb.conf
def conf
Definition: ConfigurableDb.py:282
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:92
top::nominal
@ nominal
Definition: ScaleFactorRetriever.h:29
top::check
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
Definition: EventTools.cxx:15
top::EventSelection::m_cutflow_Loose
TH1D * m_cutflow_Loose
Definition: EventSelection.h:169
top::ScaleFactorRetriever::initialize
StatusCode initialize()
Dummy implementation of the initialisation function.
Definition: ScaleFactorRetriever.cxx:30
top::EventSelection::m_cutflow
TH1D * m_cutflow
The cutflow histogram filled by the tool.
Definition: EventSelection.h:168
top::ScaleFactorRetriever
Definition: ScaleFactorRetriever.h:216
top::EventSelectorBase
This should apply event-level cuts and perform simple plotting on top::Event objects.
Definition: EventSelectorBase.h:20
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
top::EventSelection::m_positionInitial
unsigned int m_positionInitial
Definition: EventSelection.h:217
top::EventSelection::name
const std::string name() const
Tells you the name of this event selection.
Definition: EventSelection.cxx:506
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
top::EventSelection::m_containsGoodCalo
bool m_containsGoodCalo
Definition: EventSelection.h:215
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:16
top::EventSelection::m_positionGoodCalo
unsigned int m_positionGoodCalo
Definition: EventSelection.h:219
top::ScaleFactorRetriever::pileupSF
static float pileupSF(const top::Event &event, int var=0)
Definition: ScaleFactorRetriever.cxx:68
config
std::vector< std::string > config
Definition: fbtTestBasics.cxx:72
top::EventSelection::m_containsPrimaryVertex
bool m_containsPrimaryVertex
Definition: EventSelection.h:216
top::EventSelection::initialiseTopScaleFactorRetriever
void initialiseTopScaleFactorRetriever(const std::shared_ptr< TopConfig > &config)
Function to setup the tool in one place.
Definition: EventSelection.cxx:221
top::EventSelection::m_isMC
bool m_isMC
To turn on/off confusing messages about mc weights when running on data.
Definition: EventSelection.h:198
xAOD::EventInfo_v1::mcEventWeight
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
Definition: EventInfo_v1.cxx:203
top::EventSelection::m_allCuts
std::vector< std::unique_ptr< EventSelectorBase > > m_allCuts
Vector of all the tools that will be used in the analysis.
Definition: EventSelection.h:165
top::EventSelection::m_sfRetriever
ScaleFactorRetriever * m_sfRetriever
Scale factors.
Definition: EventSelection.h:204
top::EventSelection::m_cutflowMCPUWeights_Loose
TH1D * m_cutflowMCPUWeights_Loose
Definition: EventSelection.h:181
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
top::EventSelection::m_cutflowPUWeights
TH1D * m_cutflowPUWeights
Cutflow counting PileUp weights instead of events.
Definition: EventSelection.h:176
top::EventSelection::m_name
std::string m_name
Name of this selection (you can have multiple selections run in the same job.
Definition: EventSelection.h:195
top::EventSelection::m_cutflowScaleFactors_Loose
TH1D * m_cutflowScaleFactors_Loose
Definition: EventSelection.h:185