ATLAS Offline Software
Loading...
Searching...
No Matches
Analysis::JetSecVertexingAlg Class Reference

#include <JetSecVertexingAlg.h>

Inheritance diagram for Analysis::JetSecVertexingAlg:
Collaboration diagram for Analysis::JetSecVertexingAlg:

Public Member Functions

 JetSecVertexingAlg (const std::string &name, ISvcLocator *pSvcLocator)
 Constructors and destructors.
virtual ~JetSecVertexingAlg ()=default
virtual StatusCode initialize () override
 Main routines specific to an ATHENA algorithm.
virtual StatusCode execute (const EventContext &ctx) const override
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

StatusCode createSecVkalContainer (xAOD::VertexContainer *, std::vector< ElementLink< xAOD::VertexContainer > > *, const Trk::VxSecVKalVertexInfo *) const
StatusCode createJFContainer (xAOD::BTagVertexContainer *, std::vector< ElementLink< xAOD::BTagVertexContainer > > *, const Trk::VxJetFitterVertexInfo *, const xAOD::TrackParticleContainer *) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< IMSVVariablesFactorym_MSVvarFactory
std::string m_secVertexFinderBaseName
SG::ReadHandleKey< xAOD::JetContainerm_JetCollectionName {this, "JetCollectionName", "", "Input jet container"}
SG::ReadHandleKey< xAOD::TrackParticleContainerm_TrackCollectionName {this, "TrackCollectionName", "", "Input track container"}
SG::ReadHandleKey< xAOD::VertexContainerm_VertexCollectionName {this, "vxPrimaryCollectionName", "", "Input primary vertex container"}
SG::ReadHandleKey< Trk::VxSecVertexInfoContainerm_VxSecVertexInfoName {this, "BTagVxSecVertexInfoName", "", "Input VxSecVertexInfo container"}
SG::WriteHandleKey< xAOD::VertexContainerm_BTagSVCollectionName {this, "BTagSVCollectionName", "", "Output BTagging secondary vertex container"}
SG::WriteDecorHandleKey< xAOD::JetContainerm_jetSVLinkName { this, "JetSecVtxLinkName", "", "Element Link vector from jet to Vertex container"}
SG::WriteHandleKey< xAOD::BTagVertexContainerm_BTagJFVtxCollectionName {this, "BTagJFVtxCollectionName", "", "Output BTagging Jet Fitter container"}
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 41 of file JetSecVertexingAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ JetSecVertexingAlg()

Analysis::JetSecVertexingAlg::JetSecVertexingAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Constructors and destructors.

Definition at line 31 of file JetSecVertexingAlg.cxx.

31 :
32 AthReentrantAlgorithm(name,pSvcLocator),
33 m_MSVvarFactory("Analysis::MSVVariablesFactory",this)
34 {
35 declareProperty("SecVtxFinderxAODBaseName", m_secVertexFinderBaseName);
36 declareProperty("MSVVariableFactory", m_MSVvarFactory);
37 }
ToolHandle< IMSVVariablesFactory > m_MSVvarFactory
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ ~JetSecVertexingAlg()

virtual Analysis::JetSecVertexingAlg::~JetSecVertexingAlg ( )
virtualdefault

Member Function Documentation

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

64{
65 return 0;
66}

◆ createJFContainer()

StatusCode Analysis::JetSecVertexingAlg::createJFContainer ( xAOD::BTagVertexContainer * bTagJFVertexContainer,
std::vector< ElementLink< xAOD::BTagVertexContainer > > * JFVerticesLinks,
const Trk::VxJetFitterVertexInfo * myVertexInfoJetFitter,
const xAOD::TrackParticleContainer * theTrackParticleContainer ) const
private

found map

Definition at line 243 of file JetSecVertexingAlg.cxx.

