ATLAS Offline Software
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 //____________________________________________________________________
31 public:
32  static bool isFatrasTruthTrack(const QString& key);
36 
37 };
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(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 (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;
105 }
106 
107 //____________________________________________________________________
109 {
110  delete m_d;
111 }
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))
140  systemBase()->updateGUI();
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 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TrackCollHandleBase
Definition: TrackCollHandleBase.h:49
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TrackCollHandle_TrkTrack::TrackCollHandle_TrkTrack
TrackCollHandle_TrkTrack(TrackSysCommonData *, const QString &name, TrackType::Type type=TrackType::TrkTrack)
Definition: TrackCollHandle_TrkTrack.cxx:98
TrackSystemController.h
TrackCollHandle_TrkTrack.h
TrackSysCommonData::visTrkTracksToMaterialHelper
VisibleObjectToMaterialHelper< Trk::Track > * visTrkTracksToMaterialHelper() const
Definition: TrackSysCommonData.h:132
TrackCommonFlags::AUTO
@ AUTO
Definition: TrackCommonFlags.h:39
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
TrackCollHandle_TrkTrack::Imp::theclass
TrackCollHandle_TrkTrack * theclass
Definition: TrackCollHandle_TrkTrack.cxx:34
VP1QtUtils.h
TrackCollHandle_TrkTrack::m_d
Imp * m_d
Definition: TrackCollHandle_TrkTrack.h:54
TrackHandle_TrkTrack::trkTrackPointer
const Trk::Track * trkTrackPointer() const
Definition: TrackHandle_TrkTrack.h:43
TrackCollHandleBase::hintNumberOfTracksInEvent
void hintNumberOfTracksInEvent(unsigned)
Definition: TrackCollHandleBase.cxx:509
TrackCollHandle_TrkTrack::Imp::alwaysShowAllTrackColls
static bool alwaysShowAllTrackColls
Definition: TrackCollHandle_TrkTrack.cxx:33
VP1HelperClassBase::messageDebug
void messageDebug(const QString &) const
Definition: VP1HelperClassBase.cxx:65
TrackCollHandle_TrkTrack::visibleStateUpdated
void visibleStateUpdated(TrackHandle_TrkTrack *)
Definition: TrackCollHandle_TrkTrack.cxx:160
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
VP1QtUtils::environmentVariableValue
static QString environmentVariableValue(const QString &name)
Definition: VP1QtUtils.cxx:117
Track.h
TrackCollHandle_TrkTrack::availableCollections
static QStringList availableCollections(IVP1System *)
Definition: TrackCollHandle_TrkTrack.cxx:43
TrackCollHandleBase::cut
virtual bool cut(TrackHandleBase *)
Definition: TrackCollHandleBase.cxx:316
IVP1System
Definition: IVP1System.h:36
TrackCollHandle_TrkTrack
Definition: TrackCollHandle_TrkTrack.h:27
TrackSysCommonData
Definition: TrackSysCommonData.h:50
VP1QtUtils::environmentVariableIsOn
static bool environmentVariableIsOn(const QString &name)
Definition: VP1QtUtils.cxx:127
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrackHandleBase::visible
bool visible() const
Definition: TrackHandleBase.h:67
TrackCollHandle_TrkTrack::Imp
Definition: TrackCollHandle_TrkTrack.cxx:30
TrackCollection.h
TrackCollHandleBase::name
QString name() const
Definition: TrackCollHandleBase.cxx:310
VP1JobConfigInfo::hasSCTGeometry
static bool hasSCTGeometry()
Definition: VP1JobConfigInfo.cxx:128
TrackHandle_TrkTrack
Definition: TrackHandle_TrkTrack.h:29
TrackHandleBase::currentMaterial
SoMaterial * currentMaterial() const
Definition: TrackHandleBase.h:76
DataVector< Trk::Track >
VP1JobConfigInfo::hasTRTGeometry
static bool hasTRTGeometry()
Definition: VP1JobConfigInfo.cxx:129
TrackType::Type
Type
Definition: TrackTypes.h:13
VP1HelperClassBase::systemBase
IVP1System * systemBase() const
Definition: VP1HelperClassBase.h:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrackCollHandleBase::addTrackHandle
void addTrackHandle(TrackHandleBase *)
Definition: TrackCollHandleBase.cxx:515
VisibleObjectToMaterialHelper::setState
void setState(const objectT *, SoMaterial *mat)
VP1SGContentsHelper
Definition: VP1SGContentsHelper.h:26
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
TrackHandle_TrkTrack.h
TrackCollHandle_TrkTrack::load
virtual bool load()
Definition: TrackCollHandle_TrkTrack.cxx:121
IVP1System::updateGUI
void updateGUI()
Definition: IVP1System.cxx:262
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
calibdata.cd
cd
Definition: calibdata.py:51
TrackCollHandle_TrkTrack::cut
virtual bool cut(TrackHandleBase *)
Definition: TrackCollHandle_TrkTrack.cxx:150
VP1HelperClassBase::message
void message(const QString &) const
Definition: VP1HelperClassBase.cxx:49
TrackCommonFlags::DETAILLEVEL
DETAILLEVEL
Definition: TrackCommonFlags.h:39
TrackCollHandle_TrkTrack::Imp::detailLevel
TrackCommonFlags::DETAILLEVEL detailLevel
Definition: TrackCollHandle_TrkTrack.cxx:35
VP1JobConfigInfo.h
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
TrackCollHandle_TrkTrack::~TrackCollHandle_TrkTrack
virtual ~TrackCollHandle_TrkTrack()
Definition: TrackCollHandle_TrkTrack.cxx:108
TrackCollHandleBase::common
TrackSysCommonData * common() const
Definition: TrackCollHandleBase.h:79
VP1JobConfigInfo::hasPixelGeometry
static bool hasPixelGeometry()
Definition: VP1JobConfigInfo.cxx:127
TrackHandleBase
Definition: TrackHandleBase.h:56
python.DataFormatRates.env
env
Definition: DataFormatRates.py:32
VP1JobConfigInfo::hasMuonGeometry
static bool hasMuonGeometry()
Definition: VP1JobConfigInfo.cxx:134
TrackCollHandle_TrkTrack::Imp::isFatrasTruthTrack
static bool isFatrasTruthTrack(const QString &key)
Definition: TrackCollHandle_TrkTrack.cxx:114
VP1SGAccessHelper.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
IVP1System.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
VP1SGContentsHelper.h
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37