Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (d98a2936)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
20 class INTuple;
21 class INTupleSvc;
22 class IAddressCreator;
24 template <class TYPE>
26 
41 class EventCollectionSelector : public extends<Service, IEvtSelector> {
42 public:
44  public:
45  std::string criteria;
47  std::optional<NTuple::Item<IOpaqueAddress*>> item{};
49  MyContextType( MyContextType* ctxt = nullptr ) {
52  tuple = ( ctxt ) ? ctxt->tuple : nullptr;
53  if ( ctxt ) item.emplace( *ctxt->item );
54  }
55  MyContextType( const MyContextType& ctxt ) : IEvtSelector::Context( ctxt ) {
58  tuple = ctxt.tuple;
59  item.emplace( *ctxt.item );
60  }
62  MyContextType& operator=( const MyContextType& ) = delete;
63 
64  void* identifier() const override { return (void*)addressBuffer; }
65  void setAddress( IOpaqueAddress* pAddr );
66  };
67 
68 protected:
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 
85 public:
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 };
EventCollectionSelector::resetCriteria
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...
Definition: EventCollectionSelector.cpp:295
EventCollectionSelector::finalize
StatusCode finalize() override
Service override: Finalize Service.
Definition: EventCollectionSelector.cpp:209
EventCollectionSelector::m_dbType
Gaudi::Property< std::string > m_dbType
Definition: EventCollectionSelector.h:81
IAddressCreator
Definition: IAddressCreator.h:33
EventCollectionSelector::connectDataSource
virtual StatusCode connectDataSource(const std::string &db, const std::string &typ) const
Connect collection's data source to selector.
Definition: EventCollectionSelector.cpp:92
EventCollectionSelector::MyContextType::criteria
std::string criteria
Definition: EventCollectionSelector.h:45
EventCollectionSelector::m_tupleSvc
SmartIF< INTupleSvc > m_tupleSvc
Reference to Tuple service.
Definition: EventCollectionSelector.h:70
IOpaqueAddress::addRef
virtual unsigned long addRef()=0
Add reference to object.
EventCollectionSelector::MyContextType::addressBuffer
IOpaqueAddress * addressBuffer
Definition: EventCollectionSelector.h:48
EventCollectionSelector::MyContextType
Definition: EventCollectionSelector.h:43
IOpaqueAddress
Definition: IOpaqueAddress.h:28
IEvtSelector
Definition: IEvtSelector.h:26
IOpaqueAddress::release
virtual unsigned long release()=0
release reference to object
EventCollectionSelector::m_database
Gaudi::Property< std::string > m_database
Definition: EventCollectionSelector.h:80
IEvtSelector.h
EventCollectionSelector::MyContextType::~MyContextType
~MyContextType() override
Definition: EventCollectionSelector.h:61
EventCollectionSelector::m_itemName
Gaudi::Property< std::string > m_itemName
Definition: EventCollectionSelector.h:78
gaudirun.c
c
Definition: gaudirun.py:525
EventCollectionSelector::MyContextType::item
std::optional< NTuple::Item< IOpaqueAddress * > > item
Definition: EventCollectionSelector.h:47
IEvtSelector::Context
Definition: IEvtSelector.h:31
EventCollectionSelector::MyContextType::tuple
NTuple::Tuple * tuple
Definition: EventCollectionSelector.h:46
EventCollectionSelector::next
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
Definition: EventCollectionSelector.cpp:230
EventCollectionSelector::createAddress
StatusCode createAddress(const Context &refCtxt, IOpaqueAddress *&refpAddr) const override
Create new Opaque address corresponding to the current record.
Definition: EventCollectionSelector.cpp:263
EventCollectionSelector::initialize
StatusCode initialize() override
Service override: Initialize service.
Definition: EventCollectionSelector.cpp:70
GenericAddress.h
GenericAddress
Definition: GenericAddress.h:27
EventCollectionSelector::rewind
StatusCode rewind(Context &refCtxt) const override
Rewind the dataset.
Definition: EventCollectionSelector.cpp:260
EventCollectionSelector::m_pAddrCreator
SmartIF< IAddressCreator > m_pAddrCreator
Definition: EventCollectionSelector.h:71
StatusCode
Definition: StatusCode.h:64
NTuple.h
EventCollectionSelector::previous
StatusCode previous(Context &refCtxt) const override
Get previous iteration item from the event loop context.
Definition: EventCollectionSelector.cpp:245
EventCollectionSelector::MyContextType::operator=
MyContextType & operator=(const MyContextType &)=delete
INTuple
Definition: INTuple.h:86
SmartIF< INTupleSvc >
EventCollectionSelector::getNextRecord
virtual StatusCode getNextRecord(NTuple::Tuple *tuple) const
Read next record of the N-tuple.
Definition: EventCollectionSelector.cpp:146
EventCollectionSelector::createContext
StatusCode createContext(Context *&refpCtxt) const override
Create a new event loop context.
Definition: EventCollectionSelector.cpp:217
EventCollectionSelector::MyContextType::setAddress
void setAddress(IOpaqueAddress *pAddr)
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:19
EventCollectionSelector::connectTuple
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.
Definition: EventCollectionSelector.cpp:110
EventCollectionSelector::connectStatement
virtual StatusCode connectStatement(const std::string &typ, const std::string &crit, INTuple *tuple) const
Connect selection statement to refine data access.
Definition: EventCollectionSelector.cpp:129
EventCollectionSelector::connectCollection
virtual StatusCode connectCollection(MyContextType *ctxt) const
Connect collection to selector.
Definition: EventCollectionSelector.cpp:190
EventCollectionSelector::MyContextType::MyContextType
MyContextType(const MyContextType &ctxt)
Definition: EventCollectionSelector.h:55
Service.h
EventIterator
Definition: EventCollectionSelector.h:25
EventCollectionSelector::getPreviousRecord
virtual StatusCode getPreviousRecord(NTuple::Tuple *tuple) const
Read next record of the N-tuple.
Definition: EventCollectionSelector.cpp:162
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:380
EventCollectionSelector::m_cntName
Gaudi::Property< std::string > m_cntName
Definition: EventCollectionSelector.h:77
EventCollectionSelector
Definition of class EventCollectionSelector.
Definition: EventCollectionSelector.h:41
EventCollectionSelector::m_dbSvc
Gaudi::Property< std::string > m_dbSvc
Definition: EventCollectionSelector.h:82
EventSelectorDataStream
Definition of class EventSelectorDataStream.
Definition: EventSelectorDataStream.h:39
EventCollectionSelector::MyContextType::MyContextType
MyContextType(MyContextType *ctxt=nullptr)
Definition: EventCollectionSelector.h:49
EventCollectionSelector::m_tupleSvcName
Gaudi::Property< std::string > m_tupleSvcName
Definition: EventCollectionSelector.h:74
INTupleSvc
Definition: INTupleSvc.h:43
EventCollectionSelector::m_criteria
Gaudi::Property< std::string > m_criteria
Definition: EventCollectionSelector.h:79
EventCollectionSelector::releaseContext
StatusCode releaseContext(Context *&refCtxt) const override
Release existing event iteration context.
Definition: EventCollectionSelector.cpp:283
EventCollectionSelector::last
StatusCode last(Context &refCtxt) const override
Access last item in the iteration.
Definition: EventCollectionSelector.cpp:305
EventCollectionSelector::MyContextType::identifier
void * identifier() const override
Definition: EventCollectionSelector.h:64
Gaudi::Property< std::string >
EventCollectionSelector::m_statement
Gaudi::Property< std::string > m_statement
Definition: EventCollectionSelector.h:83
EventCollectionSelector::m_authentication
Gaudi::Property< std::string > m_authentication
Definition: EventCollectionSelector.h:76
NTuple::Item< IOpaqueAddress * >