246 {
247
248 //list of JFvertices
249 const std::vector<Trk::VxJetCandidate*>& JFvertices = myVertexInfoJetFitter->verticesJF();
250
251 int nVtx = 0;
252 if (!JFvertices.empty()) {
253 Trk::VxJetCandidate* vxjetcand = dynamic_cast< Trk::VxJetCandidate*>(JFvertices[0]);
254 if (!vxjetcand) {
255 ATH_MSG_WARNING("#BTAG# bad VxCandidate is not a VxJetCandidate");
256 return StatusCode::SUCCESS;
257 }
258
259 //compatibility with others SV
260 const Trk::VxClusteringTable* ClusteringTable = vxjetcand->getClusteringTable();
261 typedef std::map<Trk::VxVertexOnJetAxis*, std::vector<std::pair<Trk::VxVertexOnJetAxis*,float> > > map2vtx;
262 map2vtx inverseCompMap;
263
264 if (ClusteringTable !=nullptr) {
265 const std::map<float,Trk::PairOfVxVertexOnJetAxis>& mapPairVtxOnJetAxis = ClusteringTable->getCompatibilityPairOfVertices();
266 std::map<float,Trk::PairOfVxVertexOnJetAxis>::const_iterator mapiter = mapPairVtxOnJetAxis.begin();
267 for(;mapiter != mapPairVtxOnJetAxis.end(); ++mapiter){
268
269 Trk::VxVertexOnJetAxis* vtx1 = mapiter->second.first;
270 Trk::VxVertexOnJetAxis* vtx2 = mapiter->second.second;
271 float comp = mapiter->first;
272
273 std::pair<Trk::VxVertexOnJetAxis*,float> pair1(vtx1, comp);
274 std::pair<Trk::VxVertexOnJetAxis*,float> pair2(vtx1, comp);
275
276 inverseCompMap[vtx1].push_back(pair2);
277 inverseCompMap[vtx2].push_back(pair1);
278
279 }
280 }
281
282 //vtx on jet axis
283 const std::vector<Trk::VxVertexOnJetAxis*> Vtxonjetaxes = vxjetcand->getVerticesOnJetAxis();
284 ATH_MSG_DEBUG("#BTAG# VerticesOnJetAxis of VxJetCandidate size: " << Vtxonjetaxes.size());
285 std::vector<Trk::VxVertexOnJetAxis*>::const_iterator iterBegin = Vtxonjetaxes.begin();
286 std::vector<Trk::VxVertexOnJetAxis*>::const_iterator iterEnd = Vtxonjetaxes.end();
287 float comptoPV(0.);
288 double chi2(0.);
289 int ndf(0);
290 nVtx = Vtxonjetaxes.size();
291 std::map<Trk::VxVertexOnJetAxis*, ElementLink< xAOD::BTagVertexContainer> > oldnewmap;
292
293 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator it=iterBegin; it!=iterEnd; ++it) {
294 //ndf, chi2 , comptoPV
295 const Trk::FitQuality& fitquality = (*it)->fitQuality();
296 chi2 = fitquality.chiSquared();
297 ndf = fitquality.numberDoF();
298 comptoPV = (*it)->getCompatibilityToPrimaryVtx();
299 const std::vector<Trk::VxTrackAtVertex*> & trackatVtx = (*it)->getTracksAtVertex();
300 std::vector<Trk::VxTrackAtVertex*>::const_iterator itrBegin = trackatVtx.begin();
301 std::vector<Trk::VxTrackAtVertex*>::const_iterator itrEnd = trackatVtx.end();
302 std::vector< float> tmpchi2;
303 std::vector< float> tmpndf;
304 std::vector< ElementLink< xAOD::TrackParticleContainer > > trkLinks;
305 std::vector< float> tmpRefPx;
306 std::vector< float> tmpRefPy;
307 std::vector< float> tmpRefPz;
308
309 //loop in trks
310 for (std::vector<Trk::VxTrackAtVertex*>::const_iterator itr=itrBegin; itr!=itrEnd; ++itr) {
311 //ndf, chi2
312 const Trk::FitQuality& trkquality = (*itr)->trackQuality();
313 double tpchi2 = trkquality.chiSquared();
314 int tpndf = trkquality.numberDoF();
315 tmpchi2.push_back(float(tpchi2));
316 tmpndf.push_back(float(tpndf));
317 //tracks links
318 Trk::ITrackLink* trklinks = (*itr)->trackOrParticleLink();
319 const Trk::LinkToXAODTrackParticle* trkLinkTPxAOD=dynamic_cast<const Trk::LinkToXAODTrackParticle *>(trklinks);
320 if (!trkLinkTPxAOD) {
321 ATH_MSG_WARNING("#BTAG# bad ITrackLink is not a LinkToXAODTrackParticle");
322 continue;
323 }
324 const xAOD::TrackParticle* myTrklink = **trkLinkTPxAOD;
325 ElementLink<xAOD::TrackParticleContainer> tpel;
326
327 tpel.toContainedElement(*theTrackParticleContainer, myTrklink);
328 trkLinks.push_back(tpel);
329
330 //reffited momentum
331 const Trk::TrackParameters* trkperigee = (*itr)->perigeeAtVertex();
332 Amg::Vector3D mytrack = trkperigee->momentum();
333 tmpRefPx.push_back(mytrack.x());
334 tmpRefPy.push_back(mytrack.y());
335 tmpRefPz.push_back(mytrack.z());
336
337 }
338
339 xAOD::BTagVertex* newbtagVtx = new xAOD::BTagVertex();
340 bTagJFVertexContainer->push_back(newbtagVtx);
341
342 newbtagVtx->setNDF(ndf);
343 newbtagVtx->setChi2(chi2);
344 newbtagVtx->setPV_compatibility(comptoPV);
345 newbtagVtx->setTrack_chi2(tmpchi2);
346 newbtagVtx->setTrack_NDF(tmpndf);
347 newbtagVtx->setTrack_links(trkLinks);
348 newbtagVtx->setTrack_refPx(tmpRefPx);
349 newbtagVtx->setTrack_refPy(tmpRefPy);
350 newbtagVtx->setTrack_refPz(tmpRefPz);
351
352 ElementLink< xAOD::BTagVertexContainer> linkBTagVertex;
353 linkBTagVertex.toContainedElement(*bTagJFVertexContainer, newbtagVtx);
354 JFVerticesLinks->push_back(linkBTagVertex);
355 oldnewmap.insert(std::make_pair(*it,linkBTagVertex));
356 }
357
358 if(ClusteringTable !=nullptr){
359 for (std::vector<Trk::VxVertexOnJetAxis*>::const_iterator it=iterBegin; it!=iterEnd; ++it) {
360 std::vector< ElementLink< xAOD::BTagVertexContainer > > JFCompLinks;
361 std::vector<float> JFCompValues;
362
363 bool foundmap=true;
364 map2vtx::iterator itmap = inverseCompMap.find(*it);
365 if(itmap == inverseCompMap.end()){
366 ATH_MSG_DEBUG("#BTAG# JF compatibility value in map2vtx map not found ");
367 foundmap=false;
368 }
369
370 if(foundmap){
371
372 std::vector<std::pair<Trk::VxVertexOnJetAxis*,float> > tmpvectpair = itmap->second;
373
374 for(auto & icomppair : tmpvectpair){
375 std::map<Trk::VxVertexOnJetAxis*, ElementLink< xAOD::BTagVertexContainer> >::iterator JFOlNewIter = oldnewmap.find(icomppair.first);
376
377 if(JFOlNewIter == oldnewmap.end()){
378 ATH_MSG_DEBUG("#BTAG# JF compatibility vector not found ");
379 continue;
380 }
381
382 JFCompLinks.push_back(JFOlNewIter->second);
383 JFCompValues.push_back(icomppair.second);
384 }
385 }
386 }
387 }
388
389 const Trk::RecVertexPositions& recVtxposition = vxjetcand->getRecVertexPositions();
390 const Amg::VectorX& vtxPositions = recVtxposition.position();
391 const Amg::MatrixX& vtxCovMatrix = recVtxposition.covariancePosition();
392 ATH_MSG_DEBUG("#BTAGJF# size vtxPosition "<<vtxPositions.size());
393 std::vector< float > fittedPosition = std::vector<float>(nVtx+5,-1);
394 std::vector< float > fittedCov = std::vector<float>(nVtx+5,-1); //only store the diagonal terms
395 if (fittedPosition.size() < 5) std::abort(); // suppress cppcheck warnings
396 if(vtxPositions.rows()>4 ) {
397 fittedPosition[0] = vtxPositions[Trk::jet_xv]; //position x,y,z of PV
398 fittedPosition[1] = vtxPositions[Trk::jet_yv];
399 fittedPosition[2] = vtxPositions[Trk::jet_zv];
400 fittedPosition[3] = vtxPositions[Trk::jet_phi]; // direction of the jet axis
401 fittedPosition[4] = vtxPositions[Trk::jet_theta];
402
403 fittedCov[0] = vtxCovMatrix(0,0);
404 fittedCov[1] = vtxCovMatrix(1,1);
405 fittedCov[2] = vtxCovMatrix(2,2);
406 fittedCov[3] = vtxCovMatrix(3,3);
407 fittedCov[4] = vtxCovMatrix(4,4);
408
409 }
410
411 for(int i=0; i<nVtx; ++i){
412 fittedPosition[i+5] = vtxPositions[i+5]; //dist of vtxi on jet axis from PV
413 fittedCov[i+5] = vtxCovMatrix(i+5,i+5);
414 }
415
416 //trks at PV
417 const std::vector<Trk::VxTrackAtVertex*> & trackatPV = vxjetcand->getPrimaryVertex()->getTracksAtVertex();
418 std::vector<Trk::VxTrackAtVertex*>::const_iterator irBegin = trackatPV.begin();
419 std::vector<Trk::VxTrackAtVertex*>::const_iterator irEnd = trackatPV.end();
420 std::vector< float > tracksAtPVchi2;
421 std::vector< float > tracksAtPVndf;
422 std::vector< ElementLink< xAOD::TrackParticleContainer > > tracksAtPVlinks;
423
424 for (std::vector<Trk::VxTrackAtVertex*>::const_iterator it=irBegin; it!=irEnd; ++it) {
425 const Trk::FitQuality& trkquality = (*it)->trackQuality();
426 double tmpchi2 = trkquality.chiSquared();
427 int tmpndf = trkquality.numberDoF();
428 tracksAtPVchi2.push_back(float(tmpchi2));
429 tracksAtPVndf.push_back(float(tmpndf));
430 //links
431
432 Trk::ITrackLink* trklinks = (*it)->trackOrParticleLink();
433 const Trk::LinkToXAODTrackParticle* trkLinkTPxAOD = dynamic_cast<const Trk::LinkToXAODTrackParticle *>(trklinks);
434 if (!trkLinkTPxAOD) {
435 ATH_MSG_WARNING("#BTAG# bad ITrackLink is not a LinkToXAODTrackParticle");
436 continue;
437 }
438 const xAOD::TrackParticle* myTrklink = **trkLinkTPxAOD;
439 ElementLink<xAOD::TrackParticleContainer> tpel;
440 tpel.toContainedElement(*theTrackParticleContainer, myTrklink);
441 tracksAtPVlinks.push_back(tpel);
442 }
443 }
444 else { //No JF vertices
445 ATH_MSG_ERROR("#BTAG# No JF vertices. Minimum 1");
446 }
447
448 return StatusCode::SUCCESS;
449 }
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
int numberDoF() const
returns the number of degrees of freedom of the overall track or vertex fit as integer
Definition FitQuality.h:60
double chiSquared() const
returns the of the overall track fit
Definition FitQuality.h:56
const Amg::Vector3D & momentum() const
Access method for the momentum.
Amg::MatrixX const & covariancePosition() const
return the covDeltaV matrix of the vertex fit
const Amg::VectorX & position() const
return position of vertex
const std::map< float, PairOfVxVertexOnJetAxis > & getCompatibilityPairOfVertices(void) const
Get back full compatibility info (only for reading)
Trk::VxClusteringTable *& getClusteringTable(void)
const std::vector< VxVertexOnJetAxis * > & getVerticesOnJetAxis(void) const
const VxVertexOnJetAxis * getPrimaryVertex(void) const
const Trk::RecVertexPositions & getRecVertexPositions() const
const std::vector< Trk::VxJetCandidate * > & verticesJF() const
const std::vector< VxTrackAtVertex * > & getTracksAtVertex(void) const
get Tracks At Vertex Method
void setTrack_chi2(const std::vector< float > &values)
set track chi2 values
void setTrack_NDF(const std::vector< float > &values)
set track NDF values
void setTrack_refPz(const std::vector< float > &values)
set track momentum z components
void setChi2(float value)
access the corresponding xAOD::BTagVertex
void setTrack_refPx(const std::vector< float > &values)
set track momentum x components
void setNDF(float value)
set fit NDF
void setTrack_links(const TPELinks_t &links)
set track ElementLinks
void setPV_compatibility(float value)
set compatibility with PV
void setTrack_refPy(const std::vector< float > &values)
set track momentum y components
double chi2(TH1 *h0, TH1 *h1)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
std::pair< HepMcParticleLink, CscMcData > pair2
std::pair< HepMcParticleLink,MuonMCData > pair1
ParametersBase< TrackParametersDim, Charged > TrackParameters
@ jet_zv
position x,y,z of primary vertex
BTagVertex_v1 BTagVertex
Definition of the current "BTagging version".
Definition BTagVertex.h:17
TrackParticle_v1 TrackParticle
Reference the current persistent version:

