11#include <boost/container/static_vector.hpp>
13#include "HepPDT/ParticleDataTable.hh"
67 const float errConst = -9999999.;
77 const std::vector<const xAOD::Vertex*> &PVlist,
78 const size_t PV_minNTracks)
const {
81 lowZ=std::numeric_limits<std::size_t>::max();
84 size_t size = PVlist.size();
86 for(
size_t i =1; i<size; i++) {
87 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
89 if(a0z < lowA0zcalc) {
99 const std::vector<const xAOD::Vertex*> &PVlist,
100 const size_t PV_minNTracks)
const {
103 lowA0=std::numeric_limits<std::size_t>::max();
106 size_t size = PVlist.size();
108 for(
size_t i =1; i<size; i++) {
109 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
124 std::vector<const xAOD::Vertex*> goodPrimaryVertices;
125 goodPrimaryVertices.reserve(pvContainer->
size());
127 for (
auto ptr = pvContainer->
begin(); ptr!= pvContainer->
end(); ++ptr) {
128 VertexType thistype = (*ptr)->vertexType();
129 if ( thistype == Pileupvtx || thistype == Pvtx ) {
130 goodPrimaryVertices.push_back(*ptr);
135 return goodPrimaryVertices;
149 static const Amg::Vector3D defaultBS(-10000.,-10000.,-10000.);
156 const std::vector<const xAOD::Vertex*> &PVlist,
157 const size_t PV_minNTracks)
const {
159 size_t ilowZ0BA = std::numeric_limits<std::size_t>::max();
160 double lowZ0BAcalc = std::numeric_limits<double>::max();
161 for (
size_t i = 0; i<PVlist.size(); ++i) {
162 if ( PVlist[i]->nTrackParticles() >= PV_minNTracks ) {
164 if (z0BA < lowZ0BAcalc) {
186 TLorentzVector totalMom;
187 unsigned int NTrk = mom.size();
188 for(
unsigned int it=0; it<NTrk; it++) totalMom += mom[it];
189 TVector3 totP = totalMom.Vect();
192 if ( pT.mag2() > 0 ) {
196 xDOCA = xSV - pSV*pT.dot(xT)/pT.mag2();
198 std::cout <<
"BPhysPVCascadeTools::DocaExtrapToBeamSpot: WARNING pT == 0."
206 auto &collection =
result->vertices();
207 for(
auto v : collection)
209 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
210 for(
unsigned int i=0; i< v->trackParticleLinks().size(); i++)
214 newLinkVector.push_back( mylink );
217 v->setTrackParticleLinks( newLinkVector );
223 auto &collection =
result->vertices();
224 for(
auto v : collection) {
225 std::vector<ElementLink<DataVector<xAOD::TrackParticle> > > newLinkVector;
226 for(
auto mylink : v->trackParticleLinks()) {
229 for(
auto col : trackCols){
230 if(std::find(col->begin(), col->end(), myptr) != col->end()){
235 if(foundcontainer ==
nullptr){
236 throw std::runtime_error(
"Could not find track in original containers");
238 mylink.setStorableObject(*foundcontainer,
true);
239 newLinkVector.push_back( mylink );
242 v->setTrackParticleLinks( newLinkVector );
248 std::vector<const xAOD::TrackParticle*> exclTrk;
249 for(
size_t jt=0; jt<cascadeVertices.size(); jt++) {
250 for(
size_t it=0; it<cascadeVertices[jt]->vxTrackAtVertex().size(); it++) {
251 if(cascadeVertices[jt]->trackParticle(it)->
charge() != 0) exclTrk.push_back(cascadeVertices[jt]->trackParticle(it));
268 const std::vector<xAOD::Vertex*> &cascadeVertices = casc->
vertices();
269 const bool doPt = (DoVertexType & 1) != 0;
270 const bool doA0 = (DoVertexType & 2) != 0;
271 const bool doZ0 = (DoVertexType & 4) != 0;
272 const bool doZ0BA = (DoVertexType & 8) != 0;
278 const std::vector<const xAOD::Vertex*> GoodPVs =
GetGoodPV(pvContainer);
280 if (GoodPVs.empty() ==
false) {
282 size_t pVmax =std::min((
size_t)in_PV_max, GoodPVs.size());
283 std::vector<const xAOD::Vertex*> refPVvertexes;
284 std::vector<xAOD::Vertex*> refPVvertexes_toDelete;
285 std::vector<int> exitCode;
286 refPVvertexes.reserve(pVmax);
287 refPVvertexes_toDelete.reserve(pVmax);
288 exitCode.reserve(pVmax);
292 for (
size_t i =0; i < pVmax ; i++) {
299 exitCode.push_back(exitcode);
301 if (refPV ==
nullptr) {
302 refPVvertexes.push_back(oldPV);
303 refPVvertexes_toDelete.push_back(
nullptr);
305 refPVvertexes.push_back(refPV);
306 refPVvertexes_toDelete.push_back(refPV);
309 boost::container::static_vector<size_t, 4> indexesUsed;
310 boost::container::static_vector<std::pair<size_t, xAOD::BPhysHelper::pv_type>, 4> indexestoProcess;
313 indexestoProcess.push_back(std::make_pair
326 if( lowZBA < pVmax ) {
332 for(
size_t i =0 ; i<indexestoProcess.size(); i++){
334 auto index = indexestoProcess[i].first;
335 auto pvtype = indexestoProcess[i].second;
337 (refPVvertexes_toDelete.at(
index)) ? refPvContainer : pvContainer;
338 if(ParentContainer == refPvContainer && std::find(indexesUsed.begin(),
339 indexesUsed.end(),
index) == indexesUsed.
end()) {
342 indexesUsed.push_back(
index);
345 ParentContainer, pvtype, exitCode[
index]);
350 for(
size_t x : indexesUsed) refPVvertexes_toDelete[
x] =
nullptr;
353 for(
const xAOD::Vertex* ptr : refPVvertexes_toDelete)
delete ptr;
354 refPVvertexes.clear();
355 refPVvertexes_toDelete.clear();
377 if ( lowZBA < GoodPVs.size() ) {
387 if(pvContainer->
empty())
return StatusCode::FAILURE;
419 return StatusCode::SUCCESS;
426 const std::vector< std::vector<TLorentzVector> > &moms = casc->
getParticleMoms();
427 const std::vector<xAOD::Vertex*> &cascadeVertices = casc->
vertices();
429 std::vector<float> px;
430 std::vector<float> py;
431 std::vector<float> pz;
432 for(
size_t jt=0; jt<moms.size(); jt++) {
433 for(
size_t it=0; it<cascadeVertices[jt]->vxTrackAtVertex().size(); it++) {
434 px.push_back( moms[jt][it].Px() );
435 py.push_back( moms[jt][it].Py() );
436 pz.push_back( moms[jt][it].Pz() );
439 vtx.
setRefTrks(std::move(px),std::move(py),std::move(pz));
445 if(std::count(col.begin(), col.end(), p) > 1)
return false;
452 if((std::count(col1.begin(), col1.end(), p) + std::count(col2.begin(), col2.end(), p)) > 1)
return false;
455 if((std::count(col1.begin(), col1.end(), p) + std::count(col2.begin(), col2.end(), p)) > 1)
return false;
466 auto precedingVerticesItr = vertices.begin();
467 for(; precedingVerticesItr!=vertices.end(); ++precedingVerticesItr) {
469 if( !(*precedingVerticesItr) )
482 precedingVertexLinks.push_back( vertexLink );
487 decor(*vert) = precedingVertexLinks;
492 auto ptr = pdt->particle( pdgcode );
493 return ptr ? ptr->mass() : 0.;
double charge(const T &p)
: B-physics xAOD helpers.
#define BPHYS_CHECK(EXP)
Useful CHECK macro.
std::vector< size_t > vec
xAOD::Vertex * refitVertex(const xAOD::Vertex *vertex, const xAOD::Vertex *excludeVertex, bool ReturnCopy=true, int *exitcode=nullptr) const
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
const T * at(size_type n) const
Access an element, as an rvalue.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
ElementLink implementation for ROOT usage.
bool setElement(ElementType element)
Set to point to an element.
bool setStorableObject(BaseConstReference data, bool replace=false, IProxyDict *sg=0)
Set link to point to a new container (storable).
bool isValid() const
Test to see if the link can be dereferenced.
SG::Decorator< T, ALLOC > Decorator
const std::vector< Amg::MatrixX > & getCovariance() const
const std::vector< std::vector< TLorentzVector > > & getParticleMoms() const
const std::vector< xAOD::Vertex * > & vertices() const
float setZ0(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter
bool setLxyErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
its error
bool setLxy(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the transverse decay distance and its error measured between the refitted primary vertex of type ...
float setZ0Err(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
longitudinal impact parameter error
const xAOD::Vertex * vtx() const
Getter method for the cached xAOD::Vertex.
float setA0(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the 3D and transverse impact parameters and their error.
bool setPv(const xAOD::Vertex *pv, const xAOD::VertexContainer *vertexContainer, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the refitted collision vertex of type pv_type.
const xAOD::Vertex * pv(const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Get the refitted collision vertex of type pv_type.
pv_type
: Enum type of the PV
bool setRefTrks(std::vector< float > px, std::vector< float > py, std::vector< float > pz)
Sets refitted track momenta.
float setA0Err(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
3D impact parameter error
bool setRefitPVStatus(int code, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the exitCode of the refitter for vertex of type pv_type.
float setA0xyErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter error
float setA0xy(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
transverse impact parameter
bool setOrigPv(const xAOD::Vertex *pv, const xAOD::VertexContainer *vertexContainer, const pv_type vertexType=BPhysHelper::PV_MIN_A0)
Set the original collision vertex of type pv_type.
bool setTau(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0, const tau_type tauType=BPhysHypoHelper::TAU_CONST_MASS)
: Set the proper decay time and error.
bool setTauErr(const float val, const pv_type vertexType=BPhysHelper::PV_MIN_A0, const tau_type tauType=BPhysHypoHelper::TAU_CONST_MASS)
proper decay time error
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
EventInfo_v1 EventInfo
Definition of the latest event info version.
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.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".