ATLAS Offline Software
TrigMatchSelector.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3  */
4 
6 #include "TopEvent/Event.h"
8 
9 #include <sstream>
10 #include <iostream>
11 
12 namespace top {
13  TrigMatchSelector::TrigMatchSelector(const std::string& selectorName, std::shared_ptr<top::TopConfig> config) {
14  m_allTriggers_Tight = config->allTriggers_Tight(selectorName);
15  m_allTriggers_Loose = config->allTriggers_Loose(selectorName);
16  }
17 
19  // different treatment depending if it's a loose or tight top::Event
20  bool loose = event.m_isLoose;
21 
22  // if no trigger menu us associated to this selection, return true
23  // no effect of TRIGMATCH if TRIGDEC wasn't used
24  if (!loose) {
25  if (m_allTriggers_Tight.size() == 0) return true;
26  } else {
27  if (m_allTriggers_Loose.size() == 0) return true;
28  }
29 
30  bool trigMatch(false);
31 
32 
33 
34  // Loop over triggers; loose ones for loose events, tight ones for tight events
35  for (const auto& trigger : loose ? m_allTriggers_Loose : m_allTriggers_Tight) {
36  int nObjects(0);
37  // Loop over electrons
38  for (const auto* const elPtr : event.m_electrons) {
39  std::string trig = "TRIGMATCH_" + trigger.first;
40  if (elPtr->isAvailable<char>(trig)) {
41  if (elPtr->auxdataConst<char>(trig) == 1) {
42  nObjects++;
43  }
44  } // decoration isAvailable
45  } // Loop over electron
46 
47  // Loop over muons
48  for (const auto* const muPtr : event.m_muons) {
49  std::string trig = "TRIGMATCH_" + trigger.first;
50  if (muPtr->isAvailable<char>(trig)) {
51  if (muPtr->auxdataConst<char>(trig) == 1) {
52  nObjects++;
53  }
54  } // decoration isAvailable
55  } // Loop over muons
56 
57  // Loop over taus
58  for (const auto* const tauPtr : event.m_tauJets) {
59  std::string trig = "TRIGMATCH_" + trigger.first;
60  if (tauPtr->isAvailable<char>(trig)) {
61  if (tauPtr->auxdataConst<char>(trig) == 1) {
62  nObjects++;
63  }
64  } // decoration isAvailable
65  } // Loop over taus
66 
67  // Loop over photons
68  for (const auto* const photonPtr : event.m_photons) {
69  std::string trig = "TRIGMATCH_" + trigger.first;
70  if (photonPtr->isAvailable<char>(trig)) {
71  if (photonPtr->auxdataConst<char>(trig) == 1) {
72  nObjects++;
73  }
74  } // decoration isAvailable
75  } // Loop over photons
76  if (nObjects >= trigger.second) trigMatch = true;
77  } // Loop over triggers
78 
79  return trigMatch;
80  }
81 
82  std::string TrigMatchSelector::name() const {
83  std::string name = "TRIGMATCH";
84  return name;
85  }
86 }
top
TopConfig A simple configuration that is NOT a singleton.
Definition: AnalysisTrackingHelper.cxx:58
TrigMatchSelector.h
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
top::TrigMatchSelector::m_allTriggers_Loose
std::vector< std::pair< std::string, int > > m_allTriggers_Loose
Definition: TrigMatchSelector.h:30
top::TrigMatchSelector::m_allTriggers_Tight
std::vector< std::pair< std::string, int > > m_allTriggers_Tight
List of triggers to 'or' together for each event. If any one passes, the event passes.
Definition: TrigMatchSelector.h:29
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
Event.h
top::TrigMatchSelector::apply
virtual bool apply(const top::Event &event) const override
This does stuff based on the information in an event.
Definition: TrigMatchSelector.cxx:18
top::TrigMatchSelector::name
std::string name() const override
A human readable name.
Definition: TrigMatchSelector.cxx:82
top::TrigMatchSelector::TrigMatchSelector
TrigMatchSelector(const std::string &selectorName, std::shared_ptr< top::TopConfig > config)
Definition: TrigMatchSelector.cxx:13
TopConfig.h
top::Event
Very simple class to hold event data after reading from a file.
Definition: Event.h:49
PhysDESDM_Quirks.trigger
trigger
Definition: PhysDESDM_Quirks.py:27