ATLAS Offline Software
TrackCollHandle_TrkSegment.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_TrkSegment //
9 // //
10 // Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
11 // Initial version: February 2008 //
12 // //
14 
18 #include "VP1Base/IVP1System.h"
19 #include "VP1Base/VP1QtUtils.h"
23 #include "TrkSegment/Segment.h"
25 
26 //____________________________________________________________________
28 public:
30 };
31 
32 
34  = VP1QtUtils::environmentVariableIsOn("VP1_ALWAYS_SHOW_ALL_TRACK_COLLECTIONS");
35 
36 //____________________________________________________________________
38 {
39  //There must be at least one of the trackers available for this to make sense.
42  sys->messageDebug("TrackCollHandle_TrkSegment::availableCollections: Neither"
43  " Pixel, SCT, TRT or Muon geometry available. Won't"
44  " look in event store for Trk::Track collections");
45  return {};
46  }
47 
48  QStringList keysInSG = VP1SGContentsHelper(sys).getKeys<Trk::SegmentCollection>();
49  if (keysInSG.isEmpty()||Imp::alwaysShowAllTrackColls)
50  return keysInSG;
51 
52  QRegExp needsMuonsPattern("Converted.*|.*MBoy.*|.*Moore.*|.*Mu.*|.*Staco.*");
53  QRegExp needsAllIDPattern(".*Id.*|.*ID.*|.*InDet.*|.*Inner.*");
54  QRegExp needsTRTPattern(".*Trt.*|.*TRT.*|.*trt.*");
55 
56  const bool jobcfgAllID
60 
61  QStringList outkeys;
62 
63  for (QString key : keysInSG) {
64  if (!VP1JobConfigInfo::hasMuonGeometry() && needsMuonsPattern.exactMatch(key)) {
65  sys->messageDebug("TrackCollHandle_TrkSegment::availableCollections: Ignoring key '"
66  +key+"' since muon geometry is not present in job.");
67  continue;
68  }
69  if (!VP1JobConfigInfo::hasTRTGeometry() && needsTRTPattern.exactMatch(key)) {
70  sys->messageDebug("TrackCollHandle_TrkSegment::availableCollections: Ignoring key '"
71  +key+"' since TRT geometry is not present in job.");
72  continue;
73  }
74  if (!jobcfgAllID && needsAllIDPattern.exactMatch(key)) {
75  sys->messageDebug("TrackCollHandle_TrkSegment::availableCollections: Ignoring key '"
76  +key+"' since pixel, sct and trt geometry are not all present in job.");
77  continue;
78  }
79  outkeys<<key;
80  }
81  return outkeys;
82 
83 }
84 
85 //____________________________________________________________________
87  const QString& name)
88  : TrackCollHandleBase(cd,name,TrackType::TrkSegment), m_d(new Imp)
89 {
90 }
91 
92 //____________________________________________________________________
94 {
95  delete m_d;
96 }
97 
98 //____________________________________________________________________
100 {
101 
102 }
103 
104 //____________________________________________________________________
106 {
107  //Get collection:
108  const Trk::SegmentCollection *segmentColl(nullptr);
109  if (!VP1SGAccessHelper(systemBase()).retrieve(segmentColl, name())) {
110  common()->systemBase()->message("Error: Could not retrieve segment collection with key="+name());
111  return false;
112  }
113 
114  //Make appropriate trk::segment handles:
115  hintNumberOfTracksInEvent(segmentColl->size());
116  int i(0);
117  Trk::SegmentCollection::const_iterator segItr, segItrEnd = segmentColl->end();
118  for ( segItr = segmentColl->begin() ; segItr != segItrEnd; ++segItr) {
119  if (*segItr)
120  addTrackHandle(new TrackHandle_TrkSegment(this,*segItr));
121  else
122  common()->systemBase()->messageDebug("WARNING: Ignoring null Trk::Segment pointer.");
123 
124  if (!(i++%100))
125  common()->systemBase()->updateGUI();
126  }
127 
128  return true;
129 }
130 
131 //____________________________________________________________________
133 {
134  if (!TrackCollHandleBase::cut(handle))
135  return false;
136 
137  //fixme: more?
138  return true;
139 }
140 
141 //____________________________________________________________________
143 {
144  common()->visTrkSegmentsToMaterialHelper()->setState(handle->trkSegmentPointer(), (handle->visible() ? handle->currentMaterial() : nullptr ));
145 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
TrackCollHandle_TrkSegment::TrackCollHandle_TrkSegment
TrackCollHandle_TrkSegment(TrackSysCommonData *, const QString &name)
Definition: TrackCollHandle_TrkSegment.cxx:86
TrackCollHandleBase
Definition: TrackCollHandleBase.h:49
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
TrackCollHandle_TrkSegment::Imp::alwaysShowAllTrackColls
static bool alwaysShowAllTrackColls
Definition: TrackCollHandle_TrkSegment.cxx:29
TrackHandle_TrkSegment.h
TrackCollHandle_TrkSegment::load
bool load()
Definition: TrackCollHandle_TrkSegment.cxx:105
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
VP1QtUtils.h
TrackHandle_TrkSegment
Definition: TrackHandle_TrkSegment.h:28
TrackCollHandle_TrkSegment::~TrackCollHandle_TrkSegment
virtual ~TrackCollHandle_TrkSegment()
Definition: TrackCollHandle_TrkSegment.cxx:93
TrackCollHandle_TrkSegment.h
TrackCollHandleBase::hintNumberOfTracksInEvent
void hintNumberOfTracksInEvent(unsigned)
Definition: TrackCollHandleBase.cxx:509
mapkey::sys
@ sys
Definition: TElectronEfficiencyCorrectionTool.cxx:42
VP1SGContentsHelper::getKeys
QStringList getKeys() const
Definition: VP1SGContentsHelper.h:55
TrackCollHandle_TrkSegment::availableCollections
static QStringList availableCollections(IVP1System *)
Definition: TrackCollHandle_TrkSegment.cxx:37
TrackCollHandleBase::cut
virtual bool cut(TrackHandleBase *)
Definition: TrackCollHandleBase.cxx:316
IVP1System
Definition: IVP1System.h:36
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
TrackCollHandle_TrkSegment::setupSettingsFromControllerSpecific
void setupSettingsFromControllerSpecific(TrackSystemController *)
Definition: TrackCollHandle_TrkSegment.cxx:99
TrackHandleBase::visible
bool visible() const
Definition: TrackHandleBase.h:67
TrackHandle_TrkSegment::trkSegmentPointer
const Trk::Segment * trkSegmentPointer() const
Definition: TrackHandle_TrkSegment.h:50
TrackCollHandleBase::name
QString name() const
Definition: TrackCollHandleBase.cxx:310
VP1JobConfigInfo::hasSCTGeometry
static bool hasSCTGeometry()
Definition: VP1JobConfigInfo.cxx:128
TrackHandleBase::currentMaterial
SoMaterial * currentMaterial() const
Definition: TrackHandleBase.h:76
DataVector< Trk::Segment >
VP1JobConfigInfo::hasTRTGeometry
static bool hasTRTGeometry()
Definition: VP1JobConfigInfo.cxx:129
TrackSysCommonData::visTrkSegmentsToMaterialHelper
VisibleObjectToMaterialHelper< Trk::Segment > * visTrkSegmentsToMaterialHelper() const
Definition: TrackSysCommonData.h:133
TrackCollHandle_TrkSegment::Imp
Definition: TrackCollHandle_TrkSegment.cxx:27
TrackCollHandle_TrkSegment::visibleStateUpdated
void visibleStateUpdated(TrackHandle_TrkSegment *)
Definition: TrackCollHandle_TrkSegment.cxx:142
VP1HelperClassBase::systemBase
IVP1System * systemBase() const
Definition: VP1HelperClassBase.h:50
IVP1System::messageDebug
void messageDebug(const QString &) const
Definition: IVP1System.cxx:347
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
TrackCollHandleBase::addTrackHandle
void addTrackHandle(TrackHandleBase *)
Definition: TrackCollHandleBase.cxx:515
TrackSystemController
Definition: TrackSystemController.h:49
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.
TrackCollHandle_TrkSegment::cut
bool cut(TrackHandleBase *)
Definition: TrackCollHandle_TrkSegment.cxx:132
IVP1System::updateGUI
void updateGUI()
Definition: IVP1System.cxx:262
TrackCollHandle_TrkSegment::m_d
Imp * m_d
Definition: TrackCollHandle_TrkSegment.h:51
calibdata.cd
cd
Definition: calibdata.py:51
VP1JobConfigInfo.h
VP1SGAccessHelper
Definition: VP1SGAccessHelper.h:25
TrackCollHandleBase::common
TrackSysCommonData * common() const
Definition: TrackCollHandleBase.h:79
VP1JobConfigInfo::hasPixelGeometry
static bool hasPixelGeometry()
Definition: VP1JobConfigInfo.cxx:127
TrackHandleBase
Definition: TrackHandleBase.h:56
VP1JobConfigInfo::hasMuonGeometry
static bool hasMuonGeometry()
Definition: VP1JobConfigInfo.cxx:134
VP1SGAccessHelper.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
IVP1System.h
IVP1System::message
void message(const QString &) const
Definition: IVP1System.cxx:336
SegmentCollection.h
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
VP1TrackSystem.h
Segment.h
VP1SGContentsHelper.h
TrackType
Definition: TrackTypes.h:10
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37