ATLAS Offline Software
Loading...
Searching...
No Matches
TrackCollHandle_TrkTrack.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7// //
8// Implementation of class TrackCollHandle_TrkTrack //
9// //
10// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11// Initial version: February 2008 //
12// //
14
17#include "VP1Base/IVP1System.h"
19#include "VP1Base/VP1QtUtils.h"
23
24#include "TrkTrack/Track.h"
26
27#include <QRegExp>
28
29//____________________________________________________________________
38
40 = VP1QtUtils::environmentVariableIsOn("VP1_ALWAYS_SHOW_ALL_TRACK_COLLECTIONS");
41
42//____________________________________________________________________
44{
45 //There must be at least one of the trackers available for this to make sense.
48 sys->messageDebug("TrackCollHandle_TrkTrack::availableCollections: Neither"
49 " Pixel, SCT, TRT or Muon geometry available. Won't"
50 " look in event store for Trk::Track collections");
51 return {};
52 }
53
54 QStringList keysInSG;
55 for(const QString& key : VP1SGContentsHelper(sys).getKeys<TrackCollection>()) {
56 // if ( key=="CombinedInDetTracks") // Useful for debugging to limit to one collection
57 keysInSG<<key;
58 }
59
60 if (keysInSG.isEmpty()||Imp::alwaysShowAllTrackColls)
61 return keysInSG;
62
63 QRegExp needsMuonsPattern("Converted.*|.*MBoy.*|.*Moore.*|.*Mu.*|.*Staco.*");
64 QRegExp needsTRTPattern(".*trt.*|.*TRT.*|.*Trt.*");
65 QRegExp needsAllIDPattern("ExtendedTracks|ResolvedTracks|Tracks|.*Id.*|.*ID.*|.*InDet.*|.*Inner.*");
66
67 const bool jobcfgAllID
71
72 QStringList outkeys;
73
74 for (const QString& key : keysInSG) {
75 if (!VP1JobConfigInfo::hasMuonGeometry() && needsMuonsPattern.exactMatch(key)) {
76 sys->messageDebug("TrackCollHandle_TrkTrack::availableCollections: Ignoring key '"
77 +key+"' since muon geometry is not present in job.");
78 continue;
79 }
80 if (!jobcfgAllID && needsAllIDPattern.exactMatch(key)) {
81 sys->messageDebug("TrackCollHandle_TrkTrack::availableCollections: Ignoring key '"
82 +key+"' since pixel, sct and trt geometry are not all present in job.");
83 continue;
84 }
85 if (!VP1JobConfigInfo::hasTRTGeometry()&&needsTRTPattern.exactMatch(key)) {
86 sys->messageDebug("TrackCollHandle_TrkTrack::availableCollections: Ignoring key '"
87 +key+"' since trt geometry is not present in job.");
88 continue;
89 }
90
91 outkeys<<key;
92 }
93 return outkeys;
94
95}
96
97//____________________________________________________________________
99 const QString& name,
102{
103 m_d->theclass = this;
104 m_d->detailLevel = TrackCommonFlags::AUTO;
105}
106
107//____________________________________________________________________
112
113//____________________________________________________________________
115{
116 QString env = VP1QtUtils::environmentVariableValue("VP1_FATRAS_TRACKCOLLS_PATTERN");
117 return QRegExp((env.isEmpty()?"*fatras*":env),Qt::CaseInsensitive,QRegExp::Wildcard).exactMatch(key);
118}
119
120//____________________________________________________________________
122{
123 //Get collection:
124 const TrackCollection * trackColl(nullptr);
125 if (!VP1SGAccessHelper(systemBase()).retrieve(trackColl, name())) {
126 message("Error: Could not retrieve track collection with key="+name());
127 return false;
128 }
129
130 //Make appropriate trk::track handles:
131 hintNumberOfTracksInEvent(trackColl->size());
132 int i(0);
133 TrackCollection::const_iterator trackItr, trackItrEnd = trackColl->end();
134 for ( trackItr = trackColl->begin() ; trackItr != trackItrEnd; ++trackItr) {
135 if (*trackItr)
136 addTrackHandle(new TrackHandle_TrkTrack(this,*trackItr));
137 else
138 messageDebug("WARNING: Ignoring null Trk::Track pointer.");
139 if (!(i++%100))
141 }
142
143 //Maybe we need to show measurements, etc.:
144 // updateVisibleAssociatedObjects();
145
146 return true;
147}
148
149//____________________________________________________________________
151{
152 if (!TrackCollHandleBase::cut(handle))
153 return false;
154
155 //fixme: more?
156 return true;
157}
158
159//____________________________________________________________________
161{
162 common()->visTrkTracksToMaterialHelper()->setState(trkhandle->trkTrackPointer(), (trkhandle->visible() ? trkhandle->currentMaterial() : nullptr ));
163}
164
165
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
void updateGUI()
TrackSysCommonData * common() const
void hintNumberOfTracksInEvent(unsigned)
const QString & name() const
virtual bool cut(TrackHandleBase *)
void addTrackHandle(TrackHandleBase *)
TrackCollHandleBase(TrackSysCommonData *, const QString &name, TrackType::Type)
static bool isFatrasTruthTrack(const QString &key)
TrackCommonFlags::DETAILLEVEL detailLevel
void visibleStateUpdated(TrackHandle_TrkTrack *)
virtual bool cut(TrackHandleBase *)
TrackCollHandle_TrkTrack(TrackSysCommonData *, const QString &name, TrackType::Type type=TrackType::TrkTrack)
static QStringList availableCollections(IVP1System *)
SoMaterial * currentMaterial() const
bool visible() const
const Trk::Track * trkTrackPointer() const
VisibleObjectToMaterialHelper< Trk::Track > * visTrkTracksToMaterialHelper() const
void message(const QString &) const
IVP1System * systemBase() const
void messageDebug(const QString &) const
static bool hasTRTGeometry()
static bool hasPixelGeometry()
static bool hasSCTGeometry()
static bool hasMuonGeometry()
static bool environmentVariableIsOn(const QString &name)
static QString environmentVariableValue(const QString &name)
void setState(const objectT *, SoMaterial *mat)