ATLAS Offline Software
Loading...
Searching...
No Matches
Athena::RootNtupleOutputStream Class Reference

algorithm that marks for write data objects in SG More...

#include <RootNtupleOutputStream.h>

Inheritance diagram for Athena::RootNtupleOutputStream:
Collaboration diagram for Athena::RootNtupleOutputStream:

Public Types

typedef std::vector< SG::DataProxy * > Items
typedef std::vector< std::pair< std::string, std::string > > TypeKeyPairs

Public Member Functions

 RootNtupleOutputStream (const std::string &name, ISvcLocator *pSvcLocator)
 Standard algorithm Constructor.
virtual ~RootNtupleOutputStream ()
 Standard Destructor.
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
implement IAlgorithm
bool isEventAccepted () const
 Test whether this event should be output.

Protected Types

typedef ServiceHandle< IClassIDSvc > IClassIDSvc_t

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.

Protected Attributes

ServiceHandle< StoreGateSvcm_dataStore
 handle to the StoreGateSvc store where the data we want to write out resides
std::string m_persName
 Name of the persistency service capable to write data from the store.
StringProperty m_writingTool
 Name of the OutputStreamTool used for writing.
std::string m_outputName
 Name of the output file.
StringProperty m_processTag
 tag of processing stage:
IClassIDSvc_t m_pCLIDSvc
StringArrayProperty m_itemList
 Vector of item names.
IDataSelector m_objects
 Collection of objects beeing selected.
int m_events
 Number of events written to this output stream.
bool m_forceRead
 set to true to force read of data objects in item list
bool m_persToPers
 set to true to allow data objects being copied persistent to persistent (without SG retrieve).
std::vector< unsigned int > m_exemptPersToPers
bool m_provideDef
 set to true to allow defaults being provided for non-existent data objects.
bool m_writeOnExecute
 set to true to trigger streaming of data on execute()
bool m_writeOnFinalize
 set to true to trigger streaming of data on finalize()
bool m_itemListFromTool
 set to write out everything from input DataHeader
bool m_dynamicItemList
 dynamic output itemlist: if enabled rediscover object list to be written out at each event otherwise: reuse the one from the first event.
std::vector< SG::FolderItemm_selection
 list of selected proxies.
ToolHandle< IAthenaOutputStreamToolm_streamer
 pointer to AthenaOutputStreamTool
ToolHandleArray< IAthenaOutputToolm_helperTools
 vector of AlgTools that that are executed by this stream
StringArrayProperty m_acceptNames
 Vector of names of Algorithms that this stream accepts.
StringArrayProperty m_requireNames
 Vector of names of Algorithms that this stream requires.
StringArrayProperty m_vetoNames
 Vector of names of Algorithms that this stream is vetoed by.
ServiceHandle< IDecisionSvcm_decSvc

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

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

Friends

class AlgFactory< Athena::RootNtupleOutputStream >

implement IAlgorithm

virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode execute ()
virtual StatusCode write ()
 Stream the data.
void clearSelection ()
 Clear list of selected objects.
void collectAllObjects ()
 Collect data objects for output streamer list.
IDataSelector * selectedObjects ()
 Return the list of selected objects.
void handle (const Incident &incident)
 Incident service handle listening for MetaDataStop.

Detailed Description

algorithm that marks for write data objects in SG

Author
binet.nosp@m.@cer.nosp@m.n.ch
Id
RootNtupleOutputStream.h 500674 2012-05-14 21:36:37Z gemmeren

Definition at line 46 of file RootNtupleOutputStream.h.

Member Typedef Documentation

◆ IClassIDSvc_t

Definition at line 69 of file RootNtupleOutputStream.h.

◆ Items

Definition at line 53 of file RootNtupleOutputStream.h.

◆ StoreGateSvc_t

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

Definition at line 388 of file AthCommonDataStore.h.

◆ TypeKeyPairs

typedef std::vector<std::pair<std::string, std::string> > Athena::RootNtupleOutputStream::TypeKeyPairs

Definition at line 106 of file RootNtupleOutputStream.h.