◆ createSecVkalContainer()

StatusCode Analysis::JetSecVertexingAlg::createSecVkalContainer ( xAOD::VertexContainer * bTagVertexContainer,
std::vector< ElementLink< xAOD::VertexContainer > > * SVertexLinks,
const Trk::VxSecVKalVertexInfo * myVertexInfoVKal ) const
private

Definition at line 223 of file JetSecVertexingAlg.cxx.

224 {
225
226 std::vector<xAOD::Vertex*>::const_iterator verticesBegin = myVertexInfoVKal->vertices().begin();
227 std::vector<xAOD::Vertex*>::const_iterator verticesEnd = myVertexInfoVKal->vertices().end();
228
229 for (std::vector<xAOD::Vertex*>::const_iterator verticesIter=verticesBegin; verticesIter!=verticesEnd;++verticesIter) {
230 xAOD::Vertex* btagVtx = *verticesIter;
231 bTagVertexContainer->push_back(btagVtx);
232
233 ElementLink< xAOD::VertexContainer> linkBTagVertex;
234 linkBTagVertex.toContainedElement(*bTagVertexContainer, btagVtx);
235 SVertexLinks->push_back(linkBTagVertex);
236 }
237 ATH_MSG_DEBUG("#BTAG# SV container size: " << bTagVertexContainer->size());
238
239 return StatusCode::SUCCESS;
240 }
size_type size() const noexcept
Returns the number of elements in the collection.
const std::vector< xAOD::Vertex * > & vertices() const
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode Analysis::JetSecVertexingAlg::execute ( const EventContext & ctx) const
overridevirtual

