46 {
47
48
50 ElementLink<xAOD::TrackParticleContainer>>
52
53
54 static const SG::AuxElement::Accessor<int> acc_gsfCaloStatus("gsfCaloStatus");
55 static const SG::AuxElement::Accessor<float> acc_gsfChi2oNDF(
56 "gsfChiSquareOverNDOF");
57 static const SG::AuxElement::Accessor<float> acc_gsfCaloChi2oNDF(
58 "gsfCaloChiSquareOverNDOF");
59 static const SG::AuxElement::Accessor<ElementLink<xAOD::ElectronContainer>>
60 acc_usedElectronLink("usedElectronLink");
61 static const SG::AuxElement::ConstAccessor<
62 ElementLink<xAOD::TrackParticleContainer>>
63 read_originalTP("originalTrackParticle");
64 static const SG::AuxElement::Accessor<
65 ElementLink<xAOD::TrackParticleContainer>>
66 write_originalTP("originalTrackParticle");
67
68
69 SG::WriteHandle<xAOD::TrackParticleContainer> finalTrkPartContainer(
71
73 std::make_unique<xAOD::TrackParticleContainer>(),
74 std::make_unique<xAOD::TrackParticleAuxContainer>()));
75
77
78
83
86 if (!electronTP) {
88 << " TrackParticle!");
90 continue;
91 }
92
93
95 int gsfCaloStatus = -1;
96 float gsfChiSquareOverNDOF = -1;
97 float gsfCaloChiSquareOverNDOF = -1;
98
100
103
112
113 const Trk::Track*
track = electronTP->
track();
114
115
117
119 gsfChiSquareOverNDOF = electronTrackQuality->
chiSquared() /
120 electronTrackQuality->numberDoF();
121
122 auto electronTrackRefit = std::make_unique<Trk::Track>();
123 IegammaTrkRefitterTool::Cache
cache{};
124
127
128 if (
sc == StatusCode::SUCCESS) {
129 electronTrackRefit.reset(
cache.refittedTrack.release());
130
132
133 gsfCaloStatus = 1;
135
138 ctx, *electronTrackRefit, cPtrTrkPart, electronTrackVertex,
140 if (electronTPRefit) {
142 auto electronTrackRefitQuality = electronTrackRefit->fitQuality();
143 gsfCaloChiSquareOverNDOF = electronTrackRefitQuality->chiSquared() /
144 electronTrackRefitQuality->numberDoF();
145 } else {
147 "Can't create a new xAOD::TrackParticle from the re-fitted "
148 "Trk::Track! Using the original xAOD::TrackParticle!");
149 gsfCaloStatus = 0;
151 }
152 } else {
154 "CALO-improved Trk::Track re-fit failed! Using the original "
155 "xAOD::TrackParticle!");
157 gsfCaloStatus = 0;
158 }
159 } else {
162 << " has a valid track particle but is a TRT-only track");
163 gsfCaloStatus = 0;
165 }
166
167 if (gsfCaloStatus != 1) {
170 *electronTPRefit = *electronTP;
171 }
172
173 acc_gsfCaloStatus(*electronTPRefit) = gsfCaloStatus;
174 acc_gsfChi2oNDF(*electronTPRefit) = gsfChiSquareOverNDOF;
175 acc_gsfCaloChi2oNDF(*electronTPRefit) = gsfCaloChiSquareOverNDOF;
176
178
179
180 ElementLink<xAOD::TrackParticleContainer> linkToRefittedTrackParticle(
181 electronTPRefit, *cPtrTrkPart);
182 dec_gsfCaloTrackLink(*electron) = linkToRefittedTrackParticle;
183
184
185 ElementLink<xAOD::ElectronContainer> linkToElectron;
187 acc_usedElectronLink(*electronTPRefit) = linkToElectron;
188
189 ElementLink<xAOD::TrackParticleContainer> linkToOriginal;
190 if (read_originalTP.isAvailable(*electronTP)) {
191 linkToOriginal = read_originalTP(*electronTP);
192 }
193 write_originalTP(*electronTPRefit) = linkToOriginal;
194 }
195
197 return StatusCode::SUCCESS;
198}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
xAOD::ElectronContainer * electronContainer
value_type push_back(value_type pElem)
Add an element to the end of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
ToolHandle< Trk::ITrackParticleCreatorTool > m_particleCreatorTool
Tool to create track particle.
std::atomic< unsigned int > m_noTP
std::atomic< unsigned int > m_noRefTP
SG::WriteDecorHandleKey< xAOD::ElectronContainer > m_gsfCaloTrackLinkKey
std::atomic< unsigned int > m_allElectrons
Counters.
PublicToolHandle< Trk::IExtendedTrackSummaryTool > m_trackSummaryTool
std::atomic< unsigned int > m_successfulFits
Gaudi::Property< int > m_minNSiHits
Minimum number of silicon hits on track before it is allowed to be refitted.
SG::WriteHandleKey< xAOD::TrackParticleContainer > m_OutputTrkPartContainerKey
std::atomic< unsigned int > m_allNewTP
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronCollectionKey
std::atomic< unsigned int > m_failedFits
ToolHandle< IegammaTrkRefitterTool > m_trkRefitTool
The track refitter.
Gaudi::Property< bool > m_isAOD
std::atomic< unsigned int > m_onlyTRT
void copyInfo(const xAOD::TrackParticle &original, xAOD::TrackParticle &created, bool isRefitted) const
Copy TrackParticle info from the original TP.
bool toIndexedElement(BaseConstReference container, index_type index)
Set link to point to given index (slower).
bool isValid() const
Check if the element can be found.
double chiSquared() const
returns the of the overall track fit
const FitQuality * fitQuality() const
return a pointer to the fit quality const-overload
void setTrackLink(const ElementLink< TrackCollection > &track)
Set the link to the original track.
const ElementLink< TrackCollection > & trackLink() const
Returns a link (which can be invalid) to the Trk::Track which was used to make this TrackParticle.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
bool summaryValue(uint8_t &value, const SummaryType &information) const
Accessor for TrackSummary values.
::StatusCode StatusCode
StatusCode definition for legacy code.
float nSiHits(const U &p)
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
TrackParticle_v1 TrackParticle
Reference the current persistent version:
Vertex_v1 Vertex
Define the latest version of the vertex class.
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
@ numberOfPixelOutliers
these are the pixel outliers, including the b-layer [unit8_t].
@ numberOfSCTHits
number of hits in SCT [unit8_t].
@ numberOfSCTOutliers
number of SCT outliers [unit8_t].
@ numberOfPixelHits
these are the pixel hits, including the b-layer [unit8_t].