Commit c70ac557 authored by Mark Hodgkinson's avatar Mark Hodgkinson
Browse files

Add creation of FE and set its track links + charge.

parent 9542b245
//eflowRec includes
#include "eflowRec/PFChargedFlowElementCreatorAlgorithm.h"
#include "eflowRec/eflowRecTrack.h"
//EDM includes
#include "xAODBase/IParticleContainer.h"
#include "xAODPFlow/FlowElementAuxContainer.h"
PFChargedFlowElementCreatorAlgorithm::PFChargedFlowElementCreatorAlgorithm(const std::string& name, ISvcLocator* pSvcLocator) :
......@@ -37,4 +41,33 @@ StatusCode PFChargedFlowElementCreatorAlgorithm::finalize(){ return StatusCode::
void PFChargedFlowElementCreatorAlgorithm::createChargedFlowElements(const eflowCaloObject& energyFlowCaloObject, bool addClusters, SG::WriteHandle<xAOD::FlowElementContainer>& chargedFlowElementContainerWriteHandle) const {
/* Loop over all tracks in the eflowCaloObject */
int nTracks = energyFlowCaloObject.nTracks();
for (int iTrack = 0; iTrack < nTracks; ++iTrack) {
eflowRecTrack* efRecTrack = energyFlowCaloObject.efRecTrack(iTrack);
/* Skip tracks that haven't been subtracted */
if (false == m_eOverPMode){
if (!efRecTrack->isSubtracted()){ continue; }
}
/* Create new xAOD::FlowElement */
xAOD::FlowElement* thisFE = new xAOD::FlowElement();
chargedFlowElementContainerWriteHandle->push_back(thisFE);
/* Get the track elementLink and add it to the xAOD:FE.
Note we first have to convert it to an IParticle ElementLink. */
ElementLink<xAOD::TrackParticleContainer> theTrackLink = efRecTrack->getTrackElemLink();
ElementLink< xAOD::IParticleContainer > theIParticleTrackLink;
theIParticleTrackLink.resetWithKeyAndIndex(theTrackLink.persKey(),theTrackLink.persIndex() );
std::vector<ElementLink<xAOD::IParticleContainer> > vecIParticleTrackLinkContainer;
vecIParticleTrackLinkContainer.push_back(theIParticleTrackLink);
thisFE->setChargedObjectLinks(vecIParticleTrackLinkContainer);
//Now set the charge
thisFE->setCharge(efRecTrack->getTrack()->charge());
}//loop over eflowRecTracks
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment