ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::TrkObserverTool Class Reference

#include <TrkObserverTool.h>

Inheritance diagram for Trk::TrkObserverTool:
Collaboration diagram for Trk::TrkObserverTool:

Classes

struct  CacheEntry

Public Member Functions

 TrkObserverTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~TrkObserverTool ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void updateTrackMap (int uid, double score, xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason) const
void updateScore (int uid, double score) const
void rejectTrack (int uid, xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason) const
void addInputTrack (int uid, const Trk::Track &track) const
void addSubTrack (int track_uid, int parent_uid, const Trk::Track &track) const
ObservedTrackMapgetTrackMap (const EventContext &ctx) const
int saveTracksToStore (const EventContext &ctx, const ObservedTrackMap *trk_map) const
void updateHolesSharedHits (int uid, int numPixelHoles, int numSCTHoles, int numSplitSharedPixel, int numSplitSharedSCT, int numSharedOrSplit, int numSharedOrSplitPixels, int numShared, int isPatternTrack, int totalSiHits, int inROI, int hasIBLHit, int hasSharedIBLHit, int hasSharedPixel, int firstPixIsShared, int numPixelDeadSensor, int numSCTDeadSensor, int numPixelHits, int numSCTHits, int numUnused, int numTRT_Unused, int numSCT_Unused, int numPseudo, float averageSplit1, float averageSplit2, int numWeightedShared) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

void newEvent (CacheEntry *ent) const
void dumpTrackMap (const ObservedTrackMap *trk_map) const

Static Private Member Functions

static std::string dumpRejection (xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason)
static int getNFinalTracks (const ObservedTrackMap *trk_map)
static int getNObservedTracks (const ObservedTrackMap *trk_map)

Private Attributes

SG::WriteHandleKey< TrackCollectionm_savedTracksWriteKey
SG::WriteHandleKey< ObservedTrackMapm_savedTracksMapWriteKey
std::mutex m_mutex
SG::SlotSpecificObj< CacheEntry > m_cache ATLAS_THREAD_SAFE

Static Private Attributes

static const std::map< xAOD::RejectionStep, std::string > m_rejectStep_descriptions
static const std::map< xAOD::RejectionReason, std::string > m_rejectReason_descriptions

Detailed Description

Definition at line 40 of file TrkObserverTool.h.

Constructor & Destructor Documentation

◆ TrkObserverTool()

Trk::TrkObserverTool::TrkObserverTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 61 of file TrkObserverTool.cxx.

62 : AthAlgTool(type, name, parent){
63 declareInterface< ITrkObserverTool >(this);
64 declareProperty("ObsTrackCollection", m_savedTracksWriteKey);
65 declareProperty("ObsTrackCollectionMap", m_savedTracksMapWriteKey);
66}
SG::WriteHandleKey< TrackCollection > m_savedTracksWriteKey
SG::WriteHandleKey< ObservedTrackMap > m_savedTracksMapWriteKey

◆ ~TrkObserverTool()

Trk::TrkObserverTool::~TrkObserverTool ( )
virtualdefault

Member Function Documentation

◆ addInputTrack()

void Trk::TrkObserverTool::addInputTrack ( int uid,
const Trk::Track & track ) const
virtual

Implements Trk::ITrkObserverTool.

Definition at line 168 of file TrkObserverTool.cxx.

168 {
169
170 ATH_MSG_DEBUG("addInputTrack: track "<<uid);
171 // test to see if we have a new event
172 const EventContext& ctx{Gaudi::Hive::currentContext()};
173 std::lock_guard<std::mutex> lock{m_mutex};
174 CacheEntry* ent{m_cache.get(ctx)};
175 if (ent->m_evt!=ctx.evt()) {
176 // New event in this slot
177 newEvent(ent);
178 ent->m_evt = ctx.evt();
179 }
180 // add input track to cache map
181 std::unique_ptr<Trk::Track> copiedTrack = std::make_unique<Trk::Track>(track);
182 std::vector<xAOD::RejectionStep> v_rejectStep = {xAOD::RejectionStep::solveTracks};
183 std::vector<xAOD::RejectionReason> v_rejectReason = {xAOD::RejectionReason::acceptedTrack};
184 ent->m_observedTrkMap->insert( std::make_pair(uid, std::make_tuple(copiedTrack.release(), // Id, track
185 -1, // score
186 xAOD::RejectionStep::solveTracks, // rejection step
187 xAOD::RejectionReason::acceptedTrack, // rejection reason
188 0, // unique parentId
189 // holes/shared/split hits information (-2 means not filled yet)
190 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2.0f, -2.0f, -2,
191 v_rejectStep, v_rejectReason)));
192}
#define ATH_MSG_DEBUG(x)
void newEvent(CacheEntry *ent) const

