The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
EventCollectionSelector.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12
15#include <GaudiKernel/NTuple.h>
16#include <GaudiKernel/Service.h>
17
18#include <optional>
19
20class INTuple;
21class INTupleSvc;
22class IAddressCreator;
24template <class TYPE>
26
41class EventCollectionSelector : public extends<Service, IEvtSelector> {
42public:
44 public:
45 std::string criteria;
47 std::optional<NTuple::Item<IOpaqueAddress*>> item{};
49 MyContextType( MyContextType* ctxt = nullptr ) {
51 addressBuffer->addRef();
52 tuple = ( ctxt ) ? ctxt->tuple : nullptr;
53 if ( ctxt ) item.emplace( *ctxt->item );
54 }
55 MyContextType( const MyContextType& ctxt ) : IEvtSelector::Context( ctxt ) {
57 addressBuffer->addRef();
58 tuple = ctxt.tuple;
59 item.emplace( *ctxt.item );
60 }
61 ~MyContextType() override { addressBuffer->release(); }
63
64 void* identifier() const override { return (void*)addressBuffer; }
65 void setAddress( IOpaqueAddress* pAddr );
66 };
67
68protected:
72
73 // Properties
74 Gaudi::Property<std::string> m_tupleSvcName{ this, "CnvService", "EvtTupleSvc",
75 "name of the event collection service" };
76 Gaudi::Property<std::string> m_authentication{ this, "Authentication", "", "authentication string (if needed)" };
77 Gaudi::Property<std::string> m_cntName{ this, "Container", "B2PiPi", "container name" };
78 Gaudi::Property<std::string> m_itemName{ this, "Item", "Address", "item name" };
79 Gaudi::Property<std::string> m_criteria{ this, "Criteria", "", "criteria" };
80 Gaudi::Property<std::string> m_database{ this, "DB", "", "datafile name" };
81 Gaudi::Property<std::string> m_dbType{ this, "DbType", "", "database type identifier" };
82 Gaudi::Property<std::string> m_dbSvc{ this, "DbService", "", "database service (exclusive property with db type)" };
83 Gaudi::Property<std::string> m_statement{ this, "Function", "NTuple::Selector", "selector name" };
84
85public:
87 StatusCode initialize() override;
89 StatusCode finalize() override;
90
92
96 StatusCode createContext( Context*& refpCtxt ) const override;
97
99
103 StatusCode next( Context& refCtxt ) const override;
104
106
110 StatusCode next( Context& refCtxt, int jump ) const override;
111
113
118 StatusCode previous( Context& refCtxt ) const override;
119
121
126 StatusCode previous( Context& refCtxt, int jump ) const override;
127
129
133 StatusCode rewind( Context& refCtxt ) const override;
134
136
141 StatusCode createAddress( const Context& refCtxt, IOpaqueAddress*& refpAddr ) const override;
142
144
148 StatusCode releaseContext( Context*& refCtxt ) const override;
149
158 StatusCode resetCriteria( const std::string& cr, Context& c ) const override;
159
165 StatusCode last( Context& refCtxt ) const override;
166
168 virtual StatusCode connectCollection( MyContextType* ctxt ) const;
169
171 virtual StatusCode connectDataSource( const std::string& db, const std::string& typ ) const;
173 virtual StatusCode connectTuple( const std::string& nam, const std::string& itName, NTuple::Tuple*& tup,
174 std::optional<NTuple::Item<IOpaqueAddress*>>& item ) const;
176 virtual StatusCode connectStatement( const std::string& typ, const std::string& crit, INTuple* tuple ) const;
178 virtual StatusCode getNextRecord( NTuple::Tuple* tuple ) const;
180 virtual StatusCode getPreviousRecord( NTuple::Tuple* tuple ) const;
181
183 using extends::extends;
184};
void setAddress(IOpaqueAddress *pAddr)
std::optional< NTuple::Item< IOpaqueAddress * > > item
MyContextType & operator=(const MyContextType &)=delete
Definition of class EventCollectionSelector.
StatusCode rewind(Context &refCtxt) const override
Rewind the dataset.
StatusCode previous(Context &refCtxt) const override
Get previous iteration item from the event loop context.
virtual StatusCode connectCollection(MyContextType *ctxt) const
Connect collection to selector.
virtual StatusCode connectDataSource(const std::string &db, const std::string &typ) const
Connect collection's data source to selector.
StatusCode createContext(Context *&refpCtxt) const override
Create a new event loop context.
Gaudi::Property< std::string > m_authentication
StatusCode createAddress(const Context &refCtxt, IOpaqueAddress *&refpAddr) const override
Create new Opaque address corresponding to the current record.
virtual StatusCode getPreviousRecord(NTuple::Tuple *tuple) const
Read next record of the N-tuple.
SmartIF< IAddressCreator > m_pAddrCreator
StatusCode releaseContext(Context *&refCtxt) const override
Release existing event iteration context.
StatusCode last(Context &refCtxt) const override
Access last item in the iteration.
Gaudi::Property< std::string > m_database
StatusCode initialize() override
Service override: Initialize service.
virtual StatusCode connectTuple(const std::string &nam, const std::string &itName, NTuple::Tuple *&tup, std::optional< NTuple::Item< IOpaqueAddress * > > &item) const
Connect to existing N-tuple.
Gaudi::Property< std::string > m_tupleSvcName
Gaudi::Property< std::string > m_itemName
Gaudi::Property< std::string > m_dbSvc
StatusCode resetCriteria(const std::string &cr, Context &c) const override
Will set a new criteria for the selection of the next list of events and will change the state of the...
Gaudi::Property< std::string > m_cntName
virtual StatusCode getNextRecord(NTuple::Tuple *tuple) const
Read next record of the N-tuple.
SmartIF< INTupleSvc > m_tupleSvc
Reference to Tuple service.
virtual StatusCode connectStatement(const std::string &typ, const std::string &crit, INTuple *tuple) const
Connect selection statement to refine data access.
Gaudi::Property< std::string > m_dbType
Gaudi::Property< std::string > m_statement
StatusCode finalize() override
Service override: Finalize Service.
Gaudi::Property< std::string > m_criteria
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
Definition of class EventSelectorDataStream.
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
Generic Transient Address.
IAddressCreator interface definition.
The Event Selector Interface.
NTuple interface class definition.
Definition INTuple.h:86
Opaque address interface definition.
Class acting as a smart pointer holding a N tuple _Item.
Definition NTuple.h:251
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition NTuple.h:380
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
Base class used to extend a class implementing other interfaces.
Definition extends.h:19