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

#include <MSVVariablesFactory.h>

Inheritance diagram for Analysis::MSVVariablesFactory:
Collaboration diagram for Analysis::MSVVariablesFactory:

Public Member Functions

 MSVVariablesFactory (const std::string &name, const std::string &n, const IInterface *p)
virtual ~MSVVariablesFactory ()=default
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual StatusCode fillMSVVariables (const xAOD::Jet &, xAOD::BTagging *BTag, const Trk::VxSecVKalVertexInfo *myInfoVKal, xAOD::VertexContainer *btagVertex, const xAOD::Vertex &PV, std::string basename) const override
virtual StatusCode createMSVContainer (const xAOD::Jet &, const Trk::VxSecVKalVertexInfo *myInfoVKal, xAOD::VertexContainer *btagVertex, const xAOD::Vertex &PV) const override
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 sysInitialize () override
 Perform system initialization for an algorithm.
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

Static Public Member Functions

static const InterfaceID & interfaceID ()

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< StoreGateSvc > StoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

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 23 of file MSVVariablesFactory.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 376 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ MSVVariablesFactory()

Analysis::MSVVariablesFactory::MSVVariablesFactory ( const std::string & name,
const std::string & n,
const IInterface * p )

Definition at line 40 of file MSVVariablesFactory.cxx.

42 :
43 AthAlgTool(name, n,p)
44 {
45 declareInterface<IMSVVariablesFactory>(this);
46 }
AthAlgTool()
Default constructor:

◆ ~MSVVariablesFactory()

virtual Analysis::MSVVariablesFactory::~MSVVariablesFactory ( )
virtualdefault

Member Function Documentation

◆ createMSVContainer()

StatusCode Analysis::MSVVariablesFactory::createMSVContainer ( const xAOD::Jet & myJet,
const Trk::VxSecVKalVertexInfo * myInfoVKal,
xAOD::VertexContainer * btagVertex,
const xAOD::Vertex & PV ) const
overridevirtual

Implements Analysis::IMSVVariablesFactory.

Definition at line 58 of file MSVVariablesFactory.cxx.

60 {
61
62 Amg::Vector3D jet_V3(myJet.p4().Px(), myJet.p4().Py(), myJet.p4().Pz());
63 float jetenergy=0.;
64 const xAOD::Vertex* priVtx = &PrimaryVtx;
65 std::vector< ElementLink< xAOD::VertexContainer > > MSVVertexLinks;
66 const std::vector<xAOD::Vertex*> myVertices = myVertexInfoVKal->vertices();
67 if(myVertices.empty()){
68 ATH_MSG_DEBUG("#BTAG# no MSV vertices...fill default values only... ");
70 VertexContainer->push_back(vertex);
78 return StatusCode::SUCCESS;
79 }
80
81 jetenergy = myVertexInfoVKal->energyTrkInJet();
82
83 for (const auto& vertex : myVertexInfoVKal->vertices()){
84 VertexContainer->push_back(vertex);
85 //additional info per vertex
86 double sumpx = 0.0;
87 double sumpy = 0.0;
88 double sumpz = 0.0;
89 double sume = 0.0;
90 const std::vector<ElementLink<xAOD::TrackParticleContainer> > myTrackLinks = vertex->trackParticleLinks();
91 if (myTrackLinks.empty()) {
92 ATH_MSG_WARNING("#BTAG# No Track Links attached to the track at the sec vertex... ");
93 }
94 int npsec = 0;
95 const std::vector<Trk::VxTrackAtVertex> myTracks=vertex->vxTrackAtVertex();
96 if (!myTracks.empty()) {
97 npsec=myTracks.size();
98 for (const auto& track : myTracks) {
99 const Trk::Perigee* perigee = dynamic_cast<const Trk::Perigee*>(track.perigeeAtVertex());
100 if(perigee){
101 sumpx += perigee->momentum().x();
102 sumpy += perigee->momentum().y();
103 sumpz += perigee->momentum().z();
104 sume += std::hypot(perigee->momentum().mag(), ParticleConstants::chargedPionMassInMeV);
105 }else{
106 ATH_MSG_WARNING("#BTAG# perigee for VxTrackAtVertex not found");
107 }
108 }
109 }
110
111 CLHEP::HepLorentzVector vtxp4(sumpx,sumpy,sumpz,sume);
112 float efrac = (jetenergy>0) ? vtxp4.e()/jetenergy : 0;
113 xAOD::SecVtxHelper::setVertexMass(vertex, vtxp4.m());
115 xAOD::SecVtxHelper::setVtxNtrk(vertex, npsec);
116 xAOD::SecVtxHelper::setVtxpt(vertex, vtxp4.perp());
117 xAOD::SecVtxHelper::setVtxeta(vertex, vtxp4.eta());
118 xAOD::SecVtxHelper::setVtxphi(vertex, vtxp4.phi());
119
120 ATH_MSG_DEBUG("#BTAG# mass per vertex = "<<vtxp4.m());
121 double localdistnrm = 0;
122 std::vector<const xAOD::Vertex*> vecVtxHolder;
123 vecVtxHolder.push_back(vertex);
124
125 if (priVtx) {
126 ATH_MSG_DEBUG("Factory PVX x = " << priVtx->x() << " y = " << priVtx->y() << " z = " << priVtx->z());
127 localdistnrm = get3DSignificance(*priVtx, vecVtxHolder, jet_V3);
128 } else {
129 ATH_MSG_WARNING("#BTAG# Tagging requested, but no primary vertex supplied.");
130 }
131 xAOD::SecVtxHelper::setVtxnormDist(vertex, localdistnrm);
132 //track links,
133 vertex->setTrackParticleLinks(myTrackLinks);
134
135 } //end loop vertexcontainer
136
137 return StatusCode::SUCCESS;
138 }
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
VertexContainer_v1 VertexContainer
Definition of the current "Vertex container version".
const Amg::Vector3D & momentum() const
Access method for the momentum.
virtual FourMom_t p4() const
The full 4-momentum of the particle.
Definition Jet_v1.cxx:71
float z() const
Returns the z position.
float y() const
Returns the y position.
float x() const
Returns the x position.
Eigen::Matrix< double, 3, 1 > Vector3D
double get3DSignificance(const xAOD::Vertex &priVertex, const std::vector< const xAOD::Vertex * > &secVertex, const Amg::Vector3D &jetDirection)
Signed decay length significance of the weighted mean of the secondary vertices with respect to the p...
constexpr double chargedPionMassInMeV
the mass of the charged pion (in MeV)
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
void setVtxeta(xAOD::Vertex *, float value)
void setVertexMass(xAOD::Vertex *, float value)
void setVtxNtrk(xAOD::Vertex *, int value)
void setVtxpt(xAOD::Vertex *, float value)
void setVtxnormDist(xAOD::Vertex *, float value)
void setEnergyFraction(xAOD::Vertex *, float value)
void setVtxphi(xAOD::Vertex *, float value)
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::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 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::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< AlgTool > >::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< AlgTool > >::evtStore ( )
inlineinherited

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

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::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