Constructor & Destructor Documentation

◆ RootNtupleOutputStream()

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

Standard algorithm Constructor.

Definition at line 32 of file RootNtupleOutputStream.cxx.

33 : FilteredAlgorithm(name, pSvcLocator),
34 m_dataStore("StoreGateSvc", name),
35 m_pCLIDSvc("ClassIDSvc", name),
36 m_events(0),
37 m_streamer(std::string("AthenaOutputStreamTool/") +
38 name + std::string("Tool"), this),
39 m_helperTools(this)
40{
41 assert(pSvcLocator);
42 declareProperty("ItemList", m_itemList);
43 declareProperty("OutputFile", m_outputName="DidNotNameOutput.root");
44 declareProperty("EvtConversionSvc", m_persName="EventPersistencySvc");
45 declareProperty("WritingTool", m_streamer);
47 declareProperty("ProcessingTag", m_processTag=name);
48 declareProperty("ForceRead", m_forceRead=false);
49 declareProperty("PersToPers", m_persToPers=false);
50 declareProperty("ExemptPersToPers", m_exemptPersToPers);
51 declareProperty("ProvideDef", m_provideDef=false);
52 declareProperty("WriteOnExecute", m_writeOnExecute=true);
53 declareProperty("WriteOnFinalize", m_writeOnFinalize=false);
54 declareProperty("TakeItemsFromInput", m_itemListFromTool=false);
55 declareProperty("HelperTools", m_helperTools);
56
57 declareProperty("DynamicItemList",
58 m_dynamicItemList = false,
59 "dynamic output itemlist:\n" \
60 " if enabled rediscover object list to be written out at each event\n" \
61 " otherwise: reuse the one from the first event.");
62}
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool m_dynamicItemList
dynamic output itemlist: if enabled rediscover object list to be written out at each event otherwise:...
bool m_provideDef
set to true to allow defaults being provided for non-existent data objects.
bool m_itemListFromTool
set to write out everything from input DataHeader
ServiceHandle< StoreGateSvc > m_dataStore
handle to the StoreGateSvc store where the data we want to write out resides
bool m_persToPers
set to true to allow data objects being copied persistent to persistent (without SG retrieve).
StringArrayProperty m_itemList
Vector of item names.
bool m_forceRead
set to true to force read of data objects in item list
bool m_writeOnExecute
set to true to trigger streaming of data on execute()
std::string m_persName
Name of the persistency service capable to write data from the store.
StringProperty m_processTag
tag of processing stage:
ToolHandle< IAthenaOutputStreamTool > m_streamer
pointer to AthenaOutputStreamTool
ToolHandleArray< IAthenaOutputTool > m_helperTools
vector of AlgTools that that are executed by this stream
bool m_writeOnFinalize
set to true to trigger streaming of data on finalize()
std::string m_outputName
Name of the output file.
int m_events
Number of events written to this output stream.
std::vector< unsigned int > m_exemptPersToPers

◆ ~RootNtupleOutputStream()

Athena::RootNtupleOutputStream::~RootNtupleOutputStream ( )
virtual

Standard Destructor.

Definition at line 65 of file RootNtupleOutputStream.cxx.

66{}

Member Function Documentation

◆ clearSelection()

void Athena::RootNtupleOutputStream::clearSelection ( )
inlineprivate

Clear list of selected objects.

Definition at line 287 of file RootNtupleOutputStream.cxx.

288{
289 m_objects.resize(0);
290 if (m_dynamicItemList) {
291 m_selection.resize(0);
292 }
293}
std::vector< SG::FolderItem > m_selection
list of selected proxies.
IDataSelector m_objects
Collection of objects beeing selected.

◆ collectAllObjects()

void Athena::RootNtupleOutputStream::collectAllObjects ( )
private

Collect data objects for output streamer list.

Definition at line 296 of file RootNtupleOutputStream.cxx.

