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

#include <AANTupleStream.h>

Inheritance diagram for AANTupleStream:
Collaboration diagram for AANTupleStream:

Public Member Functions

 AANTupleStream (const std::string &name, ISvcLocator *pSvcLocator)
 Standard AANTupleStream Constructor.
virtual ~AANTupleStream ()
 Standard Destructor.
virtual StatusCode initialize ()
 Initialize AANTupleStream.
virtual StatusCode finalize ()
 Terminate AANTupleStream.
virtual StatusCode execute ()
 Working entry point.
 AthLegacySequenceAdapter (const std::string &name, ISvcLocator *pSvcLocator)
 Constructor with parameters:
const EventContext & getContext () const
virtual const DataObjIDColl & extraOutputDeps () const override
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 sysInitialize () override
 Perform system initialization for an algorithm.
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

bool isReEntrant () const override final
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

StatusCode initCollection ()
 Initialize the output collection.
StatusCode getRef (CLID id, const std::string &key, std::string &ref)
 Get ref from a proxy.
StatusCode splitAddress (const std::string &address, const std::string &match, std::string &address_header, std::string &address_data) const
 Split the address to get pool token.
StatusCode initialize_subAlgos ()
 initialize sub-algos
StatusCode execute_subAlgos ()
 execute sub-algos
void writeAttributeListSpecification ()
 write schema of AttributeList
void setupTree ()
 setup Tree
bool writeTokenAttrList (const std::string &token, const coral::AttributeList &attributeList)
 write Token and AttributeList
StatusCode getFilters ()
 get filter alogs
bool isEventAccepted () const
 check filters passed
StatusCode initSchema ()
StatusCode io_reinit ()
 callback method to reinitialize the internal state of the component for I/O purposes (e.g.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ServiceHandle< IAddressCreator > m_persSvc
 Persistency service.
coral::AttributeListSpecification * m_attribSpec
 Collection attribute specification.
std::string m_fileName
 Name of the output collection.
StringArrayProperty m_extraRefNames
 Vector of extra parent ref names to register in collection.
BooleanProperty m_writeInputDH
 Flag to signal whether or not to write input data header.
BooleanProperty m_existDH
 Flag to signal whether data header exists.
std::string m_streamName
 Name of Stream.
BooleanProperty m_lateSchema
 write schema in execute()
std::string m_macro
 macro
bool m_schemaDone
 first event
std::string m_treeName
 Name of the output tree.
std::vector< std::string > m_acceptNames
 Vector of names of Algorithms that this stream accepts.
std::vector< IAlgorithm * > m_acceptAlgs
 Vector of Algorithms that this stream accepts.
TTree * m_tree
 TTree.
TBranch * m_tokenBranch
 TBranch which contains Token info.
ServiceHandle< ITHistSvc > m_tHistSvc
 THistSvc.
std::vector< std::string > m_membersNames
char m_tokenCString [s_maxLengthOfStrings]
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

Static Private Attributes

static const unsigned int s_maxLengthOfStrings = 5000
 for string branches

Detailed Description

Definition at line 33 of file AANTupleStream.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ AANTupleStream()

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

Standard AANTupleStream Constructor.

Definition at line 48 of file AANTupleStream.cxx.

49 : AthLegacySequence(name, pSvcLocator),
50 m_persSvc ("EventPersistencySvc", name),
51 m_attribSpec(0),
52 m_schemaDone(false),
53 m_tree(0),
55 m_tHistSvc ("THistSvc", name)
56{
57 declareProperty("OutputName", m_fileName="AANTuple.root");
58 declareProperty("ExtraRefNames", m_extraRefNames);
59 declareProperty("WriteInputDataHeader", m_writeInputDH=false);
60 declareProperty("ExistDataHeader", m_existDH=true);
62 declareProperty("LateSchemaWriting", m_lateSchema=false);
64 declareProperty("Macro", m_macro="");
66 declareProperty("FilterAlgs", m_acceptNames);
67
68 m_tokenCString[0] = '\0';
69}
std::string m_treeName
Name of the output tree.
BooleanProperty m_lateSchema
write schema in execute()
std::vector< std::string > m_membersNames
std::string m_macro
macro
bool m_schemaDone
first event
ServiceHandle< IAddressCreator > m_persSvc
Persistency service.
BooleanProperty m_writeInputDH
Flag to signal whether or not to write input data header.
TBranch * m_tokenBranch
TBranch which contains Token info.
char m_tokenCString[s_maxLengthOfStrings]
StringArrayProperty m_extraRefNames
Vector of extra parent ref names to register in collection.
std::vector< std::string > m_acceptNames
Vector of names of Algorithms that this stream accepts.
coral::AttributeListSpecification * m_attribSpec
Collection attribute specification.
BooleanProperty m_existDH
Flag to signal whether data header exists.
std::string m_fileName
Name of the output collection.
ServiceHandle< ITHistSvc > m_tHistSvc
THistSvc.
std::string m_streamName
Name of Stream.
TTree * m_tree
TTree.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
static const std::string c_streamName
static const std::string c_treeName

◆ ~AANTupleStream()

AANTupleStream::~AANTupleStream ( )
virtual

Standard Destructor.

Definition at line 73 of file AANTupleStream.cxx.

74{
75}

Member Function Documentation

◆ AthLegacySequenceAdapter()

Athena::details::AthLegacySequenceAdapter::AthLegacySequenceAdapter ( const std::string & name,
ISvcLocator * pSvcLocator )
inherited

Constructor with parameters:

Definition at line 31 of file AthLegacySequence.cxx.

14 :
16 {
17 StatusCode sc = setProperty("Cardinality", 1);
18 if ( sc.isFailure() ) {
19 throw GaudiException("Failed to set property Cardinality",
20 "AthLegacySequenceAdapter", sc);
21 }
22 m_updateDataHandles =
23 std::make_unique<AthenaBaseComps::AthAlgorithmDHUpdate>
25 std::move (m_updateDataHandles));
26 }
static Double_t sc
void setProperty(columnar::PythonToolHandle &self, const std::string &key, nb::object value)
AthCommonDataStore(const std::string &name, T... args)
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ declareGaudiProperty()

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