◆ fillMSVVariables()

StatusCode Analysis::MSVVariablesFactory::fillMSVVariables ( const xAOD::Jet & myJet,
xAOD::BTagging * BTag,
const Trk::VxSecVKalVertexInfo * myInfoVKal,
xAOD::VertexContainer * btagVertex,
const xAOD::Vertex & PV,
std::string basename ) const
overridevirtual

Implements Analysis::IMSVVariablesFactory.

Definition at line 140 of file MSVVariablesFactory.cxx.

144 {
145
146 Amg::Vector3D jet_V3(myJet.p4().Px(), myJet.p4().Py(), myJet.p4().Pz());
147 int nvsec = 0;
148 float jetenergy = 0.;
149 int n2t = 0;
150 float distnrm = 0.;
151 const xAOD::Vertex* priVtx = &PrimaryVtx;
152 std::vector< ElementLink< xAOD::VertexContainer > > MSVVertexLinks;
153 const std::vector<xAOD::Vertex*> myVertices = myVertexInfoVKal->vertices();
154 if(myVertices.empty()){
155 ATH_MSG_DEBUG("#BTAG# no MSV vertices...fill default values only... ");
156 BTag->setVariable<int>(basename, "N2Tpair", n2t);
157 BTag->setVariable<float>(basename, "energyTrkInJet", jetenergy);
158 BTag->setVariable<int>(basename, "nvsec", nvsec);
159 BTag->setVariable<float>(basename, "normdist", distnrm);
160 BTag->setVariable<std::vector<ElementLink<xAOD::VertexContainer> > >(basename, "vertices", MSVVertexLinks);
161 BTag->setDynVxELName(basename, "vertices");
163 VertexContainer->push_back(vertex);
167 xAOD::SecVtxHelper::setVtxpt(vertex, -9.);
171 return StatusCode::SUCCESS;
172 }
173
174 jetenergy = myVertexInfoVKal->energyTrkInJet();
175 n2t = myVertexInfoVKal->n2trackvertices();
176 BTag->setVariable<int>(basename, "N2Tpair", n2t);
177 BTag->setVariable<float>(basename, "energyTrkInJet", jetenergy);
178
179 std::vector<const xAOD::Vertex*> vecVertices;
180 for (const auto& vertex : myVertexInfoVKal->vertices()) {
181 VertexContainer->push_back(vertex);
182 //additional info per vertex
183 vecVertices.push_back(vertex);
184 double sumpx = 0.0;
185 double sumpy = 0.0;
186 double sumpz = 0.0;
187 double sume = 0.0;
188 const std::vector<ElementLink<xAOD::TrackParticleContainer> > myTrackLinks = vertex->trackParticleLinks();
189 if (myTrackLinks.empty()) {
190 ATH_MSG_WARNING("#BTAG# No Track Links attached to the track at the sec vertex... ");
191 }
192 int npsec = 0;
193 const std::vector<Trk::VxTrackAtVertex> myTracks=vertex->vxTrackAtVertex();
194 if (!myTracks.empty()) {
195 npsec=myTracks.size();
196 for (const auto& track : myTracks) {
197 const Trk::Perigee* perigee = dynamic_cast<const Trk::Perigee*>(track.perigeeAtVertex());
198 if(perigee){
199 sumpx += perigee->momentum().x();
200 sumpy += perigee->momentum().y();
201 sumpz += perigee->momentum().z();
202 sume += std::hypot(perigee->momentum().mag(), ParticleConstants::chargedPionMassInMeV);
203 }else{
204 ATH_MSG_WARNING("#BTAG# perigee for VxTrackAtVertex not found");
205 }
206 }
207 }
208
209 CLHEP::HepLorentzVector vtxp4(sumpx,sumpy,sumpz,sume);
210 float efrac = (jetenergy>0) ? vtxp4.e()/jetenergy : 0;
211 xAOD::SecVtxHelper::setVertexMass(vertex, vtxp4.m());
213 xAOD::SecVtxHelper::setVtxNtrk(vertex, npsec);
214 xAOD::SecVtxHelper::setVtxpt(vertex, vtxp4.perp());
215 xAOD::SecVtxHelper::setVtxeta(vertex, vtxp4.eta());
216 xAOD::SecVtxHelper::setVtxphi(vertex, vtxp4.phi());
217
218 ATH_MSG_DEBUG("#BTAG# mass per vertex = "<<vtxp4.m());
219 double localdistnrm = 0;
220 std::vector<const xAOD::Vertex*> vecVtxHolder;
221 vecVtxHolder.push_back(vertex);
222
223
224 if (priVtx) {
225 ATH_MSG_DEBUG("Factory PVX x = " << priVtx->x() << " y = " << priVtx->y() << " z = " << priVtx->z());
226 localdistnrm = get3DSignificance(*priVtx, vecVtxHolder, jet_V3);
227 } else {
228 ATH_MSG_WARNING("#BTAG# Tagging requested, but no primary vertex supplied.");
229 }
230 xAOD::SecVtxHelper::setVtxnormDist(vertex, localdistnrm);
231 //track links,
232 vertex->setTrackParticleLinks(myTrackLinks);
233
234 ElementLink< xAOD::VertexContainer> linkBTagVertex;
235 linkBTagVertex.toContainedElement(*VertexContainer, vertex);
236 MSVVertexLinks.push_back(linkBTagVertex);
237 } //end loop vertexcontainer
238
239 BTag->setVariable<std::vector<ElementLink<xAOD::VertexContainer> > >(basename, "vertices", MSVVertexLinks);
240 BTag->setDynVxELName(basename, "vertices");
241
242 if (priVtx) {
243 distnrm = get3DSignificance(*priVtx, vecVertices, jet_V3);
244 } else {
245 ATH_MSG_WARNING("#BTAG# Tagging requested, but no primary vertex supplied.");
246 distnrm=0.;
247 }
248 nvsec = vecVertices.size();
249 BTag->setVariable<int>(basename, "nvsec", nvsec);
250 BTag->setVariable<float>(basename, "normdist", distnrm);
251
252 return StatusCode::SUCCESS;
253
254 }
@ BTag
The object is a b-tagging object.
Definition ObjectType.h:60
std::string basename(std::string name)
Definition utils.cxx:207