Definition at line 65 of file JetSecVertexingAlg.cxx.

65 {
66 //retrieve the Jet container
67 SG::ReadHandle<xAOD::JetContainer> h_JetCollectionName (m_JetCollectionName,ctx);
68 if (!h_JetCollectionName.isValid()) {
69 ATH_MSG_ERROR( " cannot retrieve jet container with key " << m_JetCollectionName.key() );
70 return StatusCode::FAILURE;
71 }
72
73 SG::WriteHandle<xAOD::VertexContainer> h_BTagSVCollectionName;
74 SG::WriteHandle<xAOD::BTagVertexContainer> h_BTagJFVtxCollectionName;
75
77 /* Record the BTagging JF Vertex output container */
78 if ((basename == "JetFitter") || (basename == "JetFitterFlip")) {
79 ATH_MSG_DEBUG("#BTAG# Record the BTagging JF Vertex output container");
80 h_BTagJFVtxCollectionName = SG::WriteHandle<xAOD::BTagVertexContainer>(m_BTagJFVtxCollectionName, ctx);
81 ATH_CHECK( h_BTagJFVtxCollectionName.record(std::make_unique<xAOD::BTagVertexContainer>(),
82 std::make_unique<xAOD::BTagVertexAuxContainer>()) );
83 }
84
85 /* Record the BTagging Secondary Vertex output container */
86 if ((basename == "SV1") ||(basename == "SV1Flip") || (basename == "MSV")) {
87 ATH_MSG_DEBUG("#BTAG# Record the BTagging Secondary Vertex output container");
88 h_BTagSVCollectionName = SG::WriteHandle<xAOD::VertexContainer>(m_BTagSVCollectionName, ctx);
89 ATH_CHECK( h_BTagSVCollectionName.record(std::make_unique<xAOD::VertexContainer>(),
90 std::make_unique<xAOD::VertexAuxContainer>()) );
91 }
92
93 if (h_JetCollectionName->empty()) {
94 ATH_MSG_DEBUG("#BTAG# Empty Jet collection");
95 return StatusCode::SUCCESS;
96 }
97
98 SG::ReadHandle<xAOD::TrackParticleContainer> h_TrackCollectionName (m_TrackCollectionName, ctx);
99 if (!h_TrackCollectionName.isValid()) {
100 ATH_MSG_ERROR( " cannot retrieve track container with key " << m_TrackCollectionName.key() );
101 return StatusCode::FAILURE;
102 }
103
104 const xAOD::TrackParticleContainer* theTrackParticleContainer = h_TrackCollectionName.ptr();
105
106 const xAOD::Vertex* primaryVertex(nullptr);
107
108 //retrieve primary vertex
109 SG::ReadHandle<xAOD::VertexContainer> h_VertexCollectionName (m_VertexCollectionName, ctx);
110 if (!h_VertexCollectionName.isValid()) {
111 ATH_MSG_ERROR( " cannot retrieve primary vertex container with key " << m_VertexCollectionName.key() );
112 return StatusCode::FAILURE;
113 }
114
115 //retrieve VxSecVertexInfo
116 SG::ReadHandle<Trk::VxSecVertexInfoContainer> h_VxSecVertexInfoName (m_VxSecVertexInfoName, ctx);
117 if (!h_VxSecVertexInfoName.isValid()) {
118 ATH_MSG_ERROR( " cannot retrieve secondary vertex container with key " << m_VxSecVertexInfoName.key() );
119 return StatusCode::FAILURE;
120 }
121 ATH_MSG_DEBUG("Size of VxSecVertexInfo: " << h_VxSecVertexInfoName->size());
122
123 if (h_VxSecVertexInfoName->size() != h_JetCollectionName->size()) {
124 ATH_MSG_ERROR("Size of jet container different than size of VxSecVertexInfo");
125 return StatusCode::FAILURE;
126 }
127
128 unsigned int nVertexes = h_VertexCollectionName->size();
129 if (nVertexes == 0) {
130 ATH_MSG_ERROR("#BTAG# Vertex container is empty");
131 return StatusCode::FAILURE;
132 }
133 for (const auto *fz : *h_VertexCollectionName) {
134 if (fz->vertexType() == xAOD::VxType::PriVtx) {
135 primaryVertex = fz;
136 break;
137 }
138 }
139
140 if (! primaryVertex) {
141 ATH_MSG_DEBUG("#BTAG# No vertex labeled as VxType::PriVtx!");
142 xAOD::VertexContainer::const_iterator fz = h_VertexCollectionName->begin();
143 primaryVertex = *fz;
144 if (primaryVertex->nTrackParticles() == 0) {
145 ATH_MSG_DEBUG("#BTAG# PV==BeamSpot: probably poor tagging");
146 }
147 }
148
149 const xAOD::Vertex& PrimaryVtx = *primaryVertex;
150
151 Trk::VxSecVertexInfoContainer::const_iterator infoSVIter = h_VxSecVertexInfoName->begin();
152
153 if(basename == "MSV") {
154 for (const xAOD::Jet* jetToTag : *h_JetCollectionName) {
155 const Trk::VxSecVertexInfo* myVertexInfo = *infoSVIter++;
156 if(myVertexInfo != nullptr) {
157 if(const Trk::VxSecVKalVertexInfo* myVertexInfoVKal = dynamic_cast<const Trk::VxSecVKalVertexInfo*>(myVertexInfo)) {
158 ATH_MSG_DEBUG("#BTAG# Found VKalVertexInfo information");
159 StatusCode sc = m_MSVvarFactory->createMSVContainer(*jetToTag, myVertexInfoVKal, &(*h_BTagSVCollectionName), PrimaryVtx);
160 if(sc.isFailure()){
161 ATH_MSG_ERROR("#BTAG# error filling variables in MSVVariablesFactory" );
162 return sc;
163 }
164 }
165 else {
166 ATH_MSG_DEBUG("#BTAG# dynamic_cast failed for a non-nullptr myVertexInfo!");
167 }
168 }
169 }
170 }
171
172 else if(basename == "SV1" || basename == "SV1Flip") { //SV1
173 SG::WriteDecorHandle<xAOD::JetContainer,std::vector<ElementLink< xAOD::VertexContainer> > > h_jetSVLinkName(m_jetSVLinkName, ctx);
174 for (const xAOD::Jet* jetToTag : *h_JetCollectionName) {
175 const Trk::VxSecVertexInfo* myVertexInfo = *infoSVIter++;
176 std::vector< ElementLink< xAOD::VertexContainer > > SVertexLinks;
177 if(myVertexInfo != nullptr) {
178 if(const Trk::VxSecVKalVertexInfo* myVertexInfoVKal = dynamic_cast<const Trk::VxSecVKalVertexInfo*>(myVertexInfo)) {
179 ATH_MSG_DEBUG("#BTAG# Found VKalVertexInfo information");
180 StatusCode sc = createSecVkalContainer(&(*h_BTagSVCollectionName), &SVertexLinks, myVertexInfoVKal);
181 if(sc.isFailure()){
182 ATH_MSG_ERROR("#BTAG# error filling variables from VxSecVKalVertexInfo " << m_VxSecVertexInfoName.key());
183 return sc;
184 }
185 }
186 else {
187 ATH_MSG_DEBUG("#BTAG# dynamic_cast failed for a non-nullptr myVertexInfo!");
188 }
189 }
190 h_jetSVLinkName(*jetToTag) = SVertexLinks;
191 }
192 }
193
194 else if(basename == "JetFitter" || basename == "JetFitterFlip") {
195 SG::WriteDecorHandle<xAOD::JetContainer,std::vector<ElementLink< xAOD::BTagVertexContainer> > > h_jetSVLinkName(m_jetSVLinkName, ctx);
196 for (const xAOD::Jet* jetToTag : *h_JetCollectionName) {
197 const Trk::VxSecVertexInfo* myVertexInfo = *infoSVIter++;
198 std::vector< ElementLink< xAOD::BTagVertexContainer > > JFVtxLinks;
199 if(myVertexInfo != nullptr) {
200 if(const Trk::VxJetFitterVertexInfo* myVertexInfoJetFitter = dynamic_cast<const Trk::VxJetFitterVertexInfo*>(myVertexInfo)) {
201 ATH_MSG_DEBUG("#BTAG# Found VxJetFitterVertexInfo information");
202 StatusCode sc = createJFContainer(&(*h_BTagJFVtxCollectionName), &JFVtxLinks, myVertexInfoJetFitter, theTrackParticleContainer);
203 if(sc.isFailure()){
204 ATH_MSG_ERROR("#BTAG# error filling variables from VxJetFitterVertexInfo " << m_VxSecVertexInfoName.key());
205 return sc;
206 }
207 }
208 else {
209 ATH_MSG_DEBUG("#BTAG# dynamic_cast failed for a non-nullptr myVertexInfo!");
210 }
211 }
212 h_jetSVLinkName(*jetToTag) = JFVtxLinks;
213 }
214 }
215
216 else {
217 ATH_MSG_ERROR("#BTAG# JetSecVertexingAlg encounters an unknown basename: " << basename);
218 }
219
220 return StatusCode::SUCCESS;
221 }
#define ATH_CHECK
Evaluate an expression and check for errors.
static Double_t sc
SG::ReadHandleKey< Trk::VxSecVertexInfoContainer > m_VxSecVertexInfoName
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_TrackCollectionName
SG::ReadHandleKey< xAOD::VertexContainer > m_VertexCollectionName
SG::WriteHandleKey< xAOD::BTagVertexContainer > m_BTagJFVtxCollectionName
SG::WriteHandleKey< xAOD::VertexContainer > m_BTagSVCollectionName
SG::ReadHandleKey< xAOD::JetContainer > m_JetCollectionName
StatusCode createSecVkalContainer(xAOD::VertexContainer *, std::vector< ElementLink< xAOD::VertexContainer > > *, const Trk::VxSecVKalVertexInfo *) const
SG::WriteDecorHandleKey< xAOD::JetContainer > m_jetSVLinkName
StatusCode createJFContainer(xAOD::BTagVertexContainer *, std::vector< ElementLink< xAOD::BTagVertexContainer > > *, const Trk::VxJetFitterVertexInfo *, const xAOD::TrackParticleContainer *) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
::StatusCode StatusCode
StatusCode definition for legacy code.
@ PriVtx
Primary vertex.
Jet_v1 Jet
Definition of the current "jet version".
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
std::string basename(std::string name)
Definition utils.cxx:207

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
97}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ initialize()