Working entry point.

Implements AthLegacySequence.

Definition at line 173 of file AANTupleStream.cxx.

174{
176
177 if (!m_schemaDone) {
178 sc = initSchema();
179 if (sc.isFailure())
180 return sc;
181 }
182
183 // execute sub-algos
185 if ( sc.isFailure() )
186 {
187 ATH_MSG_ERROR ("Could not execute sub-algos");
188 return sc;
189 }
190
191 std::map<std::string,std::string> inputRefs;
192 std::string ref;
193
194 // Get tokens specified by item list
195 if (m_existDH)
196 {
197 // get token
198 SG::ConstIterator<DataHeader> beg;
199 SG::ConstIterator<DataHeader> ending;
200 StatusCode status = evtStore()->retrieve(beg,ending);
201 if (status.isFailure() || beg==ending)
202 {
203 ATH_MSG_WARNING ("No DataHeaders present in StoreGate");
204 return StatusCode::FAILURE;
205 }
206
207 // look for header
208 for (; beg != ending; ++beg)
209 if (m_writeInputDH == beg->isInput()) break;
210
211 if (beg==ending)
212 {
213 ATH_MSG_WARNING ("No appropriate DataHeader present in StoreGate");
214 return StatusCode::FAILURE;
215 }
216
217 // get the ref
218 while (getRef(ClassID_traits<DataHeader>::ID(), beg.key(), ref) == StatusCode::FAILURE)
219 {
220 ++beg;
221 if (beg==ending)
222 {
223 ATH_MSG_ERROR ("No refs found");
224 return StatusCode::FAILURE;
225 }
226 }
227
228 ATH_MSG_DEBUG ("Found token: Key=" << beg.key() << ", Ref=" << ref);
229
230 // Get a single input header ref if requested
231 const DataHeader* hdr = &(*beg);
232 if (hdr->sizeProvenance())
233 {
234 std::vector<DataHeaderElement>::const_iterator it =
235 (const_cast<DataHeader*>(hdr)->beginProvenance());
236 std::vector<DataHeaderElement>::const_iterator itE =
237 (const_cast<DataHeader*>(hdr)->endProvenance());
238 // grab refs for those
239 for (; it!=itE; ++it)
240 {
241 std::string tmpRef = (*it).getToken() != NULL
242 ? (*it).getToken()->toString()
243 : "";
244 inputRefs.insert(std::make_pair(it->getKey(),tmpRef));
245 ATH_MSG_DEBUG ("Found ref for input header: Key=" << it->getKey()
246 << ", Ref=" << tmpRef);
247 }
248 }
249 }
250
251 // create Attrlist, add attributes and if extra ref is requested, append to the end
252
253 ATH_MSG_DEBUG ("create AttributeList");
254 // AthenaAttributeList newAttr(*m_attribSpec);
255 coral::AttributeList newAttr(*m_attribSpec);
256
257 unsigned int runNumber = 0;
258 unsigned int eventNumber = 0;
259
260 // retrieve event info
261 const EventInfo* eventInfo;
262 eventInfo = evtStore()->tryConstRetrieve<EventInfo>();
263 if ( !eventInfo )
264 {
265 // Try to get the xAOD::EventInfo
266 const xAOD::EventInfo* eventInfoX{nullptr};
267 ATH_CHECK( evtStore()->retrieve(eventInfoX) );
268 runNumber = eventInfoX->runNumber();
269 eventNumber = eventInfoX->eventNumber();
270 }
271 else
272 {
273 runNumber = eventInfo->event_ID()->run_number();
274 eventNumber = eventInfo->event_ID()->event_number();
275 }
276
277 // add global event tag data
278 newAttr[ name_RunNumber ].setValue( runNumber );
279 newAttr[ name_EventNumber ].setValue( eventNumber );
280
281 // add back nav ref's
282 ATH_MSG_DEBUG ("Append extra ref");
283 std::vector<std::string> extraRefs = m_extraRefNames.value();
284 std::map<std::string,std::string>::iterator itRef = inputRefs.begin();
285 std::map<std::string,std::string>::iterator itRefE = inputRefs.end();
286 for (; itRef != itRefE; ++itRef)
287 {
288 std::string name = itRef->first + "_ref";
289 if (extraRefs.end() != std::find(extraRefs.begin(),extraRefs.end(),itRef->first))
290 {
291 newAttr[name].setValue(std::string(itRef->second));
292 ATH_MSG_DEBUG (" Added extra ref to new attribute list - name: "
293 << name << " " << itRef->second);
294 }
295 }
296
297 // write if filters passed
298 if (isEventAccepted())
299 {
300 ATH_MSG_DEBUG ("write attributes to collection");
301
302 // write token plus attributes
303 try
304 {
305 writeTokenAttrList(ref, newAttr);
306 }
307 catch (std::exception &e)
308 {
310 ("Caught exception from collection add of Pool attributes. "
311 "Message: " << e.what());
312 return StatusCode::FAILURE;
313 }
314 }
315
316 ATH_MSG_DEBUG ("done successfully");
317
318 return StatusCode::SUCCESS;
319}
const boost::regex ref(r_ef)
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
bool writeTokenAttrList(const std::string &token, const coral::AttributeList &attributeList)
write Token and AttributeList
StatusCode execute_subAlgos()
execute sub-algos
StatusCode getRef(CLID id, const std::string &key, std::string &ref)
Get ref from a proxy.
StatusCode initSchema()
bool isEventAccepted() const
check filters passed
int sizeProvenance() const
EventID * event_ID()
the unique identification of the event.
uint32_t runNumber() const
The current event's run number.
uint64_t eventNumber() const
The current event's event number.
status
Definition merge.py:16
retrieve(aClass, aKey=None)
Definition PyKernel.py:110
EventInfo_v1 EventInfo
Definition of the latest event info version.

