ATLAS Offline Software
Loading...
Searching...
No Matches
MET.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// This source file implements all of the functions related to MET
6// in the SUSYObjDef_xAOD class
7
8// Local include(s):
10
16
17#ifndef XAOD_STANDALONE // For now metadata is Athena-only
19#endif
20
21namespace ST {
22
25 const xAOD::ElectronContainer* elec,
27 const xAOD::PhotonContainer* gamma,
28 const xAOD::TauJetContainer* taujet,
29 bool doTST, bool doJVTCut,
30 const xAOD::IParticleContainer* invis) {
31 if (!m_tool_init) {
32 ATH_MSG_ERROR("SUSYTools was not initialized!!");
33 return StatusCode::FAILURE;
34 }
35
36 const xAOD::MissingETContainer* metcore(nullptr);
37 if ( evtStore()->retrieve( metcore, m_inputMETCore ).isFailure() ) {
38 ATH_MSG_WARNING( "Unable to retrieve MET core container: " << m_inputMETCore );
39 return StatusCode::FAILURE;
40 }
41 const xAOD::MissingETAssociationMap* metMap(nullptr);
42 if ( evtStore()->retrieve(metMap, m_inputMETMap).isFailure() ) {
43 ATH_MSG_WARNING("Unable to retrieve MissingETAssociationMap: " << m_inputMETMap);
44 return StatusCode::FAILURE;
45 }
46 // Helper keeps track of object selection flags for this map
47 xAOD::MissingETAssociationHelper metHelper(&(*metMap));
48
49 std::string softTerm = "SoftClus";
50 if (doTST) {
51 softTerm = "PVSoftTrk";
52 } else if (doJVTCut) {
53 ATH_MSG_WARNING( "Requested CST MET and a JVT cut. This is not a recommended configuration - please consider switching to TST." );
54 }
55
56 metHelper.resetObjSelectionFlags();
57
58 // allow creation of proxy MET by flagging objects for "neutrino/ification" as already selected
59 if (invis) {
60 ATH_CHECK( m_metMaker->markInvisible(invis, metHelper, &met) );
61 }
62
63 if (elec) {
64 ATH_MSG_VERBOSE("Build electron MET");
66 for (const xAOD::Electron* el : *elec) {
67 // pass baseline selection
68 if (acc_baseline(*el)) {
69 bool veto(false);
70 if (invis) {
71 for (const xAOD::IParticle* ipart : *invis) {
72 if (ipart == el) {veto = true; break;}
73 }
74 }
75 if (!veto) metelectron.push_back(el);
76 }
77 }
78 ATH_CHECK( m_metMaker->rebuildMET(m_eleTerm, xAOD::Type::Electron, &met, metelectron.asDataVector(), metHelper) );
79 }
80
81 if (gamma) {
82 ATH_MSG_VERBOSE("Build photon MET");
84 for (const xAOD::Photon* ph : *gamma) {
85 // pass baseline selection
86 if (acc_baseline(*ph)) {
87 bool veto(false);
88 if (invis) {
89 for (const xAOD::IParticle* ipart : *invis) {
90 if (ipart == ph) {veto = true; break;}
91 }
92 }
93 if (!veto) metgamma.push_back(ph);
94 }
95 }
96 ATH_CHECK( m_metMaker->rebuildMET(m_gammaTerm, xAOD::Type::Photon, &met, metgamma.asDataVector(), metHelper) );
97 }
98
99 if (taujet) {
100 ATH_MSG_VERBOSE("Build tau MET");
102 for (const xAOD::TauJet* tau : *taujet) {
103 // pass baseline selection
104 if (acc_baseline(*tau)) {
105 bool veto(false);
106 if (invis) {
107 for (const xAOD::IParticle* ipart : *invis) {
108 if (ipart == tau) {veto = true; break;}
109 }
110 }
111 if (!veto) mettau.push_back(tau);
112 }
113 }
114 ATH_CHECK( m_metMaker->rebuildMET(m_tauTerm, xAOD::Type::Tau, &met, mettau.asDataVector(), metHelper) );
115 }
116
117 if (muon) {
118 ATH_MSG_VERBOSE("Build muon MET");
120 for (const xAOD::Muon* mu : *muon) {
121 bool veto(false);
122 // pass baseline selection
123 if (acc_baseline(*mu)) {
124 if (invis) {
125 for (const xAOD::IParticle* ipart : *invis) {
126 if (ipart == mu) {veto = true; break;}
127 }
128 }
129 if (!veto) metmuon.push_back(mu);
130 }
131 }
132 ATH_CHECK( m_metMaker->rebuildMET(m_muonTerm, xAOD::Type::Muon, &met, metmuon.asDataVector(), metHelper) );
133 }
134
135 if (!jet) {
136 ATH_MSG_WARNING("Invalid jet container specified for MET rebuilding!");
137 return StatusCode::SUCCESS;
138 }
139
140 ATH_MSG_VERBOSE("Build jet/soft MET");
141 ATH_CHECK( m_metMaker->rebuildJetMET(m_jetTerm, softTerm, &met, jet, metcore, metHelper, doJVTCut) );
142
143 if (!isData()) {
144 m_metSystTool->setRandomSeed(static_cast<int>(1e6*met[softTerm]->phi()));
145 ATH_MSG_VERBOSE("Original soft term " << met[softTerm]->name() << " (met: " << met[softTerm]->met() << ")" );
146 if ( m_metSystTool->applyCorrection(*met[softTerm], metHelper) != CP::CorrectionCode::Ok ) {
147 ATH_MSG_WARNING("GetMET: Failed to apply MET soft term systematics.");
148 }
149 ATH_MSG_VERBOSE("New soft term value: " << met[softTerm]->met() );
150 }
151
152 ATH_MSG_VERBOSE("Build MET sum");
153 ATH_CHECK( met::buildMETSum(m_outMETTerm, &met, met[softTerm]->source()) );
154 ATH_MSG_VERBOSE( "Rebuilt MET: Missing Et (x,y): (" << met[m_outMETTerm]->mpx() << "," << met[m_outMETTerm]->mpy() << ")");
155 ATH_MSG_VERBOSE( "Done rebuilding MET." );
156
157 return StatusCode::SUCCESS;
158}
159
160
162 const xAOD::JetContainer* jet,
163 const xAOD::ElectronContainer* elec,
164 const xAOD::MuonContainer* muon) {
165 if (!m_tool_init) {
166 ATH_MSG_ERROR("SUSYTools was not initialized!!");
167 return StatusCode::FAILURE;
168 }
169
170 const xAOD::MissingETContainer* metcore(nullptr);
171 if ( evtStore()->retrieve( metcore, m_inputMETCore ).isFailure() ) {
172 ATH_MSG_WARNING( "Unable to retrieve MET core container: " << m_inputMETCore );
173 return StatusCode::FAILURE;
174 }
175 const xAOD::MissingETAssociationMap* metMap(nullptr);
176 if ( evtStore()->retrieve(metMap, m_inputMETMap).isFailure() ) {
177 ATH_MSG_WARNING("Unable to retrieve MissingETAssociationMap: " << m_inputMETMap);
178 return StatusCode::FAILURE;
179 }
180 // Helper keeps track of object selection flags for this map
181 xAOD::MissingETAssociationHelper metHelper(&(*metMap));
182
183 metHelper.resetObjSelectionFlags();
184
185 if (elec) {
186 ATH_MSG_VERBOSE("Build electron MET");
188 for (const xAOD::Electron* el : *elec) {
189 // pass baseline selection
190 if (acc_baseline(*el)) metelectron.push_back(el);
191 }
192 ATH_CHECK( m_metMaker->rebuildMET(m_eleTerm, xAOD::Type::Electron, &met, metelectron.asDataVector(), metHelper) );
193 }
194
195 if (muon) {
196 ATH_MSG_VERBOSE("Build muon MET");
198 for (const xAOD::Muon* mu : *muon) {
199 // pass baseline selection
200 if (acc_baseline(*mu)) metmuon.push_back(mu);
201 }
202 ATH_CHECK( m_metMaker->rebuildMET(m_muonTerm, xAOD::Type::Muon, &met, metmuon.asDataVector(), metHelper) );
203 }
204
205 if (!jet) {
206 ATH_MSG_WARNING("Invalid jet container specified for MET rebuilding!");
207 return StatusCode::SUCCESS;
208 }
209 ATH_MSG_VERBOSE("Build jet/soft MET_Track");
210
211 std::string softTerm = "PVSoftTrk";
212 ATH_CHECK( m_metMaker->rebuildTrackMET(m_jetTerm, softTerm, &met, jet, metcore, metHelper, true) );
213
214 if (!isData()) {
215 m_metSystTool->setRandomSeed(static_cast<int>(1e6*met[softTerm]->phi()));
216
217 if (m_trkMETsyst) {
218 ATH_MSG_VERBOSE("Apply trkMET systematics");
219 if ( m_metSystTool->applyCorrection(*met[softTerm],metHelper) != CP::CorrectionCode::Ok )
220 ATH_MSG_WARNING("GetMET: Failed to apply MET track (PVSoftTrk) systematics.");
221 }
222
223 if (m_trkJetsyst) {
224 ATH_MSG_VERBOSE("Apply Ref Jet trkMET systematics");
225 if ( m_metSystTool->applyCorrection(*met[m_jetTerm],metHelper) != CP::CorrectionCode::Ok )
226 ATH_MSG_WARNING("GetMET: Failed to apply MET track (RefJet) systematics.");
227 }
228
229 }
230
231 ATH_MSG_VERBOSE("Build MET sum");
232 ATH_CHECK( met::buildMETSum("Track", &met, met[softTerm]->source()) );
233 ATH_MSG_VERBOSE( "Done rebuilding MET." );
234
235 ATH_MSG_VERBOSE( "Track MET: Missing Et (x,y): (" << met["Track"]->mpx() << "," << met["Track"]->mpy() << ")");
236
237 return StatusCode::SUCCESS;
238}
239
241 double &metSignificance,
242 bool doTST, bool doJVTCut) {
243
244 std::string softTerm = "SoftClus";
245 if (doTST) {
246 softTerm = "PVSoftTrk";
247 } else if (doJVTCut) {
248 ATH_MSG_WARNING( "Requested CST MET and a JVT cut. This is not a recommended configuration - please consider switching to TST." );
249 }
250
251 const xAOD::EventInfo* evtInfo = nullptr;
252 ATH_CHECK( evtStore()->retrieve( evtInfo, "EventInfo" ) );
253 ATH_CHECK( m_metSignif->varianceMET( &met, evtInfo->averageInteractionsPerCrossing(), m_jetTerm, softTerm, m_outMETTerm) );
254 metSignificance = m_metSignif->GetSignificance();
255 ATH_MSG_VERBOSE( "Obtained MET Significance: " << metSignificance );
256
257 return StatusCode::SUCCESS;
258}
259
260}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
ServiceHandle< StoreGateSvc > & evtStore()
@ Ok
The correction was done successfully.
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
bool isData() const override final
asg::AnaToolHandle< IMETSignificance > m_metSignif
asg::AnaToolHandle< IMETMaker > m_metMaker
StatusCode GetTrackMET(xAOD::MissingETContainer &met, const xAOD::JetContainer *jet, const xAOD::ElectronContainer *elec=nullptr, const xAOD::MuonContainer *muon=nullptr) override final
Definition MET.cxx:161
asg::AnaToolHandle< IMETSystematicsTool > m_metSystTool
StatusCode GetMET(xAOD::MissingETContainer &met, const xAOD::JetContainer *jet, const xAOD::ElectronContainer *elec=nullptr, const xAOD::MuonContainer *muon=nullptr, const xAOD::PhotonContainer *gamma=nullptr, const xAOD::TauJetContainer *taujet=nullptr, bool doTST=true, bool doJVTCut=true, const xAOD::IParticleContainer *invis=nullptr) override final
Definition MET.cxx:23
StatusCode GetMETSig(xAOD::MissingETContainer &met, double &metSignificance, bool doTST=true, bool doJVTCut=true) override final
Definition MET.cxx:240
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
Class providing the definition of the 4-vector interface.
std::vector< std::string > veto
these patterns are anded
Definition listroot.cxx:191
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
static const SG::ConstAccessor< char > acc_baseline("baseline")
StatusCode buildMETSum(const std::string &totalName, xAOD::MissingETContainer *metCont)
@ Photon
The object is a photon.
Definition ObjectType.h:47
@ Muon
The object is a muon.
Definition ObjectType.h:48
@ Electron
The object is an electron.
Definition ObjectType.h:46
@ Tau
The object is a tau (jet)
Definition ObjectType.h:49
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
TauJet_v3 TauJet
Definition of the current "tau version".
Muon_v1 Muon
Reference the current persistent version:
Photon_v1 Photon
Definition of the current "egamma version".
JetContainer_v1 JetContainer
Definition of the current "jet container version".
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
MissingETAssociationMap_v1 MissingETAssociationMap
Version control by type defintion.
Electron_v1 Electron
Definition of the current "egamma version".
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.