◆ addSubTrack()

void Trk::TrkObserverTool::addSubTrack ( int track_uid,
int parent_uid,
const Trk::Track & track ) const
virtual

Implements Trk::ITrkObserverTool.

Definition at line 194 of file TrkObserverTool.cxx.

194 {
195
196 ATH_MSG_DEBUG("addSubTrack: subtrack "<<track_uid);
197 // get event context and map from cache
198 const EventContext& ctx{Gaudi::Hive::currentContext()};
199 std::lock_guard<std::mutex> lock{m_mutex};
200 ObservedTrackMap* trk_map = getTrackMap(ctx);
201
202 // deep copy of the track (because some subtracks get deleted), information has to be available later
203 std::unique_ptr<Trk::Track> copiedTrack = std::make_unique<Trk::Track>(track);
204 // get score and rejection step from parent element
205 double score = -1;
207 if ( trk_map->find(parent_uid) == trk_map->end() ) {
208 // not found
209 ATH_MSG_WARNING("addSubTrack: parent " << parent_uid << " not found in observedTrkMap");
210 }
211 else {
212 // found
213 score = std::get<xAOD::ObserverToolIndex::score>(trk_map->at(parent_uid));
214 rejectStep = std::get<xAOD::ObserverToolIndex::rejectStep>(trk_map->at(parent_uid));
215 ATH_MSG_DEBUG("addSubTrack: track "<<track_uid<<" with parent "<<parent_uid<<", score "<<score);
216 }
217 // add subtrack to cache map
218 std::vector<xAOD::RejectionStep> v_rejectStep = {rejectStep};
219 std::vector<xAOD::RejectionReason> v_rejectReason = {xAOD::RejectionReason::acceptedTrack};
220 trk_map->insert( std::make_pair(track_uid, std::make_tuple(copiedTrack.release(), // Id, track
221 score, // score
222 rejectStep, // rejection step
223 xAOD::RejectionReason::acceptedTrack, // rejection reason
224 parent_uid, // unique parentId
225 // holes/shared/split hits information (-2 means not filled yet)
226 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2.0f, -2.0f, -2,
227 v_rejectStep, v_rejectReason)));
228}
#define ATH_MSG_WARNING(x)
std::map< int, std::tuple< Trk::Track *, double, xAOD::RejectionStep, xAOD::RejectionReason, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, float, float, int, std::vector< xAOD::RejectionStep >, std::vector< xAOD::RejectionReason > > > ObservedTrackMap
ObservedTrackMap * getTrackMap(const EventContext &ctx) const

◆ dumpRejection()

std::string Trk::TrkObserverTool::dumpRejection ( xAOD::RejectionStep rejectStep,
xAOD::RejectionReason rejectReason )
staticprivate

Definition at line 391 of file TrkObserverTool.cxx.

391 {
392 // Generate rejection description
393 std::string rejection_step = "";
394 std::string rejection_reason = "";
395 std::string rejection_description = "";
396 const auto istep = m_rejectStep_descriptions.find(rejectStep);
397 if ( istep == m_rejectStep_descriptions.end() ) {
398 // not found
399 rejection_step = "REJECTION STEP DESCRIPTION NOT FOUND: " + std::to_string(rejectStep);
400 }
401 else {
402 // found
403 rejection_step = istep->second;
404 }
405 const auto ireason = m_rejectReason_descriptions.find(rejectReason);
406 if ( ireason == m_rejectReason_descriptions.end() ) {
407 // not found
408 rejection_reason = "REJECTION REASON DESCRIPTION NOT FOUND: " + std::to_string(rejectReason);
409 }
410 else {
411 // found
412 rejection_reason = ireason->second;
413 }
414 rejection_description = rejection_step + " (" + rejection_reason + ")";
415 return rejection_description;
416}
static const std::map< xAOD::RejectionReason, std::string > m_rejectReason_descriptions
static const std::map< xAOD::RejectionStep, std::string > m_rejectStep_descriptions

◆ dumpTrackMap()

void Trk::TrkObserverTool::dumpTrackMap ( const ObservedTrackMap * trk_map) const
private

Definition at line 349 of file TrkObserverTool.cxx.

