ATLAS Offline Software
Loading...
Searching...
No Matches
MuonR4::SegmentActsRefitAlg Class Reference

#include <SegmentActsRefitAlg.h>

Inheritance diagram for MuonR4::SegmentActsRefitAlg:
Collaboration diagram for MuonR4::SegmentActsRefitAlg:

Public Member Functions

virtual StatusCode initialize () override final
virtual StatusCode execute (const EventContext &ctx) const override final
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::tuple< Amg::Vector3D, Amg::Vector3DsmearSegment (const ActsTrk::GeometryContext &gctx, const MuonR4::Segment &segment, CLHEP::HepRandomEngine *engine) const
 Smear the segment's position and direction by one sigma defined by the segment's covariance.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadHandleKey< xAOD::MuonSegmentContainerm_readKey {this, "SegmentContainer", "MuonSegmentsFromR4"}
 Declare the data dependency on the standard Mdt+Rpc+Tgc segment container.
SG::WriteHandleKey< xAOD::MuonSegmentContainerm_writeKey {this, "OutContainer", "ActsRefitSegments"}
 Declare the key for the refitted segment container.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainerm_linkKey {this, "LinkKey", m_writeKey, "prefitSegmentLink"}
 Construct a link from the refitted segment to the input segment.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainerm_localParsKey {this, "LocalParsKey", m_writeKey, "localSegPars"}
 Decorate directly the local segment parameters on to the object.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainerm_seedParsKey {this, "SeedParsKey", m_readKey, "seedSegPars"}
 Decorate the seed parameters entering the fit.
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
 IdHelperSvc to decode the Identifiers.
ToolHandle< ActsTrk::IFitterToolm_trackFitTool {this, "FittingTool", ""}
 Track fitting tool.
PublicToolHandle< ActsTrk::ITrackingGeometryToolm_trackingGeometryTool {this, "TrackingGeometryTool", ""}
 Tracking geometry tool.
ToolHandle< ActsTrk::IExtrapolationToolm_extrapolationTool {this, "ExtrapolationTool" ,"" }
 Track extrapolation tool.
ToolHandle< MuonR4::ISegmentSelectionToolm_segSelector {this, "SegmentSelectionTool" , "" }
 Segment selection tool to pick the good quality segments.
ServiceHandle< IAthRNGSvcm_rndmSvc {this, "RndmSvc", "AthRNGSvc", ""}
 Range service to smear the segment parameters.
Gaudi::Property< double > m_smearRange {this, "SmearRange", 1.}
 Smear interval in terms of standard deviations.
SG::WriteHandleKey< xAOD::TrackSurfaceContainerm_surfKey {this, "SurfaceKey", "RefitSegmentSurf"}
 Key to setup a surface container for the external constraints.
ToolHandle< ISpacePointCalibratorm_calibTool {this, "Calibrator", "" }
 Handle to the space point calibrator.
Gaudi::Property< bool > m_drawEvent {this , "drawEvent", false }
 Dump the segment line in obj files.
ActsTrk::AuxiliaryMeasurementHandler m_auxMeasProv {this}
const MuonGMR4::MuonDetectorManagerm_detMgr {nullptr}
 Detector manager to access the spectrometer sector surfaces.
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 33 of file SegmentActsRefitAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Function Documentation

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

64{
65 return 0;
66}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode MuonR4::SegmentActsRefitAlg::execute ( const EventContext & ctx) const
finaloverridevirtual

Create the context object

Random engine to smear the segment parameters

Loop over the segment container

Fetch a smeared segment position & direction

Decorate the initial seed parameters to the segment

Fetch the measurements

We add two pseudo measurements above & beneath the segment to stabilize the fit

Draw the reference segment as a red line

Construct the reference surface before the first measurement

Reference position of the surface.

Plane surface

Fetch the measurements from the track state

Direction is always expressed in global frame -> transform to local

