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