349 {
350
351 // prints out/dumps all entries in m_observedTrkMap
352
353 std::lock_guard<std::mutex> lock{m_mutex};
354
355 ATH_MSG_INFO ("Dump observedTrkMap (size = " << getNObservedTracks(trk_map) << ")");
356 for (const auto& itrMap : *trk_map) {
357 ATH_MSG_DEBUG("Id: " << itrMap.first);
358 ATH_MSG_DEBUG("\tscore: " << std::get<xAOD::ObserverToolIndex::score>(itrMap.second));
359 ATH_MSG_DEBUG("\trejectStep: " << std::get<xAOD::ObserverToolIndex::rejectStep>(itrMap.second));
360 ATH_MSG_DEBUG("\trejectReason: " << std::get<xAOD::ObserverToolIndex::rejectReason>(itrMap.second));
361 ATH_MSG_DEBUG("\tparentId: " << std::get<xAOD::ObserverToolIndex::parentId>(itrMap.second));
362 ATH_MSG_DEBUG("\tnumPixelHoles: " << std::get<xAOD::ObserverToolIndex::numPixelHoles>(itrMap.second));
363 ATH_MSG_DEBUG("\tnumSCTHoles: " << std::get<xAOD::ObserverToolIndex::numSCTHoles>(itrMap.second));
364 ATH_MSG_DEBUG("\tnumSplitSharedPixel: " << std::get<xAOD::ObserverToolIndex::numSplitSharedPixel>(itrMap.second));
365 ATH_MSG_DEBUG("\tnumSplitSharedSCT: " << std::get<xAOD::ObserverToolIndex::numSplitSharedSCT>(itrMap.second));
366 ATH_MSG_DEBUG("\tnumSharedOrSplit: " << std::get<xAOD::ObserverToolIndex::numSharedOrSplit>(itrMap.second));
367 ATH_MSG_DEBUG("\tnumSharedOrSplitPixels: " << std::get<xAOD::ObserverToolIndex::numSharedOrSplitPixels>(itrMap.second));
368 ATH_MSG_DEBUG("\tnumShared: " << std::get<xAOD::ObserverToolIndex::numShared>(itrMap.second));
369 ATH_MSG_DEBUG("\tisPatternTrack: " << std::get<xAOD::ObserverToolIndex::isPatternTrack>(itrMap.second));
370 ATH_MSG_DEBUG("\ttotalSiHits: " << std::get<xAOD::ObserverToolIndex::totalSiHits>(itrMap.second));
371 ATH_MSG_DEBUG("\tinROI: " << std::get<xAOD::ObserverToolIndex::inROI>(itrMap.second));
372 ATH_MSG_DEBUG("\thasIBLHit: " << std::get<xAOD::ObserverToolIndex::hasIBLHit>(itrMap.second));
373 ATH_MSG_DEBUG("\thasSharedIBLHit: " << std::get<xAOD::ObserverToolIndex::hasSharedIBLHit>(itrMap.second));
374 ATH_MSG_DEBUG("\thasSharedPixel: " << std::get<xAOD::ObserverToolIndex::hasSharedPixel>(itrMap.second));
375 ATH_MSG_DEBUG("\tfirstPixIsShared: " << std::get<xAOD::ObserverToolIndex::firstPixIsShared>(itrMap.second));
376 ATH_MSG_DEBUG("\tnumPixelDeadSensor: " << std::get<xAOD::ObserverToolIndex::numPixelDeadSensor>(itrMap.second));
377 ATH_MSG_DEBUG("\tnumSCTDeadSensor: " << std::get<xAOD::ObserverToolIndex::numSCTDeadSensor>(itrMap.second));
378 ATH_MSG_DEBUG("\tnumPixelHits: " << std::get<xAOD::ObserverToolIndex::numPixelHits>(itrMap.second));
379 ATH_MSG_DEBUG("\tnumSCTHits: " << std::get<xAOD::ObserverToolIndex::numSCTHits>(itrMap.second));
380 ATH_MSG_DEBUG("\tnumUnused: " << std::get<xAOD::ObserverToolIndex::numUnused>(itrMap.second));
381 ATH_MSG_DEBUG("\tnumTRT_Unused: " << std::get<xAOD::ObserverToolIndex::numTRT_Unused>(itrMap.second));
382 ATH_MSG_DEBUG("\tnumSCT_Unused: " << std::get<xAOD::ObserverToolIndex::numSCT_Unused>(itrMap.second));
383 ATH_MSG_DEBUG("\tnumPseudo: " << std::get<xAOD::ObserverToolIndex::numPseudo>(itrMap.second));
384 ATH_MSG_DEBUG("\taverageSplit1: " << std::get<xAOD::ObserverToolIndex::averageSplit1>(itrMap.second));
385 ATH_MSG_DEBUG("\taverageSplit2: " << std::get<xAOD::ObserverToolIndex::averageSplit2>(itrMap.second));
386 ATH_MSG_DEBUG("\tnumWeightedShared: " << std::get<xAOD::ObserverToolIndex::numWeightedShared>(itrMap.second));
387 }
388 ATH_MSG_DEBUG("Number of RejectionReason = acceptedTrack (should equal final tracks): " << getNFinalTracks(trk_map));
389}
#define ATH_MSG_INFO(x)
static int getNFinalTracks(const ObservedTrackMap *trk_map)
static int getNObservedTracks(const ObservedTrackMap *trk_map)