◆ execute_subAlgos()

StatusCode AANTupleStream::execute_subAlgos ( )
private

execute sub-algos

Definition at line 559 of file AANTupleStream.cxx.

560{
561 StatusCode sc = StatusCode::SUCCESS;
562
563 ATH_MSG_DEBUG ("in execute_subAlgos() ...");
564
565 const EventContext& ctx = Gaudi::Hive::currentContext();
566
567 // -- run subalgorithms
568 for ( unsigned int i=0; i < m_membersNames.size(); ++i )
569 {
570 ATH_MSG_DEBUG (" -> calling sub-algorithm " << m_membersNames[i]);
571 // skip disabled algo
572 if (! (*(this->subAlgorithms()))[i]->isEnabled()) continue ;
573
574 sc = (*(this->subAlgorithms()))[i]->execute(ctx);
575 if ( sc.isFailure())
576 {
578 (" ERROR executing sub-algorithm:" << m_membersNames[i]);
579 return StatusCode::FAILURE;
580 }
581 }
582 return sc;
583}
virtual StatusCode execute()
Working entry point.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::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 & Athena::details::AthLegacySequenceAdapter::extraOutputDeps ( ) const
overridevirtualinherited

Definition at line 30 of file AthLegacySequence.cxx.

30 {
31 if (!m_extendedExtraObjects.empty()) {
33 }
34 return Gaudi::Sequence::extraOutputDeps();
35 }

