60 unsigned int nMatches(0);
63 const unsigned int nCaloObj = data.caloObjects->size();
66 for (
auto *thisEfRecTrack : data.tracks)
69 if (!thisEfRecTrack->hasBin()) {
70 std::unique_ptr<eflowCaloObject> thisEflowCaloObject = std::make_unique<eflowCaloObject>();
71 thisEflowCaloObject->addTrack(thisEfRecTrack);
72 data.caloObjects->push_back(std::move(thisEflowCaloObject));
76 if (msgLvl(MSG::DEBUG))
79 ATH_MSG_DEBUG(
"Matching track with e,pt, eta and phi " << track->e() <<
", " << track->pt() <<
", " << track->eta() <<
" and " << track->phi());
82 std::vector<eflowTrackClusterLink*> bestClusters;
83 std::vector<float> deltaRPrime;
89 const static SG::AuxElement::Accessor<TruthLink> truthLinkAccessor(
"truthParticleLink");
91 TruthLink truthLink = truthLinkAccessor(*(thisEfRecTrack->getTrack()));
94 if (truthLink.
isValid()) trackMatchedTruthParticle = *truthLink;
96 if (trackMatchedTruthParticle){
100 if (!caloClusterReadDecorHandleNLeadingTruthParticles.isValid()){
101 ATH_MSG_WARNING(
"Failed to retrieve CaloCluster decoration with key " << caloClusterReadDecorHandleNLeadingTruthParticles.key());
104 for (
auto * thisCluster : data.clusters){
109 std::string::size_type pos = decorHandleName.find(
".");
110 std::string decorName = decorHandleName.substr(pos+1);
112 SG::AuxElement::Accessor< std::vector< std::pair<unsigned int, double> > > accessor(decorName);
114 std::vector<std::pair<unsigned int, double > > uniqueIDTruthPairs = accessor(*(thisCluster->getCluster()));
116 for (
auto &uniqueIDTruthPair : uniqueIDTruthPairs){
117 if (uniqueIDTruthPair.first == uniqueID){
119 bestClusters.push_back(thisLink);
126 else ATH_MSG_VERBOSE(
"Track with pt, eta and phi " << thisEfRecTrack->getTrack()->pt() <<
", " << thisEfRecTrack->getTrack()->eta() <<
" and " << thisEfRecTrack->getTrack()->phi() <<
" does not have a valid truth pointer");
130 if (bestClusters.empty())
continue;
132 if (msgLvl(MSG::DEBUG))
134 for (
auto *thisClusterLink : bestClusters ) {
136 ATH_MSG_DEBUG(
"Matched this track to cluster with e,pt, eta and phi " << thisCluster->
e() <<
", " << thisCluster->
pt() <<
", " << thisCluster->
eta() <<
" and " << thisCluster->
phi());
143 for (
auto *trkClusLink : bestClusters){
149 if (std::find(data.clusters.begin(), data.clusters.end(), trkClusLink->getCluster()) == data.clusters.end()) {
155 thisEfRecTrack->addClusterMatch(trackClusterLink);
162 std::vector<eflowRecCluster *> clusters(data.clusters.begin(), data.clusters.end());
165 ATH_MSG_DEBUG(
"Created " << nCaloObjects <<
" eflowCaloObjects.");
166 if (msgLvl(MSG::DEBUG)){
167 for (
auto thisEFlowCaloObject : *(data.caloObjects)){
168 ATH_MSG_DEBUG(
"This eflowCaloObject has " << thisEFlowCaloObject->nTracks() <<
" tracks and " << thisEFlowCaloObject->nClusters() <<
" clusters ");
169 for (
unsigned int count = 0;
count < thisEFlowCaloObject->nTracks();
count++){
171 ATH_MSG_DEBUG(
"Have track with e, pt, eta and phi of " << thisTrack->
e() <<
", " << thisTrack->
pt() <<
", " << thisTrack->
eta() <<
" and " << thisTrack->
phi());
173 for (
unsigned int count = 0;
count < thisEFlowCaloObject->nClusters();
count++){
175 ATH_MSG_DEBUG(
"Have cluster with e, pt, eta and phi of " << thisCluster->
e() <<
", " << thisCluster->
pt() <<
", " << thisCluster->
eta() <<
" and " << thisCluster->
phi());
181 else return nCaloObj;
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
virtual double e() const override final
The total energy of the particle.