12 #include "Gaudi/Interfaces/IOptionsSvc.h"
13 #include "GaudiKernel/IAlgManager.h"
14 #include "GaudiKernel/ISvcLocator.h"
15 #include "GaudiKernel/IAddressCreator.h"
16 #include "GaudiKernel/IOpaqueAddress.h"
17 #include "GaudiKernel/MsgStream.h"
18 #include "GaudiKernel/ITHistSvc.h"
19 #include "GaudiKernel/ListItem.h"
20 #include "GaudiKernel/ServiceHandle.h"
21 #include "GaudiKernel/IIoComponentMgr.h"
28 #include "CoralBase/AttributeList.h"
29 #include "CoralBase/AttributeListSpecification.h"
31 #include "EventInfo/EventInfo.h"
39 #include "TInterpreter.h"
50 m_persSvc (
"EventPersistencySvc",
name),
55 m_tHistSvc (
"THistSvc",
name)
85 if ( !iomgr.retrieve().isSuccess() ) {
86 ATH_MSG_ERROR (
"Could not retrieve IIoComponentMgr/IoComponentMgr !");
87 return StatusCode::FAILURE;
89 if ( !iomgr->io_register (
this).isSuccess() ) {
90 ATH_MSG_ERROR (
"Could not register with the I/O component mgr !");
91 return StatusCode::FAILURE;
93 if ( !iomgr->io_register (
this,
97 <<
m_fileName <<
"] with the I/O component manager !");
98 return StatusCode::FAILURE;
104 if ( !
sc.isSuccess() )
112 if ( !
sc.isSuccess() )
121 m_attribSpec->extend( name_EventNumber,
"unsigned int" );
125 for (
unsigned int i = 0;
i < extraRefs.size(); ++
i)
128 std::string
name = extraRefs[
i] +
"_ref";
140 if (
sc.isFailure() )
148 if (
sc.isFailure() )
173 return StatusCode::SUCCESS;
192 gInterpreter->ExecuteMacro(
m_macro.c_str());
214 if (
sc.isFailure() )
220 std::map<std::string,std::string> inputRefs;
233 return StatusCode::FAILURE;
237 for (;
beg != ending; ++
beg)
243 return StatusCode::FAILURE;
253 return StatusCode::FAILURE;
263 std::vector<DataHeaderElement>::const_iterator
it =
264 (
const_cast<DataHeader*
>(hdr)->beginProvenance());
265 std::vector<DataHeaderElement>::const_iterator
itE =
266 (
const_cast<DataHeader*
>(hdr)->endProvenance());
270 std::string tmpRef = (*it).getToken() != NULL
271 ? (*it).getToken()->toString()
273 inputRefs.insert(std::make_pair(
it->getKey(),tmpRef));
275 <<
", Ref=" << tmpRef);
315 newAttr[ name_RunNumber ].setValue(
runNumber );
316 newAttr[ name_EventNumber ].setValue(
eventNumber );
323 for (; itRef != itRefE; ++itRef)
325 std::string
name = itRef->first +
"_ref";
326 if (extraRefs.end() !=
std::find(extraRefs.begin(),extraRefs.end(),itRef->first))
328 newAttr[
name].setValue(std::string(itRef->second));
329 ATH_MSG_DEBUG (
" Added extra ref to new attribute list - name: "
330 <<
name <<
" " << itRef->second);
347 (
"Caught exception from collection add of Pool attributes. "
348 "Message: " <<
e.what());
349 return StatusCode::FAILURE;
355 return StatusCode::SUCCESS;
362 TDirectory::TContext
save;
367 for( coral::AttributeListSpecification::const_iterator iter =
m_attribSpec->begin();
369 all.m_layout.push_back( make_pair( iter->name(), iter->typeName() ) );
372 all.Write(c_attributeListLayoutName);
378 static const std::map<std::string,char> typeDict = {
380 {
"long double",
'D'},
383 {
"unsigned int",
'I'},
385 {
"unsigned long",
'I'},
387 {
"unsigned short",
'S'},
389 {
"unsigned char",
'B'},
396 TDirectory::TContext
save;
403 for(coral::AttributeListSpecification::const_iterator iter=
m_attribSpec->begin(); iter!=
m_attribSpec->end(); ++iter)
405 std::string
type =
"/?";
406 type[1] = typeDict.at(iter->typeName());
407 std::string leaflist = iter->name() +
type;
408 m_tree->Branch(iter->name().c_str(),0,leaflist.c_str());
412 std::string leaflist = c_tokenBranchName;
414 m_tree->Branch(c_tokenBranchName,0,leaflist.c_str());
431 return(StatusCode::FAILURE);
441 return(StatusCode::FAILURE);
445 IOpaqueAddress* addr = itemProxy->
address();
449 << itemProxy->
clID() <<
" " << itemProxy->
name());
450 return( StatusCode::FAILURE);
461 (
"Could not get string from IOpaqueAddress for clid " <<
id
463 <<
" is BAD_STORAGE_TYPE: "<< (
sc == IConversionSvc::Status::BAD_STORAGE_TYPE));
464 return( StatusCode::FAILURE);
474 ATH_MSG_ERROR (
"Could not get split off token. string address " << saddr);
475 return( StatusCode::FAILURE);
480 return StatusCode::SUCCESS;
487 const std::string&
match,
488 std::string& address_header,
489 std::string& address_data )
const
493 <<
" match : " <<
match);
495 std::string::size_type p1;
498 if (p1 != std::string::npos)
506 return StatusCode::FAILURE;
511 <<
" address_data : " << address_data);
513 return StatusCode::SUCCESS;
521 coral::AttributeList::const_iterator attIter = attributeList.begin();
523 std::vector<std::string> tokenStringDump;
525 for (
unsigned int i=0;
i<attributeList.size(); ++
i)
529 if (attIter->specification().type() ==
typeid(std::string))
531 const std::string&
str = attIter->data<std::string>();
534 throw std::runtime_error(
"String is too long : RootCollection::pool2Root<std::string>");
536 branch->SetAddress( (
void*)
str.c_str() );
539 else if(attIter->specification().typeName() ==
"Token")
541 tokenStringDump.push_back( attIter->data<std::string>() );
542 branch->SetAddress( (
void*) tokenStringDump.back().c_str() );
547 branch->SetAddress( (
void*)attIter->addressOfData() );
571 std::vector<std::string>::const_iterator
it;
572 std::vector<std::string>::const_iterator itend =
m_membersNames.end( );
582 std::string theType = foo.type();
583 std::string theName = foo.name();
587 sc = createSubAlgorithm( theType,theName, algo );
591 return StatusCode::FAILURE;
606 const EventContext& ctx = Gaudi::Hive::currentContext();
613 if (! (*(this->subAlgorithms()))[
i]->isEnabled()) continue ;
615 sc = (*(this->subAlgorithms()))[
i]->execute(ctx);
620 return StatusCode::FAILURE;
634 return StatusCode::SUCCESS;
653 ServiceHandle<IAlgManager> theAlgMgr(
"ApplicationMgr", this->
name());
656 return StatusCode::FAILURE;
661 std::vector<std::string>::const_iterator
it;
662 std::vector<std::string>::const_iterator itend =
m_acceptNames.end();
672 return StatusCode::FAILURE;
678 return StatusCode::FAILURE;
684 return StatusCode::SUCCESS;
698 const EventContext& ctx = Gaudi::Hive::currentContext();
701 std::vector<Algorithm*>::const_iterator
it;
702 std::vector<Algorithm*>::const_iterator itend =
m_acceptAlgs.end();
706 if ( theAlgorithm->execState(ctx).state() == AlgExecState::State::Done &&
707 ( ! theAlgorithm->execState(ctx).filterPassed() ) )
728 if (
sc.isFailure() )
736 if (
sc.isFailure() )
752 if ( !iomgr.retrieve().isSuccess() ) {
753 ATH_MSG_ERROR (
"Could not retrieve IIoComponentMgr/IoComponentMgr !");
754 return StatusCode::FAILURE;
758 if ( !josvc.retrieve().isSuccess() ) {
759 ATH_MSG_ERROR (
"Could not retrieve IOptionsSvc/JobOptionsSvc !");
760 return StatusCode::FAILURE;
764 if ( !iomgr->io_hasitem (
this) ) {
765 ATH_MSG_ERROR (
"I/O component mgr does not know about ourselves !");
766 return StatusCode::FAILURE;
770 if ( !iomgr->io_contains (
this,
m_fileName) ) {
772 (
"I/O component mgr does not have any entry about ["<<
m_fileName<<
"]");
773 return StatusCode::SUCCESS;
776 if ( !iomgr->io_retrieve (
this,
m_fileName).isSuccess() ) {
778 return StatusCode::FAILURE;
782 std::vector<std::string> outvec = {
"AANT DATAFILE='" +
m_fileName +
"' OPT='RECREATE'"};
792 return StatusCode::SUCCESS;