297{
298 typedef std::vector<SG::FolderItem> Items_t;
299
300 if (!m_dynamicItemList && !m_selection.empty()) {
301 // reuse object list from previous event.
302 } else {
303
304 // if (m_itemListFromTool) {
305 // //FIXME:
306 // // if (!m_streamer->getInputItemList(&*m_p2BWritten).isSuccess()) {
307 // // ATH_MSG_WARNING("collectAllObjects() could not get ItemList from Tool.");
308 // // }
309 // }
310
311 static const std::string s_plus = "+";
312 static const std::string s_dash = "-";
313 typedef std::vector<const SG::DataProxy*> Proxies_t;
314 Proxies_t proxies = m_dataStore->proxies();
315
316 const std::vector<std::string>& items = m_itemList.value();
317 std::vector<std::string> toremove;
318 toremove.reserve(items.size());
319
320 Items_t selection;
321 selection.reserve(items.size());
322
323 for (Proxies_t::const_iterator
324 iproxy = proxies.begin(),
325 iend = proxies.end();
326 iproxy != iend;
327 ++iproxy) {
328 const SG::DataProxy *proxy = *iproxy;
329 if (!proxy) {
330 continue;
331 }
332 for (std::vector<std::string>::const_iterator
333 jkey = items.begin(),
334 jend = items.end();
335 jkey != jend;
336 ++jkey) {
337 if (!jkey->empty()) {
338 if ((*jkey)[0] == s_dash[0]) {
339 toremove.push_back(jkey->substr(1, std::string::npos));
340 continue;
341 }
342 std::string key = *jkey;
343 if ((*jkey)[0] == s_plus[0]) {
344 key = jkey->substr(1, std::string::npos);
345 }
346 int o = fnmatch(key.c_str(),
347 proxy->name().c_str(),
348 FNM_PATHNAME);
349 if (o == 0) {
350 // accept
351 selection.push_back(SG::FolderItem(proxy->clID(), proxy->name()));
352 break;
353 }
354 }
355 }
356 }
357
358 m_selection.reserve(selection.size());
359 if (toremove.empty()) {
360 m_selection = std::move(selection);
361 } else {
362 for(Items_t::const_iterator
363 isel=selection.begin(),
364 iend=selection.end();
365 isel != iend;
366 ++isel) {
367 const std::string &name = isel->key();
368 bool keep = true;
369 for (std::vector<std::string>::const_iterator
370 jkey = toremove.begin(),
371 jend = toremove.end();
372 jkey != jend;
373 ++jkey) {
374 const std::string& key = *jkey;
375 int o = fnmatch(key.c_str(),
376 name.c_str(),
377 FNM_PATHNAME);
378 if (o == 0) {
379 // reject
380 keep = false;
381 break;
382 }
383 }
384 if (keep) {
385 m_selection.push_back(*isel);
386 }
387 }
388 }
389 }
390
391 for (Items_t::const_iterator
392 itr = m_selection.begin(),
393 iend = m_selection.end();
394 itr != iend;
395 ++itr) {
396 const std::string &name = itr->key();
397 SG::DataProxy *proxy = m_dataStore->proxy(itr->id(), name);
398 if (NULL == proxy) {
399 continue;
400 }
401 if (m_forceRead && proxy->isValid()) {
402 if (!m_persToPers) {
403 if (NULL == proxy->accessData()) {
404 ATH_MSG_ERROR(" Could not get data object for id "
405 << proxy->clID() << ",\"" << proxy->name());
406 }
407 } else if (true /*m_exemptPersToPers.find(item.id()) != m_exemptPersToPers.end()*/) {
408 if (NULL == proxy->accessData()) {
409 ATH_MSG_ERROR(" Could not get data object for id "
410 << proxy->clID() << ",\"" << proxy->name());
411 }
412 }
413 }
414 DataObject *obj = proxy->object();
415 if (NULL != obj) {
416 m_objects.push_back(obj);
417 ATH_MSG_DEBUG(" Added object " << proxy->clID() << ",\"" << proxy->name() << "\"");
418 // if (m_checkNumberOfWrites && !m_provideDef) {
419 // std::string tn;
420 // if (!m_pCLIDSvc->getTypeNameOfID(item.id(), tn).isSuccess()) {
421 // ATH_MSG_ERROR(" Could not get type name for id "
422 // << item.id() << ",\"" << itemProxy->name());
423 // } else {
424 // tn += '_' + itemProxy->name();
425 // CounterMapType::iterator cit = m_objectWriteCounter.find(tn);
426 // if (cit == m_objectWriteCounter.end()) {
427 // // First time through
428 // //std::pair<CounterMapType::iterator, bool> result =
429 // m_objectWriteCounter.insert(CounterMapType::value_type(tn, 1));
430 // } else {
431 // // set to next iteration (to avoid double counting)
432 // // StreamTools will eliminate duplicates.
433 // (*cit).second = m_events + 1;
434 // }
435 // }
436 // }
437 // } else if (!m_forceRead && m_persToPers && proxy->isValid()) {
438 // tAddr = itemProxy->transientAddress();
439 } //if data object there
440 }
441
442 return;
443}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
const std::string selection