◆ finalize()

StatusCode AANTupleStream::finalize ( )
virtual

Terminate AANTupleStream.

Definition at line 149 of file AANTupleStream.cxx.

150{
151 ATH_MSG_INFO ("finalize");
152
153 // exec macro
154 if (m_macro != "")
155 {
156 // save current dir
157 std::string curDir = gDirectory->GetPath();
158 // go to the root dir of output file
159 gDirectory->cd((m_fileName+":/").c_str());
160 // exec
161 // G__exec_tempfile(m_macro.c_str());
162 // MN: that should be the equivalent new call:
163 gInterpreter->ExecuteMacro(m_macro.c_str());
164 // back to the current dir
165 gDirectory->cd(curDir.c_str());
166 }
167
168 return AthLegacySequence::finalize();
169}
#define ATH_MSG_INFO(x)

◆ getContext()

const EventContext & Athena::details::AthLegacySequenceAdapter::getContext ( ) const
inlineinherited

Definition at line 36 of file AthLegacySequence.h.

36{ return Gaudi::Hive::currentContext(); }

◆ getFilters()

StatusCode AANTupleStream::getFilters ( )
private

get filter alogs

Definition at line 587 of file AANTupleStream.cxx.

588{
589 ATH_MSG_DEBUG ("in getFilters()");
590
591 // no filter
592 if (m_acceptNames.empty())
593 return StatusCode::SUCCESS;
594
595 ServiceHandle<IAlgManager> theAlgMgr("ApplicationMgr", this->name());
596 ATH_CHECK( theAlgMgr.retrieve() );
597
598 // loop over all alg names
599 for (const std::string& name : m_acceptNames)
600 {
601 SmartIF<IAlgorithm> ialg{theAlgMgr->algorithm(name)};
602 if (!ialg )
603 {
604 ATH_MSG_ERROR ("Can't get Filter Alg : " << name);
605 return StatusCode::FAILURE;
606 }
607 ATH_MSG_DEBUG (" -> getting Filter Alg success " << name);
608 // push back
609 m_acceptAlgs.push_back(ialg);
610 }
611 return StatusCode::SUCCESS;
612}
std::vector< IAlgorithm * > m_acceptAlgs
Vector of Algorithms that this stream accepts.

◆ getRef()

StatusCode AANTupleStream::getRef ( CLID id,
const std::string & key,
std::string & ref )
private

Get ref from a proxy.

Definition at line 385 of file AANTupleStream.cxx.

386{
387 // Must access the SG proxy to get the IOpaqueAddress
388 SG::DataProxy* itemProxy = 0;
389 ATH_MSG_DEBUG ("Retrieving proxy for " << id << " " << key);
390 itemProxy = evtStore()->proxy(id, key);
391 if (!itemProxy)
392 {
393 ATH_MSG_ERROR ("Could not get proxy ");
394 return(StatusCode::FAILURE);
395 }
396 else
397 {
398 ATH_MSG_DEBUG (" found proxy for ("<< id << ",\"" << key << "\") ");
399 }
400
401 if (!itemProxy)
402 {
403 ATH_MSG_ERROR ("Empty proxy ");
404 return(StatusCode::FAILURE);
405 }
406
407 // Get IOpaqueAddress from the proxy
408 IOpaqueAddress* addr = itemProxy->address();
409 if (!addr)
410 {
411 ATH_MSG_DEBUG ("Could not get address for clid "
412 << itemProxy->clID() << " " << itemProxy->name());
413 return( StatusCode::FAILURE);
414 }
415
416 // Convert IOpaqueAddress to string via the persistency
417 // service. And then remove header to extract the token.
418 std::string saddr;
419
420 StatusCode sc = m_persSvc->convertAddress(addr, saddr);
421 if (sc.isFailure())
422 {
424 ("Could not get string from IOpaqueAddress for clid " << id
425 << " " << key
426 << " is BAD_STORAGE_TYPE: "<< (sc == IConversionSvc::Status::BAD_STORAGE_TYPE));
427 return( StatusCode::FAILURE);
428 }
429
430
431 // We assume here some knowledge of the form of the AthenaPool
432 // string address
433 std::string hdr;
434 sc = splitAddress(saddr, " /> ", hdr, ref);
435 if (sc.isFailure())
436 {
437 ATH_MSG_ERROR ("Could not get split off token. string address " << saddr);
438 return( StatusCode::FAILURE);
439 }
440
441 ATH_MSG_DEBUG ("String address " << ref);
442
443 return StatusCode::SUCCESS;
444}
StatusCode splitAddress(const std::string &address, const std::string &match, std::string &address_header, std::string &address_data) const
Split the address to get pool token.
CLID clID() const
Retrieve clid.
virtual const name_type & name() const override final
Retrieve data object key == string.
virtual IOpaqueAddress * address() const override final
Retrieve IOpaqueAddress.