Express the parameters at the reference surface of the original segment

Straight line extension to plane

Definition at line 95 of file SegmentActsRefitAlg.cxx.

95 {
96
97 const xAOD::MuonSegmentContainer* segments{nullptr};
98 ATH_CHECK(SG::get(segments, m_readKey, ctx));
100 const ActsTrk::GeometryContext& gctx{m_trackingGeometryTool->getGeometryContext(ctx)};
101 const Acts::GeometryContext tgContext = gctx.context();
102 const Acts::MagneticFieldContext mfContext = m_extrapolationTool->getMagneticFieldContext(ctx);
103 const Acts::CalibrationContext calContext = ActsTrk::getCalibrationContext(ctx);
104
106 ATHRNG::RNGWrapper* rngWrapper = m_rndmSvc->getEngine(this, name());
107 rngWrapper->setSeed(name(), ctx);
108 CLHEP::HepRandomEngine* randEngine = rngWrapper->getEngine(ctx);
109
110 SG::WriteHandle outHandle{m_writeKey, ctx};
111 ATH_CHECK(outHandle.record(std::make_unique<xAOD::MuonSegmentContainer>(),
112 std::make_unique<xAOD::MuonSegmentAuxContainer>()));
113
114 SG::WriteHandle surfaceHandle{m_surfKey, ctx};
115 ATH_CHECK(surfaceHandle.record(std::make_unique<xAOD::TrackSurfaceContainer>(),
116 std::make_unique<xAOD::TrackStateAuxContainer>()));
117
118 ActsTrk::detail::xAODUncalibMeasSurfAcc surfAcc{};
119 auto auxMeasHandle = m_auxMeasProv.makeHandle(ctx, *surfaceHandle);
120
121 using Link_t = ElementLink<xAOD::MuonSegmentContainer>;
122 SG::WriteDecorHandle<xAOD::MuonSegmentContainer, Link_t> dec_segLink{m_linkKey, ctx};
123 using ParDecor_t = SG::WriteDecorHandle<xAOD::MuonSegmentContainer,
124 xAOD::MeasVector<Acts::toUnderlying(ParamDefs::nPars)>>;
125
126 ParDecor_t dec_locPars{m_localParsKey, ctx};
127 ParDecor_t dec_seedPars{m_seedParsKey, ctx};
128
129 Acts::ObjVisualization3D visualHelper{};
130
132 for (const xAOD::MuonSegment* reFitMe: *segments){
133 const auto msSector = m_detMgr->getSectorEnvelope(reFitMe->chamberIndex(),
134 reFitMe->sector(),
135 reFitMe->etaIndex());
136 const Amg::Transform3D& sectorTrf{msSector->localToGlobalTransform(gctx)};
137
138 m_calibTool->stampSignsOnMeasurements(*reFitMe);
139
141 const auto [seedPos, seedDir] = smearSegment(gctx, *MuonR4::detailedSegment(*reFitMe), randEngine);
143 {
144 auto invTrf = sectorTrf.inverse();
145 const Amg::Vector3D locSeedPos = invTrf * seedPos;
146 const Amg::Vector3D locSeedDir = invTrf.linear() * seedDir;
147 auto& seedPars = dec_seedPars(*reFitMe);
148 seedPars[Acts::toUnderlying(ParamDefs::x0)] = locSeedPos.x();
149 seedPars[Acts::toUnderlying(ParamDefs::y0)] = locSeedPos.y();
150 seedPars[Acts::toUnderlying(ParamDefs::theta)] = locSeedDir.theta();
151 seedPars[Acts::toUnderlying(ParamDefs::phi)] = locSeedDir.phi();
152 }
153
154 const GeoTrf::CoordEulerAngles sectorAngles = GeoTrf::getCoordRotationAngles(sectorTrf);
156 std::vector<const xAOD::UncalibratedMeasurement*> startMeas = MuonR4::collectMeasurements(*reFitMe);
157
158 const auto* refMeas = startMeas.front();
159
160 const Amg::Vector3D firstSurfPos{surfAcc.get(refMeas)->localToGlobalTransform(tgContext).translation()};
161
162 if (reFitMe->nPhiLayers() < 1) {
163 const Amg::Vector3D planeNormal = sectorTrf.linear().col(2);
164
165 const Amg::Vector3D lastSurfPos = surfAcc.get(startMeas.back())->localToGlobalTransform(tgContext).translation();
167
168 const Amg::Transform3D trfBeneath = GeoTrf::GeoTransformRT{sectorAngles, firstSurfPos - pseudoSurfDist * planeNormal};
169 const Amg::Transform3D trfAbove = GeoTrf::GeoTransformRT{sectorAngles, lastSurfPos + pseudoSurfDist * planeNormal};
170
171 auto surfBeneath = Acts::Surface::makeShared<Acts::PlaneSurface>(trfBeneath);
172 auto surfAbove = Acts::Surface::makeShared<Acts::PlaneSurface>(trfAbove);
173 const double covVal = std::pow(10.*Gaudi::Units::cm, 2);
174 startMeas.insert(startMeas.begin(), auxMeasHandle.newMeasurement<1>(surfBeneath, ProjectorType::e1DimNoTime, AmgSymMatrix(1){covVal}));
175 startMeas.insert(startMeas.end(), auxMeasHandle.newMeasurement<1>(surfAbove, ProjectorType::e1DimNoTime, AmgSymMatrix(1){covVal}));
176
177 }
178
179 if (m_drawEvent) {
181 MuonValR4::drawSegmentLine(gctx, *reFitMe, visualHelper,
182 Acts::ViewConfig{.color = {220, 0, 0}});
183 MuonValR4::drawSegmentMeasurements(gctx, *reFitMe, visualHelper, Acts::s_viewSurface);
184 }
186 const Amg::Vector3D trfZ = sectorTrf.linear().col(2);
187 const double extDist = Amg::intersect<3>(seedPos, seedDir, trfZ,
188 firstSurfPos.dot(trfZ) - 10.*Gaudi::Units::cm).value_or(0.);
190 const Amg::Vector3D refPos = seedPos + extDist * seedDir;
191 const Amg::Transform3D trf{GeoTrf::GeoTransformRT{sectorAngles, refPos}};
192 if (msgLvl(MSG::VERBOSE)) {
193 const auto [locPos, locDir] = makeLine(localSegmentPars(*reFitMe));
194
195 std::stringstream sstr{};
196 sstr<<"pos: "<<Amg::toString(seedPos)<<", dir: "<<Amg::toString(seedDir)<<", chi2/nDoF: "
197 <<reFitMe->chiSquared() / reFitMe->numberDoF()<<", nDoF: "<<reFitMe->numberDoF()<<", "
198 <<reFitMe->nPrecisionHits()<<", "<<reFitMe->nPhiLayers()<<std::endl;
199 for (const auto& meas : MuonR4::detailedSegment(*reFitMe)->measurements()) {
200 sstr<<" **** "<<(*meas)<<", chi2: "<<SeedingAux::chi2Term(locPos, locDir, *meas)
201 <<", sign: "<<(meas->isStraw() ?
202 (SeedingAux::strawSign(locPos,locDir, *meas) == 1 ? "R" : "L") : "-")
203 <<", geoId: "<<(meas->spacePoint() ? surfAcc.get(meas->spacePoint()->primaryMeasurement())->geometryId()
204 : Acts::GeometryIdentifier{})<<std::endl;
205 }
206
207 sstr<<" Target surf: "<<Amg::toString(trf)<<", firstSurf: "<< Amg::toString(trf.inverse()*firstSurfPos)
208 <<", refPoint: "<<Amg::toString(trf.inverse()*refPos)<<std::endl;
209 ATH_MSG_VERBOSE("Run G2F fit on "<<msSector->identString()<<std::endl<<sstr.str());
210 }
212 auto target = Acts::Surface::makeShared<Acts::PlaneSurface>(trf);
213
214 auto fourPos{ActsTrk::convertPosToActs(refPos, refPos.mag() / Gaudi::Units::c_light)};
215 Acts::BoundMatrix initialCov{Acts::BoundMatrix::Identity()};
216
217 auto initialPars = Acts::BoundTrackParameters::create(tgContext, target, fourPos, seedDir, straightQoverP,
218 initialCov, Acts::ParticleHypothesis::muon());
219 if (!initialPars.ok()) {
220 ATH_MSG_WARNING("Initial estimate of the parameters failed");
221 continue;
222 }
223 if (m_drawEvent) {
224 MuonValR4::drawBoundParameters(gctx, *initialPars, visualHelper,
225 Acts::ViewConfig{.color={0,220,0}});
226 }
227 ATH_MSG_DEBUG("Initial parameters "<<Amg::toString((*initialPars).parameters()));
228 auto fitTraject = m_trackFitTool->fit(startMeas, *initialPars,
229 tgContext, mfContext, calContext, target.get());
230 if (!fitTraject) {
231 ATH_MSG_WARNING("Track fit failed.");
232 if (m_drawEvent) {
233 visualHelper.write(std::format("SegmentReFitTest_failed_{:}_{:}_{:}.obj",
234 ctx.eventID().event_number(), reFitMe->index(),
235 MuonR4::printID(*reFitMe)));
236 }
237 continue;
238 }
239
240 auto track = fitTraject->getTrack(0);
241 ATH_MSG_DEBUG("Track fit succeeded. ");
242
243 MuonR4::Segment::HitSummary summary{};
245 std::vector<const xAOD::UncalibratedMeasurement*> goodMeas{};
246 unsigned int itr{0};
247 fitTraject->trackStateContainer().visitBackwards(track.tipIndex(),[&](const auto& state){
248 if (!state.hasUncalibratedSourceLink()){
249 return;
250 }
251 goodMeas.insert(goodMeas.begin(),
252 ActsTrk::detail::xAODUncalibMeasCalibrator::unpack(state.getUncalibratedSourceLink()));
253
254 ATH_MSG_VERBOSE("Loop over track state: "<<(itr++)<<", "<<m_idHelperSvc->toString(xAOD::identify(goodMeas.front()))
255 <<", id: "<<surfAcc.get(goodMeas.front())->geometryId());
256
257 const xAOD::UncalibratedMeasurement* m = goodMeas.front();
258 const bool isPrecHit = (m->type() == xAOD::UncalibMeasType::MdtDriftCircleType ||
261 !m_idHelperSvc->measuresPhi(xAOD::identify(m))));
262
263 summary.nPrecHits += isPrecHit;
264 if (m->type() == xAOD::UncalibMeasType::Other ||
265 m_idHelperSvc->measuresPhi(xAOD::identify(m))){
266 ++summary.nPhiHits;
267 } else {
268 summary.nEtaTrigHits += !isPrecHit;
269 }
270 });
271
272 Acts::BoundTrackParameters parameters = track.createParametersAtReference();
273 if (m_drawEvent) {
274 MuonValR4::drawBoundParameters(gctx, parameters, visualHelper,
275 Acts::ViewConfig{.color={0, 0, 220}});
276
277 visualHelper.write(std::format("SegmentReFitTest_goodone_{:}_{:}_{:}.obj",
278 ctx.eventID().event_number(), reFitMe->index(),
279 MuonR4::printID(*reFitMe)));
280 }
282 const Amg::Vector3D globDir = parameters.direction();
284 const Amg::Transform3D globToLoc{sectorTrf.inverse()};
285 const Amg::Vector3D refitPos = globToLoc * parameters.position(tgContext);
286 const Amg::Vector3D refitDir = globToLoc.linear() * globDir;
288 const Amg::Vector3D refitSeg = refitPos + Amg::intersect<3>(refitPos, refitDir, Amg::Vector3D::UnitZ(), 0).value_or(0.) * refitDir;
289 const Amg::Vector3D globPos{msSector->localToGlobalTransform(gctx) * refitSeg};
290
291 auto newSegment = outHandle->push_back(std::make_unique<xAOD::MuonSegment>());
292 dec_segLink(*newSegment) = Link_t{*segments, reFitMe->index(), ctx};
293
294 newSegment->setDirection(globDir.x(), globDir.y(), globDir.z());
295 newSegment->setPosition(globPos.x(), globPos.y(), globPos.z());
296
297 newSegment->setFitQuality(track.chi2(), track.nDoF());
298 newSegment->setNHits(summary.nPrecHits, summary.nPhiHits, summary.nEtaTrigHits);
299 auto& locFitPars = dec_locPars(*newSegment);
300 locFitPars[Acts::toUnderlying(ParamDefs::x0)] = refitSeg.x();
301 locFitPars[Acts::toUnderlying(ParamDefs::y0)] = refitSeg.y();
302 locFitPars[Acts::toUnderlying(ParamDefs::theta)] = refitDir.theta();
303 locFitPars[Acts::toUnderlying(ParamDefs::phi)] = refitDir.phi();
304 }
305 return StatusCode::SUCCESS;
306 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
if(febId1==febId2)
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
Definition RNGWrapper.h:169
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
Definition RNGWrapper.h:134
Acts::GeometryContext context() const
static const xAOD::UncalibratedMeasurement * unpack(const Acts::SourceLink &sl)
Helper method to unpack an Acts source link to an uncalibrated measurement.
const Acts::Surface * get(const xAOD::UncalibratedMeasurement *meas) const
Operator.
bool msgLvl(const MSG::Level lvl) const
SG::WriteHandleKey< xAOD::TrackSurfaceContainer > m_surfKey
Key to setup a surface container for the external constraints.
ServiceHandle< IAthRNGSvc > m_rndmSvc
Range service to smear the segment parameters.
ToolHandle< ActsTrk::IFitterTool > m_trackFitTool
Track fitting tool.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_localParsKey
Decorate directly the local segment parameters on to the object.
const MuonGMR4::MuonDetectorManager * m_detMgr
Detector manager to access the spectrometer sector surfaces.
ToolHandle< ISpacePointCalibrator > m_calibTool
Handle to the space point calibrator.
std::tuple< Amg::Vector3D, Amg::Vector3D > smearSegment(const ActsTrk::GeometryContext &gctx, const MuonR4::Segment &segment, CLHEP::HepRandomEngine *engine) const
Smear the segment's position and direction by one sigma defined by the segment's covariance.
SG::WriteHandleKey< xAOD::MuonSegmentContainer > m_writeKey
Declare the key for the refitted segment container.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_seedParsKey
Decorate the seed parameters entering the fit.
Gaudi::Property< bool > m_drawEvent
Dump the segment line in obj files.
SG::WriteDecorHandleKey< xAOD::MuonSegmentContainer > m_linkKey
Construct a link from the refitted segment to the input segment.
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
Track extrapolation tool.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_readKey
Declare the data dependency on the standard Mdt+Rpc+Tgc segment container.
ActsTrk::AuxiliaryMeasurementHandler m_auxMeasProv
PublicToolHandle< ActsTrk::ITrackingGeometryTool > m_trackingGeometryTool
Tracking geometry tool.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc to decode the Identifiers.
const MeasVec & measurements() const
Returns the associated measurements.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
Acts::Vector4 convertPosToActs(const Amg::Vector3D &athenaPos, const double athenaTime=0.)
Converts a position vector & time from Athena units into Acts units.
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
std::string printID(const xAOD::MuonSegment &seg)
Print the chamber ID of a segment, e.g.
std::vector< const xAOD::UncalibratedMeasurement * > collectMeasurements(const xAOD::MuonSegment &segment, bool skipOutlier=true)
Helper function to extract the measurements from the segment.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
void drawBoundParameters(const ActsTrk::GeometryContext &gctx, const Acts::BoundTrackParameters &pars, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=3.*Gaudi::Units::cm)
Draw a line representing the bound track parameters.
bool isPrecHit(const SpType &sp)
Define a spacepoint as precision hit if it's a Mdt or NSW eta hit.
void drawSegmentMeasurements(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw all uncalibrated measurements associated to the segment.
void drawSegmentLine(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=1.*Gaudi::Units::m)
Draw a segment line inside the obj file.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
const Identifier & identify(const UncalibratedMeasurement *meas)
Returns the associated identifier from the muon measurement.
MuonSegment_v1 MuonSegment
Reference the current persistent version:
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
97}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ initialize()