◆ 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 }

◆ 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 Athena::RootNtupleOutputStream::execute ( )
virtual

Reimplemented from FilteredAlgorithm.

Definition at line 212 of file RootNtupleOutputStream.cxx.

213{
214 bool failed = false;
215 for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator
216 iter = m_helperTools.begin(),
217 iend = m_helperTools.end();
218 iter != iend;
219 ++iter) {
220 if (!(*iter)->preExecute().isSuccess()) {
221 failed = true;
222 }
223 }
224 if (m_writeOnExecute) {
225 if (!write().isSuccess()) {
226 failed = true;
227 }
228 }
229 for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator
230 iter = m_helperTools.begin(),
231 iend = m_helperTools.end();
232 iter != iend;
233 ++iter) {
234 if(!(*iter)->postExecute().isSuccess()) {
235 failed = true;
236 }
237 }
238
239 return failed
240 ? StatusCode::FAILURE
241 : StatusCode::SUCCESS;
242}
virtual StatusCode write()
Stream the data.

◆ 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 Athena::RootNtupleOutputStream::finalize ( )
virtual

Reimplemented from FilteredAlgorithm.

Definition at line 187 of file RootNtupleOutputStream.cxx.

188{
189 bool failed = false;
190 ATH_MSG_DEBUG("finalize: Optimize output");
191 if (m_events == 0) {
192 if (!m_streamer->commitOutput().isSuccess()) {
193 failed = true;
194 }
195 }
196 if (!m_streamer->finalizeOutput().isSuccess()) {
197 failed = true;
198 }
199 ATH_MSG_DEBUG("finalize: end optimize output");
200 if (!m_helperTools.release().isSuccess()) {
201 failed = true;
202 }
203 if (!m_streamer.release().isSuccess()) {
204 failed = true;
205 }
206 return failed
207 ? StatusCode::FAILURE
208 : StatusCode::SUCCESS;
209}

◆ handle()

void Athena::RootNtupleOutputStream::handle ( const Incident & incident)
private

Incident service handle listening for MetaDataStop.

Definition at line 152 of file RootNtupleOutputStream.cxx.

153{
154 ATH_MSG_DEBUG("handle() incident type: " << inc.type());
155 static const std::string s_METADATASTOP = "MetaDataStop";
156 if (inc.type() == s_METADATASTOP) {
157 // Moved preFinalize of helper tools to stop - want to optimize the
158 // output file in finalize RDS 12/2009
159 for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator
160 iter = m_helperTools.begin(),
161 iend = m_helperTools.end();
162 iter != iend;
163 ++iter) {
164 if (!(*iter)->preFinalize().isSuccess()) {
165 ATH_MSG_ERROR("Cannot finalize helper tool");
166 }
167 }
168 // Always force a final commit in stop - mainly applies to AthenaPool
169 if (m_writeOnFinalize) {
170 if (!write().isSuccess()) { // true mean write AND commit
171 ATH_MSG_ERROR("Cannot write on finalize");
172 }
173 }
174 // If there are no events, then connect the output for the metadata
175 if (m_events == 0) {
176 if (m_streamer->connectOutput(m_outputName).isFailure()) {
177 ATH_MSG_ERROR("Unable to connect to file " << m_outputName);
178 }
179 }
180 }
181 ATH_MSG_INFO("Records written: " << m_events);
182 ATH_MSG_DEBUG("Leaving handle");
183}
#define ATH_MSG_INFO(x)