StatusCode Analysis::JetSecVertexingAlg::initialize ( )
overridevirtual

Main routines specific to an ATHENA algorithm.

Definition at line 39 of file JetSecVertexingAlg.cxx.

40 {
41 // This will check that the properties were initialized properly
42 // by job configuration.
43 ATH_CHECK( m_JetCollectionName.initialize() );
44 ATH_CHECK( m_TrackCollectionName.initialize() );
45 ATH_CHECK( m_VxSecVertexInfoName.initialize() );
46 ATH_CHECK( m_VertexCollectionName.initialize() );
48 ATH_CHECK( m_BTagJFVtxCollectionName.initialize( (m_secVertexFinderBaseName == "JetFitter") || (m_secVertexFinderBaseName == "JetFitterFlip") ) );
49 ATH_CHECK( m_jetSVLinkName.initialize() );
50
51 /* ----------------------------------------------------------------------------------- */
52 /* RETRIEVE SERVICES FROM STOREGATE */
53 /* ----------------------------------------------------------------------------------- */
54
55 if ( m_MSVvarFactory.retrieve().isFailure() ) {
56 ATH_MSG_ERROR("#BTAG# Failed to retrieve " << m_MSVvarFactory);
57 } else {
58 ATH_MSG_DEBUG("#BTAG# Retrieved " << m_MSVvarFactory);
59 }
60
61 return StatusCode::SUCCESS;
62 }

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