StatusCode MuonR4::SegmentActsRefitAlg::initialize ( )
finaloverridevirtual

Definition at line 39 of file SegmentActsRefitAlg.cxx.

39 {
40 ATH_CHECK(m_readKey.initialize());
41 ATH_CHECK(m_writeKey.initialize());
42 ATH_CHECK(m_linkKey.initialize());
43 ATH_CHECK(m_localParsKey.initialize());
44 ATH_CHECK(m_seedParsKey.initialize());
45 ATH_CHECK(m_surfKey.initialize());
46 ATH_CHECK(m_auxMeasProv.initialize(m_writeKey.key()));
47 ATH_CHECK(m_calibTool.retrieve());
48
49 ATH_CHECK(m_idHelperSvc.retrieve());
50 ATH_CHECK(m_trackFitTool.retrieve());
53 ATH_CHECK(m_segSelector.retrieve());
55 return StatusCode::SUCCESS;
56 }
const ServiceHandle< StoreGateSvc > & detStore() const
ToolHandle< MuonR4::ISegmentSelectionTool > m_segSelector
Segment selection tool to pick the good quality segments.
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ smearSegment()

std::tuple< Amg::Vector3D, Amg::Vector3D > MuonR4::SegmentActsRefitAlg::smearSegment ( const ActsTrk::GeometryContext & gctx,
const MuonR4::Segment & segment,
CLHEP::HepRandomEngine * engine ) const
private