◆ initialize()

StatusCode Athena::RootNtupleOutputStream::initialize ( )
virtual

Reimplemented from FilteredAlgorithm.

Definition at line 70 of file RootNtupleOutputStream.cxx.

71{
72 ATH_MSG_DEBUG("In initialize");
73 if (!this->FilteredAlgorithm::initialize().isSuccess()) {
74 ATH_MSG_ERROR("could not initialize base class");
75 return StatusCode::FAILURE;
76 }
77
78 // Reset the number of events written
79 m_events = 0;
80
81 // set up the SG service:
82 if (!m_dataStore.retrieve().isSuccess()) {
83 ATH_MSG_FATAL("Could not locate default store");
84 return StatusCode::FAILURE;
85 } else {
86 ATH_MSG_DEBUG("Found " << m_dataStore.type() << " store.");
87 }
88 assert(static_cast<bool>(m_dataStore));
89
90 // set up the CLID service:
91 if (!m_pCLIDSvc.retrieve().isSuccess()) {
92 ATH_MSG_FATAL("Could not locate default ClassIDSvc");
93 return StatusCode::FAILURE;
94 }
95 assert(static_cast<bool>(m_pCLIDSvc));
96
97 // Get Output Stream tool for writing
98 if (!m_streamer.retrieve().isSuccess()) {
99 ATH_MSG_FATAL("Can not find " << m_streamer);
100 return StatusCode::FAILURE;
101 }
102
103 const bool extendProvenanceRecord = true;
104 if (!m_streamer->connectServices(m_dataStore.type(),
105 m_persName,
106 extendProvenanceRecord).isSuccess()) {
107 ATH_MSG_FATAL("Unable to connect services");
108 return StatusCode::FAILURE;
109 }
110
111 if (!m_helperTools.retrieve().isSuccess()) {
112 ATH_MSG_FATAL("Can not find " << m_helperTools);
113 return StatusCode::FAILURE;
114 }
115 ATH_MSG_INFO("Found " << m_helperTools << endmsg << "Data output: " << m_outputName);
116
117 bool allgood = true;
118 for (std::vector<ToolHandle<IAthenaOutputTool> >::iterator
119 iter = m_helperTools.begin(),
120 iend = m_helperTools.end();
121 iter != iend;
122 ++iter) {
123 if (!(*iter)->postInitialize().isSuccess()) {
124 allgood = false;
125 }
126 }
127 if (!allgood) {
128 ATH_MSG_ERROR("problem in postInitialize of a helper tool");
129 return StatusCode::FAILURE;
130 }
131
132 // For 'write on finalize', we set up listener for 'MetaDataStop'
133 // and perform write at this point. This happens at 'stop' of the
134 // event selector. RDS 04/2010
135 if (m_writeOnFinalize) {
136 // Set to be listener for end of event
137 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc", this->name());
138 if (!incSvc.retrieve().isSuccess()) {
139 ATH_MSG_ERROR("Cannot get the IncidentSvc");
140 return StatusCode::FAILURE;
141 } else {
142 ATH_MSG_DEBUG("Retrieved IncidentSvc");
143 }
144 incSvc->addListener(this, "MetaDataStop", 50);
145 ATH_MSG_DEBUG("Added MetaDataStop listener");
146 }
147 ATH_MSG_DEBUG("End initialize");
148 return StatusCode::SUCCESS;
149}
#define endmsg
#define ATH_MSG_FATAL(x)
virtual StatusCode initialize()

◆ 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.

◆ isEventAccepted()

bool FilteredAlgorithm::isEventAccepted ( ) const
inherited

Test whether this event should be output.

Definition at line 113 of file FilteredAlgorithm.cxx.

