The Gaudi Framework  master (37c0b60a)
EventCollectionSelector.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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 //====================================================================
12 // EventCollectionSelector.h
13 //--------------------------------------------------------------------
14 //
15 // Package : EventCollectionSelector (LHCb Event Selector Package)
16 //
17 // Author : M.Frank
18 // Created : 4/10/00
19 //
20 //====================================================================
21 #ifndef GAUDISVC_EventCollectionSelector_EventCollectionSelector_H
22 #define GAUDISVC_EventCollectionSelector_EventCollectionSelector_H 1
23 
24 // Include files
27 #include <GaudiKernel/NTuple.h>
28 #include <GaudiKernel/Service.h>
29 
30 // Forward declarations
31 class INTuple;
32 class INTupleSvc;
33 class IAddressCreator;
35 template <class TYPE>
37 
52 class EventCollectionSelector : public extends<Service, IEvtSelector> {
53 public:
55  public:
63  tuple = t;
64  item = i;
65  }
66  MyContextType( MyContextType* ctxt = nullptr ) {
69  tuple = ( ctxt ) ? ctxt->tuple : nullptr;
70  item = ( ctxt ) ? ctxt->item : nullptr;
71  }
72  MyContextType( const MyContextType& ctxt ) : IEvtSelector::Context( ctxt ) {
75  tuple = ctxt.tuple;
76  item = ctxt.item;
77  }
79  MyContextType& operator=( const MyContextType& ) = delete;
80 
81  void* identifier() const override { return (void*)addressBuffer; }
82  void setAddress( IOpaqueAddress* pAddr );
83  };
84 
85 protected:
89 
90  // Properties
91  Gaudi::Property<std::string> m_tupleSvcName{ this, "CnvService", "EvtTupleSvc",
92  "name of the event collection service" };
93  Gaudi::Property<std::string> m_authentication{ this, "Authentication", "", "authentication string (if needed)" };
94  Gaudi::Property<std::string> m_cntName{ this, "Container", "B2PiPi", "container name" };
95  Gaudi::Property<std::string> m_itemName{ this, "Item", "Address", "item name" };
96  Gaudi::Property<std::string> m_criteria{ this, "Criteria", "", "criteria" };
97  Gaudi::Property<std::string> m_database{ this, "DB", "", "datafile name" };
98  Gaudi::Property<std::string> m_dbType{ this, "DbType", "", "database type identifier" };
99  Gaudi::Property<std::string> m_dbSvc{ this, "DbService", "", "database service (exclusive property with db type)" };
100  Gaudi::Property<std::string> m_statement{ this, "Function", "NTuple::Selector", "selector name" };
101 
102 public:
104  StatusCode initialize() override;
106  StatusCode finalize() override;
107 
109 
113  StatusCode createContext( Context*& refpCtxt ) const override;
114 
116 
120  StatusCode next( Context& refCtxt ) const override;
121 
123 
127  StatusCode next( Context& refCtxt, int jump ) const override;
128 
130 
135  StatusCode previous( Context& refCtxt ) const override;
136 
138 
143  StatusCode previous( Context& refCtxt, int jump ) const override;
144 
146 
150  StatusCode rewind( Context& refCtxt ) const override;
151 
153 
158  StatusCode createAddress( const Context& refCtxt, IOpaqueAddress*& refpAddr ) const override;
159 
161 
165  StatusCode releaseContext( Context*& refCtxt ) const override;
166 
175  StatusCode resetCriteria( const std::string& cr, Context& c ) const override;
176 
182  StatusCode last( Context& refCtxt ) const override;
183 
185  virtual StatusCode connectCollection( MyContextType* ctxt ) const;
186 
188  virtual StatusCode connectDataSource( const std::string& db, const std::string& typ ) const;
190  virtual StatusCode connectTuple( const std::string& nam, const std::string& itName, NTuple::Tuple*& tup,
191  NTuple::Item<IOpaqueAddress*>*& item ) const;
193  virtual StatusCode connectStatement( const std::string& typ, const std::string& crit, INTuple* tuple ) const;
195  virtual StatusCode getNextRecord( NTuple::Tuple* tuple ) const;
197  virtual StatusCode getPreviousRecord( NTuple::Tuple* tuple ) const;
198 
200  using extends::extends;
201 };
202 
203 #endif // GAUDISVC_EventCollectionSelector_EventCollectionSelector_H
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:310
EventCollectionSelector::finalize
StatusCode finalize() override
Service override: Finalize Service.
Definition: EventCollectionSelector.cpp:212
EventCollectionSelector::m_dbType
Gaudi::Property< std::string > m_dbType
Definition: EventCollectionSelector.h:98
IAddressCreator
Definition: IAddressCreator.h:38
std::string
STL class.
EventCollectionSelector::connectDataSource
virtual StatusCode connectDataSource(const std::string &db, const std::string &typ) const
Connect collection's data source to selector.
Definition: EventCollectionSelector.cpp:95
EventCollectionSelector::MyContextType::criteria
std::string criteria
Definition: EventCollectionSelector.h:56
EventCollectionSelector::m_tupleSvc
SmartIF< INTupleSvc > m_tupleSvc
Reference to Tuple service.
Definition: EventCollectionSelector.h:87
IOpaqueAddress::addRef
virtual unsigned long addRef()=0
Add reference to object.
EventCollectionSelector::MyContextType::addressBuffer
IOpaqueAddress * addressBuffer
Definition: EventCollectionSelector.h:59
EventCollectionSelector::MyContextType
Definition: EventCollectionSelector.h:54
IOpaqueAddress
Definition: IOpaqueAddress.h:33
IEvtSelector
Definition: IEvtSelector.h:28
IOpaqueAddress::release
virtual unsigned long release()=0
release reference to object
EventCollectionSelector::m_database
Gaudi::Property< std::string > m_database
Definition: EventCollectionSelector.h:97
IEvtSelector.h
EventCollectionSelector::MyContextType::~MyContextType
~MyContextType() override
Definition: EventCollectionSelector.h:78
EventCollectionSelector::m_itemName
Gaudi::Property< std::string > m_itemName
Definition: EventCollectionSelector.h:95
gaudirun.c
c
Definition: gaudirun.py:525
IEvtSelector::Context
Definition: IEvtSelector.h:33
EventCollectionSelector::MyContextType::tuple
NTuple::Tuple * tuple
Definition: EventCollectionSelector.h:57
EventCollectionSelector::next
StatusCode next(Context &refCtxt) const override
Get next iteration item from the event loop context.
Definition: EventCollectionSelector.cpp:245
EventCollectionSelector::createAddress
StatusCode createAddress(const Context &refCtxt, IOpaqueAddress *&refpAddr) const override
Create new Opaque address corresponding to the current record.
Definition: EventCollectionSelector.cpp:278
EventCollectionSelector::initialize
StatusCode initialize() override
Service override: Initialize service.
Definition: EventCollectionSelector.cpp:73
GenericAddress.h
bug_34121.t
t
Definition: bug_34121.py:31
GenericAddress
Definition: GenericAddress.h:30
EventCollectionSelector::rewind
StatusCode rewind(Context &refCtxt) const override
Rewind the dataset.
Definition: EventCollectionSelector.cpp:275
EventCollectionSelector::m_pAddrCreator
SmartIF< IAddressCreator > m_pAddrCreator
Definition: EventCollectionSelector.h:88
StatusCode
Definition: StatusCode.h:65
NTuple.h
EventCollectionSelector::MyContextType::item
NTuple::Item< IOpaqueAddress * > * item
Definition: EventCollectionSelector.h:58
EventCollectionSelector::previous
StatusCode previous(Context &refCtxt) const override
Get previous iteration item from the event loop context.
Definition: EventCollectionSelector.cpp:260
EventCollectionSelector::MyContextType::MyContextType
MyContextType(NTuple::Tuple *t, NTuple::Item< IOpaqueAddress * > *i)
Definition: EventCollectionSelector.h:60
EventCollectionSelector::MyContextType::operator=
MyContextType & operator=(const MyContextType &)=delete
INTuple
Definition: INTuple.h:91
SmartIF< INTupleSvc >
EventCollectionSelector::getNextRecord
virtual StatusCode getNextRecord(NTuple::Tuple *tuple) const
Read next record of the N-tuple.
Definition: EventCollectionSelector.cpp:149
EventCollectionSelector::createContext
StatusCode createContext(Context *&refpCtxt) const override
Create a new event loop context.
Definition: EventCollectionSelector.cpp:232
EventCollectionSelector::MyContextType::setAddress
void setAddress(IOpaqueAddress *pAddr)
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
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:132
EventCollectionSelector::connectCollection
virtual StatusCode connectCollection(MyContextType *ctxt) const
Connect collection to selector.
Definition: EventCollectionSelector.cpp:193
EventCollectionSelector::MyContextType::MyContextType
MyContextType(const MyContextType &ctxt)
Definition: EventCollectionSelector.h:72
Service.h
EventIterator
Definition: EventCollectionSelector.h:36
EventCollectionSelector::getPreviousRecord
virtual StatusCode getPreviousRecord(NTuple::Tuple *tuple) const
Read next record of the N-tuple.
Definition: EventCollectionSelector.cpp:165
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:388
EventCollectionSelector::m_cntName
Gaudi::Property< std::string > m_cntName
Definition: EventCollectionSelector.h:94
EventCollectionSelector
Definition of class EventCollectionSelector.
Definition: EventCollectionSelector.h:52
EventCollectionSelector::m_dbSvc
Gaudi::Property< std::string > m_dbSvc
Definition: EventCollectionSelector.h:99
EventSelectorDataStream
Definition of class EventSelectorDataStream.
Definition: EventSelectorDataStream.h:55
EventCollectionSelector::MyContextType::MyContextType
MyContextType(MyContextType *ctxt=nullptr)
Definition: EventCollectionSelector.h:66
EventCollectionSelector::m_tupleSvcName
Gaudi::Property< std::string > m_tupleSvcName
Definition: EventCollectionSelector.h:91
INTupleSvc
Definition: INTupleSvc.h:46
EventCollectionSelector::connectTuple
virtual StatusCode connectTuple(const std::string &nam, const std::string &itName, NTuple::Tuple *&tup, NTuple::Item< IOpaqueAddress * > *&item) const
Connect to existing N-tuple.
Definition: EventCollectionSelector.cpp:113
EventCollectionSelector::m_criteria
Gaudi::Property< std::string > m_criteria
Definition: EventCollectionSelector.h:96
EventCollectionSelector::releaseContext
StatusCode releaseContext(Context *&refCtxt) const override
Release existing event iteration context.
Definition: EventCollectionSelector.cpp:298
EventCollectionSelector::last
StatusCode last(Context &refCtxt) const override
Access last item in the iteration.
Definition: EventCollectionSelector.cpp:320
EventCollectionSelector::MyContextType::identifier
void * identifier() const override
Definition: EventCollectionSelector.h:81
Gaudi::Property< std::string >
EventCollectionSelector::m_statement
Gaudi::Property< std::string > m_statement
Definition: EventCollectionSelector.h:100
EventCollectionSelector::m_authentication
Gaudi::Property< std::string > m_authentication
Definition: EventCollectionSelector.h:93
NTuple::Item< IOpaqueAddress * >