ATLAS Offline Software
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 
7 #include "MSVtxValidationAlg.h"
8 #include "Utils.h"
9 
10 
11 using namespace MSVtxValidationAlgUtils;
12 
13 
15  ATH_MSG_DEBUG ("Initializing " << name() << "...");
16 
17  ATH_CHECK(m_evtKey.initialize());
18  ATH_CHECK(m_TruthParticleKey.initialize(m_isMC));
19  ATH_CHECK(m_TruthVertexKey.initialize(m_isMC && m_dumpTruthVertices));
20  ATH_CHECK(m_TrackParticleKey.initialize(m_computeVertexIso));
21  ATH_CHECK(m_JetKey.initialize(m_fillJets || m_computeVertexIso || m_computeActiveVertices));
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 
123 StatusCode 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
125  if(m_dumpTruthVertices) ATH_CHECK(fillTruthVertex(ctx));
126 
127  return StatusCode::SUCCESS;
128 }
129 
130 
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;
140  if (m_dumpTruthParticles) {
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 
170 StatusCode 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
236  if (m_dumpTruthParticles) {
237  for (int link : *m_truthParticle_llpVtx_link_tmp) m_truthParticle_llpVtx_link.push_back(link);
238  m_truthParticle_llpVtx_link_tmp->clear();
239  }
240 
241 
242  return StatusCode::SUCCESS;
243 }
244 
245 
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
282  if (m_dumpTruthParticles) {
283  for (int link : *m_truthParticle_truthVtx_link_tmp) m_truthParticle_truthVtx_link.push_back(link);
284  m_truthParticle_truthVtx_link_tmp->clear();
285  }
286 
287  return StatusCode::SUCCESS;
288 }
289 
290 
291 StatusCode MSVtxValidationAlg::fillJet(const EventContext& ctx) {
292  const xAOD::JetContainer* jets{nullptr};
293  ATH_CHECK(SG::get(jets, m_JetKey, ctx));
294 
295  TriggerInfo triggerInfo;
296  if (m_readTriggers) triggerInfo = getTriggerDecisions(m_triggerStringJets);
297 
298  m_jet_N = jets->size();
299  for (const xAOD::Jet* jet : *jets) {
300  m_jet->push_back(jet);
301  if (m_readTriggers) m_jet_triggers.push_back(getTriggerMatchingDecision(jet, triggerInfo, m_jetTriggerMatchingDR));
302  if (m_computeActiveVertices && m_isMC) ATH_CHECK(fillActiveVertices(ctx, jet));
303  }
304 
305  // copy linking data from temp vector and clear the temp vector for the next event
306  if (m_dumpTruthParticles) {
307  for (int link : *m_truthParticle_actVtx_link_tmp) m_truthParticle_actVtx_link.push_back(link);
308  m_truthParticle_actVtx_link_tmp->clear();
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 
330 template <typename T>
331 bool 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 
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 
390 StatusCode MSVtxValidationAlg::fillMet(const EventContext& ctx) {
391  const xAOD::MissingETContainer* MET{nullptr};
392  ATH_CHECK(SG::get(MET, m_MetKey, ctx));
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 
404 StatusCode 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 
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 
443 StatusCode 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 
500 void 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 
511  VtxIso iso = getIso(msVtx, *tracks, *jets, m_trackIso_pT, m_softTrackIso_R, m_jetIso_pT, m_jetIso_LogRatio);
512  m_msVtx_isoTracks_mindR.push_back(iso.track_mindR);
513  m_msVtx_isoTracks_pTsum.push_back(iso.track_pTsum);
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));
535  ATH_CHECK(fillTracklets(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 }
MSVtxValidationAlg::fillActiveVertices
StatusCode fillActiveVertices(const EventContext &ctx, const xAOD::Jet *jet)
Definition: MSVtxValidationAlg.cxx:346
MSVtxValidationAlg::TriggerInfo::names
std::vector< std::string > names
Definition: MSVtxValidationAlg.h:83
MSVtxValidationAlg::TriggerInfo
Definition: MSVtxValidationAlg.h:81
xAOD::muon
@ muon
Definition: TrackingPrimitives.h:196
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
defaults::Int
constexpr int Int
Definition: MSVtxValidationAlg.h:45
MSVtxValidationAlgUtils::VtxIso::track_pTsum
double track_pTsum
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.h:61
runLayerRecalibration.chain
chain
Definition: runLayerRecalibration.py:175
MSVtxValidationAlg::fillTruthParticle
StatusCode fillTruthParticle(const EventContext &ctx)
Definition: MSVtxValidationAlg.cxx:131
MSVtxValidationAlg::fillTruth
StatusCode fillTruth(const EventContext &ctx)
Definition: MSVtxValidationAlg.cxx:123
MSVtxValidationAlg::getTriggerMatchingDecision
bool getTriggerMatchingDecision(const T *object, TriggerInfo &triggerInfo, float dRmatching)
Definition: MSVtxValidationAlg.cxx:331
SG::Accessor
Helper class to provide type-safe access to aux data.
Definition: Control/AthContainers/AthContainers/Accessor.h:68
MSVtxValidationAlg::finalize
virtual StatusCode finalize() override final
Definition: MSVtxValidationAlg.cxx:544
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
MSVtxValidationAlgUtils::VtxIso::track_mindR
double track_mindR
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.h:60
MSVtxValidationAlgUtils::getCTau
double getCTau(const xAOD::TruthVertex *decVtx)
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.cxx:10
defineDB.jets
jets
Definition: JetTagCalibration/share/defineDB.py:24
ParticleTest.tp
tp
Definition: ParticleTest.py:25
MSVtxValidationAlg::fillMSVtx
StatusCode fillMSVtx(const EventContext &ctx)
Definition: MSVtxValidationAlg.cxx:443
defaults::Float
constexpr float Float
Definition: MSVtxValidationAlg.h:46
MuonVal::VectorBranch< int >
ChainGroup.h
MSVtxValidationAlgUtils::VtxIso
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.h:59
keylayer_zslicemap.fillHits
fillHits
Definition: keylayer_zslicemap.py:124
xAOD::Muon_v1
Class describing a Muon.
Definition: Muon_v1.h:38
MSVtxValidationAlg::fillJet
StatusCode fillJet(const EventContext &ctx)
Definition: MSVtxValidationAlg.cxx:291
xAOD::TruthVertex_v1::v4
FourVec_t v4() const
The full 4-vector of the vertex.
Definition: TruthVertex_v1.cxx:185
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
lumiFormat.i
int i
Definition: lumiFormat.py:85
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition: ReadCondHandle.h:283
MSVtxValidationAlg::execute
virtual StatusCode execute() override final
Definition: MSVtxValidationAlg.cxx:520
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MSVtxValidationAlg::initialize
virtual StatusCode initialize() override final
Definition: MSVtxValidationAlg.cxx:14
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
xAOD::TruthParticle_v1
Class describing a truth particle in the MC record.
Definition: TruthParticle_v1.h:37
Utils.h
MSVtxValidationAlg::fillMuons
StatusCode fillMuons(const EventContext &ctx)
Definition: MSVtxValidationAlg.cxx:404
MSVtxValidationAlgUtils::comparePt
bool comparePt(const xAOD::TruthParticle *part1, const xAOD::TruthParticle *part2)
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.cxx:33
xAOD::TruthVertex_v1::perp
float perp() const
Vertex transverse distance from the beam line.
Definition: TruthVertex_v1.cxx:164
MSVtxValidationAlg::fillMSVtxIsolation
StatusCode fillMSVtxIsolation(const xAOD::Vertex *msVtx, const xAOD::TrackParticleContainer *tracks, const xAOD::JetContainer *jets)
Definition: MSVtxValidationAlg.cxx:509
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
MSVtxValidationAlg::fillTruthVertex
StatusCode fillTruthVertex(const EventContext &ctx)
Definition: MSVtxValidationAlg.cxx:246
SG::AuxElement::index
size_t index() const
Return the index of this element within its container.
DataVector
Derived DataVector<T>.
Definition: DataVector.h:795
Trig::ChainGroup
Definition: ChainGroup.h:51
xAOD::TruthVertex_v1
Class describing a truth vertex in the MC record.
Definition: TruthVertex_v1.h:37
xAOD::MissingETContainer_v1
Container for xAOD::MissingET_v1 objects.
Definition: MissingETContainer_v1.h:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
MET
Definition: MET.py:1
MSVtxValidationAlgUtils::VtxIso::jet_mindR
double jet_mindR
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.h:62
MSVtxValidationAlg.h
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MSVtxValidationAlg::TriggerInfo::passed
std::vector< bool > passed
Definition: MSVtxValidationAlg.h:84
xAOD::EventInfo_v1
Class describing the basic event information.
Definition: EventInfo_v1.h:43
MSVtxValidationAlgUtils::getActiveVertices
std::vector< ActiveVertex > getActiveVertices(const xAOD::Jet *jet, const xAOD::TruthParticleContainer &truthParticles)
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.cxx:107
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
RTTAlgmain.branch
branch
Definition: RTTAlgmain.py:61
MSVtxValidationAlg::getTriggerDecisions
TriggerInfo getTriggerDecisions(std::string triggerString)
Definition: MSVtxValidationAlg.cxx:315
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
MSVtxValidationAlgUtils::getStableChildren
std::vector< const xAOD::TruthParticle * > getStableChildren(const xAOD::TruthParticle *particle, bool findOnlyGenStable)
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.cxx:83
MSVtxValidationAlgUtils::getIso
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)
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.cxx:153
xAOD::TruthVertex_v1::z
float z() const
Vertex longitudinal distance along the beam line form the origin.
MSVtxValidationAlg::fillHits
void fillHits(const xAOD::Vertex *vtx, const std::string &decorator_str, MuonVal::VectorBranch< int > &branch)
Definition: MSVtxValidationAlg.cxx:500
MSVtxValidationAlgUtils::ActiveVertex
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.h:44
SG::ConstAccessor< T, AuxAllocator_t< T > >::isAvailable
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
MSVtxValidationAlgUtils
Definition: MuonSpectrometer/MuonValidation/MuonVertexValidation/src/Utils.cxx:8
xAOD::TrackParticle_v1
Class describing a TrackParticle.
Definition: TrackParticle_v1.h:44
xAOD::TruthParticle_v1::p4
virtual FourMom_t p4() const override final
The full 4-momentum of the particle.
Definition: TruthParticle_v1.cxx:191
MSVtxValidationAlg::fillLLP
StatusCode fillLLP(std::vector< const xAOD::TruthParticle * > &llps)
Definition: MSVtxValidationAlg.cxx:170
MSVtxValidationAlg::fillTracklets
StatusCode fillTracklets(const EventContext &ctx)
Definition: MSVtxValidationAlg.cxx:414
MSVtxValidationAlg::fillMet
StatusCode fillMet(const EventContext &ctx)
Definition: MSVtxValidationAlg.cxx:390