| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Private Attributes | List of all members
CollectionCloneAlg Class Reference

Small algorithm, which allows to merge N-tuples in a generic way. More...

Inheritance diagram for CollectionCloneAlg:
[legend]
Collaboration diagram for CollectionCloneAlg:
[legend]

## Public Member Functions
StatusCode | initialize () override
| Initialize. More...
StatusCode | finalize () override
| Finalize. More...
StatusCode | execute () override
| Execute procedure. More...
virtual StatusCode | book (const NTuple::Tuple *nt)
| Book the N-tuple according to the specification. More...
virtual StatusCode | checkInput (const NTuple::Tuple *clone, const NTuple::Tuple *src)
StatusCode | mergeEntries (const std::string &input)
| Merge the entries of a single input tuple into the output. More...
StatusCode | connect ()
| Connect input and output N-tuples. More...
StatusCode | mergeInputTuples ()
| Merge all N-tuple entries. More...
Public Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
| LegacyAlgorithmAdapter (const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
const EventContext & | getContext () const
bool | isExecuted () const
| Has this algorithm been executed since the last reset? More...
void | setExecuted (bool state) const
| Set the executed flag to the specified state. More...
void | resetExecuted ()
| Reset the executed state of the Algorithm for the duration of the current event. More...
bool | filterPassed () const
| Did this algorithm pass or fail its filter criterion for the last event? More...
void | setFilterPassed (bool state) const
| Set the filter passed flag to the specified state. More...
Public Member Functions inherited from Gaudi::Algorithm
| Algorithm (const std::string &name, ISvcLocator *svcloc, const std::string &version=PACKAGE_VERSION)
| Constructor. More...
StatusCode | sysStart () override
| Reinitialization method invoked by the framework. More...
StatusCode | sysInitialize () override
| Initialization method invoked by the framework. More...
StatusCode | sysReinitialize () override
| Reinitialization method invoked by the framework. More...
StatusCode | sysRestart () override
| Restart method invoked by the framework. More...
StatusCode | sysExecute (const EventContext &ctx) override
| The actions to be performed by the algorithm on an event. More...
StatusCode | sysStop () override
| System stop. More...
StatusCode | sysFinalize () override
| System finalization. More...
StatusCode | sysBeginRun () override
| beginRun method invoked by the framework. More...
StatusCode | sysEndRun () override
| endRun method invoked by the framework. More...
const std::string & | name () const override
| The identifying name of the algorithm object. More...
const Gaudi::StringKey & | nameKey () const override
const std::string & | type () const override
| The type of the algorithm object. More...
void | setType (const std::string &type) override
const std::string & | version () const override
unsigned int | index () const override
StatusCode | configure () override
| Dummy implementation of IStateful::configure() method. More...
StatusCode | terminate () override
| Dummy implementation of IStateful::terminate() method. More...
StatusCode | initialize () override
| the default (empty) implementation of IStateful::initialize() method More...
StatusCode | start () override
| the default (empty) implementation of IStateful::start() method More...
StatusCode | stop () override
| the default (empty) implementation of IStateful::stop() method More...
StatusCode | finalize () override
| the default (empty) implementation of IStateful::finalize() method More...
StatusCode | reinitialize () override
| the default (empty) implementation of IStateful::reinitialize() method More...
StatusCode | restart () override
| the default (empty) implementation of IStateful::restart() method More...
Gaudi::StateMachine::State | FSMState () const override
| returns the current state of the algorithm More...
Gaudi::StateMachine::State | targetFSMState () const override
| returns the state the algorithm will be in after the ongoing transition More...
StatusCode | beginRun () override
| Algorithm begin run. More...
StatusCode | endRun () override
| Algorithm end run. This method is called at the end of the event loop. More...
bool | isEnabled () const override
| Is this algorithm enabled or disabled? More...
bool | isSequence () const override
| Are we a Sequence? More...
unsigned int | errorCount () const
| Get the number of failures of the algorithm. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
SmartIF< IService > | service (const std::string &name, const bool createIf=true, const bool quiet=false) const
| Return a pointer to the service identified by name (or "type/name") More...
template<class T >
SmartIF< T > | service (const std::string &name, bool createIf=true, bool quiet=false) const
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
SmartIF< IChronoStatSvc > & | chronoSvc () const
| The standard Chrono & Stat service, Return a pointer to the service if present. More...
SmartIF< IChronoStatSvc > & | chronoStatService () const
SmartIF< IDataProviderSvc > & | detSvc () const
| The standard detector data service. More...
SmartIF< IDataProviderSvc > & | detDataService () const
SmartIF< IConversionSvc > & | detCnvSvc () const
| The standard detector data persistency conversion service. More...
SmartIF< IConversionSvc > & | detDataCnvService () const
SmartIF< IDataProviderSvc > & | eventSvc () const
| The standard event data service. More...
SmartIF< IDataProviderSvc > & | evtSvc () const
| shortcut for method eventSvc More...
SmartIF< IDataProviderSvc > & | eventDataService () const
SmartIF< IConversionSvc > & | eventCnvSvc () const
| The standard event data persistency conversion service. More...
SmartIF< IConversionSvc > & | eventDataCnvService () const
SmartIF< IHistogramSvc > & | histoSvc () const
| The standard histogram service. More...
SmartIF< IHistogramSvc > & | histogramDataService () const
SmartIF< INTupleSvc > & | ntupleSvc () const
| The standard N tuple service. More...
SmartIF< INTupleSvc > & | ntupleService () const
SmartIF< IRndmGenSvc > & | randSvc () const
| The standard RandomGen service, Return a pointer to the service if present. More...
SmartIF< IToolSvc > & | toolSvc () const
| The standard ToolSvc service, Return a pointer to the service if present. More...
SmartIF< IExceptionSvc > & | exceptionSvc () const
| Get the exception Service. More...
SmartIF< IAlgContextSvc > & | contextSvc () const
| get Algorithm Context Service More...
SmartIF< ITimelineSvc > & | timelineSvc () const
SmartIF< ISvcLocator > & | serviceLocator () const override
| The standard service locator. More...
SmartIF< ISvcLocator > & | svcLoc () const
| shortcut for method serviceLocator More...
SmartIF< IHiveWhiteBoard > & | whiteboard () const
SmartIF< IAlgExecStateSvc > & | algExecStateSvc () const
bool | registerContext () const
| register for Algorithm Context Service? More...
StatusCode | setProperties ()
| Set the algorithm's properties. More...
template<class T >
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
template<class T >
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
SmartIF< IMonitorSvc > & | monitorSvc () const
| Access the monitor service. More...
template<class T >
void | declareInfo (const std::string &name, const T &var, const std::string &desc) const
| Declare monitoring information. More...
void | declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const
| Declare monitoring information (special case) More...
void | acceptDHVisitor (IDataHandleVisitor *) const override
void | registerTool (IAlgTool *tool) const
void | deregisterTool (IAlgTool *tool) const
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, bool createIf=true)
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
template<class T >
void | addToolsArray (ToolHandleArray< T > &hndlArr)
const std::vector< IAlgTool * > & | tools () const
bool | isIOBound () const
void | setIOBound (bool value)
unsigned int | cardinality () const override
| Return the cardinality. More...
const std::vector< std::string > & | neededResources () const override
AlgExecState & | execState (const EventContext &ctx) const override
| reference to AlgExecState of Alg More...
std::ostream & | toControlFlowExpression (std::ostream &os) const override
| Produce string represention of the control flow expression. More...
Public Member Functions inherited from DataHandleHolderBase< CounterHolder< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > > >
std::vector< Gaudi::DataHandle * > | inputHandles () const override
std::vector< Gaudi::DataHandle * > | outputHandles () const override
virtual const DataObjIDColl & | extraInputDeps () const override
virtual const DataObjIDColl & | extraOutputDeps () const override
void | declare (Gaudi::DataHandle &handle) override
void | renounce (Gaudi::DataHandle &handle) override
const DataObjIDColl & | inputDataObjs () const override
const DataObjIDColl & | outputDataObjs () const override
void | addDependency (const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
Public Member Functions inherited from extends< CounterHolder< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >, IDataHandleHolder >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
Public Member Functions inherited from CounterHolder< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >
void | declareCounter (const std::string &tag, Gaudi::Accumulators::PrintableCounter &r)
const Gaudi::Accumulators::PrintableCounter * | findCounter (const std::string &tag) const
void | forEachCounter (Callable &&f) const
int | nCounters () const
std::size_t | nOfCountersToBePrinted ()
void | clearCounters ()
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
| PropertyHolder ()=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Public Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level | msgLevel () const
| get the cached level (originally extracted from the embedded MsgStream) More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const
| Backward compatibility function for getting the output level. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...

## Private Attributes
Gaudi::Property< std::string > | m_tupleSvc {this, "EvtTupleSvc", "EvtTupleSvc", "name of the data provider service"}
Gaudi::Property< std::vector< std::string > > | m_inputs {this, "Input", {}, "input specifications"}
Gaudi::Property< std::string > | m_output {this, "Output", {}, "output specification"}
SmartIF< INTupleSvc > | m_dataSvc
| Reference to data provider service. More...
std::string | m_rootName
| Name of the root leaf (obtained at initialize) More...
std::string | m_outName
| Output tuple name. More...
std::string | m_criteria
| Selection criteria (if any) More...
std::string | m_selectorName
| Selector factory. More...

## Additional Inherited Members
Public Types inherited from Gaudi::Algorithm
typedef Gaudi::PluginService::Factory< IAlgorithm *(const std::string &, ISvcLocator *)> | Factory
Public Types inherited from extends< CounterHolder< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > >, IDataHandleHolder >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...
Public Attributes inherited from Gaudi::Algorithm
friend | AlgorithmManager
Protected Member Functions inherited from Gaudi::details::LegacyAlgorithmAdapter
bool | isReEntrant () const override
Protected Member Functions inherited from Gaudi::Algorithm
std::vector< IAlgTool * > & | tools ()
bool | isInitialized () const override
| Has the Algorithm already been initialized? More...
bool | isFinalized () const override
| Has the Algorithm already been finalized? More...
void | setIndex (const unsigned int &idx) override
| set instantiation index of Alg More...
bool | isReEntrant () const override
Protected Member Functions inherited from DataHandleHolderBase< CounterHolder< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > > >
void | initDataHandleHolder ()
| initializes all handles - called by the sysInitialize method of any descendant of this More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > >
MSG::Level | setUpMessaging () const
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Gaudi::Algorithm
std::unique_ptr< IDataHandleVisitor > | m_updateDataHandles
| Hook for for derived classes to provide a custom visitor for data handles. More...
Protected Attributes inherited from DataHandleHolderBase< CounterHolder< PropertyHolder< CommonMessaging< implements< IAlgorithm, IDataHandleHolder, IProperty, IStateful > > > > >
DataObjIDColl | m_inputDataObjs
DataObjIDColl | m_outputDataObjs

## Detailed Description

Small algorithm, which allows to merge N-tuples in a generic way.

In the options directory an python interface is presented, which shows how to steer this algorithm in a standaqlone program.

Author
  : M.Frank

Version
  : 1.0

Definition at line 112 of file CollectionCloneAlg.cpp.

## Member Function Documentation

## ◆ book()

virtual StatusCode CollectionCloneAlg::book | ( | const NTuple::Tuple * | nt | ) |
| inline virtual

Book the N-tuple according to the specification.

Definition at line 186 of file CollectionCloneAlg.cpp.

186 {
187 MsgStream log( msgSvc(), name() );
188 StatusCode status = StatusCode::SUCCESS;
189 NTuple::Tuple* tuple = m_dataSvc->book( m_outName, nt->clID(), nt->title() );
190 for ( const auto& i : nt->items() ) {
191 switch ( i->type() ) {
192 case DataTypeInfo::UCHAR:
193 status = createItem<unsigned char>( log, tuple, i, 0 );
194 break;
195 case DataTypeInfo::USHORT:
196 status = createItem<unsigned short>( log, tuple, i, 0 );
197 break;
198 case DataTypeInfo::UINT:
199 status = createItem<unsigned int>( log, tuple, i, 0 );
200 break;
201 case DataTypeInfo::ULONG:
202 status = createItem<unsigned long>( log, tuple, i, 0 );
203 break;
204 case DataTypeInfo::CHAR:
205 status = createItem<char>( log, tuple, i, 0 );
206 break;
207 case DataTypeInfo::SHORT:
208 status = createItem<short>( log, tuple, i, 0 );
209 break;
210 case DataTypeInfo::INT:
211 status = createItem<int>( log, tuple, i, 0 );
212 break;
213 case DataTypeInfo::LONG:
214 status = createItem<long>( log, tuple, i, 0 );
215 break;
216 case DataTypeInfo::BOOL:
217 status = createItem( log, tuple, i, false );
218 break;
219 case DataTypeInfo::FLOAT:
220 status = createItem<float>( log, tuple, i, 0 );
221 break;
222 case DataTypeInfo::DOUBLE:
223 status = createItem<double>( log, tuple, i, 0 );
224 break;
225 case DataTypeInfo::OBJECT_ADDR:
226 status = createItem<IOpaqueAddress*>( log, tuple, i, nullptr );
227 break;
228 case DataTypeInfo::POINTER:
229 status = createItem<void*>( log, tuple, i, nullptr );
230 break;
231 case DataTypeInfo::STRING:
232 // status = createItem(log, tuple, i, (std::string*)0);
233 // break;
234 case DataTypeInfo::NTCHAR:
235 // status = createItem(log, tuple, i, (char*)0);
236 // break;
237 case DataTypeInfo::UNKNOWN:
238 default:
239 status = StatusCode::FAILURE;
240 break;
241 }
242 }
243 return status;
244 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
DataTypeInfo::POINTER
Definition: DataTypeInfo.h:40
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
DataTypeInfo::INT
Definition: DataTypeInfo.h:31
DataTypeInfo::CHAR
Definition: DataTypeInfo.h:29
INTuple::title
virtual const std::string & title() const =0
Object title.
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
DataTypeInfo::STRING
Definition: DataTypeInfo.h:36
DataTypeInfo::SHORT
Definition: DataTypeInfo.h:30
DataTypeInfo::NTCHAR
Definition: DataTypeInfo.h:37
CollectionCloneAlg::m_dataSvc
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
Definition: CollectionCloneAlg.cpp:119
DataTypeInfo::UINT
Definition: DataTypeInfo.h:27
DataTypeInfo::USHORT
Definition: DataTypeInfo.h:26
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
CollectionCloneAlg::m_outName
std::string m_outName
Output tuple name.
Definition: CollectionCloneAlg.cpp:123
DataTypeInfo::BOOL
Definition: DataTypeInfo.h:33
DataTypeInfo::UCHAR
Definition: DataTypeInfo.h:25
DataTypeInfo::ULONG
Definition: DataTypeInfo.h:28
DataTypeInfo::LONG
Definition: DataTypeInfo.h:32
DataTypeInfo::DOUBLE
Definition: DataTypeInfo.h:35
DataTypeInfo::UNKNOWN
Definition: DataTypeInfo.h:24
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:375
DataTypeInfo::OBJECT_ADDR
Definition: DataTypeInfo.h:41
DataObject::clID
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:56
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
INTuple::items
virtual ItemContainer & items()=0
Access item container.
DataTypeInfo::FLOAT
Definition: DataTypeInfo.h:34
INTupleSvc::book
virtual NTuple::Tuple * book(const std::string &fullPath, const CLID &type, const std::string &title)=0
Book Ntuple and register it with the data store.
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## ◆ checkInput()

virtual StatusCode CollectionCloneAlg::checkInput | ( | const NTuple::Tuple * | clone,
|  | const NTuple::Tuple * | src
| ) |  |
| inline virtual

Definition at line 247 of file CollectionCloneAlg.cpp.

247 {
248 MsgStream log( msgSvc(), name() );
249 if ( clone && src ) {
250 const INTuple::ItemContainer& clone_items = clone->items();
251 const std::string clone_id = clone->registry()->identifier();
252 const std::string src_id = src->registry()->identifier();
253
254 log << MSG::ERROR;
255 for ( auto i = clone_items.begin(); i != clone_items.end(); ++i ) {
256 const INTupleItem* itm = *i;
257 const std::string& nam = itm->name();
258 const INTupleItem* src_itm = src->find( nam );
259 if ( !src_itm ) {
260 log << "Tuple item " << nam << " not present in " << src_id << endmsg;
261 return StatusCode::FAILURE;
262 }
263 if ( itm->type() != src_itm->type() ) {
264 log << "Tuple item " << nam << " are of different types in " << src_id << ":" << src_itm->typeName()
265 << " <-> " << clone_id << ":" << itm->typeName() << endmsg;
266 return StatusCode::FAILURE;
267 }
268 if ( itm->ndim() != src_itm->ndim() ) {
269 log << "Tuple item " << nam << " have different dimensions in " << src_id << ":" << src_itm->ndim() << " <-> "
270 << clone_id << ":" << itm->ndim() << endmsg;
271 return StatusCode::FAILURE;
272 }
273 for ( int j = 0; j < itm->ndim(); ++j ) {
274 if ( src_itm->dim( j ) != itm->dim( j ) ) {
275 log << "Tuple item " << nam << " have different dimensions in " << src_id << "[" << j
276 << "]:" << src_itm->dim( j ) << " <-> " << clone_id << "[" << j << "]:" << itm->dim( j ) << endmsg;
277 return StatusCode::FAILURE;
278 }
279 }
280 if ( itm->hasIndex() != src_itm->hasIndex() ) {
281 log << "Tuple item " << nam << " has different index colums " << src_id << ":" << src_itm->hasIndex()
282 << " <-> " << clone_id << ":" << itm->hasIndex() << endmsg;
283 return StatusCode::FAILURE;
284 }
285 if ( itm->hasIndex() ) {
286 if ( itm->index() != src_itm->index() ) {
287 log << "Tuple item " << nam << " has different index colums " << src_id << ":" << src_itm->index()
288 << " <-> " << clone_id << ":" << itm->index() << endmsg;
289 return StatusCode::FAILURE;
290 }
291 }
292 }
293 return StatusCode::SUCCESS;
294 }
295 return StatusCode::FAILURE;
296 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
DataObject::registry
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:72
INTupleItem::type
virtual long type() const =0
Type information of the item.
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::vector::end
T end(T... args)
INTupleItem::hasIndex
virtual bool hasIndex() const =0
Is the tuple have an index item?
INTupleItem::name
virtual const std::string & name() const =0
Access _Item name.
std::string
STL class.
INTupleItem
NTuple interface class definition.
Definition: INTuple.h:27
INTupleItem::dim
virtual long dim(long i) const =0
Access individual dimensions.
std::vector
STL class.
std::vector::begin
T begin(T... args)
INTupleItem::ndim
virtual long ndim() const =0
Dimension.
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
IRegistry::identifier
virtual const id_type & identifier() const =0
Full identifier (or key)
INTuple::items
virtual ItemContainer & items()=0
Access item container.
INTupleItem::typeName
virtual std::string typeName() const =0
Proper type name of the object.
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
INTuple::find
virtual const INTupleItem * find(const std::string &name) const =0
Find an item row of the Ntuple (CONST)
INTupleItem::index
virtual const std::string & index() const =0
Access the index _Item.
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## ◆ connect()

StatusCode CollectionCloneAlg::connect | ( |  | ) |
| inline

Connect input and output N-tuples.

Definition at line 402 of file CollectionCloneAlg.cpp.

402 {
403 StatusCode status = StatusCode::SUCCESS;
404 for ( size_t i = 0; i < m_inputs.size(); ++i ) {
405 NTuplePtr nt( m_dataSvc.get(), m_inputs[i] );
406 if ( !( 0 == nt ) ) {
407 NTuplePtr out( m_dataSvc.get(), m_outName );
408 if ( 0 == out ) {
409 status = book( nt );
410 } else {
411 status = checkInput( out, nt );
412 }
413 if ( !status.isSuccess() ) {
414 return status;
415 } else if ( m_selectorName != "" ) {
416 SmartIF<ISelectStatement> stmt( ObjFactory::create( m_selectorName, serviceLocator() ).release() );
417 if ( stmt ) {
418 if ( !m_criteria.empty() ) stmt->setCriteria( m_criteria );
419 nt->attachSelector( stmt );
420 } else {
421 MsgStream log( msgSvc(), name() );
422 log << MSG::ERROR << "Failed to attach tuple selector to " << m_inputs[i] << endmsg;
423 return StatusCode::FAILURE;
424 }
425 }
426 } else {
427 MsgStream log( msgSvc(), name() );
428 log << MSG::ERROR << "Failed to access tuple: " << m_inputs[i] << endmsg;
429 return StatusCode::FAILURE;
430 }
431 }
432 return StatusCode::SUCCESS;
433 }
CollectionCloneAlg::m_criteria
std::string m_criteria
Selection criteria (if any)
Definition: CollectionCloneAlg.cpp:125
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
SmartIF< ISelectStatement >
std::string::empty
T empty(T... args)
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
CollectionCloneAlg::book
virtual StatusCode book(const NTuple::Tuple *nt)
Book the N-tuple according to the specification.
Definition: CollectionCloneAlg.cpp:186
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi::Algorithm::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
The standard service locator.
Definition: Algorithm.cpp:689
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
CollectionCloneAlg::m_inputs
Gaudi::Property< std::vector< std::string > > m_inputs
Definition: CollectionCloneAlg.cpp:115
CollectionCloneAlg::m_dataSvc
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
Definition: CollectionCloneAlg.cpp:119
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
CollectionCloneAlg::m_outName
std::string m_outName
Output tuple name.
Definition: CollectionCloneAlg.cpp:123
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
CollectionCloneAlg::checkInput
virtual StatusCode checkInput(const NTuple::Tuple *clone, const NTuple::Tuple *src)
Definition: CollectionCloneAlg.cpp:247
SmartDataPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:47
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
CollectionCloneAlg::m_selectorName
std::string m_selectorName
Selector factory.
Definition: CollectionCloneAlg.cpp:127
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## ◆ execute()

StatusCode CollectionCloneAlg::execute | ( |  | ) |
| inline override virtual

Execute procedure.

Implements Algorithm.

Definition at line 180 of file CollectionCloneAlg.cpp.

180 {
181 StatusCode status = connect();
182 return status.isSuccess() ? mergeInputTuples() : status;
183 }
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
CollectionCloneAlg::mergeInputTuples
StatusCode mergeInputTuples()
Merge all N-tuple entries.
Definition: CollectionCloneAlg.cpp:436
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
CollectionCloneAlg::connect
StatusCode connect()
Connect input and output N-tuples.
Definition: CollectionCloneAlg.cpp:402

## ◆ finalize()

StatusCode CollectionCloneAlg::finalize | ( |  | ) |
| inline override

Finalize.

Definition at line 174 of file CollectionCloneAlg.cpp.

174 {
175 m_dataSvc.reset();
176 return StatusCode::SUCCESS;
177 }
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
CollectionCloneAlg::m_dataSvc
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
Definition: CollectionCloneAlg.cpp:119
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:86

## ◆ initialize()

StatusCode CollectionCloneAlg::initialize | ( |  | ) |
| inline override

Initialize.

Definition at line 134 of file CollectionCloneAlg.cpp.

134 {
135 MsgStream log( msgSvc(), name() );
136 m_rootName = "";
137 m_outName = "";
138 m_criteria = "";
139 m_selectorName = "";
140 m_dataSvc = service( m_tupleSvc, true );
141 if ( !m_dataSvc ) {
142 log << MSG::ERROR << "Failed to access service \"" << m_tupleSvc << "\"." << endmsg;
143 return StatusCode::FAILURE;
144 }
145 std::string fun;
146 using Parser = Gaudi::Utils::AttribStringParser;
147 for ( auto attrib : Parser( m_output ) ) {
148 switch ( ::toupper( attrib.tag[0] ) ) {
149 case 'D':
150 m_outName = std::move( attrib.value );
151 break;
152 case 'S':
153 m_criteria = std::move( attrib.value );
154 break;
155 case 'F':
156 fun = std::move( attrib.value );
157 break;
158 default:
159 break;
160 }
161 }
162 if ( m_outName.empty() ) {
163 log << MSG::ERROR << "Failed to analyze output specs:" << m_output << endmsg;
164 return StatusCode::FAILURE;
165 }
166 if ( !fun.empty() || !m_criteria.empty() ) {
167 if ( !m_criteria.empty() && fun.empty() ) fun = "NTuple::Selector";
168 m_selectorName = fun;
169 }
170 return StatusCode::SUCCESS;
171 }
Gaudi::Utils::AttribStringParser
Parse attribute strings allowing iteration over the various attributes.
Definition: AttribStringParser.h:30
CollectionCloneAlg::m_criteria
std::string m_criteria
Selection criteria (if any)
Definition: CollectionCloneAlg.cpp:125
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
std::string::empty
T empty(T... args)
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
CollectionCloneAlg::m_dataSvc
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
Definition: CollectionCloneAlg.cpp:119
std::string
STL class.
Gaudi::Algorithm::service
StatusCode service(const std::string &name, T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Algorithm.h:215
CollectionCloneAlg::m_outName
std::string m_outName
Output tuple name.
Definition: CollectionCloneAlg.cpp:123
std::move
T move(T... args)
CollectionCloneAlg::m_rootName
std::string m_rootName
Name of the root leaf (obtained at initialize)
Definition: CollectionCloneAlg.cpp:121
CollectionCloneAlg::m_output
Gaudi::Property< std::string > m_output
Definition: CollectionCloneAlg.cpp:116
CollectionCloneAlg::m_tupleSvc
Gaudi::Property< std::string > m_tupleSvc
Definition: CollectionCloneAlg.cpp:114
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
CollectionCloneAlg::m_selectorName
std::string m_selectorName
Selector factory.
Definition: CollectionCloneAlg.cpp:127
toupper
void toupper(std::string &s)
Definition: StatusCodeSvc.cpp:7
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## ◆ mergeEntries()

StatusCode CollectionCloneAlg::mergeEntries | ( | const std::string & | input | ) |
| inline

Merge the entries of a single input tuple into the output.

Definition at line 299 of file CollectionCloneAlg.cpp.

299 {
300 MsgStream log( msgSvc(), name() );
301 NTuplePtr out( m_dataSvc.get(), m_outName );
302 if ( 0 != out ) {
303 const INTuple::ItemContainer& clone_items = out->items();
304 std::vector<GenericAddress> addrVector( clone_items.size() );
305 StatusCode status = StatusCode::SUCCESS;
306 NTuplePtr nt( m_dataSvc.get(), input );
307 size_t k = 0, nentry = 0;
308 if ( 0 != nt ) {
309 const INTuple::ItemContainer& source_items = nt->items();
310 for ( k = 0; k < source_items.size(); ++k ) {
311 if ( source_items[k]->type() == DataTypeInfo::OBJECT_ADDR ) {
312 *(IOpaqueAddress**)source_items[k]->buffer() = &addrVector[k];
313 }
314 }
315 while ( status.isSuccess() ) {
316 status = m_dataSvc->readRecord( nt.ptr() );
317 if ( status.isSuccess() ) {
318 INTuple::ItemContainer::const_iterator i;
319 nentry++;
320 for ( k = 0, i = source_items.begin(); i != source_items.end(); ++i, ++k ) {
321 const INTupleItem* src_itm = *i;
322 const INTupleItem* out_itm = out->find( src_itm->name() );
323 size_t size = 0;
324 switch ( ( *i )->type() ) {
325 case DataTypeInfo::UCHAR:
326 size = sizeof( unsigned char );
327 break;
328 case DataTypeInfo::USHORT:
329 size = sizeof( unsigned short );
330 break;
331 case DataTypeInfo::UINT:
332 size = sizeof( unsigned int );
333 break;
334 case DataTypeInfo::ULONG:
335 size = sizeof( unsigned long );
336 break;
337 case DataTypeInfo::CHAR:
338 size = sizeof( char );
339 break;
340 case DataTypeInfo::SHORT:
341 size = sizeof( short );
342 break;
343 case DataTypeInfo::INT:
344 size = sizeof( int );
345 break;
346 case DataTypeInfo::LONG:
347 size = sizeof( long );
348 break;
349 case DataTypeInfo::BOOL:
350 size = sizeof( bool );
351 break;
352 case DataTypeInfo::FLOAT:
353 size = sizeof( float );
354 break;
355 case DataTypeInfo::DOUBLE:
356 size = sizeof( double );
357 break;
358 case DataTypeInfo::STRING:
359 *(std::string*)out_itm->buffer() = *(std::string*)src_itm->buffer();
360 size = 0;
361 break;
362 case DataTypeInfo::NTCHAR:
363 size = ::strlen( (const char*)src_itm->buffer() ) + 1;
364 break;
365 case DataTypeInfo::POINTER: {
366 *(void**)out_itm->buffer() = *(void**)src_itm->buffer();
367 size = 0;
368 } break;
369 case DataTypeInfo::OBJECT_ADDR: {
370 IOpaqueAddress* ppA1 = &addrVector[k];
371 IOpaqueAddress** ppA2 = (IOpaqueAddress**)( out_itm->buffer() );
372 *ppA2 = ppA1;
373 size = 0;
374 } break;
375 case DataTypeInfo::UNKNOWN:
376 default:
377 size = 0;
378 break;
379 }
380 if ( size > 0 ) {
381 ::memcpy( const_cast<void*>( out_itm->buffer() ), src_itm->buffer(), size * src_itm->length() );
382 }
383 }
384 status = m_dataSvc->writeRecord( out.ptr() );
385 if ( !status.isSuccess() ) {
386 log << MSG::ERROR << "Failed to write record " << nentry << " from " << input << " to " << m_outName
387 << endmsg;
388 }
389 }
390 }
391 log << MSG::INFO << "End of reading tuple " << input << " after " << nentry << " entries." << endmsg;
392
393 if ( nentry > 0 || m_selectorName != "" ) { return StatusCode::SUCCESS; }
394 return StatusCode::FAILURE;
395 }
396 log << MSG::ERROR << "Failed to access input: " << input << endmsg;
397 }
398 return StatusCode::FAILURE;
399 }
details::size
constexpr auto size(const T &, Args &&...) noexcept
Definition: AnyDataWrapper.h:14
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
DataTypeInfo::POINTER
Definition: DataTypeInfo.h:40
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
DataTypeInfo::INT
Definition: DataTypeInfo.h:31
DataTypeInfo::CHAR
Definition: DataTypeInfo.h:29
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::vector::end
T end(T... args)
DataTypeInfo::STRING
Definition: DataTypeInfo.h:36
DataTypeInfo::SHORT
Definition: DataTypeInfo.h:30
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
DataTypeInfo::NTCHAR
Definition: DataTypeInfo.h:37
INTupleItem::name
virtual const std::string & name() const =0
Access _Item name.
CollectionCloneAlg::m_dataSvc
SmartIF< INTupleSvc > m_dataSvc
Reference to data provider service.
Definition: CollectionCloneAlg.cpp:119
std::string
STL class.
INTupleItem
NTuple interface class definition.
Definition: INTuple.h:27
DataTypeInfo::UINT
Definition: DataTypeInfo.h:27
DataTypeInfo::USHORT
Definition: DataTypeInfo.h:26
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
INTupleSvc::writeRecord
virtual StatusCode writeRecord(NTuple::Tuple *tuple)=0
Write single record to N tuple.
Gaudi::Algorithm::type
const std::string & type() const override
The type of the algorithm object.
Definition: Algorithm.h:167
CollectionCloneAlg::m_outName
std::string m_outName
Output tuple name.
Definition: CollectionCloneAlg.cpp:123
DataTypeInfo::BOOL
Definition: DataTypeInfo.h:33
DataTypeInfo::UCHAR
Definition: DataTypeInfo.h:25
DataTypeInfo::ULONG
Definition: DataTypeInfo.h:28
DataTypeInfo::LONG
Definition: DataTypeInfo.h:32
DataTypeInfo::DOUBLE
Definition: DataTypeInfo.h:35
DataTypeInfo::UNKNOWN
Definition: DataTypeInfo.h:24
std::vector::size
T size(T... args)
DataTypeInfo::OBJECT_ADDR
Definition: DataTypeInfo.h:41
std::vector
STL class.
std::vector::begin
T begin(T... args)
INTupleSvc::readRecord
virtual StatusCode readRecord(NTuple::Tuple *tuple)=0
Read single record from N tuple.
SmartDataPtr
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:47
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
DataTypeInfo::FLOAT
Definition: DataTypeInfo.h:34
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
MSG::INFO
Definition: IMessageSvc.h:15
CollectionCloneAlg::m_selectorName
std::string m_selectorName
Selector factory.
Definition: CollectionCloneAlg.cpp:127
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645
Gaudi.Configuration.log
log
Definition: Configuration.py:13
INTupleItem::length
virtual long length() const =0
Access the buffer length.
INTupleItem::buffer
virtual const void * buffer() const =0
Access data buffer (CONST)

## ◆ mergeInputTuples()

StatusCode CollectionCloneAlg::mergeInputTuples | ( |  | ) |
| inline

Merge all N-tuple entries.

Definition at line 436 of file CollectionCloneAlg.cpp.

436 {
437 MsgStream log( msgSvc(), name() );
438 for ( const auto& input : m_inputs ) {
439 StatusCode sc = mergeEntries( input );
440 if ( !sc.isSuccess() ) {
441 log << MSG::ERROR << "Failed to merge tuple:" << input << endmsg;
442 return sc;
443 }
444 }
445 return StatusCode::SUCCESS;
446 }
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
CommonMessagingBase::msgSvc
const SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:68
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
CollectionCloneAlg::m_inputs
Gaudi::Property< std::vector< std::string > > m_inputs
Definition: CollectionCloneAlg.cpp:115
CollectionCloneAlg::mergeEntries
StatusCode mergeEntries(const std::string &input)
Merge the entries of a single input tuple into the output.
Definition: CollectionCloneAlg.cpp:299
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
MSG::ERROR
Definition: IMessageSvc.h:15
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645
Gaudi.Configuration.log
log
Definition: Configuration.py:13

## Member Data Documentation

## ◆ m_criteria

std::string CollectionCloneAlg::m_criteria
| private

Selection criteria (if any)

Definition at line 125 of file CollectionCloneAlg.cpp.

## ◆ m_dataSvc

SmartIF<INTupleSvc> CollectionCloneAlg::m_dataSvc
| private

Reference to data provider service.

Definition at line 119 of file CollectionCloneAlg.cpp.

## ◆ m_inputs

Gaudi::Property<std::vector<std::string> > CollectionCloneAlg::m_inputs {this, "Input", {}, "input specifications"}
| private

Definition at line 115 of file CollectionCloneAlg.cpp.

## ◆ m_outName

std::string CollectionCloneAlg::m_outName
| private

Output tuple name.

Definition at line 123 of file CollectionCloneAlg.cpp.

## ◆ m_output

Gaudi::Property<std::string> CollectionCloneAlg::m_output {this, "Output", {}, "output specification"}
| private

Definition at line 116 of file CollectionCloneAlg.cpp.

## ◆ m_rootName

std::string CollectionCloneAlg::m_rootName
| private

Name of the root leaf (obtained at initialize)

Definition at line 121 of file CollectionCloneAlg.cpp.

## ◆ m_selectorName

std::string CollectionCloneAlg::m_selectorName
| private

Selector factory.

Definition at line 127 of file CollectionCloneAlg.cpp.

## ◆ m_tupleSvc

Gaudi::Property<std::string> CollectionCloneAlg::m_tupleSvc {this, "EvtTupleSvc", "EvtTupleSvc", "name of the data provider service"}
| private

Definition at line 114 of file CollectionCloneAlg.cpp.

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

- GaudiSvc/src/NTupleSvc/CollectionCloneAlg.cpp