This matches ID tracks and CaloClusters, and then creates eflowCaloObjects.
Add cluster matches needed for pull calculation (in eflowCaloObject::simulateShowers) which is used to determine whether to run the charged shower subtraction or not. / Clusters in both a cone of 0.15 and 0.2 are needed for this. / The clusters in a cone of 0.2 are also used as the matched cluster list for recover split showers mode.
57 {
58
59
60 unsigned int nMatches(0);
61
62
63 const unsigned int nCaloObj =
data.caloObjects->size();
64
65
66 for (
auto *thisEfRecTrack :
data.tracks)
67 {
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));
73 continue;
74 }
75
76 if (msgLvl(MSG::DEBUG))
77 {
80 }
81
82 std::vector<eflowTrackClusterLink*> bestClusters;
83 std::vector<float> deltaRPrime;
84
85
87 typedef ElementLink<xAOD::TruthParticleContainer>
TruthLink;
88
89 const static SG::AuxElement::Accessor<TruthLink> truthLinkAccessor("truthParticleLink");
90
91 TruthLink truthLink = truthLinkAccessor(*(thisEfRecTrack->getTrack()));
92
93
94 if (truthLink.
isValid()) trackMatchedTruthParticle = *truthLink;
95
96 if (trackMatchedTruthParticle){
98
100 if (!caloClusterReadDecorHandleNLeadingTruthParticles.isValid()){
101 ATH_MSG_WARNING(
"Failed to retrieve CaloCluster decoration with key " << caloClusterReadDecorHandleNLeadingTruthParticles.key());
102 }
103
104 for (
auto * thisCluster :
data.clusters){
105
106
107
109 std::string::size_type
pos = decorHandleName.find(
".");
110 std::string decorName = decorHandleName.substr(pos+1);
111
112 SG::AuxElement::Accessor< std::vector< std::pair<unsigned int, double> > >
accessor(decorName);
113
114 std::vector<std::pair<unsigned int, double > > uniqueIDTruthPairs =
accessor(*(thisCluster->getCluster()));
115
116 for (auto &uniqueIDTruthPair : uniqueIDTruthPairs){
117 if (uniqueIDTruthPair.first == uniqueID){
119 bestClusters.push_back(thisLink);
120 break;
121 }
122 }
123 }
124
125 }
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");
127
128
129
130 if (bestClusters.empty()) continue;
131
132 if (msgLvl(MSG::DEBUG))
133 {
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());
137 }
138 }
139
140 nMatches++;
141
142
143 for (auto *trkClusLink : bestClusters){
144
145 eflowRecCluster *thisEFRecCluster = trkClusLink->getCluster();
146
148
149 if (std::find(
data.clusters.begin(),
data.clusters.end(), trkClusLink->getCluster()) ==
data.clusters.end()) {
150 continue;
151 }
152 }
153
155 thisEfRecTrack->addClusterMatch(trackClusterLink);
156
158 }
159 }
160
161
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());
172 }
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());
176 }
177 }
178 }
179
181 else return nCaloObj;
182}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool isValid() const
Check if the element can be found.
static unsigned int makeTrkCluCaloObjects(eflowRecTrackContainer *eflowTrackContainer, eflowRecClusterContainer *eflowClusterContainer, eflowCaloObjectContainer *caloObjectContainer)
void addTrackMatch(eflowTrackClusterLink *trackMatch)
static eflowTrackClusterLink * getInstance(eflowRecTrack *track, eflowRecCluster *cluster, const EventContext &ctx)
virtual double pt() const
The transverse momentum ( ) of the particle (negative for negative-energy clusters).
virtual double eta() const
The pseudorapidity ( ) of the particle.
virtual double e() const
The total energy of the particle.
virtual double phi() const
The azimuthal angle ( ) of the particle.
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.
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
const AccessorWrapper< T > * accessor(xAOD::JetAttribute::AttributeID id)
Returns an attribute accessor corresponding to an AttributeID.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
TruthParticle_v1 TruthParticle
Typedef to implementation.