ATLAS Offline Software
Loading...
Searching...
No Matches
MSVtxValidationAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8#include "Utils.h"
9
10
11using namespace MSVtxValidationAlgUtils;
12
13
15 ATH_MSG_DEBUG ("Initializing " << name() << "...");
16
17 ATH_CHECK(m_evtKey.initialize());
22 ATH_CHECK(m_MetKey.initialize(m_fillMET));
23 ATH_CHECK(m_MuonKey.initialize());
24 ATH_CHECK(m_MuonSegKey.initialize());
25 ATH_CHECK(m_TrackletKey.initialize());
26 ATH_CHECK(m_MSVtxKey.initialize());
27 if (m_readTriggers) {
28 m_trigDec.setTypeAndName("Trig::TrigDecisionTool/TrigDecisionTool");
29 m_matchingTool.setTypeAndName("Trig::R3MatchingTool/R3MatchingTool");
30 ATH_CHECK(m_trigDec.retrieve());
31 ATH_CHECK(m_matchingTool.retrieve());
32 }
33
34 // attach branches to the tree
35 m_tree.addBranch(std::make_unique<MuonVal::EventInfoBranch>(m_tree, 0));
36
37 // truth TrackParticles
38 m_truthParticle = std::make_shared<MuonVal::IParticleFourMomBranch>(m_tree, "truthParticle");
39 m_truthParticle->addVariableGeV<float>(defaults::Float, "m");
40 m_truthParticle->addVariable<int>(defaults::Int, "pdgId");
41 m_truthParticle->addVariable<int>(defaults::Int, "status");
42 m_truthParticle->addVariable<float>(defaults::Float, "pX");
43 m_truthParticle->addVariable<float>(defaults::Float, "pY");
44 m_truthParticle->addVariable<float>(defaults::Float, "pZ");
45 m_tree.addBranch(m_truthParticle);
46
47 // portal
48 m_portal = std::make_shared<MuonVal::IParticleFourMomBranch>(m_tree, "portal");
49 m_portal->addVariableGeV<float>(defaults::Float, "m");
50 m_tree.addBranch(m_portal);
51
52 // LLP
53 m_llp = std::make_shared<MuonVal::IParticleFourMomBranch>(m_tree, "llp");
54 m_llp->addVariableGeV<float>(defaults::Float, "m");
55 m_tree.addBranch(m_llp);
56
57 // muon segments: dumps the entire muon segment container without needing an explicit fill call
58 m_muonSeg = std::make_shared<MuonPRDTest::SegmentVariables>(m_tree, m_MuonSegKey.key(), "muonSeg", msgLevel());
59 m_tree.addBranch(m_muonSeg);
60
61 // muons
62 m_muon = std::make_shared<MuonVal::IParticleFourMomBranch>(m_tree, "muon");
63 m_tree.addBranch(m_muon);
64
65 // jets
66 m_jet = std::make_shared<MuonVal::IParticleFourMomBranch>(m_tree, "jet");
67 m_jet->addVariableGeV<float>(defaults::Float, "m");
68 m_tree.addBranch(m_jet);
69
70 ATH_CHECK(m_tree.init(this));
71
72 // --- //
73 // Book output histograms following the THistSvc recommendation on managing ownership. Register via histSvc()->regHist("/<stream>/histName", rawHistPtr); //
74 // --- //
75
76 // llp pair
77 auto h_LLP1LLP2dR = std::make_unique<TH1F>("h_LLP1LLP2dR","h_LLP1LLP2dR; #Delta R(LLP1, LLP2); Count / bin",50,0,4);
78 m_h_LLP1LLP2dR = h_LLP1LLP2dR.get();
79 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_LLP1LLP2dR", std::move(h_LLP1LLP2dR)));
80
81 auto h_diLLPMass = std::make_unique<TH1F>("h_diLLPMass","h_diLLPMass; m_{LL1, LLP2} [GeV]; Count / bin",50,0,1000);
82 m_h_diLLPMass = h_diLLPMass.get();
83 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_diLLPMass", std::move(h_diLLPMass)));
84
85 // leading LLP
86 auto h_leadLLPLxy = std::make_unique<TH1F>("h_leadLLPLxy","h_leadLLPLxy; lead LLP L_{xy} [mm]; Count / bin",50,0,10000);
87 m_h_leadLLPLxy = h_leadLLPLxy.get();
88 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_leadLLPLxy", std::move(h_leadLLPLxy)));
89
90 auto h_leadLLPLz = std::make_unique<TH1F>("h_leadLLPLz","h_leadLLPLz; lead LLP L_{z} [mm]; Count / bin",50,0,14000);
91 m_h_leadLLPLz = h_leadLLPLz.get();
92 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_leadLLPLz", std::move(h_leadLLPLz)));
93
94 auto h_leadLLPctau = std::make_unique<TH1F>("h_leadLLPctau","h_leadLLPctau; lead LLP c#tau [mm]; Count / bin",50,0,2000);
95 m_h_leadLLPctau = h_leadLLPctau.get();
96 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_leadLLPctau", std::move(h_leadLLPctau)));
97
98 auto h_leadLLPpt = std::make_unique<TH1F>("h_leadLLPpt","h_leadLLPpt; lead LLP p_{T} [GeV]; Count / bin",50,0,400);
99 m_h_leadLLPpt = h_leadLLPpt.get();
100 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_leadLLPpt", std::move(h_leadLLPpt)));
101
102 // subleading LLP
103 auto h_subleadLLPLxy = std::make_unique<TH1F>("h_subleadLLPLxy","h_subleadLLPLxy; sublead LLP L_{xy} [mm]; Count / bin",50,0,10000);
104 m_h_subleadLLPLxy = h_subleadLLPLxy.get();
105 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_subleadLLPLxy", std::move(h_subleadLLPLxy)));
106
107 auto h_subleadLLPLz = std::make_unique<TH1F>("h_subleadLLPLz","h_subleadLLPLz; sublead LLP L_{z} [mm]; Count / bin",50,0,10000);
108 m_h_subleadLLPLz = h_subleadLLPLz.get();
109 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_subleadLLPLz", std::move(h_subleadLLPLz)));
110
111 auto h_subleadLLPctau = std::make_unique<TH1F>("h_subleadLLPctau","h_subleadLLPctau; sublead LLP c#tau [mm]; Count / bin",50,0,2000);
112 m_h_subleadLLPctau = h_subleadLLPctau.get();
113 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_subleadLLPctau", std::move(h_subleadLLPctau)));
114
115 auto h_subleadLLPpt = std::make_unique<TH1F>("h_subleadLLPpt","h_subleadLLPpt; sublead LLP p_{T} [GeV]; Count / bin",50,0,400);
116 m_h_subleadLLPpt = h_subleadLLPpt.get();
117 ATH_CHECK(histSvc()->regHist("/MSVtxValidation/h_subleadLLPpt", std::move(h_subleadLLPpt)));
118
119 return StatusCode::SUCCESS;
120}
121
122
123StatusCode MSVtxValidationAlg::fillTruth(const EventContext& ctx) {
124 ATH_CHECK(fillTruthParticle(ctx)); // need to be run before fillTruthVertex to set up the truth particle - truth vertex linking
126
127 return StatusCode::SUCCESS;
128}
129
130
131StatusCode MSVtxValidationAlg::fillTruthParticle(const EventContext& ctx) {
132 // Fill truth particle branches and histograms
133 const xAOD::TruthParticleContainer* truth_particles{nullptr};
134 ATH_CHECK(SG::get(truth_particles, m_TruthParticleKey, ctx));
135
136 // dump the TruthParticle information and collect portal, LLPs
137 std::vector<const xAOD::TruthParticle*> portals{}, llps{};
138 for(const xAOD::TruthParticle* tp : *truth_particles){
139 if (!tp) continue;
141 m_truthParticle->push_back(tp);
142 // set default link index to -1
143 m_truthParticle_llpVtx_link_tmp->push_back(-1); // adjusted in fillLLP
144 m_truthParticle_actVtx_link_tmp->push_back(-1); // adjusted in fillJet
145 m_truthParticle_truthVtx_link_tmp->push_back(-1); // adjusted in fillTruthVertex
146 }
147
148 // fill vector of portal particles, skipping the particle if it is a self-decay
149 if(std::abs(tp->pdgId()) == m_pdgId_portal){
150 bool selfdecay = false;
151 for (size_t p = 0; p < tp->production_vertex()->nIncomingParticles(); ++p) if (tp->parent(p)->pdgId() == tp->pdgId()) { selfdecay = true; break;}
152 if (!selfdecay) portals.push_back(tp);
153 }
154
155 // fill vector of LLPs
156 if(std::abs(tp->pdgId()) == m_pdgId_llp) llps.push_back(tp);
157 }
158
159 // portal
160 m_portal_N = portals.size();
161 for(const xAOD::TruthParticle* portal : portals) m_portal->push_back(portal);
162
163 // LLP and LLP Children
164 ATH_CHECK(fillLLP(llps));
165
166 return StatusCode::SUCCESS;
167}
168
169
170StatusCode MSVtxValidationAlg::fillLLP(std::vector<const xAOD::TruthParticle*>& llps) {
171
172 // LLP and LLP children
173 m_llp_N = llps.size();
174 std::sort(llps.begin(), llps.end(), comparePt); // sort llps by pT
175 const xAOD::TruthParticle* leadLLP = nullptr;
176 const xAOD::TruthParticle* subleadLLP = nullptr;
177
178 int num_vtx = 0;
179 for(unsigned int llp_idx=0; const xAOD::TruthParticle* llp : llps){
180 m_llp->push_back(llp);
181
182 if(llp->hasDecayVtx()){
183 const xAOD::TruthVertex* decVtx = llp->decayVtx();
184 m_llpVtx_pos.push_back(decVtx->v4().Vect());
185 m_llpVtx_Lxy.push_back(decVtx->perp());
186 m_llpVtx_ctau.push_back(getCTau(decVtx));
187 ++num_vtx;
188 }
189
190 // leading LLP
191 if(llp_idx==0){
192 if(llp->hasDecayVtx()){
193 const xAOD::TruthVertex* decVtx = llp->decayVtx();
194 m_h_leadLLPLxy->Fill(decVtx->perp());
195 m_h_leadLLPLz->Fill(decVtx->z());
196 m_h_leadLLPctau->Fill(getCTau(decVtx));
197 }
198 m_h_leadLLPpt->Fill(llp->pt()/Gaudi::Units::GeV);
199 leadLLP = llp;
200 }
201 // subleading llp
202 if(llp_idx==1){
203 if(llp->hasDecayVtx()){
204 const xAOD::TruthVertex* decVtx = llp->decayVtx();
205 m_h_subleadLLPLxy->Fill(decVtx->perp());
206 m_h_subleadLLPLz->Fill(decVtx->z());
207 m_h_subleadLLPctau->Fill(getCTau(decVtx));
208 }
209 m_h_subleadLLPpt->Fill(llp->pt()/Gaudi::Units::GeV);
210 subleadLLP = llp;
211
212 // di-llp histograms
213 TLorentzVector llpSum = subleadLLP->p4()+leadLLP->p4();
214 m_h_LLP1LLP2dR->Fill(leadLLP->p4().DeltaR(subleadLLP->p4()));
215 m_h_diLLPMass->Fill(llpSum.E()/Gaudi::Units::GeV);
216 }
217
218 // LLP children
219 if (llp->hasDecayVtx() && llp->nChildren()>0 && !llp->isGenStable()) {
220 std::vector<const xAOD::TruthParticle*> stableChildren = getStableChildren(llp, m_llp_genStableChildren);
221 m_llp_Nchildren.push_back((int)stableChildren.size());
222 int nChargedChildren = 0;
223 for (const xAOD::TruthParticle *child : stableChildren){
224 if (child->charge() != 0) ++nChargedChildren;
225 if (!m_dumpTruthParticles) continue;
226 m_llpVtx_truthParticle_link.push_back(llp_idx, child->index());
227 m_truthParticle_llpVtx_link_tmp->at(child->index()) = llp_idx;
228 }
229 m_llp_NchildrenCharged.push_back(nChargedChildren);
230 }
231 ++llp_idx;
232 }
233 m_llpVtx_N = num_vtx;
234
235 // copy linking data from temp vector and clear the temp vector for the next event
237 for (int link : *m_truthParticle_llpVtx_link_tmp) m_truthParticle_llpVtx_link.push_back(link);
239 }
240
241
242 return StatusCode::SUCCESS;
243}
244
245
246StatusCode MSVtxValidationAlg::fillTruthVertex(const EventContext& ctx) {
247 const xAOD::TruthVertexContainer* truth_vertices{nullptr};
248 ATH_CHECK(SG::get(truth_vertices, m_TruthVertexKey, ctx));
249
250 int truthVtxIdx = 0;
251 for (const xAOD::TruthVertex* vtx : *truth_vertices){
252 if (!vtx) continue;
253 m_truthVtx_pos.push_back(vtx->v4().Vect());
254 m_truthVtx_status.push_back(vtx->status());
255
256 // set the interaction type based on the status code
257 int interactionType = -1;
258 if (m_hadronicProcessEnum.count(vtx->status() - 1000)) interactionType = 0;
259 else if (m_emProcessEnum.count(vtx->status() - 1000)) interactionType = 1;
260 m_truthVtx_interactionType.push_back(interactionType);
261
262 // children
263 m_truthVtx_NchildrenDirect.push_back(vtx->nOutgoingParticles());
264 int nChildren = 0;
265 int nChildrenCharged = 0;
266 for(const xAOD::TruthParticle* child : vtx->particles_out()){
267 std::vector<const xAOD::TruthParticle*> stableChildren = getStableChildren(child, false);
268 nChildren += stableChildren.size();
269 for (const xAOD::TruthParticle *stableChild : stableChildren){
270 if (stableChild->charge() != 0) ++nChildrenCharged;
271 if (!m_dumpTruthParticles) continue;
272 m_truthVtx_truthParticle_link.push_back(truthVtxIdx, stableChild->index());
273 m_truthParticle_truthVtx_link_tmp->at(stableChild->index()) = truthVtxIdx;
274 }
275 }
276 m_truthVtx_Nchildren.push_back(nChildren);
277 m_truthVtx_NchildrenCharged.push_back(nChildrenCharged);
278 truthVtxIdx++;
279 }
280
281 // copy linking data from temp vector and clear the temp vector for the next event
285 }
286
287 return StatusCode::SUCCESS;
288}
289
290
291StatusCode MSVtxValidationAlg::fillJet(const EventContext& ctx) {
292 const xAOD::JetContainer* jets{nullptr};
293 ATH_CHECK(SG::get(jets, m_JetKey, ctx));
294
295 TriggerInfo triggerInfo;
297
298 m_jet_N = jets->size();
299 for (const xAOD::Jet* jet : *jets) {
300 m_jet->push_back(jet);
303 }
304
305 // copy linking data from temp vector and clear the temp vector for the next event
307 for (int link : *m_truthParticle_actVtx_link_tmp) m_truthParticle_actVtx_link.push_back(link);
309 }
310
311 return StatusCode::SUCCESS;
312}
313
314
316 // for the configured trigger chain, store the trigger decision for this event
317 const Trig::ChainGroup* chain = m_trigDec->getChainGroup(triggerString);
318 std::vector<std::string> triggerNames = chain->getListOfTriggers();
319
320 std::vector<bool> triggerPassed;
321 for (const std::string& triggerName : triggerNames) {
322 if (m_trigDec->isPassed(triggerName)) triggerPassed.push_back(true);
323 else triggerPassed.push_back(false);
324 }
325
326 return {triggerString, triggerNames, triggerPassed};
327}
328
329
330template <typename T>
331bool MSVtxValidationAlg::getTriggerMatchingDecision(const T* object, TriggerInfo& triggerInfo, float dRmatching) {
332
333 bool firedTrigger = false;
334 for (size_t i = 0; i < triggerInfo.passed.size(); ++i) {
335 if (!triggerInfo.passed[i]) continue; // skip if trigger not passed
336 if (m_matchingTool->match(*object, triggerInfo.names[i], dRmatching, false)) {
337 firedTrigger = true;
338 break; // this object has fired one for the triggers in the chain so do not need to check the other triggers
339 }
340 }
341
342 return firedTrigger;
343}
344
345
346StatusCode MSVtxValidationAlg::fillActiveVertices(const EventContext& ctx, const xAOD::Jet* jet) {
347 const xAOD::TruthParticleContainer* truth_particles{nullptr};
348 ATH_CHECK(SG::get(truth_particles, m_TruthParticleKey, ctx));
349
350 std::vector<ActiveVertex> actVertices = getActiveVertices(jet, *truth_particles);
351
352 if (!actVertices.size()){
353 m_jet_actVtx_link.push_back({}); // empty links for this jet as no active vertex was identified
354 return StatusCode::SUCCESS;
355 }
356
357 for (ActiveVertex actVtx : actVertices) {
358 if (!actVtx.vtx) continue;
359 // index of active vertex found in the event. Not just a simple counter since each jet can have several active vertices
360 size_t actVtxIdx = m_actVtx_NChildren.size();
361 // fill the active vertex branches
362 m_actVtx_pos.push_back(actVtx.vtx->v4().Vect());
363 m_actVtx_NChildren.push_back(actVtx.nChildren);
364 m_actVtx_chainDepth.push_back(actVtx.decayDepth);
365 m_actVtx_energy.push_back(actVtx.vtxEnergy/Gaudi::Units::GeV);
366 m_actVtx_mass.push_back(actVtx.vtxMass/Gaudi::Units::GeV);
367 m_actVtx_pT.push_back(actVtx.vtxPt/Gaudi::Units::GeV);
368 m_actVtx_scalarPtSum.push_back(actVtx.vtxScalarPtSum/Gaudi::Units::GeV);
369
370 m_actVtx_jet_link.push_back(jet->index()); // link the active vertex to the jet
371 m_actVtx_jet_dEta.push_back(jet->eta() - actVtx.vtx->v4().Eta());
372 m_actVtx_jet_dPhi.push_back(jet->p4().DeltaPhi(actVtx.vtx->v4()));
373
374 m_jet_actVtx_link.push_back(jet->index(), actVtxIdx); // link the jet to the active vertex
375
376 // note that a truth particle can be linked to multiple active vertices, so the link index is not unique
377 if (!m_dumpTruthParticles) continue;
378 for (auto tpLink : actVtx.vtx->outgoingParticleLinks()) {
379 if (!tpLink) continue;
380 m_actVtx_truthParticle_link.push_back(actVtxIdx, tpLink.index());
381 m_truthParticle_actVtx_link_tmp->at(tpLink.index()) = actVtxIdx;
382 }
383 }
384 m_jet_NactVtx.push_back(actVertices.size()); // number of active vertices associated to this jet
385
386 return StatusCode::SUCCESS;
387}
388
389
390StatusCode MSVtxValidationAlg::fillMet(const EventContext& ctx) {
391 const xAOD::MissingETContainer* MET{nullptr};
393
394 m_met = (*MET)["Final"]->met()/Gaudi::Units::GeV;
395 m_met_x = (*MET)["Final"]->mpx()/Gaudi::Units::GeV;
396 m_met_y = (*MET)["Final"]->mpy()/Gaudi::Units::GeV;
397 m_met_phi = (*MET)["Final"]->phi();
398 m_sumEt = (*MET)["Final"]->sumet()/Gaudi::Units::GeV;
399
400 return StatusCode::SUCCESS;
401}
402
403
404StatusCode MSVtxValidationAlg::fillMuons(const EventContext& ctx) {
405 const xAOD::MuonContainer* muons{nullptr};
406 ATH_CHECK(SG::get(muons, m_MuonKey, ctx));
407
408 for (const xAOD::Muon* muon : *muons) m_muon->push_back(muon);
409
410 return StatusCode::SUCCESS;
411}
412
413
414StatusCode MSVtxValidationAlg::fillTracklets(const EventContext& ctx) {
415
416 const xAOD::TrackParticleContainer* msOnlyTracklets{nullptr};
417 ATH_CHECK(SG::get(msOnlyTracklets, m_TrackletKey, ctx));
418
419 m_trklet_N = msOnlyTracklets->size();
420 for(const xAOD::TrackParticle* mstrklet : *msOnlyTracklets){
421 // perigee parameters
422 m_trklet_d0.push_back(mstrklet->d0());
423 m_trklet_z0.push_back(mstrklet->z0());
424 m_trklet_phi.push_back(mstrklet->phi());
425 m_trklet_theta.push_back(mstrklet->theta());
426 m_trklet_eta.push_back(mstrklet->eta());
427 m_trklet_qOverP.push_back(mstrklet->qOverP());
428 m_trklet_q.push_back(mstrklet->charge());
429 // cartesian parameters
430 const Trk::Perigee &tkl_perigee = mstrklet->perigeeParameters();
431 const Amg::Vector3D &trklet_pos = tkl_perigee.position();
432 const Amg::Vector3D &trklet_mom = tkl_perigee.momentum()/Gaudi::Units::GeV;
433 m_trklet_pos.push_back(trklet_pos);
434 m_trklet_mom.push_back(trklet_mom);
435 // set default link index to vertex to -1 and adjust when in fillMSVtx
436 m_trklet_vtxLink.push_back(-1);
437 }
438
439 return StatusCode::SUCCESS;
440}
441
442
443StatusCode MSVtxValidationAlg::fillMSVtx(const EventContext& ctx) {
444 const xAOD::VertexContainer* msVertices{nullptr};
445 ATH_CHECK(SG::get(msVertices, m_MSVtxKey, ctx));
446
447 const xAOD::TrackParticleContainer* tracks{nullptr};
448 const xAOD::JetContainer* jets{nullptr};
449 if (m_computeVertexIso) {
450 ATH_CHECK(SG::get(tracks, m_TrackParticleKey, ctx));
451 ATH_CHECK(SG::get(jets, m_JetKey, ctx));
452 }
453
454 m_msVtx_N = msVertices->size();
455 for(const xAOD::Vertex* msVtx : *msVertices){
456 m_msVtx_pos.push_back(msVtx->position());
457 m_msVtx_chi2.push_back(msVtx->chiSquared());
458 m_msVtx_nDoF.push_back(msVtx->numberDoF());
459
460 // hits close to vertex: total, inwards of the vertex, inner layer, extended layer, middle layer, outer layer
461 fillHits(msVtx, "nMDT", m_msVtx_nMDT);
462 fillHits(msVtx, "nMDT_inwards", m_msVtx_nMDT_inwards);
463 fillHits(msVtx, "nMDT_I", m_msVtx_nMDT_I);
464 fillHits(msVtx, "nMDT_E", m_msVtx_nMDT_E);
465 fillHits(msVtx, "nMDT_M", m_msVtx_nMDT_M);
466 fillHits(msVtx, "nMDT_O", m_msVtx_nMDT_O);
467
468 fillHits(msVtx, "nRPC", m_msVtx_nRPC);
469 fillHits(msVtx, "nRPC_inwards", m_msVtx_nRPC_inwards);
470 fillHits(msVtx, "nRPC_I", m_msVtx_nRPC_I);
471 fillHits(msVtx, "nRPC_E", m_msVtx_nRPC_E);
472 fillHits(msVtx, "nRPC_M", m_msVtx_nRPC_M);
473 fillHits(msVtx, "nRPC_O", m_msVtx_nRPC_O);
474
475 fillHits(msVtx, "nTGC", m_msVtx_nTGC);
476 fillHits(msVtx, "nTGC_inwards", m_msVtx_nTGC_inwards);
477 fillHits(msVtx, "nTGC_I", m_msVtx_nTGC_I);
478 fillHits(msVtx, "nTGC_E", m_msVtx_nTGC_E);
479 fillHits(msVtx, "nTGC_M", m_msVtx_nTGC_M);
480 fillHits(msVtx, "nTGC_O", m_msVtx_nTGC_O);
481
482 // set a linking index for each tracklet used in the reconstruction of the vertex
483 size_t nTrk = msVtx->nTrackParticles();
484 m_msVtx_Ntrklet.push_back(nTrk);
485
486 for(size_t j=0; j<nTrk; ++j){
487 const xAOD::TrackParticle *consti = msVtx->trackParticle(j);
488 if (!consti) continue;
489 m_trklet_vtxLink[consti->index()] = msVtx->index();
490 }
491
492 // optionally compute the vertex isolation from tracks and jets
493 if (m_computeVertexIso) ATH_CHECK(fillMSVtxIsolation(msVtx, tracks, jets));
494 }
495
496 return StatusCode::SUCCESS;
497}
498
499
500void MSVtxValidationAlg::fillHits(const xAOD::Vertex* vtx, const std::string& decorator_str, MuonVal::VectorBranch<int>& branch) {
501 // fills branch with the number of hits close to the vertex. When the decorator is not available, the default integer value is used
502 const SG::AuxElement::Accessor<int> hits_acc(decorator_str);
503 if (hits_acc.isAvailable(*vtx)) branch.push_back(hits_acc(*vtx));
504
505 return;
506}
507
508
510
514 m_msVtx_isoJets_mindR.push_back(iso.jet_mindR);
515
516 return StatusCode::SUCCESS;
517}
518
519
521 ATH_MSG_DEBUG ("Executing " << name() << "...");
522
523 const EventContext& ctx = Gaudi::Hive::currentContext();
524
525 // event variables
526 const xAOD::EventInfo* eventInfo{nullptr};
527 ATH_CHECK(SG::get(eventInfo, m_evtKey, ctx));
528
529 ATH_MSG_DEBUG("Start to run over event "<<eventInfo->eventNumber()<<" in run" <<eventInfo->runNumber());
530
531 if(m_isMC) ATH_CHECK(fillTruth(ctx));
532 if(m_fillJets) ATH_CHECK(fillJet(ctx));
533 if(m_fillMET) ATH_CHECK(fillMet(ctx));
534 ATH_CHECK(fillMuons(ctx));
536 ATH_CHECK(fillMSVtx(ctx));
537
538 ATH_CHECK(m_tree.fill(ctx));
539
540 return StatusCode::SUCCESS;
541}
542
543
545 ATH_MSG_DEBUG ("Finalizing " << name() << "...");
546 ATH_CHECK(m_tree.write());
547
548 return StatusCode::SUCCESS;
549}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
size_type size() const noexcept
Returns the number of elements in the collection.
MuonVal::VectorBranch< int > & m_msVtx_nTGC_M
Gaudi::Property< bool > m_fillMET
MuonVal::VectorBranch< int > & m_trklet_vtxLink
MuonVal::VectorBranch< float > & m_trklet_qOverP
Gaudi::Property< bool > m_dumpTruthVertices
MuonVal::VectorBranch< float > & m_trklet_theta
Gaudi::Property< bool > m_fillJets
MuonVal::ScalarBranch< float > & m_met
MuonVal::MatrixBranch< int > & m_llpVtx_truthParticle_link
MuonVal::ThreeVectorBranch m_llpVtx_pos
MuonVal::MatrixBranch< int > & m_jet_actVtx_link
MuonVal::VectorBranch< float > & m_msVtx_chi2
std::shared_ptr< MuonPRDTest::SegmentVariables > m_muonSeg
MuonVal::VectorBranch< float > & m_llpVtx_Lxy
MuonVal::VectorBranch< int > & m_jet_triggers
StatusCode fillActiveVertices(const EventContext &ctx, const xAOD::Jet *jet)
SG::ReadHandleKey< xAOD::VertexContainer > m_MSVtxKey
MuonVal::VectorBranch< float > & m_msVtx_isoTracks_pTsum
SG::ReadHandleKey< xAOD::TruthParticleContainer > m_TruthParticleKey
MuonVal::VectorBranch< float > & m_trklet_z0
MuonVal::VectorBranch< int > & m_msVtx_nTGC_I
MuonVal::ThreeVectorBranch m_actVtx_pos
MuonVal::VectorBranch< float > & m_msVtx_isoTracks_mindR
Gaudi::Property< float > m_jetIso_pT
MuonVal::ThreeVectorBranch m_trklet_pos
std::unique_ptr< std::vector< int > > m_truthParticle_actVtx_link_tmp
MuonVal::VectorBranch< int > & m_msVtx_nMDT_I
bool getTriggerMatchingDecision(const T *object, TriggerInfo &triggerInfo, float dRmatching)
MuonVal::ScalarBranch< int > & m_msVtx_N
MuonVal::MatrixBranch< int > & m_truthVtx_truthParticle_link
std::unique_ptr< std::vector< int > > m_truthParticle_llpVtx_link_tmp
virtual StatusCode initialize() override final
SG::ReadHandleKey< xAOD::MuonContainer > m_MuonKey
Gaudi::Property< bool > m_dumpTruthParticles
MuonVal::VectorBranch< int > & m_msVtx_nRPC_E
ParticleBranchPtr_t m_portal
StatusCode fillTruthVertex(const EventContext &ctx)
MuonVal::VectorBranch< float > & m_actVtx_pT
StatusCode fillMSVtx(const EventContext &ctx)
SG::ReadHandleKey< xAOD::EventInfo > m_evtKey
MuonVal::ScalarBranch< float > & m_met_x
Gaudi::Property< float > m_jetTriggerMatchingDR
MuonVal::VectorBranch< int > & m_msVtx_nRPC_inwards
MuonVal::VectorBranch< int > & m_msVtx_nTGC_O
Gaudi::Property< bool > m_computeActiveVertices
ParticleBranchPtr_t m_truthParticle
MuonVal::VectorBranch< int > & m_msVtx_nMDT_inwards
Gaudi::Property< float > m_jetIso_LogRatio
Gaudi::Property< int > m_pdgId_portal
PublicToolHandle< Trig::R3MatchingTool > m_matchingTool
MuonVal::VectorBranch< int > & m_truthParticle_llpVtx_link
MuonVal::VectorBranch< float > & m_actVtx_energy
MuonVal::VectorBranch< int > & m_llp_NchildrenCharged
MuonVal::MuonTesterTree m_tree
MuonVal::ScalarBranch< int > & m_trklet_N
virtual StatusCode finalize() override final
Gaudi::Property< bool > m_llp_genStableChildren
SG::ReadHandleKey< xAOD::JetContainer > m_JetKey
MuonVal::VectorBranch< float > & m_actVtx_jet_dEta
std::unordered_set< int > m_emProcessEnum
MuonVal::VectorBranch< int > & m_truthParticle_truthVtx_link
MuonVal::ThreeVectorBranch m_msVtx_pos
virtual StatusCode execute() override final
StatusCode fillMSVtxIsolation(const xAOD::Vertex *msVtx, const xAOD::TrackParticleContainer *tracks, const xAOD::JetContainer *jets)
MuonVal::VectorBranch< int > & m_msVtx_nMDT_M
MuonVal::VectorBranch< int > & m_msVtx_nMDT
MuonVal::VectorBranch< int > & m_msVtx_nDoF
std::unordered_set< int > m_hadronicProcessEnum
MuonVal::ScalarBranch< int > & m_jet_N
MuonVal::VectorBranch< int > & m_msVtx_nRPC_I
MuonVal::ScalarBranch< float > & m_sumEt
MuonVal::VectorBranch< int > & m_msVtx_Ntrklet
StatusCode fillMet(const EventContext &ctx)
MuonVal::VectorBranch< int > & m_msVtx_nRPC_O
MuonVal::VectorBranch< int > & m_truthVtx_status
MuonVal::VectorBranch< float > & m_msVtx_isoJets_mindR
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrackletKey
TriggerInfo getTriggerDecisions(std::string triggerString)
StatusCode fillMuons(const EventContext &ctx)
StatusCode fillTruth(const EventContext &ctx)
MuonVal::VectorBranch< int > & m_msVtx_nRPC
SG::ReadHandleKey< xAOD::TruthVertexContainer > m_TruthVertexKey
MuonVal::VectorBranch< int > & m_truthVtx_NchildrenCharged
MuonVal::ScalarBranch< float > & m_met_phi
MuonVal::ScalarBranch< int > & m_llp_N
Gaudi::Property< bool > m_computeVertexIso
Gaudi::Property< float > m_softTrackIso_R
ParticleBranchPtr_t m_muon
MuonVal::VectorBranch< int > & m_truthParticle_actVtx_link
StatusCode fillLLP(std::vector< const xAOD::TruthParticle * > &llps)
SG::ReadHandleKey< xAOD::MissingETContainer > m_MetKey
MuonVal::VectorBranch< int > & m_msVtx_nMDT_E
MuonVal::VectorBranch< int > & m_msVtx_nTGC_inwards
MuonVal::ThreeVectorBranch m_trklet_mom
MuonVal::MatrixBranch< int > & m_actVtx_truthParticle_link
MuonVal::VectorBranch< float > & m_trklet_phi
Gaudi::Property< float > m_trackIso_pT
MuonVal::VectorBranch< float > & m_trklet_q
MuonVal::VectorBranch< float > & m_llpVtx_ctau
MuonVal::VectorBranch< int > & m_jet_NactVtx
MuonVal::ScalarBranch< int > & m_llpVtx_N
MuonVal::ScalarBranch< int > & m_portal_N
MuonVal::ThreeVectorBranch m_truthVtx_pos
MuonVal::ScalarBranch< float > & m_met_y
StatusCode fillJet(const EventContext &ctx)
ParticleBranchPtr_t m_llp
MuonVal::VectorBranch< float > & m_actVtx_mass
MuonVal::VectorBranch< float > & m_actVtx_jet_dPhi
MuonVal::VectorBranch< int > & m_msVtx_nTGC_E
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_MuonSegKey
MuonVal::VectorBranch< int > & m_actVtx_chainDepth
PublicToolHandle< Trig::TrigDecisionTool > m_trigDec
Gaudi::Property< int > m_pdgId_llp
void fillHits(const xAOD::Vertex *vtx, const std::string &decorator_str, MuonVal::VectorBranch< int > &branch)
Gaudi::Property< bool > m_isMC
Gaudi::Property< std::string > m_triggerStringJets
StatusCode fillTracklets(const EventContext &ctx)
MuonVal::VectorBranch< int > & m_msVtx_nMDT_O
MuonVal::VectorBranch< int > & m_msVtx_nRPC_M
MuonVal::VectorBranch< int > & m_msVtx_nTGC
MuonVal::VectorBranch< int > & m_actVtx_NChildren
Gaudi::Property< bool > m_readTriggers
StatusCode fillTruthParticle(const EventContext &ctx)
MuonVal::VectorBranch< int > & m_truthVtx_Nchildren
MuonVal::VectorBranch< int > & m_truthVtx_NchildrenDirect
std::unique_ptr< std::vector< int > > m_truthParticle_truthVtx_link_tmp
MuonVal::VectorBranch< int > & m_llp_Nchildren
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrackParticleKey
MuonVal::VectorBranch< int > & m_truthVtx_interactionType
MuonVal::VectorBranch< int > & m_actVtx_jet_link
MuonVal::VectorBranch< float > & m_trklet_eta
MuonVal::VectorBranch< float > & m_actVtx_scalarPtSum
ParticleBranchPtr_t m_jet
MuonVal::VectorBranch< float > & m_trklet_d0
void push_back(const T &value)
Adds a new element at the end of the vector.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
size_t index() const
Return the index of this element within its container.
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
float z() const
Vertex longitudinal distance along the beam line form the origin.
FourVec_t v4() const
The full 4-vector of the vertex.
float perp() const
Vertex transverse distance from the beam line.
Eigen::Matrix< double, 3, 1 > Vector3D
Definition MET.py:1
std::vector< const xAOD::TruthParticle * > getStableChildren(const xAOD::TruthParticle *particle, bool findOnlyGenStable)
VtxIso getIso(const xAOD::Vertex *vtx, const xAOD::TrackParticleContainer &Tracks, const xAOD::JetContainer &Jets, double trackIso_pT, double softTrackIso_R, double jetIso_pT, double jetIso_LogRatio)
std::vector< ActiveVertex > getActiveVertices(const xAOD::Jet *jet, const xAOD::TruthParticleContainer &truthParticles)
bool comparePt(const xAOD::TruthParticle *part1, const xAOD::TruthParticle *part2)
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
constexpr int Int
constexpr float Float
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Jet_v1 Jet
Definition of the current "jet version".
EventInfo_v1 EventInfo
Definition of the latest event info version.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthVertexContainer_v1 TruthVertexContainer
Declare the latest version of the truth vertex container.
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
TruthParticle_v1 TruthParticle
Typedef to implementation.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Muon_v1 Muon
Reference the current persistent version:
JetContainer_v1 JetContainer
Definition of the current "jet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".
TruthParticleContainer_v1 TruthParticleContainer
Declare the latest version of the truth particle container.
std::vector< std::string > names