◆ finalize()

StatusCode Trk::TrkObserverTool::finalize ( )
virtual

Definition at line 85 of file TrkObserverTool.cxx.

85 {
86 ATH_MSG_INFO("Finalizing " << name() << "...");
87 return StatusCode::SUCCESS;
88}

◆ getNFinalTracks()

int Trk::TrkObserverTool::getNFinalTracks ( const ObservedTrackMap * trk_map)
staticprivate

Definition at line 418 of file TrkObserverTool.cxx.

418 {
419 // counts the tracks which did not get rejected (this number should equal finalTracks)
420 int nFinalTracks = 0;
421 for (const auto& itrMap : *trk_map) {
422 if (std::get<xAOD::ObserverToolIndex::rejectReason>(itrMap.second) == xAOD::RejectionReason::acceptedTrack) nFinalTracks++;
423 }
424 return nFinalTracks;
425}

◆ getNObservedTracks()

int Trk::TrkObserverTool::getNObservedTracks ( const ObservedTrackMap * trk_map)
staticprivate

Definition at line 427 of file TrkObserverTool.cxx.

427 {
428 // check the number of tracks in the observer tool map
429 return trk_map->size();
430}

◆ getTrackMap()

ObservedTrackMap * Trk::TrkObserverTool::getTrackMap ( const EventContext & ctx) const
virtual

Implements Trk::ITrkObserverTool.

Definition at line 230 of file TrkObserverTool.cxx.

230 {
231
232 ATH_MSG_DEBUG("Get track map from cache");
233 // get cache
234 CacheEntry* ent{m_cache.get(ctx)};
235 // sanity check
236 if (ent->m_evt!=ctx.evt()) {
237 ATH_MSG_ERROR("Different event context in getTrackMap!!");
238 }
239 return ent->m_observedTrkMap;
240}
#define ATH_MSG_ERROR(x)

◆ initialize()

StatusCode Trk::TrkObserverTool::initialize ( )
virtual

Definition at line 74 of file TrkObserverTool.cxx.

74 {
75 ATH_MSG_INFO("Initializing TrkObserverTool with name: " << name());
76 ATH_MSG_INFO("\tm_savedTracksWriteKey: " << m_savedTracksWriteKey.key());
77 ATH_MSG_INFO("\tm_savedTracksMapWriteKey: " << m_savedTracksMapWriteKey.key());
78 ATH_CHECK(AthAlgTool::initialize());
79 ATH_CHECK(m_savedTracksWriteKey.initialize(!m_savedTracksWriteKey.key().empty()));
81 ATH_MSG_INFO("Initialized TrkObserverTool");
82 return StatusCode::SUCCESS;
83}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ interfaceID()

const InterfaceID & Trk::ITrkObserverTool::interfaceID ( )
inlinestaticinherited

Definition at line 49 of file ITrkObserverTool.h.

49 {
51 }
static const InterfaceID IID_ITrkObserverTool("Trk::ITrkObserverTool", 1, 0)

◆ newEvent()

void Trk::TrkObserverTool::newEvent ( CacheEntry * ent) const
private

Definition at line 93 of file TrkObserverTool.cxx.

93 {
94 ATH_MSG_DEBUG("Starting new event");
95 if (ent->m_observedTrkMap) {
96 ent->m_observedTrkMap->clear();
97 delete ent->m_observedTrkMap;
98 }
99 ent->m_observedTrkMap = new ObservedTrackMap;
100}

◆ rejectTrack()

void Trk::TrkObserverTool::rejectTrack ( int uid,
xAOD::RejectionStep rejectStep,
xAOD::RejectionReason rejectReason ) const
virtual

Implements Trk::ITrkObserverTool.

Definition at line 145 of file TrkObserverTool.cxx.

145 {
146
147 ATH_MSG_DEBUG("rejectTrack: track "<<uid);
148 // get event context and map from cache
149 const EventContext& ctx{Gaudi::Hive::currentContext()};
150 std::lock_guard<std::mutex> lock{m_mutex};
151 ObservedTrackMap* trk_map = getTrackMap(ctx);
152 // find track and update rejection location
153 if ( trk_map->find(uid) == trk_map->end() ) {
154 // not found
155 ATH_MSG_WARNING("rejectTrack: track "<<uid<<" not found in observedTrkMap");
156 }
157 else {
158 // found
159 std::get<xAOD::ObserverToolIndex::rejectStep>(trk_map->at(uid)) = rejectStep;
160 std::get<xAOD::ObserverToolIndex::rejectReason>(trk_map->at(uid)) = rejectReason;
161 // Keep track of cumulative rejection steps/reasons
162 std::get<xAOD::ObserverToolIndex::rejectStep_full>(trk_map->at(uid)).push_back(rejectStep);
163 std::get<xAOD::ObserverToolIndex::rejectReason_full>(trk_map->at(uid)).push_back(rejectReason);
164 ATH_MSG_DEBUG("rejectTrack: track "<<uid<<" with rejection in "<<dumpRejection(rejectStep, rejectReason));
165 }
166}
static std::string dumpRejection(xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason)