◆ initCollection()

StatusCode AANTupleStream::initCollection ( )
private

Initialize the output collection.

Definition at line 132 of file AANTupleStream.cxx.

133{
134 // write schema
136
137 // setup TTree
138 setupTree();
139
140 // setup Token
141 m_tokenBranch = m_tree->GetBranch(c_tokenBranchName);
142 m_tokenBranch->SetAddress(m_tokenCString);
143
144 return StatusCode::SUCCESS;
145}
void setupTree()
setup Tree
void writeAttributeListSpecification()
write schema of AttributeList

◆ initialize()

StatusCode AANTupleStream::initialize ( )
virtual

Initialize AANTupleStream.

Definition at line 79 of file AANTupleStream.cxx.

80{
81 ATH_MSG_DEBUG ("In initialize ");
82 // register with the I/O component manager
83 {
84 ServiceHandle<IIoComponentMgr> iomgr ("IoComponentMgr", this->name());
85 ATH_CHECK( iomgr.retrieve() );
86 ATH_CHECK( iomgr->io_register (this) );
87
88 if ( !iomgr->io_register (this,
89 IIoComponentMgr::IoMode::WRITE,
90 m_fileName).isSuccess() ) {
91 ATH_MSG_ERROR ("Could not register [" << this->name() << "]["
92 << m_fileName << "] with the I/O component manager !");
93 return StatusCode::FAILURE;
94 }
95 }
96
97 // StoreGateSvc
99
100 // set up the persistency service:
101 ATH_CHECK( m_persSvc.retrieve() );
102
103 // instantiate AttrListSpec and add attributes for Run# and Event#
104 m_attribSpec = new coral::AttributeListSpecification;
105 m_attribSpec->extend( name_RunNumber, "unsigned int" );
106 m_attribSpec->extend( name_EventNumber, "unsigned int" );
107
108 // Add on specification for extra refs
109 for (const std::string& ref : m_extraRefNames.value())
110 {
111 // Append _ref to name of attribute
112 m_attribSpec->extend(ref + "_ref", "string");
113 }
114
115 if (!m_lateSchema) {
117 }
118
119 // initialize sub-algos
121
122 // get filters
124
125 ATH_MSG_DEBUG ("End initialize ");
126
127 return AthLegacySequence::initialize();
128}
StatusCode getFilters()
get filter alogs
StatusCode initialize_subAlgos()
initialize sub-algos

◆ initialize_subAlgos()

StatusCode AANTupleStream::initialize_subAlgos ( )
private

initialize sub-algos

Definition at line 529 of file AANTupleStream.cxx.

530{
531 StatusCode sc = StatusCode::SUCCESS;
532
533 Algorithm* algo;
534 for (const std::string& name : m_membersNames)
535 {
536 // Parse the name for a syntax of the form:
537 //
538 // <type>/<name>
539 //
540 // Where <name> is the algorithm instance name, and <type> is the
541 // algorithm class type (being a subclass of Algorithm).
542 Gaudi::Utils::TypeNameString tn(name);
543
544 // create sub-algorithm
545 ATH_MSG_INFO (" -> creating sub-algorithm " << name);
546 sc = createSubAlgorithm( tn.type(), tn.name(), algo );
547 if (sc.isFailure())
548 {
549 ATH_MSG_FATAL (" ERROR creating sub-alg." << name);
550 return StatusCode::FAILURE;
551 }
552 }
553
554 return sc;
555}
#define ATH_MSG_FATAL(x)