114{
115 bool result = true;
116 const EventContext& ctx = this->getContext();
117 if (ctx.valid()) {
118 result = m_decSvc->isEventAccepted(this->name(),ctx);
119 //ATH_MSG_DEBUG("res=" << result << " n=" << this->name() << " sl=" << ctx.slot() << " evt=" << ctx.eventID().event_number());
120 } else {
121 ATH_MSG_DEBUG("Not a threaded app");
122 result = m_decSvc->isEventAccepted(this->name());
123 }
124
125 return result;
126}
ServiceHandle< IDecisionSvc > m_decSvc

◆ 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 }

◆ selectedObjects()

IDataSelector * Athena::RootNtupleOutputStream::selectedObjects ( )
inlineprivate

Return the list of selected objects.

Definition at line 128 of file RootNtupleOutputStream.h.

128 {
129 return &m_objects;
130 }

◆ 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

◆ write()

StatusCode Athena::RootNtupleOutputStream::write ( )
virtual

Stream the data.

Definition at line 246 of file RootNtupleOutputStream.cxx.

247{
248 bool failed = false;
249 // Clear any previously existing item list
251 // Test whether this event should be output
252 if (isEventAccepted()) {
253 // Connect the output file to the service
254 if (m_streamer->connectOutput(m_outputName).isSuccess()) {
255 // First check if there are any new items in the list
257 StatusCode sc = m_streamer->streamObjects(m_objects);
258 // Do final check of streaming
259 if (!sc.isSuccess()) {
260 if (!sc.isRecoverable()) {
261 ATH_MSG_FATAL("streamObjects failed.");
262 failed = true;
263 } else {
264 ATH_MSG_DEBUG("streamObjects failed.");
265 }
266 }
267 sc = m_streamer->commitOutput();
268 if (!sc.isSuccess()) {
269 ATH_MSG_FATAL("commitOutput failed.");
270 failed = true;
271 }
273 if (!failed) {
274 m_events++;
275 }
276 }
277 }
278
279 return failed
280 ? StatusCode::FAILURE
281 : StatusCode::SUCCESS;
282}
void clearSelection()
Clear list of selected objects.
void collectAllObjects()
Collect data objects for output streamer list.
bool isEventAccepted() const
Test whether this event should be output.

◆ AlgFactory< Athena::RootNtupleOutputStream >

Definition at line 1 of file RootNtupleOutputStream.h.

Member Data Documentation

◆ m_acceptNames

StringArrayProperty FilteredAlgorithm::m_acceptNames
protectedinherited
Initial value:
{this, "AcceptAlgs", {},
"Filters which if any are passed enable output"}

Vector of names of Algorithms that this stream accepts.

Definition at line 33 of file FilteredAlgorithm.h.

33 {this, "AcceptAlgs", {},
34 "Filters which if any are passed enable output"};

◆ m_dataStore

ServiceHandle<StoreGateSvc> Athena::RootNtupleOutputStream::m_dataStore
protected

handle to the StoreGateSvc store where the data we want to write out resides

Definition at line 58 of file RootNtupleOutputStream.h.

◆ m_decSvc

ServiceHandle<IDecisionSvc> FilteredAlgorithm::m_decSvc
protectedinherited
Initial value:
{this, "decSvc", "DecisionSvc/DecisionSvc",
"Handle to DecisionSvc"}

Definition at line 42 of file FilteredAlgorithm.h.

42 {this, "decSvc", "DecisionSvc/DecisionSvc",
43 "Handle to DecisionSvc"};

◆ 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_dynamicItemList

bool Athena::RootNtupleOutputStream::m_dynamicItemList
protected

dynamic output itemlist: if enabled rediscover object list to be written out at each event otherwise: reuse the one from the first event.

Definition at line 95 of file RootNtupleOutputStream.h.

◆ m_events

int Athena::RootNtupleOutputStream::m_events
protected

Number of events written to this output stream.

Definition at line 77 of file RootNtupleOutputStream.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_exemptPersToPers

std::vector<unsigned int> Athena::RootNtupleOutputStream::m_exemptPersToPers
protected

Definition at line 82 of file RootNtupleOutputStream.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_forceRead

