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 47 of file AANTupleStream.cxx.

48 : AthLegacySequence(name, pSvcLocator),
49 m_persSvc ("EventPersistencySvc", name),
50 m_attribSpec(0),
51 m_schemaDone(false),
52 m_tree(0),
54 m_tHistSvc ("THistSvc", name)
55{
56 declareProperty("OutputName", m_fileName="AANTuple.root");
57 declareProperty("ExtraRefNames", m_extraRefNames);
58 declareProperty("WriteInputDataHeader", m_writeInputDH=false);
59 declareProperty("ExistDataHeader", m_existDH=true);
61 declareProperty("LateSchemaWriting", m_lateSchema=false);
63 declareProperty("Macro", m_macro="");
65 declareProperty("FilterAlgs", m_acceptNames);
66
67 m_tokenCString[0] = '\0';
68}
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 72 of file AANTupleStream.cxx.

73{
74}

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 172 of file AANTupleStream.cxx.

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

◆ execute_subAlgos()

StatusCode AANTupleStream::execute_subAlgos ( )
private

execute sub-algos

Definition at line 549 of file AANTupleStream.cxx.

550{
551 StatusCode sc = StatusCode::SUCCESS;
552
553 ATH_MSG_DEBUG ("in execute_subAlgos() ...");
554
555 const EventContext& ctx = Gaudi::Hive::currentContext();
556
557 // -- run subalgorithms
558 for ( unsigned int i=0; i < m_membersNames.size(); ++i )
559 {
560 ATH_MSG_DEBUG (" -> calling sub-algorithm " << m_membersNames[i]);
561 // skip disabled algo
562 if (! (*(this->subAlgorithms()))[i]->isEnabled()) continue ;
563
564 sc = (*(this->subAlgorithms()))[i]->execute(ctx);
565 if ( sc.isFailure())
566 {
568 (" ERROR executing sub-algorithm:" << m_membersNames[i]);
569 return StatusCode::FAILURE;
570 }
571 }
572 return sc;
573}
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 148 of file AANTupleStream.cxx.

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

578{
579 ATH_MSG_DEBUG ("in getFilters()");
580
581 // no filter
582 if (m_acceptNames.empty())
583 return StatusCode::SUCCESS;
584
585 ServiceHandle<IAlgManager> theAlgMgr("ApplicationMgr", this->name());
586 ATH_CHECK( theAlgMgr.retrieve() );
587
588 // loop over all alg names
589 for (const std::string& name : m_acceptNames)
590 {
591 SmartIF<IAlgorithm> ialg{theAlgMgr->algorithm(name)};
592 if (!ialg )
593 {
594 ATH_MSG_ERROR ("Can't get Filter Alg : " << name);
595 return StatusCode::FAILURE;
596 }
597 ATH_MSG_DEBUG (" -> getting Filter Alg success " << name);
598 // push back
599 m_acceptAlgs.push_back(ialg);
600 }
601 return StatusCode::SUCCESS;
602}
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 375 of file AANTupleStream.cxx.

376{
377 // Must access the SG proxy to get the IOpaqueAddress
378 SG::DataProxy* itemProxy = 0;
379 ATH_MSG_DEBUG ("Retrieving proxy for " << id << " " << key);
380 itemProxy = evtStore()->proxy(id, key);
381 if (!itemProxy)
382 {
383 ATH_MSG_ERROR ("Could not get proxy ");
384 return(StatusCode::FAILURE);
385 }
386 else
387 {
388 ATH_MSG_DEBUG (" found proxy for ("<< id << ",\"" << key << "\") ");
389 }
390
391 if (!itemProxy)
392 {
393 ATH_MSG_ERROR ("Empty proxy ");
394 return(StatusCode::FAILURE);
395 }
396
397 // Get IOpaqueAddress from the proxy
398 IOpaqueAddress* addr = itemProxy->address();
399 if (!addr)
400 {
401 ATH_MSG_DEBUG ("Could not get address for clid "
402 << itemProxy->clID() << " " << itemProxy->name());
403 return( StatusCode::FAILURE);
404 }
405
406 // Convert IOpaqueAddress to string via the persistency
407 // service. And then remove header to extract the token.
408 std::string saddr;
409
410 StatusCode sc = m_persSvc->convertAddress(addr, saddr);
411 if (sc.isFailure())
412 {
414 ("Could not get string from IOpaqueAddress for clid " << id
415 << " " << key
416 << " is BAD_STORAGE_TYPE: "<< (sc == IConversionSvc::Status::BAD_STORAGE_TYPE));
417 return( StatusCode::FAILURE);
418 }
419
420
421 // We assume here some knowledge of the form of the AthenaPool
422 // string address
423 std::string hdr;
424 sc = splitAddress(saddr, " /> ", hdr, ref);
425 if (sc.isFailure())
426 {
427 ATH_MSG_ERROR ("Could not get split off token. string address " << saddr);
428 return( StatusCode::FAILURE);
429 }
430
431 ATH_MSG_DEBUG ("String address " << ref);
432
433 return StatusCode::SUCCESS;
434}
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 131 of file AANTupleStream.cxx.

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

