ATLAS Offline Software
Loading...
Searching...
No Matches
HGTD::TrackTimeDefAndQualityAlg Class Reference

#include <TrackTimeDefAndQualityAlg.h>

Inheritance diagram for HGTD::TrackTimeDefAndQualityAlg:
Collaboration diagram for HGTD::TrackTimeDefAndQualityAlg:

Classes

struct  CleaningResult
struct  Hit

Public Member Functions

 TrackTimeDefAndQualityAlg (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~TrackTimeDefAndQualityAlg ()
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::pair< float, float > getRadiusAndZ (const xAOD::TrackParticle &track_particle) const
CleaningResult runTimeConsistencyCuts (const std::vector< float > &times, const std::vector< bool > &has_clusters, const std::vector< int > &hit_classification) const
std::array< Hit, s_hgtd_layers > getValidHits (const std::vector< float > &times, const std::vector< bool > &has_clusters, const std::vector< int > &hit_classification) const
float calculateChi2 (const std::array< Hit, s_hgtd_layers > &hits) const
 Calculates the chi2 of the hit times given their resolution.
bool passesDeltaT (const std::array< Hit, s_hgtd_layers > &hits) const
 Checks two hits for time compatibility.
float meanTime (const std::array< Hit, s_hgtd_layers > &hits) const
 Calculates the arithmetic mean of the valid hit times;.
float trackTimeResolution (const std::array< Hit, s_hgtd_layers > &hits) const
 Calculates the combined resolution.
short findLayerWithBadChi2 (std::array< Hit, s_hgtd_layers > hits) const
 Identifies time outliers by finding the layer within which a hit contributes negatively to the overall chi2 value and returns the layer number.
void setLayerAsInvalid (std::array< Hit, s_hgtd_layers > &hits, short layer) const
 Given a layer number, the hit sitting on this layer is flagged as invalid.
short getValidPattern (const std::array< Hit, s_hgtd_layers > &hits) const
 Returns the pattern of valid hits in HGTD as a 4-bit bitfield, where a 1 encodes that a valid hit was found, while a 0 means no valid hit found.
bool lastHitIsOnLastSurface (const xAOD::TrackParticle &track_particle) const
 Checks if the last hit on track was found on a pre-specified set of Pixel and Strip layers close to the HGTD surfaces.
const Trk::TrackParametersgetLastHitOnTrack (const Trk::Track &track) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

const short m_recoed_ptrn_sft = 0
const short m_comp_ptrn_sft = 8
const short m_holes_ptrn_sft = 12
const short m_primes_ptrn_sft = 16
SG::ReadHandleKey< xAOD::TrackParticleContainerm_trackParticleContainerKey
SG::ReadDecorHandleKey< xAOD::TrackParticleContainerm_layerHasExtensionKey
SG::ReadDecorHandleKey< xAOD::TrackParticleContainerm_layerClusterTimeKey
SG::ReadDecorHandleKey< xAOD::TrackParticleContainerm_layerClusterTruthClassKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_time_dec_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_time_res_dec_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_hasValidTime_dec_key
SG::WriteDecorHandleKey< xAOD::TrackParticleContainerm_summarypattern_dec_key
Gaudi::Property< bool > m_doActs {this, "doActs", false}
FloatProperty m_chi2_threshold
FloatProperty m_deltat_cut
FloatProperty m_default_time
FloatProperty m_default_time_res
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 57 of file TrackTimeDefAndQualityAlg.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ TrackTimeDefAndQualityAlg()

HGTD::TrackTimeDefAndQualityAlg::TrackTimeDefAndQualityAlg ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 26 of file TrackTimeDefAndQualityAlg.cxx.

28 : AthReentrantAlgorithm(name, pSvcLocator) {}

◆ ~TrackTimeDefAndQualityAlg()

virtual HGTD::TrackTimeDefAndQualityAlg::~TrackTimeDefAndQualityAlg ( )
inlinevirtual

Definition at line 69 of file TrackTimeDefAndQualityAlg.h.

69{}

Member Function Documentation

◆ calculateChi2()

float HGTD::TrackTimeDefAndQualityAlg::calculateChi2 ( const std::array< Hit, s_hgtd_layers > & hits) const
private

Calculates the chi2 of the hit times given their resolution.

Parameters
[in]hitsArray of hits.
Returns
Chi2 value.

Definition at line 241 of file TrackTimeDefAndQualityAlg.cxx.

242 {
243
244 float mean = meanTime(hits);
245
246 float chi2 = 0.;
247 for (const auto& hit : hits) {
248 if (hit.m_isvalid) {
249 chi2 += (hit.m_time - mean) * (hit.m_time - mean) /
250 (hit.m_resolution * hit.m_resolution);
251 }
252 }
253 return chi2;
254}
float meanTime(const std::array< Hit, s_hgtd_layers > &hits) const
Calculates the arithmetic mean of the valid hit times;.
double chi2(TH1 *h0, TH1 *h1)
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")

◆ 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 HGTD::TrackTimeDefAndQualityAlg::execute ( const EventContext & ctx) const
finaloverridevirtual

Definition at line 47 of file TrackTimeDefAndQualityAlg.cxx.

47 {
48
49 SG::ReadHandle<xAOD::TrackParticleContainer> trk_ptkl_container_handle(
51 ATH_CHECK( trk_ptkl_container_handle.isValid() );
52 const xAOD::TrackParticleContainer* track_particles =
53 trk_ptkl_container_handle.cptr();
54 if (not track_particles) {
56 "[TrackTimeDefAndQualityAlg] TrackParticleContainer not found, "
57 "aborting execute!");
58 return StatusCode::FAILURE;
59 }
60
61 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> time_handle(
62 m_time_dec_key, ctx);
63 SG::WriteDecorHandle<xAOD::TrackParticleContainer, float> timeres_handle(
65 SG::WriteDecorHandle<xAOD::TrackParticleContainer, uint8_t> hasValidTime_handle(
67 SG::WriteDecorHandle<xAOD::TrackParticleContainer, uint32_t> summary_handle(
69
70 SG::ReadDecorHandle<xAOD::TrackParticleContainer, std::vector<float>>
71 layerClusterTimeHandle(m_layerClusterTimeKey, ctx);
72 ATH_CHECK(layerClusterTimeHandle.isValid());
73
74 SG::ReadDecorHandle<xAOD::TrackParticleContainer, std::vector<bool>>
75 layerHasExtensionHandle(m_layerHasExtensionKey, ctx);
76 ATH_CHECK(layerHasExtensionHandle.isValid());
77
78 SG::ReadDecorHandle<xAOD::TrackParticleContainer, std::vector<int>>
79 layerClusterTruthClassHandle(m_layerClusterTruthClassKey, ctx);
80 ATH_CHECK(layerClusterTruthClassHandle.isValid());
81
82
83 for (const auto* track_ptkl : *track_particles) {
84 // runs the time consistency checks
85 // if no hits are found in HGTD, returns a default time
86 const std::vector<float>& times = layerClusterTimeHandle(*track_ptkl);
87 const std::vector<bool>& has_clusters = layerHasExtensionHandle(*track_ptkl);
88 const std::vector<int>& hit_classification = layerClusterTruthClassHandle(*track_ptkl);
89
91 has_clusters,
92 hit_classification);
93
94 // check if the last hit on track was within the predefined area
95 if (lastHitIsOnLastSurface(*track_ptkl)) {
96 res.m_field |= (0b0000 << m_holes_ptrn_sft);
97 } else {
98 res.m_field |= (0b0001 << m_holes_ptrn_sft);
99 }
100
101 // keep which of the hits associated in reco were primary hits (truth info!)
102 short prime_pattern = 0x0;
103 for (short i = 0; i < s_hgtd_layers; i++) {
104 if (res.m_hits.at(i).m_isprime) {
105 prime_pattern |= (1 << i);
106 }
107 }
108 res.m_field |= (prime_pattern << m_primes_ptrn_sft);
109
110 // decorate the track again with this info
111 time_handle(*track_ptkl) = res.m_time;
112 timeres_handle(*track_ptkl) = res.m_resolution;
113 hasValidTime_handle(*track_ptkl) = res.m_hasValidTime;
114 summary_handle(*track_ptkl) = res.m_field;
115 }
116 return StatusCode::SUCCESS;
117}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
std::pair< std::vector< unsigned int >, bool > res
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_time_dec_key
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_layerClusterTruthClassKey
CleaningResult runTimeConsistencyCuts(const std::vector< float > &times, const std::vector< bool > &has_clusters, const std::vector< int > &hit_classification) const
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_time_res_dec_key
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_trackParticleContainerKey
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_hasValidTime_dec_key
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_layerClusterTimeKey
bool lastHitIsOnLastSurface(const xAOD::TrackParticle &track_particle) const
Checks if the last hit on track was found on a pre-specified set of Pixel and Strip layers close to t...
SG::WriteDecorHandleKey< xAOD::TrackParticleContainer > m_summarypattern_dec_key
SG::ReadDecorHandleKey< xAOD::TrackParticleContainer > m_layerHasExtensionKey
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".

◆ 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

◆ findLayerWithBadChi2()

short HGTD::TrackTimeDefAndQualityAlg::findLayerWithBadChi2 ( std::array< Hit, s_hgtd_layers > hits) const
private

Identifies time outliers by finding the layer within which a hit contributes negatively to the overall chi2 value and returns the layer number.

Copies the hits, since they have to be invalidated one by one.

Parameters
[in]hitsArray of hits.
Returns
Layer with outlier time, value between 0 and 3.

Definition at line 307 of file TrackTimeDefAndQualityAlg.cxx.

308 {
309 short remove_layer = -1;
310 float local_min_chi2 = 999999;
311 for (auto& hit : hits) {
312 // "turn off" hits one after the other to test their impact on the chi2
313 bool validbuff = hit.m_isvalid;
314 hit.m_isvalid = false;
315 float local_chi2 = calculateChi2(hits);
316 hit.m_isvalid = validbuff;
317 if (local_chi2 < local_min_chi2) {
318 local_min_chi2 = local_chi2;
319 remove_layer = hit.m_layer;
320 }
321 }
322 return remove_layer;
323}
float calculateChi2(const std::array< Hit, s_hgtd_layers > &hits) const
Calculates the chi2 of the hit times given their resolution.

◆ getLastHitOnTrack()

const Trk::TrackParameters * HGTD::TrackTimeDefAndQualityAlg::getLastHitOnTrack ( const Trk::Track & track) const
private

Definition at line 336 of file TrackTimeDefAndQualityAlg.cxx.

336 {
337
338 const Trk::TrackStates* tsos =
339 track.trackStateOnSurfaces();
340 if (not tsos) {
341 ATH_MSG_ERROR("Failed to retrieve track state on surfaces");
342 return nullptr;
343 }
344 // loop over the associated hits in ITk in reverse order, since we want to
345 // select the one closest to HGTD to start the extrapolation
346 for (auto i = tsos->rbegin(); i != tsos->rend(); ++i) {
347 const auto* curr_last_tsos = *i;
348 if (not curr_last_tsos) {
349 continue;
350 }
351
352 if (curr_last_tsos->type(Trk::TrackStateOnSurface::Measurement) and
353 curr_last_tsos->trackParameters() and
354 curr_last_tsos->measurementOnTrack()) {
355 return curr_last_tsos->trackParameters();
356 }
357 }
358
359 return nullptr;
360}
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
DataVector< const Trk::TrackStateOnSurface > TrackStates

◆ getRadiusAndZ()

std::pair< float, float > HGTD::TrackTimeDefAndQualityAlg::getRadiusAndZ ( const xAOD::TrackParticle & track_particle) const
private

Definition at line 362 of file TrackTimeDefAndQualityAlg.cxx.

363{
364 float radius = 0.f;
365 float abs_z = 0.f;
366
367 if (not m_doActs) {
368 const Trk::Track* track = track_particle.track();
369 if (not track) throw std::runtime_error("Cannot retrieve Trk track from Track Particle");
370 const Trk::TrackParameters* last_hit_param = getLastHitOnTrack(*track);
371 if (not last_hit_param) throw std::runtime_error("Cannot retrieve Trk track parameters from Trk track");
372
373 radius = std::hypot(last_hit_param->position().x(),
374 last_hit_param->position().y());
375 abs_z = std::abs(last_hit_param->position().z());
376 } else {
377 // ACTS
378 static const SG::ConstAccessor< ElementLink<ActsTrk::TrackContainer> > actsTrackLink("actsTrack");
379 if (not actsTrackLink.isAvailable(track_particle)) throw std::runtime_error("Track particle does not have link to acts track");
380
381 ElementLink<ActsTrk::TrackContainer> link_to_track = actsTrackLink(track_particle);
382 if (not link_to_track.isValid()) throw std::runtime_error("Element link to acts track is not valid");
383
384 std::optional<ActsTrk::TrackContainer::ConstTrackProxy> optional_track = *link_to_track;
385 if (not optional_track.has_value()) throw std::runtime_error("Link to acts track has no value");
386
387 const ActsTrk::TrackContainer::ConstTrackProxy& track = optional_track.value();
388 const auto lastMeasurementState = Acts::findLastMeasurementState(track);
389 const auto state = lastMeasurementState.value();
390
391 auto sl = state.getUncalibratedSourceLink().template get<ActsTrk::ATLASUncalibSourceLink>();
392 assert( sl != nullptr);
394 xAOD::UncalibMeasType clusterType = cluster.type();
395
396 switch (clusterType) {
398 {
399 auto glob = static_cast<const xAOD::PixelCluster*>(&cluster)->globalPosition();
400 radius = std::sqrt( glob(0, 0) * glob(0, 0) + glob(1, 0) * glob(1, 0) );
401 abs_z = std::abs( glob(2, 0) );
402 }
403 break;
405 {
406 auto glob = static_cast<const xAOD::StripCluster*>(&cluster)->globalPosition();
407 radius = std::sqrt( glob(0, 0) * glob(0, 0) + glob(1, 0) * glob(1, 0) );
408 abs_z = std::abs( glob(2, 0) );
409 }
410 break;
412 // return some default numbers
413 return std::make_pair(700, 3000);
414 default:
415 return std::make_pair(radius, abs_z);
416 }; // switch
417 } // acts
418
419 return std::make_pair(radius, abs_z);
420}
const Trk::TrackParameters * getLastHitOnTrack(const Trk::Track &track) const
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
const xAOD::UncalibratedMeasurement & getUncalibratedMeasurement(const ATLASUncalibSourceLink &source_link)
ParametersBase< TrackParametersDim, Charged > TrackParameters
StripCluster_v1 StripCluster
Define the version of the strip cluster class.
PixelCluster_v1 PixelCluster
Define the version of the pixel cluster class.
UncalibMeasType
Define the type of the uncalibrated measurement.
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.

◆ getValidHits()

std::array< TrackTimeDefAndQualityAlg::Hit, s_hgtd_layers > HGTD::TrackTimeDefAndQualityAlg::getValidHits ( const std::vector< float > & times,
const std::vector< bool > & has_clusters,
const std::vector< int > & hit_classification ) const
private

Definition at line 211 of file TrackTimeDefAndQualityAlg.cxx.

213 {
214 std::array<Hit, s_hgtd_layers> valid_hits {};
215
216 for (size_t i = 0; i < s_hgtd_layers; i++) {
217 Hit& newhit = valid_hits[i];
218 if (has_clusters.at(i)) {
219 newhit.m_time = times.at(i);
220 newhit.m_isprime = hit_classification.at(i) == 1;
221 newhit.m_isvalid = true;
222 }
223 newhit.m_layer = i;
224 }
225
226 return valid_hits;
227}

◆ getValidPattern()

short HGTD::TrackTimeDefAndQualityAlg::getValidPattern ( const std::array< Hit, s_hgtd_layers > & hits) const
private

Returns the pattern of valid hits in HGTD as a 4-bit bitfield, where a 1 encodes that a valid hit was found, while a 0 means no valid hit found.

The LSB carries the hit information for the layer closest to the IP.

Parameters
[in]hitsArray of hits.
Returns
Bit pattern encoding valid hits in layers.

Definition at line 229 of file TrackTimeDefAndQualityAlg.cxx.

231 {
232 short pattern = 0x0;
233 for (short i = 0; i < s_hgtd_layers; i++) {
234 if (hits.at(i).m_isvalid) {
235 pattern |= (1 << i);
236 }
237 }
238 return pattern;
239}

◆ initialize()

StatusCode HGTD::TrackTimeDefAndQualityAlg::initialize ( )
finaloverridevirtual

Definition at line 30 of file TrackTimeDefAndQualityAlg.cxx.

30 {
31
34 ATH_CHECK(m_layerClusterTimeKey.initialize());
36 ATH_CHECK(m_time_dec_key.initialize());
37 ATH_CHECK(m_time_res_dec_key.initialize());
40
41 return StatusCode::SUCCESS;
42}

◆ 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()

◆ lastHitIsOnLastSurface()

bool HGTD::TrackTimeDefAndQualityAlg::lastHitIsOnLastSurface ( const xAOD::TrackParticle & track_particle) const
private

Checks if the last hit on track was found on a pre-specified set of Pixel and Strip layers close to the HGTD surfaces.

FIXME: should not be hardcoded. To be exchanged by a hole search at a later point.

Parameters
[in]track_particleTrack reconstructed in ITk.
Returns
True if the last hit on track was within the specified volume.

Definition at line 422 of file TrackTimeDefAndQualityAlg.cxx.

423 {
424 auto [radius, abs_z] = getRadiusAndZ(track_particle);
425
426 if (abs_z > 2700) {
427 return true;
428 }
429 if (radius < 350 and abs_z > 2400) {
430 return true;
431 }
432 // region 2
433 if (radius > 205 and radius < 350 and abs_z > 2100) {
434 return true;
435 }
436 // region 3
437 if (radius < 220 and abs_z > 2200) {
438 return true;
439 }
440
441 if (radius < 140 and abs_z > 1890) {
442 return true;
443 }
444
445 return false;
446}
std::pair< float, float > getRadiusAndZ(const xAOD::TrackParticle &track_particle) const

◆ meanTime()

float HGTD::TrackTimeDefAndQualityAlg::meanTime ( const std::array< Hit, s_hgtd_layers > & hits) const
private

Calculates the arithmetic mean of the valid hit times;.

Parameters
[in]hitsArray of hits.
Returns
Returns true if the times were in agreement.

Definition at line 279 of file TrackTimeDefAndQualityAlg.cxx.

281 {
282 float sum = 0.;
283 short n = 0;
284 for (const auto& hit : hits) {
285 if (hit.m_isvalid) {
286 sum += hit.m_time;
287 n++;
288 }
289 }
290 return n == 0 ? m_default_time.value() : sum / (float)n;
291}

◆ 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.

◆ passesDeltaT()

bool HGTD::TrackTimeDefAndQualityAlg::passesDeltaT ( const std::array< Hit, s_hgtd_layers > & hits) const
private

Checks two hits for time compatibility.

Parameters
[in]hitsArray of hits.
Returns
Returns true if the times were in agreement.

Definition at line 256 of file TrackTimeDefAndQualityAlg.cxx.

258 {
259 // don't trust the user here.
260 short n_valid = std::count_if(hits.begin(), hits.end(),
261 [](const Hit& hit) { return hit.m_isvalid; });
262 if (n_valid != 2) {
263 return false;
264 }
265 // FIXME this should be doable in a simpler manner...
266 std::vector<float> times;
267 std::vector<float> res;
268 for (const auto& hit : hits) {
269 if (hit.m_isvalid) {
270 times.push_back(hit.m_time);
271 res.push_back(hit.m_resolution);
272 }
273 }
274 // pass if the distance in units of the resolution passes the cut
275 return std::abs(times.at(0) - times.at(1)) <
276 m_deltat_cut * hypot(res.at(0), res.at(1));
277}

◆ 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 }

◆ runTimeConsistencyCuts()

TrackTimeDefAndQualityAlg::CleaningResult HGTD::TrackTimeDefAndQualityAlg::runTimeConsistencyCuts ( const std::vector< float > & times,
const std::vector< bool > & has_clusters,
const std::vector< int > & hit_classification ) const
private

Definition at line 123 of file TrackTimeDefAndQualityAlg.cxx.

125 {
126 // get all available hits (see the struct Hit) in a first step
127 std::array<Hit, s_hgtd_layers> valid_hits = getValidHits(times,
128 has_clusters,
129 hit_classification);
130
132 result.m_hits = valid_hits;
133 result.m_field = 0x0;
134 result.m_time = m_default_time;
135 result.m_resolution = m_default_time_res;
136 result.m_hasValidTime = 0;
137
138 short recoed_pattern = getValidPattern(valid_hits);
139 // stored the pattern of hits as retrieved from the iterative extension
140 result.m_field |= (recoed_pattern << m_recoed_ptrn_sft);
141
142 short nhits = std::count_if(valid_hits.begin(), valid_hits.end(),
143 [](const Hit& hit) { return hit.m_isvalid; });
144 if (nhits < 2) {
145 // fill the patern with the 1 hit (or none) and return
146 result.m_field |= (recoed_pattern << m_comp_ptrn_sft);
147 result.m_time = meanTime(valid_hits);
148 result.m_resolution = trackTimeResolution(valid_hits);
149 result.m_hasValidTime = recoed_pattern ? 1 : 0;
150 return result;
151 } else if (nhits == 2) {
152 // if the deltaT cut is passed, the pattern stays the same, otherwise set
153 // to 0 as no hit passes
154 // TODO: find better way to treat this!
155 if (passesDeltaT(valid_hits)) {
156 result.m_field |= (recoed_pattern << m_comp_ptrn_sft); // stays the same
157 result.m_time = meanTime(valid_hits);
158 result.m_resolution = trackTimeResolution(valid_hits);
159 result.m_hasValidTime = 1;
160 return result;
161 } else {
162 result.m_field |= (0b0000 << m_comp_ptrn_sft); // no hit passes
163 result.m_time = m_default_time; // TODO should I just use the mean?
164 result.m_resolution = m_default_time_res;
165 return result;
166 }
167
168 } else {
169 // for 3 or 4 hits, remove hit(s) with worst chi2 if needed
170 float chi2 = calculateChi2(valid_hits);
171 // if the chi2 is below the threshold, keep all hits
172 bool searching = chi2 > m_chi2_threshold;
173 while (searching) {
174 short remove_layer = findLayerWithBadChi2(valid_hits);
175 setLayerAsInvalid(valid_hits, remove_layer);
176 float new_chi2 = calculateChi2(valid_hits);
177 nhits = std::count_if(valid_hits.begin(), valid_hits.end(),
178 [](const Hit& hit) { return hit.m_isvalid; });
179 if (new_chi2 <= m_chi2_threshold or nhits < 3) {
180 searching = false;
181 }
182 } // while loop ended
183
184 short chi2_rej_pattern = getValidPattern(valid_hits);
185
186 if (nhits == 2) {
187 if (passesDeltaT(valid_hits)) {
188 result.m_field |= (chi2_rej_pattern << m_comp_ptrn_sft);
189 result.m_time = meanTime(valid_hits);
190 result.m_resolution = trackTimeResolution(valid_hits);
191 result.m_hasValidTime = 1;
192 return result;
193 } else {
194 result.m_field |= (0b0000 << m_comp_ptrn_sft); // no hit passes
195 result.m_time = m_default_time; // TODO should I just use the mean?
196 result.m_resolution = m_default_time_res;
197 return result;
198 }
199 } else {
200 // 3 or 4 hits, chi2 passed
201 result.m_field |= (chi2_rej_pattern << m_comp_ptrn_sft);
202 result.m_time = meanTime(valid_hits);
203 result.m_resolution = trackTimeResolution(valid_hits);
204 result.m_hasValidTime = 1;
205 return result;
206 }
207 }
208}
std::array< Hit, s_hgtd_layers > getValidHits(const std::vector< float > &times, const std::vector< bool > &has_clusters, const std::vector< int > &hit_classification) const
void setLayerAsInvalid(std::array< Hit, s_hgtd_layers > &hits, short layer) const
Given a layer number, the hit sitting on this layer is flagged as invalid.
float trackTimeResolution(const std::array< Hit, s_hgtd_layers > &hits) const
Calculates the combined resolution.
short findLayerWithBadChi2(std::array< Hit, s_hgtd_layers > hits) const
Identifies time outliers by finding the layer within which a hit contributes negatively to the overal...
bool passesDeltaT(const std::array< Hit, s_hgtd_layers > &hits) const
Checks two hits for time compatibility.
short getValidPattern(const std::array< Hit, s_hgtd_layers > &hits) const
Returns the pattern of valid hits in HGTD as a 4-bit bitfield, where a 1 encodes that a valid hit was...

◆ 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

◆ setLayerAsInvalid()

void HGTD::TrackTimeDefAndQualityAlg::setLayerAsInvalid ( std::array< Hit, s_hgtd_layers > & hits,
short layer ) const
private

Given a layer number, the hit sitting on this layer is flagged as invalid.

Used for outlier removal.

Parameters
[in]hitsArray of hits.
[in]layerThe layer that should be masked.

Definition at line 325 of file TrackTimeDefAndQualityAlg.cxx.

327 {
328 for (auto& hit : hits) {
329 if (hit.m_layer == layer) {
330 hit.m_isvalid = false;
331 }
332 }
333}

◆ 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_WARNING(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.

◆ trackTimeResolution()

float HGTD::TrackTimeDefAndQualityAlg::trackTimeResolution ( const std::array< Hit, s_hgtd_layers > & hits) const
private

Calculates the combined resolution.

Definition at line 293 of file TrackTimeDefAndQualityAlg.cxx.

295 {
296
297 float sum = 0.;
298 for (const auto& hit : hits) {
299 if (hit.m_isvalid) {
300 sum += 1. / (hit.m_resolution * hit.m_resolution);
301 }
302 }
303 return sum == 0. ? m_default_time_res.value()
304 : static_cast<float>(std::sqrt(1. / sum));
305}

◆ 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_chi2_threshold

FloatProperty HGTD::TrackTimeDefAndQualityAlg::m_chi2_threshold
private
Initial value:
{
this, "Chi2Threshold", 1.5,
"Quality cut for decision to keep hits compatible in time"}

Definition at line 125 of file TrackTimeDefAndQualityAlg.h.

125 {
126 this, "Chi2Threshold", 1.5,
127 "Quality cut for decision to keep hits compatible in time"};

◆ m_comp_ptrn_sft

const short HGTD::TrackTimeDefAndQualityAlg::m_comp_ptrn_sft = 8
private

Definition at line 63 of file TrackTimeDefAndQualityAlg.h.

◆ m_default_time

FloatProperty HGTD::TrackTimeDefAndQualityAlg::m_default_time
private
Initial value:
{
this, "DefaultTime", 0.0,
"Default time used for tracks without HGTD timing info"}

Definition at line 131 of file TrackTimeDefAndQualityAlg.h.

131 {
132 this, "DefaultTime", 0.0,
133 "Default time used for tracks without HGTD timing info"};

◆ m_default_time_res

FloatProperty HGTD::TrackTimeDefAndQualityAlg::m_default_time_res
private
Initial value:
{
this, "DefaultTimeRes", 50. / std::sqrt(12.),
"Default time resolution used for tracks without HGTD timing info"}

Definition at line 136 of file TrackTimeDefAndQualityAlg.h.

136 {
137 this, "DefaultTimeRes", 50. / std::sqrt(12.),
138 "Default time resolution used for tracks without HGTD timing info"};

◆ m_deltat_cut

FloatProperty HGTD::TrackTimeDefAndQualityAlg::m_deltat_cut
private
Initial value:
{this, "DeltaTCut", 2.0,
"Upper limit for a cluster delta t cut"}

Definition at line 128 of file TrackTimeDefAndQualityAlg.h.

128 {this, "DeltaTCut", 2.0,
129 "Upper limit for a cluster delta t cut"};

◆ 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_doActs

Gaudi::Property<bool> HGTD::TrackTimeDefAndQualityAlg::m_doActs {this, "doActs", false}
private

Definition at line 105 of file TrackTimeDefAndQualityAlg.h.

105{this, "doActs", 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_hasValidTime_dec_key

SG::WriteDecorHandleKey<xAOD::TrackParticleContainer> HGTD::TrackTimeDefAndQualityAlg::m_hasValidTime_dec_key
private
Initial value:
{
this, "hasValidTime", m_trackParticleContainerKey, "hasValidTime", "Time assigned to this track is valid"}

Definition at line 98 of file TrackTimeDefAndQualityAlg.h.

98 {
99 this, "hasValidTime", m_trackParticleContainerKey, "hasValidTime", "Time assigned to this track is valid"};

◆ m_holes_ptrn_sft

const short HGTD::TrackTimeDefAndQualityAlg::m_holes_ptrn_sft = 12
private

Definition at line 64 of file TrackTimeDefAndQualityAlg.h.

◆ m_layerClusterTimeKey

SG::ReadDecorHandleKey<xAOD::TrackParticleContainer> HGTD::TrackTimeDefAndQualityAlg::m_layerClusterTimeKey
private
Initial value:
{
this, "HGTD_cluster_time", m_trackParticleContainerKey, "HGTD_cluster_time",
"deco with a handle for cluster time"}

Definition at line 84 of file TrackTimeDefAndQualityAlg.h.

84 {
85 this, "HGTD_cluster_time", m_trackParticleContainerKey, "HGTD_cluster_time",
86 "deco with a handle for cluster time"};

◆ m_layerClusterTruthClassKey

SG::ReadDecorHandleKey<xAOD::TrackParticleContainer> HGTD::TrackTimeDefAndQualityAlg::m_layerClusterTruthClassKey
private
Initial value:
{
this, "HGTD_cluster_truth_class", m_trackParticleContainerKey,
"HGTD_cluster_truth_class",
"deco with a handle for a truth time"}

Definition at line 88 of file TrackTimeDefAndQualityAlg.h.

88 {
89 this, "HGTD_cluster_truth_class", m_trackParticleContainerKey,
90 "HGTD_cluster_truth_class",
91 "deco with a handle for a truth time"};

◆ m_layerHasExtensionKey

SG::ReadDecorHandleKey<xAOD::TrackParticleContainer> HGTD::TrackTimeDefAndQualityAlg::m_layerHasExtensionKey
private
Initial value:
{
this, "HGTD_has_extension", m_trackParticleContainerKey, "HGTD_has_extension",
"deco with a handle for an extension"}

Definition at line 81 of file TrackTimeDefAndQualityAlg.h.

81 {
82 this, "HGTD_has_extension", m_trackParticleContainerKey, "HGTD_has_extension",
83 "deco with a handle for an extension"};

◆ m_primes_ptrn_sft

const short HGTD::TrackTimeDefAndQualityAlg::m_primes_ptrn_sft = 16
private

Definition at line 65 of file TrackTimeDefAndQualityAlg.h.

◆ m_recoed_ptrn_sft

const short HGTD::TrackTimeDefAndQualityAlg::m_recoed_ptrn_sft = 0
private

Definition at line 61 of file TrackTimeDefAndQualityAlg.h.

◆ m_summarypattern_dec_key

SG::WriteDecorHandleKey<xAOD::TrackParticleContainer> HGTD::TrackTimeDefAndQualityAlg::m_summarypattern_dec_key
private
Initial value:
{this, "HGTD_summaryinfo", m_trackParticleContainerKey,
"HGTD_summaryinfo",
"Bitfield for working point definition"}

Definition at line 101 of file TrackTimeDefAndQualityAlg.h.

101 {this, "HGTD_summaryinfo", m_trackParticleContainerKey,
102 "HGTD_summaryinfo",
103 "Bitfield for working point definition"};

◆ m_time_dec_key

SG::WriteDecorHandleKey<xAOD::TrackParticleContainer> HGTD::TrackTimeDefAndQualityAlg::m_time_dec_key
private
Initial value:
{
this, "time", m_trackParticleContainerKey, "time", "Time assigned to this track"}

Definition at line 93 of file TrackTimeDefAndQualityAlg.h.

93 {
94 this, "time", m_trackParticleContainerKey, "time", "Time assigned to this track"};

◆ m_time_res_dec_key

SG::WriteDecorHandleKey<xAOD::TrackParticleContainer> HGTD::TrackTimeDefAndQualityAlg::m_time_res_dec_key
private
Initial value:
{
this, "timeResolution", m_trackParticleContainerKey, "timeResolution",
"Time resolution assigned to this track"}

Definition at line 95 of file TrackTimeDefAndQualityAlg.h.

95 {
96 this, "timeResolution", m_trackParticleContainerKey, "timeResolution",
97 "Time resolution assigned to this track"};

◆ m_trackParticleContainerKey

SG::ReadHandleKey<xAOD::TrackParticleContainer> HGTD::TrackTimeDefAndQualityAlg::m_trackParticleContainerKey
private
Initial value:
{
this, "TrackParticleContainerName", "InDetTrackParticles",
"Name of the TrackParticle container"}

Definition at line 77 of file TrackTimeDefAndQualityAlg.h.

77 {
78 this, "TrackParticleContainerName", "InDetTrackParticles",
79 "Name of the TrackParticle container"};

◆ 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.


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