◆ saveTracksToStore()

int Trk::TrkObserverTool::saveTracksToStore ( const EventContext & ctx,
const ObservedTrackMap * trk_map ) const
virtual

Implements Trk::ITrkObserverTool.

Definition at line 242 of file TrkObserverTool.cxx.

242 {
243
244 std::lock_guard<std::mutex> lock{m_mutex};
245 // Save tracks and map to store
246 ATH_MSG_INFO ("saveTracksToStore: Recording empty observed track containers to event store");
247 ATH_MSG_DEBUG("\tm_savedTracksWriteKey: "<<m_savedTracksWriteKey.key());
248 ATH_MSG_DEBUG("\tm_savedTracksMapWriteKey: "<<m_savedTracksMapWriteKey.key());
249
250 SG::WriteHandle<TrackCollection> wh_tracks{m_savedTracksWriteKey, ctx};
251 SG::WriteHandle<ObservedTrackMap> wh_tracksMap{m_savedTracksMapWriteKey, ctx};
252
253 // Tracks write handle
254 StatusCode sc = wh_tracks.record(std::make_unique<TrackCollection>());
255 if (sc.isFailure()) {
256 ATH_MSG_ERROR("saveTracksToStore: Could not record input tracks: "<<m_savedTracksWriteKey.key());
257 }
258 else {
259 ATH_MSG_INFO("saveTracksToStore: Recorded empty container for input tracks to: "<<m_savedTracksWriteKey.key());
260 }
261 if (!wh_tracks.isValid()) {
262 ATH_MSG_DEBUG ("saveTracksToStore: Invalid key: "<<m_savedTracksWriteKey.key());
263 }
264 else {
265 ATH_MSG_DEBUG ("saveTracksToStore: Valid key: "<<m_savedTracksWriteKey.key());
266 }
267
268 // Tracks map write handle
269 sc = wh_tracksMap.record(std::make_unique<ObservedTrackMap>());
270 if (sc.isFailure()) {
271 ATH_MSG_ERROR("saveTracksToStore: Could not record tracks map: "<<m_savedTracksMapWriteKey.key());
272 }
273 else {
274 ATH_MSG_INFO("saveTracksToStore: Recorded empty container for tracks map to: "<<m_savedTracksMapWriteKey.key());
275 }
276 if (!wh_tracksMap.isValid()) {
277 ATH_MSG_DEBUG ("saveTracksToStore: Invalid key: "<<m_savedTracksMapWriteKey.key());
278 }
279 else {
280 ATH_MSG_DEBUG ("saveTracksToStore: Valid key: "<<m_savedTracksMapWriteKey.key());
281 }
282 if (!trk_map){
283 return 0;
284 }
285 else {
286 ATH_MSG_INFO ("saveTracksToStore: Recording "<<trk_map->size() << " observed track candidates to event store");
287 }
288 for (const auto& itrMap : *trk_map) {
289 ATH_MSG_DEBUG("saveTracksToStore: Writing track with id "<<itrMap.first<<", rejection step "<<std::get<xAOD::ObserverToolIndex::rejectStep>(itrMap.second)<<", rejection reason "<<std::get<xAOD::ObserverToolIndex::rejectReason>(itrMap.second));
290 wh_tracks->push_back(std::get<xAOD::ObserverToolIndex::track>(itrMap.second));
291 wh_tracksMap->insert(std::make_pair(itrMap.first, itrMap.second));
292 }
293
294 ATH_MSG_DEBUG("saveTracksToStore: Pushed "<<wh_tracks->size()<<" observed tracks to store");
295 ATH_MSG_DEBUG("saveTracksToStore: Pushed "<<wh_tracksMap->size()<<" pairs to track map in store");
296 // Keep track of "good" tracks as a sanity check
297 int nFinalTracks = getNFinalTracks(trk_map);
298 ATH_MSG_DEBUG ("saveTracksToStore: Number of RejectionReason = acceptedTrack (should equal final tracks): " << nFinalTracks);
299 return nFinalTracks;
300}
static Double_t sc
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ updateHolesSharedHits()