◆ initSchema()

StatusCode AANTupleStream::initSchema ( )
private

dump

Definition at line 639 of file AANTupleStream.cxx.

640{
641 m_schemaDone = true;
642
643 ATH_CHECK( m_tHistSvc.retrieve() );
644
645 // initialize output collection
647
648 // register TTree to THistSvc
649 ATH_CHECK( m_tHistSvc->regTree("/"+m_streamName+"/"+m_treeName, m_tree) );
650
652 m_tree->Print();
653
654 return StatusCode::SUCCESS;
655}
StatusCode initCollection()
Initialize the output collection.

◆ inputHandles()

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

◆ io_reinit()

StatusCode AANTupleStream::io_reinit ( )
private

callback method to reinitialize the internal state of the component for I/O purposes (e.g.

upon fork(2))

Definition at line 658 of file AANTupleStream.cxx.

659{
660 ServiceHandle<IIoComponentMgr> iomgr ("IoComponentMgr", this->name());
661 ATH_CHECK( iomgr.retrieve() );
662
663 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> josvc ("JobOptionsSvc", this->name());
664 ATH_CHECK( josvc.retrieve() );
665
666 // check the I/O manager knows about me
667 if ( !iomgr->io_hasitem (this) ) {
668 ATH_MSG_ERROR ("I/O component mgr does not know about ourselves !");
669 return StatusCode::FAILURE;
670 }
671
672 // check there is actually something to do...
673 if ( !iomgr->io_contains (this, m_fileName) ) {
675 ("I/O component mgr does not have any entry about ["<< m_fileName<<"]");
676 return StatusCode::SUCCESS;
677 }
678
679 if ( !iomgr->io_retrieve (this, m_fileName).isSuccess() ) {
680 ATH_MSG_ERROR ("Could not retrieve new name for [" << m_fileName << "] !");
681 return StatusCode::FAILURE;
682 }
683
684 // recreate the proper property value...
685 std::vector<std::string> outvec = {"AANT DATAFILE='" + m_fileName + "' OPT='RECREATE'"};
686 josvc->set("THistSvc.Output", Gaudi::Utils::toString(outvec));
687
688 // handle schema...
689 if (!m_schemaDone) {
690 if ( !initSchema().isSuccess() ) {
691 ATH_MSG_ERROR ("Could not initialize schema !");
692 }
693 }
694
695 return StatusCode::SUCCESS;
696}

◆ isEventAccepted()

bool AANTupleStream::isEventAccepted ( ) const
private

check filters passed

Definition at line 619 of file AANTupleStream.cxx.

620{
621 // no filter
622 if (m_acceptAlgs.empty())
623 return true;
624
625 const EventContext& ctx = Gaudi::Hive::currentContext();
626
627 // loop over all algs
628 for (const IAlgorithm* alg : m_acceptAlgs)
629 {
630 if ( alg->execState(ctx).state() == AlgExecState::State::Done &&
631 ( ! alg->execState(ctx).filterPassed() ) )
632 return false;
633 }
634
635 return true;
636}

◆ isReEntrant()

bool Athena::details::AthLegacySequenceAdapter::isReEntrant ( ) const
inlinefinaloverrideprotectedinherited

Definition at line 41 of file AthLegacySequence.h.

41{ return false; }

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Sequence >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

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

◆ msgLvl()

bool AthCommonMsg< Gaudi::Sequence >::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< Gaudi::Sequence > >::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< Gaudi::Sequence > >::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< Gaudi::Sequence > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setupTree()

void AANTupleStream::setupTree ( )
private

setup Tree

Definition at line 339 of file AANTupleStream.cxx.

