ATLAS Offline Software
MbtsHypoTool.cxx
Go to the documentation of this file.
1 
2 /*
3 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4 */
5 
8 
9 #include "MbtsHypoTool.h"
10 
11 using namespace TrigCompositeUtils;
12 MbtsHypoTool::MbtsHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
14  m_decisionId(HLT::Identifier::fromToolName(name)) {}
15 
17 {
18  if (! m_monTool.empty() ) ATH_CHECK( m_monTool.retrieve() );
19  return StatusCode::SUCCESS;
20 }
21 
23 {
24  ATH_MSG_DEBUG("Executing this T2MbtsHypo " << name());
25 
26  if (info.previousDecisionIDs.count(m_decisionId.numeric()) == 0)
27  {
28  ATH_MSG_DEBUG("Already rejected");
29  return StatusCode::SUCCESS;
30  }
31 
32  // Calculate MBTS counter multiplicities after energy and an optional time cut.
33  Counts counts = calculateMultiplicities(info.mbtsBits);
34  if (counts.sideA == 0 && counts.sideC == 0)
35  {
36  ATH_MSG_DEBUG("calculateMultiplicities failed, no multiplicities");
37  return StatusCode::SUCCESS;
38  }
39  bool pass = m_acceptAll;
40  if (m_coincidence)
41  { // Coincidence logic
42  if (!m_veto)
43  {
44  if (counts.sideA >= m_mbtsCounters && counts.sideC >= m_mbtsCounters)
45  pass = true;
46  }
47  else
48  {
49  if (counts.sideA < m_mbtsCounters && counts.sideC < m_mbtsCounters)
50  pass = true;
51  }
52  }
53  else
54  {
55  if (m_or)
56  { // Or logic
57  if (!m_veto)
58  {
59  if ((counts.sideA >= m_mbtsCounters || counts.sideC >= m_mbtsCounters))
60  pass = true;
61  }
62  else
63  {
64  if ((counts.sideA < m_mbtsCounters || counts.sideC < m_mbtsCounters))
65  pass = true;
66  }
67  }
68  else
69  { // Sum logic
70  if (!m_veto)
71  {
72  if ((counts.sideA + counts.sideC) >= m_mbtsCounters)
73  pass = true;
74  }
75  else
76  {
77  if ((counts.sideA + counts.sideC) < m_mbtsCounters)
78  pass = true;
79  }
80  }
81  }
82 
83  ATH_MSG_DEBUG("REGTEST: event " << (pass ? "accepted" : "failed") << " with EBA(" << counts.sideA << ") + EBC(" << counts.sideC << ") hits above threshold.");
84 
85  if (pass)
86  {
88  ATH_MSG_DEBUG("REGTEST event accepted");
89  }
90  return StatusCode::SUCCESS;
91 }
92 
94 {
95 
96  if (!t2mbtsBits)
97  {
98  return {0, 0};
99  }
100 
101  ATH_MSG_DEBUG("Getting energy and time values.");
102 
103  std::vector<float> triggerEnergies = t2mbtsBits->triggerEnergies();
104  std::vector<float> triggerTimes = t2mbtsBits->triggerTimes();
105 
106  if (triggerEnergies.size() != xAOD::TrigT2MbtsBits::NUM_MBTS || triggerTimes.size() != xAOD::TrigT2MbtsBits::NUM_MBTS)
107  {
108  ATH_MSG_WARNING("Vector sizes are not equal to number of MBTS counters.");
109  return {0, 0};
110  }
111 
112  ATH_MSG_DEBUG("Forming hit multiplicities.");
113 
114  std::bitset<16> ebaTriggerBits;
115  std::bitset<16> ebcTriggerBits;
116 
117 
118  unsigned ibit;
119  int ebaCounters = 0, ebcCounters = 0;
120 
121  // Initialize monitoring variables.
122  double timeDiff_A_C = 0.;
123  double timeMean_A = 0.;
124  double timeMean_C = 0.;
125 
126  // Loop over each counter and form bit sets from time and energy (optional).
127  for (ibit = 0; ibit < xAOD::TrigT2MbtsBits::NUM_MBTS; ibit++)
128  {
129  if (m_mbtsmode == 1 && !(ibit < 8 || (ibit >= 16 && ibit < 24)))
130  continue; // count only inner
131  if (m_mbtsmode == 2 && !((ibit >= 8 && ibit < 16) || (ibit >= 24 && ibit < 32)))
132  continue; // count only outer
133 
134  // Check the energy threshold.
135  if (triggerEnergies[ibit] <= m_threshold)
136  continue;
137 
138  // Calculate the mean time for this side;
139  if (ibit < 16)
140  {
141  timeMean_A += triggerTimes[ibit];
142  ebaCounters++;
143  }
144  else
145  {
146  timeMean_C += triggerTimes[ibit];
147  ebcCounters++;
148  }
149 
150  // Check the time cut if it is active.
151  if (m_timeCut >= 0 && std::abs(triggerTimes[ibit] - m_timeOffsets[ibit] - m_globalTimeOffset) >= m_timeCut)
152  continue;
153 
154  // Set the bits for this side;
155  if (ibit < 16)
156  {
157  ebaTriggerBits.set(ibit);
158  }
159  else
160  {
161  ebcTriggerBits.set(ibit - 16);
162  }
163  }
164 
165  if (ebaCounters > 0)
166  {
167  timeMean_A /= ebaCounters;
168  }
169  else
170  {
171  timeMean_A = -999.0;
172  }
173 
174  if (ebcCounters > 0)
175  {
176  timeMean_C /= ebcCounters;
177  }
178  else
179  {
180  timeMean_C = -999.0;
181  }
182 
183  if (ebaCounters > 0 && ebcCounters > 0)
184  {
185  timeDiff_A_C = timeMean_A - timeMean_C;
186  }
187  else
188  {
189  timeDiff_A_C = -999.0;
190  }
191  ATH_MSG_DEBUG("average MBTS trigger time"
192  << " side A: " << timeMean_A
193  << ", side C: " << timeMean_C
194  << ", difference A-C: " << timeDiff_A_C);
195 
196  ATH_MSG_DEBUG("MBTS EBA trigger bits: " << ebaTriggerBits);
197  ATH_MSG_DEBUG("MBTS EBC trigger bits: " << ebcTriggerBits);
198  if ( ! m_monTool.empty() ) {
199  std::vector<int> counts;
200  counts.reserve(ebaTriggerBits.size() + ebcTriggerBits.size());
201 
202  for ( size_t bit = 0; bit < ebaTriggerBits.size(); ++bit )
203  counts.push_back( ebaTriggerBits[bit] ? bit : -1 );
204  for ( size_t bit = 0; bit < ebcTriggerBits.size(); ++bit )
205  counts.push_back( ebcTriggerBits[bit] ? bit+ebaTriggerBits.size() : -1 );
206  auto mon_counts = Monitored::Collection("Counts", counts);
207  Monitored::Group(m_monTool, mon_counts);
208  }
209  return {ebaTriggerBits.count(), ebcTriggerBits.count()};
210 }
grepfile.info
info
Definition: grepfile.py:38
TrigDefs::Group
Group
Properties of a chain group.
Definition: GroupProperties.h:13
MbtsHypoTool::m_mbtsCounters
Gaudi::Property< unsigned int > m_mbtsCounters
Definition: MbtsHypoTool.h:37
MbtsHypoTool::m_monTool
ToolHandle< GenericMonitoringTool > m_monTool
Definition: MbtsHypoTool.h:55
HLT::Identifier::numeric
TrigCompositeUtils::DecisionID numeric() const
numeric ID
Definition: TrigCompositeUtils/TrigCompositeUtils/HLTIdentifier.h:47
MbtsHypoTool::decide
StatusCode decide(MbtsHypoInfo &decisions) const
Definition: MbtsHypoTool.cxx:22
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
MbtsHypoTool::initialize
virtual StatusCode initialize() override
Definition: MbtsHypoTool.cxx:16
MbtsHypoTool::m_timeOffsets
Gaudi::Property< std::vector< float > > m_timeOffsets
Definition: MbtsHypoTool.h:53
MbtsHypoTool::m_or
Gaudi::Property< bool > m_or
Definition: MbtsHypoTool.h:41
Monitored::Collection
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
Definition: MonitoredCollection.h:38
MbtsHypoTool::m_timeCut
Gaudi::Property< float > m_timeCut
Definition: MbtsHypoTool.h:49
MbtsHypoTool::Counts::sideA
size_t sideA
Definition: MbtsHypoTool.h:58
MbtsHypoTool::Counts::sideC
size_t sideC
Definition: MbtsHypoTool.h:59
HLT
It used to be useful piece of code for replacing actual SG with other store of similar functionality ...
Definition: HLTResultReader.h:26
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TrigT2MbtsBits_v1
Definition: TrigT2MbtsBits_v1.h:14
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MbtsHypoTool::Counts
Definition: MbtsHypoTool.h:57
Monitored.h
Header file to be included by clients of the Monitored infrastructure.
MbtsHypoTool::m_decisionId
HLT::Identifier m_decisionId
Definition: MbtsHypoTool.h:34
xAOD::TrigT2MbtsBits_v1::NUM_MBTS
static const unsigned int NUM_MBTS
Prints out data members to MsgStream.
Definition: TrigT2MbtsBits_v1.h:39
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
MbtsHypoTool::calculateMultiplicities
Counts calculateMultiplicities(const xAOD::TrigT2MbtsBits *t2mbtsBits) const
Definition: MbtsHypoTool.cxx:93
MbtsHypoTool::m_acceptAll
Gaudi::Property< bool > m_acceptAll
Definition: MbtsHypoTool.h:35
MbtsHypoTool::m_veto
Gaudi::Property< bool > m_veto
Definition: MbtsHypoTool.h:43
MbtsHypoTool::MbtsHypoInfo
Definition: MbtsHypoTool.h:24
MbtsHypoTool::m_coincidence
Gaudi::Property< bool > m_coincidence
Definition: MbtsHypoTool.h:39
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
HLTIdentifier.h
MbtsHypoTool::m_globalTimeOffset
Gaudi::Property< float > m_globalTimeOffset
Definition: MbtsHypoTool.h:51
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
MbtsHypoTool::m_threshold
Gaudi::Property< float > m_threshold
Definition: MbtsHypoTool.h:47
AthAlgTool
Definition: AthAlgTool.h:26
MbtsHypoTool::MbtsHypoTool
MbtsHypoTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MbtsHypoTool.cxx:12
xAOD::TrigT2MbtsBits_v1::triggerTimes
const std::vector< float > & triggerTimes() const
Return the relative times of the triggers.
MbtsHypoTool::m_mbtsmode
Gaudi::Property< int > m_mbtsmode
Definition: MbtsHypoTool.h:45
xAOD::TrigT2MbtsBits_v1::triggerEnergies
const std::vector< float > & triggerEnergies() const
Return the trigger energies of each counter.
MbtsHypoTool.h