void Trk::TrkObserverTool::updateHolesSharedHits ( int uid,
int numPixelHoles,
int numSCTHoles,
int numSplitSharedPixel,
int numSplitSharedSCT,
int numSharedOrSplit,
int numSharedOrSplitPixels,
int numShared,
int isPatternTrack,
int totalSiHits,
int inROI,
int hasIBLHit,
int hasSharedIBLHit,
int hasSharedPixel,
int firstPixIsShared,
int numPixelDeadSensor,
int numSCTDeadSensor,
int numPixelHits,
int numSCTHits,
int numUnused,
int numTRT_Unused,
int numSCT_Unused,
int numPseudo,
float averageSplit1,
float averageSplit2,
int numWeightedShared ) const
virtual

Implements Trk::ITrkObserverTool.

Definition at line 302 of file TrkObserverTool.cxx.

305 {
306
307 ATH_MSG_DEBUG("updateHolesSharedHits: track "<<uid);
308 // get event context and map from cache
309 const EventContext& ctx{Gaudi::Hive::currentContext()};
310 std::lock_guard<std::mutex> lock{m_mutex};
311 ObservedTrackMap* trk_map = getTrackMap(ctx);
312
313 // find track and update rejection location
314 if ( trk_map->find(uid) == trk_map->end() ) {
315 // not found
316 ATH_MSG_WARNING("updateHolesSharedHits: track "<<uid<<" not found in observedTrkMap");
317 }
318 else {
319 // found
320 std::get<xAOD::ObserverToolIndex::numPixelHoles>(trk_map->at(uid)) = numPixelHoles;
321 std::get<xAOD::ObserverToolIndex::numSCTHoles>(trk_map->at(uid)) = numSCTHoles;
322 std::get<xAOD::ObserverToolIndex::numSplitSharedPixel>(trk_map->at(uid)) = numSplitSharedPixel; // Number of Pixel clusters comptaible with being split that are also shared
323 std::get<xAOD::ObserverToolIndex::numSplitSharedSCT>(trk_map->at(uid)) = numSplitSharedSCT; // Number of SCT clusters comptaible with being split that are also shared
324 std::get<xAOD::ObserverToolIndex::numSharedOrSplit>(trk_map->at(uid)) = numSharedOrSplit; // Number of split + shared clusters
325 std::get<xAOD::ObserverToolIndex::numSharedOrSplitPixels>(trk_map->at(uid)) = numSharedOrSplitPixels; // Number of pixel clusters that are either split or shared
326 std::get<xAOD::ObserverToolIndex::numShared>(trk_map->at(uid)) = numShared; // Number of shared hits on track
327 std::get<xAOD::ObserverToolIndex::isPatternTrack>(trk_map->at(uid)) = isPatternTrack; // Pattern Track or Fitted track
328 std::get<xAOD::ObserverToolIndex::totalSiHits>(trk_map->at(uid)) = totalSiHits; // totalSiHits
329 std::get<xAOD::ObserverToolIndex::inROI>(trk_map->at(uid)) = inROI;
330 std::get<xAOD::ObserverToolIndex::hasIBLHit>(trk_map->at(uid)) = hasIBLHit;
331 std::get<xAOD::ObserverToolIndex::hasSharedIBLHit>(trk_map->at(uid)) = hasSharedIBLHit;
332 std::get<xAOD::ObserverToolIndex::hasSharedPixel>(trk_map->at(uid)) = hasSharedPixel;
333 std::get<xAOD::ObserverToolIndex::firstPixIsShared>(trk_map->at(uid)) = firstPixIsShared;
334 std::get<xAOD::ObserverToolIndex::numPixelDeadSensor>(trk_map->at(uid)) = numPixelDeadSensor;
335 std::get<xAOD::ObserverToolIndex::numSCTDeadSensor>(trk_map->at(uid)) = numSCTDeadSensor;
336 std::get<xAOD::ObserverToolIndex::numPixelHits>(trk_map->at(uid)) = numPixelHits;
337 std::get<xAOD::ObserverToolIndex::numSCTHits>(trk_map->at(uid)) = numSCTHits;
338 std::get<xAOD::ObserverToolIndex::numUnused>(trk_map->at(uid)) = numUnused;
339 std::get<xAOD::ObserverToolIndex::numTRT_Unused>(trk_map->at(uid)) = numTRT_Unused;
340 std::get<xAOD::ObserverToolIndex::numSCT_Unused>(trk_map->at(uid)) = numSCT_Unused;
341 std::get<xAOD::ObserverToolIndex::numPseudo>(trk_map->at(uid)) = numPseudo;
342 std::get<xAOD::ObserverToolIndex::averageSplit1>(trk_map->at(uid)) = averageSplit1;
343 std::get<xAOD::ObserverToolIndex::averageSplit2>(trk_map->at(uid)) = averageSplit2;
344 std::get<xAOD::ObserverToolIndex::numWeightedShared>(trk_map->at(uid)) = numWeightedShared;
345 ATH_MSG_DEBUG("updateHolesSharedHits: track "<<uid<<" with totalSiHits "<<totalSiHits);
346 }
347}
@ numSharedOrSplitPixels

