60 unsigned int nMatches(0);
63 const unsigned int nCaloObj = data.caloObjects->size();
67 const SG::AuxElement::Accessor<TruthLink> truthLinkAccessor(
"truthParticleLink");
68 for (
auto *thisEfRecTrack : data.tracks)
71 if (!thisEfRecTrack->hasBin()) {
72 std::unique_ptr<eflowCaloObject> thisEflowCaloObject = std::make_unique<eflowCaloObject>();
73 thisEflowCaloObject->addTrack(thisEfRecTrack);
74 data.caloObjects->push_back(std::move(thisEflowCaloObject));
78 if (msgLvl(MSG::DEBUG))
81 ATH_MSG_DEBUG(
"Matching track with e,pt, eta and phi " << track->e() <<
", " << track->pt() <<
", " << track->eta() <<
" and " << track->phi());
84 std::vector<eflowTrackClusterLink*> bestClusters;
85 std::vector<float> deltaRPrime;
92 TruthLink truthLink = truthLinkAccessor(*(thisEfRecTrack->getTrack()));
95 if (truthLink.
isValid()) trackMatchedTruthParticle = *truthLink;
97 if (trackMatchedTruthParticle){
101 if (!caloClusterReadDecorHandleNLeadingTruthParticles.isValid()){
102 ATH_MSG_WARNING(
"Failed to retrieve CaloCluster decoration with key " << caloClusterReadDecorHandleNLeadingTruthParticles.key());
105 for (
auto * thisCluster : data.clusters){
110 std::string::size_type pos = decorHandleName.find(
".");
111 std::string decorName = decorHandleName.substr(pos+1);
113 SG::AuxElement::Accessor< std::vector< std::pair<unsigned int, double> > > accessor(decorName);
115 std::vector<std::pair<unsigned int, double > > uniqueIDTruthPairs = accessor(*(thisCluster->getCluster()));
117 for (
auto &uniqueIDTruthPair : uniqueIDTruthPairs){
118 if (uniqueIDTruthPair.first == uniqueID){
120 bestClusters.push_back(thisLink);
127 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");
131 if (bestClusters.empty())
continue;
133 if (msgLvl(MSG::DEBUG))
135 for (
auto *thisClusterLink : bestClusters ) {
137 ATH_MSG_DEBUG(
"Matched this track to cluster with e,pt, eta and phi " << thisCluster->
e() <<
", " << thisCluster->
pt() <<
", " << thisCluster->
eta() <<
" and " << thisCluster->
phi());
144 for (
auto *trkClusLink : bestClusters){
150 if (std::find(data.clusters.begin(), data.clusters.end(), trkClusLink->getCluster()) == data.clusters.end()) {
156 thisEfRecTrack->addClusterMatch(trackClusterLink);
163 std::vector<eflowRecCluster *> clusters(data.clusters.begin(), data.clusters.end());
166 ATH_MSG_DEBUG(
"Created " << nCaloObjects <<
" eflowCaloObjects.");
167 if (msgLvl(MSG::DEBUG)){
168 for (
auto thisEFlowCaloObject : *(data.caloObjects)){
169 ATH_MSG_DEBUG(
"This eflowCaloObject has " << thisEFlowCaloObject->nTracks() <<
" tracks and " << thisEFlowCaloObject->nClusters() <<
" clusters ");
170 for (
unsigned int count = 0;
count < thisEFlowCaloObject->nTracks();
count++){
172 ATH_MSG_DEBUG(
"Have track with e, pt, eta and phi of " << thisTrack->
e() <<
", " << thisTrack->
pt() <<
", " << thisTrack->
eta() <<
" and " << thisTrack->
phi());
174 for (
unsigned int count = 0;
count < thisEFlowCaloObject->nClusters();
count++){
176 ATH_MSG_DEBUG(
"Have cluster with e, pt, eta and phi of " << thisCluster->
e() <<
", " << thisCluster->
pt() <<
", " << thisCluster->
eta() <<
" and " << thisCluster->
phi());
182 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.