95 {
96 std::vector<Trk::VxCascadeInfo*> cascadeinfoContainer;
97 constexpr int topoN = 2;
98 std::array<xAOD::VertexContainer*, topoN> Vtxwritehandles;
99 std::array<xAOD::VertexAuxContainer*, topoN> Vtxwritehandlesaux;
101
102 for(
int i =0;
i<topoN;
i++){
105 Vtxwritehandles[
i]->setStore(Vtxwritehandlesaux[i]);
108 }
109
110
111
112
117
118 if (pvContainer->
size()==0){
120 return StatusCode::RECOVERABLE;
121 } else {
122 primaryVertex = (*pvContainer)[0];
123 }
124
125
126
127
132
135 } else {
136
139 refPvContainer->setStore(refPvAuxContainer);
142 }
143 }
144
149 return StatusCode::FAILURE;
150 }
151
154
155
156 SG::AuxElement::Decorator<VertexLinkVector> CascadeLinksDecor("CascadeVertexLinks");
157 SG::AuxElement::Decorator<MuonsLinkVector> MuonsLinksDecor("MuonsLinks");
158 SG::AuxElement::Decorator<VertexLinkVector> DxLinksDecor("DxVertexLinks");
159 SG::AuxElement::Decorator<float> chi2_decor("ChiSquared");
160 SG::AuxElement::Decorator<float> ndof_decor("NumberDoF");
161 SG::AuxElement::Decorator<float> Pt_decor("Pt");
162 SG::AuxElement::Decorator<float> PtErr_decor("PtErr");
163 SG::AuxElement::Decorator<float> Mass_svdecor("Dx_mass");
164 SG::AuxElement::Decorator<float> MassErr_svdecor("Dx_massErr");
165 SG::AuxElement::Decorator<float> Pt_svdecor("Dx_Pt");
166 SG::AuxElement::Decorator<float> PtErr_svdecor("Dx_PtErr");
167 SG::AuxElement::Decorator<float> Lxy_svdecor("Dx_Lxy");
168 SG::AuxElement::Decorator<float> LxyErr_svdecor("Dx_LxyErr");
169 SG::AuxElement::Decorator<float> Tau_svdecor("Dx_Tau");
170 SG::AuxElement::Decorator<float> TauErr_svdecor("Dx_TauErr");
171 SG::AuxElement::Decorator<float> Dx_chi2_svdecor("Dx_chi2");
172 SG::AuxElement::Decorator<float> Dx_ndof_svdecor("Dx_ndof");
173
174
175
176
177
178
179 SG::AuxElement::Decorator<float> massKX1_svdecor("KX_mass");
180 SG::AuxElement::Decorator<float> massKX1X2_svdecor("KXpi_mass");
181 SG::AuxElement::Decorator<float> RapidityKX1X2_svdecor("KXpi_Rapidity");
182
183 SG::AuxElement::Decorator<float> MuMass_decor("Mu_mass");
184 SG::AuxElement::Decorator<float> MuPt_decor("Mu_pt");
185 SG::AuxElement::Decorator<float> MuEta_decor("Mu_eta");
186 SG::AuxElement::Decorator<float> MuChi2_decor("Mu_chi2");
187 SG::AuxElement::Decorator<float> MunDoF_decor("Mu_nDoF");
188
189 SG::AuxElement::Decorator<float> MuChi2B_decor("Mu_chi2_B");
190 SG::AuxElement::Decorator<float> MunDoFB_decor("Mu_nDoF_B");
191
192 SG::AuxElement::Decorator<float> ChargeK_decor("K_charge");
193 SG::AuxElement::Decorator<float> ChargeX1_decor("X_charge");
194 SG::AuxElement::Decorator<float> ChargeX2_decor("Pi_charge");
195 SG::AuxElement::Decorator<float> ChargeMu_decor("Mu_charge");
196
197 ATH_MSG_DEBUG(
"cascadeinfoContainer size " << cascadeinfoContainer.size());
198
199
203
204
207
208 for (Trk::VxCascadeInfo*
x : cascadeinfoContainer) {
211 continue;
212 }
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232 const std::vector<xAOD::Vertex*> &cascadeVertices =
x->vertices();
233
234 if(cascadeVertices.size()!=topoN)
ATH_MSG_ERROR(
"Incorrect number of vertices");
235 if(cascadeVertices[0] ==
nullptr || cascadeVertices[1] ==
nullptr)
ATH_MSG_ERROR(
"Error null vertex");
236
237 for(
int i =0;
i<topoN;
i++) Vtxwritehandles[i]->
push_back(cascadeVertices[i]);
238
239 x->setSVOwnership(
false);
240 const auto mainVertex = cascadeVertices[1];
241
242 const std::vector< std::vector<TLorentzVector> > &moms =
x->getParticleMoms();
243
244
245
246 std::vector<const xAOD::Vertex*> verticestoLink;
247 verticestoLink.push_back(cascadeVertices[0]);
248 if(Vtxwritehandles[1] ==
nullptr)
ATH_MSG_ERROR(
"Vtxwritehandles[1] is null");
251
252
253
254 typedef std::vector<const xAOD::Muon*> MuonBag;
255 MuonBag selectedMuons; selectedMuons.clear();
256
258 const xAOD::TrackParticle* muonTrk =
mu->trackParticle(xAOD::Muon::TrackParticleType::InnerDetectorTrackParticle );
259 if (muonTrk == cascadeVertices[1]->trackParticle(0)) selectedMuons.push_back(mu);
260 }
262
263
264
265
267
268
269 auto muItr = selectedMuons.begin();
270 for(; muItr != selectedMuons.end(); muItr++) {
271
275
276
277 if( !muLink.isValid() ) continue;
278
279
280 preMuLinks.push_back( muLink );
281
282 }
283
284
285 MuonsLinksDecor(*cascadeVertices[1]) = preMuLinks;
286
287
288
289
290
292 ATH_MSG_DEBUG(
"1 pt D_(s)+/Lambda_c+ tracks " << cascadeVertices[1]->trackParticle(0)->
pt()<<
", "
293 << cascadeVertices[0]->trackParticle(0)->
pt()<<
", "<< cascadeVertices[0]->trackParticle(1)->
pt()<<
", "
294 << cascadeVertices[0]->trackParticle(2)->
pt());
297
298 std::vector<const xAOD::Vertex*> dxVerticestoLink;
299 if (dxVertex) dxVerticestoLink.push_back(dxVertex);
302 ATH_MSG_ERROR(
"Error decorating with D_(s)+/Lambda_c+ vertices");
303
304
305 bool tagDp(true);
306 if (dxVertex) {
308 }
309
310
313 std::vector<double> massesMu;
315 std::vector<double> massesDx;
316 if(tagDp){
319 }else{
322 }
324 std::vector<double> Masses;
327
328
329
330
331
332
333 xAOD::BPhysHypoHelper vtx(
m_hypoName, mainVertex);
334
335
337
338
339
340
343
345 PtErr_decor(*mainVertex) =
m_CascadeTools->pTError(moms[1],
x->getCovariance()[1]);
346
347 chi2_decor(*mainVertex) =
x->fitChi2();
348 ndof_decor(*mainVertex) =
x->nDoF();
349 Dx_chi2_svdecor(*mainVertex) = cascadeVertices[0]->chiSquared();
350 Dx_ndof_svdecor(*mainVertex) = cascadeVertices[0]->numberDoF();
351
352
353 float muM = 0., mupt = 0., mueta = 0.;
354 if (selectedMuons.size()==1) {
355 TLorentzVector p4_mu1;
356 p4_mu1.SetPtEtaPhiM(selectedMuons.at(0)->pt(),
357 selectedMuons.at(0)->eta(),
359 muM = p4_mu1.M();
360 mupt = p4_mu1.Pt();
361 mueta = p4_mu1.Eta();
362 }
363 MuMass_decor(*mainVertex) = muM;
364 MuPt_decor(*mainVertex) = mupt;
365 MuEta_decor(*mainVertex) = mueta;
366 ChargeMu_decor(*mainVertex) = selectedMuons.at(0)->charge();
367 MuChi2_decor(*mainVertex) = cascadeVertices[1]->trackParticle(0)->chiSquared();
368 MunDoF_decor(*mainVertex) = cascadeVertices[1]->trackParticle(0)->numberDoF();
369
370
371 std::vector< Trk::VxTrackAtVertex > trkAtB = cascadeVertices[1]->vxTrackAtVertex();
372 MuChi2B_decor(*mainVertex) = trkAtB.at(0).trackQuality().chiSquared();
373 MunDoFB_decor(*mainVertex) = trkAtB.at(0).trackQuality().numberDoF();
374
375
376
377 float massKX1 = 0.;
378 float massKX1X2 = 0.;
379 float RapidityKX1X2 = 0.;
380 if (dxVertex) {
381 TLorentzVector p4_h1, p4_h2, p4_h3;
382 if(tagDp){
391 }else{
396
401 }
406
407 massKX1 = (p4_h1 + p4_h2).M();
408 massKX1X2 = (p4_h1 + p4_h2 + p4_h3).M();
409 RapidityKX1X2 = (p4_h1 + p4_h2 + p4_h3).Rapidity();
410 }
411 massKX1_svdecor(*mainVertex) = massKX1;
412 massKX1X2_svdecor(*mainVertex) = massKX1X2;
413 RapidityKX1X2_svdecor(*mainVertex) = RapidityKX1X2;
414
415
418
419
420
421
422 Mass_svdecor(*mainVertex) =
m_CascadeTools->invariantMass(moms[0]);
423 MassErr_svdecor(*mainVertex) =
m_CascadeTools->invariantMassError(moms[0],
x->getCovariance()[0]);
425 PtErr_svdecor(*mainVertex) =
m_CascadeTools->pTError(moms[0],
x->getCovariance()[0]);
426 Lxy_svdecor(*mainVertex) =
m_CascadeTools->lxy(moms[0],cascadeVertices[0],cascadeVertices[1]);
427 LxyErr_svdecor(*mainVertex) =
m_CascadeTools->lxyError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[1]);
428 Tau_svdecor(*mainVertex) =
m_CascadeTools->tau(moms[0],cascadeVertices[0],cascadeVertices[1]);
429 TauErr_svdecor(*mainVertex) =
m_CascadeTools->tauError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[1]);
430
431
433 <<
" chi2_1 " <<
m_V0Tools->chisq(cascadeVertices[0])
434 <<
" chi2_2 " <<
m_V0Tools->chisq(cascadeVertices[1])
438 <<
" error " <<
m_V0Tools->invariantMassError(cascadeVertices[0],massesDx)
439 <<
" mass_J " <<
m_V0Tools->invariantMass(cascadeVertices[1],massesMu)
440 <<
" error " <<
m_V0Tools->invariantMassError(cascadeVertices[1],massesMu));
441
444 double Mass_B_err =
m_CascadeTools->invariantMassError(moms[1],
x->getCovariance()[1]);
445 double Mass_D_err =
m_CascadeTools->invariantMassError(moms[0],
x->getCovariance()[0]);
447 ATH_MSG_DEBUG(
"Mass_B_err " << Mass_B_err <<
" Mass_D_err " << Mass_D_err);
448 double mprob_B =
m_CascadeTools->massProbability(mass_b,Mass_B,Mass_B_err);
449 double mprob_D =
m_CascadeTools->massProbability(mass_d,Mass_D,Mass_D_err);
450 ATH_MSG_DEBUG(
"mprob_B " << mprob_B <<
" mprob_D " << mprob_D);
451
453 <<
" Mass_d " <<
m_CascadeTools->invariantMass(moms[0],massesDx));
455 <<
" Mass_d_err " <<
m_CascadeTools->invariantMassError(moms[0],
x->getCovariance()[0],massesDx));
458 <<
" pt_dp " <<
m_V0Tools->pT(cascadeVertices[0]));
460 <<
" ptErr_d " <<
m_CascadeTools->pTError(moms[0],
x->getCovariance()[0])
461 <<
" ptErr_dp " <<
m_V0Tools->pTError(cascadeVertices[0]));
465 <<
" lxyErr_d " <<
m_CascadeTools->lxyError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[1])
466 <<
" lxyErr_dp " <<
m_V0Tools->lxyError(cascadeVertices[0],cascadeVertices[1]));
468 <<
" tau_dp " <<
m_V0Tools->tau(cascadeVertices[0],cascadeVertices[1],massesDx));
470 <<
" tau_d " <<
m_CascadeTools->tau(moms[0],cascadeVertices[0],cascadeVertices[1])
471 <<
" tau_D " <<
m_CascadeTools->tau(moms[0],cascadeVertices[0],cascadeVertices[1],mass_d));
473 <<
" tauErr_d " <<
m_CascadeTools->tauError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[1])
474 <<
" tauErr_dp " <<
m_V0Tools->tauError(cascadeVertices[0],cascadeVertices[1],massesDx));
476 <<
" TauErr_d " <<
m_CascadeTools->tauError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[1],mass_d)
477 <<
" TauErr_dp " <<
m_V0Tools->tauError(cascadeVertices[0],cascadeVertices[1],massesDx,mass_d));
478
479 ATH_MSG_DEBUG(
"CascadeTools main vert wrt PV " <<
" CascadeTools SV " <<
" V0Tools SV");
481 <<
", " <<
m_CascadeTools->a0z(moms[0],cascadeVertices[0],cascadeVertices[1])
482 <<
", " <<
m_V0Tools->a0z(cascadeVertices[0],cascadeVertices[1]));
484 <<
", " <<
m_CascadeTools->a0zError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[1])
485 <<
", " <<
m_V0Tools->a0zError(cascadeVertices[0],cascadeVertices[1]));
487 <<
", " <<
m_CascadeTools->a0xy(moms[0],cascadeVertices[0],cascadeVertices[1])
488 <<
", " <<
m_V0Tools->a0xy(cascadeVertices[0],cascadeVertices[1]));
490 <<
", " <<
m_CascadeTools->a0xyError(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[1])
491 <<
", " <<
m_V0Tools->a0xyError(cascadeVertices[0],cascadeVertices[1]));
493 <<
", " <<
m_CascadeTools->a0(moms[0],cascadeVertices[0],cascadeVertices[1])
494 <<
", " <<
m_V0Tools->a0(cascadeVertices[0],cascadeVertices[1]));
496 <<
", " <<
m_CascadeTools->a0Error(moms[0],
x->getCovariance()[0],cascadeVertices[0],cascadeVertices[1])
497 <<
", " <<
m_V0Tools->a0Error(cascadeVertices[0],cascadeVertices[1]));
500 ATH_MSG_DEBUG(
"X0 " << primaryVertex->
x() <<
" Y0 " << primaryVertex->
y() <<
" Z0 " << primaryVertex->
z());
503 ATH_MSG_DEBUG(
"Rxy0 wrt PV " <<
m_V0Tools->rxy(cascadeVertices[0],primaryVertex) <<
" RxyErr0 wrt PV " <<
m_V0Tools->rxyError(cascadeVertices[0],primaryVertex));
504 ATH_MSG_DEBUG(
"Rxy1 wrt PV " <<
m_V0Tools->rxy(cascadeVertices[1],primaryVertex) <<
" RxyErr1 wrt PV " <<
m_V0Tools->rxyError(cascadeVertices[1],primaryVertex));
505 ATH_MSG_DEBUG(
"number of covariance matrices " << (
x->getCovariance()).size());
506
507 }
508
509
510
511 for (
auto x : cascadeinfoContainer)
delete x;
512
513 return StatusCode::SUCCESS;
514 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define BPHYS_CHECK(EXP)
Useful CHECK macro.
xAOD::MuonContainer * muonContainer
size_type size() const noexcept
Returns the number of elements in the collection.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfo_key
StatusCode performSearch(std::vector< Trk::VxCascadeInfo * > *cascadeinfoContainer, const EventContext &ctx) const
bool setElement(ElementType element)
Set link to point to an Element (slowest).
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
float charge() const
Returns the charge.
float z() const
Returns the z position.
const TrackParticle * trackParticle(size_t i) const
Get the pointer to a given track that was used in vertex reco.
float y() const
Returns the y position.
float x() const
Returns the x position.
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
ElementLink< xAOD::MuonContainer > MuonsLink
std::vector< MuonsLink > MuonsLinkVector
VertexAuxContainer_v1 VertexAuxContainer
Definition of the current jet auxiliary container.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
Vertex_v1 Vertex
Define the latest version of the vertex class.
Muon_v1 Muon
Reference the current persistent version:
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".