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

#include <AlignTrackCollSplitter.h>

Inheritance diagram for Trk::AlignTrackCollSplitter:
Collaboration diagram for Trk::AlignTrackCollSplitter:

Public Member Functions

 AlignTrackCollSplitter (const std::string &name, ISvcLocator *pSvcLocator)
 constructor
virtual ~AlignTrackCollSplitter ()
 destructor
virtual StatusCode initialize ()
 initialize method
virtual StatusCode execute ()
 loops over tracks in event, and accumulates information necessary for alignmnet
virtual StatusCode stop ()
 stop method
virtual StatusCode finalize ()
 finalize method
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
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

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

StringProperty m_inputCol
StringProperty m_outColPrefix
std::vector< std::string > m_outColNames
 Names of output track collections.
int m_nevents = 0
 number of processed events
int m_ntracks = 0
 number of processed tracks
std::vector< int > m_trackTypeCounter
 counter for different types of tracks
int m_nRetrievalErrors = 0
 number of retrieval errors at the beginning of the job
IntegerProperty m_maxRetrievalErrors
DataObjIDColl m_extendedExtraObjects
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 25 of file AlignTrackCollSplitter.h.

Member Typedef Documentation

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ AlignTrackCollSplitter()

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

constructor

Definition at line 13 of file AlignTrackCollSplitter.cxx.

14 : AthAlgorithm(name, pSvcLocator)
16{
17}
AthAlgorithm()
Default constructor:
std::vector< int > m_trackTypeCounter
counter for different types of tracks
@ NTrackTypes
total number of track types
Definition AlignTrack.h:53

◆ ~AlignTrackCollSplitter()

AlignTrackCollSplitter::~AlignTrackCollSplitter ( )
virtual

destructor

Definition at line 20 of file AlignTrackCollSplitter.cxx.

21{
22 ATH_MSG_DEBUG("AlignTrackCollSplitter destructor");
23}
#define ATH_MSG_DEBUG(x)

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< 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< 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< 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< 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 AlignTrackCollSplitter::execute ( )
virtual

loops over tracks in event, and accumulates information necessary for alignmnet

Definition at line 41 of file AlignTrackCollSplitter.cxx.

42{
43 ATH_MSG_DEBUG("AlignTrackCollSplitter::execute()");
44
45 // increment number of events
46 m_nevents++;
47
48 // loop over tracks
49 const TrackCollection * originalTracks = nullptr;
50
51 // check if m_inputCol is a TrackCollection and exists for this event
52 // perhaps this can be done in a much nicer way on the python side ala PyUtils/checkFile.py
53 // do it here for now
55 evtStore()->retrieve(originalTracks,m_inputCol).isFailure() ) {
56 ATH_MSG_DEBUG("input track collection \'"<<m_inputCol<<"\' not found for this event");
57
61 msg(MSG::FATAL)<<"Input track collection \'"<<m_inputCol<<"\' not found in first "
62 <<m_nRetrievalErrors<<" events. Aborting."<<endmsg;
63 msg(MSG::FATAL)<<"Maximum allowed number of events without the track collection "
64 <<"can be changed using the \'MaxRetrievalErrors\' option (-1 for infinite)."
65 <<endmsg;
66 return StatusCode::FAILURE;
67 }
68 }
69 return StatusCode::SUCCESS;
70 }
71
72 // if we're here it means that the track collection m_inputCol exists in the file
73 // (it can be empty) so we change the error cutoff to process the whole file
76
77 if(originalTracks->empty())
78 return StatusCode::SUCCESS;
79
80 // increment number of processed tracks
81 m_ntracks += originalTracks->size();
82
83 // vector to keep all different AlignTrack collections
84 // +1 is for undefined AlignTrack type
85 std::vector<TrackCollection *> alignTracks;
86 alignTracks.reserve(AlignTrack::NTrackTypes+1);
87
88for(int i=0;i<AlignTrack::NTrackTypes+1;i++)
89 alignTracks.push_back(new TrackCollection);
90
91 // loop over AlignTracks and fill the corresponding track collections
92 int itrk = 0;
93 DataVector<Track>::const_iterator it = originalTracks->begin();
94 DataVector<Track>::const_iterator it_end = originalTracks->end();
95 for ( ;it != it_end ; ++it, ++itrk) {
96
97 ATH_MSG_DEBUG("Processing AlignTrack "<<itrk);
98
99 // each track in the collection HAS to be an AlignTrack
100 const AlignTrack * alignTrack = dynamic_cast<const AlignTrack*>(*it);
101 if(!alignTrack) {
102 msg(MSG::FATAL)<<"Track is not an AlignTrack. The code only works with TrackCollection"
103 <<" filled with AlignTracks."<<endmsg;
104 return StatusCode::FAILURE;
105 }
106
107 int type = alignTrack->type();
108 ATH_MSG_DEBUG("type of AlignTrack: "<<alignTrack->type());
109
110 //previously this check was always returning true (type>=0 || type<AlignTrack::NTrackTypes), meaning that in principle you could try
111 //to access an invalid vector element if type was negative. Assume that what we have below is what was meant, as last entry in vector
112 // is for undefined tracks? (Nick Styles, 04/02/15)
113 int colIndex = (type>=0 && type<AlignTrack::NTrackTypes) ? type : AlignTrack::NTrackTypes;
114
115 ATH_MSG_DEBUG("collection index is "<<colIndex);
116 alignTracks[colIndex]->push_back(new AlignTrack(*alignTrack));
117 ATH_MSG_DEBUG("pushback ok");
118
119 ++m_trackTypeCounter[colIndex];
120 }
121
122 // record the collections in the StoreGate that takes care of deletion
123 // only record collection to storegate if it's not empty
124 for(int icol=0;icol<AlignTrack::NTrackTypes+1;++icol) {
125 ATH_MSG_DEBUG(icol<<": recording "<<m_outColNames[icol]<<" size "<<alignTracks[icol]->size());
126 if(!alignTracks[icol]->empty()) {
127 if(evtStore()->record(alignTracks[icol],m_outColNames[icol],false).isFailure()) {
128 ATH_MSG_ERROR("Unable to record "<<m_outColNames[icol]<<" in the StoreGate");
129 delete alignTracks[icol];
130 }
131 ATH_MSG_DEBUG("Recorded \'"<<m_outColNames[icol]<<"\' with size "<<alignTracks[icol]->size()<<" to StoreGate");
132 }
133 else {
134 ATH_MSG_DEBUG("not recording "<<m_outColNames[icol]);
135 delete alignTracks[icol];
136 }
137 }
138
139 ATH_MSG_DEBUG("returning SUCCESS");
140 return StatusCode::SUCCESS;
141}
#define endmsg
#define ATH_MSG_ERROR(x)
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
static const Attributes_t empty
MsgStream & msg() const
DataModel_detail::const_iterator< DataVector > const_iterator
Standard 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.
bool empty() const noexcept
Returns true if the collection is empty.
int m_ntracks
number of processed tracks
int m_nRetrievalErrors
number of retrieval errors at the beginning of the job
std::vector< std::string > m_outColNames
Names of output track collections.
int m_nevents
number of processed events
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
retrieve(aClass, aKey=None)
Definition PyKernel.py:110

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< 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 & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ finalize()