77{
78 return BaseAlg::sysExecute (ctx);
79}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

107 {
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_BTagJFVtxCollectionName

SG::WriteHandleKey<xAOD::BTagVertexContainer> Analysis::JetSecVertexingAlg::m_BTagJFVtxCollectionName {this, "BTagJFVtxCollectionName", "", "Output BTagging Jet Fitter container"}
private

Definition at line 67 of file JetSecVertexingAlg.h.

67{this, "BTagJFVtxCollectionName", "", "Output BTagging Jet Fitter container"};

◆ m_BTagSVCollectionName

SG::WriteHandleKey<xAOD::VertexContainer> Analysis::JetSecVertexingAlg::m_BTagSVCollectionName {this, "BTagSVCollectionName", "", "Output BTagging secondary vertex container"}
private

Definition at line 65 of file JetSecVertexingAlg.h.

65{this, "BTagSVCollectionName", "", "Output BTagging secondary vertex container"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_JetCollectionName

SG::ReadHandleKey<xAOD::JetContainer > Analysis::JetSecVertexingAlg::m_JetCollectionName {this, "JetCollectionName", "", "Input jet container"}
private

Definition at line 61 of file JetSecVertexingAlg.h.

61{this, "JetCollectionName", "", "Input jet container"};

◆ m_jetSVLinkName

SG::WriteDecorHandleKey<xAOD::JetContainer> Analysis::JetSecVertexingAlg::m_jetSVLinkName { this, "JetSecVtxLinkName", "", "Element Link vector from jet to Vertex container"}
private

Definition at line 66 of file JetSecVertexingAlg.h.

66{ this, "JetSecVtxLinkName", "", "Element Link vector from jet to Vertex container"};

◆ m_MSVvarFactory

ToolHandle<IMSVVariablesFactory> Analysis::JetSecVertexingAlg::m_MSVvarFactory
private

Definition at line 57 of file JetSecVertexingAlg.h.

◆ m_secVertexFinderBaseName

std::string Analysis::JetSecVertexingAlg::m_secVertexFinderBaseName
private

Definition at line 59 of file JetSecVertexingAlg.h.

◆ m_TrackCollectionName

SG::ReadHandleKey<xAOD::TrackParticleContainer > Analysis::JetSecVertexingAlg::m_TrackCollectionName {this, "TrackCollectionName", "", "Input track container"}
private

Definition at line 62 of file JetSecVertexingAlg.h.

62{this, "TrackCollectionName", "", "Input track container"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_VertexCollectionName

SG::ReadHandleKey<xAOD::VertexContainer> Analysis::JetSecVertexingAlg::m_VertexCollectionName {this, "vxPrimaryCollectionName", "", "Input primary vertex container"}
private

Definition at line 63 of file JetSecVertexingAlg.h.

63{this, "vxPrimaryCollectionName", "", "Input primary vertex container"};

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_VxSecVertexInfoName

SG::ReadHandleKey<Trk::VxSecVertexInfoContainer> Analysis::JetSecVertexingAlg::m_VxSecVertexInfoName {this, "BTagVxSecVertexInfoName", "", "Input VxSecVertexInfo container"}
private

Definition at line 64 of file JetSecVertexingAlg.h.

64{this, "BTagVxSecVertexInfoName", "", "Input VxSecVertexInfo container"};

The documentation for this class was generated from the following files: