ATLAS Offline Software
Loading...
Searching...
No Matches
PileUpStream Class Reference

a triple selector/context/store defines a stream More...

#include <PileUpStream.h>

Inheritance diagram for PileUpStream:
Collaboration diagram for PileUpStream:

Public Types

typedef IEvtSelector::Context EvtIterator

Public Member Functions

bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.
Structors
 PileUpStream ()
 Structors.
 PileUpStream (const PileUpStream &rhs)=delete
PileUpStreamoperator= (const PileUpStream &rhs)=delete
 PileUpStream (PileUpStream &&rhs)
PileUpStreamoperator= (PileUpStream &&rhs)
 PileUpStream (const std::string &name, ISvcLocator *svcLoc, const std::string &selecName)
 PileUpStream (const std::string &name, ISvcLocator *svcLoc, IEvtSelector *sel)
virtual ~PileUpStream ()

Private Member Functions

void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

accessors

std::string m_name
 Stream name.
ISvcLocator * p_svcLoc {nullptr}
 ServiceLocator.
SmartIF< IEvtSelector > m_sel
 Selector.
SmartIF< StoreGateSvcm_SG
 StoreGateSvc;.
EvtIteratorp_iter {nullptr}
 Input Iterators.
ServiceHandle< PileUpMergeSvcm_mergeSvc
bool m_ownEvtIterator {false}
 do we own p_iter?
bool m_neverLoaded {true}
 has an event been loaded into this stream?
bool m_ownStore {false}
 is m_SG a store we cloned from the master one?
bool m_used {false}
 has this stream already been used? (for the current event)
bool m_hasRing {false}
unsigned int m_iOriginalRing {0}
 original ring in which event was used
const std::string & name ()
IEvtSelector & selector ()
EvtIteratoriterator ()
StoreGateSvcstore ()
const IEvtSelector & selector () const
const EvtIteratoriterator () const
const StoreGateSvcstore () const
const xAOD::EventInfonextEventPre (bool readRecord=true)
 return next Event, load store with next Event
bool nextEventPre_Passive (bool readRecord)
 like nextEventPre, but doesn't actually load anything
bool setupStore ()
 setup input and overlay selectors and iters
bool setupStore (bool)
 backward compatibility
StatusCode finalize ()
 finalize and release store. To be called on ... finalize()
bool used () const
 has this stream already be used in this event?
void setUsed ()
void resetUsed ()
bool hasRing () const
unsigned int originalIRing () const
 index of the ring for which this stream was used originally
void setOriginalIRing (unsigned int iR)
ISvcLocator * serviceLocator ()
StatusCode nextRecordPre ()
 increment event iterator before loading store
StatusCode nextRecordPre_Passive ()
 increment event iterator
bool loadStore ()
 clear store and load new proxies
void setActiveStore ()
 set ActiveStore

Detailed Description

a triple selector/context/store defines a stream

Definition at line 30 of file PileUpStream.h.

Member Typedef Documentation

◆ EvtIterator

typedef IEvtSelector::Context PileUpStream::EvtIterator

Definition at line 34 of file PileUpStream.h.

Constructor & Destructor Documentation

◆ PileUpStream() [1/5]

PileUpStream::PileUpStream ( )

Structors.

Definition at line 25 of file PileUpStream.cxx.

25 :
26 AthMessaging ("PileUpStream"),
27 m_name("INVALID"),
28 m_mergeSvc("PileUpMergeSvc", m_name)
29{
30}
AthMessaging()
Default constructor:
std::string m_name
Stream name.
ServiceHandle< PileUpMergeSvc > m_mergeSvc

◆ PileUpStream() [2/5]

PileUpStream::PileUpStream ( const PileUpStream & rhs)
delete

◆ PileUpStream() [3/5]

PileUpStream::PileUpStream ( PileUpStream && rhs)

Definition at line 32 of file PileUpStream.cxx.

32 :
34{
35 *this = std::move(rhs);
36}
PileUpStream()
Structors.

◆ PileUpStream() [4/5]

PileUpStream::PileUpStream ( const std::string & name,
ISvcLocator * svcLoc,
const std::string & selecName )

Definition at line 77 of file PileUpStream.cxx.

79 :
81 m_name(name),
82 p_svcLoc(svcLoc),
83 m_mergeSvc("PileUpMergeSvc", name)
84{
85 m_sel = serviceLocator()->service<IEvtSelector>(selecName);
86 if ( !(m_sel.isValid() && m_mergeSvc.isValid() &&
87 m_sel->createContext(p_iter).isSuccess()) ) {
88 const std::string errMsg("PileUpStream: can not create stream");
89 ATH_MSG_ERROR ( errMsg );
90 throw std::runtime_error(errMsg);
91 } else m_ownEvtIterator=true;
92}
#define ATH_MSG_ERROR(x)
bool m_ownEvtIterator
do we own p_iter?
const std::string & name()
ISvcLocator * serviceLocator()
SmartIF< IEvtSelector > m_sel
Selector.
EvtIterator * p_iter
Input Iterators.
ISvcLocator * p_svcLoc
ServiceLocator.

◆ PileUpStream() [5/5]

PileUpStream::PileUpStream ( const std::string & name,
ISvcLocator * svcLoc,
IEvtSelector * sel )

Definition at line 61 of file PileUpStream.cxx.

63 :
65 m_name(name),
66 p_svcLoc(svcLoc),
67 m_sel(sel),
68 m_mergeSvc("PileUpMergeSvc", name)
69{
70 if( !( m_sel->createContext(p_iter).isSuccess() && m_mergeSvc.isValid() ) ) {
71 const std::string errMsg("PileUpStream:: can not create stream");
72 ATH_MSG_ERROR ( errMsg );
73 throw std::runtime_error(errMsg);
74 } else m_ownEvtIterator=true;
75}

◆ ~PileUpStream()

PileUpStream::~PileUpStream ( )
virtual

Definition at line 94 of file PileUpStream.cxx.

95{
96}

Member Function Documentation

◆ finalize()

StatusCode PileUpStream::finalize ( )

finalize and release store. To be called on ... finalize()

Definition at line 232 of file PileUpStream.cxx.

232 {
233 StatusCode sc(StatusCode::SUCCESS);
234 if (m_ownEvtIterator) delete p_iter;
235 //we own and manage our cloned SG instance
236 if (m_ownStore && Gaudi::StateMachine::INITIALIZED == store().FSMState()) {
237 sc = this->store().sysFinalize();
238 }
239 this->store().release();
240 return sc;
241}
static Double_t sc
StoreGateSvc & store()
bool m_ownStore
is m_SG a store we cloned from the master one?
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ hasRing()

bool PileUpStream::hasRing ( ) const
inline

Definition at line 81 of file PileUpStream.h.

81{ return m_hasRing; }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40{
42 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ iterator() [1/2]

EvtIterator & PileUpStream::iterator ( )
inline

Definition at line 56 of file PileUpStream.h.

56{ return *p_iter; }

◆ iterator() [2/2]

const EvtIterator & PileUpStream::iterator ( ) const
inline

Definition at line 59 of file PileUpStream.h.

59{ return *p_iter; }

◆ loadStore()

bool PileUpStream::loadStore ( )
private

clear store and load new proxies

Definition at line 179 of file PileUpStream.cxx.

180{
181 m_neverLoaded=false;
182
183 IOpaqueAddress* paddr(0);
184 bool rc = (this->selector().createAddress(iterator(), paddr)).isSuccess();
185 if ( 0 != paddr) rc &= this->store().recordAddress(paddr).isSuccess();
186
187 // load store proxies
188 rc &= this->store().loadEventProxies().isSuccess();
189 return rc;
190}
static Double_t rc
bool m_neverLoaded
has an event been loaded into this stream?
EvtIterator & iterator()
IEvtSelector & selector()
StatusCode recordAddress(const std::string &skey, CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress, bool clearAddressFlag=true)
Create a proxy object using an IOpaqueAddress and a transient key.
StatusCode loadEventProxies()
load proxies at begin event

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 163 of file AthMessaging.h.

164{
165 MsgStream* ms = m_msg_tls.get();
166 if (!ms) {
167 if (!m_initialized.test_and_set()) initMessaging();
168 ms = new MsgStream(m_imsg,m_nm);
169 m_msg_tls.reset( ms );
170 }
171
172 ms->setLevel (m_lvl);
173 return *ms;
174}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 178 of file AthMessaging.h.

179{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152{
153 if (m_lvl <= lvl) {
154 msg() << lvl;
155 return true;
156 } else {
157 return false;
158 }
159}

◆ name()

const std::string & PileUpStream::name ( )
inline

Definition at line 54 of file PileUpStream.h.

54{ return m_name; }

◆ nextEventPre()

const xAOD::EventInfo * PileUpStream::nextEventPre ( bool readRecord = true)

return next Event, load store with next Event

Definition at line 193 of file PileUpStream.cxx.

194{
195 if (m_neverLoaded) readRecord=true;
196 else if (readRecord) {
197 //do not reset these the first time we call nextEventPre
198 this->resetUsed();
199 m_hasRing=false;
200 }
201 // if (isNotEmpty()) {
202 if (readRecord && this->nextRecordPre().isFailure()) {
203 ATH_MSG_INFO ( "nextEventPre(): end of the loop. No more events in the selection" );
204 return nullptr;
205 }
206
207 const xAOD::EventInfo* xAODEventInfo = m_mergeSvc->getPileUpEvent( m_SG, "" );
208 if (readRecord and xAODEventInfo) {
209 ATH_MSG_DEBUG ( "nextEventPre(): read new event "
210 << xAODEventInfo->eventNumber()
211 << " run " << xAODEventInfo->runNumber()
212 << " into store " << this->store().name() );
213 }
214
215 return xAODEventInfo;
216}
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
StatusCode nextRecordPre()
increment event iterator before loading store
void resetUsed()
SmartIF< StoreGateSvc > m_SG
StoreGateSvc;.
EventInfo_v1 EventInfo
Definition of the latest event info version.

◆ nextEventPre_Passive()

bool PileUpStream::nextEventPre_Passive ( bool readRecord)

like nextEventPre, but doesn't actually load anything

Definition at line 218 of file PileUpStream.cxx.

218 {
219 if (m_neverLoaded) readRecord=true;
220 else if (readRecord) {
221 //do not reset these the first time we call nextEventPre_Passive
222 this->resetUsed();
223 m_hasRing=false;
224 }
225 if (readRecord && this->nextRecordPre_Passive().isFailure()) {
226 ATH_MSG_INFO ( "nextEventPre_Passive(): end of the loop. No more events in the selection" );
227 return false;
228 }
229 return true;
230}
StatusCode nextRecordPre_Passive()
increment event iterator

◆ nextRecordPre()

StatusCode PileUpStream::nextRecordPre ( )
private

increment event iterator before loading store

Definition at line 170 of file PileUpStream.cxx.

171{
172 // Clear the store, move to next event and load the store
173 return (this->nextRecordPre_Passive().isSuccess() &&
174 this->loadStore()) ?
175 StatusCode::SUCCESS :
176 StatusCode::FAILURE;
177}
bool loadStore()
clear store and load new proxies

◆ nextRecordPre_Passive()

StatusCode PileUpStream::nextRecordPre_Passive ( )
private

increment event iterator

Definition at line 160 of file PileUpStream.cxx.

161{
162 this->setActiveStore();
163 // Clear the store, move to next event
164 return (this->store().clearStore().isSuccess() &&
165 this->selector().next(iterator()).isSuccess() ) ?
166 StatusCode::SUCCESS :
167 StatusCode::FAILURE;
168}
void setActiveStore()
set ActiveStore

◆ operator=() [1/2]

PileUpStream & PileUpStream::operator= ( const PileUpStream & rhs)
delete

◆ operator=() [2/2]

PileUpStream & PileUpStream::operator= ( PileUpStream && rhs)

Definition at line 39 of file PileUpStream.cxx.

40{
41 if (this != &rhs) {
42 m_name=rhs.m_name;
44 m_sel=rhs.m_sel;
45 m_SG=rhs.m_SG;
46 p_iter=rhs.p_iter;
51 m_used=rhs.m_used;
54 //transferred ownership
55 rhs.m_ownEvtIterator=false;
56 rhs.m_ownStore=false;
57 }
58 return *this;
59}
bool m_used
has this stream already been used? (for the current event)
unsigned int m_iOriginalRing
original ring in which event was used

◆ originalIRing()

unsigned int PileUpStream::originalIRing ( ) const
inline

index of the ring for which this stream was used originally

Definition at line 83 of file PileUpStream.h.

83{ return m_iOriginalRing; }

◆ resetUsed()

void PileUpStream::resetUsed ( )
inline

Definition at line 80 of file PileUpStream.h.

80{m_used=false;}

◆ selector() [1/2]

IEvtSelector & PileUpStream::selector ( )
inline

Definition at line 55 of file PileUpStream.h.

55{ return *m_sel; }

◆ selector() [2/2]

const IEvtSelector & PileUpStream::selector ( ) const
inline

Definition at line 58 of file PileUpStream.h.

58{ return *m_sel; }

◆ serviceLocator()

ISvcLocator * PileUpStream::serviceLocator ( )
inlineprivate

Definition at line 93 of file PileUpStream.h.

93{ return p_svcLoc; }

◆ setActiveStore()

void PileUpStream::setActiveStore ( )
private

set ActiveStore

Definition at line 155 of file PileUpStream.cxx.

156{
157 store().makeCurrent();
158}
void makeCurrent()
The current store is becoming the active store.

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29{
30 m_lvl = lvl;
31}

◆ setOriginalIRing()

void PileUpStream::setOriginalIRing ( unsigned int iR)
inline

Definition at line 84 of file PileUpStream.h.

84 {
85 if (!m_hasRing) {
86 m_hasRing=true;
88 }
89 }

◆ setupStore() [1/2]

bool PileUpStream::setupStore ( )

setup input and overlay selectors and iters

Definition at line 98 of file PileUpStream.cxx.

99{
100 bool rc(true);
101 std::string storeName(name() + "_SG");
102
103 //start by looking for the store directly: in overlay jobs it may already be there
104 m_SG = serviceLocator()->service<StoreGateSvc>(storeName, /*createIf*/false);
105 if (m_SG) {
106 m_ownStore = false;
107 } else {
108 //not there, create one cloning the master store
109 Service *child;
110 //if the parent store is not there barf
111 //remember the clone function also initializes the service if needed
112 SmartIF<StoreGateSvc> pIS(serviceLocator()->service("StoreGateSvc"));
113 rc = (pIS.isValid() &&
114 CloneService::clone(pIS, storeName, child).isSuccess() &&
115 (m_SG = SmartIF<StoreGateSvc>(child)).isValid());
116 if ( rc ) {
117 m_ownStore = true;
118 // further initialization of the cloned service
119 rc = (m_SG->sysInitialize()).isSuccess();
120 m_SG->setStoreID(StoreID::PILEUP_STORE); //needed by ProxyProviderSvc
121 } //clones
122 }
123 if (rc) {
124 //if the selector is an address provider like the AthenaPool one,
125 //create a dedicated ProxyProviderSvc and associate it to the store
126 SmartIF<IAddressProvider> pIAP(m_sel);
127 if (pIAP.isValid()) {
128 const std::string PPSName(name() + "_PPS");
129 SmartIF<IProxyProviderSvc> pPPSvc(serviceLocator()->service(PPSName));
130 SmartIF<ISvcManager> pISM(serviceLocator());
131 if ( pISM.isValid() &&
132 pISM->declareSvcType(PPSName, "ProxyProviderSvc").isSuccess() &&
133 pPPSvc.isValid() ) {
134
135 pPPSvc->addProvider(pIAP);
136 SmartIF<IAddressProvider> pAthPoolAddProv(serviceLocator()->service("AthenaPoolAddressProviderSvc"));
137 if (pAthPoolAddProv.isValid()) {
138 pPPSvc->addProvider(pAthPoolAddProv);
139 } else {
140 ATH_MSG_WARNING ( "could not add AthenaPoolAddressProviderSvc as AddresssProvider for "<< PPSName );
141 }
142 SmartIF<IAddressProvider> pAddrRemap(serviceLocator()->service("AddressRemappingSvc"));
143 if (pAddrRemap.isValid()) {
144 pPPSvc->addProvider(pAddrRemap);
145 } else {
146 ATH_MSG_WARNING ( "could not add AddressRemappingSvc as AddresssProvider for "<< PPSName );
147 }
148 m_SG->setProxyProviderSvc(pPPSvc);
149 }
150 } //valid address provider
151 }
152 return rc;
153}
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
@ PILEUP_STORE
Definition StoreID.h:31
StatusCode clone(const IService *parent, const std::string &childName, Service *&child)
given a reference to a parent svc sets a reference to a cloned child

◆ setupStore() [2/2]

bool PileUpStream::setupStore ( bool )
inline

backward compatibility

Definition at line 72 of file PileUpStream.h.

72{ return setupStore();}
bool setupStore()
setup input and overlay selectors and iters

◆ setUsed()

void PileUpStream::setUsed ( )
inline

Definition at line 79 of file PileUpStream.h.

79{m_used=true;}

◆ store() [1/2]

StoreGateSvc & PileUpStream::store ( )
inline

Definition at line 57 of file PileUpStream.h.

57{ return *m_SG; }

◆ store() [2/2]

const StoreGateSvc & PileUpStream::store ( ) const
inline

Definition at line 60 of file PileUpStream.h.

60{ return *m_SG; }

◆ used()

bool PileUpStream::used ( ) const
inline

has this stream already be used in this event?

Definition at line 78 of file PileUpStream.h.

78{return m_used;}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_hasRing

bool PileUpStream::m_hasRing {false}
private

Definition at line 126 of file PileUpStream.h.

126{false};

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_iOriginalRing

unsigned int PileUpStream::m_iOriginalRing {0}
private

original ring in which event was used

Definition at line 127 of file PileUpStream.h.

127{0};

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_mergeSvc

ServiceHandle<PileUpMergeSvc> PileUpStream::m_mergeSvc
private

Definition at line 118 of file PileUpStream.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_name

std::string PileUpStream::m_name
private

Stream name.

Definition at line 108 of file PileUpStream.h.

◆ m_neverLoaded

bool PileUpStream::m_neverLoaded {true}
private

has an event been loaded into this stream?

Definition at line 122 of file PileUpStream.h.

122{true};

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_ownEvtIterator

bool PileUpStream::m_ownEvtIterator {false}
private

do we own p_iter?

Definition at line 121 of file PileUpStream.h.

121{false};

◆ m_ownStore

bool PileUpStream::m_ownStore {false}
private

is m_SG a store we cloned from the master one?

Definition at line 123 of file PileUpStream.h.

123{false};

◆ m_sel

SmartIF<IEvtSelector> PileUpStream::m_sel
private

Selector.

Definition at line 112 of file PileUpStream.h.

◆ m_SG

SmartIF<StoreGateSvc> PileUpStream::m_SG
private

StoreGateSvc;.

Definition at line 114 of file PileUpStream.h.

◆ m_used

bool PileUpStream::m_used {false}
private

has this stream already been used? (for the current event)

Definition at line 125 of file PileUpStream.h.

125{false};

◆ p_iter

EvtIterator* PileUpStream::p_iter {nullptr}
private

Input Iterators.

Definition at line 116 of file PileUpStream.h.

116{nullptr};

◆ p_svcLoc

ISvcLocator* PileUpStream::p_svcLoc {nullptr}
private

ServiceLocator.

Definition at line 110 of file PileUpStream.h.

110{nullptr};

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