◆ finalize()

StatusCode Analysis::MSVVariablesFactory::finalize ( )
overridevirtual

Implements Analysis::IMSVVariablesFactory.

Definition at line 53 of file MSVVariablesFactory.cxx.

53 {
54 ATH_MSG_DEBUG(" Finalization of MSVVariablesFactory succesfull");
55 return StatusCode::SUCCESS;
56 }

◆ initialize()

StatusCode Analysis::MSVVariablesFactory::initialize ( )
overridevirtual

Implements Analysis::IMSVVariablesFactory.

Definition at line 48 of file MSVVariablesFactory.cxx.

48 {
49 ATH_MSG_DEBUG(" Initialization of MSVVariablesFactory succesfull");
50 return StatusCode::SUCCESS;
51 }

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::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.

◆ interfaceID()

const InterfaceID & Analysis::IMSVVariablesFactory::interfaceID ( )
inlinestaticinherited

Definition at line 49 of file IMSVVariablesFactory.h.

49{ return IID_IMSVVariablesFactory; };
static const InterfaceID IID_IMSVVariablesFactory("Analysis::IMSVVariablesFactory", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< AlgTool >::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< AlgTool > >::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< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 368 of file AthCommonDataStore.h.

369 {
370 h.renounce();
372 }
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< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 352 of file AthCommonDataStore.h.

352 {
354 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, and AthCheckedComponent<::AthAlgTool >.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::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< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 298 of file AthCommonDataStore.h.

298 {
299 for (auto &a : m_vhka) {
301 for (auto k : keys) {
302 k->setOwner(this);
303 }
304 }
305 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 381 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 378 of file AthCommonDataStore.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 387 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 386 of file AthCommonDataStore.h.


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