StatusCode AlignTrackCollSplitter::finalize ( )
virtual

finalize method

Definition at line 159 of file AlignTrackCollSplitter.cxx.

160{
161 ATH_MSG_DEBUG("AlignTrackCollSplitter::finalize()");
162 return StatusCode::SUCCESS;
163}

◆ initialize()

StatusCode AlignTrackCollSplitter::initialize ( )
virtual

initialize method

Definition at line 26 of file AlignTrackCollSplitter.cxx.

27{
28 ATH_MSG_DEBUG("AlignTrackCollSplitter::initialize()");
29
30 // set the track collection names
31 ATH_MSG_INFO("Splitting "<<m_inputCol<<" into:");
32 for(int icol=0; icol<AlignTrack::NTrackTypes+1; ++icol) {
34 ATH_MSG_INFO(" - "<<m_outColNames[icol]);
35 }
36
37 return StatusCode::SUCCESS;
38}
#define ATH_MSG_INFO(x)
std::string dumpAlignTrackType(const AlignTrack::AlignTrackType type)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< 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.

◆ msg()

MsgStream & AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< 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< 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.

◆ 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< 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< Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ stop()

StatusCode AlignTrackCollSplitter::stop ( )
virtual

stop method

Definition at line 144 of file AlignTrackCollSplitter.cxx.

145{
146 ATH_MSG_DEBUG("AlignTrackCollSplitter::stop()");
147
148 ATH_MSG_INFO("Processed "<<m_nevents<<" with "<<m_ntracks<<" AlignTracks");
149 ATH_MSG_INFO("Track collections recorded in StoreGate:");
150 ATH_MSG_INFO("----------------------------------------------");
151 for(int icol=0;icol<AlignTrack::NTrackTypes+1;++icol)
153 ATH_MSG_INFO("----------------------------------------------");
154
155 return StatusCode::SUCCESS;
156}

◆ sysInitialize()

StatusCode AthAlgorithm::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< Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_WARNING(x)
static Double_t sc
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< 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.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< 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 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_inputCol

StringProperty Trk::AlignTrackCollSplitter::m_inputCol
private
Initial value:
{this, "InputTrkCol", "AlignTracks",
"Name of input track collection"}

Definition at line 49 of file AlignTrackCollSplitter.h.

49 {this, "InputTrkCol", "AlignTracks",
50 "Name of input track collection"};

◆ m_maxRetrievalErrors

IntegerProperty Trk::AlignTrackCollSplitter::m_maxRetrievalErrors
private
Initial value:
{this, "MaxRetrievalErrors", -1,
"maximum allowed number of retrieval errors at the beginning of the job (-1 for infinite)"}

Definition at line 62 of file AlignTrackCollSplitter.h.

62 {this, "MaxRetrievalErrors", -1,
63 "maximum allowed number of retrieval errors at the beginning of the job (-1 for infinite)"};

◆ m_nevents

int Trk::AlignTrackCollSplitter::m_nevents = 0
private

number of processed events

Definition at line 56 of file AlignTrackCollSplitter.h.

◆ m_nRetrievalErrors

int Trk::AlignTrackCollSplitter::m_nRetrievalErrors = 0
private

number of retrieval errors at the beginning of the job

Definition at line 61 of file AlignTrackCollSplitter.h.

◆ m_ntracks

int Trk::AlignTrackCollSplitter::m_ntracks = 0
private

number of processed tracks

Definition at line 57 of file AlignTrackCollSplitter.h.

◆ m_outColNames

std::vector<std::string> Trk::AlignTrackCollSplitter::m_outColNames
private

Names of output track collections.

Definition at line 54 of file AlignTrackCollSplitter.h.

◆ m_outColPrefix

StringProperty Trk::AlignTrackCollSplitter::m_outColPrefix
private
Initial value:
{this, "OutputColPrefix", "AlignTracks",
"Prefix for names of output track collections"}

Definition at line 51 of file AlignTrackCollSplitter.h.

51 {this, "OutputColPrefix", "AlignTracks",
52 "Prefix for names of output track collections"};

◆ m_trackTypeCounter

std::vector<int> Trk::AlignTrackCollSplitter::m_trackTypeCounter
private

counter for different types of tracks

Definition at line 59 of file AlignTrackCollSplitter.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


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