ATLAS Offline Software
EventSelectorMuonCalibStream.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 //====================================================================
5 // EventSelectorMuonCalibStream.cxx
6 // Event loop for calibration stream
7 //====================================================================
8 //
9 // Include files.
11 
13 #include "GaudiKernel/ClassID.h"
14 #include "GaudiKernel/ISvcLocator.h"
15 #include "GaudiKernel/StatusCode.h"
20 
21 // Constructor.
23  AthService(name, svcloc),
24  m_beginIter(nullptr),
25  m_endIter(nullptr),
26  m_eventSource(nullptr),
27  m_dataProvider(nullptr),
28  m_SkipEvents(0),
29  m_NumEvents(0) {
30  ATH_MSG_DEBUG("EventSelectorMuonCalibStream constructor");
31  m_eventSourceName = "MuonCalibStreamFileInputSvc";
32  m_SkipEvents = 0;
33  declareProperty("MuonCalibStreamInputSvc", m_eventSourceName);
34  declareProperty("SkipEvents", m_SkipEvents);
35 }
36 
37 // Destructor.
39  // if(m_eventSource) m_eventSource->release();
40  if (m_beginIter) delete m_beginIter;
41  if (m_endIter) delete m_endIter;
42 }
43 
44 // EventSelectorMuonCalibStream::initialize().
46  ATH_MSG_INFO("EventSelectorMuonCalibStream::initialize");
47  // Check MuonCalibStreamCnvSvc
48  IService *svc;
49  ATH_CHECK(serviceLocator()->getService(m_eventSourceName, svc));
50 
51  m_eventSource = dynamic_cast<MuonCalibStreamInputSvc *>(svc);
52  if (m_eventSource == 0) {
53  ATH_MSG_ERROR("Cannot cast to MuonCalibStreamInputSvc");
54  return StatusCode::FAILURE;
55  }
56  m_eventSource->addRef();
57 
58  ATH_CHECK(service("MuonCalibStreamDataProviderSvc", m_dataProvider));
59 
60  // Create the begin and end iterators for this selector.
62  // increment to get the new event in.
63  // ++(*m_beginIter); ???
65 
66  return StatusCode::SUCCESS;
67 }
68 
70  it = new EventContextMuonCalibStream(this);
71  return (StatusCode::SUCCESS);
72 }
73 
74 // Implementation of IEvtSelector::next().
75 StatusCode EventSelectorMuonCalibStream::next(IEvtSelector::Context &it) const {
76  ATH_MSG_DEBUG(" EventSelectorMuonCalibStream::next m_NumEvents=" << m_NumEvents);
77  for (;;) {
78  const LVL2_MUON_CALIBRATION::CalibEvent *pre = m_eventSource->nextEvent();
79  if (!pre) {
80  // End of file
81  it = *m_endIter;
82  return StatusCode::FAILURE;
83  }
84  ++m_NumEvents;
85 
86  // Check if we are skipping events
87  if (m_NumEvents > m_SkipEvents) {
88  break;
89  } else {
90  ATH_MSG_DEBUG(" Skipping event " << m_NumEvents - 1);
91  }
92  }
93 
94  return StatusCode::SUCCESS;
95 }
96 
97 // Implementation of IEvtSelector::next() with a "jump" parameter
98 // (to skip over a certain number of events?)
99 StatusCode EventSelectorMuonCalibStream::next(IEvtSelector::Context &ctxt, int jump) const {
100  ATH_MSG_DEBUG(" EventSelectorMuonCalibStream::next skipping events ==" << jump);
101  if (jump > 0) {
102  for (int i = 0; i < jump; ++i) {
103  StatusCode status = next(ctxt);
104  if (!status.isSuccess()) { return status; }
105  }
106  return StatusCode::SUCCESS;
107  }
108  return StatusCode::FAILURE;
109 }
110 
111 //________________________________________________________________________________
112 StatusCode EventSelectorMuonCalibStream::previous(IEvtSelector::Context & /*it*/) const {
113  ATH_MSG_ERROR("EventSelectorMuonCalibStream::previous() not implemented");
114  return (StatusCode::FAILURE);
115 }
116 
117 //________________________________________________________________________________
118 StatusCode EventSelectorMuonCalibStream::previous(IEvtSelector::Context &it, int /*jump*/) const { return (previous(it)); }
119 
120 //________________________________________________________________________________
121 StatusCode EventSelectorMuonCalibStream::last(IEvtSelector::Context &it) const {
122  if (it.identifier() == m_endIter->identifier()) {
123  ATH_MSG_DEBUG("last(): Last event in InputStream.");
124  return (StatusCode::SUCCESS);
125  }
126  return (StatusCode::FAILURE);
127 }
128 
129 //________________________________________________________________________________
130 StatusCode EventSelectorMuonCalibStream::resetCriteria(const std::string & /*criteria*/, IEvtSelector::Context & /*ctxt*/) const {
131  return (StatusCode::SUCCESS);
132 }
133 
134 //________________________________________________________________________________
135 StatusCode EventSelectorMuonCalibStream::rewind(IEvtSelector::Context & /*it*/) const {
136  ATH_MSG_ERROR("EventSelectorMuonCalibStream::rewind() not implemented");
137  return (StatusCode::FAILURE);
138 }
139 
140 //________________________________________________________________________________
141 StatusCode EventSelectorMuonCalibStream::createAddress(const IEvtSelector::Context & /*it*/, IOpaqueAddress *&iop) const {
142  ATH_MSG_DEBUG("EventSelectorMuonCalibStream::createAddress");
143  const LVL2_MUON_CALIBRATION::CalibEvent *pre = m_eventSource->currentEvent();
145  ATH_MSG_DEBUG("Calib Event cached in Data Provider ");
146 
147  iop = new MuonCalibStreamAddress(ClassID_traits<xAOD::EventInfo>::ID(), "EventInfo", ""); // change to xAOD::EventInfo key
148  //iop = new MuonCalibStreamAddress(ClassID_traits<xAOD::EventInfo>::ID(), "MuonCalibStreamEventInfo", ""); // old key which need the conversion afterwards
149  ATH_MSG_DEBUG("MuonCalibStreamAddress for MuonCalibStreamEventInfo created ");
150 
151  return (StatusCode::SUCCESS);
152 }
153 
154 //________________________________________________________________________________
155 StatusCode EventSelectorMuonCalibStream::releaseContext(IEvtSelector::Context *& /*it*/) const { return (StatusCode::SUCCESS); }
156 
157 // Implementation of IInterface::queryInterface.
158 StatusCode EventSelectorMuonCalibStream::queryInterface(const InterfaceID &riid, void **ppvInterface) {
159  if (riid == IEvtSelector::interfaceID()) {
160  *ppvInterface = (IEvtSelector *)this;
161  } else if (riid == IProperty::interfaceID()) {
162  *ppvInterface = (IProperty *)this;
163  } else {
164  return AthService::queryInterface(riid, ppvInterface);
165  }
166 
167  addRef();
168  return StatusCode::SUCCESS;
169 }
MuonCalibStreamAddress.h
EventSelectorMuonCalibStream::createContext
virtual StatusCode createContext(Context *&it) const
Definition: EventSelectorMuonCalibStream.cxx:69
EventSelectorMuonCalibStream::next
virtual StatusCode next(Context &it) const
Definition: EventSelectorMuonCalibStream.cxx:75
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
IMuonCalibStreamDataProviderSvc.h
skel.it
it
Definition: skel.GENtoEVGEN.py:423
MuonCalibStreamInputSvc::currentEvent
virtual const LVL2_MUON_CALIBRATION::CalibEvent * currentEvent() const =0
EventSelectorMuonCalibStream::m_eventSource
MuonCalibStreamInputSvc * m_eventSource
Definition: EventSelectorMuonCalibStream.h:61
EventSelectorMuonCalibStream::releaseContext
virtual StatusCode releaseContext(Context *&it) const
Definition: EventSelectorMuonCalibStream.cxx:155
EventSelectorMuonCalibStream::initialize
virtual StatusCode initialize()
Definition: EventSelectorMuonCalibStream.cxx:45
EventSelectorMuonCalibStream::previous
virtual StatusCode previous(Context &it) const
Definition: EventSelectorMuonCalibStream.cxx:112
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
EventSelectorMuonCalibStream::rewind
virtual StatusCode rewind(Context &it) const
Definition: EventSelectorMuonCalibStream.cxx:135
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
EventSelectorMuonCalibStream::~EventSelectorMuonCalibStream
~EventSelectorMuonCalibStream()
Definition: EventSelectorMuonCalibStream.cxx:38
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthService
Definition: AthService.h:32
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
EventSelectorMuonCalibStream::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface)
Definition: EventSelectorMuonCalibStream.cxx:158
EventSelectorMuonCalibStream::m_eventSourceName
string m_eventSourceName
Definition: EventSelectorMuonCalibStream.h:58
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
EventSelectorMuonCalibStream::last
virtual StatusCode last(Context &it) const
Definition: EventSelectorMuonCalibStream.cxx:121
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
MuonCalibStreamInputSvc.h
EventSelectorMuonCalibStream::m_beginIter
EventContextMuonCalibStream * m_beginIter
Definition: EventSelectorMuonCalibStream.h:59
EventSelectorMuonCalibStream.h
EventSelectorMuonCalibStream::EventSelectorMuonCalibStream
EventSelectorMuonCalibStream(const string &name, ISvcLocator *svcloc)
Definition: EventSelectorMuonCalibStream.cxx:22
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
EventContextMuonCalibStream::identifier
virtual void * identifier() const
Inequality operator.
Definition: EventContextMuonCalibStream.cxx:25
EventSelectorMuonCalibStream::m_endIter
EventContextMuonCalibStream * m_endIter
Definition: EventSelectorMuonCalibStream.h:60
EventInfo.h
IMuonCalibStreamDataProviderSvc::setNextEvent
virtual void setNextEvent(const LVL2_MUON_CALIBRATION::CalibEvent *re)=0
EventSelectorMuonCalibStream::m_SkipEvents
int m_SkipEvents
Definition: EventSelectorMuonCalibStream.h:64
MuonCalibStreamInputSvc
Definition: MuonCalibStreamInputSvc.h:16
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
EventSelectorMuonCalibStream::m_dataProvider
IMuonCalibStreamDataProviderSvc * m_dataProvider
Definition: EventSelectorMuonCalibStream.h:62
EventSelectorMuonCalibStream::resetCriteria
virtual StatusCode resetCriteria(const std::string &criteria, Context &context) const
Definition: EventSelectorMuonCalibStream.cxx:130
merge.status
status
Definition: merge.py:17
EventSelectorMuonCalibStream::createAddress
virtual StatusCode createAddress(const Context &it, IOpaqueAddress *&iop) const
Definition: EventSelectorMuonCalibStream.cxx:141
MuonCalibStreamAddress
Definition: MuonCalibStreamAddress.h:14
EventContextMuonCalibStream
This class provides the Context for EventSelectorMuonCalibStream.
Definition: EventContextMuonCalibStream.h:23
EventContextMuonCalibStream.h
This file contains the class definition for the EventContextMuonCalibStream class.
MuonCalibStreamInputSvc::nextEvent
virtual const LVL2_MUON_CALIBRATION::CalibEvent * nextEvent()=0