◆ updateScore()

void Trk::TrkObserverTool::updateScore ( int uid,
double score ) const
virtual

Implements Trk::ITrkObserverTool.

Definition at line 126 of file TrkObserverTool.cxx.

126 {
127
128 ATH_MSG_DEBUG("updateScore: track "<<uid);
129 // get event context and map from cache
130 const EventContext& ctx{Gaudi::Hive::currentContext()};
131 std::lock_guard<std::mutex> lock{m_mutex};
132 ObservedTrackMap* trk_map = getTrackMap(ctx);
133 // find track and update score
134 if ( trk_map->find(uid) == trk_map->end() ) {
135 // not found
136 ATH_MSG_WARNING("updateScore: track " << uid << " not found in observedTrkMap");
137 }
138 else {
139 // found
140 std::get<xAOD::ObserverToolIndex::score>(trk_map->at(uid)) = score;
141 ATH_MSG_DEBUG("updateScore: track "<<uid<<" with score "<<score);
142 }
143}

◆ updateTrackMap()

void Trk::TrkObserverTool::updateTrackMap ( int uid,
double score,
xAOD::RejectionStep rejectStep,
xAOD::RejectionReason rejectReason ) const
virtual

Implements Trk::ITrkObserverTool.

Definition at line 102 of file TrkObserverTool.cxx.

102 {
103
104 ATH_MSG_DEBUG("updateTrackMap: track "<<uid);
105 // get event context and map from cache
106 const EventContext& ctx{Gaudi::Hive::currentContext()};
107 std::lock_guard<std::mutex> lock{m_mutex};
108 ObservedTrackMap* trk_map = getTrackMap(ctx);
109 // find track and update score
110 if ( trk_map->find(uid) == trk_map->end() ) {
111 // not found
112 ATH_MSG_WARNING("updateTrackMap: track << " << uid << " not found in observedTrkMap");
113 }
114 else {
115 // found
116 std::get<xAOD::ObserverToolIndex::score>(trk_map->at(uid)) = score;
117 std::get<xAOD::ObserverToolIndex::rejectStep>(trk_map->at(uid)) = rejectStep;
118 std::get<xAOD::ObserverToolIndex::rejectReason>(trk_map->at(uid)) = rejectReason;
119 // Keep track of cumulative rejection steps/reasons
120 std::get<xAOD::ObserverToolIndex::rejectStep_full>(trk_map->at(uid)).push_back(rejectStep);
121 std::get<xAOD::ObserverToolIndex::rejectReason_full>(trk_map->at(uid)).push_back(rejectReason);
122 ATH_MSG_DEBUG("updateTrackMap: track "<<uid<<" with score, rejectStep, rejectReason: "<<score<<", "<<rejectStep<<", "<<rejectReason);
123 }
124}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

SG::SlotSpecificObj<CacheEntry> m_cache Trk::TrkObserverTool::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 71 of file TrkObserverTool.h.

◆ m_mutex

std::mutex Trk::TrkObserverTool::m_mutex
mutableprivate

Definition at line 65 of file TrkObserverTool.h.

◆ m_rejectReason_descriptions

const std::map< xAOD::RejectionReason, std::string > Trk::TrkObserverTool::m_rejectReason_descriptions
staticprivate

Definition at line 440 of file TrkObserverTool.h.

◆ m_rejectStep_descriptions

const std::map< xAOD::RejectionStep, std::string > Trk::TrkObserverTool::m_rejectStep_descriptions
staticprivate
Initial value:
= {
{xAOD::RejectionStep::addNewTracks, "DenseEnvironmentsAmbiguityScoreProcessorTool::addNewTracks"},
{xAOD::RejectionStep::refitTrack, "AmbiguityProcessorBase::refitTrack"},
{xAOD::RejectionStep::addTrack, "AmbiguityProcessorBase::addTrack"},
{xAOD::RejectionStep::decideWhichHitsToKeep, "InDetDenseEnvAmbiTrackSelectionTool::decideWhichHitsToKeep"},
{xAOD::RejectionStep::getCleanedOutTrack, "InDetDenseEnvAmbiTrackSelectionTool::getCleanedOutTrack"}
}
@ decideWhichHitsToKeep

Definition at line 432 of file TrkObserverTool.h.

