ATLAS Offline Software
Loading...
Searching...
No Matches
RefitSiOnlyTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6// ================================================
7// RefitSiOnly
8// ================================================
9//
10// RefitSiOnlyTool.cxx
11// Source file for RefitSiOnlyTool
12//
13// namespace InDetAlignment
14//
15// AlgTool to create refitted tracks with only silicon hits present
16
18
19#include "Identifier/Identifier.h"
21
22//Track-things
23#include "TrkTrack/Track.h"
28
30
32
33#include "RefitSiOnlyTool.h"
34
35namespace InDetAlignment {
36
37 RefitSiOnlyTool::RefitSiOnlyTool (const std::string& type, const std::string& name, const IInterface* parent):
38 AthAlgTool(type,name,parent),
39 m_idHelper{},
40 m_ITrkFitter("Trk::KalmanFitter"),
41 m_comPar(nullptr),
42 m_ParticleHypothesis(Trk::nonInteracting),
44 {
45 declareInterface<ICollectionProcessor>(this);
46 declareProperty("OutlierRemoval" , m_OutlierRemoval = true);
47 declareProperty("FitterTool" , m_ITrkFitter);
48 declareProperty("ParticleNumber" , m_ParticleNumber = 2);
49 declareProperty("Cosmic" , m_doCosmic = false);
50 declareProperty("StripPixelHits" , m_stripPixelHits = false);
51 declareProperty("StripSCTHits" , m_stripSCTHits = false);
52 declareProperty("StripTRTHits" , m_stripTRTHits = true);
53 }
54 //_________________________________________________________________________________________
55
56 //destructor
58 //_________________________________________________________________________________________
59
61 {
62 StatusCode sc;
63 ATH_MSG_DEBUG( "Initialize() of RefitSiOnlyTool" );
64
65 // make for cosmic tracks new reference point
66 Amg::Vector3D refGP(0.,15000.,0.);
68
69 //ID Helper
70 ATH_CHECK (detStore()->retrieve(m_idHelper,"AtlasID"));
71
72 //Fitter
73 ATH_CHECK(m_ITrkFitter.retrieve());
74
82
83 if (msgLvl(MSG::DEBUG)) {
84 msg(MSG::DEBUG) << "ParticleNumber: " << m_ParticleNumber << endmsg;
85 msg(MSG::DEBUG) << "ParticleHypothesis: " << m_ParticleHypothesis << endmsg;
86 msg(MSG::DEBUG) << "Initialize() of RefitSiOnlyTool successful" << endmsg;
87 }
88
89 return StatusCode::SUCCESS;
90 }
91 //_________________________________________________________________________________________
92
94 {
95 ATH_MSG_DEBUG("Finalize() of RefitSiOnlyTool" );
96 return StatusCode::SUCCESS;
97 }
98 //_________________________________________________________________________________________
100 {
101 ATH_MSG_DEBUG( "nothing to configure - everything has already been configured in initialize()" );
102 return StatusCode::SUCCESS;
103 }
104 //_________________________________________________________________________________________
106 ATH_MSG_DEBUG( "processTrackCollection() of RefitSiOnlyTool" );
107
108 m_trkindex=0;
110
111 for (DataVector<Trk::Track>::const_iterator t=trks->begin(); t!=trks->end();++t) {
112 if (*t) {
113 Trk::Track* refittedTrack = refit(*t);
114
115 if (refittedTrack==nullptr)
116 ATH_MSG_DEBUG( " Refit of the track " << m_trkindex << " did not work. Track skipped." );
117
118 newTrks->push_back(refittedTrack);
119 } else {
120 newTrks->push_back(nullptr);
121 ATH_MSG_DEBUG( " Track " << m_trkindex << " is empty." );
122 }
123
124 m_trkindex++;
125 }
126
127 if (msgLvl(MSG::DEBUG)) {
128 dumpTrackCol(newTrks);
129 }
130
131 return newTrks;
132 }
133
134 //_________________________________________________________________________________________
136 // Step through all hits on a Trk::Track, pushback SiliconHits into RIO_Collection
137 // and Refit Track with SiliconHits
138 ATH_MSG_DEBUG( "Entering RefitSiOnlyTool::refit() for track #" << m_trkindex );
139
140 const Trk::Perigee* initialPerigee = tr->perigeeParameters();
141 if (initialPerigee) {
142 ATH_MSG_DEBUG( "Track # " << m_trkindex << " has momentum before refit: "
143 << initialPerigee->momentum().mag() / CLHEP::GeV << " CLHEP::GeV/c" );
144 }
145 else { ATH_MSG_WARNING( "Track # " << m_trkindex << " without perigee" ); }
146
147 Trk::Track* SiOnlyTrack = nullptr;
148 bool containsGangedPixels = false;
149 std::vector<const Trk::MeasurementBase*> MeasurementBase_Collection;
150
151 ATH_MSG_DEBUG( "Building stripped RIO_Collection" );
153 measBase !=tr->measurementsOnTrack()->end(); ++measBase) {
154
155 const Trk::RIO_OnTrack* rio = dynamic_cast <const Trk::RIO_OnTrack*>(*measBase);
156 if (rio != nullptr) {
157 const Identifier& surfaceID = (rio->identify());
158 if(filterHit(surfaceID)==false) {
159 MeasurementBase_Collection.push_back(*measBase);
160
161 // protect against ganged Pixel Hits
162 if (rio->prepRawData()) {
163 const InDet::SiCluster* siHit = dynamic_cast <const InDet::SiCluster*>(rio->prepRawData());
164 if (siHit) {
165 if (siHit->gangedPixel()) {
166 containsGangedPixels = true;
167 ATH_MSG_DEBUG( " Reject track # " << m_trkindex
168 << " because it contains ganged pixel hits" );
169 }
170 }
171 }
172
173 }
174 }
175 }
176
177 // Do Silicon only Refit with Silicon only HitCollection and TrackParameters
178 // at StartingPoint of track
179 if (!containsGangedPixels) {
180 if (m_doCosmic) {
181 ATH_MSG_DEBUG("Refitting using Cosmic reference point");
182
183 // order the parameters according to the Cosmics reference points
184 // works only for Si, not for TRT!
185 const Trk::TrackParameters* minPar =
186 *(std::min_element(tr->trackParameters()->begin(),
187 tr->trackParameters()->end(),
188 *m_comPar));
189
190 SiOnlyTrack = m_ITrkFitter
191 ->fit(Gaudi::Hive::currentContext(),
192 MeasurementBase_Collection,
193 *minPar,
196 .release();
197 } // m_doCosmic
198 else {
199 SiOnlyTrack = m_ITrkFitter
200 ->fit(Gaudi::Hive::currentContext(),
201 MeasurementBase_Collection,
202 *(tr->trackParameters()->front()),
205 .release();
206 }
207 }
208 else {
209 ATH_MSG_DEBUG(" No refit was done for track # " << m_trkindex);
210 return nullptr;
211 }
212
213 return SiOnlyTrack;
214 }
215
216
217 //_________________________________________________________________________________________
219 {
220 if (m_idHelper->is_sct(id) && m_stripSCTHits) {return true;}
221 else if (m_idHelper->is_pixel(id) && m_stripPixelHits) {return true;}
222 else if (m_idHelper->is_trt(id) && m_stripTRTHits) {return true;}
223 else {return false;}
224 }
225
226
227 //_________________________________________________________________________________________
229 ATH_MSG_DEBUG( "In dumpTrackCol() with size=" << tracks->size() );
230
231 int itrk = 0;
233 it!=tracks->end();++it) {
234
235 if(*it!=nullptr){
236
237 const Trk::Perigee* aMeasPer = (*it)->perigeeParameters();
238 if (aMeasPer==nullptr){
239 ATH_MSG_ERROR( "Could not get Trk::MeasuredPerigee" );}
240 else {
241 double d0 = aMeasPer->parameters()[Trk::d0];
242 double z0 = aMeasPer->parameters()[Trk::z0];
243 double phi0 = aMeasPer->parameters()[Trk::phi0];
244 double theta = aMeasPer->parameters()[Trk::theta];
245 double qOverP = aMeasPer->parameters()[Trk::qOverP];
246 if (msgLvl(MSG::DEBUG)) {
247 msg(MSG::DEBUG) << itrk << ". Track Parameters (d0,z0,phi0,theta,qOverP)" << endmsg;
248 msg(MSG::DEBUG) << " " << d0 << ", " << z0 << ", "
249 << phi0 << ", " << theta << ", " << qOverP << endmsg;
250 msg(MSG::DEBUG) << " - momentum: "
251 << aMeasPer->momentum().mag() / CLHEP::GeV << " CLHEP::GeV/c" << endmsg;
252 }
253 }
254 }
255 itrk++;
256 }
257 }
258} //namespace
Scalar theta() const
theta method
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This class provides an interface to generate or decode an identifier for the upper levels of the dete...
An STL vector of pointers that by default owns its pointed-to elements.
static Double_t sc
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
Derived DataVector<T>.
Definition DataVector.h:795
DataModel_detail::const_iterator< DataVector > const_iterator
Standard const_iterator.
Definition DataVector.h:838
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual const DataVector< Trk::Track > * processTrackCollection(const DataVector< Trk::Track > *trks)
main processing of track collection - refits a track using only filtered hits (e.g.
bool m_doCosmic
Flag for cosmics.
bool m_OutlierRemoval
flag for outlier removal
virtual StatusCode configure()
does necessary configuration to the tool
bool m_stripPixelHits
flag to not consider Pixel hits in the refit
Trk::TrkParametersComparisonFunction * m_comPar
bool m_stripTRTHits
flag to not consider TRT hits in the refit
bool m_stripSCTHits
flag to not consider SCT hits in the refit
virtual StatusCode finalize()
Athena Tool methods.
Trk::Track * refit(const Trk::Track *tr) const
refits a track not using non-silicon hits
virtual StatusCode initialize()
Athena Tool methods.
RefitSiOnlyTool(const std::string &type, const std::string &name, const IInterface *parent)
void dumpTrackCol(DataVector< Trk::Track > *tracks)
const AtlasDetectorID * m_idHelper
Trk::ParticleHypothesis m_ParticleHypothesis
ToolHandle< Trk::ITrackFitter > m_ITrkFitter
bool filterHit(const Identifier &id) const
determines from flags, if this hit should be included in the fit or not
bool gangedPixel() const
return the flag of this cluster containing a gangedPixel
const Amg::Vector3D & momentum() const
Access method for the momentum.
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
virtual const Trk::PrepRawData * prepRawData() const =0
returns the PrepRawData (also known as RIO) object to which this RIO_OnTrack is associated.
Identifier identify() const
return the identifier -extends MeasurementBase
const DataVector< const MeasurementBase > * measurementsOnTrack() const
return a pointer to a vector of MeasurementBase (NOT including any that come from outliers).
const DataVector< const TrackParameters > * trackParameters() const
Return a pointer to a vector of TrackParameters.
const Perigee * perigeeParameters() const
return Perigee.
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ComparisonFunction< TrackParameters > TrkParametersComparisonFunction
@ phi0
Definition ParamDefs.h:65
@ theta
Definition ParamDefs.h:66
@ qOverP
perigee
Definition ParamDefs.h:67
@ d0
Definition ParamDefs.h:63
@ z0
Definition ParamDefs.h:64
ParametersBase< TrackParametersDim, Charged > TrackParameters