◆ initialize()

StatusCode AANTupleStream::initialize ( )
virtual

Initialize AANTupleStream.

Definition at line 78 of file AANTupleStream.cxx.

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

◆ initialize_subAlgos()

StatusCode AANTupleStream::initialize_subAlgos ( )
private

initialize sub-algos

Definition at line 519 of file AANTupleStream.cxx.

520{
521 StatusCode sc = StatusCode::SUCCESS;
522
523 Algorithm* algo;
524 for (const std::string& name : m_membersNames)
525 {
526 // Parse the name for a syntax of the form:
527 //
528 // <type>/<name>
529 //
530 // Where <name> is the algorithm instance name, and <type> is the
531 // algorithm class type (being a subclass of Algorithm).
532 Gaudi::Utils::TypeNameString tn(name);
533
534 // create sub-algorithm
535 ATH_MSG_INFO (" -> creating sub-algorithm " << name);
536 sc = createSubAlgorithm( tn.type(), tn.name(), algo );
537 if (sc.isFailure())
538 {
539 ATH_MSG_FATAL (" ERROR creating sub-alg." << name);
540 return StatusCode::FAILURE;
541 }
542 }
543
544 return sc;
545}
#define ATH_MSG_FATAL(x)

◆ initSchema()

StatusCode AANTupleStream::initSchema ( )
private

dump

Definition at line 629 of file AANTupleStream.cxx.

630{
631 m_schemaDone = true;
632
633 ATH_CHECK( m_tHistSvc.retrieve() );
634
635 // initialize output collection
637
638 // register TTree to THistSvc
639 ATH_CHECK( m_tHistSvc->regTree("/"+m_streamName+"/"+m_treeName, m_tree) );
640
642 m_tree->Print();
643
644 return StatusCode::SUCCESS;
645}
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 648 of file AANTupleStream.cxx.

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

◆ isEventAccepted()

bool AANTupleStream::isEventAccepted ( ) const
private

check filters passed

Definition at line 609 of file AANTupleStream.cxx.

610{
611 // no filter
612 if (m_acceptAlgs.empty())
613 return true;
614
615 const EventContext& ctx = Gaudi::Hive::currentContext();
616
617 // loop over all algs
618 for (const IAlgorithm* alg : m_acceptAlgs)
619 {
620 if ( alg->execState(ctx).state() == AlgExecState::State::Done &&
621 ( ! alg->execState(ctx).filterPassed() ) )
622 return false;
623 }
624
625 return true;
626}

◆ 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 329 of file AANTupleStream.cxx.

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

◆ 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 439 of file AANTupleStream.cxx.

443{
444 ATH_MSG_DEBUG ("splitAddress " << endmsg
445 << " address : " << address
446 << " match : " << match);
447
448 std::string::size_type p1;
449
450 p1 = address.find( match );
451 if (p1 != std::string::npos)
452 {
453 address_header = address.substr( 0, p1+match.size());
454
455 address_data = address.substr( p1+match.size() );
456 }
457 else
458 {
459 return StatusCode::FAILURE;
460 }
461
462 ATH_MSG_DEBUG (" address_header : " << address_header
463 << endmsg
464 << " address_data : " << address_data);
465
466 return StatusCode::SUCCESS;
467}
#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 321 of file AANTupleStream.cxx.

322{
323 // go to the root dir of output file
324 TDirectory::TContext save;
325 gDirectory->cd((m_fileName+":/").c_str());
326}

◆ writeTokenAttrList()

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

write Token and AttributeList

Definition at line 471 of file AANTupleStream.cxx.

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