 |
ATLAS Offline Software
|
Go to the documentation of this file.
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/TypeNameString.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)
88 if ( !iomgr->io_register (
this,
92 <<
m_fileName <<
"] with the I/O component manager !");
93 return StatusCode::FAILURE;
106 m_attribSpec->extend( name_EventNumber,
"unsigned int" );
144 return StatusCode::SUCCESS;
163 gInterpreter->ExecuteMacro(
m_macro.c_str());
185 if (
sc.isFailure() )
191 std::map<std::string,std::string> inputRefs;
204 return StatusCode::FAILURE;
208 for (;
beg != ending; ++
beg)
214 return StatusCode::FAILURE;
224 return StatusCode::FAILURE;
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());
241 std::string tmpRef = (*it).getToken() != NULL
242 ? (*it).getToken()->toString()
244 inputRefs.insert(std::make_pair(
it->getKey(),tmpRef));
246 <<
", Ref=" << tmpRef);
278 newAttr[ name_RunNumber ].setValue(
runNumber );
279 newAttr[ name_EventNumber ].setValue(
eventNumber );
286 for (; itRef != itRefE; ++itRef)
288 std::string
name = itRef->first +
"_ref";
289 if (extraRefs.end() !=
std::find(extraRefs.begin(),extraRefs.end(),itRef->first))
291 newAttr[
name].setValue(std::string(itRef->second));
292 ATH_MSG_DEBUG (
" Added extra ref to new attribute list - name: "
293 <<
name <<
" " << itRef->second);
310 (
"Caught exception from collection add of Pool attributes. "
311 "Message: " <<
e.what());
312 return StatusCode::FAILURE;
318 return StatusCode::SUCCESS;
325 TDirectory::TContext
save;
330 for( coral::AttributeListSpecification::const_iterator
iter =
m_attribSpec->begin();
332 all.m_layout.push_back( make_pair(
iter->name(),
iter->typeName() ) );
335 all.Write(c_attributeListLayoutName);
341 static const std::map<std::string,char> typeDict = {
343 {
"long double",
'D'},
346 {
"unsigned int",
'I'},
348 {
"unsigned long",
'I'},
350 {
"unsigned short",
'S'},
352 {
"unsigned char",
'B'},
359 TDirectory::TContext
save;
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());
375 std::string leaflist = c_tokenBranchName;
377 m_tree->Branch(c_tokenBranchName,0,leaflist.c_str());
394 return(StatusCode::FAILURE);
404 return(StatusCode::FAILURE);
408 IOpaqueAddress* addr = itemProxy->
address();
412 << itemProxy->
clID() <<
" " << itemProxy->
name());
413 return( StatusCode::FAILURE);
424 (
"Could not get string from IOpaqueAddress for clid " <<
id
426 <<
" is BAD_STORAGE_TYPE: "<< (
sc == IConversionSvc::Status::BAD_STORAGE_TYPE));
427 return( StatusCode::FAILURE);
437 ATH_MSG_ERROR (
"Could not get split off token. string address " << saddr);
438 return( StatusCode::FAILURE);
443 return StatusCode::SUCCESS;
450 const std::string&
match,
451 std::string& address_header,
452 std::string& address_data )
const
456 <<
" match : " <<
match);
458 std::string::size_type
p1;
461 if (
p1 != std::string::npos)
469 return StatusCode::FAILURE;
474 <<
" address_data : " << address_data);
476 return StatusCode::SUCCESS;
484 coral::AttributeList::const_iterator attIter = attributeList.begin();
486 std::vector<std::string> tokenStringDump;
488 for (
unsigned int i=0;
i<attributeList.size(); ++
i)
492 if (attIter->specification().type() ==
typeid(std::string))
494 const std::string&
str = attIter->data<std::string>();
497 throw std::runtime_error(
"String is too long : RootCollection::pool2Root<std::string>");
499 branch->SetAddress( (
void*)
str.c_str() );
502 else if(attIter->specification().typeName() ==
"Token")
504 tokenStringDump.push_back( attIter->data<std::string>() );
505 branch->SetAddress( (
void*) tokenStringDump.back().c_str() );
510 branch->SetAddress( (
void*)attIter->addressOfData() );
542 Gaudi::Utils::TypeNameString tn(
name);
546 sc = createSubAlgorithm( tn.type(), tn.name(), algo );
550 return StatusCode::FAILURE;
565 const EventContext& ctx = Gaudi::Hive::currentContext();
572 if (! (*(this->subAlgorithms()))[
i]->isEnabled()) continue ;
574 sc = (*(this->subAlgorithms()))[
i]->execute(ctx);
579 return StatusCode::FAILURE;
593 return StatusCode::SUCCESS;
601 SmartIF<IAlgorithm> ialg{theAlgMgr->algorithm(
name)};
605 return StatusCode::FAILURE;
611 return StatusCode::SUCCESS;
625 const EventContext& ctx = Gaudi::Hive::currentContext();
630 if (
alg->execState(ctx).state() == AlgExecState::State::Done &&
631 ( !
alg->execState(ctx).filterPassed() ) )
654 return StatusCode::SUCCESS;
667 if ( !iomgr->io_hasitem (
this) ) {
668 ATH_MSG_ERROR (
"I/O component mgr does not know about ourselves !");
669 return StatusCode::FAILURE;
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;
679 if ( !iomgr->io_retrieve (
this,
m_fileName).isSuccess() ) {
681 return StatusCode::FAILURE;
685 std::vector<std::string> outvec = {
"AANT DATAFILE='" +
m_fileName +
"' OPT='RECREATE'"};
695 return StatusCode::SUCCESS;
def retrieve(aClass, aKey=None)
JetConstituentVector::iterator iterator
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
AANTupleStream(const std::string &name, ISvcLocator *pSvcLocator)
Standard AANTupleStream Constructor.
virtual StatusCode finalize()
Terminate AANTupleStream.
virtual StatusCode execute()
Working entry point.
std::string find(const std::string &s)
return a remapped string
bool writeTokenAttrList(const std::string &token, const coral::AttributeList &attributeList)
write Token and AttributeList
void setupTree()
setup Tree
StatusCode getRef(CLID id, const std::string &key, std::string &ref)
Get ref from a proxy.
std::vector< IAlgorithm * > m_acceptAlgs
Vector of Algorithms that this stream accepts.
std::vector< std::string > m_membersNames
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.
ServiceHandle< IAddressCreator > m_persSvc
Persistency service.
void writeAttributeListSpecification()
write schema of AttributeList
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
TBranch * m_tokenBranch
TBranch which contains Token info.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
def save(self, fileName="./columbo.out")
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
virtual StatusCode initialize()
Initialize AANTupleStream.
virtual IOpaqueAddress * address() const override final
Retrieve IOpaqueAddress.
bool isEventAccepted() const
check filters passed
Alias for backward compatibility.
StatusCode io_reinit()
callback method to reinitialize the internal state of the component for I/O purposes (e....
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
EventID * event_ID()
the unique identification of the event.
Default, invalid implementation of ClassID_traits.
StatusCode getFilters()
get filter alogs
bool m_schemaDone
first event
std::string m_treeName
Name of the output tree.
uint32_t CLID
The Class ID type.
CLID clID() const
Retrieve clid.
std::string m_streamName
Name of Stream.
char m_tokenCString[s_maxLengthOfStrings]
coral::AttributeListSpecification * m_attribSpec
Collection attribute specification.
static const unsigned int s_maxLengthOfStrings
for string branches
StatusCode initCollection()
Initialize the output collection.
StringArrayProperty m_extraRefNames
Vector of extra parent ref names to register in collection.
This class provides general information about an event. Event information is provided by the accessor...
virtual const name_type & name() const override final
Retrieve data object key == string.
Class describing the basic event information.
BooleanProperty m_lateSchema
write schema in execute()
virtual ~AANTupleStream()
Standard Destructor.
#define ATH_MSG_WARNING(x)
const boost::regex ref(r_ef)
StatusCode execute_subAlgos()
execute sub-algos
ServiceHandle< ITHistSvc > m_tHistSvc
THistSvc.
std::vector< std::string > m_acceptNames
Vector of names of Algorithms that this stream accepts.
static void setTree(const std::string &stream, TTree *tree)
BooleanProperty m_writeInputDH
Flag to signal whether or not to write input data header.
StatusCode initialize_subAlgos()
initialize sub-algos
bool match(std::string s1, std::string s2)
match the individual directories of two strings
BooleanProperty m_existDH
Flag to signal whether data header exists.
std::string m_fileName
Name of the output collection.