ATLAS Offline Software
TrigL1FexJetMonitorTool.cxx
Go to the documentation of this file.
1 // -*- C++ -*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
10 
11 #include "./JTMContainers.h"
12 #include "./L1MonitorAdaptors.h"
13 #include "./DataStructs.h"
14 #include <memory>
15 
17 
18 template<typename T>
20  const std::string& name,
21  const IInterface* parent)
22  : AthAlgTool( type, name, parent )
23 {
24  declareProperty("l1container", m_l1jetContainerkey);
25 
26 }
27 
28 
29 template<typename T>
31 TrigL1FexJetMonitorTool<T>::queryInterface( const InterfaceID& riid, void** ppvIf )
32 {
33  if ( riid == ITrigJetMonitorTool::interfaceID() ) {
34  *ppvIf = (ITrigJetMonitorTool*)this;
35  addRef();
36  return StatusCode::SUCCESS;
37  }
38 
39  return AthAlgTool::queryInterface( riid, ppvIf );
40 }
41 
42 
43 
44 template<typename T>
46 {
47  ATH_CHECK(m_l1jetContainerkey.initialize());
48 
49  if (m_doMatching) {
50  m_offmatchedKey =
51  m_l1jetContainerkey.key() + ".matched_" + m_offlineJetContainerToMatch;
52 
53  m_offptdiffKey =
54  m_l1jetContainerkey.key() + ".ptdiff_" + m_offlineJetContainerToMatch;
55 
56  m_offenergydiffKey =
57  m_l1jetContainerkey.key() + ".energydiff_" + m_offlineJetContainerToMatch;
58 
59  m_offmassdiffKey =
60  m_l1jetContainerkey.key() + ".massdiff_" + m_offlineJetContainerToMatch;
61 
62  m_offptrespKey =
63  m_l1jetContainerkey.key() + ".ptresp_" + m_offlineJetContainerToMatch;
64 
65  m_offenergyrespKey =
66  m_l1jetContainerkey.key() + ".energyresp_" + m_offlineJetContainerToMatch;
67 
68  m_offmassrespKey =
69  m_l1jetContainerkey.key() + ".massresp_" + m_offlineJetContainerToMatch;
70 
71  m_offptrefKey =
72  m_l1jetContainerkey.key() + ".ptRef_" + m_offlineJetContainerToMatch;
73 
74  m_offetarefKey =
75  m_l1jetContainerkey.key() + ".etaRef_" + m_offlineJetContainerToMatch;
76 
77  ATH_CHECK(m_offmatchedKey.initialize() );
78  ATH_CHECK(m_offptdiffKey.initialize() );
79  ATH_CHECK(m_offenergydiffKey.initialize() );
80  ATH_CHECK(m_offmassdiffKey.initialize() );
81  ATH_CHECK(m_offptrespKey.initialize() );
82  ATH_CHECK(m_offenergyrespKey.initialize() );
83  ATH_CHECK(m_offmassrespKey.initialize() );
84  ATH_CHECK(m_offptrefKey.initialize() );
85  ATH_CHECK(m_offetarefKey.initialize() );
86 
87  m_hltmatchedKey =
88  m_l1jetContainerkey.key() + ".matched_" + m_HLTJetContainerToMatch;
89 
90  m_hltptdiffKey =
91  m_l1jetContainerkey.key() + ".ptdiff_" + m_HLTJetContainerToMatch;
92 
93  m_hltenergydiffKey =
94  m_l1jetContainerkey.key() + ".energydiff_" + m_HLTJetContainerToMatch;
95 
96  m_hltmassdiffKey =
97  m_l1jetContainerkey.key() + ".massdiff_" + m_HLTJetContainerToMatch;
98 
99  m_hltptrespKey =
100  m_l1jetContainerkey.key() + ".ptresp_" + m_HLTJetContainerToMatch;
101 
102  m_hltenergyrespKey =
103  m_l1jetContainerkey.key() + ".energyresp_" + m_HLTJetContainerToMatch;
104 
105  m_hltmassrespKey =
106  m_l1jetContainerkey.key() + ".massresp_" + m_HLTJetContainerToMatch;
107 
108  m_hltptrefKey =
109  m_l1jetContainerkey.key() + ".ptRef_" + m_HLTJetContainerToMatch;
110 
111  m_hltetarefKey =
112  m_l1jetContainerkey.key() + ".etaRef_" + m_HLTJetContainerToMatch;
113 
114  ATH_CHECK(m_hltmatchedKey.initialize());
115  ATH_CHECK(m_hltptdiffKey.initialize());
116  ATH_CHECK(m_hltenergydiffKey.initialize());
117  ATH_CHECK(m_hltmassdiffKey.initialize());
118  ATH_CHECK(m_hltptrespKey.initialize());
119  ATH_CHECK(m_hltenergyrespKey.initialize());
120  ATH_CHECK(m_hltmassrespKey.initialize());
121  ATH_CHECK(m_hltptrefKey.initialize());
122  ATH_CHECK(m_hltetarefKey.initialize());
123 
124  } else {
125  // declare the keys unused if no matching is configured
126 
127  // offline container matching
128  ATH_CHECK(m_offmatchedKey.initialize(false));
129  ATH_CHECK(m_offptdiffKey.initialize(false));
130  ATH_CHECK(m_offenergydiffKey.initialize(false));
131  ATH_CHECK(m_offmassdiffKey.initialize(false));
132  ATH_CHECK(m_offptrespKey.initialize(false));
133  ATH_CHECK(m_offenergyrespKey.initialize(false));
134  ATH_CHECK(m_offmassrespKey.initialize(false));
135  ATH_CHECK(m_offptrefKey.initialize(false));
136  ATH_CHECK(m_offetarefKey.initialize(false));
137 
138  // trigger container matching
139  ATH_CHECK(m_hltmatchedKey.initialize(false));
140  ATH_CHECK(m_hltptdiffKey.initialize(false));
141  ATH_CHECK(m_hltenergydiffKey.initialize(false));
142  ATH_CHECK(m_hltmassdiffKey.initialize(false));
143  ATH_CHECK(m_hltptrespKey.initialize(false));
144  ATH_CHECK(m_hltenergyrespKey.initialize(false));
145  ATH_CHECK(m_hltmassrespKey.initialize(false));
146  ATH_CHECK(m_hltptrefKey.initialize(false));
147  ATH_CHECK(m_hltetarefKey.initialize(false));
148  }
149 
150  return StatusCode::SUCCESS;
151 }
152 
153 
154 
155 template<typename T>
157 TrigL1FexJetMonitorTool<T>::getData(const EventContext& ctx,
158  std::vector<JetData>& jetData
159  ) const{
160 
161 
162  // Retrieve the L1 jet container
163  SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx);
164  if( !jets.isValid() ){
165  // the L1 containers should _always_ be present, although may be empty.
166  ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name "
167  << m_l1jetContainerkey);
168  return StatusCode::SUCCESS;
169  }
170 
171  // find variables associated with jets in the input container.
172  for(const auto jet : *jets){
173  /*
174  Ensure that the the et is above a hardware threshold:
175  From Sergi Rodriguez 23/02/2022
176  in the bitwise simulation we also have an energy threshold,
177  which is taken from the trigger menu.
178  If the Et is below the threshold the TOB word is set to 0
179  */
180 
181  if (vetoJet(jet)) {continue;} // see L1MonitoredAdaptors
182 
183  jetData.emplace_back(et(jet)*0.001, // see L1MonitoredAdaptors
184  jet->eta(),
185  jet->phi(),
186  et_label(jet));
187 
188  }
189  return StatusCode::SUCCESS;
190 }
191 
192 
193 
194 template<typename T>
197  MatchToEnum matchTo,
198  std::vector<JetMatchData>& jetMatchData
199  ) const {
200  if (!m_doMatching) {
201  // otherwise will attempt to use uniniatialied Keys
202  return StatusCode::SUCCESS;
203  }
204 
205  std::unique_ptr<SG::ReadDecorHandle<JetContainer, char>> matchedHandle;
206  std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptdiffHandle;
207  std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> energydiffHandle;
208  std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> massdiffHandle;
209  std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptrespHandle;
210  std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> energyrespHandle;
211  std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> massrespHandle;
212  std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> ptrefHandle;
213  std::unique_ptr<SG::ReadDecorHandle<JetContainer, double>> etarefHandle;
214 
215  if (matchTo == MatchToEnum::hlt) {
216 
217  matchedHandle.reset(new SG::ReadDecorHandle<JetContainer, char> (m_hltmatchedKey, ctx));
218  ptdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptdiffKey, ctx));
219  energydiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltenergydiffKey, ctx));
220  massdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltmassdiffKey, ctx));
221  ptrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptrespKey, ctx));
222  energyrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltenergyrespKey, ctx));
223  massrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltmassrespKey, ctx));
224  ptrefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltptrefKey, ctx));
225  etarefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_hltetarefKey, ctx));
226  } else if (matchTo == MatchToEnum::offline) {
227  matchedHandle.reset(new SG::ReadDecorHandle<JetContainer, char> (m_offmatchedKey, ctx));
228  ptdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptdiffKey, ctx));
229  energydiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offenergydiffKey, ctx));
230  massdiffHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offmassdiffKey, ctx));
231  ptrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptrespKey, ctx));
232  energyrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offenergyrespKey, ctx));
233  massrespHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offmassrespKey, ctx));
234  ptrefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offptrefKey, ctx));
235  etarefHandle.reset(new SG::ReadDecorHandle<JetContainer, double> (m_offetarefKey, ctx));
236  } else {
237  ATH_MSG_ERROR ("unsupported MatchTo value");
238  return StatusCode::FAILURE;
239  }
240 
241  ATH_CHECK((*matchedHandle).initialize());
242  ATH_CHECK((*ptdiffHandle).initialize());
243  ATH_CHECK((*energydiffHandle).initialize());
244  ATH_CHECK((*massdiffHandle).initialize());
245  ATH_CHECK((*ptrespHandle).initialize());
246  ATH_CHECK((*energyrespHandle).initialize());
247  ATH_CHECK((*massrespHandle).initialize());
248  ATH_CHECK((*ptrefHandle).initialize());
249  ATH_CHECK((*etarefHandle).initialize());
250 
251 
252  // Loop over L1 jets and fill pt, energy, mass differences and responses
253  // between matched jets, plus reference pT and eta
254 
255  // Retrieve the L1 jet container
256  SG::ReadHandle<JetContainer> jets(m_l1jetContainerkey, ctx);
257  if(!jets.isValid()){
258  // the L1 containers should _always_ be present, although may be empty.
259  ATH_MSG_WARNING("evtStore() does not contain the L1 jet collection with name "
260  << m_l1jetContainerkey);
261  return StatusCode::SUCCESS;
262  }
263 
264  for(const auto jet : *jets){
265  bool matched = (*matchedHandle)(*jet);
266 
267  if(matched){
268  jetMatchData.emplace_back((*ptdiffHandle)(*jet),
269  (*energydiffHandle)(*jet),
270  (*massdiffHandle)(*jet),
271  (*ptrespHandle)(*jet),
272  (*energyrespHandle)(*jet),
273  (*massrespHandle)(*jet),
274  (*ptrefHandle)(*jet),
275  (*etarefHandle)(*jet));
276  }
277  }
278 
279  return StatusCode::SUCCESS;
280 }
281 
286 
287 
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
MatchToEnum::offline
@ offline
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
MatchToEnum::hlt
@ hlt
TrigL1FexJetMonitorTool::m_l1jetContainerkey
SG::ReadHandleKey< JetContainer > m_l1jetContainerkey
Definition: TrigL1FexJetMonitorTool.h:52
L1MonitorAdaptors.h
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
JTMContainers.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SG::ReadDecorHandle
Handle class for reading a decoration on an object.
Definition: StoreGate/StoreGate/ReadDecorHandle.h:94
TrigL1FexJetMonitorTool::getMatchData
virtual StatusCode getMatchData(const EventContext &ctx, MatchToEnum, std::vector< JetMatchData > &jetData) const override
Definition: TrigL1FexJetMonitorTool.cxx:196
TrigL1FexJetMonitorTool::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvIf) override
Definition: TrigL1FexJetMonitorTool.cxx:31
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthMonitorAlgorithm.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
et_label
std::string et_label(const xAOD::jFexSRJetRoI *)
Definition: L1MonitorAdaptors.h:20
TrigL1FexJetMonitorTool
Definition: TrigL1FexJetMonitorTool.h:22
TrigL1FexJetMonitorTool::getData
virtual StatusCode getData(const EventContext &ctx, std::vector< JetData > &jetData) const override
Definition: TrigL1FexJetMonitorTool.cxx:157
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
python.ElectronD3PDObject.matched
matched
Definition: ElectronD3PDObject.py:138
TrigL1FexJetMonitorTool::initialize
virtual StatusCode initialize() override
Definition: TrigL1FexJetMonitorTool.cxx:45
ITrigJetMonitorTool
Definition: ITrigJetMonitorTool.h:22
TrigL1FexJetMonitorTool::TrigL1FexJetMonitorTool
TrigL1FexJetMonitorTool(const std::string &, const std::string &, const IInterface *)
Definition: TrigL1FexJetMonitorTool.cxx:19
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrigL1FexJetMonitorTool.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ReadDecorHandle.h
Handle class for reading a decoration on an object.
defineDB.jets
list jets
Definition: JetTagCalibration/share/defineDB.py:24
MatchToEnum
MatchToEnum
Definition: ITrigJetMonitorTool.h:17
DataStructs.h
AthAlgTool
Definition: AthAlgTool.h:26
vetoJet
bool vetoJet(const xAOD::jFexSRJetRoI *j)
Definition: L1MonitorAdaptors.h:14