36 {
"PV_MAX_SUM_PT2",
"PV_MIN_A0",
"PV_MIN_Z0",
"PV_MIN_Z0_BA"};
45 #define GET_PV( name ) \
47 static const SG::AuxElement::Accessor<VertexLink> pvLinkAcc(name); \
48 if(!pvLinkAcc.isAvailable(*m_b)) { \
51 const VertexLink& pvLink = pvLinkAcc(*m_b); \
52 if(!pvLink.isValid()) { \
58 #define SET_PV( name, pv, vertexContainer ) \
60 static const SG::AuxElement::Decorator<VertexLink> pvLinkDecor(name); \
61 VertexLink vertexLink; \
63 vertexLink.setElement(pv); \
64 vertexLink.setStorableObject(*vertexContainer); \
65 if( !vertexLink.isValid() ) \
67 pvLinkDecor(*m_b) = vertexLink; \
71 #define GET_FLOAT(name) \
73 static const SG::AuxElement::Accessor<float> floatAcc(name); \
74 if(!floatAcc.isAvailable(*m_b)) return -9999999.; \
75 return floatAcc(*m_b); \
78 #define SET_FLOAT( name, val) \
80 static const SG::AuxElement::Decorator<float> floatDec(name); \
81 floatDec(*m_b) = val; \
85 #define GET_INT(name) \
87 static const SG::AuxElement::Accessor<int> intAcc(name); \
88 if(!intAcc.isAvailable(*m_b)) return -9999999; \
89 return intAcc(*m_b); \
92 #define SET_INT( name, val) \
94 static const SG::AuxElement::Decorator<int> intDec(name); \
118 if( !cacheRefTracks() )
return -1;
121 return m_cachedRefTracks.size();
129 if( !cacheRefTracks() )
return
133 if(
index>=m_cachedRefTracks.size())
134 return TVector3(0,0,0);
137 return m_cachedRefTracks[
index];
145 if( !cacheRefTracks() )
149 return m_cachedRefTracks;
156 if( !cacheRefTracks() )
return
157 TLorentzVector(0,0,0,0);
160 if(
index>=m_cachedRefTracks.size())
161 return TLorentzVector(0,0,0,0);
179 if(
index>=m_b->nTrackParticles())
183 if(index<m_b->nTrackParticles()) {
184 return m_b->trackParticle(
index);
202 if(
index>=m_b->nTrackParticles())
203 return TVector3(0,0,0);
205 if(index<m_b->nTrackParticles()) {
210 if(!trk)
return TVector3(0,0,0);
214 tmp.SetPtEtaPhi(trk->
pt(), trk->
eta(), trk->
phi());
230 return TVector3(0,0,0);
244 if(
index>=m_b->nTrackParticles())
245 return TLorentzVector(0,0,0,0);
263 if(
index>=m_b->nTrackParticles())
266 if(index<m_b->nTrackParticles()) {
287 std::vector<float>
py,
288 std::vector<float>
pz)
291 if(
px.size()!=
py.size() ||
px.size()!=
pz.size())
295 m_refTracksCached =
false;
296 m_cachedRefTracks.clear();
304 refTrackPxDeco(*m_b) = std::move(
px);
305 refTrackPyDeco(*m_b) = std::move(
py);
306 refTrackPzDeco(*m_b) = std::move(
pz);
319 std::vector<float>
px;
320 std::vector<float>
py;
321 std::vector<float>
pz;
322 px.reserve(refTrks.size());
323 py.reserve(refTrks.size());
324 pz.reserve(refTrks.size());
326 std::vector<TVector3>::const_iterator refTrksItr = refTrks.begin();
327 for(; refTrksItr!=refTrks.end(); ++refTrksItr) {
328 px.push_back( refTrksItr->Px() );
329 py.push_back( refTrksItr->Py() );
330 pz.push_back( refTrksItr->Pz() );
334 return setRefTrks(std::move(
px),std::move(
py),std::move(
pz));
339 #ifndef XAOD_ANALYSIS
344 std::vector<float>
px;
345 std::vector<float>
py;
346 std::vector<float>
pz;
347 const auto N = vtx()->vxTrackAtVertex().size();
365 setRefTrks(std::move(
px), std::move(
py), std::move(
pz));
372 #endif // not XAOD_ANALYSIS
377 if( !cacheRefTracks() && nCascadeVertices()<=0) {
380 return TVector3(0,0,0);
386 for(
int i=0;
i<
n; ++
i) {
391 if(nCascadeVertices()>0) {
392 for(
int i=0;
i<nCascadeVertices(); ++
i) {
395 TVector3 daughterP = daughterVtx.
totalP();
398 if(daughterP==TVector3(0,0,0))
399 return TVector3(0,0,0);
413 if( !cacheRefTracks() )
414 return TLorentzVector(0,0,0,0);
418 return TLorentzVector(0,0,0,0);
422 for(
int i=0;
i<
n; ++
i) {
448 return m_cachedMuons.size();
459 if(
index>=m_cachedMuons.size())
463 return m_cachedMuons[
index];
475 return m_cachedMuons;
483 m_muonsCached =
false;
484 m_cachedMuons.clear();
493 std::vector<const xAOD::Muon*>::const_iterator muonsItr = muons.begin();
494 for(; muonsItr!=muons.end(); ++muonsItr) {
509 muonLinks.push_back( muLink );
514 muonLinksDecor(*m_b) = std::move(muonLinks);
524 if(!cacheElectrons())
528 return m_cachedElectrons.size();
535 if(!cacheElectrons())
539 if(
index>=m_cachedElectrons.size())
543 return m_cachedElectrons[
index];
551 if(!cacheElectrons())
555 return m_cachedElectrons;
563 m_electronsCached =
false;
564 m_cachedElectrons.clear();
573 std::vector<const xAOD::Electron*>::const_iterator electronsItr =
electrons.begin();
574 for(; electronsItr!=
electrons.end(); ++electronsItr) {
576 if( !(*electronsItr) )
589 electronLinks.push_back( elLink );
594 electronLinksDecor(*m_b) = std::move(electronLinks);
604 if(!cachePrecedingVertices())
608 return m_cachedPrecedingVertices.size();
616 if(!cachePrecedingVertices())
620 if(
index>=m_cachedPrecedingVertices.size())
624 return m_cachedPrecedingVertices[
index];
632 if(!cachePrecedingVertices())
636 return m_cachedPrecedingVertices;
645 m_precedingVerticesCached =
false;
646 m_cachedPrecedingVertices.clear();
655 std::vector<const xAOD::Vertex*>::const_iterator precedingVerticesItr = vertices.begin();
656 for(; precedingVerticesItr!=vertices.end(); ++precedingVerticesItr) {
658 if( !(*precedingVerticesItr) )
671 precedingVertexLinks.push_back( vertexLink );
676 precedingVertexLinksDecor(*m_b) = std::move(precedingVertexLinks);
685 if(!cacheCascadeVertices())
689 return m_cachedCascadeVertices.size();
697 if(!cacheCascadeVertices())
701 if(
index>=m_cachedCascadeVertices.size())
705 return m_cachedCascadeVertices[
index];
713 if(!cacheCascadeVertices())
717 return m_cachedCascadeVertices;
726 m_cascadeVerticesCached =
false;
727 m_cachedCascadeVertices.clear();
736 std::vector<const xAOD::Vertex*>::const_iterator cascadeVerticesItr = vertices.begin();
737 for(; cascadeVerticesItr!=vertices.end(); ++cascadeVerticesItr) {
739 if( !(*cascadeVerticesItr) )
752 cascadeVertexLinks.push_back( vertexLink );
757 cascadeVertexLinksDecor(*m_b) = std::move(cascadeVertexLinks);
772 if(
n<0 && nCascadeVertices()<=0) {
774 }
else if(
n<0 && nCascadeVertices()>0) {
779 for(
int i=0;
i<nCascadeVertices(); ++
i) {
799 case PV_MAX_SUM_PT2 :
GET_PV(
"PvMaxSumPt2Link");
800 case PV_MIN_A0 :
GET_PV(
"PvMinA0Link");
801 case PV_MIN_Z0 :
GET_PV(
"PvMinZ0Link");
802 case PV_MIN_Z0_BA :
GET_PV(
"PvMinZ0BALink");
803 default:
return nullptr;
810 case PV_MAX_SUM_PT2 :
GET_PV(
"OrigPvMaxSumPt2Link");
811 case PV_MIN_A0 :
GET_PV(
"OrigPvMinA0Link");
812 case PV_MIN_Z0 :
GET_PV(
"OrigPvMinZ0Link");
813 case PV_MIN_Z0_BA :
GET_PV(
"OrigPvMinZ0BALink");
814 default:
return nullptr;
823 case PV_MAX_SUM_PT2 :
SET_PV(
"OrigPvMaxSumPt2Link",
pv, vertexContainer);
824 case PV_MIN_A0 :
SET_PV(
"OrigPvMinA0Link" ,
pv, vertexContainer);
825 case PV_MIN_Z0 :
SET_PV(
"OrigPvMinZ0Link" ,
pv, vertexContainer);
826 case PV_MIN_Z0_BA :
SET_PV(
"OrigPvMinZ0BALink" ,
pv, vertexContainer);
836 case PV_MAX_SUM_PT2 :
SET_PV(
"PvMaxSumPt2Link",
pv, vertexContainer);
837 case PV_MIN_A0 :
SET_PV(
"PvMinA0Link" ,
pv, vertexContainer);
838 case PV_MIN_Z0 :
SET_PV(
"PvMinZ0Link" ,
pv, vertexContainer);
839 case PV_MIN_Z0_BA :
SET_PV(
"PvMinZ0BALink" ,
pv, vertexContainer);
840 default:
return false;
847 case PV_MAX_SUM_PT2 :
SET_INT(
"PvMaxSumPt2Status",
code);
850 case PV_MIN_Z0_BA :
SET_INT(
"PvMinZ0BAStatus" ,
code);
858 case PV_MAX_SUM_PT2 :
GET_INT(
"PvMaxSumPt2Status");
859 case PV_MIN_A0 :
GET_INT(
"PvMinA0Status" );
860 case PV_MIN_Z0 :
GET_INT(
"PvMinZ0Status" );
861 case PV_MIN_Z0_BA :
GET_INT(
"PvMinZ0BAStatus" );
862 default:
return -999999;
869 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"LxyMaxSumPt2");
872 case PV_MIN_Z0_BA :
GET_FLOAT(
"LxyMinZ0BA");
873 default:
return -9999999.;
880 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"LxyErrMaxSumPt2");
881 case PV_MIN_A0 :
GET_FLOAT(
"LxyErrMinA0");
882 case PV_MIN_Z0 :
GET_FLOAT(
"LxyErrMinZ0");
883 case PV_MIN_Z0_BA :
GET_FLOAT(
"LxyErrMinZ0BA");
884 default:
return -9999999.;
895 default:
return false;
902 case PV_MAX_SUM_PT2 :
SET_FLOAT(
"LxyErrMaxSumPt2",
val);
906 default:
return false;
915 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"LxyzMaxSumPt2");
918 case PV_MIN_Z0_BA :
GET_FLOAT(
"LxyzMinZ0BA");
919 default:
return -9999999.;
926 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"LxyzErrMaxSumPt2");
927 case PV_MIN_A0 :
GET_FLOAT(
"LxyzErrMinA0");
928 case PV_MIN_Z0 :
GET_FLOAT(
"LxyzErrMinZ0");
929 case PV_MIN_Z0_BA :
GET_FLOAT(
"LxyzErrMinZ0BA");
930 default:
return -9999999.;
941 default:
return false;
948 case PV_MAX_SUM_PT2 :
SET_FLOAT(
"LxyzErrMaxSumPt2",
val);
952 default:
return false;
960 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"A0MaxSumPt2");
963 case PV_MIN_Z0_BA :
GET_FLOAT(
"A0MinZ0BA");
964 default:
return -9999999.;
971 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"A0ErrMaxSumPt2");
972 case PV_MIN_A0 :
GET_FLOAT(
"A0ErrMinA0");
973 case PV_MIN_Z0 :
GET_FLOAT(
"A0ErrMinZ0");
974 case PV_MIN_Z0_BA :
GET_FLOAT(
"A0ErrMinZ0BA");
975 default:
return -9999999.;
982 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"A0xyMaxSumPt2");
985 case PV_MIN_Z0_BA :
GET_FLOAT(
"A0xyMinZ0BA");
986 default:
return -9999999.;
993 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"A0xyErrMaxSumPt2");
994 case PV_MIN_A0 :
GET_FLOAT(
"A0xyErrMinA0");
995 case PV_MIN_Z0 :
GET_FLOAT(
"A0xyErrMinZ0");
996 case PV_MIN_Z0_BA :
GET_FLOAT(
"A0xyErrMinZ0BA");
997 default:
return -9999999.;
1004 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"Z0MaxSumPt2");
1007 case PV_MIN_Z0_BA :
GET_FLOAT(
"Z0MinZ0BA");
1008 default:
return -9999999.;
1015 case PV_MAX_SUM_PT2 :
GET_FLOAT(
"Z0ErrMaxSumPt2");
1016 case PV_MIN_A0 :
GET_FLOAT(
"Z0ErrMinA0");
1017 case PV_MIN_Z0 :
GET_FLOAT(
"Z0ErrMinZ0");
1018 case PV_MIN_Z0_BA :
GET_FLOAT(
"Z0ErrMinZ0BA");
1019 default:
return -9999999.;
1030 default:
return false;
1037 case PV_MAX_SUM_PT2 :
SET_FLOAT(
"A0ErrMaxSumPt2",
val);
1041 default:
return false;
1052 default:
return false;
1059 case PV_MAX_SUM_PT2 :
SET_FLOAT(
"A0xyErrMaxSumPt2",
val);
1063 default:
return false;
1074 default:
return false;
1081 case PV_MAX_SUM_PT2 :
SET_FLOAT(
"Z0ErrMaxSumPt2",
val);
1085 default:
return false;
1092 if(m_covCached && m_cachedCov.GetNrows()!=0)
1096 if(m_covCached && m_cachedCov.GetNrows()==0)
1102 const int nTrk = nRefTrks();
1111 const std::vector<float>&
cov = m_b->covariance();
1114 if(
int(
cov.size())==(3*nTrk+3)*(3*nTrk+3+1)/2) {
1116 m_cachedCov.ResizeTo(3+3*nTrk, 3+3*nTrk);
1119 for(
int i=0;
i<(3+3*nTrk);
i++) {
1120 for(
int j=0; j<=
i; j++) {
1121 m_cachedCov(
i,j) =
cov[ij];
1140 if(m_refTracksCached && !m_cachedRefTracks.empty())
1144 if(m_refTracksCached && m_cachedRefTracks.empty())
1148 m_refTracksCached =
true;
1149 m_cachedRefTracks.clear();
1163 const std::vector<float>& refTrackPx = refTrackPxAcc(*m_b);
1164 const std::vector<float>& refTrackPy = refTrackPyAcc(*m_b);
1165 const std::vector<float>& refTrackPz = refTrackPzAcc(*m_b);
1168 if(refTrackPx.size()!=refTrackPy.size() || refTrackPx.size()!=refTrackPz.size())
1172 for(
uint i=0;
i<refTrackPx.size(); ++
i) {
1173 m_cachedRefTracks.emplace_back(refTrackPx[
i], refTrackPy[
i], refTrackPz[
i] );
1184 if(m_muonsCached && !m_cachedMuons.empty())
1188 if(m_muonsCached && m_cachedMuons.empty())
1192 m_muonsCached =
true;
1193 m_cachedMuons.clear();
1207 MuonLinkVector::const_iterator muonLinksItr = muonLinks.begin();
1208 for(; muonLinksItr!=muonLinks.end(); ++muonLinksItr) {
1210 if(!(*muonLinksItr).isValid()) {
1216 muonLinksItr = muonLinks.begin();
1217 for(; muonLinksItr!=muonLinks.end(); ++muonLinksItr) {
1218 m_cachedMuons.push_back(*(*muonLinksItr));
1229 if(m_electronsCached && !m_cachedElectrons.empty())
1233 if(m_electronsCached && m_cachedElectrons.empty())
1237 m_electronsCached =
true;
1238 m_cachedElectrons.clear();
1252 ElectronLinkVector::const_iterator electronLinksItr = electronLinks.begin();
1253 for(; electronLinksItr!=electronLinks.end(); ++electronLinksItr) {
1255 if(!(*electronLinksItr).isValid()) {
1261 electronLinksItr = electronLinks.begin();
1262 for(; electronLinksItr!=electronLinks.end(); ++electronLinksItr) {
1263 m_cachedElectrons.push_back(*(*electronLinksItr));
1274 if(m_precedingVerticesCached && !m_cachedPrecedingVertices.empty())
1278 if(m_precedingVerticesCached && m_cachedPrecedingVertices.empty())
1282 m_precedingVerticesCached =
true;
1283 m_cachedPrecedingVertices.clear();
1294 const VertexLinkVector& precedingVertexLinks = precedingVertexLinksAcc(*m_b);
1297 VertexLinkVector::const_iterator precedingVertexLinksItr = precedingVertexLinks.begin();
1298 for(; precedingVertexLinksItr!=precedingVertexLinks.end(); ++precedingVertexLinksItr) {
1300 if(!(*precedingVertexLinksItr).isValid()) {
1306 precedingVertexLinksItr = precedingVertexLinks.begin();
1307 for(; precedingVertexLinksItr!=precedingVertexLinks.end(); ++precedingVertexLinksItr) {
1308 m_cachedPrecedingVertices.push_back(*(*precedingVertexLinksItr));
1319 if(m_cascadeVerticesCached && !m_cachedCascadeVertices.empty())
1323 if(m_cascadeVerticesCached && m_cachedCascadeVertices.empty())
1327 m_cascadeVerticesCached =
true;
1328 m_cachedCascadeVertices.clear();
1342 VertexLinkVector::const_iterator cascadeVertexLinksItr = cascadeVertexLinks.begin();
1343 for(; cascadeVertexLinksItr!=cascadeVertexLinks.end(); ++cascadeVertexLinksItr) {
1345 if(!(*cascadeVertexLinksItr).isValid()) {
1351 cascadeVertexLinksItr = cascadeVertexLinks.begin();
1352 for(; cascadeVertexLinksItr!=cascadeVertexLinks.end(); ++cascadeVertexLinksItr) {
1353 m_cachedCascadeVertices.push_back(*(*cascadeVertexLinksItr));