340{
341 static const std::map<std::string,char> typeDict = {
342 {"double", 'D'},
343 {"long double", 'D'}, // only 64 bit doubles are supported
344 {"float", 'F'},
345 {"int", 'i'},
346 {"unsigned int", 'I'},
347 {"long", 'i'}, // support for 64 bit integers introduced with ROOT 4.00/08
348 {"unsigned long", 'I'}, // support for 64 bit integers introduced with ROOT 4.00/08
349 {"short", 's'},
350 {"unsigned short", 'S'},
351 {"char", 'b'}, // AttributeLists's "get_root_type_char(...)" returned 'C' ???
352 {"unsigned char", 'B'}, // AttributeLists's "get_root_type_char(...)" returned 's' ???
353 {"bool", 'B'}, // AttributeLists's "get_root_type_char(...)" returned 'i' ???
354 {"string", 'C'},
355 {"Token", 'C'}
356 };
357
358 // go to the root dir of output file
359 TDirectory::TContext save;
360 gDirectory->cd((m_fileName+":/").c_str());
361
362 // instantiate TTree
363 m_tree = new TTree(m_treeName.c_str(), m_treeName.c_str());
364
365 // add branches for attributes
366 for(coral::AttributeListSpecification::const_iterator iter=m_attribSpec->begin(); iter!=m_attribSpec->end(); ++iter)
367 {
368 std::string type = "/?";
369 type[1] = typeDict.at(iter->typeName());
370 std::string leaflist = iter->name() + type;
371 m_tree->Branch(iter->name().c_str(),0,leaflist.c_str());
372 }
373
374 // add Token branch
375 std::string leaflist = c_tokenBranchName;
376 leaflist += "/C";
377 m_tree->Branch(c_tokenBranchName,0,leaflist.c_str());
378
379 // set TTree
381}
static void setTree(const std::string &stream, TTree *tree)
Definition AANTTreeMap.h:18

◆ splitAddress()

StatusCode AANTupleStream::splitAddress ( const std::string & address,
const std::string & match,
std::string & address_header,
std::string & address_data ) const
private

Split the address to get pool token.

Definition at line 449 of file AANTupleStream.cxx.

453{
454 ATH_MSG_DEBUG ("splitAddress " << endmsg
455 << " address : " << address
456 << " match : " << match);
457
458 std::string::size_type p1;
459
460 p1 = address.find( match );
461 if (p1 != std::string::npos)
462 {
463 address_header = address.substr( 0, p1+match.size());
464
465 address_data = address.substr( p1+match.size() );
466 }
467 else
468 {
469 return StatusCode::FAILURE;
470 }
471
472 ATH_MSG_DEBUG (" address_header : " << address_header
473 << endmsg
474 << " address_data : " << address_data);
475
476 return StatusCode::SUCCESS;
477}
#define endmsg
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::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< Gaudi::Sequence > >::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 }

◆ writeAttributeListSpecification()

void AANTupleStream::writeAttributeListSpecification ( )
private

write schema of AttributeList

Definition at line 322 of file AANTupleStream.cxx.

323{
324 // go to the root dir of output file
325 TDirectory::TContext save;
326 gDirectory->cd((m_fileName+":/").c_str());
327
328 AttributeListLayout all;
329 // store schema in the schema object
330 for( coral::AttributeListSpecification::const_iterator iter = m_attribSpec->begin();
331 iter != m_attribSpec->end(); ++iter) {
332 all.m_layout.push_back( make_pair( iter->name(), iter->typeName() ) );
333 }
334 // write schema object
335 all.Write(c_attributeListLayoutName);
336}

◆ writeTokenAttrList()

bool AANTupleStream::writeTokenAttrList ( const std::string & token,
const coral::AttributeList & attributeList )
private

write Token and AttributeList

Definition at line 481 of file AANTupleStream.cxx.