bool Athena::RootNtupleOutputStream::m_forceRead
protected

set to true to force read of data objects in item list

Definition at line 79 of file RootNtupleOutputStream.h.

◆ m_helperTools

ToolHandleArray<IAthenaOutputTool> Athena::RootNtupleOutputStream::m_helperTools
protected

vector of AlgTools that that are executed by this stream

Definition at line 103 of file RootNtupleOutputStream.h.

◆ m_itemList

StringArrayProperty Athena::RootNtupleOutputStream::m_itemList
protected

Vector of item names.

Definition at line 73 of file RootNtupleOutputStream.h.

◆ m_itemListFromTool

bool Athena::RootNtupleOutputStream::m_itemListFromTool
protected

set to write out everything from input DataHeader

Definition at line 90 of file RootNtupleOutputStream.h.

◆ m_objects

IDataSelector Athena::RootNtupleOutputStream::m_objects
protected

Collection of objects beeing selected.

Definition at line 75 of file RootNtupleOutputStream.h.

◆ m_outputName

std::string Athena::RootNtupleOutputStream::m_outputName
protected

Name of the output file.

Definition at line 65 of file RootNtupleOutputStream.h.

◆ m_pCLIDSvc

IClassIDSvc_t Athena::RootNtupleOutputStream::m_pCLIDSvc
protected

Definition at line 70 of file RootNtupleOutputStream.h.

◆ m_persName

std::string Athena::RootNtupleOutputStream::m_persName
protected

Name of the persistency service capable to write data from the store.

Definition at line 61 of file RootNtupleOutputStream.h.

◆ m_persToPers

bool Athena::RootNtupleOutputStream::m_persToPers
protected

set to true to allow data objects being copied persistent to persistent (without SG retrieve).

Definition at line 81 of file RootNtupleOutputStream.h.

◆ m_processTag

StringProperty Athena::RootNtupleOutputStream::m_processTag
protected

tag of processing stage:

Definition at line 67 of file RootNtupleOutputStream.h.

◆ m_provideDef

bool Athena::RootNtupleOutputStream::m_provideDef
protected

set to true to allow defaults being provided for non-existent data objects.

Definition at line 84 of file RootNtupleOutputStream.h.

◆ m_requireNames

StringArrayProperty FilteredAlgorithm::m_requireNames
protectedinherited
Initial value:
{this, "RequireAlgs", {},
"Filters which must all be passed to enable output"}

Vector of names of Algorithms that this stream requires.

Definition at line 36 of file FilteredAlgorithm.h.

36 {this, "RequireAlgs", {},
37 "Filters which must all be passed to enable output"};

◆ m_selection

std::vector<SG::FolderItem> Athena::RootNtupleOutputStream::m_selection
protected

list of selected proxies.

Definition at line 98 of file RootNtupleOutputStream.h.

◆ m_streamer

ToolHandle<IAthenaOutputStreamTool> Athena::RootNtupleOutputStream::m_streamer
protected

pointer to AthenaOutputStreamTool

Definition at line 101 of file RootNtupleOutputStream.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vetoNames

StringArrayProperty FilteredAlgorithm::m_vetoNames
protectedinherited
Initial value:
{this, "VetoAlgs", {},
"Filters which if any are passed disable output"}

Vector of names of Algorithms that this stream is vetoed by.

Definition at line 39 of file FilteredAlgorithm.h.

39 {this, "VetoAlgs", {},
40 "Filters which if any are passed disable output"};

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_writeOnExecute

bool Athena::RootNtupleOutputStream::m_writeOnExecute
protected

set to true to trigger streaming of data on execute()

Definition at line 86 of file RootNtupleOutputStream.h.

◆ m_writeOnFinalize

bool Athena::RootNtupleOutputStream::m_writeOnFinalize
protected

set to true to trigger streaming of data on finalize()

Definition at line 88 of file RootNtupleOutputStream.h.

◆ m_writingTool

StringProperty Athena::RootNtupleOutputStream::m_writingTool
protected

Name of the OutputStreamTool used for writing.

Definition at line 63 of file RootNtupleOutputStream.h.


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