Smear the segment's position and direction by one sigma defined by the segment's covariance.

Returns a tuple of smeared position & direction.

Parameters
gctxGeometry context to fetch the alignment of the segment
segmentReference to the segment to smear
engineRandom engine to pass through the random number sequence

Smear the parameters

Ensure that the left-right ambiguity is preserved

Definition at line 58 of file SegmentActsRefitAlg.cxx.

60 {
61 // return std::make_pair(segment.position(), segment.direction()* (segment.direction().z() < 0 ? -1. : 1.));
62 const auto segPars = localSegmentPars(gctx, segment);
63 auto smearedPars = segPars;
65 for (ParamDefs precPar : {ParamDefs::y0, ParamDefs::theta,
66 ParamDefs::x0, ParamDefs::phi}) {
67 if (precPar == ParamDefs::phi && !segment.summary().nPhiHits) {
68 break;
69 }
70 const unsigned idx = Acts::toUnderlying(precPar);
71 const double uncert = Amg::error(segment.covariance(), idx) * m_smearRange;
72 smearedPars[idx] = CLHEP::RandGaussZiggurat::shoot(engine, segPars[idx], uncert);
73 ATH_MSG_VERBOSE("Apply smearing to "<<SeedingAux::parName(precPar)
74 <<" parameter -- cov: "<<uncert
75 <<", original: "<<segPars[idx]<<", smeared: "<<smearedPars[idx]<<", deviation: "
76 <<(smearedPars[idx] - segPars[idx]) / uncert );
77
78 }
79 auto [smearLocPos, smearLocDir] = makeLine(smearedPars);
80 const auto [locPos, locDir] = makeLine(segPars);
82 if (SeedingAux::strawSigns(locPos,locDir, segment.measurements()) !=
83 SeedingAux::strawSigns(smearLocPos, smearLocDir, segment.measurements())) {
84 ATH_MSG_ALWAYS("Parameter smearng from "<<toString(segPars)<<" -> "<<toString(smearedPars)
85 <<" changes the L/R ambiguity -> avoid for this test");
86 return smearSegment(gctx, segment, engine);
87 }
88
89 const Amg::Transform3D& locToGlob{segment.msSector()->localToGlobalTransform(gctx)};
90 if (smearLocDir.z() < 0) {
91 smearLocDir = -smearLocDir;
92 }
93 return std::make_tuple(locToGlob * smearLocPos, locToGlob.linear() * smearLocDir);
94 }
#define ATH_MSG_ALWAYS(x)
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &gctx) const
Returns the local -> global tarnsformation from the sector.
Gaudi::Property< double > m_smearRange
Smear interval in terms of standard deviations.
const SegmentFit::Covariance & covariance() const
Returns the uncertainties of the defining parameters.
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
SeedingAux::FitParIndex ParamDefs
Use the same parameter indices as used by the CompSpacePointAuxiliaries.
std::string toString(const Parameters &pars)
Dumps the parameters into a string with labels in front of each number.

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