482{
483 // set addresses for attributes
484 coral::AttributeList::const_iterator attIter = attributeList.begin();
485 const TObjArray* branches = m_tree->GetListOfBranches();
486 std::vector<std::string> tokenStringDump;
487 // loop over all attributes
488 for (unsigned int i=0; i<attributeList.size(); ++i)
489 {
490 TBranch* branch = (TBranch*)branches->UncheckedAt(i);
491 // string attributes
492 if (attIter->specification().type() == typeid(std::string))
493 {
494 const std::string& str = attIter->data<std::string>();
495 if( str.length()+1 >= s_maxLengthOfStrings )
496 {
497 throw std::runtime_error("String is too long : RootCollection::pool2Root<std::string>");
498 }
499 branch->SetAddress( (void*)str.c_str() );
500 }
501 // Token
502 else if(attIter->specification().typeName() == "Token")
503 {
504 tokenStringDump.push_back( attIter->data<std::string>() );
505 branch->SetAddress( (void*) tokenStringDump.back().c_str() );
506 }
507 // else
508 else
509 {
510 branch->SetAddress( (void*)attIter->addressOfData() );
511 }
512 ++attIter;
513 }
514
515 // set address for Token
516 m_tokenBranch->SetAddress((void*)token.c_str());
517
518 // fill TTree
519 m_tree->Fill();
520
521 // releases Token
522 m_tokenBranch->SetAddress(m_tokenCString);
523
524 return true;
525}
static const unsigned int s_maxLengthOfStrings
for string branches

Member Data Documentation

◆ m_acceptAlgs

std::vector<IAlgorithm*> AANTupleStream::m_acceptAlgs
private

Vector of Algorithms that this stream accepts.

Definition at line 133 of file AANTupleStream.h.

◆ m_acceptNames

std::vector<std::string> AANTupleStream::m_acceptNames
private

Vector of names of Algorithms that this stream accepts.

Definition at line 130 of file AANTupleStream.h.

◆ m_attribSpec

coral::AttributeListSpecification* AANTupleStream::m_attribSpec
private

Collection attribute specification.

Definition at line 100 of file AANTupleStream.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_existDH

BooleanProperty AANTupleStream::m_existDH
private

Flag to signal whether data header exists.

Definition at line 112 of file AANTupleStream.h.

◆ m_extendedExtraObjects

DataObjIDColl Athena::details::AthLegacySequenceAdapter::m_extendedExtraObjects
privateinherited

Definition at line 51 of file AthLegacySequence.h.

◆ m_extraRefNames

StringArrayProperty AANTupleStream::m_extraRefNames
private

Vector of extra parent ref names to register in collection.

Definition at line 106 of file AANTupleStream.h.

◆ m_fileName

std::string AANTupleStream::m_fileName
private

Name of the output collection.

Definition at line 103 of file AANTupleStream.h.

◆ m_lateSchema

BooleanProperty AANTupleStream::m_lateSchema
private

write schema in execute()

Definition at line 118 of file AANTupleStream.h.

◆ m_macro

std::string AANTupleStream::m_macro
private

macro

Definition at line 121 of file AANTupleStream.h.

◆ m_membersNames

std::vector<std::string> AANTupleStream::m_membersNames
private

Definition at line 145 of file AANTupleStream.h.

◆ m_persSvc

ServiceHandle<IAddressCreator> AANTupleStream::m_persSvc
private

Persistency service.

Definition at line 97 of file AANTupleStream.h.

◆ m_schemaDone

bool AANTupleStream::m_schemaDone
private

first event

Definition at line 124 of file AANTupleStream.h.

◆ m_streamName

std::string AANTupleStream::m_streamName
private

Name of Stream.

Definition at line 115 of file AANTupleStream.h.

◆ m_tHistSvc

ServiceHandle<ITHistSvc> AANTupleStream::m_tHistSvc
private

THistSvc.

Definition at line 142 of file AANTupleStream.h.

◆ m_tokenBranch

TBranch* AANTupleStream::m_tokenBranch
private

TBranch which contains Token info.

Definition at line 139 of file AANTupleStream.h.

◆ m_tokenCString

char AANTupleStream::m_tokenCString[s_maxLengthOfStrings]
private

Definition at line 149 of file AANTupleStream.h.

◆ m_tree

TTree* AANTupleStream::m_tree
private

TTree.

Definition at line 136 of file AANTupleStream.h.

◆ m_treeName

std::string AANTupleStream::m_treeName
private

Name of the output tree.

Definition at line 127 of file AANTupleStream.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Sequence > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

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

Definition at line 398 of file AthCommonDataStore.h.

◆ m_writeInputDH

BooleanProperty AANTupleStream::m_writeInputDH
private

Flag to signal whether or not to write input data header.

Definition at line 109 of file AANTupleStream.h.

◆ s_maxLengthOfStrings

const unsigned int AANTupleStream::s_maxLengthOfStrings = 5000
staticprivate

for string branches

Definition at line 148 of file AANTupleStream.h.


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