467 {
468
469 class ITrackParticleCreatorTool;
470
471 class TrkObserverTool : virtual public Trk::ITrkObserverTool, public :: AthAlgTool {
472 public:
473 TrkObserverTool(const std::string& type, const std::string& name, const IInterface* parent);
474 virtual ~TrkObserverTool();
475 // athena algtool's Hooks
476 virtual StatusCode initialize();
477 virtual StatusCode finalize();
478 // const methods
479 void updateTrackMap(int uid, double score, xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason) const;
480 void updateScore(int uid, double score) const;
481 void rejectTrack(int uid, xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason) const;
482 void addInputTrack(int uid, const Trk::Track& track) const;
483 void addSubTrack(int track_uid, int parent_uid, const Trk::Track& track) const;
484 ObservedTrackMap* getTrackMap(const EventContext& ctx) const;
485 int saveTracksToStore(const EventContext& ctx, const ObservedTrackMap* trk_map) const;
486 void updateHolesSharedHits(int uid, int numPixelHoles, int numSCTHoles, int numSplitSharedPixel, int numSplitSharedSCT,
487 int numSharedOrSplit, int numSharedOrSplitPixels, int numShared, int isPatternTrack, int totalSiHits, int inROI, int hasIBLHit,
488 int hasSharedIBLHit, int hasSharedPixel, int firstPixIsShared, int numPixelDeadSensor, int numSCTDeadSensor, int numPixelHits,
489 int numSCTHits, int numUnused, int numTRT_Unused, int numSCT_Unused, int numPseudo, float averageSplit1, float averageSplit2, int numWeightedShared) const;
490
491 private:
492 // name of the observed (saved) track collection
493 SG::WriteHandleKey<TrackCollection> m_savedTracksWriteKey;
494 SG::WriteHandleKey<ObservedTrackMap> m_savedTracksMapWriteKey;
495
496 mutable std::mutex m_mutex;
497 struct CacheEntry {
498 EventContext::ContextEvt_t m_evt{EventContext::INVALID_CONTEXT_EVT};
499 // map with observed tracks and information
500 ObservedTrackMap* m_observedTrkMap;
501 };
502 mutable SG::SlotSpecificObj<CacheEntry> m_cache ATLAS_THREAD_SAFE; // Guarded by m_mutex
503
504 void newEvent(CacheEntry* ent) const;
505 void dumpTrackMap(const ObservedTrackMap* trk_map) const;
506 static std::string dumpRejection(xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason) ;
507 static int getNFinalTracks(const ObservedTrackMap* trk_map) ;
508 static int getNObservedTracks(const ObservedTrackMap* trk_map) ;
509 static const std::map<xAOD::RejectionStep, std::string> m_rejectStep_descriptions;
510 static const std::map<xAOD::RejectionReason, std::string> m_rejectReason_descriptions;
511 };
512}
513
514#endif // TRK_TRKOBSERVERTOOL_H
int saveTracksToStore(const EventContext &ctx, const ObservedTrackMap *trk_map) const
virtual ~TrkObserverTool()
void addInputTrack(int uid, const Trk::Track &track) const
void rejectTrack(int uid, xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason) const
void updateScore(int uid, double score) const
virtual StatusCode initialize()
void updateHolesSharedHits(int uid, int numPixelHoles, int numSCTHoles, int numSplitSharedPixel, int numSplitSharedSCT, int numSharedOrSplit, int numSharedOrSplitPixels, int numShared, int isPatternTrack, int totalSiHits, int inROI, int hasIBLHit, int hasSharedIBLHit, int hasSharedPixel, int firstPixIsShared, int numPixelDeadSensor, int numSCTDeadSensor, int numPixelHits, int numSCTHits, int numUnused, int numTRT_Unused, int numSCT_Unused, int numPseudo, float averageSplit1, float averageSplit2, int numWeightedShared) const
SG::SlotSpecificObj< CacheEntry > m_cache ATLAS_THREAD_SAFE
void addSubTrack(int track_uid, int parent_uid, const Trk::Track &track) const
void updateTrackMap(int uid, double score, xAOD::RejectionStep rejectStep, xAOD::RejectionReason rejectReason) const
virtual StatusCode finalize()
void dumpTrackMap(const ObservedTrackMap *trk_map) const
TrkObserverTool(const std::string &type, const std::string &name, const IInterface *parent)

◆ m_savedTracksMapWriteKey

SG::WriteHandleKey<ObservedTrackMap> Trk::TrkObserverTool::m_savedTracksMapWriteKey
private

Definition at line 63 of file TrkObserverTool.h.

◆ m_savedTracksWriteKey

SG::WriteHandleKey<TrackCollection> Trk::TrkObserverTool::m_savedTracksWriteKey
private

Definition at line 62 of file TrkObserverTool.h.


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