77{
78 return BaseAlg::sysExecute (ctx);
79}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

107 {
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
#define ATH_MSG_ERROR(x)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_auxMeasProv

ActsTrk::AuxiliaryMeasurementHandler MuonR4::SegmentActsRefitAlg::m_auxMeasProv {this}
private

Definition at line 79 of file SegmentActsRefitAlg.h.

79{this};

◆ m_calibTool

ToolHandle<ISpacePointCalibrator> MuonR4::SegmentActsRefitAlg::m_calibTool {this, "Calibrator", "" }
private

Handle to the space point calibrator.

Definition at line 75 of file SegmentActsRefitAlg.h.

75{this, "Calibrator", "" };

◆ m_detMgr

const MuonGMR4::MuonDetectorManager* MuonR4::SegmentActsRefitAlg::m_detMgr {nullptr}
private

Detector manager to access the spectrometer sector surfaces.

Definition at line 81 of file SegmentActsRefitAlg.h.

81{nullptr};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_drawEvent

Gaudi::Property<bool> MuonR4::SegmentActsRefitAlg::m_drawEvent {this , "drawEvent", false }
private

Dump the segment line in obj files.

Definition at line 77 of file SegmentActsRefitAlg.h.

77{this , "drawEvent", false };

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_extrapolationTool

ToolHandle<ActsTrk::IExtrapolationTool> MuonR4::SegmentActsRefitAlg::m_extrapolationTool {this, "ExtrapolationTool" ,"" }
private

Track extrapolation tool.

Definition at line 65 of file SegmentActsRefitAlg.h.

65{this, "ExtrapolationTool" ,"" };

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> MuonR4::SegmentActsRefitAlg::m_idHelperSvc {this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

IdHelperSvc to decode the Identifiers.

Definition at line 59 of file SegmentActsRefitAlg.h.

59{this, "IdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_linkKey

SG::WriteDecorHandleKey<xAOD::MuonSegmentContainer> MuonR4::SegmentActsRefitAlg::m_linkKey {this, "LinkKey", m_writeKey, "prefitSegmentLink"}
private

Construct a link from the refitted segment to the input segment.

Definition at line 52 of file SegmentActsRefitAlg.h.

52{this, "LinkKey", m_writeKey, "prefitSegmentLink"};

◆ m_localParsKey

SG::WriteDecorHandleKey<xAOD::MuonSegmentContainer> MuonR4::SegmentActsRefitAlg::m_localParsKey {this, "LocalParsKey", m_writeKey, "localSegPars"}
private

Decorate directly the local segment parameters on to the object.

Definition at line 54 of file SegmentActsRefitAlg.h.

54{this, "LocalParsKey", m_writeKey, "localSegPars"};

◆ m_readKey

SG::ReadHandleKey<xAOD::MuonSegmentContainer> MuonR4::SegmentActsRefitAlg::m_readKey {this, "SegmentContainer", "MuonSegmentsFromR4"}
private

Declare the data dependency on the standard Mdt+Rpc+Tgc segment container.

Definition at line 48 of file SegmentActsRefitAlg.h.

48{this, "SegmentContainer", "MuonSegmentsFromR4"};

◆ m_rndmSvc

ServiceHandle<IAthRNGSvc> MuonR4::SegmentActsRefitAlg::m_rndmSvc {this, "RndmSvc", "AthRNGSvc", ""}
private

Range service to smear the segment parameters.

Definition at line 69 of file SegmentActsRefitAlg.h.

69{this, "RndmSvc", "AthRNGSvc", ""};

◆ m_seedParsKey

SG::WriteDecorHandleKey<xAOD::MuonSegmentContainer> MuonR4::SegmentActsRefitAlg::m_seedParsKey {this, "SeedParsKey", m_readKey, "seedSegPars"}
private

Decorate the seed parameters entering the fit.

Definition at line 56 of file SegmentActsRefitAlg.h.

56{this, "SeedParsKey", m_readKey, "seedSegPars"};

◆ m_segSelector

ToolHandle<MuonR4::ISegmentSelectionTool> MuonR4::SegmentActsRefitAlg::m_segSelector {this, "SegmentSelectionTool" , "" }
private

Segment selection tool to pick the good quality segments.

Definition at line 67 of file SegmentActsRefitAlg.h.

67{this, "SegmentSelectionTool" , "" };

◆ m_smearRange

Gaudi::Property<double> MuonR4::SegmentActsRefitAlg::m_smearRange {this, "SmearRange", 1.}
private

Smear interval in terms of standard deviations.

Definition at line 71 of file SegmentActsRefitAlg.h.

71{this, "SmearRange", 1.};

◆ m_surfKey

SG::WriteHandleKey<xAOD::TrackSurfaceContainer> MuonR4::SegmentActsRefitAlg::m_surfKey {this, "SurfaceKey", "RefitSegmentSurf"}
private

Key to setup a surface container for the external constraints.

Definition at line 73 of file SegmentActsRefitAlg.h.

73{this, "SurfaceKey", "RefitSegmentSurf"};

◆ m_trackFitTool

ToolHandle<ActsTrk::IFitterTool> MuonR4::SegmentActsRefitAlg::m_trackFitTool {this, "FittingTool", ""}
private

Track fitting tool.

Definition at line 61 of file SegmentActsRefitAlg.h.

61{this, "FittingTool", ""};

◆ m_trackingGeometryTool

PublicToolHandle<ActsTrk::ITrackingGeometryTool> MuonR4::SegmentActsRefitAlg::m_trackingGeometryTool {this, "TrackingGeometryTool", ""}
private

Tracking geometry tool.

Definition at line 63 of file SegmentActsRefitAlg.h.

63{this, "TrackingGeometryTool", ""};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.

◆ m_writeKey

SG::WriteHandleKey<xAOD::MuonSegmentContainer> MuonR4::SegmentActsRefitAlg::m_writeKey {this, "OutContainer", "ActsRefitSegments"}
private

Declare the key for the refitted segment container.

Definition at line 50 of file SegmentActsRefitAlg.h.

50{this, "OutContainer", "ActsRefitSegments"};

The documentation for this class was generated from the following files: